Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1191164 > unrolled thread
| Started by | Irina Tirdea <irina.tirdea@intel.com> |
|---|---|
| First post | 2015-07-23 19:30 +0200 |
| Last post | 2015-07-24 01:10 +0200 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH 0/2] tools: iio: generic_buffer fixes Irina Tirdea <irina.tirdea@intel.com> - 2015-07-23 19:30 +0200
[PATCH 1/2] tools: iio: fix mask for 32 bit sensor data Irina Tirdea <irina.tirdea@intel.com> - 2015-07-23 19:30 +0200
Re: [PATCH 1/2] tools: iio: fix mask for 32 bit sensor data Hartmut Knaack <knaack.h@gmx.de> - 2015-07-24 01:10 +0200
| From | Irina Tirdea <irina.tirdea@intel.com> |
|---|---|
| Date | 2015-07-23 19:30 +0200 |
| Subject | [PATCH 0/2] tools: iio: generic_buffer fixes |
| Message-ID | <pPstI-4VP-17@gated-at.bofh.it> |
Fixes for a couple of small issues found while testing the bmc150_magn driver. Irina Tirdea (2): tools: iio: fix mask for 32 bit sensor data tools: iio: print error message when buffer enable fails tools/iio/generic_buffer.c | 5 ++++- tools/iio/iio_utils.c | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Irina Tirdea <irina.tirdea@intel.com> |
|---|---|
| Date | 2015-07-23 19:30 +0200 |
| Subject | [PATCH 1/2] tools: iio: fix mask for 32 bit sensor data |
| Message-ID | <pPstJ-4VP-41@gated-at.bofh.it> |
| In reply to | #1191164 |
When the the sensor data uses 32 bits out of 32, generic_buffer prints
the value 0 for all data read.
In this case, the mask is shifted 32 bits, which is beyond the size of
an integer. This will lead to the mask always being 0. Before printing,
the mask is applied to the raw value, thus generating a final value of 0.
Fix the mask by shifting a 64 bit value instead of an integer.
Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
---
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 1dcdf03..a95270f 100644
--- a/tools/iio/iio_utils.c
+++ b/tools/iio/iio_utils.c
@@ -168,7 +168,7 @@ int iioutils_get_type(unsigned *is_signed, unsigned *bytes, unsigned *bits_used,
if (*bits_used == 64)
*mask = ~0;
else
- *mask = (1 << *bits_used) - 1;
+ *mask = (1ULL << *bits_used) - 1;
*is_signed = (signchar == 's');
if (fclose(sysfsfp)) {
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Hartmut Knaack <knaack.h@gmx.de> |
|---|---|
| Date | 2015-07-24 01:10 +0200 |
| Subject | Re: [PATCH 1/2] tools: iio: fix mask for 32 bit sensor data |
| Message-ID | <pPxMJ-4tL-15@gated-at.bofh.it> |
| In reply to | #1191168 |
Irina Tirdea schrieb am 23.07.2015 um 19:22:
> When the the sensor data uses 32 bits out of 32, generic_buffer prints
> the value 0 for all data read.
>
> In this case, the mask is shifted 32 bits, which is beyond the size of
> an integer. This will lead to the mask always being 0. Before printing,
> the mask is applied to the raw value, thus generating a final value of 0.
>
> Fix the mask by shifting a 64 bit value instead of an integer.
>
> Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
Acked-by: Hartmut Knaack <knaack.h@gmx.de>
> ---
> 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 1dcdf03..a95270f 100644
> --- a/tools/iio/iio_utils.c
> +++ b/tools/iio/iio_utils.c
> @@ -168,7 +168,7 @@ int iioutils_get_type(unsigned *is_signed, unsigned *bytes, unsigned *bits_used,
> if (*bits_used == 64)
> *mask = ~0;
> else
> - *mask = (1 << *bits_used) - 1;
> + *mask = (1ULL << *bits_used) - 1;
>
> *is_signed = (signchar == 's');
> if (fclose(sysfsfp)) {
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web