mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH v2 1/2] aiodev: add helper for getting a value by its channel name
@ 2024-04-04 11:15 Sascha Hauer
  2024-04-04 11:15 ` [PATCH v2 2/2] arm: boards: Add support for protonic-mecsbc board Sascha Hauer
  2024-04-05 10:16 ` [PATCH v2 1/2] aiodev: add helper for getting a value by its channel name Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Sascha Hauer @ 2024-04-04 11:15 UTC (permalink / raw)
  To: Barebox List

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@pengutronix.de>
---
 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




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-04-05 11:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-04 11:15 [PATCH v2 1/2] aiodev: add helper for getting a value by its channel name Sascha Hauer
2024-04-04 11:15 ` [PATCH v2 2/2] arm: boards: Add support for protonic-mecsbc board Sascha Hauer
2024-04-05 10:16 ` [PATCH v2 1/2] aiodev: add helper for getting a value by its channel name Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox