From patchwork Thu Sep 1 09:44:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 75182 Delivered-To: patch@linaro.org Received: by 10.140.29.8 with SMTP id a8csp196614qga; Thu, 1 Sep 2016 02:44:58 -0700 (PDT) X-Received: by 10.98.14.208 with SMTP id 77mr25191781pfo.23.1472723098867; Thu, 01 Sep 2016 02:44:58 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y15si4838059pfb.247.2016.09.01.02.44.58; Thu, 01 Sep 2016 02:44:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751143AbcIAJo6 (ORCPT + 3 others); Thu, 1 Sep 2016 05:44:58 -0400 Received: from mail-lf0-f41.google.com ([209.85.215.41]:36761 "EHLO mail-lf0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751080AbcIAJo5 (ORCPT ); Thu, 1 Sep 2016 05:44:57 -0400 Received: by mail-lf0-f41.google.com with SMTP id g62so56208002lfe.3 for ; Thu, 01 Sep 2016 02:44:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=5oA5KugjZUm4NCEXXVnO7kpzI85y12h2al4BVD6tpps=; b=LZXkJiiamnlV2+N2D1WwiJgYy6jU4QGpcWpmOoZTi/lvq+KZ9g3vymOlZVzsWyepPe JIUKEWtSMqEGN4xhERGJFMdmFWkxpe3tivvOrdNm6/8z/ZFsgscRF13qYHAT+Nv1f6E7 VZwvqbHgQDDM1DSBPuh3gtwRxkI1baxrQkQao= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=5oA5KugjZUm4NCEXXVnO7kpzI85y12h2al4BVD6tpps=; b=KGH30MnzAztKh1hbq/VLyQrrVlJ+JHz7eRnE41ivb9XXNnjjjr4ZlSKLLHdkZp+fUO kW+gE+B6on4QkuGPBvDiKsgUuIPtdk4cdetB/UY38ayAqVcTyb9rDQqs+hBLTLuxShVX Letgcx02JEjjAa181+xzL8FZuSo1wZV3rhYnl6RyzE72JQAKL1pi+dTjQ4y4IaIZkQT8 LFiyTFJR9cmTKWvn/3g4wSNbq5+1f0+pF32n4rDtIymXtvRjlAknHRRqS1gJ9YrMDWrP fZ/HIXx1fWmYKCsfKMAOy8QAI6RSUu2niKT84YSaBne2WqCyYH/76/bRTCY7r+UehuwW FAQg== X-Gm-Message-State: AE9vXwNEt+S3KLvYbFBDWkKBaWB7H+vBGCGNuWpgMXlCAPP4dESxoUUBamrVA7hZtvehH2ti X-Received: by 10.25.144.8 with SMTP id s8mr4922820lfd.94.1472723093918; Thu, 01 Sep 2016 02:44:53 -0700 (PDT) Received: from linuslaptop.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id f22sm792878lji.13.2016.09.01.02.44.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Sep 2016 02:44:53 -0700 (PDT) From: Linus Walleij To: Jonathan Cameron , linux-iio@vger.kernel.org Cc: Linus Walleij , stable@vger.kernel.org Subject: [PATCH 01/15 v2] iio: accel: kxsd9: Fix scaling bug Date: Thu, 1 Sep 2016 11:44:35 +0200 Message-Id: <1472723089-25113-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 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. Cc: stable@vger.kernel.org Tested-by: Jonathan Cameron Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Move this first in the series as Jonathan's request. --- drivers/iio/accel/kxsd9.c | 1 + 1 file changed, 1 insertion(+) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe stable" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/iio/accel/kxsd9.c b/drivers/iio/accel/kxsd9.c index da5fb67ecb34..9d72d4bcf5e9 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;