diff options
Diffstat (limited to 'drivers/hwmon/w83627hf.c')
-rw-r--r-- | drivers/hwmon/w83627hf.c | 46 |
1 files changed, 16 insertions, 30 deletions
diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c index 5ce54a297249..ab4825205a9d 100644 --- a/drivers/hwmon/w83627hf.c +++ b/drivers/hwmon/w83627hf.c | |||
@@ -1359,19 +1359,17 @@ static int __devinit w83627hf_probe(struct platform_device *pdev) | |||
1359 | }; | 1359 | }; |
1360 | 1360 | ||
1361 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); | 1361 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); |
1362 | if (!request_region(res->start, WINB_REGION_SIZE, DRVNAME)) { | 1362 | if (!devm_request_region(dev, res->start, WINB_REGION_SIZE, DRVNAME)) { |
1363 | dev_err(dev, "Failed to request region 0x%lx-0x%lx\n", | 1363 | dev_err(dev, "Failed to request region 0x%lx-0x%lx\n", |
1364 | (unsigned long)res->start, | 1364 | (unsigned long)res->start, |
1365 | (unsigned long)(res->start + WINB_REGION_SIZE - 1)); | 1365 | (unsigned long)(res->start + WINB_REGION_SIZE - 1)); |
1366 | err = -EBUSY; | 1366 | return -EBUSY; |
1367 | goto ERROR0; | ||
1368 | } | 1367 | } |
1369 | 1368 | ||
1370 | data = kzalloc(sizeof(struct w83627hf_data), GFP_KERNEL); | 1369 | data = devm_kzalloc(dev, sizeof(struct w83627hf_data), GFP_KERNEL); |
1371 | if (!data) { | 1370 | if (!data) |
1372 | err = -ENOMEM; | 1371 | return -ENOMEM; |
1373 | goto ERROR1; | 1372 | |
1374 | } | ||
1375 | data->addr = res->start; | 1373 | data->addr = res->start; |
1376 | data->type = sio_data->type; | 1374 | data->type = sio_data->type; |
1377 | data->name = names[sio_data->type]; | 1375 | data->name = names[sio_data->type]; |
@@ -1391,7 +1389,7 @@ static int __devinit w83627hf_probe(struct platform_device *pdev) | |||
1391 | /* Register common device attributes */ | 1389 | /* Register common device attributes */ |
1392 | err = sysfs_create_group(&dev->kobj, &w83627hf_group); | 1390 | err = sysfs_create_group(&dev->kobj, &w83627hf_group); |
1393 | if (err) | 1391 | if (err) |
1394 | goto ERROR3; | 1392 | return err; |
1395 | 1393 | ||
1396 | /* Register chip-specific device attributes */ | 1394 | /* Register chip-specific device attributes */ |
1397 | if (data->type == w83627hf || data->type == w83697hf) | 1395 | if (data->type == w83627hf || data->type == w83697hf) |
@@ -1419,7 +1417,7 @@ static int __devinit w83627hf_probe(struct platform_device *pdev) | |||
1419 | &sensor_dev_attr_pwm1_freq.dev_attr)) | 1417 | &sensor_dev_attr_pwm1_freq.dev_attr)) |
1420 | || (err = device_create_file(dev, | 1418 | || (err = device_create_file(dev, |
1421 | &sensor_dev_attr_pwm2_freq.dev_attr))) | 1419 | &sensor_dev_attr_pwm2_freq.dev_attr))) |
1422 | goto ERROR4; | 1420 | goto error; |
1423 | 1421 | ||
1424 | if (data->type != w83697hf) | 1422 | if (data->type != w83697hf) |
1425 | if ((err = device_create_file(dev, | 1423 | if ((err = device_create_file(dev, |
@@ -1454,7 +1452,7 @@ static int __devinit w83627hf_probe(struct platform_device *pdev) | |||
1454 | &sensor_dev_attr_temp3_beep.dev_attr)) | 1452 | &sensor_dev_attr_temp3_beep.dev_attr)) |
1455 | || (err = device_create_file(dev, | 1453 | || (err = device_create_file(dev, |
1456 | &sensor_dev_attr_temp3_type.dev_attr))) | 1454 | &sensor_dev_attr_temp3_type.dev_attr))) |
1457 | goto ERROR4; | 1455 | goto error; |
1458 | 1456 | ||
1459 | if (data->type != w83697hf && data->vid != 0xff) { | 1457 | if (data->type != w83697hf && data->vid != 0xff) { |
1460 | /* Convert VID to voltage based on VRM */ | 1458 | /* Convert VID to voltage based on VRM */ |
@@ -1462,14 +1460,14 @@ static int __devinit w83627hf_probe(struct platform_device *pdev) | |||
1462 | 1460 | ||
1463 | if ((err = device_create_file(dev, &dev_attr_cpu0_vid)) | 1461 | if ((err = device_create_file(dev, &dev_attr_cpu0_vid)) |
1464 | || (err = device_create_file(dev, &dev_attr_vrm))) | 1462 | || (err = device_create_file(dev, &dev_attr_vrm))) |
1465 | goto ERROR4; | 1463 | goto error; |
1466 | } | 1464 | } |
1467 | 1465 | ||
1468 | if (data->type == w83627thf || data->type == w83637hf | 1466 | if (data->type == w83627thf || data->type == w83637hf |
1469 | || data->type == w83687thf) { | 1467 | || data->type == w83687thf) { |
1470 | err = device_create_file(dev, &sensor_dev_attr_pwm3.dev_attr); | 1468 | err = device_create_file(dev, &sensor_dev_attr_pwm3.dev_attr); |
1471 | if (err) | 1469 | if (err) |
1472 | goto ERROR4; | 1470 | goto error; |
1473 | } | 1471 | } |
1474 | 1472 | ||
1475 | if (data->type == w83637hf || data->type == w83687thf) | 1473 | if (data->type == w83637hf || data->type == w83687thf) |
@@ -1479,57 +1477,45 @@ static int __devinit w83627hf_probe(struct platform_device *pdev) | |||
1479 | &sensor_dev_attr_pwm2_freq.dev_attr)) | 1477 | &sensor_dev_attr_pwm2_freq.dev_attr)) |
1480 | || (err = device_create_file(dev, | 1478 | || (err = device_create_file(dev, |
1481 | &sensor_dev_attr_pwm3_freq.dev_attr))) | 1479 | &sensor_dev_attr_pwm3_freq.dev_attr))) |
1482 | goto ERROR4; | 1480 | goto error; |
1483 | 1481 | ||
1484 | if (data->type != w83627hf) | 1482 | if (data->type != w83627hf) |
1485 | if ((err = device_create_file(dev, | 1483 | if ((err = device_create_file(dev, |
1486 | &sensor_dev_attr_pwm1_enable.dev_attr)) | 1484 | &sensor_dev_attr_pwm1_enable.dev_attr)) |
1487 | || (err = device_create_file(dev, | 1485 | || (err = device_create_file(dev, |
1488 | &sensor_dev_attr_pwm2_enable.dev_attr))) | 1486 | &sensor_dev_attr_pwm2_enable.dev_attr))) |
1489 | goto ERROR4; | 1487 | goto error; |
1490 | 1488 | ||
1491 | if (data->type == w83627thf || data->type == w83637hf | 1489 | if (data->type == w83627thf || data->type == w83637hf |
1492 | || data->type == w83687thf) { | 1490 | || data->type == w83687thf) { |
1493 | err = device_create_file(dev, | 1491 | err = device_create_file(dev, |
1494 | &sensor_dev_attr_pwm3_enable.dev_attr); | 1492 | &sensor_dev_attr_pwm3_enable.dev_attr); |
1495 | if (err) | 1493 | if (err) |
1496 | goto ERROR4; | 1494 | goto error; |
1497 | } | 1495 | } |
1498 | 1496 | ||
1499 | data->hwmon_dev = hwmon_device_register(dev); | 1497 | data->hwmon_dev = hwmon_device_register(dev); |
1500 | if (IS_ERR(data->hwmon_dev)) { | 1498 | if (IS_ERR(data->hwmon_dev)) { |
1501 | err = PTR_ERR(data->hwmon_dev); | 1499 | err = PTR_ERR(data->hwmon_dev); |
1502 | goto ERROR4; | 1500 | goto error; |
1503 | } | 1501 | } |
1504 | 1502 | ||
1505 | return 0; | 1503 | return 0; |
1506 | 1504 | ||
1507 | ERROR4: | 1505 | error: |
1508 | sysfs_remove_group(&dev->kobj, &w83627hf_group); | 1506 | sysfs_remove_group(&dev->kobj, &w83627hf_group); |
1509 | sysfs_remove_group(&dev->kobj, &w83627hf_group_opt); | 1507 | sysfs_remove_group(&dev->kobj, &w83627hf_group_opt); |
1510 | ERROR3: | ||
1511 | platform_set_drvdata(pdev, NULL); | ||
1512 | kfree(data); | ||
1513 | ERROR1: | ||
1514 | release_region(res->start, WINB_REGION_SIZE); | ||
1515 | ERROR0: | ||
1516 | return err; | 1508 | return err; |
1517 | } | 1509 | } |
1518 | 1510 | ||
1519 | static int __devexit w83627hf_remove(struct platform_device *pdev) | 1511 | static int __devexit w83627hf_remove(struct platform_device *pdev) |
1520 | { | 1512 | { |
1521 | struct w83627hf_data *data = platform_get_drvdata(pdev); | 1513 | struct w83627hf_data *data = platform_get_drvdata(pdev); |
1522 | struct resource *res; | ||
1523 | 1514 | ||
1524 | hwmon_device_unregister(data->hwmon_dev); | 1515 | hwmon_device_unregister(data->hwmon_dev); |
1525 | 1516 | ||
1526 | sysfs_remove_group(&pdev->dev.kobj, &w83627hf_group); | 1517 | sysfs_remove_group(&pdev->dev.kobj, &w83627hf_group); |
1527 | sysfs_remove_group(&pdev->dev.kobj, &w83627hf_group_opt); | 1518 | sysfs_remove_group(&pdev->dev.kobj, &w83627hf_group_opt); |
1528 | platform_set_drvdata(pdev, NULL); | ||
1529 | kfree(data); | ||
1530 | |||
1531 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); | ||
1532 | release_region(res->start, WINB_REGION_SIZE); | ||
1533 | 1519 | ||
1534 | return 0; | 1520 | return 0; |
1535 | } | 1521 | } |