Commit 06c96f18 authored by Jingoo Han's avatar Jingoo Han Committed by Linus Torvalds

backlight: corgi_lcd: use devm_ functions

The devm_ functions allocate memory that is released when a driver
detaches.  This patch uses devm_kzalloc of these functions.
Signed-off-by: default avatarJingoo Han <jg1.han@samsung.com>
Cc: Eric Miao <eric.y.miao@gmail.com>
Cc: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 80629efc
...@@ -544,7 +544,7 @@ static int __devinit corgi_lcd_probe(struct spi_device *spi) ...@@ -544,7 +544,7 @@ static int __devinit corgi_lcd_probe(struct spi_device *spi)
return -EINVAL; return -EINVAL;
} }
lcd = kzalloc(sizeof(struct corgi_lcd), GFP_KERNEL); lcd = devm_kzalloc(&spi->dev, sizeof(struct corgi_lcd), GFP_KERNEL);
if (!lcd) { if (!lcd) {
dev_err(&spi->dev, "failed to allocate memory\n"); dev_err(&spi->dev, "failed to allocate memory\n");
return -ENOMEM; return -ENOMEM;
...@@ -554,10 +554,9 @@ static int __devinit corgi_lcd_probe(struct spi_device *spi) ...@@ -554,10 +554,9 @@ static int __devinit corgi_lcd_probe(struct spi_device *spi)
lcd->lcd_dev = lcd_device_register("corgi_lcd", &spi->dev, lcd->lcd_dev = lcd_device_register("corgi_lcd", &spi->dev,
lcd, &corgi_lcd_ops); lcd, &corgi_lcd_ops);
if (IS_ERR(lcd->lcd_dev)) { if (IS_ERR(lcd->lcd_dev))
ret = PTR_ERR(lcd->lcd_dev); return PTR_ERR(lcd->lcd_dev);
goto err_free_lcd;
}
lcd->power = FB_BLANK_POWERDOWN; lcd->power = FB_BLANK_POWERDOWN;
lcd->mode = (pdata) ? pdata->init_mode : CORGI_LCD_MODE_VGA; lcd->mode = (pdata) ? pdata->init_mode : CORGI_LCD_MODE_VGA;
...@@ -591,8 +590,6 @@ static int __devinit corgi_lcd_probe(struct spi_device *spi) ...@@ -591,8 +590,6 @@ static int __devinit corgi_lcd_probe(struct spi_device *spi)
backlight_device_unregister(lcd->bl_dev); backlight_device_unregister(lcd->bl_dev);
err_unregister_lcd: err_unregister_lcd:
lcd_device_unregister(lcd->lcd_dev); lcd_device_unregister(lcd->lcd_dev);
err_free_lcd:
kfree(lcd);
return ret; return ret;
} }
...@@ -613,7 +610,6 @@ static int __devexit corgi_lcd_remove(struct spi_device *spi) ...@@ -613,7 +610,6 @@ static int __devexit corgi_lcd_remove(struct spi_device *spi)
corgi_lcd_set_power(lcd->lcd_dev, FB_BLANK_POWERDOWN); corgi_lcd_set_power(lcd->lcd_dev, FB_BLANK_POWERDOWN);
lcd_device_unregister(lcd->lcd_dev); lcd_device_unregister(lcd->lcd_dev);
kfree(lcd);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment