It's a common pattern to get an aiochannel by name and the value afterwards. Add a helper for this pattern. Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx> --- drivers/aiodev/core.c | 12 ++++++++++++ include/aiodev.h | 9 +++++++++ 2 files changed, 21 insertions(+) diff --git a/drivers/aiodev/core.c b/drivers/aiodev/core.c index 1fbb7b9188..5bdc4d83d4 100644 --- a/drivers/aiodev/core.c +++ b/drivers/aiodev/core.c @@ -73,6 +73,18 @@ int aiochannel_get_value(struct aiochannel *aiochan, int *value) } EXPORT_SYMBOL(aiochannel_get_value); +int aiochannel_name_get_value(const char *chname, int *value) +{ + struct aiochannel *aio; + + aio = aiochannel_by_name(chname); + if (IS_ERR(aio)) + return PTR_ERR(aio); + + return aiochannel_get_value(aio, value); +} +EXPORT_SYMBOL(aiochannel_name_get_value); + int aiochannel_get_index(struct aiochannel *aiochan) { return aiochan->index; diff --git a/include/aiodev.h b/include/aiodev.h index 56bd2da9f5..fb0807ad42 100644 --- a/include/aiodev.h +++ b/include/aiodev.h @@ -47,4 +47,13 @@ static inline const char *aiochannel_get_unit(struct aiochannel *aiochan) extern struct list_head aiodevices; #define for_each_aiodevice(aiodevice) list_for_each_entry(aiodevice, &aiodevices, list) +#ifdef CONFIG_AIODEV +int aiochannel_name_get_value(const char *chname, int *value); +#else +static inline int aiochannel_name_get_value(const char *chname, int *value) +{ + return -EOPNOTSUPP; +} +#endif + #endif -- 2.39.2