From patchwork Fri Jun 12 07:10:19 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: 6594861 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 60814C0020 for ; Fri, 12 Jun 2015 07:10:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7BB7D2060E for ; Fri, 12 Jun 2015 07:10:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4F32220462 for ; Fri, 12 Jun 2015 07:10:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753387AbbFLHKe (ORCPT ); Fri, 12 Jun 2015 03:10:34 -0400 Received: from metis.ext.pengutronix.de ([92.198.50.35]:52638 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753287AbbFLHKd (ORCPT ); Fri, 12 Jun 2015 03:10:33 -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 1Z3J6g-0006yE-Lt; Fri, 12 Jun 2015 09:10:26 +0200 Received: from ukl by dude.hi.pengutronix.de with local (Exim 4.85) (envelope-from ) id 1Z3J6f-0003k6-2H; Fri, 12 Jun 2015 09:10:25 +0200 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= To: Felipe Balbi , Heikki Krogerus , Greg Kroah-Hartman Cc: Alexandre Courbot , Linus Walleij , kernel@pengutronix.de, linux-usb@vger.kernel.org, linux-omap@vger.kernel.org Subject: [PATCH] usb: dwc3: pci: make better use of gpiod API Date: Fri, 12 Jun 2015 09:10:19 +0200 Message-Id: <1434093019-14009-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-omap@vger.kernel.org Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@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=ham 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. Furthermore there is devm_gpiod_get_optional which is designed to get optional gpios. Also use devm_gpiod_get* because otherwise the gpio might be grabbed by a different driver. Simplify driver accordingly. Signed-off-by: Uwe Kleine-König Acked-by: Linus Walleij --- Hello, This usage without flags was introduced by commit a89d977cc04c (usb: dwc3: pci: add quirk for Baytrails) that is currently in next. Note I plan to make the flags parameter mandatory for 4.3. So unless this change gets into 4.2, would it be ok to let it go in via the gpio tree? Best regards Uwe drivers/usb/dwc3/dwc3-pci.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c index 27e4fc896e9d..7e308730f955 100644 --- a/drivers/usb/dwc3/dwc3-pci.c +++ b/drivers/usb/dwc3/dwc3-pci.c @@ -84,18 +84,19 @@ static int dwc3_pci_quirks(struct pci_dev *pdev) acpi_dwc3_byt_gpios); /* These GPIOs will turn on the USB2 PHY */ - gpio = gpiod_get(&pdev->dev, "cs"); - if (!IS_ERR(gpio)) { - gpiod_direction_output(gpio, 0); - gpiod_set_value_cansleep(gpio, 1); - gpiod_put(gpio); - } + gpio = devm_gpiod_get_optional(&pdev->dev, "cs", GPIOD_OUT_LOW); + if (IS_ERR(gpio)) + return PTR_ERR(gpio); + + gpiod_set_value_cansleep(gpio, 1); + + gpio = devm_gpiod_get_optional(&pdev->dev, "reset", + GPIOD_OUT_LOW); + if (IS_ERR(gpio)) + return PTR_ERR(gpio); - gpio = gpiod_get(&pdev->dev, "reset"); - if (!IS_ERR(gpio)) { - gpiod_direction_output(gpio, 0); + if (gpio) { gpiod_set_value_cansleep(gpio, 1); - gpiod_put(gpio); usleep_range(10000, 11000); } }