From: Guenter Roeck Date: Sat, 2 Jun 2012 16:58:00 +0000 (-0700) Subject: hwmon: (ads7871) Convert to use devm_ functions X-Git-Tag: next-20120914~85^2~45 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=599598edab2c316ae9ec1e64197ce682cb54eb96;p=karo-tx-linux.git 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 --- diff --git a/drivers/hwmon/ads7871.c b/drivers/hwmon/ads7871.c index e65c6e45d36b..e8377079ad90 100644 --- a/drivers/hwmon/ads7871.c +++ b/drivers/hwmon/ads7871.c @@ -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); @@ -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; } @@ -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; }