diff options
author | Guenter Roeck <linux@roeck-us.net> | 2012-03-24 21:54:41 -0700 |
---|---|---|
committer | Guenter Roeck <guenter.roeck@ericsson.com> | 2012-05-22 06:48:48 -0700 |
commit | 62a1d05f0ecf9c6a376bbe310718ed76582496a2 (patch) | |
tree | fc2d5c04a7ba8c96eb55f34f3bc88be90bb7d8d7 /drivers/hwmon | |
parent | f7c2fe386ae92b471a0edd4fa4bed7033224b9bf (diff) |
hwmon: (it87) Convert to use devm_kzalloc and devm_request_region
This makes the code a bit simpler and smaller.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r-- | drivers/hwmon/it87.c | 54 |
1 files changed, 20 insertions, 34 deletions
diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c index bef8732f08b1..071dd60f1c82 100644 --- a/drivers/hwmon/it87.c +++ b/drivers/hwmon/it87.c @@ -1965,19 +1965,17 @@ static int __devinit it87_probe(struct platform_device *pdev) }; res = platform_get_resource(pdev, IORESOURCE_IO, 0); - if (!request_region(res->start, IT87_EC_EXTENT, DRVNAME)) { + if (!devm_request_region(&pdev->dev, res->start, IT87_EC_EXTENT, + DRVNAME)) { dev_err(dev, "Failed to request region 0x%lx-0x%lx\n", (unsigned long)res->start, (unsigned long)(res->start + IT87_EC_EXTENT - 1)); - err = -EBUSY; - goto ERROR0; + return -EBUSY; } - data = kzalloc(sizeof(struct it87_data), GFP_KERNEL); - if (!data) { - err = -ENOMEM; - goto ERROR1; - } + data = devm_kzalloc(&pdev->dev, sizeof(struct it87_data), GFP_KERNEL); + if (!data) + return -ENOMEM; data->addr = res->start; data->type = sio_data->type; @@ -1986,10 +1984,8 @@ static int __devinit it87_probe(struct platform_device *pdev) /* Now, we do the remaining detection. */ if ((it87_read_value(data, IT87_REG_CONFIG) & 0x80) - || it87_read_value(data, IT87_REG_CHIPID) != 0x90) { - err = -ENODEV; - goto ERROR2; - } + || it87_read_value(data, IT87_REG_CHIPID) != 0x90) + return -ENODEV; platform_set_drvdata(pdev, data); @@ -2019,26 +2015,26 @@ static int __devinit it87_probe(struct platform_device *pdev) /* Register sysfs hooks */ err = sysfs_create_group(&dev->kobj, &it87_group); if (err) - goto ERROR2; + return err; for (i = 0; i < 9; i++) { if (sio_data->skip_in & (1 << i)) continue; err = sysfs_create_group(&dev->kobj, &it87_group_in[i]); if (err) - goto ERROR4; + goto error; if (sio_data->beep_pin && it87_attributes_in_beep[i]) { err = sysfs_create_file(&dev->kobj, it87_attributes_in_beep[i]); if (err) - goto ERROR4; + goto error; } } if (sio_data->beep_pin) { err = sysfs_create_group(&dev->kobj, &it87_group_beep); if (err) - goto ERROR4; + goto error; } /* Do not create fan files for disabled fans */ @@ -2049,13 +2045,13 @@ static int __devinit it87_probe(struct platform_device *pdev) continue; err = sysfs_create_group(&dev->kobj, &fan_group[i]); if (err) - goto ERROR4; + goto error; if (sio_data->beep_pin) { err = sysfs_create_file(&dev->kobj, it87_attributes_fan_beep[i]); if (err) - goto ERROR4; + goto error; if (!fan_beep_need_rw) continue; @@ -2080,14 +2076,14 @@ static int __devinit it87_probe(struct platform_device *pdev) err = sysfs_create_group(&dev->kobj, &it87_group_pwm[i]); if (err) - goto ERROR4; + goto error; if (!has_old_autopwm(data)) continue; err = sysfs_create_group(&dev->kobj, &it87_group_autopwm[i]); if (err) - goto ERROR4; + goto error; } } @@ -2097,7 +2093,7 @@ static int __devinit it87_probe(struct platform_device *pdev) data->vid = sio_data->vid_value; err = sysfs_create_group(&dev->kobj, &it87_group_vid); if (err) - goto ERROR4; + goto error; } /* Export labels for internal sensors */ @@ -2107,25 +2103,19 @@ static int __devinit it87_probe(struct platform_device *pdev) err = sysfs_create_file(&dev->kobj, it87_attributes_label[i]); if (err) - goto ERROR4; + goto error; } data->hwmon_dev = hwmon_device_register(dev); if (IS_ERR(data->hwmon_dev)) { err = PTR_ERR(data->hwmon_dev); - goto ERROR4; + goto error; } return 0; -ERROR4: +error: it87_remove_files(dev); -ERROR2: - platform_set_drvdata(pdev, NULL); - kfree(data); -ERROR1: - release_region(res->start, IT87_EC_EXTENT); -ERROR0: return err; } @@ -2136,10 +2126,6 @@ static int __devexit it87_remove(struct platform_device *pdev) hwmon_device_unregister(data->hwmon_dev); it87_remove_files(&pdev->dev); - release_region(data->addr, IT87_EC_EXTENT); - platform_set_drvdata(pdev, NULL); - kfree(data); - return 0; } |