diff options
-rw-r--r-- | drivers/video/backlight/atmel-pwm-bl.c | 31 |
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 | ||
198 | err_free_pwm: | 191 | err_free_pwm: |
199 | pwm_channel_free(&pwmbl->pwmc); | 192 | pwm_channel_free(&pwmbl->pwmc); |
200 | err_free_mem: | 193 | |
201 | return retval; | 194 | return retval; |
202 | } | 195 | } |
203 | 196 | ||