aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2012-06-02 14:35:54 -0400
committerGuenter Roeck <linux@roeck-us.net>2012-07-22 00:48:42 -0400
commit84269edce742e20a97b29619d3b9163a45a2a244 (patch)
treef66c409b59387c8b9bad56badb973306541093ff
parentfd55bc009aeed6265841d4c07d317ec2e557db03 (diff)
hwmon: (vt1211) Convert to use devm_ functions
Convert to use devm_ functions to reduce code size and simplify the code. Cc: Juerg Haefliger <juergh@gmail.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net> Acked-by: Jean Delvare <khali@linux-fr.org>
-rw-r--r--drivers/hwmon/vt1211.c22
1 files changed, 5 insertions, 17 deletions
diff --git a/drivers/hwmon/vt1211.c b/drivers/hwmon/vt1211.c
index c2c5c72fb8f0..f2c61153dba9 100644
--- a/drivers/hwmon/vt1211.c
+++ b/drivers/hwmon/vt1211.c
@@ -1148,19 +1148,18 @@ static int __devinit vt1211_probe(struct platform_device *pdev)
1148 struct resource *res; 1148 struct resource *res;
1149 int i, err; 1149 int i, err;
1150 1150
1151 data = kzalloc(sizeof(struct vt1211_data), GFP_KERNEL); 1151 data = devm_kzalloc(dev, sizeof(struct vt1211_data), GFP_KERNEL);
1152 if (!data) { 1152 if (!data) {
1153 err = -ENOMEM;
1154 dev_err(dev, "Out of memory\n"); 1153 dev_err(dev, "Out of memory\n");
1155 goto EXIT; 1154 return -ENOMEM;
1156 } 1155 }
1157 1156
1158 res = platform_get_resource(pdev, IORESOURCE_IO, 0); 1157 res = platform_get_resource(pdev, IORESOURCE_IO, 0);
1159 if (!request_region(res->start, resource_size(res), DRVNAME)) { 1158 if (!devm_request_region(dev, res->start, resource_size(res),
1160 err = -EBUSY; 1159 DRVNAME)) {
1161 dev_err(dev, "Failed to request region 0x%lx-0x%lx\n", 1160 dev_err(dev, "Failed to request region 0x%lx-0x%lx\n",
1162 (unsigned long)res->start, (unsigned long)res->end); 1161 (unsigned long)res->start, (unsigned long)res->end);
1163 goto EXIT_KFREE; 1162 return -EBUSY;
1164 } 1163 }
1165 data->addr = res->start; 1164 data->addr = res->start;
1166 data->name = DRVNAME; 1165 data->name = DRVNAME;
@@ -1215,26 +1214,15 @@ EXIT_DEV_REMOVE:
1215 dev_err(dev, "Sysfs interface creation failed (%d)\n", err); 1214 dev_err(dev, "Sysfs interface creation failed (%d)\n", err);
1216EXIT_DEV_REMOVE_SILENT: 1215EXIT_DEV_REMOVE_SILENT:
1217 vt1211_remove_sysfs(pdev); 1216 vt1211_remove_sysfs(pdev);
1218 release_region(res->start, resource_size(res));
1219EXIT_KFREE:
1220 platform_set_drvdata(pdev, NULL);
1221 kfree(data);
1222EXIT:
1223 return err; 1217 return err;
1224} 1218}
1225 1219
1226static int __devexit vt1211_remove(struct platform_device *pdev) 1220static int __devexit vt1211_remove(struct platform_device *pdev)
1227{ 1221{
1228 struct vt1211_data *data = platform_get_drvdata(pdev); 1222 struct vt1211_data *data = platform_get_drvdata(pdev);
1229 struct resource *res;
1230 1223
1231 hwmon_device_unregister(data->hwmon_dev); 1224 hwmon_device_unregister(data->hwmon_dev);
1232 vt1211_remove_sysfs(pdev); 1225 vt1211_remove_sysfs(pdev);
1233 platform_set_drvdata(pdev, NULL);
1234 kfree(data);
1235
1236 res = platform_get_resource(pdev, IORESOURCE_IO, 0);
1237 release_region(res->start, resource_size(res));
1238 1226
1239 return 0; 1227 return 0;
1240} 1228}