Lines Matching +full:iio +full:- +full:consumer

1 // SPDX-License-Identifier: GPL-2.0
3 * iio/adc/max11100.c
4 * Maxim max11100 ADC Driver with IIO interface
6 * Copyright (C) 2016-17 Renesas Electronics Corporation
7 * Copyright (C) 2016-17 Jacopo Mondi
13 #include <linux/regulator/consumer.h>
17 #include <linux/iio/iio.h>
18 #include <linux/iio/driver.h>
55 ret = spi_read(state->spi, state->buffer, sizeof(state->buffer)); in max11100_read_single()
57 dev_err(&indio_dev->dev, "SPI transfer failed\n"); in max11100_read_single()
62 if (state->buffer[0]) { in max11100_read_single()
63 dev_err(&indio_dev->dev, "Invalid value: buffer[0] != 0\n"); in max11100_read_single()
64 return -EINVAL; in max11100_read_single()
67 *val = get_unaligned_be16(&state->buffer[1]); in max11100_read_single()
88 vref_uv = regulator_get_voltage(state->vref_reg); in max11100_read_raw()
90 /* dummy regulator "get_voltage" returns -EINVAL */ in max11100_read_raw()
91 return -EINVAL; in max11100_read_raw()
98 return -EINVAL; in max11100_read_raw()
116 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*state)); in max11100_probe()
118 return -ENOMEM; in max11100_probe()
121 state->spi = spi; in max11100_probe()
123 indio_dev->name = "max11100"; in max11100_probe()
124 indio_dev->info = &max11100_info; in max11100_probe()
125 indio_dev->modes = INDIO_DIRECT_MODE; in max11100_probe()
126 indio_dev->channels = max11100_channels; in max11100_probe()
127 indio_dev->num_channels = ARRAY_SIZE(max11100_channels); in max11100_probe()
129 state->vref_reg = devm_regulator_get(&spi->dev, "vref"); in max11100_probe()
130 if (IS_ERR(state->vref_reg)) in max11100_probe()
131 return PTR_ERR(state->vref_reg); in max11100_probe()
133 ret = regulator_enable(state->vref_reg); in max11100_probe()
137 ret = devm_add_action_or_reset(&spi->dev, max11100_regulator_disable, in max11100_probe()
138 state->vref_reg); in max11100_probe()
142 return devm_iio_device_register(&spi->dev, indio_dev); in max11100_probe()