Re: [PATCH 6/7] iio: adc: Add support for AD7091R-8

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

 



On 21/11/2023 22:36, marcelo.schmitt@xxxxxxxxxx wrote:
> From: Marcelo Schmitt <marcelo.schmitt@xxxxxxxxxx>
> 
> Add support for Analog Devices AD7091R-2, AD7091R-4, and AD7091R-8
> low power 12-Bit SAR ADCs.
> Extend ad7091r-base driver so it can be used by AD7091R-8 drivers.
> 
> Signed-off-by: Marcelo Schmitt <marcelo.schmitt@xxxxxxxxxx>
> ---
> 
> Device read/write might look odd due to the transfer protocol for these devices.
> I'm glad to hear any suggestions on how to make it better.
> 


...

> +
> +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: %ld\n",
> +				     PTR_ERR(st->convst_gpio));

Don't print error code twice.

> +
> +	st->reset_gpio =  devm_gpiod_get_optional(st->dev, "reset",
> +						  GPIOD_OUT_HIGH);
> +	if (IS_ERR(st->reset_gpio))
> +		return PTR_ERR(st->reset_gpio);
> +
> +	if (st->reset_gpio) {
> +		fsleep(20);
> +		gpiod_set_value_cansleep(st->reset_gpio, 0);
> +	}
> +
> +	return 0;
> +}
> +
> +static int ad7091r8_spi_probe(struct spi_device *spi)
> +{
> +	const struct ad7091r_chip_info *chip_info;
> +	struct ad7091r_state *st;
> +	struct iio_dev *iio_dev;
> +	struct regmap *map;
> +	int ret;
> +
> +	chip_info = spi_get_device_match_data(spi);
> +	if (!chip_info)
> +		return -EINVAL;
> +
> +	iio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
> +	if (!iio_dev)
> +		return -ENOMEM;
> +
> +	st = iio_priv(iio_dev);
> +	st->dev = &spi->dev;
> +
> +	map = devm_regmap_init(&spi->dev, &ad7091r8_regmap_bus, st,
> +			       &ad7091r_spi_regmap_config[chip_info->type]);
> +
> +	if (IS_ERR(map))
> +		return dev_err_probe(&spi->dev, PTR_ERR(map),
> +				     "Error initializing spi regmap: %ld\n",
> +				     PTR_ERR(map));

Don't print error code twice.

Best regards,
Krzysztof





[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