Commit f35bbf61 authored by Mika Westerberg's avatar Mika Westerberg Committed by Linus Walleij

gpio / ACPI: Return -EPROBE_DEFER if the gpiochip was not found

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: default avatarTobias Diedrich <tobiasdiedrich@gmail.com>
Signed-off-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
Acked-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: default avatarTobias Diedrich <ranma+kernel@tdiedrich.de>
Reviewed-by: default avatarAmos Kong <kongjianjun@gmail.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 2b528fff
...@@ -114,10 +114,11 @@ static inline int acpi_gpiochip_pin_to_gpio_offset(struct gpio_chip *chip, ...@@ -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") * @path: ACPI GPIO controller full path name, (e.g. "\\_SB.GPO1")
* @pin: ACPI GPIO pin number (0-based, controller-relative) * @pin: ACPI GPIO pin number (0-based, controller-relative)
* *
* Returns GPIO descriptor to use with Linux generic GPIO API, or ERR_PTR * Return: GPIO descriptor to use with Linux generic GPIO API, or ERR_PTR
* error value * 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) static struct gpio_desc *acpi_get_gpiod(char *path, int pin)
{ {
struct gpio_chip *chip; struct gpio_chip *chip;
...@@ -131,7 +132,7 @@ static struct gpio_desc *acpi_get_gpiod(char *path, int pin) ...@@ -131,7 +132,7 @@ static struct gpio_desc *acpi_get_gpiod(char *path, int pin)
chip = gpiochip_find(handle, acpi_gpiochip_find); chip = gpiochip_find(handle, acpi_gpiochip_find);
if (!chip) if (!chip)
return ERR_PTR(-ENODEV); return ERR_PTR(-EPROBE_DEFER);
offset = acpi_gpiochip_pin_to_gpio_offset(chip, pin); offset = acpi_gpiochip_pin_to_gpio_offset(chip, pin);
if (offset < 0) if (offset < 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment