aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Vasut <marex@denx.de>2013-06-29 17:20:00 -0400
committerJonathan Cameron <jic23@kernel.org>2013-07-03 15:48:53 -0400
commite1b1fa66a0398f0b52ae79a2bdc7de87c205d074 (patch)
treeb40a32ce62bd667e33d83cd66da131fe0364eb11
parentf91d1b63a4e096d3023aaaafec9d9d3aff25997f (diff)
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: 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> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
-rw-r--r--drivers/staging/iio/adc/mxs-lradc.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/drivers/staging/iio/adc/mxs-lradc.c b/drivers/staging/iio/adc/mxs-lradc.c
index d92c97a59d61..c5edf1cad07a 100644
--- a/drivers/staging/iio/adc/mxs-lradc.c
+++ b/drivers/staging/iio/adc/mxs-lradc.c
@@ -661,12 +661,13 @@ static int mxs_lradc_trigger_init(struct iio_dev *iio)
661{ 661{
662 int ret; 662 int ret;
663 struct iio_trigger *trig; 663 struct iio_trigger *trig;
664 struct mxs_lradc *lradc = iio_priv(iio);
664 665
665 trig = iio_trigger_alloc("%s-dev%i", iio->name, iio->id); 666 trig = iio_trigger_alloc("%s-dev%i", iio->name, iio->id);
666 if (trig == NULL) 667 if (trig == NULL)
667 return -ENOMEM; 668 return -ENOMEM;
668 669
669 trig->dev.parent = iio->dev.parent; 670 trig->dev.parent = lradc->dev;
670 iio_trigger_set_drvdata(trig, iio); 671 iio_trigger_set_drvdata(trig, iio);
671 trig->ops = &mxs_lradc_trigger_ops; 672 trig->ops = &mxs_lradc_trigger_ops;
672 673
@@ -676,15 +677,17 @@ static int mxs_lradc_trigger_init(struct iio_dev *iio)
676 return ret; 677 return ret;
677 } 678 }
678 679
679 iio->trig = trig; 680 lradc->trig = trig;
680 681
681 return 0; 682 return 0;
682} 683}
683 684
684static void mxs_lradc_trigger_remove(struct iio_dev *iio) 685static void mxs_lradc_trigger_remove(struct iio_dev *iio)
685{ 686{
686 iio_trigger_unregister(iio->trig); 687 struct mxs_lradc *lradc = iio_priv(iio);
687 iio_trigger_free(iio->trig); 688
689 iio_trigger_unregister(lradc->trig);
690 iio_trigger_free(lradc->trig);
688} 691}
689 692
690static int mxs_lradc_buffer_preenable(struct iio_dev *iio) 693static int mxs_lradc_buffer_preenable(struct iio_dev *iio)