Re: [PATCH 2/3] gpiolib: use kref in gpio_desc

From: Linus Walleij
Date: Sat May 16 2020 - 05:51:00 EST


On Thu, May 14, 2020 at 3:42 PM Bartosz Golaszewski <brgl@xxxxxxxx> wrote:

> So this "numbing down" of the chip works - in that I don't see any
> splat in the above use-case but right now if nvmem takes an existing
> GPIO descriptor over nvmem_config, then it will call gpiod_put() on it
> and we'll do the same in the provider driver leading to the following
> warning:

Isn't that the WARN_ON(extra_checks) in gpiod_free()?
What part of the if() clause is causing this? I.e.:
if (desc && desc->gdev && gpiod_free_commit(desc)) ...

I suspect gpiod_free_commit() is causing it by returning nonzero.
We could essentially ignore that if and only if the gpio_chip
has been detached from the gpio_device.

This should fix the problem if I'm right.

Yours,
Linus Walleij