Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751858AbbHBRi5 (ORCPT ); Sun, 2 Aug 2015 13:38:57 -0400 Received: from saturn.retrosnub.co.uk ([178.18.118.26]:45462 "EHLO saturn.retrosnub.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751434AbbHBRi4 (ORCPT ); Sun, 2 Aug 2015 13:38:56 -0400 Subject: Re: [PATCH v2 1/2] tools: iio: fix mask for 32 bit sensor data To: Irina Tirdea , linux-iio@vger.kernel.org, Hartmut Knaack References: <1437744486-16456-1-git-send-email-irina.tirdea@intel.com> <1437744486-16456-2-git-send-email-irina.tirdea@intel.com> Cc: linux-kernel@vger.kernel.org From: Jonathan Cameron Message-ID: <55BE55AE.1000001@kernel.org> Date: Sun, 2 Aug 2015 18:38:54 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <1437744486-16456-2-git-send-email-irina.tirdea@intel.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1473 Lines: 41 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 > Acked-by: Hartmut Knaack 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)) { > -- 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/