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

Andy Shevchenko <[email protected]>
Newsgroups org.kernel.vger.linux-iio,org.kernel.vger.linux-devicetree,org.kernel.vger.linux-doc,org.kernel.vger.linux-gpio,org.kernel.vger.linux-kernel
Organization Intel Finland Oy - BIC 0357606-4 - c/o Alberga Business Park, 6 krs, Bertel Jungin Aukio 5, 02600 Espoo
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.