Commit e1b1fa66 authored by Marek Vasut's avatar Marek Vasut Committed by Jonathan Cameron

iio: mxs-lradc: Fix misuse of iio->trig

The struct iio_dev .trig field is to be used only by the IIO core,
the driver shall not fill this field. This fixes ugly crash when
the driver is compiled as a module and the module is rmmod'd.
Signed-off-by: default avatarMarek Vasut <marex@denx.de>
Cc: Fabio Estevam <fabio.estevam@freescale.com>
Cc: Jonathan Cameron <jic23@kernel.org>
Cc: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent f91d1b63
...@@ -661,12 +661,13 @@ static int mxs_lradc_trigger_init(struct iio_dev *iio) ...@@ -661,12 +661,13 @@ static int mxs_lradc_trigger_init(struct iio_dev *iio)
{ {
int ret; int ret;
struct iio_trigger *trig; struct iio_trigger *trig;
struct mxs_lradc *lradc = iio_priv(iio);
trig = iio_trigger_alloc("%s-dev%i", iio->name, iio->id); trig = iio_trigger_alloc("%s-dev%i", iio->name, iio->id);
if (trig == NULL) if (trig == NULL)
return -ENOMEM; return -ENOMEM;
trig->dev.parent = iio->dev.parent; trig->dev.parent = lradc->dev;
iio_trigger_set_drvdata(trig, iio); iio_trigger_set_drvdata(trig, iio);
trig->ops = &mxs_lradc_trigger_ops; trig->ops = &mxs_lradc_trigger_ops;
...@@ -676,15 +677,17 @@ static int mxs_lradc_trigger_init(struct iio_dev *iio) ...@@ -676,15 +677,17 @@ static int mxs_lradc_trigger_init(struct iio_dev *iio)
return ret; return ret;
} }
iio->trig = trig; lradc->trig = trig;
return 0; return 0;
} }
static void mxs_lradc_trigger_remove(struct iio_dev *iio) static void mxs_lradc_trigger_remove(struct iio_dev *iio)
{ {
iio_trigger_unregister(iio->trig); struct mxs_lradc *lradc = iio_priv(iio);
iio_trigger_free(iio->trig);
iio_trigger_unregister(lradc->trig);
iio_trigger_free(lradc->trig);
} }
static int mxs_lradc_buffer_preenable(struct iio_dev *iio) static int mxs_lradc_buffer_preenable(struct iio_dev *iio)
......
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