Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754235AbbGWXGT (ORCPT ); Thu, 23 Jul 2015 19:06:19 -0400 Received: from mout.gmx.net ([212.227.17.22]:57860 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753682AbbGWXGQ (ORCPT ); Thu, 23 Jul 2015 19:06:16 -0400 Message-ID: <55B1735B.5040706@gmx.de> Date: Fri, 24 Jul 2015 01:06:03 +0200 From: Hartmut Knaack User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:36.0) Gecko/20100101 Firefox/36.0 SeaMonkey/2.33.1 MIME-Version: 1.0 To: Irina Tirdea , Jonathan Cameron , linux-iio@vger.kernel.org CC: linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] tools: iio: fix mask for 32 bit sensor data References: <1437672172-21189-1-git-send-email-irina.tirdea@intel.com> <1437672172-21189-2-git-send-email-irina.tirdea@intel.com> In-Reply-To: <1437672172-21189-2-git-send-email-irina.tirdea@intel.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:99cIigR2Nbuwtay1yZnuIoEq2iAvykRiWo9cDKkvqjxjs1ahB6A 6e1nw/r2CdkzuLm/FGRF0otI5xK1FZlHEQ7R90VX7836GLpUckAUKwlU41vJvvS6zlLL9ls sCue0xphxoR7CDvQqvLi4aXn8kJ7m1lx/osLlNbx4i8siP3DO7H63FULkS0hJxOuz2mrqNR riuC5SSWCNHecFZvMsNMw== X-UI-Out-Filterresults: notjunk:1;V01:K0:AZELJMAnVjs=:4/uAwXRCLiNkfUYko2N+Hj 9KJeYsBl3QM1Kw7ctlT1wtsAqL170JjhHkA3/x/3EFxgGol7ucAUajluvxmRqodXYG4OkS2Az c1iqzAnHF+3800PIgqpCcfTGEUTcjQF06LiLoSlQtbejvqTfkLYC9Nnze/qJX9n5W87rhk6aB C417Lc37w5/f60J15XJ8OUEwqVNSp8ouKwEO2HVWtD+IDThIFEP5RpTnQpbsC1tdS4rz4x4qy ZWaDnYud7rQQ6sEWAYxD8A2PpJOejFS24k20ijPKSrng62k8h//pCpHN8nb4zVrxUGy8tu+mi kQ6VTArcKBV7tjVlVD6pAg9jxgfWQPr6UqbLZYy1YC+2bvvaQQ4eQWXoU7HGoWeE/Ty5hnhOP wyWZzHp3VmWtYBZGgkqc7a70TaxfFgX1c+3ldBvGh9ni/mlSjkqhYbaBDDcvKoeHEG26LPsFW rlj0xPPvvj2639b6wLqlmeNhoIB6HimXgAGBpxUsBSK6k4rbuibROQ4TaedruIUXLHsDIELj8 t19XZO4YmJzlrxxkQsJ332DMsrUeFfbQg2uFnjRrcCkd8IPknEo0PIqTYjE1Z2kFFPCRCHiWF 2mt+2mCSx/tqrfOe63tXxL8j2oIQN/59RYc51wRmalADdTKXs96V70m3Jz9rSGudRtkWPf5tP DW7Chjjvi5/pmlIJaFXFrcyt6udPqRxuLXnQAUij2sSCMRxIwtvlh823BgiTyw0vqJ2E= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1349 Lines: 36 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 Acked-by: Hartmut Knaack > --- > 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/