From: Nuno Sa via B4 Relay <devnull+nuno.sa.analog.com@kernel.org>
To: linux-iio@vger.kernel.org
Cc: Lars-Peter Clausen <lars@metafoo.de>,
Michael Hennerich <Michael.Hennerich@analog.com>,
Jonathan Cameron <jic23@kernel.org>,
Olivier Moysan <olivier.moysan@foss.st.com>,
Dragos Bogdan <dragos.bogdan@analog.com>
Subject: [PATCH v2 1/8] iio: backend: introduce struct iio_backend_info
Date: Fri, 02 Aug 2024 16:26:59 +0200 [thread overview]
Message-ID: <20240802-dev-iio-backend-add-debugfs-v2-1-4cb62852f0d0@analog.com> (raw)
In-Reply-To: <20240802-dev-iio-backend-add-debugfs-v2-0-4cb62852f0d0@analog.com>
From: Nuno Sa <nuno.sa@analog.com>
Instead of only passing the backend ops when calling
devm_iio_backend_register(), pass an info like structure that will
contains the ops and additional information. Fow now, the backend name
is being added as that will be used by the debugFS interface introduced
in a later patch.
It also opens the door for further customizations passed by backends.
All users of devm_iio_backend_register() were updated accordingly.
Signed-off-by: Nuno Sa <nuno.sa@analog.com>
---
drivers/iio/adc/adi-axi-adc.c | 7 ++++++-
drivers/iio/dac/adi-axi-dac.c | 7 ++++++-
drivers/iio/industrialio-backend.c | 10 +++++-----
include/linux/iio/backend.h | 12 +++++++++++-
4 files changed, 28 insertions(+), 8 deletions(-)
diff --git a/drivers/iio/adc/adi-axi-adc.c b/drivers/iio/adc/adi-axi-adc.c
index 21ce7564e83db..0a9d7433da304 100644
--- a/drivers/iio/adc/adi-axi-adc.c
+++ b/drivers/iio/adc/adi-axi-adc.c
@@ -273,7 +273,7 @@ static const struct regmap_config axi_adc_regmap_config = {
.reg_stride = 4,
};
-static const struct iio_backend_ops adi_axi_adc_generic = {
+static const struct iio_backend_ops adi_axi_adc_ops = {
.enable = axi_adc_enable,
.disable = axi_adc_disable,
.data_format_set = axi_adc_data_format_set,
@@ -287,6 +287,11 @@ static const struct iio_backend_ops adi_axi_adc_generic = {
.chan_status = axi_adc_chan_status,
};
+static const struct iio_backend_info adi_axi_adc_generic = {
+ .name = "axi-adc",
+ .ops = &adi_axi_adc_ops,
+};
+
static int adi_axi_adc_probe(struct platform_device *pdev)
{
const unsigned int *expected_ver;
diff --git a/drivers/iio/dac/adi-axi-dac.c b/drivers/iio/dac/adi-axi-dac.c
index e44463f48bf5d..9655705b158be 100644
--- a/drivers/iio/dac/adi-axi-dac.c
+++ b/drivers/iio/dac/adi-axi-dac.c
@@ -507,7 +507,7 @@ static int axi_dac_set_sample_rate(struct iio_backend *back, unsigned int chan,
return 0;
}
-static const struct iio_backend_ops axi_dac_generic = {
+static const struct iio_backend_ops axi_dac_generic_ops = {
.enable = axi_dac_enable,
.disable = axi_dac_disable,
.request_buffer = axi_dac_request_buffer,
@@ -519,6 +519,11 @@ static const struct iio_backend_ops axi_dac_generic = {
.set_sample_rate = axi_dac_set_sample_rate,
};
+static const struct iio_backend_info axi_dac_generic = {
+ .name = "axi-dac",
+ .ops = &axi_dac_generic_ops,
+};
+
static const struct regmap_config axi_dac_regmap_config = {
.val_bits = 32,
.reg_bits = 32,
diff --git a/drivers/iio/industrialio-backend.c b/drivers/iio/industrialio-backend.c
index f9da635cdfeaf..0cf80ffd2e612 100644
--- a/drivers/iio/industrialio-backend.c
+++ b/drivers/iio/industrialio-backend.c
@@ -641,20 +641,20 @@ static void iio_backend_unregister(void *arg)
/**
* devm_iio_backend_register - Device managed backend device register
* @dev: Backend device being registered
- * @ops: Backend ops
+ * @info: Backend info
* @priv: Device private data
*
- * @ops is mandatory. Not providing it results in -EINVAL.
+ * @info is mandatory. Not providing it results in -EINVAL.
*
* RETURNS:
* 0 on success, negative error number on failure.
*/
int devm_iio_backend_register(struct device *dev,
- const struct iio_backend_ops *ops, void *priv)
+ const struct iio_backend_info *info, void *priv)
{
struct iio_backend *back;
- if (!ops)
+ if (!info || !info->ops)
return dev_err_probe(dev, -EINVAL, "No backend ops given\n");
/*
@@ -667,7 +667,7 @@ int devm_iio_backend_register(struct device *dev,
if (!back)
return -ENOMEM;
- back->ops = ops;
+ back->ops = info->ops;
back->owner = dev->driver->owner;
back->dev = dev;
back->priv = priv;
diff --git a/include/linux/iio/backend.h b/include/linux/iio/backend.h
index 29c4cf0bd761f..f120fa2e0a434 100644
--- a/include/linux/iio/backend.h
+++ b/include/linux/iio/backend.h
@@ -115,6 +115,16 @@ struct iio_backend_ops {
const struct iio_chan_spec *chan, char *buf);
};
+/**
+ * struct iio_backend_info - info structure for an iio_backend
+ * @name: Backend name.
+ * @ops: Backend operations.
+ */
+struct iio_backend_info {
+ const char *name;
+ const struct iio_backend_ops *ops;
+};
+
int iio_backend_chan_enable(struct iio_backend *back, unsigned int chan);
int iio_backend_chan_disable(struct iio_backend *back, unsigned int chan);
int devm_iio_backend_enable(struct device *dev, struct iio_backend *back);
@@ -151,6 +161,6 @@ __devm_iio_backend_get_from_fwnode_lookup(struct device *dev,
struct fwnode_handle *fwnode);
int devm_iio_backend_register(struct device *dev,
- const struct iio_backend_ops *ops, void *priv);
+ const struct iio_backend_info *info, void *priv);
#endif
--
2.45.2
next prev parent reply other threads:[~2024-08-02 14:27 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-02 14:26 [PATCH v2 0/8] iio: adc: ad9467: add debugFS test mode support Nuno Sa via B4 Relay
2024-08-02 14:26 ` Nuno Sa via B4 Relay [this message]
2024-08-02 14:27 ` [PATCH v2 2/8] iio: backend: add debugFs interface Nuno Sa via B4 Relay
2024-08-02 14:27 ` [PATCH v2 3/8] iio: backend: add a modified prbs23 support Nuno Sa via B4 Relay
2024-08-02 14:27 ` [PATCH v2 4/8] iio: adc: adi-axi-adc: support modified prbs23 Nuno Sa via B4 Relay
2024-08-02 14:27 ` [PATCH v2 5/8] iio: adc: adi-axi-adc: split axi_adc_chan_status() Nuno Sa via B4 Relay
2024-08-02 14:27 ` [PATCH v2 6/8] iio: adc: adi-axi-adc: implement backend debugfs interface Nuno Sa via B4 Relay
2024-08-02 14:27 ` [PATCH v2 7/8] iio: adc: ad9467: add backend test mode helpers Nuno Sa via B4 Relay
2024-08-02 14:27 ` [PATCH v2 8/8] iio: adc: ad9467: add digital interface test to debugfs Nuno Sa via B4 Relay
2024-08-03 13:38 ` Jonathan Cameron
2024-08-05 6:39 ` Nuno Sá
2024-08-03 13:39 ` [PATCH v2 0/8] iio: adc: ad9467: add debugFS test mode support Jonathan Cameron
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=20240802-dev-iio-backend-add-debugfs-v2-1-4cb62852f0d0@analog.com \
--to=devnull+nuno.sa.analog.com@kernel.org \
--cc=Michael.Hennerich@analog.com \
--cc=dragos.bogdan@analog.com \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=olivier.moysan@foss.st.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