lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMpxmJXzBphmW7SWD05wtLjSAR7VBzVAgnYJYd3Sd49Bp6AmgQ@mail.gmail.com>
Date:   Thu, 28 Nov 2019 11:46:19 +0100
From:   Bartosz Golaszewski <bgolaszewski@...libre.com>
To:     Marco Felsch <m.felsch@...gutronix.de>
Cc:     Linus Walleij <linus.walleij@...aro.org>,
        Support Opensource <support.opensource@...semi.com>,
        Lee Jones <lee.jones@...aro.org>,
        Rob Herring <robh+dt@...nel.org>,
        Liam Girdwood <lgirdwood@...il.com>,
        Mark Brown <broonie@...nel.org>,
        Steve Twiss <stwiss.opensource@...semi.com>,
        Adam.Thomson.Opensource@...semi.com,
        linux-devicetree <devicetree@...r.kernel.org>,
        LKML <linux-kernel@...r.kernel.org>, kernel@...gutronix.de
Subject: Re: [PATCH v2 1/5] gpio: add support to get local gpio number

śr., 27 lis 2019 o 14:59 Marco Felsch <m.felsch@...gutronix.de> napisał(a):
>
> Sometimes consumers needs to know the gpio-chip local gpio number of a
> 'struct gpio_desc' for further configuration. This is often the case for
> mfd devices.
>

We already have this support. It's just a matter of exporting it, so
maybe adjust the commit message to not be confusing.

That being said: I'm not really a fan of this - the whole idea of gpio
descriptors was to make them opaque and their hardware offsets
irrelevant. :(

> Signed-off-by: Marco Felsch <m.felsch@...gutronix.de>
> ---
>  drivers/gpio/gpiolib.c        |  6 ++++++
>  include/linux/gpio/consumer.h | 10 ++++++++++
>  2 files changed, 16 insertions(+)
>
> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> index 104ed299d5ea..7709648313fc 100644
> --- a/drivers/gpio/gpiolib.c
> +++ b/drivers/gpio/gpiolib.c
> @@ -4377,6 +4377,12 @@ int gpiod_count(struct device *dev, const char *con_id)
>  }
>  EXPORT_SYMBOL_GPL(gpiod_count);
>
> +int gpiod_to_offset(struct gpio_desc *desc)

Maybe call it: gpiod_desc_to_offset()?

> +{
> +       return gpio_chip_hwgpio(desc);
> +}
> +EXPORT_SYMBOL_GPL(gpiod_to_offset);
> +
>  /**
>   * gpiod_get - obtain a GPIO for a given GPIO function
>   * @dev:       GPIO consumer, can be NULL for system-global GPIOs
> diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h
> index b70af921c614..e2178c3bf7fd 100644
> --- a/include/linux/gpio/consumer.h
> +++ b/include/linux/gpio/consumer.h
> @@ -60,6 +60,9 @@ enum gpiod_flags {
>  /* Return the number of GPIOs associated with a device / function */
>  int gpiod_count(struct device *dev, const char *con_id);
>
> +/* Get the local chip offset from a global desc */
> +int gpiod_to_offset(struct gpio_desc *desc);
> +
>  /* Acquire and dispose GPIOs */
>  struct gpio_desc *__must_check gpiod_get(struct device *dev,
>                                          const char *con_id,
> @@ -189,6 +192,13 @@ static inline int gpiod_count(struct device *dev, const char *con_id)
>         return 0;
>  }
>
> +static inline int gpiod_to_offset(struct gpio_desc *desc)
> +{
> +       /* GPIO can never have been requested */
> +       WARN_ON(desc);
> +       return 0;
> +}
> +
>  static inline struct gpio_desc *__must_check gpiod_get(struct device *dev,
>                                                        const char *con_id,
>                                                        enum gpiod_flags flags)
> --
> 2.20.1
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ