Re: iio_buffer_register arguments

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

 



On 01/05/2012 03:19 PM, J.I. Cameron wrote:
> On Jan 5 2012, Lars-Peter Clausen wrote:
> 
>> On 01/04/2012 01:30 PM, Manuel Stahl wrote:
>>> Hi,
>>>
>>> I have a short question about the arguments of iio_buffer_register. Are
>>> they really needed?
>>> When we look at this code from lis3l02dq_core.c:
>>>
>>>     indio_dev->channels = lis3l02dq_channels;
>>>     indio_dev->num_channels = ARRAY_SIZE(lis3l02dq_channels);
>>>
>>>     <zip>
>>>
>>>     ret = iio_buffer_register(indio_dev,
>>>                   lis3l02dq_channels,
>>>                   ARRAY_SIZE(lis3l02dq_channels));
>>>
>>> The needed info is already available in indio_dev...
>>>
>>
>> It might even cause problems if we pass another set of channels to
>> iio_buffer_register as we assign to the indio_dev. So it properly is a good
>> idea to update the function to only take the indio_dev as a parameter.
> There certainly have been driver that have different sets of channels passed
> into
> the buffer registration code from elsewhere. These mostly came about
> to keep things working with minimal changes as we moved over the channel spec.
> 
> Also, we may need a clean way to say, 'this one does not go in the buffer' and
> also a cleaner option for the opposite case of 'this one is buffered only'.
> 
> Jonathan


Just wrote a small cocci script which finds these drivers and there are
indeed two which do this:

./adc/ad7298_core.c:223:7-26: Channels passed to iio_buffer_register differ
./adc/ad7298_core.c:223:7-26: Number of channels passed to
iio_buffer_register differ
./impedance-analyzer/ad5933.c:734:7-26: Channels passed to
iio_buffer_register differ
./impedance-analyzer/ad5933.c:734:7-26: Number of channels passed to
iio_buffer_register differ

So I guess best would be to add a flag to chan spec which allows us to
specify that a channel is not buffer-able or buffered only.

- Lars



@r1@
struct iio_dev *indio_dev;
expression ch;
expression num;
@@
indio_dev->channels = ch;
indio_dev->num_channels = num;

@r2 depends on r1@
expression indiodev;
expression ch;
expression num;
position p;
@@
 iio_buffer_register@p(indiodev, ch, num)

@script:python depends on r2@
indio_dev << r1.indio_dev;
ch1 << r1.ch;
ch2 << r2.ch;
num1 << r1.num;
num2 << r2.num;
p << r2.p;
@@

if (str(ch1) != str(ch2) and str(ch2) != "%s -> channels" % str(indio_dev)):
	coccilib.report.print_report(p[0], "Channels passed to iio_buffer_register
differ")
if (str(num1) != str(num2) and
	str(num2) != "%s -> num_channels" % str(indio_dev)):
	coccilib.report.print_report(p[0], "Number of channels passed " +
		"to iio_buffer_register differ")
--
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