linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Irina Tirdea <irina.tirdea@intel.com>,
	linux-iio@vger.kernel.org, Hartmut Knaack <knaack.h@gmx.de>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/2] tools: iio: fix mask for 32 bit sensor data
Date: Sun, 2 Aug 2015 18:38:54 +0100	[thread overview]
Message-ID: <55BE55AE.1000001@kernel.org> (raw)
In-Reply-To: <1437744486-16456-2-git-send-email-irina.tirdea@intel.com>

On 24/07/15 14:28, Irina Tirdea wrote:
> 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>
Applied to the togreg branch of iio.git
Pushed out as testing for the autobuilders to completely
ignore this patch :)

Jonathan
> ---
>  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)) {
> 


  reply	other threads:[~2015-08-02 17:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-24 13:28 [PATCH v2 0/2] tools: iio: generic_buffer fixes Irina Tirdea
2015-07-24 13:28 ` [PATCH v2 1/2] tools: iio: fix mask for 32 bit sensor data Irina Tirdea
2015-08-02 17:38   ` Jonathan Cameron [this message]
2015-07-24 13:28 ` [PATCH v2 2/2] tools: iio: print error message when buffer enable fails Irina Tirdea
2015-07-24 18:23   ` Hartmut Knaack
2015-08-02 17:39     ` Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55BE55AE.1000001@kernel.org \
    --to=jic23@kernel.org \
    --cc=irina.tirdea@intel.com \
    --cc=knaack.h@gmx.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).