diff mbox

[v3,07/11] IIO: consumer: allow to set buffer sizes

Message ID 1489759704-30217-8-git-send-email-arnaud.pouliquen@st.com (mailing list archive)
State New, archived
Headers show

Commit Message

Arnaud POULIQUEN March 17, 2017, 2:08 p.m. UTC
Add iio consumer API to set buffer size and watermark according
to sysfs API.

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
---
 drivers/iio/buffer/industrialio-buffer-cb.c | 12 ++++++++++++
 include/linux/iio/consumer.h                | 13 +++++++++++++
 2 files changed, 25 insertions(+)

Comments

Jonathan Cameron March 19, 2017, 10:44 p.m. UTC | #1
On 17/03/17 14:08, Arnaud Pouliquen wrote:
> Add iio consumer API to set buffer size and watermark according
> to sysfs API.
> 
> Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
Hmm. Not keen on the length one.  Setting a requested watermark
is fair enough.  There is no actually buffer in these cases though
so setting it's length is downright odd..

Guess this is part of the hacks we need to clean up by doing
the dma buffer consumer stuff right...

Jonathan
> ---
>  drivers/iio/buffer/industrialio-buffer-cb.c | 12 ++++++++++++
>  include/linux/iio/consumer.h                | 13 +++++++++++++
>  2 files changed, 25 insertions(+)
> 
> diff --git a/drivers/iio/buffer/industrialio-buffer-cb.c b/drivers/iio/buffer/industrialio-buffer-cb.c
> index b8f550e..43c066a 100644
> --- a/drivers/iio/buffer/industrialio-buffer-cb.c
> +++ b/drivers/iio/buffer/industrialio-buffer-cb.c
> @@ -103,6 +103,18 @@ struct iio_cb_buffer *iio_channel_get_all_cb(struct device *dev,
>  }
>  EXPORT_SYMBOL_GPL(iio_channel_get_all_cb);
>  
> +int iio_channel_cb_set_buffer_params(struct iio_cb_buffer *cb_buff,
> +				      size_t length, size_t watermark)
> +{
> +	if (!length || length < watermark)
> +		return -EINVAL;
> +	cb_buff->buffer.watermark = watermark;
> +	cb_buff->buffer.length = length;
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL_GPL(iio_channel_start_all_cb);
> +
>  int iio_channel_start_all_cb(struct iio_cb_buffer *cb_buff)
>  {
>  	return iio_update_buffers(cb_buff->indio_dev, &cb_buff->buffer,
> diff --git a/include/linux/iio/consumer.h b/include/linux/iio/consumer.h
> index cb44771..0f6e94d 100644
> --- a/include/linux/iio/consumer.h
> +++ b/include/linux/iio/consumer.h
> @@ -134,6 +134,19 @@ struct iio_cb_buffer *iio_channel_get_all_cb(struct device *dev,
>  						       void *private),
>  					     void *private);
>  /**
> + * iio_channel_cb_set_buffer_size() - set the buffer length.
> + * @cb_buffer:		The callback buffer from whom we want the channel
> + *			information.
> + * @length: buffer length in bytes
> + * @watermark: buffer watermark in bytes
> + *
> + * This function allows to configure the buffer length. The watermark if
> + * forced to half of the buffer.
> + */
> +int iio_channel_cb_set_buffer_params(struct iio_cb_buffer *cb_buffer,
> +				     size_t length, size_t watermark);
> +
> +/**
>   * iio_channel_release_all_cb() - release and unregister the callback.
>   * @cb_buffer:		The callback buffer that was allocated.
>   */
>
kernel test robot March 20, 2017, 6:22 a.m. UTC | #2
Hi Arnaud,

[auto build test ERROR on asoc/for-next]
[also build test ERROR on v4.11-rc3]
[cannot apply to iio/togreg next-20170310]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Arnaud-Pouliquen/Add-STM32-DFSDM-support/20170320-133247
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
config: i386-randconfig-x073-201712 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All error/warnings (new ones prefixed by >>):

   In file included from include/linux/linkage.h:6:0,
                    from include/linux/kernel.h:6,
                    from drivers/iio/buffer/industrialio-buffer-cb.c:8:
>> include/linux/export.h:67:20: error: redefinition of '__kstrtab_iio_channel_start_all_cb'
     static const char __kstrtab_##sym[]    \
                       ^
   include/linux/export.h:100:25: note: in expansion of macro '___EXPORT_SYMBOL'
    #define __EXPORT_SYMBOL ___EXPORT_SYMBOL
                            ^~~~~~~~~~~~~~~~
   include/linux/export.h:107:2: note: in expansion of macro '__EXPORT_SYMBOL'
     __EXPORT_SYMBOL(sym, "_gpl")
     ^~~~~~~~~~~~~~~
>> drivers/iio/buffer/industrialio-buffer-cb.c:124:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
    EXPORT_SYMBOL_GPL(iio_channel_start_all_cb);
    ^~~~~~~~~~~~~~~~~
   include/linux/export.h:67:20: note: previous definition of '__kstrtab_iio_channel_start_all_cb' was here
     static const char __kstrtab_##sym[]    \
                       ^
   include/linux/export.h:100:25: note: in expansion of macro '___EXPORT_SYMBOL'
    #define __EXPORT_SYMBOL ___EXPORT_SYMBOL
                            ^~~~~~~~~~~~~~~~
   include/linux/export.h:107:2: note: in expansion of macro '__EXPORT_SYMBOL'
     __EXPORT_SYMBOL(sym, "_gpl")
     ^~~~~~~~~~~~~~~
   drivers/iio/buffer/industrialio-buffer-cb.c:117:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
    EXPORT_SYMBOL_GPL(iio_channel_start_all_cb);
    ^~~~~~~~~~~~~~~~~
   include/linux/export.h:70:36: error: redefinition of '__ksymtab_iio_channel_start_all_cb'
     static const struct kernel_symbol __ksymtab_##sym  \
                                       ^
   include/linux/export.h:100:25: note: in expansion of macro '___EXPORT_SYMBOL'
    #define __EXPORT_SYMBOL ___EXPORT_SYMBOL
                            ^~~~~~~~~~~~~~~~
   include/linux/export.h:107:2: note: in expansion of macro '__EXPORT_SYMBOL'
     __EXPORT_SYMBOL(sym, "_gpl")
     ^~~~~~~~~~~~~~~
>> drivers/iio/buffer/industrialio-buffer-cb.c:124:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
    EXPORT_SYMBOL_GPL(iio_channel_start_all_cb);
    ^~~~~~~~~~~~~~~~~
   include/linux/export.h:70:36: note: previous definition of '__ksymtab_iio_channel_start_all_cb' was here
     static const struct kernel_symbol __ksymtab_##sym  \
                                       ^
   include/linux/export.h:100:25: note: in expansion of macro '___EXPORT_SYMBOL'
    #define __EXPORT_SYMBOL ___EXPORT_SYMBOL
                            ^~~~~~~~~~~~~~~~
   include/linux/export.h:107:2: note: in expansion of macro '__EXPORT_SYMBOL'
     __EXPORT_SYMBOL(sym, "_gpl")
     ^~~~~~~~~~~~~~~
   drivers/iio/buffer/industrialio-buffer-cb.c:117:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
    EXPORT_SYMBOL_GPL(iio_channel_start_all_cb);
    ^~~~~~~~~~~~~~~~~

vim +/__kstrtab_iio_channel_start_all_cb +67 include/linux/export.h

f5016932 Paul Gortmaker  2011-05-23  61  #endif
f5016932 Paul Gortmaker  2011-05-23  62  
f5016932 Paul Gortmaker  2011-05-23  63  /* For every exported symbol, place a struct in the __ksymtab section */
f2355416 Nicolas Pitre   2016-01-22  64  #define ___EXPORT_SYMBOL(sym, sec)					\
f5016932 Paul Gortmaker  2011-05-23  65  	extern typeof(sym) sym;						\
f5016932 Paul Gortmaker  2011-05-23  66  	__CRC_SYMBOL(sym, sec)						\
f5016932 Paul Gortmaker  2011-05-23 @67  	static const char __kstrtab_##sym[]				\
f5016932 Paul Gortmaker  2011-05-23  68  	__attribute__((section("__ksymtab_strings"), aligned(1)))	\
b92021b0 Rusty Russell   2013-03-15  69  	= VMLINUX_SYMBOL_STR(sym);					\
b67067f1 Nicholas Piggin 2016-08-24  70  	static const struct kernel_symbol __ksymtab_##sym		\

:::::: The code at line 67 was first introduced by commit
:::::: f50169324df4ad942e544386d136216c8617636a module.h: split out the EXPORT_SYMBOL into export.h

:::::: TO: Paul Gortmaker <paul.gortmaker@windriver.com>
:::::: CC: Paul Gortmaker <paul.gortmaker@windriver.com>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
Arnaud POULIQUEN March 20, 2017, 11:30 a.m. UTC | #3
On 03/19/2017 11:44 PM, Jonathan Cameron wrote:
> On 17/03/17 14:08, Arnaud Pouliquen wrote:
>> Add iio consumer API to set buffer size and watermark according
>> to sysfs API.
>>
>> Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
> Hmm. Not keen on the length one.  Setting a requested watermark
> is fair enough.  There is no actually buffer in these cases though
> so setting it's length is downright odd..
Length and watermark are configurable from user land through sysfs.
Seems to me logic to also propose it in inkern API...
But I can clean length , no problem.

> 
> Guess this is part of the hacks we need to clean up by doing
> the dma buffer consumer stuff right...
Yes all is linked :-).

> 
> Jonathan
>> ---
>>  drivers/iio/buffer/industrialio-buffer-cb.c | 12 ++++++++++++
>>  include/linux/iio/consumer.h                | 13 +++++++++++++
>>  2 files changed, 25 insertions(+)
>>
>> diff --git a/drivers/iio/buffer/industrialio-buffer-cb.c b/drivers/iio/buffer/industrialio-buffer-cb.c
>> index b8f550e..43c066a 100644
>> --- a/drivers/iio/buffer/industrialio-buffer-cb.c
>> +++ b/drivers/iio/buffer/industrialio-buffer-cb.c
>> @@ -103,6 +103,18 @@ struct iio_cb_buffer *iio_channel_get_all_cb(struct device *dev,
>>  }
>>  EXPORT_SYMBOL_GPL(iio_channel_get_all_cb);
>>  
>> +int iio_channel_cb_set_buffer_params(struct iio_cb_buffer *cb_buff,
>> +				      size_t length, size_t watermark)
>> +{
>> +	if (!length || length < watermark)
>> +		return -EINVAL;
>> +	cb_buff->buffer.watermark = watermark;
>> +	cb_buff->buffer.length = length;
>> +
>> +	return 0;
>> +}
>> +EXPORT_SYMBOL_GPL(iio_channel_start_all_cb);
>> +
>>  int iio_channel_start_all_cb(struct iio_cb_buffer *cb_buff)
>>  {
>>  	return iio_update_buffers(cb_buff->indio_dev, &cb_buff->buffer,
>> diff --git a/include/linux/iio/consumer.h b/include/linux/iio/consumer.h
>> index cb44771..0f6e94d 100644
>> --- a/include/linux/iio/consumer.h
>> +++ b/include/linux/iio/consumer.h
>> @@ -134,6 +134,19 @@ struct iio_cb_buffer *iio_channel_get_all_cb(struct device *dev,
>>  						       void *private),
>>  					     void *private);
>>  /**
>> + * iio_channel_cb_set_buffer_size() - set the buffer length.
>> + * @cb_buffer:		The callback buffer from whom we want the channel
>> + *			information.
>> + * @length: buffer length in bytes
>> + * @watermark: buffer watermark in bytes
>> + *
>> + * This function allows to configure the buffer length. The watermark if
>> + * forced to half of the buffer.
>> + */
>> +int iio_channel_cb_set_buffer_params(struct iio_cb_buffer *cb_buffer,
>> +				     size_t length, size_t watermark);
>> +
>> +/**
>>   * iio_channel_release_all_cb() - release and unregister the callback.
>>   * @cb_buffer:		The callback buffer that was allocated.
>>   */
>>
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
Jonathan Cameron March 25, 2017, 4:01 p.m. UTC | #4
On 20/03/17 11:30, Arnaud Pouliquen wrote:
> 
> 
> On 03/19/2017 11:44 PM, Jonathan Cameron wrote:
>> On 17/03/17 14:08, Arnaud Pouliquen wrote:
>>> Add iio consumer API to set buffer size and watermark according
>>> to sysfs API.
>>>
>>> Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
>> Hmm. Not keen on the length one.  Setting a requested watermark
>> is fair enough.  There is no actually buffer in these cases though
>> so setting it's length is downright odd..
> Length and watermark are configurable from user land through sysfs.
> Seems to me logic to also propose it in inkern API...
> But I can clean length , no problem.
The concept of length for the consumer interface doesn't currently
make sense as it refers to an actual buffer.   The consumer interface
currently passes one entry at a time...
> 
>>
>> Guess this is part of the hacks we need to clean up by doing
>> the dma buffer consumer stuff right...
> Yes all is linked :-).
> 
>>
>> Jonathan
>>> ---
>>>  drivers/iio/buffer/industrialio-buffer-cb.c | 12 ++++++++++++
>>>  include/linux/iio/consumer.h                | 13 +++++++++++++
>>>  2 files changed, 25 insertions(+)
>>>
>>> diff --git a/drivers/iio/buffer/industrialio-buffer-cb.c b/drivers/iio/buffer/industrialio-buffer-cb.c
>>> index b8f550e..43c066a 100644
>>> --- a/drivers/iio/buffer/industrialio-buffer-cb.c
>>> +++ b/drivers/iio/buffer/industrialio-buffer-cb.c
>>> @@ -103,6 +103,18 @@ struct iio_cb_buffer *iio_channel_get_all_cb(struct device *dev,
>>>  }
>>>  EXPORT_SYMBOL_GPL(iio_channel_get_all_cb);
>>>  
>>> +int iio_channel_cb_set_buffer_params(struct iio_cb_buffer *cb_buff,
>>> +				      size_t length, size_t watermark)
>>> +{
>>> +	if (!length || length < watermark)
>>> +		return -EINVAL;
>>> +	cb_buff->buffer.watermark = watermark;
>>> +	cb_buff->buffer.length = length;
>>> +
>>> +	return 0;
>>> +}
>>> +EXPORT_SYMBOL_GPL(iio_channel_start_all_cb);
>>> +
>>>  int iio_channel_start_all_cb(struct iio_cb_buffer *cb_buff)
>>>  {
>>>  	return iio_update_buffers(cb_buff->indio_dev, &cb_buff->buffer,
>>> diff --git a/include/linux/iio/consumer.h b/include/linux/iio/consumer.h
>>> index cb44771..0f6e94d 100644
>>> --- a/include/linux/iio/consumer.h
>>> +++ b/include/linux/iio/consumer.h
>>> @@ -134,6 +134,19 @@ struct iio_cb_buffer *iio_channel_get_all_cb(struct device *dev,
>>>  						       void *private),
>>>  					     void *private);
>>>  /**
>>> + * iio_channel_cb_set_buffer_size() - set the buffer length.
>>> + * @cb_buffer:		The callback buffer from whom we want the channel
>>> + *			information.
>>> + * @length: buffer length in bytes
>>> + * @watermark: buffer watermark in bytes
>>> + *
>>> + * This function allows to configure the buffer length. The watermark if
>>> + * forced to half of the buffer.
>>> + */
>>> +int iio_channel_cb_set_buffer_params(struct iio_cb_buffer *cb_buffer,
>>> +				     size_t length, size_t watermark);
>>> +
>>> +/**
>>>   * iio_channel_release_all_cb() - release and unregister the callback.
>>>   * @cb_buffer:		The callback buffer that was allocated.
>>>   */
>>>
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
diff mbox

Patch

diff --git a/drivers/iio/buffer/industrialio-buffer-cb.c b/drivers/iio/buffer/industrialio-buffer-cb.c
index b8f550e..43c066a 100644
--- a/drivers/iio/buffer/industrialio-buffer-cb.c
+++ b/drivers/iio/buffer/industrialio-buffer-cb.c
@@ -103,6 +103,18 @@  struct iio_cb_buffer *iio_channel_get_all_cb(struct device *dev,
 }
 EXPORT_SYMBOL_GPL(iio_channel_get_all_cb);
 
+int iio_channel_cb_set_buffer_params(struct iio_cb_buffer *cb_buff,
+				      size_t length, size_t watermark)
+{
+	if (!length || length < watermark)
+		return -EINVAL;
+	cb_buff->buffer.watermark = watermark;
+	cb_buff->buffer.length = length;
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(iio_channel_start_all_cb);
+
 int iio_channel_start_all_cb(struct iio_cb_buffer *cb_buff)
 {
 	return iio_update_buffers(cb_buff->indio_dev, &cb_buff->buffer,
diff --git a/include/linux/iio/consumer.h b/include/linux/iio/consumer.h
index cb44771..0f6e94d 100644
--- a/include/linux/iio/consumer.h
+++ b/include/linux/iio/consumer.h
@@ -134,6 +134,19 @@  struct iio_cb_buffer *iio_channel_get_all_cb(struct device *dev,
 						       void *private),
 					     void *private);
 /**
+ * iio_channel_cb_set_buffer_size() - set the buffer length.
+ * @cb_buffer:		The callback buffer from whom we want the channel
+ *			information.
+ * @length: buffer length in bytes
+ * @watermark: buffer watermark in bytes
+ *
+ * This function allows to configure the buffer length. The watermark if
+ * forced to half of the buffer.
+ */
+int iio_channel_cb_set_buffer_params(struct iio_cb_buffer *cb_buffer,
+				     size_t length, size_t watermark);
+
+/**
  * iio_channel_release_all_cb() - release and unregister the callback.
  * @cb_buffer:		The callback buffer that was allocated.
  */