From: Jonathan Cameron <jic23@kernel.org>
To: ahaslam@baylibre.com
Cc: lars@metafoo.de, Michael.Hennerich@analog.com, robh@kernel.org,
krzk+dt@kernel.org, conor+dt@kernel.org, nuno.sa@analog.com,
dlechner@baylibre.com, linux-iio@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/6] iio: dac: ad5791: Include chip_info in device match tables
Date: Mon, 28 Oct 2024 20:22:18 +0000 [thread overview]
Message-ID: <20241028202218.0f0b3d14@jic23-huawei> (raw)
In-Reply-To: <20241028071118.699951-4-ahaslam@baylibre.com>
On Mon, 28 Oct 2024 08:11:15 +0100
ahaslam@baylibre.com wrote:
> From: Axel Haslam <ahaslam@baylibre.com>
>
> Include a chip info struct in device SPI and device OF match tables to
> provide channel definitions for each particular ADC model and drop
> device enum.
>
> Suggested-by: Nuno Sa <nuno.sa@analog.com>
> Signed-off-by: Axel Haslam <ahaslam@baylibre.com>
> ---
> drivers/iio/dac/ad5791.c | 107 +++++++++++++++++++--------------------
> 1 file changed, 51 insertions(+), 56 deletions(-)
>
> diff --git a/drivers/iio/dac/ad5791.c b/drivers/iio/dac/ad5791.c
> index 553431bf0232..a11e81211669 100644
> --- a/drivers/iio/dac/ad5791.c
> +++ b/drivers/iio/dac/ad5791.c
> @@ -65,7 +65,9 @@
> */
Whilst adding the docs for the missing entries, please delete this
blank line!
Otherwise patch looks good to me.
Jonathan
>
> struct ad5791_chip_info {
> - int (*get_lin_comp) (unsigned int span);
> + const char *name;
> + const struct iio_chan_spec channel;
> + int (*get_lin_comp)(unsigned int span);
> };
>
> /**
> @@ -98,13 +100,6 @@ struct ad5791_state {
> } data[3] __aligned(IIO_DMA_MINALIGN);
> };
>
> -enum ad5791_supported_device_ids {
> - ID_AD5760,
> - ID_AD5780,
> - ID_AD5781,
> - ID_AD5791,
> -};
> -
> static int ad5791_spi_write(struct ad5791_state *st, u8 addr, u32 val)
> {
> st->data[0].d32 = cpu_to_be32(AD5791_CMD_WRITE |
> @@ -228,20 +223,6 @@ static int ad5780_get_lin_comp(unsigned int span)
> else
> return AD5780_LINCOMP_10_20;
> }
> -static const struct ad5791_chip_info ad5791_chip_info_tbl[] = {
> - [ID_AD5760] = {
> - .get_lin_comp = ad5780_get_lin_comp,
> - },
> - [ID_AD5780] = {
> - .get_lin_comp = ad5780_get_lin_comp,
> - },
> - [ID_AD5781] = {
> - .get_lin_comp = ad5791_get_lin_comp,
> - },
> - [ID_AD5791] = {
> - .get_lin_comp = ad5791_get_lin_comp,
> - },
> -};
>
> static int ad5791_read_raw(struct iio_dev *indio_dev,
> struct iio_chan_spec const *chan,
> @@ -289,30 +270,34 @@ static const struct iio_chan_spec_ext_info ad5791_ext_info[] = {
> { },
> };
>
> -#define AD5791_CHAN(bits, _shift) { \
> - .type = IIO_VOLTAGE, \
> - .output = 1, \
> - .indexed = 1, \
> - .address = AD5791_ADDR_DAC0, \
> - .channel = 0, \
> - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
> - .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) | \
> - BIT(IIO_CHAN_INFO_OFFSET), \
> - .scan_type = { \
> - .sign = 'u', \
> - .realbits = (bits), \
> - .storagebits = 24, \
> - .shift = (_shift), \
> - }, \
> - .ext_info = ad5791_ext_info, \
> +#define AD5791_DEFINE_CHIP_INFO(_name, bits, _shift, _lin_comp) \
> +static const struct ad5791_chip_info _name##_chip_info = { \
> + .name = #_name, \
> + .get_lin_comp = &(_lin_comp), \
> + .channel = { \
> + .type = IIO_VOLTAGE, \
> + .output = 1, \
> + .indexed = 1, \
> + .address = AD5791_ADDR_DAC0, \
> + .channel = 0, \
> + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
> + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) | \
> + BIT(IIO_CHAN_INFO_OFFSET), \
> + .scan_type = { \
> + .sign = 'u', \
> + .realbits = (bits), \
> + .storagebits = 24, \
> + .shift = (_shift), \
> + }, \
> + .ext_info = ad5791_ext_info, \
> + }, \
> }
>
> -static const struct iio_chan_spec ad5791_channels[] = {
> - [ID_AD5760] = AD5791_CHAN(16, 4),
> - [ID_AD5780] = AD5791_CHAN(18, 2),
> - [ID_AD5781] = AD5791_CHAN(18, 2),
> - [ID_AD5791] = AD5791_CHAN(20, 0)
> -};
> +AD5791_DEFINE_CHIP_INFO(ad5760, 16, 4, ad5780_get_lin_comp);
> +AD5791_DEFINE_CHIP_INFO(ad5780, 18, 2, ad5780_get_lin_comp);
> +AD5791_DEFINE_CHIP_INFO(ad5781, 18, 2, ad5791_get_lin_comp);
> +AD5791_DEFINE_CHIP_INFO(ad5790, 20, 0, ad5791_get_lin_comp);
> +AD5791_DEFINE_CHIP_INFO(ad5791, 20, 0, ad5791_get_lin_comp);
next prev parent reply other threads:[~2024-10-28 20:22 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-28 7:11 [PATCH 0/6] Improvements and Enhancements for AD5791 DAC Driver ahaslam
2024-10-28 7:11 ` [PATCH 1/6] dt-bindings: iio: dac: ad5791: Add optional reset, clr and ldac gpios ahaslam
2024-10-28 7:42 ` Krzysztof Kozlowski
2024-10-28 7:11 ` [PATCH 2/6] dt-bindings: iio: dac: ad5791: Add required voltage supplies ahaslam
2024-10-28 8:06 ` Krzysztof Kozlowski
2024-10-28 23:07 ` Axel Haslam
2024-10-29 6:27 ` Krzysztof Kozlowski
2024-10-28 7:11 ` [PATCH 3/6] iio: dac: ad5791: Include chip_info in device match tables ahaslam
2024-10-28 16:38 ` kernel test robot
2024-10-28 20:22 ` Jonathan Cameron [this message]
2024-10-28 7:11 ` [PATCH 4/6] iio: dac: ad5791: Add reset, clr and ldac gpios ahaslam
2024-10-28 18:46 ` kernel test robot
2024-10-28 7:11 ` [PATCH 5/6] iio: dac: ad5791: Use devm_regulator_get_enable_read_voltage ahaslam
2024-10-28 18:32 ` kernel test robot
2024-10-28 7:11 ` [PATCH 6/6] iio: dac: ad5791: Use devm_iio_device_register ahaslam
2024-10-28 20:25 ` Jonathan Cameron
-- strict thread matches above, loose matches on Subject: below --
2024-10-29 7:38 [PATCH 0/6] Improvements and Enhancements for AD5791 DAC Driver ahaslam
2024-10-29 7:38 ` [PATCH 3/6] iio: dac: ad5791: Include chip_info in device match tables ahaslam
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=20241028202218.0f0b3d14@jic23-huawei \
--to=jic23@kernel.org \
--cc=Michael.Hennerich@analog.com \
--cc=ahaslam@baylibre.com \
--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=linux-kernel@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).