From: Jonathan Cameron <jic23@kernel.org>
To: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: nuno.sa@analog.com, linux-iio@vger.kernel.org,
devicetree@vger.kernel.org,
Michael Hennerich <Michael.Hennerich@analog.com>,
David Lechner <dlechner@baylibre.com>,
Andy Shevchenko <andy@kernel.org>,
Lars-Peter Clausen <lars@metafoo.de>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>
Subject: Re: [PATCH v4 07/12] iio: dac: ad5446: Separate I2C/SPI into different drivers
Date: Sun, 9 Nov 2025 15:55:38 +0000 [thread overview]
Message-ID: <20251109155538.51f890de@jic23-huawei> (raw)
In-Reply-To: <aQpD7zx7D6sQOAdC@smile.fi.intel.com>
On Tue, 4 Nov 2025 20:20:31 +0200
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:
> On Tue, Nov 04, 2025 at 03:35:12PM +0000, Nuno Sá via B4 Relay wrote:
> >
> > Properly separate the I2C and SPI drivers into two different drivers
> > living in their own source file (as usual). So that no need for the
> > hacky ifdefery.
>
> ...
>
> > +#include <linux/iio/iio.h>
> > +#include <linux/mutex.h>
> > +#include <linux/types.h>
> > +
> > +struct device;
> > +
> > +extern const struct iio_chan_spec_ext_info ad5446_ext_info_powerdown[];
> > +
> > +#define _AD5446_CHANNEL(bits, storage, _shift, ext) { \
> > + .type = IIO_VOLTAGE, \
> > + .indexed = 1, \
> > + .output = 1, \
>
> > + .channel = 0, \
>
> Unneeded.
Even though it is indeed not strictly needed:
As it's indexed I'd normally suggest we keep this as explicitly
set. There isn't an obvious default for a channel number.
>
> > + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
> > + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \
> > + .scan_type = { \
> > + .sign = 'u', \
> > + .realbits = (bits), \
> > + .storagebits = (storage), \
> > + .shift = (_shift), \
> > + }, \
> > + .ext_info = (ext), \
> > +}
> > +
> > +#define AD5446_CHANNEL(bits, storage, shift) \
> > + _AD5446_CHANNEL(bits, storage, shift, NULL)
> > +#define AD5446_CHANNEL_POWERDOWN(bits, storage, shift) \
> > + _AD5446_CHANNEL(bits, storage, shift, ad5446_ext_info_powerdown)
> > +
> > +/**
> > + * struct ad5446_state - driver instance specific data
> > + * @dev: this device
> > + * @chip_info: chip model specific constants, available modes etc
> > + * @vref_mv: actual reference voltage used
> > + * @cached_val: store/retrieve values during power down
> > + * @pwr_down_mode: power down mode (1k, 100k or tristate)
> > + * @pwr_down: true if the device is in power down
> > + * @lock: lock to protect the data buffer during write ops
> > + */
> > +struct ad5446_state {
> > + struct device *dev;
> > + const struct ad5446_chip_info *chip_info;
> > + unsigned short vref_mv;
>
> _mV?
>
> > + unsigned int cached_val;
> > + unsigned int pwr_down_mode;
> > + unsigned int pwr_down;
> > + /* mutex to protect device shared data */
> > + struct mutex lock;
> > + union {
> > + __be16 d16;
> > + u8 d24[3];
> > + } __aligned(IIO_DMA_MINALIGN);
> > +};
> > +
> > +/**
> > + * struct ad5446_chip_info - chip specific information
> > + * @channel: channel spec for the DAC
> > + * @int_vref_mv: AD5620/40/60: the internal reference voltage
> > + * @write: chip specific helper function to write to the register
> > + */
> > +struct ad5446_chip_info {
> > + struct iio_chan_spec channel;
> > + u16 int_vref_mv;
>
> _mV?
>
> > + int (*write)(struct ad5446_state *st, unsigned int val);
> > +};
> > +
> > +int ad5446_probe(struct device *dev, const char *name,
> > + const struct ad5446_chip_info *chip_info);
> > +
> > +#endif
>
next prev parent reply other threads:[~2025-11-09 15:55 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-04 15:35 [PATCH v4 00/12] iio: dac: ad5446: Refactor and add support for AD5542 Nuno Sá via B4 Relay
2025-11-04 15:35 ` [PATCH v4 01/12] dt-bindings: iio: dac: Document AD5446 and similar devices Nuno Sá via B4 Relay
2025-11-04 17:51 ` [PATCH v5 6/7] dt-bindings: clock: rockchip: Add RK3506 clock and reset unit Conor Dooley
2025-11-09 15:57 ` Jonathan Cameron
2025-11-09 19:51 ` Conor Dooley
2025-11-09 16:05 ` [PATCH v4 01/12] dt-bindings: iio: dac: Document AD5446 and similar devices Jonathan Cameron
2025-11-04 15:35 ` [PATCH v4 02/12] iio: dac: ad5446: Use DMA safe buffer for transfers Nuno Sá via B4 Relay
2025-11-04 17:10 ` Andy Shevchenko
2025-11-09 16:04 ` Jonathan Cameron
2025-11-04 15:35 ` [PATCH v4 03/12] iio: dac: ad5446: Drop duplicated spi_id entry Nuno Sá via B4 Relay
2025-11-04 17:12 ` Andy Shevchenko
2025-11-05 10:16 ` Nuno Sá
2025-11-09 16:05 ` Jonathan Cameron
2025-11-04 15:35 ` [PATCH v4 04/12] iio: dac: ad5446: Don't ignore missing regulator Nuno Sá via B4 Relay
2025-11-09 16:05 ` Jonathan Cameron
2025-11-04 15:35 ` [PATCH v4 05/12] iio: dac: ad5446: Move to single chip_info structures Nuno Sá via B4 Relay
2025-11-09 16:06 ` Jonathan Cameron
2025-11-04 15:35 ` [PATCH v4 06/12] iio: dac: ad5456: Add missing DT compatibles Nuno Sá via B4 Relay
2025-11-09 16:13 ` Jonathan Cameron
2025-11-04 15:35 ` [PATCH v4 07/12] iio: dac: ad5446: Separate I2C/SPI into different drivers Nuno Sá via B4 Relay
2025-11-04 18:20 ` Andy Shevchenko
2025-11-09 15:55 ` Jonathan Cameron [this message]
2025-11-09 16:13 ` Jonathan Cameron
2025-11-09 16:16 ` Jonathan Cameron
2025-11-10 15:11 ` Nuno Sá
2025-11-04 15:35 ` [PATCH v4 08/12] iio: dac: ad5446: Make use of devm_mutex_init() Nuno Sá via B4 Relay
2025-11-09 16:16 ` Jonathan Cameron
2025-11-04 15:35 ` [PATCH v4 09/12] iio: dac: ad5446: Make use of the cleanup helpers Nuno Sá via B4 Relay
2025-11-04 18:23 ` Andy Shevchenko
2025-11-09 16:19 ` Jonathan Cameron
2025-11-04 15:35 ` [PATCH v4 10/12] iio: dac: ad5446: Refactor header inclusion Nuno Sá via B4 Relay
2025-11-04 18:24 ` Andy Shevchenko
2025-11-09 16:30 ` Jonathan Cameron
2025-11-09 19:32 ` Andy Shevchenko
2025-11-11 19:25 ` Jonathan Cameron
2025-11-04 15:35 ` [PATCH v4 11/12] iio: dac: ad5446: Fix coding style issues Nuno Sá via B4 Relay
2025-11-04 18:26 ` Andy Shevchenko
2025-11-09 16:32 ` Jonathan Cameron
2025-11-04 15:35 ` [PATCH v4 12/12] iio: dac: ad5446: Add AD5542 to the spi id table Nuno Sá via B4 Relay
2025-11-09 16:32 ` Jonathan Cameron
2025-11-04 18:30 ` [PATCH v4 00/12] iio: dac: ad5446: Refactor and add support for AD5542 Andy Shevchenko
2025-11-05 10:16 ` Nuno Sá
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=20251109155538.51f890de@jic23-huawei \
--to=jic23@kernel.org \
--cc=Michael.Hennerich@analog.com \
--cc=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=krzk+dt@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).