[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMuHMdWigj9_CDdDD49qU-y7r+he53v1NEKE9_0RBQCFUrY-Qw@mail.gmail.com>
Date: Mon, 20 Jan 2020 09:44:43 +0100
From: Geert Uytterhoeven <geert@...ux-m68k.org>
To: Bartosz Golaszewski <brgl@...ev.pl>
Cc: Kent Gibson <warthog618@...il.com>,
Linus Walleij <linus.walleij@...aro.org>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
"open list:GPIO SUBSYSTEM" <linux-gpio@...r.kernel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Bartosz Golaszewski <bgolaszewski@...libre.com>,
Andy Shevchenko <andy.shevchenko@...il.com>
Subject: Re: [PATCH v4 02/13] gpiolib: have a single place of calling set_config()
Hi Bartosz,
On Tue, Dec 24, 2019 at 1:08 PM Bartosz Golaszewski <brgl@...ev.pl> wrote:
> From: Bartosz Golaszewski <bgolaszewski@...libre.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.
>
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@...libre.com>
> Reviewed-by: Andy Shevchenko <andy.shevchenko@...il.com>
> --- 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);
These two lines are not equivalent: the new code no longer uses the
packed value of mode and arg!
Hence this leads to subsequent cleanups in commits e5e42ad224a040f9
("gpiolib: remove set but not used variable 'config'") and d18fddff061d2796
("gpiolib: Remove duplicated function gpio_do_set_config()").
However, what was the purpose of the PIN_CONF_PACKED() translation?
Why is it no longer needed?
Thanks!
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@...ux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Powered by blists - more mailing lists