Re: [PATCH 2/3] iio: potentiometer: Add support for the Renesas X9250 potentiometers

From: Herve Codina
Date: Thu Apr 20 2023 - 11:56:01 EST


On Thu, 20 Apr 2023 06:47:32 -0700
Lars-Peter Clausen <lars@xxxxxxxxxx> wrote:

> On 4/20/23 05:13, Herve Codina wrote:
> > The Renesas X9250 integrates four digitally controlled potentiometers.
> > On each potentiometer, the X9250T has a 100 kOhms total resistance and
> > the X9250U has a 50 kOhms total resistance.
> >
> > Signed-off-by: Herve Codina <herve.codina@xxxxxxxxxxx>
>
> Hi,
>
> Looks perfect! Just one small comment.
>
> > +static int x9250_write8(struct x9250 *x9250, u8 cmd, u8 val)
> > +{
> > + struct spi_transfer xfer = {
> > + .tx_buf = &x9250->spi_tx_buf,
> > + .len = 3,
> > + };
> > + int ret;
> > +
> > + BUILD_BUG_ON(sizeof(x9250->spi_tx_buf) < 3);
> > +
> > + mutex_lock(&x9250->lock);
> > +
> > + x9250->spi_tx_buf[0] = 0x50;
> The 0x50 shows up as a magic constant in multiple places, a define for
> it would be nice.

Sure, a define will be present in next iteration.

> > + x9250->spi_tx_buf[1] = cmd;
> > + x9250->spi_tx_buf[2] = val;
> > +
> > + ret = spi_sync_transfer(x9250->spi, &xfer, 1);
> > +
> > + mutex_unlock(&x9250->lock);
> > +
> > + return ret;
> > +}

Thanks for the review,
Hervé

--
Hervé Codina, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com