Commit 8e71c04f authored by Alban Bedel's avatar Alban Bedel Committed by Jonathan Cameron

iio:st_sensors: Fix oops when probing SPI devices

In SPI mode the transfer buffer is locked with a mutex. However this
mutex is only initilized after the probe, but some transfer needs to
be done in the probe.

To fix this bug we move the mutex initialization at the beginning of
the device probe.
Signed-off-by: default avatarAlban Bedel <alban.bedel@avionic-design.de>
Acked-by: default avatarDenis Ciocca <denis.ciocca@st.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent 97ffae1d
...@@ -546,6 +546,7 @@ int st_accel_common_probe(struct iio_dev *indio_dev) ...@@ -546,6 +546,7 @@ int st_accel_common_probe(struct iio_dev *indio_dev)
indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->modes = INDIO_DIRECT_MODE;
indio_dev->info = &accel_info; indio_dev->info = &accel_info;
mutex_init(&adata->tb.buf_lock);
st_sensors_power_enable(indio_dev); st_sensors_power_enable(indio_dev);
......
...@@ -304,8 +304,6 @@ int st_sensors_init_sensor(struct iio_dev *indio_dev, ...@@ -304,8 +304,6 @@ int st_sensors_init_sensor(struct iio_dev *indio_dev,
struct st_sensors_platform_data *of_pdata; struct st_sensors_platform_data *of_pdata;
int err = 0; int err = 0;
mutex_init(&sdata->tb.buf_lock);
/* If OF/DT pdata exists, it will take precedence of anything else */ /* If OF/DT pdata exists, it will take precedence of anything else */
of_pdata = st_sensors_of_probe(indio_dev->dev.parent, pdata); of_pdata = st_sensors_of_probe(indio_dev->dev.parent, pdata);
if (of_pdata) if (of_pdata)
......
...@@ -400,6 +400,7 @@ int st_gyro_common_probe(struct iio_dev *indio_dev) ...@@ -400,6 +400,7 @@ int st_gyro_common_probe(struct iio_dev *indio_dev)
indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->modes = INDIO_DIRECT_MODE;
indio_dev->info = &gyro_info; indio_dev->info = &gyro_info;
mutex_init(&gdata->tb.buf_lock);
st_sensors_power_enable(indio_dev); st_sensors_power_enable(indio_dev);
......
...@@ -369,6 +369,7 @@ int st_magn_common_probe(struct iio_dev *indio_dev) ...@@ -369,6 +369,7 @@ int st_magn_common_probe(struct iio_dev *indio_dev)
indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->modes = INDIO_DIRECT_MODE;
indio_dev->info = &magn_info; indio_dev->info = &magn_info;
mutex_init(&mdata->tb.buf_lock);
st_sensors_power_enable(indio_dev); st_sensors_power_enable(indio_dev);
......
...@@ -417,6 +417,7 @@ int st_press_common_probe(struct iio_dev *indio_dev) ...@@ -417,6 +417,7 @@ int st_press_common_probe(struct iio_dev *indio_dev)
indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->modes = INDIO_DIRECT_MODE;
indio_dev->info = &press_info; indio_dev->info = &press_info;
mutex_init(&press_data->tb.buf_lock);
st_sensors_power_enable(indio_dev); st_sensors_power_enable(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