aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/backlight/atmel-pwm-bl.c
diff options
context:
space:
mode:
authorJohan Hovold <jhovold@gmail.com>2013-11-12 18:09:41 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-11-12 22:09:21 -0500
commitce726c9738a27ee32a00136cc512b1058044a0fe (patch)
tree57acdb0383364b683ffed7b224850283fe3bcd82 /drivers/video/backlight/atmel-pwm-bl.c
parent5c057e5570f18b9d0f4eea99e0a0d55ad5f30e36 (diff)
backlight: atmel-pwm-bl: clean up probe error handling
Clean up probe error handling by checking parameters before any allocations and removing an obsolete error label. Also remove unnecessary reset of private gpio number. Signed-off-by: Johan Hovold <jhovold@gmail.com> Acked-by: Jingoo Han <jg1.han@samsung.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/video/backlight/atmel-pwm-bl.c')
-rw-r--r--drivers/video/backlight/atmel-pwm-bl.c31
1 files changed, 12 insertions, 19 deletions
diff --git a/drivers/video/backlight/atmel-pwm-bl.c b/drivers/video/backlight/atmel-pwm-bl.c
index 4886028c9eaa..01af5c2d028a 100644
--- a/drivers/video/backlight/atmel-pwm-bl.c
+++ b/drivers/video/backlight/atmel-pwm-bl.c
@@ -126,40 +126,33 @@ static int atmel_pwm_bl_probe(struct platform_device *pdev)
126 struct atmel_pwm_bl *pwmbl; 126 struct atmel_pwm_bl *pwmbl;
127 int retval; 127 int retval;
128 128
129 pdata = dev_get_platdata(&pdev->dev);
130 if (!pdata)
131 return -ENODEV;
132
133 if (pdata->pwm_compare_max < pdata->pwm_duty_max ||
134 pdata->pwm_duty_min > pdata->pwm_duty_max ||
135 pdata->pwm_frequency == 0)
136 return -EINVAL;
137
129 pwmbl = devm_kzalloc(&pdev->dev, sizeof(struct atmel_pwm_bl), 138 pwmbl = devm_kzalloc(&pdev->dev, sizeof(struct atmel_pwm_bl),
130 GFP_KERNEL); 139 GFP_KERNEL);
131 if (!pwmbl) 140 if (!pwmbl)
132 return -ENOMEM; 141 return -ENOMEM;
133 142
134 pwmbl->pdev = pdev; 143 pwmbl->pdev = pdev;
135
136 pdata = dev_get_platdata(&pdev->dev);
137 if (!pdata) {
138 retval = -ENODEV;
139 goto err_free_mem;
140 }
141
142 if (pdata->pwm_compare_max < pdata->pwm_duty_max ||
143 pdata->pwm_duty_min > pdata->pwm_duty_max ||
144 pdata->pwm_frequency == 0) {
145 retval = -EINVAL;
146 goto err_free_mem;
147 }
148
149 pwmbl->pdata = pdata; 144 pwmbl->pdata = pdata;
150 pwmbl->gpio_on = pdata->gpio_on; 145 pwmbl->gpio_on = pdata->gpio_on;
151 146
152 retval = pwm_channel_alloc(pdata->pwm_channel, &pwmbl->pwmc); 147 retval = pwm_channel_alloc(pdata->pwm_channel, &pwmbl->pwmc);
153 if (retval) 148 if (retval)
154 goto err_free_mem; 149 return retval;
155 150
156 if (pwmbl->gpio_on != -1) { 151 if (pwmbl->gpio_on != -1) {
157 retval = devm_gpio_request(&pdev->dev, pwmbl->gpio_on, 152 retval = devm_gpio_request(&pdev->dev, pwmbl->gpio_on,
158 "gpio_atmel_pwm_bl"); 153 "gpio_atmel_pwm_bl");
159 if (retval) { 154 if (retval)
160 pwmbl->gpio_on = -1;
161 goto err_free_pwm; 155 goto err_free_pwm;
162 }
163 156
164 /* Turn display off by default. */ 157 /* Turn display off by default. */
165 retval = gpio_direction_output(pwmbl->gpio_on, 158 retval = gpio_direction_output(pwmbl->gpio_on,
@@ -197,7 +190,7 @@ static int atmel_pwm_bl_probe(struct platform_device *pdev)
197 190
198err_free_pwm: 191err_free_pwm:
199 pwm_channel_free(&pwmbl->pwmc); 192 pwm_channel_free(&pwmbl->pwmc);
200err_free_mem: 193
201 return retval; 194 return retval;
202} 195}
203 196