hwmon: (adcxx) Convert to use devm_ functions
authorGuenter Roeck <linux@roeck-us.net>
Sat, 2 Jun 2012 16:57:58 +0000 (09:57 -0700)
committerGuenter Roeck <linux@roeck-us.net>
Mon, 24 Sep 2012 04:08:29 +0000 (21:08 -0700)
Convert to use devm_ functions to reduce code size and simplify the code.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/adcxx.c

index a3d3183454adb16e6854e0c0558ec1dc5a13d787..111af7c4a3d430749fa7c7ec269b4606778f8c42 100644 (file)
@@ -171,7 +171,7 @@ static int __devinit adcxx_probe(struct spi_device *spi)
        int status;
        int i;
 
-       adc = kzalloc(sizeof *adc, GFP_KERNEL);
+       adc = devm_kzalloc(&spi->dev, sizeof(*adc), GFP_KERNEL);
        if (!adc)
                return -ENOMEM;
 
@@ -208,7 +208,6 @@ out_err:
 
        spi_set_drvdata(spi, NULL);
        mutex_unlock(&adc->lock);
-       kfree(adc);
        return status;
 }
 
@@ -224,7 +223,6 @@ static int __devexit adcxx_remove(struct spi_device *spi)
 
        spi_set_drvdata(spi, NULL);
        mutex_unlock(&adc->lock);
-       kfree(adc);
 
        return 0;
 }