Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/tilcdc: panel: make better use of gpiod API

Since 39b2bbe3d715 (gpio: add flags argument to gpiod_get*() functions)
which appeared in v3.17-rc1, the gpiod_get* functions take an additional
parameter that allows to specify direction and initial value for output.

Furthermore there is devm_gpiod_get_optional which is designed to get
optional gpios.

Simplify driver accordingly.

Acked-by: Alexandre Courbot <acourbot@nvidia.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

+7 -15
+7 -15
drivers/gpu/drm/tilcdc/tilcdc_panel.c
··· 375 375 dev_info(&pdev->dev, "found backlight\n"); 376 376 } 377 377 378 - panel_mod->enable_gpio = devm_gpiod_get(&pdev->dev, "enable"); 378 + panel_mod->enable_gpio = devm_gpiod_get_optional(&pdev->dev, "enable", 379 + GPIOD_OUT_LOW); 379 380 if (IS_ERR(panel_mod->enable_gpio)) { 380 381 ret = PTR_ERR(panel_mod->enable_gpio); 381 - if (ret != -ENOENT) { 382 - dev_err(&pdev->dev, "failed to request enable GPIO\n"); 383 - goto fail_backlight; 384 - } 385 - 386 - /* Optional GPIO is not here, continue silently. */ 387 - panel_mod->enable_gpio = NULL; 388 - } else { 389 - ret = gpiod_direction_output(panel_mod->enable_gpio, 0); 390 - if (ret < 0) { 391 - dev_err(&pdev->dev, "failed to setup GPIO\n"); 392 - goto fail_backlight; 393 - } 394 - dev_info(&pdev->dev, "found enable GPIO\n"); 382 + dev_err(&pdev->dev, "failed to request enable GPIO\n"); 383 + goto fail_backlight; 395 384 } 385 + 386 + if (panel_mod->enable_gpio) 387 + dev_info(&pdev->dev, "found enable GPIO\n"); 396 388 397 389 mod = &panel_mod->base; 398 390 pdev->dev.platform_data = mod;