Commit 57a01173 authored by Alban Bedel's avatar Alban Bedel Committed by Luis Henriques

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>
[ luis: backported to 3.16:
  - use 'pdata' instead of 'press_data' in st_press_common_probe()
  - adjusted context ]
Signed-off-by: default avatarLuis Henriques <luis.henriques@canonical.com>
parent 578267de
......@@ -458,6 +458,7 @@ int st_accel_common_probe(struct iio_dev *indio_dev,
indio_dev->modes = INDIO_DIRECT_MODE;
indio_dev->info = &accel_info;
mutex_init(&adata->tb.buf_lock);
st_sensors_power_enable(indio_dev);
......
......@@ -271,8 +271,6 @@ int st_sensors_init_sensor(struct iio_dev *indio_dev,
struct st_sensor_data *sdata = iio_priv(indio_dev);
int err = 0;
mutex_init(&sdata->tb.buf_lock);
if (pdata)
err = st_sensors_set_drdy_int_pin(indio_dev, pdata);
......
......@@ -310,6 +310,7 @@ int st_gyro_common_probe(struct iio_dev *indio_dev,
indio_dev->modes = INDIO_DIRECT_MODE;
indio_dev->info = &gyro_info;
mutex_init(&gdata->tb.buf_lock);
st_sensors_power_enable(indio_dev);
......
......@@ -362,6 +362,7 @@ int st_magn_common_probe(struct iio_dev *indio_dev,
indio_dev->modes = INDIO_DIRECT_MODE;
indio_dev->info = &magn_info;
mutex_init(&mdata->tb.buf_lock);
st_sensors_power_enable(indio_dev);
......
......@@ -395,6 +395,7 @@ int st_press_common_probe(struct iio_dev *indio_dev,
indio_dev->modes = INDIO_DIRECT_MODE;
indio_dev->info = &press_info;
mutex_init(&pdata->tb.buf_lock);
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