From: Matti Vaittinen <matti.vaittinen@linux.dev>
To: Matti Vaittinen <mazziesaccount@gmail.com>,
Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>,
Matti Vaittinen <matti.vaittinen@linux.dev>
Cc: "Jonathan Cameron" <jic23@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Matti Vaittinen" <mazziesaccount@gmail.com>,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 3/4] iio: dac: rohm-bd79703: Avoid copying chip-data
Date: Wed, 2 Dec 2026 15:39:08 +0200 [thread overview]
Message-ID: <e6f29d1688fb1c567fa0d05533698095ecd8df2b.1796049052.git.mazziesaccount@gmail.com> (raw)
In-Reply-To: <cover.1796049052.git.mazziesaccount@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2523 bytes --]
From: Matti Vaittinen <mazziesaccount@gmail.com>
The bd79703 driver data has been divided into a static, chip specific
data, and to an instance specific data, which can be modified at run-time.
At the moment, only the instance-specific data is usable after probe,
and only chip-type dependent constant 'num_vfs_chan', is copied to
instance-specific struct.
Upcoming support for bd7971x family of chips will introduce a need to
use a few more chip-specific static values at runtime. Copying them to
dynamic private data struct would get wasteful.
Save some bytes and minimize data copying by storing a pointer to the
constant, chip-type specific data, instead of copying all the values into
the instance specific data.
Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
---
drivers/iio/dac/rohm-bd79703.c | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/drivers/iio/dac/rohm-bd79703.c b/drivers/iio/dac/rohm-bd79703.c
index 1d58bc1544a1..b6508e1e1c4f 100644
--- a/drivers/iio/dac/rohm-bd79703.c
+++ b/drivers/iio/dac/rohm-bd79703.c
@@ -38,14 +38,6 @@ static const struct regmap_config bd79703_regmap_config = {
.cache_type = REGCACHE_MAPLE,
};
-/* Dynamic driver private data */
-struct bd79703_data {
- struct regmap *regmap;
- int vcc_mv;
- int vfs_mv;
- unsigned int num_vfs_chan;
-};
-
/* Static, IC type specific data for different variants */
struct bd7970x_chip_data {
const char *name;
@@ -58,6 +50,14 @@ struct bd7970x_chip_data {
unsigned int num_vfs_chan;
};
+/* Dynamic driver private data */
+struct bd79703_data {
+ struct regmap *regmap;
+ const struct bd7970x_chip_data *cd;
+ int vcc_mv;
+ int vfs_mv;
+};
+
static int bd79703_read_raw(struct iio_dev *idev,
struct iio_chan_spec const *chan, int *val,
int *val2, long mask)
@@ -67,7 +67,7 @@ static int bd79703_read_raw(struct iio_dev *idev,
if (mask != IIO_CHAN_INFO_SCALE)
return -EINVAL;
- if (data->num_vfs_chan > chan->channel)
+ if (data->cd->num_vfs_chan > chan->channel)
*val = data->vfs_mv;
else
*val = data->vcc_mv;
@@ -224,9 +224,10 @@ static int bd79703_probe(struct spi_device *spi)
return dev_err_probe(dev, ret, "Failed to get Vfs\n");
data->vfs_mv = ret / 1000;
- data->num_vfs_chan = cd->num_vfs_chan;
}
+ data->cd = cd;
+
idev->channels = cd->channels;
idev->num_channels = cd->num_channels;
idev->modes = INDIO_DIRECT_MODE;
--
2.56.1
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2026-12-02 13:39 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 13:38 [PATCH 0/4] Support ROHM BD7971x family of DACs Matti Vaittinen
2026-12-02 13:38 ` [PATCH 1/4] dt-bindings: iio: bd79703: Fix VFS explanation Matti Vaittinen
2026-12-02 13:38 ` [PATCH 2/4] dt-bindings: iio: dac: Add ROHM BD7971x Matti Vaittinen
2026-12-02 13:39 ` Matti Vaittinen [this message]
2026-12-02 13:39 ` [PATCH 4/4] bd79703: Support ROHM BD7971x DACs Matti Vaittinen
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=e6f29d1688fb1c567fa0d05533698095ecd8df2b.1796049052.git.mazziesaccount@gmail.com \
--to=matti.vaittinen@linux.dev \
--cc=andy@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matti.vaittinen@fi.rohmeurope.com \
--cc=mazziesaccount@gmail.com \
--cc=nuno.sa@analog.com \
--cc=robh@kernel.org \
/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
all inboxes | Powered by JetHome®