From: Jonathan Cameron <jic23@kernel.org>
To: "Siratul Islam" <siratul.islam@linux.dev>
Cc: Lukas <lukas.metz@gmx.net>,
"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>,
linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org,
devicetree@vger.kernel.org
Subject: Re: [PATCH v2 2/2] iio: dac: dac8163: Add driver for DAC8163
Date: Sun, 26 Jul 2026 19:18:33 +0100 [thread overview]
Message-ID: <20260726191833.67dcfac2@jic23-huawei> (raw)
In-Reply-To: <6b3f1b6188afbb8ebf9576274894b5ed292eca92@linux.dev>
On Sun, 26 Jul 2026 17:01:51 +0000
"Siratul Islam" <siratul.islam@linux.dev> wrote:
> July 26, 2026 at 8:10 PM, "Lukas" <lukas.metz@gmx.net mailto:lukas.metz@gmx.net?to=%22Lukas%22%20%3Clukas.metz%40gmx.net%3E > wrote:
>
>
> >
> > On Wed, Jul 08, 2026 at 09:58:13PM +0600, Siratul Islam wrote:
> >
> > >
> > > +
> > > + const struct reg_default reg_defaults[] = {
> > > + {
> > > + .reg = CMD_SET(CMD_WRITE_UPDATE, 0),
> > > + .def = info->default_output_reg,
> > > + },
> > > + {
> > > + .reg = CMD_SET(CMD_WRITE_UPDATE, 1),
> > > + .def = info->default_output_reg,
> > > + },
> > > + };
> > > +
> > > + const struct regmap_config regmap_config = {
> > > + .reg_bits = 8,
> > > + .val_bits = 16,
> > > +
> > > + .max_register = CMD_REF << 3,
> > > + .cache_type = REGCACHE_MAPLE,
> > > +
> > > + .volatile_reg = dac8163_reg_false,
> > > +
> > > + .reg_defaults = reg_defaults,
> > > + .num_reg_defaults = ARRAY_SIZE(reg_defaults),
> > > + };
> > > Why are these defined inside probe? Should be defined outside the function.
> > >
> > The default values after reset are different for the compatible devices
> > (0 for the dacxxx2 devices and mid-scale for the dacxxx3 devices).
> > So these are runtime dependent. The alternative would be to have two
> > regmap_configs for the two device types and add these to the chip_info.
> > Or do you have another suggestion?
> You don't need two regmap_configs. The way I would do it is, move the "regmap_config" out of probe and name it something
> like "dac8563_regmap_config". And in chip info struct, replace "default_output_reg" with "reg_defaults[]".
> Then for each "dacxxxx_chip_info" define the appropriate "reg_defaults" configuration.
>
> This way you can do
>
> struct regmap_config regmap_config = dac8563_regmap_config;
> ...
> regmap_config.reg_defaults = info->reg_defaults;
> regmap_config.num_reg_defaults = ARRAY_SIZE(info->reg_defaults);
>
> A bit of work, but it would ensure most of the work is done at compile time,
> and we avoid reconstructing these sructs everytime probe runs.
As this has come up, I'd favour just having two static const regmap_config structures
and picking between them. Obviously I haven't checked but I'd guess that any
overhead of extra text data for those is not that different to the extra code of the current
approach. Generally if you can make this sort of thing data rather than code it
is a net gain.
Jonathan
>
> >
> > Best regards
> >
> > Lukas
> >
> --
> Best regards,
> Sirat
next prev parent reply other threads:[~2026-07-26 18:18 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-08 9:52 [PATCH v2 0/2] Add driver for DAC8163: Lukas Metz
2026-07-08 9:52 ` [PATCH v2 1/2] dt-bindings: iio: dac: Add DAC8163 Lukas Metz
2026-07-08 10:06 ` sashiko-bot
2026-07-08 16:37 ` Conor Dooley
2026-07-14 15:01 ` Lukas
2026-07-14 16:49 ` Conor Dooley
2026-07-14 19:25 ` David Lechner
2026-07-08 9:52 ` [PATCH v2 2/2] iio: dac: dac8163: Add driver for DAC8163 Lukas Metz
2026-07-08 10:04 ` sashiko-bot
2026-07-08 11:32 ` Andy Shevchenko
2026-07-09 10:03 ` Lukas
2026-07-09 10:19 ` Andy Shevchenko
2026-07-08 15:58 ` Siratul Islam
2026-07-08 17:33 ` Jonathan Cameron
2026-07-08 19:04 ` Siratul Islam
2026-07-26 14:10 ` Lukas
2026-07-26 17:01 ` Siratul Islam
2026-07-26 18:18 ` Jonathan Cameron [this message]
2026-07-26 18:46 ` Lukas
2026-07-26 18:52 ` Siratul Islam
2026-07-26 18:48 ` Siratul Islam
2026-07-12 22:23 ` Uwe Kleine-König
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=20260726191833.67dcfac2@jic23-huawei \
--to=jic23@kernel.org \
--cc=andy@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=krzk+dt@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lukas.metz@gmx.net \
--cc=nuno.sa@analog.com \
--cc=robh@kernel.org \
--cc=siratul.islam@linux.dev \
/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