aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/w83781d.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/w83781d.c')
-rw-r--r--drivers/hwmon/w83781d.c46
1 files changed, 16 insertions, 30 deletions
diff --git a/drivers/hwmon/w83781d.c b/drivers/hwmon/w83781d.c
index b03d54a799e3..c11452ebe18f 100644
--- a/drivers/hwmon/w83781d.c
+++ b/drivers/hwmon/w83781d.c
@@ -1213,11 +1213,9 @@ w83781d_probe(struct i2c_client *client, const struct i2c_device_id *id)
1213 struct w83781d_data *data; 1213 struct w83781d_data *data;
1214 int err; 1214 int err;
1215 1215
1216 data = kzalloc(sizeof(struct w83781d_data), GFP_KERNEL); 1216 data = devm_kzalloc(dev, sizeof(struct w83781d_data), GFP_KERNEL);
1217 if (!data) { 1217 if (!data)
1218 err = -ENOMEM; 1218 return -ENOMEM;
1219 goto ERROR1;
1220 }
1221 1219
1222 i2c_set_clientdata(client, data); 1220 i2c_set_clientdata(client, data);
1223 mutex_init(&data->lock); 1221 mutex_init(&data->lock);
@@ -1229,7 +1227,7 @@ w83781d_probe(struct i2c_client *client, const struct i2c_device_id *id)
1229 /* attach secondary i2c lm75-like clients */ 1227 /* attach secondary i2c lm75-like clients */
1230 err = w83781d_detect_subclients(client); 1228 err = w83781d_detect_subclients(client);
1231 if (err) 1229 if (err)
1232 goto ERROR3; 1230 return err;
1233 1231
1234 /* Initialize the chip */ 1232 /* Initialize the chip */
1235 w83781d_init_device(dev); 1233 w83781d_init_device(dev);
@@ -1237,25 +1235,22 @@ w83781d_probe(struct i2c_client *client, const struct i2c_device_id *id)
1237 /* Register sysfs hooks */ 1235 /* Register sysfs hooks */
1238 err = w83781d_create_files(dev, data->type, 0); 1236 err = w83781d_create_files(dev, data->type, 0);
1239 if (err) 1237 if (err)
1240 goto ERROR4; 1238 goto exit_remove_files;
1241 1239
1242 data->hwmon_dev = hwmon_device_register(dev); 1240 data->hwmon_dev = hwmon_device_register(dev);
1243 if (IS_ERR(data->hwmon_dev)) { 1241 if (IS_ERR(data->hwmon_dev)) {
1244 err = PTR_ERR(data->hwmon_dev); 1242 err = PTR_ERR(data->hwmon_dev);
1245 goto ERROR4; 1243 goto exit_remove_files;
1246 } 1244 }
1247 1245
1248 return 0; 1246 return 0;
1249 1247
1250ERROR4: 1248 exit_remove_files:
1251 w83781d_remove_files(dev); 1249 w83781d_remove_files(dev);
1252 if (data->lm75[0]) 1250 if (data->lm75[0])
1253 i2c_unregister_device(data->lm75[0]); 1251 i2c_unregister_device(data->lm75[0]);
1254 if (data->lm75[1]) 1252 if (data->lm75[1])
1255 i2c_unregister_device(data->lm75[1]); 1253 i2c_unregister_device(data->lm75[1]);
1256ERROR3:
1257 kfree(data);
1258ERROR1:
1259 return err; 1254 return err;
1260} 1255}
1261 1256
@@ -1273,8 +1268,6 @@ w83781d_remove(struct i2c_client *client)
1273 if (data->lm75[1]) 1268 if (data->lm75[1])
1274 i2c_unregister_device(data->lm75[1]); 1269 i2c_unregister_device(data->lm75[1]);
1275 1270
1276 kfree(data);
1277
1278 return 0; 1271 return 0;
1279} 1272}
1280 1273
@@ -1780,17 +1773,16 @@ w83781d_isa_probe(struct platform_device *pdev)
1780 1773
1781 /* Reserve the ISA region */ 1774 /* Reserve the ISA region */
1782 res = platform_get_resource(pdev, IORESOURCE_IO, 0); 1775 res = platform_get_resource(pdev, IORESOURCE_IO, 0);
1783 if (!request_region(res->start + W83781D_ADDR_REG_OFFSET, 2, 1776 if (!devm_request_region(&pdev->dev,
1784 "w83781d")) { 1777 res->start + W83781D_ADDR_REG_OFFSET, 2,
1785 err = -EBUSY; 1778 "w83781d"))
1786 goto exit; 1779 return -EBUSY;
1787 } 1780
1781 data = devm_kzalloc(&pdev->dev, sizeof(struct w83781d_data),
1782 GFP_KERNEL);
1783 if (!data)
1784 return -ENOMEM;
1788 1785
1789 data = kzalloc(sizeof(struct w83781d_data), GFP_KERNEL);
1790 if (!data) {
1791 err = -ENOMEM;
1792 goto exit_release_region;
1793 }
1794 mutex_init(&data->lock); 1786 mutex_init(&data->lock);
1795 data->isa_addr = res->start; 1787 data->isa_addr = res->start;
1796 platform_set_drvdata(pdev, data); 1788 platform_set_drvdata(pdev, data);
@@ -1829,10 +1821,6 @@ w83781d_isa_probe(struct platform_device *pdev)
1829 exit_remove_files: 1821 exit_remove_files:
1830 w83781d_remove_files(&pdev->dev); 1822 w83781d_remove_files(&pdev->dev);
1831 device_remove_file(&pdev->dev, &dev_attr_name); 1823 device_remove_file(&pdev->dev, &dev_attr_name);
1832 kfree(data);
1833 exit_release_region:
1834 release_region(res->start + W83781D_ADDR_REG_OFFSET, 2);
1835 exit:
1836 return err; 1824 return err;
1837} 1825}
1838 1826
@@ -1844,8 +1832,6 @@ w83781d_isa_remove(struct platform_device *pdev)
1844 hwmon_device_unregister(data->hwmon_dev); 1832 hwmon_device_unregister(data->hwmon_dev);
1845 w83781d_remove_files(&pdev->dev); 1833 w83781d_remove_files(&pdev->dev);
1846 device_remove_file(&pdev->dev, &dev_attr_name); 1834 device_remove_file(&pdev->dev, &dev_attr_name);
1847 release_region(data->isa_addr + W83781D_ADDR_REG_OFFSET, 2);
1848 kfree(data);
1849 1835
1850 return 0; 1836 return 0;
1851} 1837}