summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorTrent Piepho <trent.piepho@synapse.com>2020-09-25 16:43:12 -0700
committerSascha Hauer <s.hauer@pengutronix.de>2020-09-29 09:04:34 +0200
commit66195d63e85e56f9fc20b61c72f8f8cef57e18d8 (patch)
treed73f79d163bef582a5e9573ec71ef541e7a6fe36 /drivers
parentec233330b0c382e79003d50f206c469344fe5960 (diff)
downloadbarebox-66195d63e85e56f9fc20b61c72f8f8cef57e18d8.tar.gz
barebox-66195d63e85e56f9fc20b61c72f8f8cef57e18d8.tar.xz
aiodev: Name channels with device instance name
When dynamically assigning device names, an aiodev's name will be "aiodev" and an index, not part of the name string itself, will be allocated dynamically. These are combined to register a device with a name like "aiodev0" or "aiodev1". The shell environment variables use the device name, so one might use "${aiodev0.in_value0_mV}" and "${aiodev1.in_value0_mV}". However, the channel names that are used with aiochannel_get_by_name() just use the aiodev's name and channel name. So channel 0 of the 1st aiodev would be "aiodev.in_value0_mV" and the 2nd aiodev would use the same name. Change the channel naming to use the device instance name, e.g. "aiodev0", rather than the aiodev's base name. This makes the names used aiochannel_get_by_name() match the environment variable names and also avoids duplicate names with more than one dynamically allocated aiodev. Rename aiochannel_get_by_name() to aiochannel_by_name() so that any out of tree boards that use it will fail to compile, since they now need to pass in a different name. Signed-off-by: Trent Piepho <trent.piepho@synapse.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/aiodev/core.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/aiodev/core.c b/drivers/aiodev/core.c
index b8428346a3..7240de2c40 100644
--- a/drivers/aiodev/core.c
+++ b/drivers/aiodev/core.c
@@ -24,7 +24,7 @@
LIST_HEAD(aiodevices);
EXPORT_SYMBOL(aiodevices);
-struct aiochannel *aiochannel_get_by_name(const char *name)
+struct aiochannel *aiochannel_by_name(const char *name)
{
struct aiodevice *aiodev;
int i;
@@ -131,7 +131,7 @@ int aiodevice_register(struct aiodevice *aiodev)
aiochannel_param_get_value,
&aiochan->value, "%d", aiochan);
- aiochan->name = xasprintf("%s.%s", aiodev->name, name);
+ aiochan->name = xasprintf("%s.%s", dev_name(&aiodev->dev), name);
free(name);
}