linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Bartosz Golaszewski <brgl@bgdev.pl>
Cc: Kent Gibson <warthog618@gmail.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	"open list:GPIO SUBSYSTEM" <linux-gpio@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Bartosz Golaszewski <bgolaszewski@baylibre.com>
Subject: Re: [PATCH v2 02/11] gpiolib: have a single place of calling set_config()
Date: Thu, 5 Dec 2019 00:18:40 +0200	[thread overview]
Message-ID: <CAHp75Vc2E4iXDvq4wV7nkoizPaz_vRxfYztzwStt9ux9oYWExg@mail.gmail.com> (raw)
In-Reply-To: <20191204155912.17590-3-brgl@bgdev.pl>

On Wed, Dec 4, 2019 at 6:04 PM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
>
> From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
>
> Instead of calling the gpiochip's set_config() callback directly and
> checking its existence every time - just add a new routine that performs
> this check internally. Call it in gpio_set_config() and
> gpiod_set_transitory(). Also call it in gpiod_set_debounce() and drop
> the check for chip->set() as it's irrelevant to this config option.
>

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> ---
>  drivers/gpio/gpiolib.c | 21 ++++++++++++---------
>  1 file changed, 12 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> index a31797fe78fa..72211407469f 100644
> --- a/drivers/gpio/gpiolib.c
> +++ b/drivers/gpio/gpiolib.c
> @@ -3042,6 +3042,15 @@ EXPORT_SYMBOL_GPL(gpiochip_free_own_desc);
>   * rely on gpio_request() having been called beforehand.
>   */
>
> +static int gpio_do_set_config(struct gpio_chip *gc, unsigned int offset,
> +                             enum pin_config_param mode)
> +{
> +       if (!gc->set_config)
> +               return -ENOTSUPP;
> +
> +       return gc->set_config(gc, offset, mode);
> +}
> +
>  static int gpio_set_config(struct gpio_chip *gc, unsigned int offset,
>                            enum pin_config_param mode)
>  {
> @@ -3060,7 +3069,7 @@ static int gpio_set_config(struct gpio_chip *gc, unsigned int offset,
>         }
>
>         config = PIN_CONF_PACKED(mode, arg);
> -       return gc->set_config ? gc->set_config(gc, offset, config) : -ENOTSUPP;
> +       return gpio_do_set_config(gc, offset, mode);
>  }
>
>  static int gpio_set_bias(struct gpio_chip *chip, struct gpio_desc *desc)
> @@ -3294,15 +3303,9 @@ int gpiod_set_debounce(struct gpio_desc *desc, unsigned debounce)
>
>         VALIDATE_DESC(desc);
>         chip = desc->gdev->chip;
> -       if (!chip->set || !chip->set_config) {
> -               gpiod_dbg(desc,
> -                         "%s: missing set() or set_config() operations\n",
> -                         __func__);
> -               return -ENOTSUPP;
> -       }
>
>         config = pinconf_to_config_packed(PIN_CONFIG_INPUT_DEBOUNCE, debounce);
> -       return chip->set_config(chip, gpio_chip_hwgpio(desc), config);
> +       return gpio_do_set_config(chip, gpio_chip_hwgpio(desc), config);
>  }
>  EXPORT_SYMBOL_GPL(gpiod_set_debounce);
>
> @@ -3339,7 +3342,7 @@ int gpiod_set_transitory(struct gpio_desc *desc, bool transitory)
>         packed = pinconf_to_config_packed(PIN_CONFIG_PERSIST_STATE,
>                                           !transitory);
>         gpio = gpio_chip_hwgpio(desc);
> -       rc = chip->set_config(chip, gpio, packed);
> +       rc = gpio_do_set_config(chip, gpio, packed);
>         if (rc == -ENOTSUPP) {
>                 dev_dbg(&desc->gdev->dev, "Persistence not supported for GPIO %d\n",
>                                 gpio);
> --
> 2.23.0
>


-- 
With Best Regards,
Andy Shevchenko

  reply	other threads:[~2019-12-04 22:18 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-04 15:59 [PATCH v2 00/11] gpiolib: add an ioctl() for monitoring line status changes Bartosz Golaszewski
2019-12-04 15:59 ` [PATCH v2 01/11] gpiolib: use 'unsigned int' instead of 'unsigned' in gpio_set_config() Bartosz Golaszewski
2019-12-04 22:18   ` Andy Shevchenko
2019-12-04 15:59 ` [PATCH v2 02/11] gpiolib: have a single place of calling set_config() Bartosz Golaszewski
2019-12-04 22:18   ` Andy Shevchenko [this message]
2019-12-04 15:59 ` [PATCH v2 03/11] gpiolib: convert the type of hwnum to unsigned int in gpiochip_get_desc() Bartosz Golaszewski
2019-12-04 22:19   ` Andy Shevchenko
2019-12-04 15:59 ` [PATCH v2 04/11] gpiolib: use gpiochip_get_desc() in linehandle_create() Bartosz Golaszewski
2019-12-04 22:20   ` Andy Shevchenko
2019-12-04 15:59 ` [PATCH v2 05/11] gpiolib: use gpiochip_get_desc() in lineevent_create() Bartosz Golaszewski
2019-12-04 22:20   ` Andy Shevchenko
2019-12-04 15:59 ` [PATCH v2 06/11] gpiolib: use gpiochip_get_desc() in gpio_ioctl() Bartosz Golaszewski
2019-12-04 16:25   ` Rainer Sickinger
2019-12-04 22:21   ` Andy Shevchenko
2019-12-04 15:59 ` [PATCH v2 07/11] gpiolib: rework the locking mechanism for lineevent kfifo Bartosz Golaszewski
2019-12-04 22:25   ` Andy Shevchenko
2019-12-05  9:31     ` Bartosz Golaszewski
2019-12-05 10:22       ` Andy Shevchenko
2019-12-04 15:59 ` [PATCH v2 08/11] gpiolib: emit a debug message when adding events to a full kfifo Bartosz Golaszewski
2019-12-04 22:28   ` Andy Shevchenko
2019-12-19 16:22     ` Bartosz Golaszewski
2019-12-04 15:59 ` [PATCH v2 09/11] gpiolib: provide a dedicated function for setting lineinfo Bartosz Golaszewski
2019-12-04 22:30   ` Andy Shevchenko
2019-12-05  9:28     ` Bartosz Golaszewski
2019-12-05 10:20       ` Andy Shevchenko
2019-12-05 13:45         ` Bartosz Golaszewski
2019-12-05 16:47           ` Andy Shevchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAHp75Vc2E4iXDvq4wV7nkoizPaz_vRxfYztzwStt9ux9oYWExg@mail.gmail.com \
    --to=andy.shevchenko@gmail.com \
    --cc=bgolaszewski@baylibre.com \
    --cc=brgl@bgdev.pl \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=warthog618@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).