Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 26a5bd26 authored by Uwe Kleine-König's avatar Uwe Kleine-König
Browse files

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



Since 39b2bbe3 (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: default avatarAlexandre Courbot <acourbot@nvidia.com>
Acked-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
parent 89ae3d3b
Loading
Loading
Loading
Loading
+7 −15
Original line number Diff line number Diff line
@@ -375,24 +375,16 @@ static int panel_probe(struct platform_device *pdev)
		dev_info(&pdev->dev, "found backlight\n");
	}

	panel_mod->enable_gpio = devm_gpiod_get(&pdev->dev, "enable");
	panel_mod->enable_gpio = devm_gpiod_get_optional(&pdev->dev, "enable",
							 GPIOD_OUT_LOW);
	if (IS_ERR(panel_mod->enable_gpio)) {
		ret = PTR_ERR(panel_mod->enable_gpio);
		if (ret != -ENOENT) {
		dev_err(&pdev->dev, "failed to request enable GPIO\n");
		goto fail_backlight;
	}

		/* Optional GPIO is not here, continue silently. */
		panel_mod->enable_gpio = NULL;
	} else {
		ret = gpiod_direction_output(panel_mod->enable_gpio, 0);
		if (ret < 0) {
			dev_err(&pdev->dev, "failed to setup GPIO\n");
			goto fail_backlight;
		}
	if (panel_mod->enable_gpio)
		dev_info(&pdev->dev, "found enable GPIO\n");
	}

	mod = &panel_mod->base;
	pdev->dev.platform_data = mod;