Re: [PATCH 1/5] iio:common: introduce st_sensors_buffer_preenable/predisable functions

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

 



On Wed, 2019-07-31 at 14:52 -0700, Denis Ciocca wrote:
> [External]
> 
> This patch is introducing preenable/postdisable in the common
> st_sensors_buffer code in order to remove the memory allocation /
> de-allocation from each single st driver.
> 

Reviewed-by: Alexandru Ardelean <alexandru.ardelean@xxxxxxxxxx>

> Signed-off-by: Denis Ciocca <denis.ciocca@xxxxxx>
> ---
>  .../iio/common/st_sensors/st_sensors_buffer.c | 22 +++++++++++++++++++
>  include/linux/iio/common/st_sensors.h         |  2 ++
>  2 files changed, 24 insertions(+)
> 
> diff --git a/drivers/iio/common/st_sensors/st_sensors_buffer.c b/drivers/iio/common/st_sensors/st_sensors_buffer.c
> index eee30130ae23..9da1c8104883 100644
> --- a/drivers/iio/common/st_sensors/st_sensors_buffer.c
> +++ b/drivers/iio/common/st_sensors/st_sensors_buffer.c
> @@ -81,6 +81,28 @@ irqreturn_t st_sensors_trigger_handler(int irq, void *p)
>  }
>  EXPORT_SYMBOL(st_sensors_trigger_handler);
>  
> +int st_sensors_buffer_preenable(struct iio_dev *indio_dev)
> +{
> +	struct st_sensor_data *sdata = iio_priv(indio_dev);
> +
> +	sdata->buffer_data = kmalloc(indio_dev->scan_bytes,
> +				     GFP_DMA | GFP_KERNEL);
> +	if (!sdata->buffer_data)
> +		return -ENOMEM;
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL(st_sensors_buffer_preenable);
> +
> +int st_sensors_buffer_postdisable(struct iio_dev *indio_dev)
> +{
> +	struct st_sensor_data *sdata = iio_priv(indio_dev);
> +
> +	kfree(sdata->buffer_data);
> +	return 0;
> +}
> +EXPORT_SYMBOL(st_sensors_buffer_postdisable);
> +
>  MODULE_AUTHOR("Denis Ciocca <denis.ciocca@xxxxxx>");
>  MODULE_DESCRIPTION("STMicroelectronics ST-sensors buffer");
>  MODULE_LICENSE("GPL v2");
> diff --git a/include/linux/iio/common/st_sensors.h b/include/linux/iio/common/st_sensors.h
> index 28fc1f9fa7d5..c66ebb236a15 100644
> --- a/include/linux/iio/common/st_sensors.h
> +++ b/include/linux/iio/common/st_sensors.h
> @@ -254,6 +254,8 @@ struct st_sensor_data {
>  
>  #ifdef CONFIG_IIO_BUFFER
>  irqreturn_t st_sensors_trigger_handler(int irq, void *p);
> +int st_sensors_buffer_preenable(struct iio_dev *indio_dev);
> +int st_sensors_buffer_postdisable(struct iio_dev *indio_dev);
>  #endif
>  
>  #ifdef CONFIG_IIO_TRIGGER




[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