[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMuHMdWAxhUWPt06vcaHwD34=k=ihzVAxSTtFnO4r2bY7nAmjA@mail.gmail.com>
Date: Mon, 17 Feb 2020 22:13:17 +0100
From: Geert Uytterhoeven <geert@...ux-m68k.org>
To: Bartosz Golaszewski <brgl@...ev.pl>
Cc: Linus Walleij <linus.walleij@...aro.org>,
Srinivas Kandagatla <srinivas.kandagatla@...aro.org>,
Khouloud Touil <ktouil@...libre.com>,
"open list:GPIO SUBSYSTEM" <linux-gpio@...r.kernel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Bartosz Golaszewski <bgolaszewski@...libre.com>
Subject: Re: [PATCH 6/6] nvmem: increase the reference count of a gpio passed
over config
Hi Bartosz,
On Mon, Feb 17, 2020 at 8:56 PM Bartosz Golaszewski <brgl@...ev.pl> wrote:
> From: Bartosz Golaszewski <bgolaszewski@...libre.com>
>
> We can obtain the write-protect GPIO in nvmem_register() by requesting
> it ourselves or by storing the gpio_desc passed in nvmem_config. In the
> latter case we need to increase the reference count so that it gets
> freed correctly.
>
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@...libre.com>
Thanks for your patch!
> --- a/drivers/nvmem/core.c
> +++ b/drivers/nvmem/core.c
> @@ -349,11 +349,13 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
> return ERR_PTR(rval);
> }
>
> - if (config->wp_gpio)
> + if (config->wp_gpio) {
> nvmem->wp_gpio = config->wp_gpio;
> - else
> + gpiod_ref(config->wp_gpio);
If gpiod_ref() would return the passed GPIO, or an error code, you could write
nvmem->wp_gpio = gpiod_ref(config->wp_gpio);
> + } else {
> nvmem->wp_gpio = gpiod_get_optional(config->dev, "wp",
> GPIOD_OUT_HIGH);
> + }
> if (IS_ERR(nvmem->wp_gpio))
> goto err_ida_remove;
>
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