Commit 291d83f2 authored by Denis Ciocca's avatar Denis Ciocca Committed by Jonathan Cameron

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: default avatarDenis Ciocca <denis.ciocca@st.com>
Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 3c05484c
......@@ -57,17 +57,27 @@ MODULE_DEVICE_TABLE(of, st_magn_of_match);
static int st_magn_i2c_probe(struct i2c_client *client,
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);
......
......@@ -51,18 +51,28 @@ MODULE_DEVICE_TABLE(of, st_magn_of_match);
static int st_magn_spi_probe(struct spi_device *spi)
{
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(&spi->dev, st_magn_of_match,
spi->modalias, sizeof(spi->modalias));
settings = st_magn_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(*mdata));
if (!indio_dev)
return -ENOMEM;
mdata = iio_priv(indio_dev);
mdata->sensor_settings = (struct st_sensor_settings *)settings;
st_sensors_of_name_probe(&spi->dev, st_magn_of_match,
spi->modalias, sizeof(spi->modalias));
st_sensors_spi_configure(indio_dev, spi, mdata);
err = st_magn_common_probe(indio_dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment