Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1162955

Re: [PATCH] gpio / ACPI: Return -EPROBE_DEFER if the gpiochip was not found

Path csiph.com!aioe.org!bofh.it!news.nic.it!robomod
From Amos Jianjun Kong <kongjianjun@gmail.com>
Newsgroups linux.kernel
Subject Re: [PATCH] gpio / ACPI: Return -EPROBE_DEFER if the gpiochip was not found
Date Thu, 11 Jun 2015 02:50:02 +0200
Message-ID <pzYQW-6ff-7@gated-at.bofh.it> (permalink)
References <pzNVx-75c-37@gated-at.bofh.it>
X-Original-To Mika Westerberg <mika.westerberg@linux.intel.com>
X-Greylist delayed 826 seconds by postgrey-1.27 at vger.kernel.org; Wed, 10 Jun 2015 20:42:57 EDT
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=cD4nRQfFF6Hj8C5ga9sl2nXu2xCwMHa7NFDzW6z9UE0=; b=LFBUw4jb7GVw+VXa3B/XS0MN0ymPGUAA2QIxSbx/Ek421TG5dHV/E7RxDL8+Ot+Jfs lr6wAFz33tVvBqR+iawColyk+L3hB/MhwZxF1tbJ4mjHrXtcA/2FAVS35YuZwlmMhEJQ haeOWBskNE8AFmSJC+6phbPqTA01a/6jb5hHMZ/T+Pa+fQvM75dVqK3QWIiHwNi+qY2d Cwcl8LKB4zXdVJn5Pkl88luCQj5jXV+60gOswiSe0KU2sTtPlt076W8U4Qri1chykKxb 8FrgUgzC+kkRNkjYkLfKX53A/c9VLYNtdKjeEsqE0M0meU+aDjLR4HJHQs8boK8zV2bH xtNQ==
MIME-Version 1.0
X-Received by 10.13.199.195 with SMTP id j186mr8055363ywd.112.1433982550478; Wed, 10 Jun 2015 17:29:10 -0700 (PDT)
Content-Type text/plain; charset=UTF-8
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 67
Organization linux.* mail to news gateway
X-Original-Cc Linus Walleij <linus.walleij@linaro.org>, Alexandre Courbot <gnurou@gmail.com>, "Rafael J. Wysocki" <rjw@rjwysocki.net>, Andy Shevchenko <andriy.shevchenko@linux.intel.com>, Tobias Diedrich <tobiasdiedrich@gmail.com>, linux-gpio@vger.kernel.org, open list <linux-kernel@vger.kernel.org>
X-Original-Date Thu, 11 Jun 2015 08:29:10 +0800
X-Original-Message-ID <CAFeW=pasTrKoSpzwYCJx9mUjeq+9HWC+v5mtHC22par5=shpPA@mail.gmail.com>
X-Original-References <1433941505-135180-1-git-send-email-mika.westerberg@linux.intel.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref aioe.org linux.kernel:1162955

Show key headers only | View raw


On Wed, Jun 10, 2015 at 9:05 PM, Mika Westerberg
<mika.westerberg@linux.intel.com> 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 <tobiasdiedrich@gmail.com>
> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
> ---
>  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.
>   */
> -

api_get_gpiod() is called in preprobe stage, we still have chance to
probe the device.

Reviewed-by: Amos Kong <kongjianjun@gmail.com>

>  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)
> --
> 2.1.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

Re: [PATCH] gpio / ACPI: Return -EPROBE_DEFER if the gpiochip was not found Amos Jianjun Kong <kongjianjun@gmail.com> - 2015-06-11 02:50 +0200

csiph-web