Skip to content

Commit

Permalink
iio:st_sensors: Fix oops when probing SPI devices
Browse files Browse the repository at this point in the history
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: Alban Bedel <alban.bedel@avionic-design.de>
Acked-by: Denis Ciocca <denis.ciocca@st.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
  • Loading branch information
Alban Bedel authored and Jonathan Cameron committed Apr 26, 2015
1 parent 97ffae1 commit 8e71c04
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions drivers/iio/accel/st_accel_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,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);

Expand Down
2 changes: 0 additions & 2 deletions drivers/iio/common/st_sensors/st_sensors_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,6 @@ int st_sensors_init_sensor(struct iio_dev *indio_dev,
struct st_sensors_platform_data *of_pdata;
int err = 0;

mutex_init(&sdata->tb.buf_lock);

/* If OF/DT pdata exists, it will take precedence of anything else */
of_pdata = st_sensors_of_probe(indio_dev->dev.parent, pdata);
if (of_pdata)
Expand Down
1 change: 1 addition & 0 deletions drivers/iio/gyro/st_gyro_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,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);

Expand Down
1 change: 1 addition & 0 deletions drivers/iio/magnetometer/st_magn_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,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);

Expand Down
1 change: 1 addition & 0 deletions drivers/iio/pressure/st_pressure_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ int st_press_common_probe(struct iio_dev *indio_dev)

indio_dev->modes = INDIO_DIRECT_MODE;
indio_dev->info = &press_info;
mutex_init(&press_data->tb.buf_lock);

st_sensors_power_enable(indio_dev);

Expand Down

0 comments on commit 8e71c04

Please sign in to comment.