Commit d513454b authored by Alban Bedel's avatar Alban Bedel Committed by Greg Kroah-Hartman

iio:st_sensors: Fix oops when probing SPI devices

commit 8e71c04f upstream.

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>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 3e630b9b
...@@ -465,6 +465,7 @@ int st_accel_common_probe(struct iio_dev *indio_dev) ...@@ -465,6 +465,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)
......
...@@ -317,6 +317,7 @@ int st_gyro_common_probe(struct iio_dev *indio_dev) ...@@ -317,6 +317,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