diff options
author | Denis Ciocca <denis.ciocca@st.com> | 2019-07-19 00:53:50 +0200 |
---|---|---|
committer | Jonathan Cameron <Jonathan.Cameron@huawei.com> | 2019-07-27 23:52:05 +0200 |
commit | 291d83f2f4ef40e1d2d9504d29ecdf7000a655fb (patch) | |
tree | 9825da4034cf3c46fad99062332ac70a2d0b3a69 /drivers/iio/magnetometer/st_magn_i2c.c | |
parent | iio:gyro: device settings are set immediately during probe (diff) | |
download | linux-291d83f2f4ef40e1d2d9504d29ecdf7000a655fb.tar.xz linux-291d83f2f4ef40e1d2d9504d29ecdf7000a655fb.zip |
iio:magn: device settings are set immediately during probe
This patch set magn 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/magnetometer/st_magn_i2c.c')
-rw-r--r-- | drivers/iio/magnetometer/st_magn_i2c.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/drivers/iio/magnetometer/st_magn_i2c.c b/drivers/iio/magnetometer/st_magn_i2c.c index 4d014fd1aeb0..d5d565639bed 100644 --- a/drivers/iio/magnetometer/st_magn_i2c.c +++ b/drivers/iio/magnetometer/st_magn_i2c.c @@ -55,19 +55,29 @@ MODULE_DEVICE_TABLE(of, st_magn_of_match); #endif static int st_magn_i2c_probe(struct i2c_client *client, - const struct i2c_device_id *id) + const struct i2c_device_id *id) { - struct iio_dev *indio_dev; + const struct st_sensor_settings *settings; struct st_sensor_data *mdata; + struct iio_dev *indio_dev; int err; + st_sensors_of_name_probe(&client->dev, st_magn_of_match, + client->name, sizeof(client->name)); + + settings = st_magn_get_settings(client->name); + if (!settings) { + dev_err(&client->dev, "device name %s not recognized.\n", + client->name); + return -ENODEV; + } + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*mdata)); if (!indio_dev) return -ENOMEM; mdata = iio_priv(indio_dev); - st_sensors_of_name_probe(&client->dev, st_magn_of_match, - client->name, sizeof(client->name)); + mdata->sensor_settings = (struct st_sensor_settings *)settings; st_sensors_i2c_configure(indio_dev, client, mdata); |