hwmon: (ads7871) Convert to use devm_ functions
Convert to use devm_ functions to reduce code size and simplify the code. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
parent
34e3f7f5a2
commit
33fd2b84c9
1 changed files with 7 additions and 14 deletions
|
@ -198,20 +198,17 @@ static int __devinit ads7871_probe(struct spi_device *spi)
|
||||||
* because there is no other error checking on an SPI bus
|
* because there is no other error checking on an SPI bus
|
||||||
* we need to make sure we really have a chip
|
* we need to make sure we really have a chip
|
||||||
*/
|
*/
|
||||||
if (val != ret) {
|
if (val != ret)
|
||||||
err = -ENODEV;
|
return -ENODEV;
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
pdata = kzalloc(sizeof(struct ads7871_data), GFP_KERNEL);
|
pdata = devm_kzalloc(&spi->dev, sizeof(struct ads7871_data),
|
||||||
if (!pdata) {
|
GFP_KERNEL);
|
||||||
err = -ENOMEM;
|
if (!pdata)
|
||||||
goto exit;
|
return -ENOMEM;
|
||||||
}
|
|
||||||
|
|
||||||
err = sysfs_create_group(&spi->dev.kobj, &ads7871_group);
|
err = sysfs_create_group(&spi->dev.kobj, &ads7871_group);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
goto error_free;
|
return err;
|
||||||
|
|
||||||
spi_set_drvdata(spi, pdata);
|
spi_set_drvdata(spi, pdata);
|
||||||
|
|
||||||
|
@ -225,9 +222,6 @@ static int __devinit ads7871_probe(struct spi_device *spi)
|
||||||
|
|
||||||
error_remove:
|
error_remove:
|
||||||
sysfs_remove_group(&spi->dev.kobj, &ads7871_group);
|
sysfs_remove_group(&spi->dev.kobj, &ads7871_group);
|
||||||
error_free:
|
|
||||||
kfree(pdata);
|
|
||||||
exit:
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,7 +231,6 @@ static int __devexit ads7871_remove(struct spi_device *spi)
|
||||||
|
|
||||||
hwmon_device_unregister(pdata->hwmon_dev);
|
hwmon_device_unregister(pdata->hwmon_dev);
|
||||||
sysfs_remove_group(&spi->dev.kobj, &ads7871_group);
|
sysfs_remove_group(&spi->dev.kobj, &ads7871_group);
|
||||||
kfree(pdata);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue