Re: [PATCH v7 2/2] iio: dac: ad5706r: Add support for AD5706R DAC

From: Andy Shevchenko

Date: Mon Apr 13 2026 - 03:51:40 EST


On Mon, Apr 13, 2026 at 10:16 AM Torreno, Alexis Czezar
<AlexisCzezar.Torreno@xxxxxxxxxx> wrote:

...

> > > + /* Extract value from response (skip 2-byte command echo) */
> > > + if (num_bytes == AD5706R_SINGLE_BYTE_LEN)
> > > + val = st->rx_buf[2];
> > > + else if (num_bytes == AD5706R_DOUBLE_BYTE_LEN)
> > > + val = get_unaligned_be16(&st->rx_buf[2]);
> > > + else
> > > + return -EINVAL;
> > > +
> > > + put_unaligned_be16(val, val_buf);
> >
> > Can't this all be simplified to memcpy(val_buf, &st->rx_buf[2], num_bytes); ?

Also note, num_bytes still needs validation.

> > Or the whole thing simplified to:
> >
> > return spi_write_then_read(st->spi, reg_buf, 2, val_buf, num_bytes);
>
> as discussed above about mem* and spi_write_then_read



--
With Best Regards,
Andy Shevchenko