Re: [PATCH v4 07/14] iio: adc: ad7768: Add calibration controls

From: Andy Shevchenko

Date: Mon Aug 24 2026 - 02:51:29 EST


On Fri, Aug 21, 2026 at 04:07:00PM +0200, Janani Sunil wrote:
> Expose the per-channel offset and gain calibration registers through the
> IIO calibbias and calibscale attributes.

...

> +static int ad7768_read_calib_value(struct ad7768_state *st,
> + unsigned int base_reg, unsigned int *val)
> +{
> + u8 data[3];
> + int ret;
> +
> + guard(mutex)(&st->lock);
> +
> + ret = regmap_bulk_read(st->regmap, base_reg, data, ARRAY_SIZE(data));

sizeof() works good for byte arrays.

> + if (ret)
> + return ret;
> +
> + *val = get_unaligned_be24(data);
> +
> + return 0;
> +}

...

> +static int ad7768_write_calib_value(struct ad7768_state *st,
> + unsigned int base_reg, unsigned int val)
> +{
> + u8 data[3];
> +
> + if (val > AD7768_CALIB_REG_MSK)
> + return -EINVAL;
> +
> + put_unaligned_be24(val, data);
> +
> + guard(mutex)(&st->lock);
> +
> + return regmap_bulk_write(st->regmap, base_reg, data, ARRAY_SIZE(data));

Ditto.

> +}

--
With Best Regards,
Andy Shevchenko