From patchwork Wed Dec 28 09:39:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Song X-Patchwork-Id: 13082802 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 70A81C4708D for ; Wed, 28 Dec 2022 09:39:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232554AbiL1JjP (ORCPT ); Wed, 28 Dec 2022 04:39:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232813AbiL1JjJ (ORCPT ); Wed, 28 Dec 2022 04:39:09 -0500 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2074.outbound.protection.outlook.com [40.107.22.74]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA53DDF11 for ; Wed, 28 Dec 2022 01:39:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R52f+FaA0QcrE5PgsZ/vCzQKJh4o9qku37vCsDAY1O7p1kGUBjcDXJ521INJ1C78bx70W+zGmQtgfioSrgeEThIEwycHJW5iubZic/fYQZpA6xCH0OZ9TQF0s9gH0YYVzEt/A9wvPeRC8clRyG5iCvcic3lv8ZZaG4TrmtyimHk+n5k50rPQ5t0vMGlrF8PI6MzIUQHojwyIHEl3N+B64cZ/yfIx4nCGeZPlvxodgBmp6rUrxMMHCoUMFeTrbnOHQNaqXckQUKZr46WunU0gBFxcWCuLzPx7D+i89G+K0z1joGiX9LsLJjebqpoOT0HfmgVAjz87R0nFmKpkLLLG3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=WIhyZryQxFaQMbqpvTPAfPJDo2jCPPhJp5rmu/3JlhI=; b=kkEUr+vDZJNHtrcjzywhcWtDs1uNWlKmFShNL+1ytKVzo0DqCGumAaGi8IX/I7rWI7dIZYcuGvrTIqiLfjYYbBrjt0wC2uysFWIuajSQpKYjNl4psHRpt0OBHOOa+wkWtiq2aVCNUEz4KIKtnJ5I4h5SDJsKx17QYyKZOIbHa+RG0+cJMHTKHZ/mi+aqOy7CYgSTbTQ0t2PnN/Qt1uky8gkeMaqQCcxV1qR6IAunoLt2zD6WiOAtjbvdQjZk2sKxk4t21mQc4xz12QSJJ18AKytsLSqPx6LFccZSLsn0drtZbymoaFypzo2Htmxguq7gpHDDGZ4hmVtHO+hLBuN+kw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WIhyZryQxFaQMbqpvTPAfPJDo2jCPPhJp5rmu/3JlhI=; b=knQbm4M6KbXJ4/YxgaOCBYT3XspIuQn3Pu8Jlx2VWCnGHACztWE9a2Elr28NfbOhjWCReV7X4+1fXW270jVk/YRhE5O1hSxxlBCgtwjit5eiJKE4c639o0yoZ+ahrQdTuTyDzyp3dEK+5HdsrXEQQzngIbs811tzEcsKV8EiAoo= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5005.eurprd04.prod.outlook.com (2603:10a6:803:57::30) by AM9PR04MB8177.eurprd04.prod.outlook.com (2603:10a6:20b:3b7::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.16; Wed, 28 Dec 2022 09:39:07 +0000 Received: from VI1PR04MB5005.eurprd04.prod.outlook.com ([fe80::e2d1:cb8b:dc57:8749]) by VI1PR04MB5005.eurprd04.prod.outlook.com ([fe80::e2d1:cb8b:dc57:8749%3]) with mapi id 15.20.5944.014; Wed, 28 Dec 2022 09:39:07 +0000 From: carlos.song@nxp.com To: jic23@kernel.org, lars@metafoo.de Cc: rjones@gateworks.com, Jonathan.Cameron@huawei.com, haibo.chen@nxp.com, carlos.song@nxp.com, linux-imx@nxp.com, linux-iio@vger.kernel.org Subject: [PATCH v4 1/4] iio: imu: fxos8700: fix incorrect ODR mode readback Date: Wed, 28 Dec 2022 17:39:38 +0800 Message-Id: <20221228093941.270046-2-carlos.song@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221228093941.270046-1-carlos.song@nxp.com> References: <20221228093941.270046-1-carlos.song@nxp.com> X-ClientProxiedBy: SI2PR01CA0030.apcprd01.prod.exchangelabs.com (2603:1096:4:192::15) To VI1PR04MB5005.eurprd04.prod.outlook.com (2603:10a6:803:57::30) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5005:EE_|AM9PR04MB8177:EE_ X-MS-Office365-Filtering-Correlation-Id: d086c384-fc3c-48e0-c37a-08dae8b75dad X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uQlOSp7MAvbM9jqvVyxbxJO7t9GlfpZgw1BHBbdd7zFPDtIeni6Cxzna23DX0vYUuEzt/oaq92vCz86IunRIIZDJ7hLkocjW1ikmCjOn58SuIMtLBPYoc6mlRrJ0TehldQI6UEwsFZz8A/HDl3MqOFYaP5F9/VoORqOMkczaN7icPOaM+aomsmw6EkdQDHtV0pnhsIE7JWbG20Pfh1cZyx5Gace9K7h1IDxkwfQixaq0fw0NDFwXwHiL9H8fx5oj/9DCiILbvNydTQGruF031hzJyUhGX6mk6XemSBoFbEUDp2Flxe9uvE8AmR+ca56XNvD5ulfeObNm3KopEhhyIeWvhRu4IdvQudCSfp5utreGJG71lDw9D98qPuK2WRzwnCJiJzWOW+DEyIvVnd41QiQU4pUHS+MC7cfX/5OEh7Y8A13uTuXIYeAY5p126ygzRD+1HK9cARBd9DK3+KANj4VdpXOicJLfh26riTuq2okIRtI5+1ZvQfuGnlUONhYFMIo4aV/lVCWVUYuORaRWvJI7VtXJAD84SSdOQ+KvvZrD8ypaMve2Kzmvp7GyVpmO4nxWuGbSHytqjDNm8Hz7rIGoTyvmRmdfp3fDffUcvAFtaPYCIF75SkGL5GD7EZwfRE92/iW6kY7OahSGHxFKM0V9uSTOiriFOsGnxzb7U5oT/nZcx77SB6ZaJLFM38dg2FvR0eUvJXVRRY7+Hdas5A== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5005.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(39860400002)(366004)(346002)(136003)(376002)(396003)(451199015)(66476007)(66556008)(4326008)(8676002)(8936002)(86362001)(5660300002)(66946007)(41300700001)(36756003)(316002)(2906002)(83380400001)(52116002)(6486002)(478600001)(1076003)(6666004)(2616005)(6506007)(186003)(26005)(6512007)(9686003)(38100700002)(38350700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fvfRCVm0KLk1KGqt4j/3KaM1xsdzqlVlkpGG4B5uPzkkrUZi/H36WN5IGsQ+Kb+NPRAz0971e/D/znwknvhtLDgsB7VNXFtS17xXSxgBH2SzZT5auzsRaCJBFQcs5cetCRkdrEP+Fxb/ZEeoBSz8g91nVk07KA4DqShW8DhqcY7XyB+lCo5yvtl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mmXnhW382Fvt+AfShKYT9TQgV3lNoLTJnYJkYNW5ZhOwHjs4yHA96VtjA+i0L885pwtVio4mD9hE0qP2fzCfTwIh6h1kBlOPqLBgBhgcOC2+Pe6V2TeTXUhgp6kUnvPPQ5o1F4TAnm/TW4AAtqHbdK+HGtKb7lzc75srzXPmTC3701QVIgrAsjoq4goxfHq2U7QOMj7YRAlEFGYeANiCYJLDUP+i7VfEd4p/neQ0CDz/ykCwNjJM9tQMsTzMDvKhV5+z1OjzxLarJJgSeq63n01hyVR8og10YTUcF7OcW4UTdxfNnwXhr7Sc+cIUUyFnY1wuD9AxwY3Tp6PYz0w X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d086c384-fc3c-48e0-c37a-08dae8b75dad X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5005.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Dec 2022 09:39:07.7174 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 5BGSs4IFYqSdnPQyLJECnhNaxO10+2pIGmLhdENSGDRCyz8NS2Vw/olHBWTh6cqvcCf3s7cMADb1zWYW9zVNyA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8177 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Carlos Song The absence of a correct offset leads an incorrect ODR mode readback after use a hexadecimal number to mark the value from FXOS8700_CTRL_REG1. Get ODR mode by field mask and FIELD_GET clearly and conveniently. And attach other additional fix for keeping the original code logic and a good readability. Fixes: 84e5ddd5c46e ("iio: imu: Add support for the FXOS8700 IMU") Signed-off-by: Carlos Song --- Changes for V4: - Use ODR_MSK in the first place that merged the first two patches in V3 into this patch. - Rework commit log Changes for V3: - Remove FXOS8700_CTRL_ODR_GENMSK and set FXOS8700_CTRL_ODR_MSK a field mask - Legal use of filed mask and FIELD_PREP() to select ODR mode - Rework commit log --- drivers/iio/imu/fxos8700_core.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/iio/imu/fxos8700_core.c b/drivers/iio/imu/fxos8700_core.c index 773f62203bf0..a1af5d0fde5d 100644 --- a/drivers/iio/imu/fxos8700_core.c +++ b/drivers/iio/imu/fxos8700_core.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -144,9 +145,9 @@ #define FXOS8700_NVM_DATA_BNK0 0xa7 /* Bit definitions for FXOS8700_CTRL_REG1 */ -#define FXOS8700_CTRL_ODR_MSK 0x38 #define FXOS8700_CTRL_ODR_MAX 0x00 #define FXOS8700_CTRL_ODR_MIN GENMASK(4, 3) +#define FXOS8700_CTRL_ODR_MSK GENMASK(5, 3) /* Bit definitions for FXOS8700_M_CTRL_REG1 */ #define FXOS8700_HMS_MASK GENMASK(1, 0) @@ -508,10 +509,8 @@ static int fxos8700_set_odr(struct fxos8700_data *data, enum fxos8700_sensor t, if (i >= odr_num) return -EINVAL; - return regmap_update_bits(data->regmap, - FXOS8700_CTRL_REG1, - FXOS8700_CTRL_ODR_MSK + FXOS8700_ACTIVE, - fxos8700_odr[i].bits << 3 | active_mode); + val = val | FIELD_PREP(FXOS8700_CTRL_ODR_MSK, fxos8700_odr[i].bits) | active_mode; + return regmap_write(data->regmap, FXOS8700_CTRL_REG1, val); } static int fxos8700_get_odr(struct fxos8700_data *data, enum fxos8700_sensor t, @@ -524,7 +523,7 @@ static int fxos8700_get_odr(struct fxos8700_data *data, enum fxos8700_sensor t, if (ret) return ret; - val &= FXOS8700_CTRL_ODR_MSK; + val = FIELD_GET(FXOS8700_CTRL_ODR_MSK, val); for (i = 0; i < odr_num; i++) if (val == fxos8700_odr[i].bits) From patchwork Wed Dec 28 09:39:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Song X-Patchwork-Id: 13082800 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5B796C46467 for ; Wed, 28 Dec 2022 09:39:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232562AbiL1JjQ (ORCPT ); Wed, 28 Dec 2022 04:39:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232819AbiL1JjO (ORCPT ); Wed, 28 Dec 2022 04:39:14 -0500 Received: from EUR03-VI1-obe.outbound.protection.outlook.com (mail-vi1eur03on2070.outbound.protection.outlook.com [40.107.103.70]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 762C5F015 for ; Wed, 28 Dec 2022 01:39:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UxgZR2Q/5qEasjWQgkOUvVQImmwwl7TOpX8R99MyhLzxCb8/7QOKQYTcYsuHctthUxdWd2eTp8alMcTWBA+w1QVhG8rNSkijwu/VuEwSj1NaF2QfdH4GcJv8kgqbKk2nUMm6sXCUTlyhChUC2X2Xsys1HGJiOCka0MQxaokJGUIuQXS+xwvdbux7p5WCtCJ/Bt6xK4+i6hfqmCjLSVnqjes5aJueDTWnpIi0EIw9IcyM47qSGhoE6fN7yCCoosTtJy/vg/2RIZ5+RGOnjxUsCH5514oGs5wRfNIZ5mTuz8JNu38uQd8nqpWlPADH9LWgdiIJ9Rz5mA59gQgb3S04Iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=TgXC0Z3/M2gPBYpPr4l3jOhdS4KGeH6Tl2udpBH5iwQ=; b=DNDs4j8aijnGNmhvM7p4sz+SZgFrke89IXiq0XSApKdVH6/XwtBGKYL3CUzNUyTpXvIsP4dI4SKStqresrQxTyzbzV8wRLF3SwH0Gi+UGz5NDDdJjbB0B92md9JPI8NHiUDelQ3XAWRcAbT8DBRDRWXIbw/J7jtKg83+EsagnIx7XHm3HZ7JvxBCSd510Q1xMfFMRSBsZEfhozJpmdMNm0gSrX6Xh7j0Hwaiz6+wFmo1heYv5sjpvXY+L6zc0oaNtuWOok5+c0uVM58W1qrkRufJ1WXoEfafgbtO469WdE0PsbrsJdOVuJEbJak7aNI+AVwUWGxsfFHkQZBnZAn+yQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TgXC0Z3/M2gPBYpPr4l3jOhdS4KGeH6Tl2udpBH5iwQ=; b=Qm+nsHG2yP+E8LoCvP5Ntdwm0fJ/HTq781xZI6OfUQBSM7olOeW7mK5MXdrhq85IPyZDHbenV8Jd7Q1yNzj8f57NLEONaJPA4yYxG7bkBCJlQzqKO1HfWnD61CcMEvqpy3eUF6jMqAJBK+OZzdV6SuSJAjEE5oDI2C3E+DtOPbU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5005.eurprd04.prod.outlook.com (2603:10a6:803:57::30) by AM9PR04MB8177.eurprd04.prod.outlook.com (2603:10a6:20b:3b7::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.16; Wed, 28 Dec 2022 09:39:10 +0000 Received: from VI1PR04MB5005.eurprd04.prod.outlook.com ([fe80::e2d1:cb8b:dc57:8749]) by VI1PR04MB5005.eurprd04.prod.outlook.com ([fe80::e2d1:cb8b:dc57:8749%3]) with mapi id 15.20.5944.014; Wed, 28 Dec 2022 09:39:10 +0000 From: carlos.song@nxp.com To: jic23@kernel.org, lars@metafoo.de Cc: rjones@gateworks.com, Jonathan.Cameron@huawei.com, haibo.chen@nxp.com, carlos.song@nxp.com, linux-imx@nxp.com, linux-iio@vger.kernel.org Subject: [PATCH v4 2/4] iio: imu: fxos8700: fix failed initialization ODR mode assignment Date: Wed, 28 Dec 2022 17:39:39 +0800 Message-Id: <20221228093941.270046-3-carlos.song@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221228093941.270046-1-carlos.song@nxp.com> References: <20221228093941.270046-1-carlos.song@nxp.com> X-ClientProxiedBy: SI2PR01CA0030.apcprd01.prod.exchangelabs.com (2603:1096:4:192::15) To VI1PR04MB5005.eurprd04.prod.outlook.com (2603:10a6:803:57::30) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5005:EE_|AM9PR04MB8177:EE_ X-MS-Office365-Filtering-Correlation-Id: 7d7c9863-623e-47f7-451e-08dae8b75f5d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GRa2ncO/69cnGIruqQ4WEADhpF+69xnj2RDLIUByRqLZKrQQlweP0jGR7Wn4dE1WWolV7cCqR55Hw3lanQ+omcs5Dl87NTYGnQwr5cYbUydMKTG2UAdLJG4W9JALNcgO4M66d/oiRJfDMML2Ip4QMRIzoa8JAFzrXjd95YuzS08Jlb9u07CdiGNTJHHdSMdRdn+yrtcGA8nId7RQ79xoecMSj6ajqD6duuUY2/1DWtiS0p4p/UVPb3uCAE80C+dC/qbJHUKA1PVzLPNQKktGzJq/kmSkURhQvAsM4QbcgXu3vvi/7K4sNZ+ZVLybDvQSQP2hzUw/KmvcZhfayiYWJYrWAEN80OCFyVRHGOGhNk9V7N4TM3Aok6lpM3GcJ4FJtcfWFgCS5fPZzVtmPatmQZhmuT5nx3N4y9s6XJVvnWeeYHNomOrggymyTuW8xj25Egv1VdXkv1w0hgAGanyaH8ClGwVA2l+CPhV4AZDGv5qoDSsReb8HYDPvxZUfFL/blu8luCHaTtiuhYeDPjgdz01A0ZI4msTSGzgQrN9VSaPi/z993gCaILFn6hob5iRKzcGdXjHywKBTrOsrvFhZP2L+f3xymPV2kWg8dt6IINBzlg6GHxriWLLM0dMXc1814yIVS4Im6qvkFcd+B4M9Qj+Y1tsfqncJv99KB2r853UtUtm79w2WnNTcdREowURA53UBlrdKdySGJQ9BD3J5Gw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5005.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(39860400002)(366004)(346002)(136003)(376002)(396003)(451199015)(66476007)(66556008)(4326008)(8676002)(8936002)(86362001)(5660300002)(66946007)(41300700001)(36756003)(316002)(2906002)(83380400001)(52116002)(6486002)(478600001)(1076003)(6666004)(2616005)(6506007)(186003)(26005)(6512007)(9686003)(38100700002)(38350700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: B+0bxaVZ9ZDqUy2NcrJiHW5MMG+2jeW5cy5zotvXeyzP3g8Rzu2JGqZEExPS9NdtjxWvOYYH1dnxPlsrse3WCHpesoI8BSebKUCCDzCP6T35VZJYjtSftpZnzj6CKwUFFBoMaGywy1o/z7abUNpksiYc8GL9rDCgA3WEr8R9Wr+lYdimYKK8DrW4GQVr88jFfmivYrTGi7hy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ivPiWGXy0vL03PSChiiMpJTBzJyLKAo2JI84FPwgNwTnlpdkrKLTLWc/FES6awsDx/g3Mv7CqOS9gQmi4o9Lbo4nF9ow7TB8jLKJQxwMoYhxk6c5PznhPztyH4bOqG49Qzqz19KDXN6Z44LPEMlTatMLJiDR5pzicKEjmLJV4eRBDuoaU/Xjcz8g1qMf1DHH85E6lA2AExTHfGHQKuaYCxSwC9W2IYRPOQVtBp5mF4TCKl1wSA5cxng7EMhS4CZMe4VKEylncRKbR1gDz1PcXuMgT2RvjDqvHMYlJkZoJtLeHCmrl4Pi2e1fzMZ505n X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7d7c9863-623e-47f7-451e-08dae8b75f5d X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5005.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Dec 2022 09:39:10.5453 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: bSDAHqAwLLICPIW07YTA+e93zm4DbTMa3E2TXtE6jhmEX2vYYQjEWCRqRDC6VjgV3yfwfLNYA94Xs8qCLrR5JA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8177 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Carlos Song The absence of correct offset leads a failed initialization ODR mode assignment. Select MAX ODR mode as the initialization ODR mode by field mask and FIELD_PREP. Fixes: 84e5ddd5c46e ("iio: imu: Add support for the FXOS8700 IMU") Signed-off-by: Carlos Song --- Changes for V4: - None Changes for V3: - Legal use of FIELD_PREP() and field mask to select initialization ODR mode - Rework commit log --- drivers/iio/imu/fxos8700_core.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/iio/imu/fxos8700_core.c b/drivers/iio/imu/fxos8700_core.c index a1af5d0fde5d..de4ced979226 100644 --- a/drivers/iio/imu/fxos8700_core.c +++ b/drivers/iio/imu/fxos8700_core.c @@ -611,6 +611,7 @@ static const struct iio_info fxos8700_info = { static int fxos8700_chip_init(struct fxos8700_data *data, bool use_spi) { int ret; + int reg; unsigned int val; struct device *dev = regmap_get_device(data->regmap); @@ -663,8 +664,11 @@ static int fxos8700_chip_init(struct fxos8700_data *data, bool use_spi) return ret; /* Max ODR (800Hz individual or 400Hz hybrid), active mode */ - return regmap_write(data->regmap, FXOS8700_CTRL_REG1, - FXOS8700_CTRL_ODR_MAX | FXOS8700_ACTIVE); + ret = regmap_read(data->regmap, FXOS8700_CTRL_REG1, ®); + if (ret) + return ret; + reg = reg | FIELD_PREP(FXOS8700_CTRL_ODR_MSK, FXOS8700_CTRL_ODR_MAX) | FXOS8700_ACTIVE; + return regmap_write(data->regmap, FXOS8700_CTRL_REG1, reg); } static void fxos8700_chip_uninit(void *data) From patchwork Wed Dec 28 09:39:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Song X-Patchwork-Id: 13082803 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 172C3C4708E for ; Wed, 28 Dec 2022 09:39:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232730AbiL1Jji (ORCPT ); Wed, 28 Dec 2022 04:39:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230006AbiL1JjP (ORCPT ); Wed, 28 Dec 2022 04:39:15 -0500 Received: from EUR03-VI1-obe.outbound.protection.outlook.com (mail-vi1eur03on2070.outbound.protection.outlook.com [40.107.103.70]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B4FCF01B for ; Wed, 28 Dec 2022 01:39:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hZj3LD6Tlhx8FKcPGDJLwgrCP/LpjNpwZe50Rvhokyfd9smuT+dJgZAT+//hZijHJ+7wgrJ6yTWm8M2Mx+HIjrTwXqdOxvxDL3pBWYT4m17uMOc6VBcX4qxf/E6sRMyii4v45Ic43xm2zJqC4iOiOCpMD06DZ/OhKjX3Smbqpj7Fwj9rHOk1jE38MYLY0H5fteA7xYz0v3KBNBN7e1zPT6q4DrjAwpBMV95jmv/sGlsBCI6A7Yx0+yVPTDwgndVpoMg+ClNw17+WwOeZ2lgtV+U959ESEUvgNz6EC5W0MqLjPOacT56cc9OzbyyWZOQWm/pRq0j+nk2Hjq4LIaRaeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=zbO6xd0v9tYr1SVUTPR9dRz5iKiq5K6H3ZaqSQWEyY4=; b=ZLVy4FwPOnJCL08xKCvKI7p0PHEKCxrZV0hz5ewDZob2Qlj/DSNviB33Saca/0p2wHQ9I7HONScbRCvah7om+uOnCzBlVGNMbpyX9hui5BGv1x3w4Bo3HD5+OzLZu+rNH5a3OhZ7Fozyb37LNDGrnKC3AbyGycpeYi36LlFW2lj4QWuYp1/uHiKuj9pKM7v1ZcxewtWAYUGaYpNvxiUwkUUIu7AqeQf52uTS743IPj1jMKjfAF2xUWrMRS1u6ZIRDQskIYUoITc2DRRH2eaj+5QJzVDsk8FWMqIYcAFlzUUIUYeJxn5xztM4HCmfyRlYceZKJ5CDYxGsCwKDMgKlCg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zbO6xd0v9tYr1SVUTPR9dRz5iKiq5K6H3ZaqSQWEyY4=; b=QmIrdohwJ3Ndsx6XPMEj9lTlpoYhuBoAPOlq7Sh8WFA1AopQ8ButdCkQID15Zujia8n5YT3yBY7hATHLCsp8fOXlp4oJ4BeFHtOBCyX+1FNJfZbEFc9wGseFuKyW8YniEN5RVUJibVuQg+WX1qITFK5AhxphUBsWQskvj2E8cHU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5005.eurprd04.prod.outlook.com (2603:10a6:803:57::30) by AM9PR04MB8177.eurprd04.prod.outlook.com (2603:10a6:20b:3b7::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.16; Wed, 28 Dec 2022 09:39:13 +0000 Received: from VI1PR04MB5005.eurprd04.prod.outlook.com ([fe80::e2d1:cb8b:dc57:8749]) by VI1PR04MB5005.eurprd04.prod.outlook.com ([fe80::e2d1:cb8b:dc57:8749%3]) with mapi id 15.20.5944.014; Wed, 28 Dec 2022 09:39:13 +0000 From: carlos.song@nxp.com To: jic23@kernel.org, lars@metafoo.de Cc: rjones@gateworks.com, Jonathan.Cameron@huawei.com, haibo.chen@nxp.com, carlos.song@nxp.com, linux-imx@nxp.com, linux-iio@vger.kernel.org Subject: [PATCH v4 3/4] iio: imu: fxos8700: remove definition FXOS8700_CTRL_ODR_MIN Date: Wed, 28 Dec 2022 17:39:40 +0800 Message-Id: <20221228093941.270046-4-carlos.song@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221228093941.270046-1-carlos.song@nxp.com> References: <20221228093941.270046-1-carlos.song@nxp.com> X-ClientProxiedBy: SI2PR01CA0030.apcprd01.prod.exchangelabs.com (2603:1096:4:192::15) To VI1PR04MB5005.eurprd04.prod.outlook.com (2603:10a6:803:57::30) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5005:EE_|AM9PR04MB8177:EE_ X-MS-Office365-Filtering-Correlation-Id: 3e6a4cfd-d784-459c-c6c3-08dae8b7610c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Kc3s3e/aZ/4z4EWOTuHAfJPVwDW0wL+Tmr9wOdYYX3FPhcAZqIM2laQ+icqCfcUxxFFiiO5z6uCC6cNBUmWM1BYRNCgZZ6DP71Q6p+uZlic4rEtaEViiZpPNnSwS4Oh3KfAWzTZfayn/5ELE2iatd4kPVuxAXkSj9m3jvuxc78UgWo3UpQmENeHHiDCxNmShVyVptzoM2YIiekVELmy+L1Sm2zMg+73WwbL70lVW+ISOtuZnynSzBJcO40Frb33VdsnEQIT6SHxqK4qZlN8MiTwbQojVOtnQuziZ+pkVA+FCuc8G9nirNciSZrANk74L0bCYpUeLGDjWooSi5lGT1uTlOwVoIxeZ5HLlpFYa37lTLo1wqkWWYM5c7M6ArtGJjZmITSWwGmAThY4p3YyywvUDh8ljJfRtRVFjcs0f6DidutZQ1vsbTnmlFdIsnYwQEHR+6fYXPA7Lq5awY0hxT5VPwfQSjfC+AIFTO2CwUd3o02pK2PD0LmI/2pC1O9eqcV+dBiPwtLBNZAVwu4N2lSdoqwi2WQ1b5vn+/Rwn7yaRCCqiel3xNVnvFo5phTKP8Qryiw/0XIgSJRFFzzZ2/OLWOtBymNWlUge8UPEyo6PuUTF2NNMvUHUodCcDXHsxiB+wk/3V4KjFLU94sTZbu4jDsml0wytHFUmDR1VhWrk/aXAo7Hogrv8fw4OIwvcjYF9Uo0fuO7uye3GyXE7H2A== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5005.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(39860400002)(366004)(346002)(136003)(376002)(396003)(451199015)(66476007)(66556008)(4326008)(8676002)(8936002)(86362001)(5660300002)(66946007)(41300700001)(36756003)(316002)(2906002)(83380400001)(4744005)(52116002)(6486002)(478600001)(1076003)(6666004)(2616005)(6506007)(186003)(26005)(6512007)(9686003)(38100700002)(38350700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: mNWr1FgLRyY89AevxGBe7CRbabEhL+hH+RTgFsFbjjiJ5f3T9vR5hGyD1SBYQD0evBQml5DOJEF3sRpGPAWyfuXO/1frzcIEO7O36rY7vXAzJfY9V6mJWgv3KcidwiWLWZsoTltmVKLsQ/F6NpepFMfsSzE2td7UidPzRne0NXANlISdRHx4VMzfHW8LfIXxQN1Wf+xykCfpVnKBjH7/Wf6TCELhyGCWeZUeoaACA4PZ3VhbKYyN1VP+y5tkBrcU3cIAr7bfPk/JrZ+9YxHDOjs6rq4rkpUgFQ0HawnULalvpkv0ClwH7oLAq80WuxGBORRIbUXoxdIBNToyri2sSidnXPyyCR7u8WyREiGTWS1aw5seCGvYQMzRfNF8iKUkKIW5QBjhToFPjxuoW7LD/TpaFds+TBRnAayZCOehqfX6AB1OhqNpr+mTi8R2twmE9XWzJlrZ9qtZurxN5EACWt9TpLjw27WvQ8XLbgJ7p+8z1wiQKBjmZ++fy4fvSxrWGkT6IcMIpYXdBmviKN4wAxmU2mw/jRCU8r8nJKbwIJORbrAE6yWj5Wc+OMXb8jWMtyh9XsXb0GcGV88EG5XCCnnGQe905Ua/138OJvzNyCrD41WvlPRjzR1AqvKX4wla+g+g4AggN6LhbIftIgUKau4uG/suzihR0cbplqEkvTq1dBk4iiv3tKQatG5FZoAIUqMlOdV7unoSdGILTow5L9tNjv+srg32PpzJcznYLBggcADUlrcW7FHBaG/opwNBowyU3e+JayCtX+Amj6TnHkHaGLg79raYNCifSBu9u3GHkorZ0MFDjKValg0RLI62jliwlSmfZGNGcbtR7w8PlY7I8bV9gIfMS0bmuWS8dGfVC12OQuzG0sgvO5qMtrjUoXecxoSRnL6Tays1PemRsm0VFj9Jj8tdFb5OWW8QV9/f9hHlezN+qnjguCcr2zMaezHNa0Gx2vo1a7XgEufWUOs6Oa6kO58R2vHaTEkr1g8AYDSu1y89/InMvSYMZ8ASgUB1tkiTxngp/hHw/gvokqCPIBVFbfXTvGkpC6djr9C5iWjZhJ1q7aZrWlkHC8mv57eTwa6C7kZ9ulQyvGmvnAtIi798On/DtmJ/K+iXZYNWzArNZoafr6TRXqxbqaXwpqavCmNEa8o+NVwSz2jjkHY3lCG9fL5d8eFp2LWnAJ0+Mjbx02tz6mlwY6CEPM1jZR52VQIUykL+qE8fK+Kx59Apt21w2nwKuuPoWv5ZEui49QSHwnhTUeNUjl6DGE6Ogt+U4tJeLwVzBfB1dA//TXXq2XeyxDemNV/NMRu5HJ7EUiDz8o9/C8g4pcR1iJeZL5a2uBZWo0ZOf69cP4IWTh4xTa/Fd1z7CdmUOIY5xSvFXIfA9IH6nOR/sVUpqZpGp7/Cqq5iR7w69xR0IjNLsDvog8ew8b10SVVkyy6MmcKr7X5x81g19UbfZCrSq6DuoM+2FnW/zbtGgl50dmUP7fVnwg7janTlJUvvZfB7FojH5SaHiTbhI1kDScAPynbbCgXQz29QAyeVSMZOYHg+0kY25MXMFI/vrSUqA59P9+vciJbmipwD5D4DxWtChwWJ X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3e6a4cfd-d784-459c-c6c3-08dae8b7610c X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5005.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Dec 2022 09:39:13.4514 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: tVxEY32uf9P23dspLs8ElnKVTRouBnUFl5I/qZCRkQA3NFndkMsXwIF/6zD/RJh9ntIvtTbEtV1fMT3Kbk3KiA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8177 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Carlos Song FXOS8700_CTRL_ODR_MIN is not used but value is probably wrong. Remove it for a good readability. Fixes: 84e5ddd5c46e ("iio: imu: Add support for the FXOS8700 IMU") Signed-off-by: Carlos Song --- Changes for V4: - None Changes for V3: - Proposed a separate clean fix --- drivers/iio/imu/fxos8700_core.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/iio/imu/fxos8700_core.c b/drivers/iio/imu/fxos8700_core.c index de4ced979226..7b370bd643a1 100644 --- a/drivers/iio/imu/fxos8700_core.c +++ b/drivers/iio/imu/fxos8700_core.c @@ -146,7 +146,6 @@ /* Bit definitions for FXOS8700_CTRL_REG1 */ #define FXOS8700_CTRL_ODR_MAX 0x00 -#define FXOS8700_CTRL_ODR_MIN GENMASK(4, 3) #define FXOS8700_CTRL_ODR_MSK GENMASK(5, 3) /* Bit definitions for FXOS8700_M_CTRL_REG1 */ From patchwork Wed Dec 28 09:39:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Song X-Patchwork-Id: 13082804 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 02F0DC4332F for ; Wed, 28 Dec 2022 09:39:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232720AbiL1Jjj (ORCPT ); Wed, 28 Dec 2022 04:39:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232674AbiL1JjV (ORCPT ); Wed, 28 Dec 2022 04:39:21 -0500 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on20610.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e1b::610]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1837DEBA for ; Wed, 28 Dec 2022 01:39:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Hp55z3ov/2LbjKXUzf+Dbzkf+JZhJEPwmh+Tf/CQCp1PrZ+pvXufZojGqZyD0QZ0B7fm3VchafJUaznpmdwbnigN8IBUW1RnTGfwWREqiQW+brmlru1K8H0PWN07ojL36GXqXjVWJVrq8WWMyylT9BB8/R7n8KLMK8fS78F9gqUl7FCQJzVdmPeNNuNUJm7CgaY9x+WHI64xcUGV2wrSLlSeJrtFCeOsx8GTdWh+rT01wXlpD6W0HZDaz2EUEzcZs4xOXR+YU4bKWDjZPHIlfYpdfW3rrPtEX2+YBJrFQMNDPGoQMcPlPUDspQNzguEE5ZEbnsapBzjs/efhQm/q2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=x2SvZQE3CxiykwmACqCbvngM30kXemGS6Gv/XpJZ/L8=; b=JyUIzVaXpBFNANu4qmmvMcm+3kAGpaX+PN58Ldiv5nfduduP97KMvctyS8OUJ2p9eN+E3LQfOZWYbTMaGtTHvhYAJxH3DuH5noaFYwcWz71sHbZ2WTG09SfAuyNEQnKfKQoVDedt3yfxC4Shj8yUqxBJ+nX36EScNnlxRpHD1sWhNud6OgSoKr6n6iyaFAZ7Z82kWh7/tLCL5xGYs3KXmDBa/i6JhDpsB7EJ8/TUnQIJMrqeFNVIDAaN6e52Cki432PONO1hirZHCYXtMqNixDUTaHU89AZ7xHZ3QJblhJC301mwrFhPw2Q8Ix10KwpAPJ7N8SX+I0xf920YvL3zZA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=x2SvZQE3CxiykwmACqCbvngM30kXemGS6Gv/XpJZ/L8=; b=IkcL1k9UhHWa73ckcnV1iSf7Q4cvNVDnX5VJiUwzZoLy+cfifb0RGWUY3fX1qZr3TS9LX7qi8fYX7uNlkndKs2rRDz9EckmfK29NYPwTuKd2BYZ7pRAIUo5jeqOd4TkwQhmoOLxzXIyQzlJ4y2WCG4g/Q4QuswOb+P+Wd6tZfx4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5005.eurprd04.prod.outlook.com (2603:10a6:803:57::30) by AM9PR04MB8177.eurprd04.prod.outlook.com (2603:10a6:20b:3b7::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.16; Wed, 28 Dec 2022 09:39:16 +0000 Received: from VI1PR04MB5005.eurprd04.prod.outlook.com ([fe80::e2d1:cb8b:dc57:8749]) by VI1PR04MB5005.eurprd04.prod.outlook.com ([fe80::e2d1:cb8b:dc57:8749%3]) with mapi id 15.20.5944.014; Wed, 28 Dec 2022 09:39:16 +0000 From: carlos.song@nxp.com To: jic23@kernel.org, lars@metafoo.de Cc: rjones@gateworks.com, Jonathan.Cameron@huawei.com, haibo.chen@nxp.com, carlos.song@nxp.com, linux-imx@nxp.com, linux-iio@vger.kernel.org Subject: [PATCH v4 4/4] iio: imu: fxos8700: fix MAGN sensor scale and unit Date: Wed, 28 Dec 2022 17:39:41 +0800 Message-Id: <20221228093941.270046-5-carlos.song@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221228093941.270046-1-carlos.song@nxp.com> References: <20221228093941.270046-1-carlos.song@nxp.com> X-ClientProxiedBy: SI2PR01CA0030.apcprd01.prod.exchangelabs.com (2603:1096:4:192::15) To VI1PR04MB5005.eurprd04.prod.outlook.com (2603:10a6:803:57::30) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5005:EE_|AM9PR04MB8177:EE_ X-MS-Office365-Filtering-Correlation-Id: 5966d244-c40a-47fb-33f1-08dae8b762c8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mp6LtXu7PmFDH8em8eIbjnFzq0ROfCwTU36p9TWzU+VYnAUn/ZsW2uUh+Q/8MWvz7cmhSENzqSnhJfU74pZY70JYHyg1FvbtIf7zBTpqIbPyvu9E2Bl4Jc+WfH1HyIUtjdmFBq9a4ZJFtJJFFaUjzbHlIxYror+FmNZrJ9LDNu2B+JGSBpfX5Z7HhFIgAIGKw9A4gEUK7ie0gX1823MrNtDCBJWcWnVluPUC9kOCZ3lOl42/4LssX3vL0jppSaNuTApeQaG4w+o/Q0bNm1UksMWc6PP9+hJP1nodivYW88tt4aL+4ZgT9jVnVVlfVusjuSgCxPjx35IzQUwT22U4HlY7QaeQFYvRCCPbfU/xe4BTyAJU2VL4fwBKjVM22PkPH5dJNLbYx2fbsieSk6Cr5IhFxqMJOooCuT/QiTNxauCXosZX+mZKF2XWpFzzCAXJEc5owceGu3q1tYMVMcaFxsWTLocjgp1ouixdHm93Ff7KXqeAQ73u20phdWQHQDtK1EB3bkmrravCqmRoY7KI5ofmUHgB0vF+gbemtDFr/o+8x4OY181r+nFYe099wiYbfEyNpVsWxXVvDBFxY9YiXIzbXd8wux/QrAQwcc8bsH6AK+h5ZGecDe84vUAYza5UXw2V1ECtdJaaGnfDPWRjAMoBXkOTcjC24MR3k6A20IFNv8HMX+cPCfPveo622eUJL0VMEPPtRkUDh26HUu52RA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5005.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(39860400002)(366004)(346002)(136003)(376002)(396003)(451199015)(66476007)(66556008)(4326008)(8676002)(8936002)(86362001)(5660300002)(66946007)(41300700001)(36756003)(316002)(2906002)(83380400001)(52116002)(6486002)(478600001)(1076003)(6666004)(2616005)(6506007)(186003)(26005)(6512007)(9686003)(38100700002)(38350700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ePLMeu0oleG+jurDR9mK5gojQfrjKQd0Ih5mBRmVnG+H6gKDESRQEebyYHCkh+3QiWGMyTmao61J3NvTDCpMglHVZYqgVMgbnlTmXI2Q2DAayp2xsUbfOTVD/ug9YrpxXPX4KL3pBkdrF7eq8r1g6CzsIwEdCbp/V5uRm/uqbzoYr8FFuH1VWnYJW3Iy6enyjbBKWs5Gfk4BIQORB7dWimtXxUIf/gxw5azj1VhVC5hkjJfR+/uIUIJUV9IqHec34sqQNFZUWnutBnbf5Toor8MoFLZ2HxafZcABygIwGQlZSVGzN/345u1e3awa/82zzmlHXO4GBcKSGWWM0TLn3Uala3eG550fMmqSRC3uRKIPahYB/bF9EN1p9iOg77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bmk6T+EklEVsalKagTtZwnhH1FWFAhH6n/CqpQqtc44X2FmcIcFeEhyRjITl0Vm5VWZ3w6HggZvk+ACihQJH3Os2dlTl+LxO7gCa1WhGUXGsYWTFqLWx4gEpTGbKrZA1jufsC X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5966d244-c40a-47fb-33f1-08dae8b762c8 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5005.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Dec 2022 09:39:16.2949 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: B7r7CZlDeHo0KVA9/tWT5tfwwxiVFluQFMECmhoxJZmn1q+0O9VmTdn7ue/CqiDytHb2dG0+HPeX9Xlvhq83dQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8177 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Carlos Song +/-1200uT is a MAGN sensor full measurement range. Magnetometer scale is the magnetic sensitivity parameter. It is referenced as 0.1uT according to datasheet and magnetometer channel unit is Gauss in sysfs-bus-iio documentation. Gauss and uTesla unit conversion relationship as follows: 0.1uT = 0.001Gs. Set magnetometer scale and available magnetometer scale as fixed 0.001Gs. Fixes: 84e5ddd5c46e ("iio: imu: Add support for the FXOS8700 IMU") Signed-off-by: Carlos Song --- Changes for V4: - None Changes for V3: - Modify the magnetometer sensitivity unit "g" to standard unit "Gs" - Check and confirm uscale value is correct. The readback of MAGN scale is 0.001 Gs - Rework commit log Changes for V2: - Modify the magnetometer sensitivity unit to be consistent with the documentation as 0.001g - Rework commit log --- drivers/iio/imu/fxos8700_core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/iio/imu/fxos8700_core.c b/drivers/iio/imu/fxos8700_core.c index 7b370bd643a1..8320a3b6f942 100644 --- a/drivers/iio/imu/fxos8700_core.c +++ b/drivers/iio/imu/fxos8700_core.c @@ -351,7 +351,7 @@ static int fxos8700_set_scale(struct fxos8700_data *data, struct device *dev = regmap_get_device(data->regmap); if (t == FXOS8700_MAGN) { - dev_err(dev, "Magnetometer scale is locked at 1200uT\n"); + dev_err(dev, "Magnetometer scale is locked at 0.001Gs\n"); return -EINVAL; } @@ -396,7 +396,7 @@ static int fxos8700_get_scale(struct fxos8700_data *data, static const int scale_num = ARRAY_SIZE(fxos8700_accel_scale); if (t == FXOS8700_MAGN) { - *uscale = 1200; /* Magnetometer is locked at 1200uT */ + *uscale = 1000; /* Magnetometer is locked at 0.001Gs */ return 0; } @@ -587,7 +587,7 @@ static IIO_CONST_ATTR(in_accel_sampling_frequency_available, static IIO_CONST_ATTR(in_magn_sampling_frequency_available, "1.5625 6.25 12.5 50 100 200 400 800"); static IIO_CONST_ATTR(in_accel_scale_available, "0.000244 0.000488 0.000976"); -static IIO_CONST_ATTR(in_magn_scale_available, "0.000001200"); +static IIO_CONST_ATTR(in_magn_scale_available, "0.001000"); static struct attribute *fxos8700_attrs[] = { &iio_const_attr_in_accel_sampling_frequency_available.dev_attr.attr,