iio-buffer-utils: Don't fail on non-existing attributes

build_channel_array() goes through each directory member in
scan_elements folder and tries to get scale and offset of matching
elements. But there will be no scale and offset for some elements
like timestamp.
For example:
in_accel_x_en     in_accel_y_en     in_accel_z_en     in_timestamp_en
in_accel_x_index  in_accel_y_index  in_accel_z_index  in_timestamp_index
in_accel_x_type   in_accel_y_type   in_accel_z_type   in_timestamp_type

When scale and offset not present, iioutils_get_param_float() will fail,
this causes return from the build_channel_array().

It shouldn't return when the error is caused by the attribute not being
present as, in this case, in_time_stamp_scale.

This was fixed in the kernel's iio_utils.c in commit 7868dfd.
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=7868dfd216074fc5f902e7befacda2a0ec76e403

Closes: #114
This commit is contained in:
Srinivas Pandruvada
2016-11-17 13:39:27 -08:00
committed by Bastien Nocera
parent 78b4656fc2
commit 12c137bcf1

View File

@@ -275,7 +275,7 @@ build_channel_array (const char *device_dir,
device_dir,
current->name,
current->generic_name);
if (ret < 0)
if ((ret < 0) && (ret != -ENOENT))
goto error;
ret = iioutils_get_param_float (&current->offset,
@@ -283,7 +283,7 @@ build_channel_array (const char *device_dir,
device_dir,
current->name,
current->generic_name);
if (ret < 0)
if ((ret < 0) && (ret != -ENOENT))
goto error;
ret = iioutils_get_type (&current->is_signed,