aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Hovold <johan@kernel.org>2017-11-20 05:45:44 -0500
committerLee Jones <lee.jones@linaro.org>2018-06-11 08:40:20 -0400
commit4a9c8bb2aca5b5a2a15744333729745dd9903562 (patch)
treeaa5cb3df0c4b50454c7134c07c8f70eaef6bcca5
parent840d40d941bf669669088732ef68606adb19feeb (diff)
backlight: as3711_bl: Fix Device Tree node lookup
Fix child-node lookup during probe, which ended up searching the whole device tree depth-first starting at the parent rather than just matching on its children. To make things worse, the parent mfd node was also prematurely freed. Cc: stable <stable@vger.kernel.org> # 3.10 Fixes: 59eb2b5e57ea ("drivers/video/backlight/as3711_bl.c: add OF support") Signed-off-by: Johan Hovold <johan@kernel.org> Acked-by: Daniel Thompson <daniel.thompson@linaro.org> Signed-off-by: Lee Jones <lee.jones@linaro.org>
-rw-r--r--drivers/video/backlight/as3711_bl.c33
1 files changed, 23 insertions, 10 deletions
diff --git a/drivers/video/backlight/as3711_bl.c b/drivers/video/backlight/as3711_bl.c
index 734a9158946b..e55304d5cf07 100644
--- a/drivers/video/backlight/as3711_bl.c
+++ b/drivers/video/backlight/as3711_bl.c
@@ -262,10 +262,10 @@ static int as3711_bl_register(struct platform_device *pdev,
262static int as3711_backlight_parse_dt(struct device *dev) 262static int as3711_backlight_parse_dt(struct device *dev)
263{ 263{
264 struct as3711_bl_pdata *pdata = dev_get_platdata(dev); 264 struct as3711_bl_pdata *pdata = dev_get_platdata(dev);
265 struct device_node *bl = 265 struct device_node *bl, *fb;
266 of_find_node_by_name(dev->parent->of_node, "backlight"), *fb;
267 int ret; 266 int ret;
268 267
268 bl = of_get_child_by_name(dev->parent->of_node, "backlight");
269 if (!bl) { 269 if (!bl) {
270 dev_dbg(dev, "backlight node not found\n"); 270 dev_dbg(dev, "backlight node not found\n");
271 return -ENODEV; 271 return -ENODEV;
@@ -279,7 +279,7 @@ static int as3711_backlight_parse_dt(struct device *dev)
279 if (pdata->su1_max_uA <= 0) 279 if (pdata->su1_max_uA <= 0)
280 ret = -EINVAL; 280 ret = -EINVAL;
281 if (ret < 0) 281 if (ret < 0)
282 return ret; 282 goto err_put_bl;
283 } 283 }
284 284
285 fb = of_parse_phandle(bl, "su2-dev", 0); 285 fb = of_parse_phandle(bl, "su2-dev", 0);
@@ -292,7 +292,7 @@ static int as3711_backlight_parse_dt(struct device *dev)
292 if (pdata->su2_max_uA <= 0) 292 if (pdata->su2_max_uA <= 0)
293 ret = -EINVAL; 293 ret = -EINVAL;
294 if (ret < 0) 294 if (ret < 0)
295 return ret; 295 goto err_put_bl;
296 296
297 if (of_find_property(bl, "su2-feedback-voltage", NULL)) { 297 if (of_find_property(bl, "su2-feedback-voltage", NULL)) {
298 pdata->su2_feedback = AS3711_SU2_VOLTAGE; 298 pdata->su2_feedback = AS3711_SU2_VOLTAGE;
@@ -314,8 +314,10 @@ static int as3711_backlight_parse_dt(struct device *dev)
314 pdata->su2_feedback = AS3711_SU2_CURR_AUTO; 314 pdata->su2_feedback = AS3711_SU2_CURR_AUTO;
315 count++; 315 count++;
316 } 316 }
317 if (count != 1) 317 if (count != 1) {
318 return -EINVAL; 318 ret = -EINVAL;
319 goto err_put_bl;
320 }
319 321
320 count = 0; 322 count = 0;
321 if (of_find_property(bl, "su2-fbprot-lx-sd4", NULL)) { 323 if (of_find_property(bl, "su2-fbprot-lx-sd4", NULL)) {
@@ -334,8 +336,10 @@ static int as3711_backlight_parse_dt(struct device *dev)
334 pdata->su2_fbprot = AS3711_SU2_GPIO4; 336 pdata->su2_fbprot = AS3711_SU2_GPIO4;
335 count++; 337 count++;
336 } 338 }
337 if (count != 1) 339 if (count != 1) {
338 return -EINVAL; 340 ret = -EINVAL;
341 goto err_put_bl;
342 }
339 343
340 count = 0; 344 count = 0;
341 if (of_find_property(bl, "su2-auto-curr1", NULL)) { 345 if (of_find_property(bl, "su2-auto-curr1", NULL)) {
@@ -355,11 +359,20 @@ static int as3711_backlight_parse_dt(struct device *dev)
355 * At least one su2-auto-curr* must be specified iff 359 * At least one su2-auto-curr* must be specified iff
356 * AS3711_SU2_CURR_AUTO is used 360 * AS3711_SU2_CURR_AUTO is used
357 */ 361 */
358 if (!count ^ (pdata->su2_feedback != AS3711_SU2_CURR_AUTO)) 362 if (!count ^ (pdata->su2_feedback != AS3711_SU2_CURR_AUTO)) {
359 return -EINVAL; 363 ret = -EINVAL;
364 goto err_put_bl;
365 }
360 } 366 }
361 367
368 of_node_put(bl);
369
362 return 0; 370 return 0;
371
372err_put_bl:
373 of_node_put(bl);
374
375 return ret;
363} 376}
364 377
365static int as3711_backlight_probe(struct platform_device *pdev) 378static int as3711_backlight_probe(struct platform_device *pdev)