Re: [PATCH] tools: iio: avoid returning error when channel does not have an offset

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

 



On Sat, Oct 31, 2015 at 11:27 PM, Ioana Ciornei <ciorneiioana@xxxxxxxxx> wrote:
> On Sat, Oct 31, 2015 at 12:13 PM, Jonathan Cameron <jic23@xxxxxxxxxx> wrote:
>> On 30/10/15 13:11, Ioana Ciornei wrote:
>>> This patch avoids getting an error and aborting when a channel does not have a
>>> specific parameter like 'offset' and the file associated with it is not present.
>>> When none of the files from the device folder does not matches the desired channel's
>>> param function iioutils_get_param_float should return 0.
>>>
>>> This change is safe previous to calling the function the parameters are set to
>>> their defaults, 0 in case of 'offset'
>>>
>>> Signed-off-by: Ioana Ciornei <ciorneiioana@xxxxxxxxx>
>> This is rather fixing it in the wrong place.  This function is specifically getting
>> the parameter. If it is not there, then the function should return that fact.
>> It's the caller that should know whether the parameter is optional.
>>
>> For example, build_channel_array explicitly catches the -ENOENT error and allows
>> for that case.
>>

I took a look at the build_channel_array and the
iioutils_get_param_float and now I do not understand how the generic
buffer tool fails at line 495 (where the check is made) if there is no
offset in the channel.
If there is no file in the device folder that matches *_offset it the
iioutils_get_param_float call should return -ENOENT and it should pass
that line since the check permits it.

Sorry, but now I'm confused..

Ioana

>> Perhaps we need to improve the documentation to make it clear that this is
>> the expected behaviour?
>
> Ok, sure. I will deal with the documentation in a patch.
>
> Sorry for the late response.
>
> Ioana
>
>>
>>> ---
>>> not tested
>>>
>>>  tools/iio/iio_utils.c | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/tools/iio/iio_utils.c b/tools/iio/iio_utils.c
>>> index 5eb6793..cbaf696 100644
>>> --- a/tools/iio/iio_utils.c
>>> +++ b/tools/iio/iio_utils.c
>>> @@ -241,7 +241,7 @@ int iioutils_get_param_float(float *output, const char *param_name,
>>>               goto error_free_builtname_generic;
>>>       }
>>>
>>> -     ret = -ENOENT;
>>> +     ret = 0;
>>>       while (ent = readdir(dp), ent)
>>>               if ((strcmp(builtname, ent->d_name) == 0) ||
>>>                   (strcmp(builtname_generic, ent->d_name) == 0)) {
>>>
>>
--
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