From: Olivier Moysan <olivier.moysan@foss.st.com>
To: Nuno Sa <nuno.sa@analog.com>,
Olivier Moysan <olivier.moysan@foss.st.com>,
Jonathan Cameron <jic23@kernel.org>,
Lars-Peter Clausen <lars@metafoo.de>
Cc: <linux-iio@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: [PATCH 3/8] iio: add child nodes support in iio backend framework
Date: Tue, 18 Jun 2024 18:08:29 +0200 [thread overview]
Message-ID: <20240618160836.945242-4-olivier.moysan@foss.st.com> (raw)
In-Reply-To: <20240618160836.945242-1-olivier.moysan@foss.st.com>
Add an API to support IIO generic channels binding:
http://devicetree.org/schemas/iio/adc/adc.yaml#
This new API is needed, as generic channel DT node
isn't populated as a device.
Add devm_iio_backend_subnode_get() to allow an IIO device
backend consumer to configure backend phandles in its
child nodes.
Signed-off-by: Olivier Moysan <olivier.moysan@foss.st.com>
---
drivers/iio/industrialio-backend.c | 48 ++++++++++++++++++++++--------
include/linux/iio/backend.h | 2 ++
2 files changed, 38 insertions(+), 12 deletions(-)
diff --git a/drivers/iio/industrialio-backend.c b/drivers/iio/industrialio-backend.c
index d3db048c086b..e9d29131634d 100644
--- a/drivers/iio/industrialio-backend.c
+++ b/drivers/iio/industrialio-backend.c
@@ -575,17 +575,8 @@ static int __devm_iio_backend_get(struct device *dev, struct iio_backend *back)
return 0;
}
-/**
- * devm_iio_backend_get - Device managed backend device get
- * @dev: Consumer device for the backend
- * @name: Backend name
- *
- * Get's the backend associated with @dev.
- *
- * RETURNS:
- * A backend pointer, negative error pointer otherwise.
- */
-struct iio_backend *devm_iio_backend_get(struct device *dev, const char *name)
+static struct iio_backend *__devm_iio_backend_node_get(struct device *dev, const char *name,
+ struct fwnode_handle *node)
{
struct fwnode_handle *fwnode;
struct iio_backend *back;
@@ -602,7 +593,7 @@ struct iio_backend *devm_iio_backend_get(struct device *dev, const char *name)
index = 0;
}
- fwnode = fwnode_find_reference(dev_fwnode(dev), "io-backends", index);
+ fwnode = fwnode_find_reference(node, "io-backends", index);
if (IS_ERR(fwnode)) {
dev_err_probe(dev, PTR_ERR(fwnode),
"Cannot get Firmware reference\n");
@@ -625,8 +616,41 @@ struct iio_backend *devm_iio_backend_get(struct device *dev, const char *name)
fwnode_handle_put(fwnode);
return ERR_PTR(-EPROBE_DEFER);
}
+
+/**
+ * devm_iio_backend_get - Device managed backend device get
+ * @dev: Consumer device for the backend
+ * @name: Backend name
+ *
+ * Get's the backend associated with @dev.
+ *
+ * RETURNS:
+ * A backend pointer, negative error pointer otherwise.
+ */
+struct iio_backend *devm_iio_backend_get(struct device *dev, const char *name)
+{
+ return __devm_iio_backend_node_get(dev, name, dev_fwnode(dev));
+}
EXPORT_SYMBOL_NS_GPL(devm_iio_backend_get, IIO_BACKEND);
+/**
+ * devm_iio_backend_subnode_get - Device managed backend device get
+ * @dev: Consumer device for the backend
+ * @name: Backend name
+ * @node: Firmware node of the backend consumer
+ *
+ * Get's the backend associated with @dev.
+ *
+ * RETURNS:
+ * A backend pointer, negative error pointer otherwise.
+ */
+struct iio_backend *devm_iio_backend_subnode_get(struct device *dev, const char *name,
+ struct fwnode_handle *node)
+{
+ return __devm_iio_backend_node_get(dev, name, node);
+}
+EXPORT_SYMBOL_NS_GPL(devm_iio_backend_subnode_get, IIO_BACKEND);
+
/**
* __devm_iio_backend_get_from_fwnode_lookup - Device managed fwnode backend device get
* @dev: Consumer device for the backend
diff --git a/include/linux/iio/backend.h b/include/linux/iio/backend.h
index 81277e5b6160..1050ab68e4e4 100644
--- a/include/linux/iio/backend.h
+++ b/include/linux/iio/backend.h
@@ -152,6 +152,8 @@ int iio_backend_extend_chan_spec(struct iio_dev *indio_dev,
struct iio_chan_spec *chan);
void *iio_backend_get_priv(const struct iio_backend *conv);
struct iio_backend *devm_iio_backend_get(struct device *dev, const char *name);
+struct iio_backend *devm_iio_backend_subnode_get(struct device *dev, const char *name,
+ struct fwnode_handle *node);
struct iio_backend *
__devm_iio_backend_get_from_fwnode_lookup(struct device *dev,
struct fwnode_handle *fwnode);
--
2.25.1
next prev parent reply other threads:[~2024-06-18 16:11 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-18 16:08 [PATCH 0/8] iio: adc: dfsdm: add scaling support Olivier Moysan
2024-06-18 16:08 ` [PATCH 1/8] iio: add read raw service to iio backend framework Olivier Moysan
2024-06-19 5:25 ` Nuno Sá
2024-06-18 16:08 ` [PATCH 2/8] iio: add enable and disable services " Olivier Moysan
2024-06-19 5:21 ` Nuno Sá
2024-06-19 15:59 ` Olivier MOYSAN
2024-06-20 10:07 ` Nuno Sá
2024-06-23 13:56 ` Jonathan Cameron
2024-06-24 8:13 ` Nuno Sá
2024-06-18 16:08 ` Olivier Moysan [this message]
2024-06-19 5:31 ` [PATCH 3/8] iio: add child nodes support in " Nuno Sá
2024-06-19 16:00 ` Olivier MOYSAN
2024-06-23 13:59 ` Jonathan Cameron
2024-06-18 16:08 ` [PATCH 4/8] dt-bindings: iio: dfsdm: move to " Olivier Moysan
2024-06-18 18:10 ` Conor Dooley
2024-06-20 8:03 ` Olivier MOYSAN
2024-06-20 8:51 ` Conor Dooley
2024-06-23 15:01 ` Jonathan Cameron
2024-06-18 16:08 ` [PATCH 5/8] dt-bindings: iio: add sigma delta modulator backend Olivier Moysan
2024-06-18 18:13 ` Conor Dooley
2024-06-25 9:26 ` Olivier MOYSAN
2024-06-18 16:08 ` [PATCH 6/8] iio: adc: stm32-dfsdm: adopt generic channels bindings Olivier Moysan
2024-06-23 15:01 ` Jonathan Cameron
2024-06-18 16:08 ` [PATCH 7/8] iio: add sd modulator generic iio backend Olivier Moysan
2024-06-23 15:11 ` Jonathan Cameron
2024-06-24 12:43 ` Olivier MOYSAN
2024-06-24 15:22 ` Nuno Sá
2024-06-24 16:26 ` Olivier MOYSAN
2024-06-25 12:14 ` Nuno Sá
2024-06-24 17:41 ` Jonathan Cameron
2024-06-18 16:08 ` [PATCH 8/8] iio: adc: stm32-dfsdm: add scaling support to dfsdm Olivier Moysan
2024-06-19 5:47 ` Nuno Sá
2024-06-20 14:15 ` Olivier MOYSAN
2024-06-23 15:21 ` Jonathan Cameron
2024-06-25 9:39 ` Olivier MOYSAN
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240618160836.945242-4-olivier.moysan@foss.st.com \
--to=olivier.moysan@foss.st.com \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).