lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75VcA2SNGb6cpHaOQwQ_dNaG5xCZnfrXtu+u9pB1+oz7xew@mail.gmail.com>
Date: Mon, 15 Dec 2025 19:00:35 +0200
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: Ajith Anandhan <ajithanandhan0406@...il.com>
Cc: David Lechner <dlechner@...libre.com>, jic23@...nel.org, nuno.sa@...log.com, 
	andy@...nel.org, robh@...nel.org, krzk+dt@...nel.org, conor+dt@...nel.org, 
	linux-iio@...r.kernel.org, devicetree@...r.kernel.org, 
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 2/2] iio: adc: Add support for TI ADS1120

On Mon, Dec 15, 2025 at 6:49 PM Ajith Anandhan
<ajithanandhan0406@...il.com> wrote:
> On 12/15/25 10:06 PM, David Lechner wrote:
> > On 12/15/25 10:13 AM, Ajith Anandhan wrote:
> >> On 11/18/25 7:34 PM, David Lechner wrote:
> >>> On 11/9/25 8:11 AM, Ajith Anandhan wrote:

Please, do not forget to remove context that is not being discussed.

...

> >>>> +/* Regmap write function for ADS1120 */
> >>>> +static int ads1120_regmap_write(void *context, const void *data, size_t count)
> >>>> +{
> >>>> +    struct ads1120_state *st = context;
> >>>> +    const u8 *buf = data;
> >>>> +
> >>>> +    if (count != 2)
> >>>> +        return -EINVAL;
> >>>> +
> >>>> +    /* WREG command: 0100rr00 where rr is register address */
> >>>> +    st->data[0] = ADS1120_CMD_WREG | (buf[0] << 2);
> >>>> +    st->data[1] = buf[1];
> >>>> +
> >>>> +    return spi_write(st->spi, st->data, 2);
> >>>> +}
> >>> I don't see anyting unusal about these read/write functions. We should
> >>> be able to use the existing spi_regmap with the proper configuration
> >>> instead of making a custom regmap_bus.
> >>
> >>     The ADS1120 needs register address shifted by 2 bits
> >>     in command byte (reg << 2). I couldn't find a way to do this with standard
> >>     SPI regmap. If there's a configuration I'm missing, please point me to it and I'll gladly simplify.
> >>
> > I think you are looking for reg_shift in struct regmap_config.

> Thanks for the pointer.
>
> I did look at reg_shift, but it doesn’t fit this device. With .reg_shift
> = 2, regmap would send only (reg << 2) (e.g. 0x0c for reg 3).
>
> The ADS1120 requires the command byte to be CMD | (reg << 2) (e.g. 0x20
> | 0x0c = 0x2c for an RREG of reg 3).
>
> Similarly,
>
>   .read_flag_mask would produce reg | mask (e.g. 0x03 | 0x20 = 0x23),
> which is also not the required format.
>
> Unless I’m missing a regmap configuration that can generate (reg << 2) |
> CMD as a single byte,
>
> a custom regmap bus seems necessary here. Please let me know if there is
> a way to express this with standard regmap-spi.

So, and if you define both?



-- 
With Best Regards,
Andy Shevchenko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ