Re: [PATCH v3] iio: adc: Add support for TI ADC108S102 and ADC128S102

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

 



On Fri, May 05, 2017 at 08:31:32AM +0200, Jan Kiszka wrote:
> +static int adc108s102_probe(struct spi_device *spi)
> +{
> +	struct adc108s102_state *st;
> +	struct iio_dev *indio_dev;
> +	int ret;
> +
> +	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
> +	if (!indio_dev)
> +		return -ENOMEM;
> +
> +	st = iio_priv(indio_dev);
> +
> +	if (ACPI_COMPANION(&spi->dev)) {
> +		st->reg = NULL;
> +		ret = device_property_read_u32(&spi->dev, "va-millivolt",
> +					    &st->va_millivolt);

Please try to avoid things like this for now. You can just hard code the
voltage now and we can think how to solve this in ACPI if there will be
an actual user needing anything else than the voltage you are using on
your board.

> +		if (ret < 0) {
> +			dev_err(&spi->dev,
> +				"Missing va-millivolt device property\n");
> +			return -ENODEV;
> +		}
> +	} else {
> +		st->reg = devm_regulator_get(&spi->dev, "vref");
> +		if (IS_ERR(st->reg))
> +			return PTR_ERR(st->reg);

This should be an optional regulator and in case of ACPI you just don't
have it.

> +
> +		ret = regulator_enable(st->reg);
> +		if (ret < 0) {
> +			dev_err(&spi->dev, "Cannot enable vref regulator\n");
> +			return ret;
> +		}
> +	}
--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[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