diff options
author | Jingoo Han <jg1.han@samsung.com> | 2012-05-29 18:07:23 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-05-29 19:22:30 -0400 |
commit | 86f6be4fae7aeaeb038dc809b232ebe76b2e1dd2 (patch) | |
tree | 5f84de7ca32d7f5f27d18ec75145170a254f333e | |
parent | ba4a887ac3ff2e3ce876115a3e0828caa9c6f428 (diff) |
backlight: ld9040: 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: Jingoo Han <jg1.han@samsung.com>
Cc: Donghwa Lee <dh09.lee@samsung.com>
Cc: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | drivers/video/backlight/ld9040.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/drivers/video/backlight/ld9040.c b/drivers/video/backlight/ld9040.c index 2ea06a5fae55..58f517fb7d40 100644 --- a/drivers/video/backlight/ld9040.c +++ b/drivers/video/backlight/ld9040.c | |||
@@ -707,7 +707,7 @@ static int ld9040_probe(struct spi_device *spi) | |||
707 | struct backlight_device *bd = NULL; | 707 | struct backlight_device *bd = NULL; |
708 | struct backlight_properties props; | 708 | struct backlight_properties props; |
709 | 709 | ||
710 | lcd = kzalloc(sizeof(struct ld9040), GFP_KERNEL); | 710 | lcd = devm_kzalloc(&spi->dev, sizeof(struct ld9040), GFP_KERNEL); |
711 | if (!lcd) | 711 | if (!lcd) |
712 | return -ENOMEM; | 712 | return -ENOMEM; |
713 | 713 | ||
@@ -717,7 +717,7 @@ static int ld9040_probe(struct spi_device *spi) | |||
717 | ret = spi_setup(spi); | 717 | ret = spi_setup(spi); |
718 | if (ret < 0) { | 718 | if (ret < 0) { |
719 | dev_err(&spi->dev, "spi setup failed.\n"); | 719 | dev_err(&spi->dev, "spi setup failed.\n"); |
720 | goto out_free_lcd; | 720 | return ret; |
721 | } | 721 | } |
722 | 722 | ||
723 | lcd->spi = spi; | 723 | lcd->spi = spi; |
@@ -726,7 +726,7 @@ static int ld9040_probe(struct spi_device *spi) | |||
726 | lcd->lcd_pd = spi->dev.platform_data; | 726 | lcd->lcd_pd = spi->dev.platform_data; |
727 | if (!lcd->lcd_pd) { | 727 | if (!lcd->lcd_pd) { |
728 | dev_err(&spi->dev, "platform data is NULL.\n"); | 728 | dev_err(&spi->dev, "platform data is NULL.\n"); |
729 | goto out_free_lcd; | 729 | return -EFAULT; |
730 | } | 730 | } |
731 | 731 | ||
732 | mutex_init(&lcd->lock); | 732 | mutex_init(&lcd->lock); |
@@ -734,13 +734,13 @@ static int ld9040_probe(struct spi_device *spi) | |||
734 | ret = regulator_bulk_get(lcd->dev, ARRAY_SIZE(supplies), supplies); | 734 | ret = regulator_bulk_get(lcd->dev, ARRAY_SIZE(supplies), supplies); |
735 | if (ret) { | 735 | if (ret) { |
736 | dev_err(lcd->dev, "Failed to get regulators: %d\n", ret); | 736 | dev_err(lcd->dev, "Failed to get regulators: %d\n", ret); |
737 | goto out_free_lcd; | 737 | return ret; |
738 | } | 738 | } |
739 | 739 | ||
740 | ld = lcd_device_register("ld9040", &spi->dev, lcd, &ld9040_lcd_ops); | 740 | ld = lcd_device_register("ld9040", &spi->dev, lcd, &ld9040_lcd_ops); |
741 | if (IS_ERR(ld)) { | 741 | if (IS_ERR(ld)) { |
742 | ret = PTR_ERR(ld); | 742 | ret = PTR_ERR(ld); |
743 | goto out_free_lcd; | 743 | goto out_free_regulator; |
744 | } | 744 | } |
745 | 745 | ||
746 | lcd->ld = ld; | 746 | lcd->ld = ld; |
@@ -782,10 +782,9 @@ static int ld9040_probe(struct spi_device *spi) | |||
782 | 782 | ||
783 | out_unregister_lcd: | 783 | out_unregister_lcd: |
784 | lcd_device_unregister(lcd->ld); | 784 | lcd_device_unregister(lcd->ld); |
785 | out_free_lcd: | 785 | out_free_regulator: |
786 | regulator_bulk_free(ARRAY_SIZE(supplies), supplies); | 786 | regulator_bulk_free(ARRAY_SIZE(supplies), supplies); |
787 | 787 | ||
788 | kfree(lcd); | ||
789 | return ret; | 788 | return ret; |
790 | } | 789 | } |
791 | 790 | ||
@@ -797,7 +796,6 @@ static int __devexit ld9040_remove(struct spi_device *spi) | |||
797 | backlight_device_unregister(lcd->bd); | 796 | backlight_device_unregister(lcd->bd); |
798 | lcd_device_unregister(lcd->ld); | 797 | lcd_device_unregister(lcd->ld); |
799 | regulator_bulk_free(ARRAY_SIZE(supplies), supplies); | 798 | regulator_bulk_free(ARRAY_SIZE(supplies), supplies); |
800 | kfree(lcd); | ||
801 | 799 | ||
802 | return 0; | 800 | return 0; |
803 | } | 801 | } |