Skip to content

Commit 10b8e0f

Browse files
ADESTMvinodkoul
authored andcommitted
dmaengine: add channel device name to channel registration
Channel device name is used for sysfs, but also by dmatest filter function. With dynamic channel registration, channels can be registered after dma controller registration. Users may want to have specific channel names. If name is NULL, the channel name relies on previous implementation, dma<controller_device_id>chan<channel_device_id>. Signed-off-by: Amelie Delaunay <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 2088473 commit 10b8e0f

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

drivers/dma/dmaengine.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,7 +1037,8 @@ static int get_dma_id(struct dma_device *device)
10371037
}
10381038

10391039
static int __dma_async_device_channel_register(struct dma_device *device,
1040-
struct dma_chan *chan)
1040+
struct dma_chan *chan,
1041+
const char *name)
10411042
{
10421043
int rc;
10431044

@@ -1066,8 +1067,10 @@ static int __dma_async_device_channel_register(struct dma_device *device,
10661067
chan->dev->device.parent = device->dev;
10671068
chan->dev->chan = chan;
10681069
chan->dev->dev_id = device->dev_id;
1069-
dev_set_name(&chan->dev->device, "dma%dchan%d",
1070-
device->dev_id, chan->chan_id);
1070+
if (!name)
1071+
dev_set_name(&chan->dev->device, "dma%dchan%d", device->dev_id, chan->chan_id);
1072+
else
1073+
dev_set_name(&chan->dev->device, name);
10711074
rc = device_register(&chan->dev->device);
10721075
if (rc)
10731076
goto err_out_ida;
@@ -1087,11 +1090,12 @@ static int __dma_async_device_channel_register(struct dma_device *device,
10871090
}
10881091

10891092
int dma_async_device_channel_register(struct dma_device *device,
1090-
struct dma_chan *chan)
1093+
struct dma_chan *chan,
1094+
const char *name)
10911095
{
10921096
int rc;
10931097

1094-
rc = __dma_async_device_channel_register(device, chan);
1098+
rc = __dma_async_device_channel_register(device, chan, name);
10951099
if (rc < 0)
10961100
return rc;
10971101

@@ -1203,7 +1207,7 @@ int dma_async_device_register(struct dma_device *device)
12031207

12041208
/* represent channels in sysfs. Probably want devs too */
12051209
list_for_each_entry(chan, &device->channels, device_node) {
1206-
rc = __dma_async_device_channel_register(device, chan);
1210+
rc = __dma_async_device_channel_register(device, chan, NULL);
12071211
if (rc < 0)
12081212
goto err_out;
12091213
}

drivers/dma/idxd/dma.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ static int idxd_register_dma_channel(struct idxd_wq *wq)
269269
desc->txd.tx_submit = idxd_dma_tx_submit;
270270
}
271271

272-
rc = dma_async_device_channel_register(dma, chan);
272+
rc = dma_async_device_channel_register(dma, chan, NULL);
273273
if (rc < 0) {
274274
kfree(idxd_chan);
275275
return rc;

include/linux/dmaengine.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1575,7 +1575,8 @@ int dma_async_device_register(struct dma_device *device);
15751575
int dmaenginem_async_device_register(struct dma_device *device);
15761576
void dma_async_device_unregister(struct dma_device *device);
15771577
int dma_async_device_channel_register(struct dma_device *device,
1578-
struct dma_chan *chan);
1578+
struct dma_chan *chan,
1579+
const char *name);
15791580
void dma_async_device_channel_unregister(struct dma_device *device,
15801581
struct dma_chan *chan);
15811582
void dma_run_dependencies(struct dma_async_tx_descriptor *tx);

0 commit comments

Comments
 (0)