Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp548595pxb; Thu, 21 Apr 2022 05:32:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzaBuIwHwNwL/fGrA+2LnpKaL5yv07pIXPxsTaHPsuFCcWfzNb0u8/UCtFuOaQJ3kodrkyh X-Received: by 2002:a65:4c4e:0:b0:39d:21c4:2381 with SMTP id l14-20020a654c4e000000b0039d21c42381mr23836973pgr.566.1650544363586; Thu, 21 Apr 2022 05:32:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650544363; cv=none; d=google.com; s=arc-20160816; b=OzBI/UCGmHFzvn6s8Bw1MuIfjom5PUErKfLGhgoDjZ2ty7L3xpDDNihLYWVLle0WF1 JdI8U+6tJum/f34wtJO5oAtvwaYgutzvzWQfESUdQ8LisS7FTb/ctsZiLEPfcf0XuH7k 2FpXCrc9r0enQhPaxlDsevJ9MR+n66R0y71xy2sEWfq4vJnHb4+xcYexU9kTWMPwh1bK 2oycc3IBq9nKW0XGVovIEfj79hTlm/SDd9ZKh4BOEg+5B1sVUrTP4L5Ywk8GNsGMwrrq f5XaV77gva89jrpNrgsxHztv9fQcEkt+3RZ/fxhOA4bBvZP5g2+GbQmpBxB9TvYppw+7 01hQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=4ROcGHuFTnTL2fbWmLOSf06EmqWWnhDvcVWXtNXGstI=; b=Ie4M6hpMFp4SZfvq7sP/no/vwt5BOsNWnTnX6ZfKh0vycEzC4r86hdgxvlRjmgDOwP IaWlktBFW+QNzwjyUh7MysXcZwbuLfaFoAnG9lm2SjkDXO81a6q1XLJEWvbwXXTm4b9V 9dgeTFLVVRfI5HPxVV4U1/EBdCzjLI6vCtthjFquoWY6zcOqHbIb4cpqZt557sS6t5s2 L9CJ4Qu+ufSwSx+/R1qwffMlLjY792D1RVIfczHhEbq0TK2vgpbPh1EC6MHYTiO9XDCL jkqTxINFRstJVJ67WTdpfpeNqr+4FEhHByGC28k4BlzV7J8MN1E0oxCY7+Xb0SVmVO8F pZQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=dtdXqku7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x135-20020a63318d000000b0039d59d47179si5698778pgx.225.2022.04.21.05.32.28; Thu, 21 Apr 2022 05:32:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=dtdXqku7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1382366AbiDTVOB (ORCPT + 99 others); Wed, 20 Apr 2022 17:14:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1382353AbiDTVN7 (ORCPT ); Wed, 20 Apr 2022 17:13:59 -0400 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B43F13B2A1; Wed, 20 Apr 2022 14:11:12 -0700 (PDT) Received: by mail-pl1-x62b.google.com with SMTP id q3so2948555plg.3; Wed, 20 Apr 2022 14:11:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4ROcGHuFTnTL2fbWmLOSf06EmqWWnhDvcVWXtNXGstI=; b=dtdXqku7t/c6bQ12fBhLC3WNa1pewG3OxAFM2pWllY2YFRbL/fvdRm+dNoPywCBGzH 8n61Dcox8RxUuf8vq4xG/GlzYPdVS4CsiN0iVdSe++BPHsf6SHwQ10GXbPo8Ev39u+el 8uH/8rr5l2EUcNbb2L5yV9XcC6Kxa06VpjMID4CxYJU6pAnqhps8pW6ANQuKBlNPOucU QOixqOzZK82Z7eJDRxtA5tHa91frQT8mp7/hE88REUpwA3D+VhUfnQOJW/LISEBGEm6O u8+YKAzTnMgKg8Wb8vAgJz5BEkUY3CBHUBOC2rr8RA66CiW7ocVMfZfqgj9UgfoFfDY6 QcPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=4ROcGHuFTnTL2fbWmLOSf06EmqWWnhDvcVWXtNXGstI=; b=mu495PcW3YtFr0PXogAhL3Slo+iE2TU+tzIT+26CK4QYT1xwj2mX1qPZNY0cveuSy5 EX+m9JtYRI9c4nX1KPlnVRSoSeu7VS6INMGZH1RnY12lS8fvQzWg5ZTNnOyMtSSo2A0o u6X3SrasCc1G/lVkYOL3sW9SCkkQDQv09cyzz4/EfL9hrGRCa7i5W6N5NWxcJ8Lvpe2m sMoVCsEalO9UcJycjIuJVRxTnrakXAmqwlNpY5FaCFQD4rH8SE3NhG4DGTz0mWWap0nS Fampqlefq2F/JhLuyycchyUmVlnn7NbcMcFIeK6tOesvKsEM59taGRWp/ACkNdEeTjqH wrOQ== X-Gm-Message-State: AOAM532KOLYdvI6r+7FvL6HDQEMUp61m7698gFgjb4pGW+4h4opsYzJ7 7EBybrFMv/TvhCpUPmREboA= X-Received: by 2002:a17:902:bd06:b0:158:8973:b16b with SMTP id p6-20020a170902bd0600b001588973b16bmr22532902pls.129.1650489072179; Wed, 20 Apr 2022 14:11:12 -0700 (PDT) Received: from localhost.localdomain ([27.7.104.83]) by smtp.gmail.com with ESMTPSA id v13-20020a17090a00cd00b001cd4989fee4sm106652pjd.48.2022.04.20.14.11.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 14:11:11 -0700 (PDT) From: Jagath Jog J To: dan@dlrobertson.com, jic23@kernel.org, andy.shevchenko@gmail.com Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 1/9] iio: accel: bma400: Fix the scale min and max macro values Date: Thu, 21 Apr 2022 02:40:57 +0530 Message-Id: <20220420211105.14654-2-jagathjog1996@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220420211105.14654-1-jagathjog1996@gmail.com> References: <20220420211105.14654-1-jagathjog1996@gmail.com> X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Changing the scale macro values to match the bma400 sensitivity for 1 LSB of all the available ranges. Fixes: 465c811f1f20 ("iio: accel: Add driver for the BMA400") Signed-off-by: Jagath Jog J --- drivers/iio/accel/bma400.h | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/drivers/iio/accel/bma400.h b/drivers/iio/accel/bma400.h index c4c8d74155c2..80330c7ce17f 100644 --- a/drivers/iio/accel/bma400.h +++ b/drivers/iio/accel/bma400.h @@ -83,8 +83,27 @@ #define BMA400_ACC_ODR_MIN_WHOLE_HZ 25 #define BMA400_ACC_ODR_MIN_HZ 12 -#define BMA400_SCALE_MIN 38357 -#define BMA400_SCALE_MAX 306864 +/* + * BMA400_SCALE_MIN macro value represents m/s^2 for 1 LSB before + * converting to micro values for +-2g range. + * + * For +-2g - 1 LSB = 0.976562 milli g = 0.009576 m/s^2 + * For +-4g - 1 LSB = 1.953125 milli g = 0.019153 m/s^2 + * For +-16g - 1 LSB = 7.8125 milli g = 0.076614 m/s^2 + * + * The raw value which is used to select the different ranges is determined + * by the first bit set position from the scale value, so BMA400_SCALE_MIN + * should be odd. + * + * Scale values for +-2g, +-4g, +-8g and +-16g are populated into bma400_scales + * array by left shifting BMA400_SCALE_MIN. + * e.g.: + * To select +-2g = 9577 << 0 = raw value to write is 0. + * To select +-8g = 9577 << 2 = raw value to write is 2. + * To select +-16g = 9577 << 3 = raw value to write is 3. + */ +#define BMA400_SCALE_MIN 9577 +#define BMA400_SCALE_MAX 76617 #define BMA400_NUM_REGULATORS 2 #define BMA400_VDD_REGULATOR 0 -- 2.17.1