Skip to content

Commit bad8356

Browse files
Peter Ujfalusivinodkoul
authored andcommitted
dmaengine: Cleanups for the slave <-> channel symlink support
No need to use goto to jump over the return chan ? chan : ERR_PTR(-EPROBE_DEFER); We can just revert the check and return right there. Do not fail the channel request if the chan->name allocation fails, but print a warning about it. Change the dev_err to dev_warn if sysfs_create_link() fails as it is not fatal. Only attempt to remove the DMA_SLAVE_NAME symlink if it is created - or it was attempted to be created. Signed-off-by: Peter Ujfalusi <[email protected]> Reviewed-by: Geert Uytterhoeven <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 5429b51 commit bad8356

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

drivers/dma/dmaengine.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -756,22 +756,21 @@ struct dma_chan *dma_request_chan(struct device *dev, const char *name)
756756
}
757757
mutex_unlock(&dma_list_mutex);
758758

759-
if (!IS_ERR_OR_NULL(chan))
760-
goto found;
761-
762-
return chan ? chan : ERR_PTR(-EPROBE_DEFER);
759+
if (IS_ERR_OR_NULL(chan))
760+
return chan ? chan : ERR_PTR(-EPROBE_DEFER);
763761

764762
found:
765-
chan->slave = dev;
766763
chan->name = kasprintf(GFP_KERNEL, "dma:%s", name);
767764
if (!chan->name)
768-
return ERR_PTR(-ENOMEM);
765+
return chan;
766+
chan->slave = dev;
769767

770768
if (sysfs_create_link(&chan->dev->device.kobj, &dev->kobj,
771769
DMA_SLAVE_NAME))
772-
dev_err(dev, "Cannot create DMA %s symlink\n", DMA_SLAVE_NAME);
770+
dev_warn(dev, "Cannot create DMA %s symlink\n", DMA_SLAVE_NAME);
773771
if (sysfs_create_link(&dev->kobj, &chan->dev->device.kobj, chan->name))
774-
dev_err(dev, "Cannot create DMA %s symlink\n", chan->name);
772+
dev_warn(dev, "Cannot create DMA %s symlink\n", chan->name);
773+
775774
return chan;
776775
}
777776
EXPORT_SYMBOL_GPL(dma_request_chan);
@@ -830,13 +829,14 @@ void dma_release_channel(struct dma_chan *chan)
830829
/* drop PRIVATE cap enabled by __dma_request_channel() */
831830
if (--chan->device->privatecnt == 0)
832831
dma_cap_clear(DMA_PRIVATE, chan->device->cap_mask);
832+
833833
if (chan->slave) {
834+
sysfs_remove_link(&chan->dev->device.kobj, DMA_SLAVE_NAME);
834835
sysfs_remove_link(&chan->slave->kobj, chan->name);
835836
kfree(chan->name);
836837
chan->name = NULL;
837838
chan->slave = NULL;
838839
}
839-
sysfs_remove_link(&chan->dev->device.kobj, DMA_SLAVE_NAME);
840840
mutex_unlock(&dma_list_mutex);
841841
}
842842
EXPORT_SYMBOL_GPL(dma_release_channel);

0 commit comments

Comments
 (0)