Re: [PATCH v4 1/4] dmaengine: add dma_device_get() helper

"Garg, Shivank" <[email protected]>
Newsgroups org.kernel.vger.dmaengine,org.kernel.vger.linux-kernel,org.kernel.vger.stable
Message-ID <[email protected]>
On Tue, 2026-08-18 at 11:12 -0500, Frank Li wrote:
> On Tue, Aug 18, 2026 at 03:43:45AM +0000, Shivank Garg wrote:
> > Add dma_device_get() helper to match dma_device_put() to make code
> > symmetric. It wraps open-coded kref_get_unless_zero() and asserts that
> > dma_list_mutex is held, matching its put counterpart.
> > 
> > No functional change intended.
> > 
> > Suggested-by: Frank Li <[email protected]>
> > Signed-off-by: Shivank Garg <[email protected]>
> > ---
> >  drivers/dma/dmaengine.c | 9 +++++++--
> >  1 file changed, 7 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
> > index 6ffd8bd82154..77638dc16e71 100644
> > --- a/drivers/dma/dmaengine.c
> > +++ b/drivers/dma/dmaengine.c
> > @@ -433,6 +433,12 @@ static void dma_device_release(struct kref *ref)
> >  		device->device_release(device);
> >  }
> > 
> > +static bool dma_device_get(struct dma_device *device)
> 
> Please the same return type of kref_get_unless_zero(),
> 
> it should be int.
> 

Thanks, refcount_inc_not_zero() (and callees) returns bool to
kref_get_unless_zero(). I used bool because of boolean result value,
but I have no strong opinion here. I'll change dma_device_get() to
return int to match kref_get_unless_zero().


I think I should also add __must_check attribute, since kref_get_unless_zero()
has it.

Thanks,
Shivank
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.