2008-10-30 00:29:18

by Kay Sievers

[permalink] [raw]
Subject: dmaengine: struct device - replace bus_id with dev_name(), dev_set_name()

This patch is part of a larger patch series which will remove
the "char bus_id[20]" name string from struct device. The device
name is managed in the kobject anyway, and without any size
limitation, and just needlessly copied into "struct device".

To set and read the device name dev_name(dev) and dev_set_name(dev)
must be used. If your code uses static kobjects, which it shouldn't
do, "const char *init_name" can be used to statically provide the
name the registered device should have. At registration time, the
init_name field is cleared, to enforce the use of dev_name(dev) to
access the device name at a later time.

We need to get rid of all occurrences of bus_id in the entire tree
to be able to enable the new interface. Please apply this patch,
and possibly convert any remaining remaining occurrences of bus_id.

We want to submit a patch to -next, which will remove bus_id from
"struct device", to find the remaining pieces to convert, and finally
switch over to the new api, which will remove the 20 bytes array
and does no longer have a size limitation.

Thanks,
Kay


From: Kay Sievers <[email protected]>
Subject: dmaengine: struct device - replace bus_id with dev_name(), dev_set_name()

Cc: Maciej Sosnowski <[email protected]>
Cc: Dan Williams <[email protected]>
Acked-by: Greg Kroah-Hartman <[email protected]>
Signed-Off-By: Kay Sievers <[email protected]>
---


diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
index dc003a3..5317e08 100644
--- a/drivers/dma/dmaengine.c
+++ b/drivers/dma/dmaengine.c
@@ -399,8 +399,8 @@ int dma_async_device_register(struct dma_device *device)
chan->chan_id = chancnt++;
chan->dev.class = &dma_devclass;
chan->dev.parent = device->dev;
- snprintf(chan->dev.bus_id, BUS_ID_SIZE, "dma%dchan%d",
- device->dev_id, chan->chan_id);
+ dev_set_name(&chan->dev, "dma%dchan%d",
+ device->dev_id, chan->chan_id);

rc = device_register(&chan->dev);
if (rc) {
diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c
index d1e381e..ed9636b 100644
--- a/drivers/dma/dmatest.c
+++ b/drivers/dma/dmatest.c
@@ -20,11 +20,11 @@ static unsigned int test_buf_size = 16384;
module_param(test_buf_size, uint, S_IRUGO);
MODULE_PARM_DESC(test_buf_size, "Size of the memcpy test buffer");

-static char test_channel[BUS_ID_SIZE];
+static char test_channel[20];
module_param_string(channel, test_channel, sizeof(test_channel), S_IRUGO);
MODULE_PARM_DESC(channel, "Bus ID of the channel to test (default: any)");

-static char test_device[BUS_ID_SIZE];
+static char test_device[20];
module_param_string(device, test_device, sizeof(test_device), S_IRUGO);
MODULE_PARM_DESC(device, "Bus ID of the DMA Engine to test (default: any)");

@@ -80,14 +80,14 @@ static bool dmatest_match_channel(struct dma_chan *chan)
{
if (test_channel[0] == '\0')
return true;
- return strcmp(chan->dev.bus_id, test_channel) == 0;
+ return strcmp(dev_name(&chan->dev), test_channel) == 0;
}

static bool dmatest_match_device(struct dma_device *device)
{
if (test_device[0] == '\0')
return true;
- return strcmp(device->dev->bus_id, test_device) == 0;
+ return strcmp(dev_name(device->dev), test_device) == 0;
}

static unsigned long dmatest_random(void)
@@ -332,7 +332,7 @@ static enum dma_state_client dmatest_add_channel(struct dma_chan *chan)

dtc = kmalloc(sizeof(struct dmatest_chan), GFP_KERNEL);
if (!dtc) {
- pr_warning("dmatest: No memory for %s\n", chan->dev.bus_id);
+ pr_warning("dmatest: No memory for %s\n", dev_name(&chan->dev));
return DMA_NAK;
}

@@ -343,16 +343,16 @@ static enum dma_state_client dmatest_add_channel(struct dma_chan *chan)
thread = kzalloc(sizeof(struct dmatest_thread), GFP_KERNEL);
if (!thread) {
pr_warning("dmatest: No memory for %s-test%u\n",
- chan->dev.bus_id, i);
+ dev_name(&chan->dev), i);
break;
}
thread->chan = dtc->chan;
smp_wmb();
thread->task = kthread_run(dmatest_func, thread, "%s-test%u",
- chan->dev.bus_id, i);
+ dev_name(&chan->dev), i);
if (IS_ERR(thread->task)) {
pr_warning("dmatest: Failed to run thread %s-test%u\n",
- chan->dev.bus_id, i);
+ dev_name(&chan->dev), i);
kfree(thread);
break;
}
@@ -362,7 +362,7 @@ static enum dma_state_client dmatest_add_channel(struct dma_chan *chan)
list_add_tail(&thread->node, &dtc->threads);
}

- pr_info("dmatest: Started %u threads using %s\n", i, chan->dev.bus_id);
+ pr_info("dmatest: Started %u threads using %s\n", i, dev_name(&chan->dev));

list_add_tail(&dtc->node, &dmatest_channels);
nr_channels++;
@@ -379,7 +379,7 @@ static enum dma_state_client dmatest_remove_channel(struct dma_chan *chan)
list_del(&dtc->node);
dmatest_cleanup_channel(dtc);
pr_debug("dmatest: lost channel %s\n",
- chan->dev.bus_id);
+ dev_name(&chan->dev));
return DMA_ACK;
}
}
@@ -418,7 +418,7 @@ dmatest_event(struct dma_client *client, struct dma_chan *chan,

default:
pr_info("dmatest: Unhandled event %u (%s)\n",
- state, chan->dev.bus_id);
+ state, dev_name(&chan->dev));
break;
}


2008-11-03 16:54:28

by Sosnowski, Maciej

[permalink] [raw]
Subject: RE: dmaengine: struct device - replace bus_id with dev_name(),dev_set_name()

Kay Sievers wrote:
> This patch is part of a larger patch series which will remove
> the "char bus_id[20]" name string from struct device. The device
> name is managed in the kobject anyway, and without any size
> limitation, and just needlessly copied into "struct device".
>
> To set and read the device name dev_name(dev) and dev_set_name(dev)
> must be used. If your code uses static kobjects, which it shouldn't
> do, "const char *init_name" can be used to statically provide the
> name the registered device should have. At registration time, the
> init_name field is cleared, to enforce the use of dev_name(dev) to
> access the device name at a later time.
>
> We need to get rid of all occurrences of bus_id in the entire tree
> to be able to enable the new interface. Please apply this patch,
> and possibly convert any remaining remaining occurrences of bus_id.
>
> We want to submit a patch to -next, which will remove bus_id from
> "struct device", to find the remaining pieces to convert, and finally
> switch over to the new api, which will remove the 20 bytes array
> and does no longer have a size limitation.
>
> Thanks,
> Kay
>
>
> From: Kay Sievers <[email protected]>
> Subject: dmaengine: struct device - replace bus_id with dev_name(),
> dev_set_name()
>
> Cc: Maciej Sosnowski <[email protected]>
> Cc: Dan Williams <[email protected]>
> Acked-by: Greg Kroah-Hartman <[email protected]>
> Signed-Off-By: Kay Sievers <[email protected]>
> ---

Acked-by: Maciej Sosnowski <[email protected]>

2008-11-04 23:01:18

by Dan Williams

[permalink] [raw]
Subject: Re: dmaengine: struct device - replace bus_id with dev_name(), dev_set_name()

On Wed, Oct 29, 2008 at 5:29 PM, Kay Sievers <[email protected]> wrote:
> We need to get rid of all occurrences of bus_id in the entire tree
> to be able to enable the new interface. Please apply this patch,
> and possibly convert any remaining remaining occurrences of bus_id.
>

Applied to async_tx.git#next.