diff options
Diffstat (limited to 'drivers/hwmon')
-rw-r--r-- | drivers/hwmon/abituguru.c | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/drivers/hwmon/abituguru.c b/drivers/hwmon/abituguru.c index b1dc63e4ac7b..bede4d990ea6 100644 --- a/drivers/hwmon/abituguru.c +++ b/drivers/hwmon/abituguru.c | |||
@@ -1267,30 +1267,42 @@ static int __devinit abituguru_probe(struct platform_device *pdev) | |||
1267 | printk(KERN_INFO ABIT_UGURU_NAME ": found Abit uGuru\n"); | 1267 | printk(KERN_INFO ABIT_UGURU_NAME ": found Abit uGuru\n"); |
1268 | 1268 | ||
1269 | /* Register sysfs hooks */ | 1269 | /* Register sysfs hooks */ |
1270 | data->class_dev = hwmon_device_register(&pdev->dev); | ||
1271 | if (IS_ERR(data->class_dev)) { | ||
1272 | res = PTR_ERR(data->class_dev); | ||
1273 | goto abituguru_probe_error; | ||
1274 | } | ||
1275 | for (i = 0; i < sysfs_attr_i; i++) | 1270 | for (i = 0; i < sysfs_attr_i; i++) |
1276 | device_create_file(&pdev->dev, &data->sysfs_attr[i].dev_attr); | 1271 | if (device_create_file(&pdev->dev, |
1272 | &data->sysfs_attr[i].dev_attr)) | ||
1273 | goto abituguru_probe_error; | ||
1277 | for (i = 0; i < ARRAY_SIZE(abituguru_sysfs_attr); i++) | 1274 | for (i = 0; i < ARRAY_SIZE(abituguru_sysfs_attr); i++) |
1278 | device_create_file(&pdev->dev, | 1275 | if (device_create_file(&pdev->dev, |
1279 | &abituguru_sysfs_attr[i].dev_attr); | 1276 | &abituguru_sysfs_attr[i].dev_attr)) |
1277 | goto abituguru_probe_error; | ||
1280 | 1278 | ||
1281 | return 0; | 1279 | data->class_dev = hwmon_device_register(&pdev->dev); |
1280 | if (!IS_ERR(data->class_dev)) | ||
1281 | return 0; /* success */ | ||
1282 | 1282 | ||
1283 | res = PTR_ERR(data->class_dev); | ||
1283 | abituguru_probe_error: | 1284 | abituguru_probe_error: |
1285 | for (i = 0; data->sysfs_attr[i].dev_attr.attr.name; i++) | ||
1286 | device_remove_file(&pdev->dev, &data->sysfs_attr[i].dev_attr); | ||
1287 | for (i = 0; i < ARRAY_SIZE(abituguru_sysfs_attr); i++) | ||
1288 | device_remove_file(&pdev->dev, | ||
1289 | &abituguru_sysfs_attr[i].dev_attr); | ||
1284 | kfree(data); | 1290 | kfree(data); |
1285 | return res; | 1291 | return res; |
1286 | } | 1292 | } |
1287 | 1293 | ||
1288 | static int __devexit abituguru_remove(struct platform_device *pdev) | 1294 | static int __devexit abituguru_remove(struct platform_device *pdev) |
1289 | { | 1295 | { |
1296 | int i; | ||
1290 | struct abituguru_data *data = platform_get_drvdata(pdev); | 1297 | struct abituguru_data *data = platform_get_drvdata(pdev); |
1291 | 1298 | ||
1292 | platform_set_drvdata(pdev, NULL); | 1299 | platform_set_drvdata(pdev, NULL); |
1293 | hwmon_device_unregister(data->class_dev); | 1300 | hwmon_device_unregister(data->class_dev); |
1301 | for (i = 0; data->sysfs_attr[i].dev_attr.attr.name; i++) | ||
1302 | device_remove_file(&pdev->dev, &data->sysfs_attr[i].dev_attr); | ||
1303 | for (i = 0; i < ARRAY_SIZE(abituguru_sysfs_attr); i++) | ||
1304 | device_remove_file(&pdev->dev, | ||
1305 | &abituguru_sysfs_attr[i].dev_attr); | ||
1294 | kfree(data); | 1306 | kfree(data); |
1295 | 1307 | ||
1296 | return 0; | 1308 | return 0; |