* [PATCH] gpiolib: acpi: Add ACPI device NULL check to acpi_can_fallback_to_crs()
@ 2024-05-09 10:46 Laura Nao
2024-05-09 12:55 ` AngeloGioacchino Del Regno
2024-05-10 14:46 ` Andy Shevchenko
0 siblings, 2 replies; 4+ messages in thread
From: Laura Nao @ 2024-05-09 10:46 UTC (permalink / raw)
To: mika.westerberg, andriy.shevchenko
Cc: linus.walleij, brgl, kernel, linux-kernel, linux-gpio, linux-acpi,
Laura Nao, kernelci.org bot
Check ACPI device for NULL inside acpi_can_fallback_to_crs(), so callers
won't need to.
Signed-off-by: Laura Nao <laura.nao@collabora.com>
Reported-by: "kernelci.org bot" <bot@kernelci.org>
Closes: https://lore.kernel.org/all/20240426154208.81894-1-laura.nao@collabora.com/
Fixes: 49c02f6e901c ("gpiolib: acpi: Move acpi_can_fallback_to_crs() out of __acpi_find_gpio()")
---
drivers/gpio/gpiolib-acpi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
index 553a5f94c00a..688aff6e51bc 100644
--- a/drivers/gpio/gpiolib-acpi.c
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -939,7 +939,7 @@ static bool acpi_can_fallback_to_crs(struct acpi_device *adev,
const char *con_id)
{
/* Never allow fallback if the device has properties */
- if (acpi_dev_has_props(adev) || adev->driver_gpios)
+ if (!adev || acpi_dev_has_props(adev) || adev->driver_gpios)
return false;
return con_id == NULL;
--
2.30.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] gpiolib: acpi: Add ACPI device NULL check to acpi_can_fallback_to_crs()
2024-05-09 10:46 [PATCH] gpiolib: acpi: Add ACPI device NULL check to acpi_can_fallback_to_crs() Laura Nao
@ 2024-05-09 12:55 ` AngeloGioacchino Del Regno
2024-05-10 14:46 ` Andy Shevchenko
1 sibling, 0 replies; 4+ messages in thread
From: AngeloGioacchino Del Regno @ 2024-05-09 12:55 UTC (permalink / raw)
To: Laura Nao, mika.westerberg, andriy.shevchenko
Cc: linus.walleij, brgl, kernel, linux-kernel, linux-gpio, linux-acpi,
kernelci.org bot
Il 09/05/24 12:46, Laura Nao ha scritto:
> Check ACPI device for NULL inside acpi_can_fallback_to_crs(), so callers
> won't need to.
>
> Signed-off-by: Laura Nao <laura.nao@collabora.com>
> Reported-by: "kernelci.org bot" <bot@kernelci.org>
> Closes: https://lore.kernel.org/all/20240426154208.81894-1-laura.nao@collabora.com/
> Fixes: 49c02f6e901c ("gpiolib: acpi: Move acpi_can_fallback_to_crs() out of __acpi_find_gpio()")
>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] gpiolib: acpi: Add ACPI device NULL check to acpi_can_fallback_to_crs()
2024-05-09 10:46 [PATCH] gpiolib: acpi: Add ACPI device NULL check to acpi_can_fallback_to_crs() Laura Nao
2024-05-09 12:55 ` AngeloGioacchino Del Regno
@ 2024-05-10 14:46 ` Andy Shevchenko
2024-05-13 10:02 ` [PATCH] gpiolib: acpi: Add ACPI device NULL check to Laura Nao
1 sibling, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2024-05-10 14:46 UTC (permalink / raw)
To: Laura Nao
Cc: mika.westerberg, linus.walleij, brgl, kernel, linux-kernel,
linux-gpio, linux-acpi, kernelci.org bot
On Thu, May 09, 2024 at 12:46:05PM +0200, Laura Nao wrote:
> Check ACPI device for NULL inside acpi_can_fallback_to_crs(), so callers
> won't need to.
Thank you for the patch, one change seems good to have along this.
...
> /* Never allow fallback if the device has properties */
> - if (acpi_dev_has_props(adev) || adev->driver_gpios)
> + if (!adev || acpi_dev_has_props(adev) || adev->driver_gpios)
Right, since it was adev || _crs() combined.
> return false;
Now we may remove that check from __acpi_find_gpio():
--- a/drivers/gpio/gpiolib-acpi.c
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -988,10 +988,10 @@ __acpi_find_gpio(struct fwnode_handle *fwnode, const char *con_id, unsigned int
}
/* Then from plain _CRS GPIOs */
- if (!adev || !can_fallback)
- return ERR_PTR(-ENOENT);
+ if (can_fallback)
+ return acpi_get_gpiod_by_index(adev, NULL, idx, info);
- return acpi_get_gpiod_by_index(adev, NULL, idx, info);
+ return ERR_PTR(-ENOENT);
}
struct gpio_desc *acpi_find_gpio(struct fwnode_handle *fwnode,
As a side effect it will make the comment better to understand.
With above suggestion applied, feel free to add mine
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
You might need to rephrase the commit message to say that
"We also move the check in additional to the moving the function call
outside of __acpi_find_gpio()."
or something similar, up to you.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] gpiolib: acpi: Add ACPI device NULL check to
2024-05-10 14:46 ` Andy Shevchenko
@ 2024-05-13 10:02 ` Laura Nao
0 siblings, 0 replies; 4+ messages in thread
From: Laura Nao @ 2024-05-13 10:02 UTC (permalink / raw)
To: andriy.shevchenko
Cc: bot, brgl, kernel, laura.nao, linus.walleij, linux-acpi,
linux-gpio, linux-kernel, mika.westerberg
Hi Andy,
On 5/10/24 16:46, Andy Shevchenko wrote:
>
> Now we may remove that check from __acpi_find_gpio():
>
> --- a/drivers/gpio/gpiolib-acpi.c
> +++ b/drivers/gpio/gpiolib-acpi.c
> @@ -988,10 +988,10 @@ __acpi_find_gpio(struct fwnode_handle *fwnode,
> const char *con_id, unsigned int
> }
>
> /* Then from plain _CRS GPIOs */
> - if (!adev || !can_fallback)
> - return ERR_PTR(-ENOENT);
> + if (can_fallback)
> + return acpi_get_gpiod_by_index(adev, NULL, idx, info);
>
> - return acpi_get_gpiod_by_index(adev, NULL, idx, info);
> + return ERR_PTR(-ENOENT);
> }
>
> struct gpio_desc *acpi_find_gpio(struct fwnode_handle *fwnode,
>
>
> As a side effect it will make the comment better to understand.
>
> With above suggestion applied, feel free to add mine
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>
> You might need to rephrase the commit message to say that
>
> "We also move the check in additional to the moving the function
> call
> outside of __acpi_find_gpio()."
>
> or something similar, up to you.
>
Thanks for the feedback, I sent another patch with the suggestions above
applied:
https://lore.kernel.org/all/20240513095610.216668-1-laura.nao@collabora.com/T/#u
Best regards,
Laura Nao
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-05-13 10:01 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-09 10:46 [PATCH] gpiolib: acpi: Add ACPI device NULL check to acpi_can_fallback_to_crs() Laura Nao
2024-05-09 12:55 ` AngeloGioacchino Del Regno
2024-05-10 14:46 ` Andy Shevchenko
2024-05-13 10:02 ` [PATCH] gpiolib: acpi: Add ACPI device NULL check to Laura Nao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).