From patchwork Thu May 28 08:05:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 6496551 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id F1D8F9F38C for ; Thu, 28 May 2015 08:05:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0DD4B206AF for ; Thu, 28 May 2015 08:05:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5EF43206B8 for ; Thu, 28 May 2015 08:05:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751372AbbE1IF2 (ORCPT ); Thu, 28 May 2015 04:05:28 -0400 Received: from metis.ext.pengutronix.de ([92.198.50.35]:57379 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752833AbbE1IF0 (ORCPT ); Thu, 28 May 2015 04:05:26 -0400 Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7]) by metis.ext.pengutronix.de with esmtps (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1Yxsoc-0000Qe-G5; Thu, 28 May 2015 10:05:22 +0200 Received: from ukl by dude.hi.pengutronix.de with local (Exim 4.85) (envelope-from ) id 1Yxsoa-0006tk-Sd; Thu, 28 May 2015 10:05:20 +0200 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= To: Tomi Valkeinen , Jean-Christophe Plagniol-Villard Cc: linux-omap@vger.kernel.org, linux-fbdev@vger.kernel.org, Linus Walleij , kernel@pengutronix.de Subject: [PATCH] fbdev: omap2: improve usage of gpiod API Date: Thu, 28 May 2015 10:05:15 +0200 Message-Id: <1432800315-25972-1-git-send-email-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.1.4 MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-fbdev@vger.kernel.org Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Also make use of gpiod_get*_optional where applicable. Apart from simplification of the affected drivers this is another step towards making the flags argument to gpiod_get*() mandatory. Signed-off-by: Uwe Kleine-König --- drivers/video/fbdev/omap2/displays-new/encoder-opa362.c | 12 +++--------- drivers/video/fbdev/omap2/displays-new/panel-dpi.c | 13 +++---------- .../fbdev/omap2/displays-new/panel-lgphilips-lb035q02.c | 7 +++---- .../fbdev/omap2/displays-new/panel-sharp-ls037v7dw01.c | 9 ++------- 4 files changed, 11 insertions(+), 30 deletions(-) diff --git a/drivers/video/fbdev/omap2/displays-new/encoder-opa362.c b/drivers/video/fbdev/omap2/displays-new/encoder-opa362.c index 84a6b3367124..a14d993f719d 100644 --- a/drivers/video/fbdev/omap2/displays-new/encoder-opa362.c +++ b/drivers/video/fbdev/omap2/displays-new/encoder-opa362.c @@ -201,15 +201,9 @@ static int opa362_probe(struct platform_device *pdev) platform_set_drvdata(pdev, ddata); - gpio = devm_gpiod_get(&pdev->dev, "enable"); - if (IS_ERR(gpio)) { - if (PTR_ERR(gpio) != -ENOENT) - return PTR_ERR(gpio); - - gpio = NULL; - } else { - gpiod_direction_output(gpio, 0); - } + gpio = devm_gpiod_get_optional(&pdev->dev, "enable", GPIOD_OUT_LOW); + if (IS_ERR(gpio)) + return PTR_ERR(gpio); ddata->enable_gpio = gpio; diff --git a/drivers/video/fbdev/omap2/displays-new/panel-dpi.c b/drivers/video/fbdev/omap2/displays-new/panel-dpi.c index eb8fd8140ad0..f7be3489f744 100644 --- a/drivers/video/fbdev/omap2/displays-new/panel-dpi.c +++ b/drivers/video/fbdev/omap2/displays-new/panel-dpi.c @@ -209,16 +209,9 @@ static int panel_dpi_probe_of(struct platform_device *pdev) struct videomode vm; struct gpio_desc *gpio; - gpio = devm_gpiod_get(&pdev->dev, "enable"); - - if (IS_ERR(gpio)) { - if (PTR_ERR(gpio) != -ENOENT) - return PTR_ERR(gpio); - else - gpio = NULL; - } else { - gpiod_direction_output(gpio, 0); - } + gpio = devm_gpiod_get_optional(&pdev->dev, "enable", GPIOD_OUT_LOW); + if (IS_ERR(gpio)) + return PTR_ERR(gpio); ddata->enable_gpio = gpio; diff --git a/drivers/video/fbdev/omap2/displays-new/panel-lgphilips-lb035q02.c b/drivers/video/fbdev/omap2/displays-new/panel-lgphilips-lb035q02.c index 9974a37a11af..6a1b6a89a928 100644 --- a/drivers/video/fbdev/omap2/displays-new/panel-lgphilips-lb035q02.c +++ b/drivers/video/fbdev/omap2/displays-new/panel-lgphilips-lb035q02.c @@ -285,15 +285,14 @@ static int lb035q02_probe_of(struct spi_device *spi) struct omap_dss_device *in; struct gpio_desc *gpio; - gpio = devm_gpiod_get(&spi->dev, "enable"); + gpio = devm_gpiod_get(&spi->dev, "enable", GPIOD_OUT_LOW); if (IS_ERR(gpio)) { dev_err(&spi->dev, "failed to parse enable gpio\n"); return PTR_ERR(gpio); - } else { - gpiod_direction_output(gpio, 0); - ddata->enable_gpio = gpio; } + ddata->enable_gpio = gpio; + ddata->backlight_gpio = -ENOENT; in = omapdss_of_find_source_for_first_ep(node); diff --git a/drivers/video/fbdev/omap2/displays-new/panel-sharp-ls037v7dw01.c b/drivers/video/fbdev/omap2/displays-new/panel-sharp-ls037v7dw01.c index eae263702964..abfd1f6e3327 100644 --- a/drivers/video/fbdev/omap2/displays-new/panel-sharp-ls037v7dw01.c +++ b/drivers/video/fbdev/omap2/displays-new/panel-sharp-ls037v7dw01.c @@ -268,17 +268,12 @@ static int sharp_ls_get_gpio_of(struct device *dev, int index, int val, const char *desc, struct gpio_desc **gpiod) { struct gpio_desc *gd; - int r; *gpiod = NULL; - gd = devm_gpiod_get_index(dev, desc, index); + gd = devm_gpiod_get_index(dev, desc, index, GPIOD_OUT_LOW); if (IS_ERR(gd)) - return PTR_ERR(gd) == -ENOENT ? 0 : PTR_ERR(gd); - - r = gpiod_direction_output(gd, val); - if (r) - return r; + return PTR_ERR(gd); *gpiod = gd; return 0;