Re: [PATCH] iio: mxs-lradc: Fix misuse of iio->trig

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxx>
> Cc: Fabio Estevam <fabio.estevam@xxxxxxxxxxxxx>
> Cc: Jonathan Cameron <jic23@xxxxxxxxxx>
> Cc: Shawn Guo <shawn.guo@xxxxxxxxxx>

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)
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux