From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932654AbbFJXR7 (ORCPT ); Wed, 10 Jun 2015 19:17:59 -0400 Received: from v094114.home.net.pl ([79.96.170.134]:45406 "HELO v094114.home.net.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1751727AbbFJXRv (ORCPT ); Wed, 10 Jun 2015 19:17:51 -0400 From: "Rafael J. Wysocki" To: Mika Westerberg Cc: Linus Walleij , Alexandre Courbot , Andy Shevchenko , Tobias Diedrich , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] gpio / ACPI: Return -EPROBE_DEFER if the gpiochip was not found Date: Thu, 11 Jun 2015 01:43:41 +0200 Message-ID: <5235346.FKkPIUuDpF@vostro.rjw.lan> User-Agent: KMail/4.11.5 (Linux/4.1.0-rc5+; KDE/4.11.5; x86_64; ; ) In-Reply-To: <1433941505-135180-1-git-send-email-mika.westerberg@linux.intel.com> References: <1433941505-135180-1-git-send-email-mika.westerberg@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="utf-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wednesday, June 10, 2015 04:05:05 PM Mika Westerberg wrote: > If a driver requests a GPIO described in its _CRS but the GPIO host > controller (gpiochip) driver providing the GPIO has not been loaded yet > acpi_get_gpiod() returns -ENODEV which causes the calling driver to fail. > > If the gpiochip driver is loaded afterwards the driver requesting the GPIO > will not notice this. > > Better approach is to return -EPROBE_DEFER in such case. Then when the > gpiochip driver appears the driver requesting the GPIO will be probed > again. This also aligns ACPI GPIO lookup code closer to DT as it does > pretty much the same when no gpiochip driver was found. > > Reported-by: Tobias Diedrich > Signed-off-by: Mika Westerberg Makes sense to me. Acked-by: Rafael J. Wysocki > --- > drivers/gpio/gpiolib-acpi.c | 9 +++++---- > 1 file changed, 5 insertions(+), 4 deletions(-) > > diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c > index 19b99d0c2bf0..b49006c81a7f 100644 > --- a/drivers/gpio/gpiolib-acpi.c > +++ b/drivers/gpio/gpiolib-acpi.c > @@ -114,10 +114,11 @@ static inline int acpi_gpiochip_pin_to_gpio_offset(struct gpio_chip *chip, > * @path: ACPI GPIO controller full path name, (e.g. "\\_SB.GPO1") > * @pin: ACPI GPIO pin number (0-based, controller-relative) > * > - * Returns GPIO descriptor to use with Linux generic GPIO API, or ERR_PTR > - * error value > + * Return: GPIO descriptor to use with Linux generic GPIO API, or ERR_PTR > + * error value. Specifically returns %-EPROBE_DEFER if the referenced GPIO > + * controller does not have gpiochip registered at the moment. This is to > + * support probe deferral. > */ > - > static struct gpio_desc *acpi_get_gpiod(char *path, int pin) > { > struct gpio_chip *chip; > @@ -131,7 +132,7 @@ static struct gpio_desc *acpi_get_gpiod(char *path, int pin) > > chip = gpiochip_find(handle, acpi_gpiochip_find); > if (!chip) > - return ERR_PTR(-ENODEV); > + return ERR_PTR(-EPROBE_DEFER); > > offset = acpi_gpiochip_pin_to_gpio_offset(chip, pin); > if (offset < 0) > -- I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.