hwmon: (ads7871) Convert to use devm_ functions
Jean Delvare
Acked-byQuoted 40 lines · Guenter Roeck
Convert to use
devm_functions to reduce code size and simplify the code.Signed-off-by Guenter Roeck <[email protected]>--- drivers/hwmon/ads7871.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-)drivers/hwmon/ads7871.c +7
-10@@ -189,20 +189,17 @@ static int __devinit ads7871_probe(struct spi_device *spi)* because there is no other error checking on an SPI bus * we need to make sure we really have a chip */ -if (val != ret) { - err = -ENODEV ; - goto exit; - } +if (val != ret) +return -ENODEV ; - pdata =kzalloc (sizeof (struct ads7871_data ),GFP_KERNEL ); -if (!pdata) { - err = -ENOMEM ; - goto exit; - } + pdata =devm_kzalloc (&spi->dev,sizeof (struct ads7871_data ), +GFP_KERNEL ); +if (!pdata) +return -ENOMEM ; err =sysfs_create_group (&spi->dev.kobj, &ads7871_group);if (err <0 ) - goto error_free; +return err;spi_set_drvdata (spi, pdata);
drivers/hwmon/ads7871.c static int __devinit ads7871_probe(struct spi_device *spi) · line 217
Quoted 8 lines
drivers/hwmon/ads7871.c +0
-3@@ -216,9 +213,6 @@ static int __devinit ads7871_probe(struct spi_device *spi) error_remove:sysfs_remove_group (&spi->dev.kobj, &ads7871_group); -error_free: -kfree (pdata); -exit:return err; }
At this point it becomes dubious to use a separate error path. You have a single label and you use it only once, so there is no practical benefit.
drivers/hwmon/ads7871.c static int __devexit ads7871_remove(struct spi_device *spi) · line 227
Quoted 9 lines
drivers/hwmon/ads7871.c +0
-1@@ -228,7 +222,6 @@ static int __devexit ads7871_remove(struct spi_device *spi)hwmon_device_unregister (pdata->hwmon_dev);sysfs_remove_group (&spi->dev.kobj, &ads7871_group); -kfree (pdata);return 0 ; }
Functionally the change is correct, so:
Acked-by Jean Delvare <[email protected]>
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors