mirror of
https://github.com/torvalds/linux.git
synced 2026-09-24 06:24:02 +02:00
dmaengine: add dma_device_get() helper
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 <Frank.Li@nxp.com> Reviewed-by: Logan Gunthorpe <logang@deltatee.com> Signed-off-by: Shivank Garg <shivankg@amd.com> Link: https://patch.msgid.link/20260822-dmaengine-kref-fix-v5-1-d4a4ee47d927@amd.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
This commit is contained in:
parent
a7df136ec5
commit
424103642d
|
|
@ -433,6 +433,12 @@ static void dma_device_release(struct kref *ref)
|
|||
device->device_release(device);
|
||||
}
|
||||
|
||||
static int __must_check dma_device_get(struct dma_device *device)
|
||||
{
|
||||
lockdep_assert_held(&dma_list_mutex);
|
||||
return kref_get_unless_zero(&device->ref);
|
||||
}
|
||||
|
||||
static void dma_device_put(struct dma_device *device)
|
||||
{
|
||||
lockdep_assert_held(&dma_list_mutex);
|
||||
|
|
@ -460,8 +466,7 @@ static int dma_chan_get(struct dma_chan *chan)
|
|||
if (!try_module_get(owner))
|
||||
return -ENODEV;
|
||||
|
||||
ret = kref_get_unless_zero(&chan->device->ref);
|
||||
if (!ret) {
|
||||
if (!dma_device_get(chan->device)) {
|
||||
ret = -ENODEV;
|
||||
goto module_put_out;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user