iio: Fix 32-bit unaligned helper

0640bf0 added helpers to fetch unaligned memory, but didn't take
the offset to the data location into account, reading from
the header instead.

Closes: #195
This commit is contained in:
Bastien Nocera
2017-10-24 13:46:29 +02:00
parent d1c06920ab
commit 4bf3b38a59

View File

@@ -61,8 +61,8 @@ static inline guint32
iio_readu32 (struct iio_channel_info *info, const guint8 * data)
{
if (info->be)
return _IIO_READ_UINT32_BE (data);
return _IIO_READ_UINT32_LE(data);
return _IIO_READ_UINT32_BE (data + info->location);
return _IIO_READ_UINT32_LE(data + info->location);
}
#define _IIO_GET(__data, __idx, __size, __shift) \
@@ -82,8 +82,8 @@ static inline gint32
iio_read32 (struct iio_channel_info *info, const gint8 * data)
{
if (info->be)
return _IIO_READ_INT32_BE (data);
return _IIO_READ_INT32_LE(data);
return _IIO_READ_INT32_BE (data + info->location);
return _IIO_READ_INT32_LE(data + info->location);
}
static char *