linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] gpio: generic: Revert to old error handling in bgpio_map
@ 2015-10-21  7:12 Guenter Roeck
  2015-10-21  9:13 ` Heiner Kallweit
  2015-10-27 10:28 ` Linus Walleij
  0 siblings, 2 replies; 3+ messages in thread
From: Guenter Roeck @ 2015-10-21  7:12 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Alexandre Courbot, linux-gpio, linux-kernel, Guenter Roeck,
	Heiner Kallweit

Returning an error instead of NULL in bgpio_map if
platform_get_resource_byname does not find a resource was introduced with
commit cf3f2a2c8bae ("gpio: generic: improve error handling in bgpio_map").
This results in several qemu runtime failures with default and non-default
configurations, if attempts are made to boot from mmcblk0. Examples for
failures with multi_v7_defconfig are

Machine: vexpress-a9	dtb: vexpress-v2p-ca9
Machine: vexpress-a15	dtb: vexpress-v2p-ca15-tc1

Crash:

VFS: Cannot open root device "mmcblk0" or unknown-block(0,0): error -6
Please append a correct "root=" boot option; here are the available partitions:
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)

Looking into the code, always returning an error if bgpio_map fails
does not appear to make much sense, since the code in bgpio_setup_io
specifically supports some of the resources to be NULL.

Fixes: cf3f2a2c8bae ("gpio: generic: improve error handling in bgpio_map")
Cc: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 drivers/gpio/gpio-generic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-generic.c b/drivers/gpio/gpio-generic.c
index d8b1700b9519..bd5193c67a9c 100644
--- a/drivers/gpio/gpio-generic.c
+++ b/drivers/gpio/gpio-generic.c
@@ -586,7 +586,7 @@ static void __iomem *bgpio_map(struct platform_device *pdev,
 
 	r = platform_get_resource_byname(pdev, IORESOURCE_MEM, name);
 	if (!r)
-		return IOMEM_ERR_PTR(-EINVAL);
+		return NULL;
 
 	sz = resource_size(r);
 	if (sz != sane_sz)
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH -next] gpio: generic: Revert to old error handling in bgpio_map
  2015-10-21  7:12 [PATCH -next] gpio: generic: Revert to old error handling in bgpio_map Guenter Roeck
@ 2015-10-21  9:13 ` Heiner Kallweit
  2015-10-27 10:28 ` Linus Walleij
  1 sibling, 0 replies; 3+ messages in thread
From: Heiner Kallweit @ 2015-10-21  9:13 UTC (permalink / raw)
  To: Guenter Roeck; +Cc: Linus Walleij, Alexandre Courbot, linux-gpio, linux-kernel

On Wed, Oct 21, 2015 at 9:12 AM, Guenter Roeck <linux@roeck-us.net> wrote:
> Returning an error instead of NULL in bgpio_map if
> platform_get_resource_byname does not find a resource was introduced with
> commit cf3f2a2c8bae ("gpio: generic: improve error handling in bgpio_map").
> This results in several qemu runtime failures with default and non-default
> configurations, if attempts are made to boot from mmcblk0. Examples for
> failures with multi_v7_defconfig are
>
> Machine: vexpress-a9    dtb: vexpress-v2p-ca9
> Machine: vexpress-a15   dtb: vexpress-v2p-ca15-tc1
>
> Crash:
>
> VFS: Cannot open root device "mmcblk0" or unknown-block(0,0): error -6
> Please append a correct "root=" boot option; here are the available partitions:
> Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
>
> Looking into the code, always returning an error if bgpio_map fails
> does not appear to make much sense, since the code in bgpio_setup_io
> specifically supports some of the resources to be NULL.
>
Indeed. Seems like "dat" is the only mandatory resource.
Previously there was a double check that "dat" is set:
in bgpio_dev_probe and in bgpio_setup_io

With your proposed patch the check in bgpio_dev_probe is removed.
Due to the (previously redundant) check in bgpio_setup_io it's ok however.

One could only discuss whether "dat" should be checked as early as possible
(in bgpio_dev_probe instead of bgpio_setup_io).
But that's something I'd consider to be more or less cosmetic.

> Fixes: cf3f2a2c8bae ("gpio: generic: improve error handling in bgpio_map")
> Cc: Heiner Kallweit <hkallweit1@gmail.com>
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> ---
>  drivers/gpio/gpio-generic.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpio/gpio-generic.c b/drivers/gpio/gpio-generic.c
> index d8b1700b9519..bd5193c67a9c 100644
> --- a/drivers/gpio/gpio-generic.c
> +++ b/drivers/gpio/gpio-generic.c
> @@ -586,7 +586,7 @@ static void __iomem *bgpio_map(struct platform_device *pdev,
>
>         r = platform_get_resource_byname(pdev, IORESOURCE_MEM, name);
>         if (!r)
> -               return IOMEM_ERR_PTR(-EINVAL);
> +               return NULL;
>
>         sz = resource_size(r);
>         if (sz != sane_sz)
> --
> 2.1.4
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH -next] gpio: generic: Revert to old error handling in bgpio_map
  2015-10-21  7:12 [PATCH -next] gpio: generic: Revert to old error handling in bgpio_map Guenter Roeck
  2015-10-21  9:13 ` Heiner Kallweit
@ 2015-10-27 10:28 ` Linus Walleij
  1 sibling, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2015-10-27 10:28 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Alexandre Courbot, linux-gpio@vger.kernel.org,
	linux-kernel@vger.kernel.org, Heiner Kallweit

On Wed, Oct 21, 2015 at 9:12 AM, Guenter Roeck <linux@roeck-us.net> wrote:

> Returning an error instead of NULL in bgpio_map if
> platform_get_resource_byname does not find a resource was introduced with
> commit cf3f2a2c8bae ("gpio: generic: improve error handling in bgpio_map").
> This results in several qemu runtime failures with default and non-default
> configurations, if attempts are made to boot from mmcblk0. Examples for
> failures with multi_v7_defconfig are
>
> Machine: vexpress-a9    dtb: vexpress-v2p-ca9
> Machine: vexpress-a15   dtb: vexpress-v2p-ca15-tc1
>
> Crash:
>
> VFS: Cannot open root device "mmcblk0" or unknown-block(0,0): error -6
> Please append a correct "root=" boot option; here are the available partitions:
> Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
>
> Looking into the code, always returning an error if bgpio_map fails
> does not appear to make much sense, since the code in bgpio_setup_io
> specifically supports some of the resources to be NULL.
>
> Fixes: cf3f2a2c8bae ("gpio: generic: improve error handling in bgpio_map")
> Cc: Heiner Kallweit <hkallweit1@gmail.com>
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>

Patch/revert applied. Thanks for digging in and fixing this Günther!

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-10-27 10:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-21  7:12 [PATCH -next] gpio: generic: Revert to old error handling in bgpio_map Guenter Roeck
2015-10-21  9:13 ` Heiner Kallweit
2015-10-27 10:28 ` Linus Walleij

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).