diff options
author | Denis Ciocca <denis.ciocca@st.com> | 2019-07-18 15:53:51 -0700 |
---|---|---|
committer | Jonathan Cameron <Jonathan.Cameron@huawei.com> | 2019-07-27 22:52:05 +0100 |
commit | 570c2c55ef364ef6aed531e554be4c989fb1a49c (patch) | |
tree | 2f0bf7c7248f2c0a3271ac8d910afc2f1ffc357e /drivers/iio/pressure/st_pressure_spi.c | |
parent | 291d83f2f4ef40e1d2d9504d29ecdf7000a655fb (diff) |
iio:pressure: device settings are set immediately during probe
This patch set pressure settings right after probe start. This is
done in preparation of regmap that needs different configuration
based on multiread bit value.
Signed-off-by: Denis Ciocca <denis.ciocca@st.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio/pressure/st_pressure_spi.c')
-rw-r--r-- | drivers/iio/pressure/st_pressure_spi.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/drivers/iio/pressure/st_pressure_spi.c b/drivers/iio/pressure/st_pressure_spi.c index ef61401c41d3..3e8c1ffe001e 100644 --- a/drivers/iio/pressure/st_pressure_spi.c +++ b/drivers/iio/pressure/st_pressure_spi.c @@ -61,18 +61,28 @@ MODULE_DEVICE_TABLE(of, st_press_of_match); static int st_press_spi_probe(struct spi_device *spi) { - struct iio_dev *indio_dev; + const struct st_sensor_settings *settings; struct st_sensor_data *press_data; + struct iio_dev *indio_dev; int err; + st_sensors_of_name_probe(&spi->dev, st_press_of_match, + spi->modalias, sizeof(spi->modalias)); + + settings = st_press_get_settings(spi->modalias); + if (!settings) { + dev_err(&spi->dev, "device name %s not recognized.\n", + spi->modalias); + return -ENODEV; + } + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*press_data)); - if (indio_dev == NULL) + if (!indio_dev) return -ENOMEM; press_data = iio_priv(indio_dev); + press_data->sensor_settings = (struct st_sensor_settings *)settings; - st_sensors_of_name_probe(&spi->dev, st_press_of_match, - spi->modalias, sizeof(spi->modalias)); st_sensors_spi_configure(indio_dev, spi, press_data); err = st_press_common_probe(indio_dev); |