From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965457AbbHLHVQ (ORCPT ); Wed, 12 Aug 2015 03:21:16 -0400 Received: from metis.ext.pengutronix.de ([92.198.50.35]:40393 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965294AbbHLHVN (ORCPT ); Wed, 12 Aug 2015 03:21:13 -0400 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= To: Stephen Rothwell , Linus Walleij , Gustavo Padovan , Frederic Danis , Marcel Holtmann Cc: linux-next@vger.kernel.org, linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org, kernel@pengutronix.de Subject: [PATCH] Bluetooth: hci_bcm: improve use of gpios API Date: Wed, 12 Aug 2015 09:20:56 +0200 Message-Id: <1439364056-8564-1-git-send-email-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.4.6 In-Reply-To: <20150812165949.0d66f2be@canb.auug.org.au> References: <20150812165949.0d66f2be@canb.auug.org.au> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org devm_gpiod_get currently has an optional parameter to set initial direction and value for the requested gpio. Make use of this to simplify the driver and make it not fail to build when this parameter is made mandatory (which is scheduled for 4.3-rc1). Moreover use the _optional variant of devm_gpiod_get to simplify error handling (which also gets more strict for free). Signed-off-by: Uwe Kleine-König --- Hello, this is needed on top of commit 0395ffc1ee05 ("Bluetooth: hci_bcm: Add PM for BCM devices") incombination with b17d1bf16cc7 ("gpio: make flags mandatory for gpiod_get functions") which is currently sitting in next. Stephen fixed it up with a simpler patch, which works fine, but doesn't benefit from the nice things devm_gpiod_get et al offer. Best regards Uwe drivers/bluetooth/hci_bcm.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/drivers/bluetooth/hci_bcm.c b/drivers/bluetooth/hci_bcm.c index cb7fe837f7d9..6070303418d8 100644 --- a/drivers/bluetooth/hci_bcm.c +++ b/drivers/bluetooth/hci_bcm.c @@ -408,7 +408,6 @@ static int bcm_acpi_probe(struct bcm_device *dev) { struct platform_device *pdev = dev->pdev; const struct acpi_device_id *id; - struct gpio_desc *gpio; struct acpi_device *adev; LIST_HEAD(resources); int ret; @@ -426,21 +425,16 @@ static int bcm_acpi_probe(struct bcm_device *dev) dev->clk = devm_clk_get(&pdev->dev, NULL); - gpio = devm_gpiod_get(&pdev->dev, "device-wakeup"); - if (!IS_ERR(gpio)) { - ret = gpiod_direction_output(gpio, 0); - if (ret) - return ret; - dev->device_wakeup = gpio; - } + dev->device_wakeup = devm_gpiod_get_optional(&pdev->dev, + "device-wakeup", + GPIOD_OUT_LOW); + if (IS_ERR(dev->device_wakeup)) + return PTR_ERR(dev->device_wakeup); - gpio = devm_gpiod_get(&pdev->dev, "shutdown"); - if (!IS_ERR(gpio)) { - ret = gpiod_direction_output(gpio, 0); - if (ret) - return ret; - dev->shutdown = gpio; - } + dev->shutdown = devm_gpiod_get_optional(&pdev->dev, "shutdown", + GPIOD_OUT_LOW); + if (IS_ERR(dev->shutdown)) + return PTR_ERR(dev->shutdown); /* Make sure at-least one of the GPIO is defined and that * a name is specified for this instance -- 2.4.6