From mboxrd@z Thu Jan 1 00:00:00 1970 From: Markus Pargmann Subject: [PATCH v2 1/3] gpio: Use __gpiod_request directly Date: Sun, 30 Aug 2015 09:44:44 +0200 Message-ID: <1440920686-6892-2-git-send-email-mpa@pengutronix.de> References: <1440920686-6892-1-git-send-email-mpa@pengutronix.de> Return-path: Received: from metis.ext.pengutronix.de ([92.198.50.35]:35137 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751137AbbH3HpG (ORCPT ); Sun, 30 Aug 2015 03:45:06 -0400 In-Reply-To: <1440920686-6892-1-git-send-email-mpa@pengutronix.de> Sender: linux-gpio-owner@vger.kernel.org List-Id: linux-gpio@vger.kernel.org To: Linus Walleij Cc: Alexandre Courbot , Arun Bharadwaj , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Johan Hovold , chrisrfq@gmail.com, linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, kernel@pengutronix.de, Markus Pargmann There is no reason to find out chip and hwnum to use to request a gpio and get another gpio descriptor. We already have the descriptor we want to use so we can directly use it. Signed-off-by: Markus Pargmann --- drivers/gpio/gpiolib.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 79a0b41ce57b..872fdd3617c1 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -2189,25 +2189,20 @@ EXPORT_SYMBOL_GPL(__gpiod_get_index_optional); int gpiod_hog(struct gpio_desc *desc, const char *name, unsigned long lflags, enum gpiod_flags dflags) { - struct gpio_chip *chip; - struct gpio_desc *local_desc; - int hwnum; int status; - chip = gpiod_to_chip(desc); - hwnum = gpio_chip_hwgpio(desc); - - local_desc = gpiochip_request_own_desc(chip, hwnum, name); - if (IS_ERR(local_desc)) { + status = __gpiod_request(desc, name); + if (status) { pr_err("requesting hog GPIO %s (chip %s, offset %d) failed\n", - name, chip->label, hwnum); - return PTR_ERR(local_desc); + name, gpiod_to_chip(desc)->label, + gpio_chip_hwgpio(desc)); + return status; } status = gpiod_configure_flags(desc, name, lflags, dflags); if (status < 0) { pr_err("setup of hog GPIO %s (chip %s, offset %d) failed\n", - name, chip->label, hwnum); + name, gpiod_to_chip(desc)->label, gpio_chip_hwgpio(desc)); gpiochip_free_own_desc(desc); return status; } -- 2.5.0