aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/f71805f.c
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2012-06-02 12:58:05 -0400
committerGuenter Roeck <linux@roeck-us.net>2012-07-22 00:48:38 -0400
commitadc1413279d124e0940a314ccabebbbee159fd8f (patch)
tree5b7973361635e5eda15110f54e5128547eb377a2 /drivers/hwmon/f71805f.c
parent7b7bb90ca37914556c50947c4fcc09a9333cb9b6 (diff)
hwmon: (f71805f) Convert to use devm_ functions
Convert to use devm_ functions to reduce code size and simplify the code. Cc: Jean Delvare <khali@linux-fr.org> Signed-off-by: Guenter Roeck <linux@roeck-us.net> Acked-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/hwmon/f71805f.c')
-rw-r--r--drivers/hwmon/f71805f.c26
1 files changed, 7 insertions, 19 deletions
diff --git a/drivers/hwmon/f71805f.c b/drivers/hwmon/f71805f.c
index 3e4da620e9c7..4dd7723d257f 100644
--- a/drivers/hwmon/f71805f.c
+++ b/drivers/hwmon/f71805f.c
@@ -1386,20 +1386,20 @@ static int __devinit f71805f_probe(struct platform_device *pdev)
1386 "f71872f", 1386 "f71872f",
1387 }; 1387 };
1388 1388
1389 data = kzalloc(sizeof(struct f71805f_data), GFP_KERNEL); 1389 data = devm_kzalloc(&pdev->dev, sizeof(struct f71805f_data),
1390 GFP_KERNEL);
1390 if (!data) { 1391 if (!data) {
1391 err = -ENOMEM;
1392 pr_err("Out of memory\n"); 1392 pr_err("Out of memory\n");
1393 goto exit; 1393 return -ENOMEM;
1394 } 1394 }
1395 1395
1396 res = platform_get_resource(pdev, IORESOURCE_IO, 0); 1396 res = platform_get_resource(pdev, IORESOURCE_IO, 0);
1397 if (!request_region(res->start + ADDR_REG_OFFSET, 2, DRVNAME)) { 1397 if (!devm_request_region(&pdev->dev, res->start + ADDR_REG_OFFSET, 2,
1398 err = -EBUSY; 1398 DRVNAME)) {
1399 dev_err(&pdev->dev, "Failed to request region 0x%lx-0x%lx\n", 1399 dev_err(&pdev->dev, "Failed to request region 0x%lx-0x%lx\n",
1400 (unsigned long)(res->start + ADDR_REG_OFFSET), 1400 (unsigned long)(res->start + ADDR_REG_OFFSET),
1401 (unsigned long)(res->start + ADDR_REG_OFFSET + 1)); 1401 (unsigned long)(res->start + ADDR_REG_OFFSET + 1));
1402 goto exit_free; 1402 return -EBUSY;
1403 } 1403 }
1404 data->addr = res->start; 1404 data->addr = res->start;
1405 data->name = names[sio_data->kind]; 1405 data->name = names[sio_data->kind];
@@ -1427,7 +1427,7 @@ static int __devinit f71805f_probe(struct platform_device *pdev)
1427 /* Register sysfs interface files */ 1427 /* Register sysfs interface files */
1428 err = sysfs_create_group(&pdev->dev.kobj, &f71805f_group); 1428 err = sysfs_create_group(&pdev->dev.kobj, &f71805f_group);
1429 if (err) 1429 if (err)
1430 goto exit_release_region; 1430 return err;
1431 if (data->has_in & (1 << 4)) { /* in4 */ 1431 if (data->has_in & (1 << 4)) { /* in4 */
1432 err = sysfs_create_group(&pdev->dev.kobj, 1432 err = sysfs_create_group(&pdev->dev.kobj,
1433 &f71805f_group_optin[0]); 1433 &f71805f_group_optin[0]);
@@ -1487,19 +1487,12 @@ exit_remove_files:
1487 for (i = 0; i < 4; i++) 1487 for (i = 0; i < 4; i++)
1488 sysfs_remove_group(&pdev->dev.kobj, &f71805f_group_optin[i]); 1488 sysfs_remove_group(&pdev->dev.kobj, &f71805f_group_optin[i]);
1489 sysfs_remove_group(&pdev->dev.kobj, &f71805f_group_pwm_freq); 1489 sysfs_remove_group(&pdev->dev.kobj, &f71805f_group_pwm_freq);
1490exit_release_region:
1491 release_region(res->start + ADDR_REG_OFFSET, 2);
1492exit_free:
1493 platform_set_drvdata(pdev, NULL);
1494 kfree(data);
1495exit:
1496 return err; 1490 return err;
1497} 1491}
1498 1492
1499static int __devexit f71805f_remove(struct platform_device *pdev) 1493static int __devexit f71805f_remove(struct platform_device *pdev)
1500{ 1494{
1501 struct f71805f_data *data = platform_get_drvdata(pdev); 1495 struct f71805f_data *data = platform_get_drvdata(pdev);
1502 struct resource *res;
1503 int i; 1496 int i;
1504 1497
1505 hwmon_device_unregister(data->hwmon_dev); 1498 hwmon_device_unregister(data->hwmon_dev);
@@ -1507,11 +1500,6 @@ static int __devexit f71805f_remove(struct platform_device *pdev)
1507 for (i = 0; i < 4; i++) 1500 for (i = 0; i < 4; i++)
1508 sysfs_remove_group(&pdev->dev.kobj, &f71805f_group_optin[i]); 1501 sysfs_remove_group(&pdev->dev.kobj, &f71805f_group_optin[i]);
1509 sysfs_remove_group(&pdev->dev.kobj, &f71805f_group_pwm_freq); 1502 sysfs_remove_group(&pdev->dev.kobj, &f71805f_group_pwm_freq);
1510 platform_set_drvdata(pdev, NULL);
1511 kfree(data);
1512
1513 res = platform_get_resource(pdev, IORESOURCE_IO, 0);
1514 release_region(res->start + ADDR_REG_OFFSET, 2);
1515 1503
1516 return 0; 1504 return 0;
1517} 1505}