* [PATCH] iio: mxs-lradc: Fix misuse of iio->trig
@ 2013-06-29 21:20 Marek Vasut
2013-07-03 19:50 ` Jonathan Cameron
0 siblings, 1 reply; 3+ messages in thread
From: Marek Vasut @ 2013-06-29 21:20 UTC (permalink / raw)
To: linux-iio; +Cc: otavio, Marek Vasut, Fabio Estevam, Jonathan Cameron, Shawn Guo
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: Marek Vasut <marex@denx.de>
Cc: Fabio Estevam <fabio.estevam@freescale.com>
Cc: Jonathan Cameron <jic23@kernel.org>
Cc: Shawn Guo <shawn.guo@linaro.org>
---
drivers/staging/iio/adc/mxs-lradc.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/iio/adc/mxs-lradc.c b/drivers/staging/iio/adc/mxs-lradc.c
index 55a459b..28e029a 100644
--- a/drivers/staging/iio/adc/mxs-lradc.c
+++ b/drivers/staging/iio/adc/mxs-lradc.c
@@ -664,12 +664,13 @@ static int mxs_lradc_trigger_init(struct iio_dev *iio)
{
int ret;
struct iio_trigger *trig;
+ struct mxs_lradc *lradc = iio_priv(iio);
trig = iio_trigger_alloc("%s-dev%i", iio->name, iio->id);
if (trig == NULL)
return -ENOMEM;
- trig->dev.parent = iio->dev.parent;
+ trig->dev.parent = lradc->dev;
trig->private_data = iio;
trig->ops = &mxs_lradc_trigger_ops;
@@ -679,15 +680,17 @@ static int mxs_lradc_trigger_init(struct iio_dev *iio)
return ret;
}
- iio->trig = trig;
+ lradc->trig = trig;
return 0;
}
static void mxs_lradc_trigger_remove(struct iio_dev *iio)
{
- iio_trigger_unregister(iio->trig);
- iio_trigger_free(iio->trig);
+ struct mxs_lradc *lradc = iio_priv(iio);
+
+ iio_trigger_unregister(lradc->trig);
+ iio_trigger_free(lradc->trig);
}
static int mxs_lradc_buffer_preenable(struct iio_dev *iio)
--
1.7.10.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] iio: mxs-lradc: Fix misuse of iio->trig
2013-06-29 21:20 [PATCH] iio: mxs-lradc: Fix misuse of iio->trig Marek Vasut
@ 2013-07-03 19:50 ` Jonathan Cameron
2013-07-03 21:47 ` Marek Vasut
0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Cameron @ 2013-07-03 19:50 UTC (permalink / raw)
To: Marek Vasut; +Cc: linux-iio, otavio, Fabio Estevam, Shawn Guo
On 06/29/2013 10:20 PM, Marek Vasut wrote:
> 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: Marek Vasut <marex@denx.de>
> Cc: Fabio Estevam <fabio.estevam@freescale.com>
> Cc: Jonathan Cameron <jic23@kernel.org>
> Cc: Shawn Guo <shawn.guo@linaro.org>
I've applied this to the fixes-togreg branch of iio.git but had a bit
of fuzz, could you just santiy check that nothing went wrong please.
https://git.kernel.org/cgit/linux/kernel/git/jic23/iio.git/log/?h=fixes-togreg
Thanks
Jonathan
> ---
> drivers/staging/iio/adc/mxs-lradc.c | 11 +++++++----
> 1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/staging/iio/adc/mxs-lradc.c b/drivers/staging/iio/adc/mxs-lradc.c
> index 55a459b..28e029a 100644
> --- a/drivers/staging/iio/adc/mxs-lradc.c
> +++ b/drivers/staging/iio/adc/mxs-lradc.c
> @@ -664,12 +664,13 @@ static int mxs_lradc_trigger_init(struct iio_dev *iio)
> {
> int ret;
> struct iio_trigger *trig;
> + struct mxs_lradc *lradc = iio_priv(iio);
>
> trig = iio_trigger_alloc("%s-dev%i", iio->name, iio->id);
> if (trig == NULL)
> return -ENOMEM;
>
> - trig->dev.parent = iio->dev.parent;
> + trig->dev.parent = lradc->dev;
> trig->private_data = iio;
> trig->ops = &mxs_lradc_trigger_ops;
>
> @@ -679,15 +680,17 @@ static int mxs_lradc_trigger_init(struct iio_dev *iio)
> return ret;
> }
>
> - iio->trig = trig;
> + lradc->trig = trig;
>
> return 0;
> }
>
> static void mxs_lradc_trigger_remove(struct iio_dev *iio)
> {
> - iio_trigger_unregister(iio->trig);
> - iio_trigger_free(iio->trig);
> + struct mxs_lradc *lradc = iio_priv(iio);
> +
> + iio_trigger_unregister(lradc->trig);
> + iio_trigger_free(lradc->trig);
> }
>
> static int mxs_lradc_buffer_preenable(struct iio_dev *iio)
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] iio: mxs-lradc: Fix misuse of iio->trig
2013-07-03 19:50 ` Jonathan Cameron
@ 2013-07-03 21:47 ` Marek Vasut
0 siblings, 0 replies; 3+ messages in thread
From: Marek Vasut @ 2013-07-03 21:47 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, otavio, Fabio Estevam, Shawn Guo
Hello Jonathan,
> On 06/29/2013 10:20 PM, Marek Vasut wrote:
> > 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: Marek Vasut <marex@denx.de>
> > Cc: Fabio Estevam <fabio.estevam@freescale.com>
> > Cc: Jonathan Cameron <jic23@kernel.org>
> > Cc: Shawn Guo <shawn.guo@linaro.org>
>
> I've applied this to the fixes-togreg branch of iio.git but had a bit
> of fuzz, could you just santiy check that nothing went wrong please.
>
> https://git.kernel.org/cgit/linux/kernel/git/jic23/iio.git/log/?h=fixes-tog
> reg
>
> Thanks
All OK, it must be my -next tree, sorry for the trouble.
Best regards,
Marek Vasut
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-07-03 21:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-29 21:20 [PATCH] iio: mxs-lradc: Fix misuse of iio->trig Marek Vasut
2013-07-03 19:50 ` Jonathan Cameron
2013-07-03 21:47 ` Marek Vasut
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.