[lm-sensors] [PATCH v2 3/3] hwmon: (it87) Convert to use devm_kzalloc
Guenter Roeck
linux at roeck-us.net
Sun Mar 25 07:00:33 CEST 2012
This makes the code a bit simpler and smaller.
Signed-off-by: Guenter Roeck <linux at roeck-us.net>
---
drivers/hwmon/it87.c | 10 ++--------
1 files changed, 2 insertions(+), 8 deletions(-)
diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c
index 7dc4e48..e663638 100644
--- a/drivers/hwmon/it87.c
+++ b/drivers/hwmon/it87.c
@@ -1966,7 +1966,7 @@ static int __devinit it87_probe(struct platform_device *pdev)
goto ERROR0;
}
- data = kzalloc(sizeof(struct it87_data), GFP_KERNEL);
+ data = devm_kzalloc(&pdev->dev, sizeof(struct it87_data), GFP_KERNEL);
if (!data) {
err = -ENOMEM;
goto ERROR1;
@@ -1981,7 +1981,7 @@ static int __devinit it87_probe(struct platform_device *pdev)
if ((it87_read_value(data, IT87_REG_CONFIG) & 0x80)
|| it87_read_value(data, IT87_REG_CHIPID) != 0x90) {
err = -ENODEV;
- goto ERROR2;
+ goto ERROR1;
}
platform_set_drvdata(pdev, data);
@@ -2113,9 +2113,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:
@@ -2130,9 +2127,6 @@ static int __devexit it87_remove(struct platform_device *pdev)
it87_remove_files(&pdev->dev);
release_region(data->addr, IT87_EC_EXTENT);
- platform_set_drvdata(pdev, NULL);
- kfree(data);
-
return 0;
}
--
1.7.5.4
More information about the lm-sensors
mailing list