[PATCH v3 14/21] gpio: add ops to get dir flags

Simon Glass sjg at chromium.org
Thu Jan 30 03:18:14 CET 2020


On Mon, 13 Jan 2020 at 03:35, Patrick Delaunay <patrick.delaunay at st.com> wrote:
>
> Add the ops for GPIO driver get_dir_flags(), allows to get dynamically
> the current gpio configuration; it is used by the API function
> dm_gpio_get_dir_flags().
>
> When these optional ops are absent, the gpio uclass continues to use
> the mandatory ops (direction_output, direction_input, get_value) and
> value of desc->flags to manage only the main dir flags:
> - GPIOD_IS_IN
> - GPIOD_IS_OUT
> - GPIOD_IS_OUT_ACTIVE
> - GPIOD_ACTIVE_LOW
>
> Signed-off-by: Patrick Delaunay <patrick.delaunay at st.com>
> ---
>
> This patch was part of v2 08/14
> = gpio: add ops for configuration with dir flags
>
>
> Changes in v3:
> - Split the previous patch [PATCH v2 08/14] to help review
>
> Changes in v2:
> - change the proposed ops for pin config to set_dir_flags/get_dir_flags
> - reused the existing API dm_gpio_set_dir_flags/dm_gpio_set_dir
> - add a new API dm_gpio_get_dir_flags
>
>  drivers/gpio/gpio-uclass.c | 31 +++++++++++++++++++++++++------
>  include/asm-generic/gpio.h | 15 +++++++++++++++
>  2 files changed, 40 insertions(+), 6 deletions(-)

Reviewed-by: Simon Glass <sjg at chromium.org>

But please see below

> diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h
> index 4f7b43f163..ac30c3ee4e 100644
> --- a/include/asm-generic/gpio.h
> +++ b/include/asm-generic/gpio.h
> @@ -297,6 +297,21 @@ struct dm_gpio_ops {
>          */
>         int (*xlate)(struct udevice *dev, struct gpio_desc *desc,
>                      struct ofnode_phandle_args *args);
> +
> +       /**
> +        * get_dir_flags() - Get GPIO dir flags
> +        *
> +        * This function return the GPIO direction flags used.

returns

used by what? This is too vague.

> +        *
> +        * This method is optional.

Please expand this (perhaps in a follow-up patch) to explain what
happens when not implemented.


> +        *
> +        * @dev:        GPIO device
> +        * @offset:     GPIO offset within that device
> +        * @flags:      place to put the used direction flags by GPIO
> +        * @return 0 if OK, -ve on error
> +        */
> +       int (*get_dir_flags)(struct udevice *dev, unsigned int offset,
> +                            ulong *flags);
>  };
>
>  /**
> --
> 2.17.1
>


More information about the U-Boot mailing list