Re: [PATCH v2 5/7] nvmem: remove unneeded __nvmem_device_put()
From: Bartosz Golaszewski
Date: Wed Apr 29 2026 - 11:55:04 EST
On Mon, Mar 23, 2026 at 5:44 PM Johan Hovold <johan@xxxxxxxxxx> wrote:
>
> On Mon, Feb 23, 2026 at 11:57:06AM +0100, Bartosz Golaszewski wrote:
> > __nvmem_device_put() is wrapped by nvmem_device_put() but there's no
> > extra functionality offered by the latter so just fold one into the
> > other.
> >
> > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxxxxxxxx>
> > ---
> > drivers/nvmem/core.c | 23 +++++++++--------------
> > 1 file changed, 9 insertions(+), 14 deletions(-)
> >
> > diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
> > index 42827ba2146ce9ba07716ac5973327da6e9426da..30aee8089f1dc65b1fa07dac8fb35e1dbbcd0ce7 100644
> > --- a/drivers/nvmem/core.c
> > +++ b/drivers/nvmem/core.c
> > @@ -1134,13 +1134,6 @@ static struct nvmem_device *__nvmem_device_get(void *data,
> > return nvmem;
> > }
> >
> > -static void __nvmem_device_put(struct nvmem_device *nvmem)
> > -{
> > - put_device(&nvmem->dev);
> > - module_put(nvmem->owner);
> > - kref_put(&nvmem->refcnt, nvmem_device_release);
> > -}
>
> Not sure this is a good idea since __nvmem_device_put() here matches
> __nvmem_device_get() just above (and we already have
> nvmem_device_get()).
>
> Keeping them together and as the inverse of each other should prevent
> things from getting out of sync.
>
> I'd just leave this as is for now.
>
In v3 I decided to propose to go even further and rename
__nvmem_device_get() to nvmem_device_match() instead as it better
reflects its function and results in symmetric refcounting (with
nvmem_device_match() returning a reference just like other
*_device_match() functions in the kernel).
Bart