Skip to contentSkip to conversation

hwmon: (it87) Convert to use devm_kzalloc

PATCH In review Guenter Roeck 1 participant 1 message Mar 25, 2012

Subsystems (2)
lore
Share & tools
lore

Guenter Roeck

author maintainer
#0 lore raw

PATCH v2 3/3 hwmon: (it87) Convert to use devm_kzalloc

This makes the code a bit simpler and smaller.

---
 drivers/hwmon/it87.c |   10 ++--------
 1 files changed, 2 insertions(+), 8 deletions(-)
drivers/hwmon/it87.c +2 -8
index 7dc4e48..e663638 100644
@@ -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;
 }
 
Signature · 7 lines
1.7.5.4


_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors