Re: [PATCH 4/7] iio: triggered-buffer: simplify devm_iio_triggered_buffer_setup_ext

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

 



On 2021/4/11 22:16, Jonathan Cameron wrote:
> On Thu, 8 Apr 2021 19:38:13 +0800
> Yicong Yang <yangyicong@xxxxxxxxxxxxx> wrote:
> 
>> Use devm_add_action_or_reset() instead of devres_alloc() and
>> devres_add(), which works the same. This will simplify the
>> code. There is no functional changes.
>>
>> Signed-off-by: Yicong Yang <yangyicong@xxxxxxxxxxxxx>
>> ---
>>  drivers/iio/buffer/industrialio-triggered-buffer.c | 19 +++++--------------
>>  1 file changed, 5 insertions(+), 14 deletions(-)
>>
>> diff --git a/drivers/iio/buffer/industrialio-triggered-buffer.c b/drivers/iio/buffer/industrialio-triggered-buffer.c
>> index 92b8aea..63b4722 100644
>> --- a/drivers/iio/buffer/industrialio-triggered-buffer.c
>> +++ b/drivers/iio/buffer/industrialio-triggered-buffer.c
>> @@ -92,9 +92,9 @@ void iio_triggered_buffer_cleanup(struct iio_dev *indio_dev)
>>  }
>>  EXPORT_SYMBOL(iio_triggered_buffer_cleanup);
>>  
>> -static void devm_iio_triggered_buffer_clean(struct device *dev, void *res)
>> +static void devm_iio_triggered_buffer_clean(void *indio_dev)
>>  {
>> -	iio_triggered_buffer_cleanup(*(struct iio_dev **)res);
>> +	iio_triggered_buffer_cleanup(indio_dev);
>>  }
>>  
>>  int devm_iio_triggered_buffer_setup_ext(struct device *dev,
>> @@ -104,24 +104,15 @@ int devm_iio_triggered_buffer_setup_ext(struct device *dev,
>>  					const struct iio_buffer_setup_ops *ops,
>>  					const struct attribute **buffer_attrs)
>>  {
>> -	struct iio_dev **ptr;
>>  	int ret;
>>  
>> -	ptr = devres_alloc(devm_iio_triggered_buffer_clean, sizeof(*ptr),
>> -			   GFP_KERNEL);
>> -	if (!ptr)
>> -		return -ENOMEM;
>> -
>> -	*ptr = indio_dev;
>> -
>>  	ret = iio_triggered_buffer_setup_ext(indio_dev, h, thread, ops,
>>  					     buffer_attrs);
>>  	if (!ret)
>> -		devres_add(dev, ptr);
>> -	else
>> -		devres_free(ptr);
>> +		return ret;
> 
> This looks inverted from what it should be.
> 
> 	if (ret)
> 		return ret;
> 
> 	return devm_add_action_or_reset()...
> 

yes. it does. will fix.

thanks

>>  
>> -	return ret;
>> +	return devm_add_action_or_reset(dev, devm_iio_triggered_buffer_clean,
>> +					indio_dev);
>>  }
>>  EXPORT_SYMBOL_GPL(devm_iio_triggered_buffer_setup_ext);
>>  
> 
> 
> .
> 




[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