From patchwork Sun Feb 5 19:20:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Willy Tarreau X-Patchwork-Id: 93377 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp1439217qgi; Sun, 5 Feb 2017 11:58:41 -0800 (PST) X-Received: by 10.84.140.1 with SMTP id 1mr12196666pls.38.1486324721129; Sun, 05 Feb 2017 11:58:41 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r39si31633677pld.320.2017.02.05.11.58.40; Sun, 05 Feb 2017 11:58:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754126AbdBET62 (ORCPT + 25 others); Sun, 5 Feb 2017 14:58:28 -0500 Received: from wtarreau.pck.nerim.net ([62.212.114.60]:28092 "EHLO 1wt.eu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754050AbdBETZc (ORCPT ); Sun, 5 Feb 2017 14:25:32 -0500 Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id v15JMsM2008564; Sun, 5 Feb 2017 20:22:54 +0100 From: Willy Tarreau To: linux-kernel@vger.kernel.org, stable@vger.kernel.org, linux@roeck-us.net Cc: Linus Walleij , Jonathan Cameron , Willy Tarreau Subject: [PATCH 3.10 194/319] iio: accel: kxsd9: Fix scaling bug Date: Sun, 5 Feb 2017 20:20:16 +0100 Message-Id: <1486322541-8206-95-git-send-email-w@1wt.eu> X-Mailer: git-send-email 2.8.0.rc2.1.gbe9624a In-Reply-To: <1486322541-8206-1-git-send-email-w@1wt.eu> References: <1486322541-8206-1-git-send-email-w@1wt.eu> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Linus Walleij commit 307fe9dd11ae44d4f8881ee449a7cbac36e1f5de upstream. All the scaling of the KXSD9 involves multiplication with a fraction number < 1. However the scaling value returned from IIO_INFO_SCALE was unpredictable as only the micros of the value was assigned, and not the integer part, resulting in scaling like this: $cat in_accel_scale -1057462640.011978 Fix this by assigning zero to the integer part. Tested-by: Jonathan Cameron Signed-off-by: Linus Walleij Signed-off-by: Jonathan Cameron Signed-off-by: Willy Tarreau --- drivers/iio/accel/kxsd9.c | 1 + 1 file changed, 1 insertion(+) -- 2.8.0.rc2.1.gbe9624a diff --git a/drivers/iio/accel/kxsd9.c b/drivers/iio/accel/kxsd9.c index d94c0ca..4f9d178 100644 --- a/drivers/iio/accel/kxsd9.c +++ b/drivers/iio/accel/kxsd9.c @@ -166,6 +166,7 @@ static int kxsd9_read_raw(struct iio_dev *indio_dev, ret = spi_w8r8(st->us, KXSD9_READ(KXSD9_REG_CTRL_C)); if (ret < 0) goto error_ret; + *val = 0; *val2 = kxsd9_micro_scales[ret & KXSD9_FS_MASK]; ret = IIO_VAL_INT_PLUS_MICRO; break;