leds: convert DAC124S085 LED driver to devm_kzalloc()
authorBryan Wu <bryan.wu@canonical.com>
Wed, 4 Jul 2012 04:27:40 +0000 (12:27 +0800)
committerBryan Wu <bryan.wu@canonical.com>
Mon, 23 Jul 2012 23:52:40 +0000 (07:52 +0800)
Cc: Guennadi Liakhovetski <lg@denx.de>
Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
drivers/leds/leds-dac124s085.c

index d56c14269ff0c7e9c5e40992f689919024cef7bd..1f9d8e62d37e8d26860303b83ab206260fefd2a7 100644 (file)
@@ -69,7 +69,7 @@ static int dac124s085_probe(struct spi_device *spi)
        struct dac124s085_led   *led;
        int i, ret;
 
-       dac = kzalloc(sizeof(*dac), GFP_KERNEL);
+       dac = devm_kzalloc(&spi->dev, sizeof(*dac), GFP_KERNEL);
        if (!dac)
                return -ENOMEM;
 
@@ -102,7 +102,6 @@ eledcr:
                led_classdev_unregister(&dac->leds[i].ldev);
 
        spi_set_drvdata(spi, NULL);
-       kfree(dac);
        return ret;
 }
 
@@ -117,7 +116,6 @@ static int dac124s085_remove(struct spi_device *spi)
        }
 
        spi_set_drvdata(spi, NULL);
-       kfree(dac);
 
        return 0;
 }