diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-01-10 18:09:21 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-01-10 19:30:48 -0500 |
commit | 48e78e8cc87ab80617ef0c5a146701ca96a4a51d (patch) | |
tree | 607c7288eec87945a387a035b297a41650ed6b61 /drivers/video | |
parent | 66655760bf38861299e3c8196f5303f886b0eef9 (diff) |
backlight: convert platform_lcd to devm_kzalloc()
Saves some error handling code and eliminates a class of leaks.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: Richard Purdie <rpurdie@rpsys.net>
Cc: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/video')
-rw-r--r-- | drivers/video/backlight/platform_lcd.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/drivers/video/backlight/platform_lcd.c b/drivers/video/backlight/platform_lcd.c index 187da59e3a13..f0bf491ed087 100644 --- a/drivers/video/backlight/platform_lcd.c +++ b/drivers/video/backlight/platform_lcd.c | |||
@@ -85,7 +85,8 @@ static int __devinit platform_lcd_probe(struct platform_device *pdev) | |||
85 | return -EINVAL; | 85 | return -EINVAL; |
86 | } | 86 | } |
87 | 87 | ||
88 | plcd = kzalloc(sizeof(struct platform_lcd), GFP_KERNEL); | 88 | plcd = devm_kzalloc(&pdev->dev, sizeof(struct platform_lcd), |
89 | GFP_KERNEL); | ||
89 | if (!plcd) { | 90 | if (!plcd) { |
90 | dev_err(dev, "no memory for state\n"); | 91 | dev_err(dev, "no memory for state\n"); |
91 | return -ENOMEM; | 92 | return -ENOMEM; |
@@ -98,7 +99,7 @@ static int __devinit platform_lcd_probe(struct platform_device *pdev) | |||
98 | if (IS_ERR(plcd->lcd)) { | 99 | if (IS_ERR(plcd->lcd)) { |
99 | dev_err(dev, "cannot register lcd device\n"); | 100 | dev_err(dev, "cannot register lcd device\n"); |
100 | err = PTR_ERR(plcd->lcd); | 101 | err = PTR_ERR(plcd->lcd); |
101 | goto err_mem; | 102 | goto err; |
102 | } | 103 | } |
103 | 104 | ||
104 | platform_set_drvdata(pdev, plcd); | 105 | platform_set_drvdata(pdev, plcd); |
@@ -106,8 +107,7 @@ static int __devinit platform_lcd_probe(struct platform_device *pdev) | |||
106 | 107 | ||
107 | return 0; | 108 | return 0; |
108 | 109 | ||
109 | err_mem: | 110 | err: |
110 | kfree(plcd); | ||
111 | return err; | 111 | return err; |
112 | } | 112 | } |
113 | 113 | ||
@@ -116,7 +116,6 @@ static int __devexit platform_lcd_remove(struct platform_device *pdev) | |||
116 | struct platform_lcd *plcd = platform_get_drvdata(pdev); | 116 | struct platform_lcd *plcd = platform_get_drvdata(pdev); |
117 | 117 | ||
118 | lcd_device_unregister(plcd->lcd); | 118 | lcd_device_unregister(plcd->lcd); |
119 | kfree(plcd); | ||
120 | 119 | ||
121 | return 0; | 120 | return 0; |
122 | } | 121 | } |