hwmon: (it87) Convert to use devm_kzalloc and devm_request_region
Subsystems (2)
PATCH v2 1/1 hwmon: (it87) Convert to use devm_kzalloc and devm_request_region
From: Guenter Roeck <[email protected]>
This makes the code a bit simpler and smaller.
---
v2: Also convert devm_request_region for further simplification
drivers/hwmon/it87.c | 32 +++++++++----------------------- 1 files changed, 9 insertions(+), 23 deletions(-)
drivers/hwmon/it87.c +9 -23
@@ -1968,19 +1968,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;
@@ -1989,10 +1987,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);
@@ -2022,7 +2018,7 @@ 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))
@@ -2123,12 +2119,6 @@ static int __devinit it87_probe(struct platform_device *pdev) ERROR4:it87_remove_files (dev); -ERROR2: -platform_set_drvdata (pdev,NULL ); -kfree (data); -ERROR1: -release_region (res->start,IT87_EC_EXTENT ); -ERROR0:return err; }
@@ -2139,10 +2129,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 ; }
Signature · 7 lines
1.7.9.48.g85da4d _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 11 lines · Guenter Roeck
From: Guenter Roeck <[email protected]>
This makes the code a bit simpler and smaller.
Signed-off-by Guenter Roeck <[email protected]>---
v2: Also convertdevm_request_regionfor further simplificationdrivers/hwmon/it87.c | 32 +++++++++----------------------- 1 files changed, 9 insertions(+), 23 deletions(-)(...)
Looks good.
It might make sense to rename ERROR4 to something more meaningful? With only this label remaining, the name looks obscure.
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 13 lines · Jean Delvare
Quoted 11 lines · Guenter Roeck
From: Guenter Roeck <[email protected]>
This makes the code a bit simpler and smaller.
Signed-off-by Guenter Roeck <[email protected]>---
v2: Also convertdevm_request_regionfor further simplificationdrivers/hwmon/it87.c | 32 +++++++++----------------------- 1 files changed, 9 insertions(+), 23 deletions(-)(...)
Quoted 7 lines
Looks good.
Acked-by Jean Delvare <[email protected]>It might make sense to rename ERROR4 to something more meaningful? With only this label remaining, the name looks obscure.
Makes sense. I'll do s/ERROR4/error/.
Thanks,
Guenter
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors