Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp971423rdb; Fri, 20 Oct 2023 05:09:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IETkz4XffmBL4Nzk99WHplpCHHqn69ob2Z8dEZ9Kr+lMdUGNdytjdOqPAWzod9dwCerpFRX X-Received: by 2002:a05:6358:71a:b0:143:864e:f96f with SMTP id e26-20020a056358071a00b00143864ef96fmr1536511rwj.1.1697803780622; Fri, 20 Oct 2023 05:09:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697803780; cv=none; d=google.com; s=arc-20160816; b=tPzZc7W7fWRqIX1N+8vkZBqUa2YUUVoui+3t4X5HnkUDQIMObg+utozzXq9/6+7/EE 20dq5RktEMdmkHTyQhjy8rN7u3LXXnwJm2afMirfQqBemrbnK4gc6lY52xl6QqHQlSTj ojwng66qJw9cxxaXVJePda2OGrYrTQW3zFpvq+fe3ilYHXg+uTxemS7ceQAU2hQPuQ4g 6XtVb1/Uq/DwzZPOAyleYi17VjAMJ2vchc1MbKryC7jT6m0AcZkTEOANriJKSgdh4lt+ JfKH1gcGc4lCSVfgxBdevYWng4+MPCqU60xRJe7D751pt2aGvgT6iHb26H2NhzU2txce tkQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=mGwuaBFtqO94TAMSnO/Xh6NCf2pq0vUZ7fh5FlEE1TU=; fh=AQEG9nX3csSazH0LPztSV+kmZ0LNp4lwrftv731KsrA=; b=YpCBVXvfUbpnlRreDlwHAXoXKKZNBQsd4aYm0X9/yZBUJu0y4b1Sf+r/EUzAQDijD7 0HfYbWCKZ/cXusrto3y1EZoLOJadF+LxLgMK06efq805i+D2Hh4SVGQ+CwFrnCLEpTls KNtsthjn90dCkmbSU2SQCpnpcIX0oXeUZ3GksCjo+g3pkN6gDOLllATQYqdO+gqDiwAE wZHTLmxMxAPffWzZ0MVWmRquWLaZCbS973gZioFt+goo4xiAjol/t2UGfZrtrDaIk0de EJMChERtmUwi1A7yobjwK1ccMIV+2iQgYairh4Myl5rCRQ00y5UdSDvgyYRqjicrxsSh leog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=UOD1IR7j; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id r23-20020aa79637000000b0068fea8a6169si1650003pfg.404.2023.10.20.05.09.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 05:09:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=UOD1IR7j; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 8422182A5051; Fri, 20 Oct 2023 05:09:38 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377329AbjJTMJW (ORCPT + 99 others); Fri, 20 Oct 2023 08:09:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377099AbjJTMJV (ORCPT ); Fri, 20 Oct 2023 08:09:21 -0400 Received: from mail-lj1-x234.google.com (mail-lj1-x234.google.com [IPv6:2a00:1450:4864:20::234]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E55239E; Fri, 20 Oct 2023 05:09:18 -0700 (PDT) Received: by mail-lj1-x234.google.com with SMTP id 38308e7fff4ca-2c503da4fd6so10556411fa.1; Fri, 20 Oct 2023 05:09:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697803757; x=1698408557; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=mGwuaBFtqO94TAMSnO/Xh6NCf2pq0vUZ7fh5FlEE1TU=; b=UOD1IR7jqLMlN9d4+r+Lk7+JogbOFvRlbgWrxJXqC29vtOP4v+6otcPGa8fYOulN6C fcvvo3Zy4qHBMlFBGeZ4SWQ/KIm+7RcMt7FtBNUU9hJlWVl/gnKLHUE4NICYJa6QO7TS /HoyXGfnYEHD7B85vwj8ewhOQ54x2pUOQLsNqq9H4dlXblEHwGo3+ZQObBfGheojHmm5 iuK+/9Vkf15a/ZQADBOoOFT9Kit6gOs9lw+aRopvLUpflZy3o8KYS3uNNlOIvXxItqgK 0VQ8KI/AbIvjZAJ2XDleNvc7swx9otzxa5uuPsPsVT1xkh7tsMjHaECUmjsSV+rbB+u8 oZuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697803757; x=1698408557; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=mGwuaBFtqO94TAMSnO/Xh6NCf2pq0vUZ7fh5FlEE1TU=; b=q0GaLh19VNN5O7USmkEf6Znq/L3y4Qf5ZsknkaemVsqvir2W+uA3AKPpsrQH4zWSqD +Oj206R0/dDc9/j7aZpco2qrSjT70w5K/x2xlDX5UNSB9ULwgRI4EDQp3Pds6cNoTBVo a/0P3N5KzmXQiSstzJ0KuHCkGqGpsblGGpZV/LDRpk+rT8uefbmGGkqv9m1BxOxibtgw MJtjFjVWOI2cQwSuS1x1WCEFI3oVr3zmNwL8UB/F4rtJLhesbYy0vMwbJPiJwQpYs7zK kpyB0YJEmMTEMZwD4fFwvaVXJvHiczOa3rc4KJruZ9pffLMkv4Z/SLcc0oMjkgD+0LlH ETlg== X-Gm-Message-State: AOJu0YxE6B/3ihe4rPGt0IftJ8Xfd9bFwj3luSr7De5jHWpsIH578oUk S0r+4nAqMLXBQD1eqzgUyxw= X-Received: by 2002:a05:651c:a0c:b0:2c5:24a8:c22d with SMTP id k12-20020a05651c0a0c00b002c524a8c22dmr1760577ljq.3.1697803756767; Fri, 20 Oct 2023 05:09:16 -0700 (PDT) Received: from ?IPV6:2001:14ba:16f8:1500::7? (dc78bmyyyyyyyyyyyyydt-3.rev.dnainternet.fi. [2001:14ba:16f8:1500::7]) by smtp.gmail.com with ESMTPSA id p12-20020a2e740c000000b002b6ad323248sm336000ljc.10.2023.10.20.05.09.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 20 Oct 2023 05:09:15 -0700 (PDT) Message-ID: Date: Fri, 20 Oct 2023 15:09:14 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] iio: kx022a: Fix acceleration value scaling Content-Language: en-US, en-GB To: Jagath Jog J Cc: Matti Vaittinen , Jonathan Cameron , Lars-Peter Clausen , Mehdi Djait , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org References: From: Matti Vaittinen In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Fri, 20 Oct 2023 05:09:38 -0700 (PDT) On 10/19/23 21:21, Jagath Jog J wrote: > Hi Matti, > > On Thu, Oct 19, 2023 at 6:54 PM Matti Vaittinen > wrote: >> >> The IIO ABI mandates acceleration values from accelerometer to be >> emitted in m/s^2. The KX022A was emitting values in micro m/s^2. >> >> Fix driver to report the correct scale values. >> >> Signed-off-by: Matti Vaittinen >> Reported-by: Jagath Jog J >> Fixes: 7c1d1677b322 ("iio: accel: Support Kionix/ROHM KX022A accelerometer") >> >> --- >> The fix is somewhat crude and just crops the last 3 digits (rounds) of the >> scale while using IIO_VAL_INT_PLUS_NANO. I played with a thought of using >> IIO_VAL_FRACTIONAL, which could have modelled the computation >> G_range * g * scaling / (2^16 * scaling) - where scaling 10000 would >> have allowed using g value 980665. >> >> This would have worked fine for reporting scale and available scales - >> but would be somewhat tricky when converting the user-supplied scale to >> register values in write_raw(). >> >> Well, the g varies from 9.832 (poles) to 9.780 (equator) according to >> some website - no proper source check done but this sounds about right - >> so maybe the loss of accuracy is acceptable. >> >> I did only very quick testing on KX022A and iio_generic_buffer. After >> the patch the values seemed to be correct order of magnitude. Further >> testing is appreciated :) > > Values are correct with this change, Thank you for fixing. > Tested-by: Jagath Jog J Thanks a ton for testing! May I ask which component did you use (or did you just use some 'simulated' regster values?) Yours, -- Matti -- Matti Vaittinen Linux kernel developer at ROHM Semiconductors Oulu Finland ~~ When things go utterly wrong vim users can always type :help! ~~