Commit bad83565 authored by Peter Ujfalusi's avatar Peter Ujfalusi Committed by Vinod Koul

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: default avatarPeter Ujfalusi <peter.ujfalusi@ti.com>
Reviewed-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20200131093859.3311-2-peter.ujfalusi@ti.comSigned-off-by: default avatarVinod Koul <vkoul@kernel.org>
parent 5429b51f
...@@ -756,22 +756,21 @@ struct dma_chan *dma_request_chan(struct device *dev, const char *name) ...@@ -756,22 +756,21 @@ struct dma_chan *dma_request_chan(struct device *dev, const char *name)
} }
mutex_unlock(&dma_list_mutex); mutex_unlock(&dma_list_mutex);
if (!IS_ERR_OR_NULL(chan)) if (IS_ERR_OR_NULL(chan))
goto found;
return chan ? chan : ERR_PTR(-EPROBE_DEFER); return chan ? chan : ERR_PTR(-EPROBE_DEFER);
found: found:
chan->slave = dev;
chan->name = kasprintf(GFP_KERNEL, "dma:%s", name); chan->name = kasprintf(GFP_KERNEL, "dma:%s", name);
if (!chan->name) if (!chan->name)
return ERR_PTR(-ENOMEM); return chan;
chan->slave = dev;
if (sysfs_create_link(&chan->dev->device.kobj, &dev->kobj, if (sysfs_create_link(&chan->dev->device.kobj, &dev->kobj,
DMA_SLAVE_NAME)) DMA_SLAVE_NAME))
dev_err(dev, "Cannot create DMA %s symlink\n", DMA_SLAVE_NAME); dev_warn(dev, "Cannot create DMA %s symlink\n", DMA_SLAVE_NAME);
if (sysfs_create_link(&dev->kobj, &chan->dev->device.kobj, chan->name)) if (sysfs_create_link(&dev->kobj, &chan->dev->device.kobj, chan->name))
dev_err(dev, "Cannot create DMA %s symlink\n", chan->name); dev_warn(dev, "Cannot create DMA %s symlink\n", chan->name);
return chan; return chan;
} }
EXPORT_SYMBOL_GPL(dma_request_chan); EXPORT_SYMBOL_GPL(dma_request_chan);
...@@ -830,13 +829,14 @@ void dma_release_channel(struct dma_chan *chan) ...@@ -830,13 +829,14 @@ void dma_release_channel(struct dma_chan *chan)
/* drop PRIVATE cap enabled by __dma_request_channel() */ /* drop PRIVATE cap enabled by __dma_request_channel() */
if (--chan->device->privatecnt == 0) if (--chan->device->privatecnt == 0)
dma_cap_clear(DMA_PRIVATE, chan->device->cap_mask); dma_cap_clear(DMA_PRIVATE, chan->device->cap_mask);
if (chan->slave) { if (chan->slave) {
sysfs_remove_link(&chan->dev->device.kobj, DMA_SLAVE_NAME);
sysfs_remove_link(&chan->slave->kobj, chan->name); sysfs_remove_link(&chan->slave->kobj, chan->name);
kfree(chan->name); kfree(chan->name);
chan->name = NULL; chan->name = NULL;
chan->slave = NULL; chan->slave = NULL;
} }
sysfs_remove_link(&chan->dev->device.kobj, DMA_SLAVE_NAME);
mutex_unlock(&dma_list_mutex); mutex_unlock(&dma_list_mutex);
} }
EXPORT_SYMBOL_GPL(dma_release_channel); EXPORT_SYMBOL_GPL(dma_release_channel);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment