Re: [PATCH v4 13/15] iio: adc: Add support for AD7091R-8

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

 



On Sat, 16 Dec 2023 14:50:44 -0300
Marcelo Schmitt <marcelo.schmitt@xxxxxxxxxx> wrote:

> Add support for Analog Devices AD7091R-2, AD7091R-4, and AD7091R-8
> low power 12-Bit SAR ADCs with SPI interface.
> Extend ad7091r-base driver so it can be used by the AD7091R-8 driver.
> 
> Signed-off-by: Marcelo Schmitt <marcelo.schmitt@xxxxxxxxxx>
Hi Marcelo

A few trivial things from taking another look.

Jonathan

> diff --git a/drivers/iio/adc/ad7091r-base.c b/drivers/iio/adc/ad7091r-base.c
> index a30dc587ce45..57355ca157a1 100644
> --- a/drivers/iio/adc/ad7091r-base.c
> +++ b/drivers/iio/adc/ad7091r-base.c
> @@ -6,6 +6,7 @@
>   */
>  
>  #include <linux/bitops.h>
> +#include <linux/bitfield.h>

Not obvious what connection of this header to the code below is...
Wrong patch perhaps?
>  #include <linux/iio/events.h>
>  #include <linux/iio/iio.h>
>  #include <linux/interrupt.h>
> @@ -187,6 +188,12 @@ int ad7091r_probe(struct device *dev, const struct ad7091r_init_info *init_info,
>  	iio_dev->info = &ad7091r_info;
>  	iio_dev->modes = INDIO_DIRECT_MODE;
>  
> +	if (init_info->setup) {
> +		ret = init_info->setup(st);
> +		if (ret < 0)
> +			return ret;
> +	}
> +
>  	if (irq) {
>  		st->chip_info = &init_info->irq_info;
>  		ret = regmap_update_bits(st->map, AD7091R_REG_CONF,
> diff --git a/drivers/iio/adc/ad7091r-base.h b/drivers/iio/adc/ad7091r-base.h
> index 2b4e25e766c8..994505a740b3 100644
> --- a/drivers/iio/adc/ad7091r-base.h
> +++ b/drivers/iio/adc/ad7091r-base.h
> @@ -45,6 +45,8 @@
>  	.scan_type.realbits = bits,					\
>  }
>  
> +#include <linux/gpio/consumer.h>
> +

struct gpio_desc;

and drop the include which only provides an opaque definition anyway.

>  struct device;
>  
>  enum ad7091r_mode {
> @@ -56,10 +58,14 @@ enum ad7091r_mode {
>  struct ad7091r_state {
>  	struct device *dev;
>  	struct regmap *map;
> +	struct gpio_desc *convst_gpio;
> +	struct gpio_desc *reset_gpio;
>  	struct regulator *vref;
>  	const struct ad7091r_chip_info *chip_info;
>  	enum ad7091r_mode mode;
>  	struct mutex lock; /*lock to prevent concurent reads */
> +	__be16 tx_buf __aligned(IIO_DMA_MINALIGN);
> +	__be16 rx_buf;
>  };
>  
>  struct ad7091r_chip_info {
> @@ -77,6 +83,7 @@ struct ad7091r_init_info {
>  	const struct regmap_config *regmap_config;
>  	void (*init_adc_regmap)(struct ad7091r_state *st,
>  				const struct regmap_config *regmap_conf);
> +	int (*setup)(struct ad7091r_state *st);
>  };
>  
>  extern const struct iio_event_spec ad7091r_events[3];
> diff --git a/drivers/iio/adc/ad7091r8.c b/drivers/iio/adc/ad7091r8.c
> new file mode 100644
> index 000000000000..0a6da47d89c0
> --- /dev/null
> +++ b/drivers/iio/adc/ad7091r8.c

> +static int ad7091r8_gpio_setup(struct ad7091r_state *st)
> +{
> +	st->convst_gpio = devm_gpiod_get(st->dev, "adi,conversion-start",
> +					 GPIOD_OUT_LOW);
> +	if (IS_ERR(st->convst_gpio))
> +		return dev_err_probe(st->dev, PTR_ERR(st->convst_gpio),
> +				     "Error getting convst GPIO\n");
> +
> +	st->reset_gpio =  devm_gpiod_get_optional(st->dev, "reset",

Trivial but looks like a bonus space after the =

> +						  GPIOD_OUT_HIGH);
> +	if (IS_ERR(st->reset_gpio))
> +		return dev_err_probe(st->dev, PTR_ERR(st->convst_gpio),
> +				     "Error on requesting reset GPIO\n");
> +
> +	if (st->reset_gpio) {
> +		fsleep(20);
> +		gpiod_set_value_cansleep(st->reset_gpio, 0);
> +	}
> +
> +	return 0;
> +}




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux