Re: [PATCH RFC v2 2/4] iio: adc: ad7380: enable regmap cache

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 24 Dec 2024 10:34:31 +0100
Julien Stephan <jstephan@xxxxxxxxxxxx> wrote:

> Enable regmap cache, to avoid useless access on spi bus.
> Don't store anymore the oversampling ratio in private data structure.
> 
> Signed-off-by: Julien Stephan <jstephan@xxxxxxxxxxxx>

A few really minor things inline,

Jonathan

>  static int ad7380_debugfs_reg_access(struct iio_dev *indio_dev, u32 reg,
> @@ -692,6 +709,37 @@ static int ad7380_debugfs_reg_access(struct iio_dev *indio_dev, u32 reg,
>  	return ret;
>  }
>  
> +/**
> + * ad7380_regval_to_osr - convert OSR register value to ratio
> + * @regval: register value to check
> + *
> + * Returns: the ratio corresponding to the OSR register. If regval is not in
> + * bound, return 1 (oversampling disabled)
> + *
> + */
> +static int ad7380_regval_to_osr(int regval)

Make regval an unsigned int and yout can drop one test.
The FIELD_GET is never going to give you a signed value anyway.

> +{
> +	if (regval < 0 || regval >= ARRAY_SIZE(ad7380_oversampling_ratios))
> +		return 1;
> +
> +	return ad7380_oversampling_ratios[regval];
> +}
> +
> +static int ad7380_get_osr(struct ad7380_state *st, int *val)
> +{
> +	int tmp;
> +	int ret = 0;

No point in initializing.

> +
> +	ret = regmap_read(st->regmap, AD7380_REG_ADDR_CONFIG1, &tmp);
> +	if (ret)
> +		return ret;
> +
> +	*val = ad7380_regval_to_osr(FIELD_GET(AD7380_CONFIG1_OSR, tmp));
> +
> +	return 0;
> +}
> +
> +

Trivial but one blank line almost always enough!

>  /*






[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux