Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754700AbbGXN3a (ORCPT ); Fri, 24 Jul 2015 09:29:30 -0400 Received: from mga14.intel.com ([192.55.52.115]:35118 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754670AbbGXN3E (ORCPT ); Fri, 24 Jul 2015 09:29:04 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,538,1432623600"; d="scan'208";a="753837748" From: Irina Tirdea To: Jonathan Cameron , linux-iio@vger.kernel.org, Hartmut Knaack Cc: linux-kernel@vger.kernel.org, Irina Tirdea Subject: [PATCH v2 1/2] tools: iio: fix mask for 32 bit sensor data Date: Fri, 24 Jul 2015 16:28:05 +0300 Message-Id: <1437744486-16456-2-git-send-email-irina.tirdea@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1437744486-16456-1-git-send-email-irina.tirdea@intel.com> References: <1437744486-16456-1-git-send-email-irina.tirdea@intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1257 Lines: 36 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)) { -- 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/