[PATCH v2 09/19] cmd: gpio: Skip output on -ENOENT

Marek Vasut marek.vasut at mailbox.org
Sat Oct 14 21:51:41 CEST 2023


On 10/9/23 18:46, Paul Barker wrote:
> On the Renesas RZ/G2L SoC family, valid GPIO numbers are not contiguous.
> This is determined by the device tree, where a fixed number of bits are
> used for the 'pin' number within a 'port', even though not all ports
> have the same number of pins. The device tree can't be changed here
> without breaking backwards compatibility in Linux, which we don't want
> to do.
> 
> To avoid printing a status for each of these invalid GPIO numbers when
> a user executes `gpio status -a`, we allow gpio_get_function() to return
> -ENOENT when the given offset does not refer to a valid GPIO pin and we
> skip printing anything if this occurs.
> 
> Signed-off-by: Paul Barker <paul.barker.ct at bp.renesas.com>
> ---
> v1->v2:
>    * New patch to simplify `gpio status -a` output.
> 
>   cmd/gpio.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/cmd/gpio.c b/cmd/gpio.c
> index f4565982ecd9..a55d5970765b 100644
> --- a/cmd/gpio.c
> +++ b/cmd/gpio.c
> @@ -17,6 +17,7 @@
>   #endif
>   #include <asm/gpio.h>
>   #include <linux/err.h>
> +#include <dm/device_compat.h>
>   
>   __weak int name_to_gpio(const char *name)
>   {
> @@ -69,6 +70,8 @@ static void gpio_get_description(struct udevice *dev, const char *bank_name,
>   	printf("%s\n", buf);
>   	return;
>   err:
> +	if (ret == -ENOENT)
> +		return;
>   	printf("Error %d\n", ret);

You could do:

if (ret != -ENOENT)
   printf("Error %d\n", ret);

With that fixed:

Reviewed-by: Marek Vasut <marek.vasut+renesas at mailbox.org>


More information about the U-Boot mailing list