[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250308132754.7f91c7d2@jic23-huawei>
Date: Sat, 8 Mar 2025 13:27:54 +0000
From: Jonathan Cameron <jic23@...nel.org>
To: Marcelo Schmitt <marcelo.schmitt1@...il.com>
Cc: Jonathan Santos <Jonathan.Santos@...log.com>, linux-iio@...r.kernel.org,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-gpio@...r.kernel.org, lars@...afoo.de, Michael.Hennerich@...log.com,
marcelo.schmitt@...log.com, robh@...nel.org, krzk+dt@...nel.org,
conor+dt@...nel.org, linus.walleij@...aro.org, brgl@...ev.pl,
lgirdwood@...il.com, broonie@...nel.org, dlechner@...libre.com,
jonath4nns@...il.com
Subject: Re: [PATCH v4 08/17] iio: adc: ad7768-1: convert driver to use
regmap
On Fri, 7 Mar 2025 10:20:04 -0300
Marcelo Schmitt <marcelo.schmitt1@...il.com> wrote:
> On 03/06, Jonathan Santos wrote:
> > Convert the AD7768-1 driver to use the regmap API for register
> > access. This change simplifies and standardizes register interactions,
> > reducing code duplication and improving maintainability.
> >
> > Create two regmap configurations, one for 8-bit register values and
> > other for 24-bit register values.
> >
> > Since we are using regmap now, define the remaining registers from 0x32
> > to 0x34.
> >
Marcelo, crop to just the bit you reply to. Reduces chance that
key part is missed when someone is scrolling through.
> > -static int ad7768_spi_reg_write(struct ad7768_state *st,
> > - unsigned int addr,
> > - unsigned int val)
> > -{
> > - st->data.d8[0] = AD7768_WR_FLAG_MSK(addr);
> > - st->data.d8[1] = val & 0xFF;
> > +static const struct regmap_config ad7768_regmap_config = {
> > + .name = "ad7768-1-8",
> > + .reg_bits = 8,
> > + .val_bits = 8,
> > + .read_flag_mask = BIT(6),
> > + .rd_table = &ad7768_regmap_rd_table,
> > + .wr_table = &ad7768_regmap_wr_table,
> > + .max_register = AD7768_REG_ACCESS_KEY,
> > + .use_single_write = true,
> > + .use_single_read = true,
> > +};
> >
> > - return spi_write(st->spi, st->data.d8, 2);
> > -}
> > +static const struct regmap_range ad7768_regmap24_rd_ranges[] = {
> > + regmap_reg_range(AD7768_REG24_ADC_DATA, AD7768_REG24_ADC_DATA),
> > + regmap_reg_range(AD7768_REG24_COEFF_DATA, AD7768_REG24_COEFF_DATA),
>
> So, this device has only two registers that are 24-bit size?
> Also, one of those is the ADC_DATA register which you will probably want
> to read with optimized SPI messages in the future (devm_spi_optimize_message()).
> That makes me wonder if the 24-bit regmap worth's the boiler plate to have it.
> Does the driver access AD7768_REG24_COEFF_DATA after the patches from this
> series is applied? If not, maybe drop the 24-bit regmap and implement ADC_DATA
> with usual spi_message/spi_transfer interfaces?
Given it's used today and is better than a mix of regmap and non-regmap
(as no need to go SPI specific yet) I'd keep it for now. If it ends up
completely unused, then fair enough to rip it out again. It's not
a lot of code.
Jonathan
Powered by blists - more mailing lists