Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp171408rdf; Mon, 20 Nov 2023 21:51:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IGWPKm+6pjU/5PeIknyFyXppd0i4c0g/YQFzQE/N0CigwyDaOLtuRbw7Xkf/Xgzk+tISPCU X-Received: by 2002:a05:6830:1e30:b0:6d6:4e53:c81b with SMTP id t16-20020a0568301e3000b006d64e53c81bmr10154964otr.8.1700545868580; Mon, 20 Nov 2023 21:51:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700545868; cv=pass; d=google.com; s=arc-20160816; b=jm8MVxIpfMXot87EN20zFSNYBNaONslklamROeybauDl/KWQzbGXPDcznPCS55Z+Kv SzzhvN9lDnyp7UpC5doYjSeTOL6fRNEipJSsub2UVUUhyVjy2eRvJTJDQ4rAPeUzmjHf e/aVj5xzUl8eK1g1xSfeeYYqU0OFzfpWww/cF5Tjo5acP3GPuS8zACcJofg+8fTyvQ/W h6YaRtpcOsyLdQF91efkr8V+IZP/2AkRkheRD4KUHfIAmFvUH0DGMlZ+JiMF29yufEYa 84ARxVvXEnMPTacRZskWnSWsnhd72mIulOO5zO7NIIc2UfqULqihFnWCjCmqWRCH3bW5 39sQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-language:cc:to:subject:from:user-agent:date:message-id :dkim-signature; bh=mknMSsMOfYtkqgEVeeZDb3t47igeR1HLYf8CRmHwC4c=; fh=lHb194UoI3hE2GdudDE9iL30O/HczIDPD66GffS+/rA=; b=IUI8AEPApvFtRR+uqGW7EN1cur780v67r/3cdluN5+iK30RqoG7djGU6HLvLB4AQ+y xngvRIC/vyxfvD4TlVF78HerJMF5QJzzYAC6i2xFPJ4iJB122k3nqBWjRNhmmVbhvLNt 96e/CbS2DeV1zZD1TptLBD828cWFrwhLm499/vYb5lcRJR0U0Coy194KCJRKaq8rT5a8 NvZif8xeQrM/DdiYBdKBHVwHjho2BZ3yBwfScXTBvjP1wHiZ+2Xv7JA6Rf3AM/KrD87B 2jsUkaq1uD77eP7MQ7MrUFiHd83WG4HQhlW/3vBiexNO7IDg9XRv8+1w9GxU7rPdiloM uAOw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@wolfvision.net header.s=selector2 header.b=o225mk0D; arc=pass (i=1 spf=pass spfdomain=wolfvision.net dkim=pass dkdomain=wolfvision.net dmarc=pass fromdomain=wolfvision.net); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wolfvision.net Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id ca23-20020a056a02069700b005be209ac7fesi10383488pgb.744.2023.11.20.21.51.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 21:51:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@wolfvision.net header.s=selector2 header.b=o225mk0D; arc=pass (i=1 spf=pass spfdomain=wolfvision.net dkim=pass dkdomain=wolfvision.net dmarc=pass fromdomain=wolfvision.net); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wolfvision.net Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 70E6D80A07ED; Mon, 20 Nov 2023 21:48:58 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233365AbjKUFsv (ORCPT + 99 others); Tue, 21 Nov 2023 00:48:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229512AbjKUFst (ORCPT ); Tue, 21 Nov 2023 00:48:49 -0500 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2081.outbound.protection.outlook.com [40.107.20.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C7DAA0; Mon, 20 Nov 2023 21:48:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Kp5XGYF+8dnUnevuiGxQNaPC4IAfWov5oIa0fG8TGHtV7iBC7sPIzLQgfymo2z5/zJhIu+h73ITMnZhU2qVwhvFgtbCs8ukrMUIO9Hraf12cXW0P9QPU3LvqDg0GYG8k/wgJPMuPOk6mI4lIE4hSO5RhNJfTZWcoo0qlhhHTsdWILeQsFw8s+Hugf/DzGMp0g0+XkxitrxSHTh/DQvQHoqT2Sp253FF64DGjcoDN42BM5rMUF+RKUAegn3UTbrMihIDNbNwG/I1fl5osT0XOK0iDgJ81bj0Vpz/IX3T3XXAfQ35SaU0PP+IOCQd2rsBUMcsBBQHl4phS8Dp/VbBNAQ== 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=mknMSsMOfYtkqgEVeeZDb3t47igeR1HLYf8CRmHwC4c=; b=XSvWZMRI6lEl+3x2zdCKwV3oGPcI2jBVcrQJiiLY6dlVK3pPCeE24ECO4mF4aK+q6yLjpxZDXcTxMDzZB2cS0H+h7FETsfpb1vc28Ds8Q/nY7TI0faTWmyHqcVJTBY1jQq3kVfNAlb5P68zbe0GymJZI6JvIQ1+Z7xgYu1c1ObcT1NSboYXjpB/lqTzxA2N7id7dgWyoAHK7vmBoTy6VUw9vWLrAT3reUnfOZws77uAIa+RrXxY4wB6qxEWrBde+cfcy7Z7fXxsg9oAASWyMqlUZg07nxZIDma5O9jxAnkjAhFxR9PdhgH3V905VfWnbUPR6OElrVAPu7roP+ookfg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=wolfvision.net; dmarc=pass action=none header.from=wolfvision.net; dkim=pass header.d=wolfvision.net; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wolfvision.net; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mknMSsMOfYtkqgEVeeZDb3t47igeR1HLYf8CRmHwC4c=; b=o225mk0D3IOSwVuE7Uu9NvHqqJ5fUQzXk9gjVR+ukXG+gIaDlVS5QI1HELqScRWJOEj/zUr5ljFe8PVeHLgm8hBdk4wCiwOc5vJ2nVGRq1/kdnNIsWeUJcUSkfhYGEtukiK32b6O180DkxIEaT1c0LC4GqlNY+73527Uwoznrvw= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=wolfvision.net; Received: from VE1PR08MB4974.eurprd08.prod.outlook.com (2603:10a6:803:111::15) by AM8PR08MB5795.eurprd08.prod.outlook.com (2603:10a6:20b:1df::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.28; Tue, 21 Nov 2023 05:48:41 +0000 Received: from VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::6b40:1e6f:7c94:71dc]) by VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::6b40:1e6f:7c94:71dc%4]) with mapi id 15.20.7002.028; Tue, 21 Nov 2023 05:48:41 +0000 Message-ID: <9879beec-05fc-4fc6-af62-d771e238954e@wolfvision.net> Date: Tue, 21 Nov 2023 06:48:39 +0100 User-Agent: Mozilla Thunderbird From: Javier Carrasco Subject: [PATCH v2] iio: tmag5273: fix temperature offset To: Gerald Loacker , Jonathan Cameron , Lars-Peter Clausen Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Javier Carrasco Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: VI1P189CA0022.EURP189.PROD.OUTLOOK.COM (2603:10a6:802:2a::35) To VE1PR08MB4974.eurprd08.prod.outlook.com (2603:10a6:803:111::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR08MB4974:EE_|AM8PR08MB5795:EE_ X-MS-Office365-Filtering-Correlation-Id: f10d922e-e85e-4793-f97b-08dbea558408 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RWXEEwCKoijGHOyemNBJnTOeO0P9mJj1LSSvorXNEz0/mVy8m8vkfRX2fYZ+aZCle5P8bT242BRYADhCUproOts7RMrQlGByi9kdtHB/e+DYr+SEVi0FqtxCF8bS6POZdsPOulLxJyAJGFz8yb08MvxBFIWJ0X37un7VFgwZaBuKYk/yu1LQN/gpsA3SSXt3jRZCEdfxEKnuEqAjpm45xZIg15dkY3buDGXlSDBhZ7lBkXN20v+q60H1EVp/hmODtxC5VIAcn2VK/23jsPZ/gXDOIZrGeltp0bkrTbLqwmaV3K7pTS8094c0c1QGFY5gw2E1yAwBsOBBcT/EhgkUOcT9IuMdP1DmiEuuY93OWCU19e7lze6frWWl4Gj3Z/ndrJswn7TqvyOES+fBnisHNiJ+KnQSE8WBG7NEBAH52HhQKsNmBqUG3Apum9ihoaBElWJt+ikKS9PgKLtuo5/z11Du0N0s7tdgR1jjp+4m8zC/ExdQn9uRT9+wiAVphzp+rwBwF1wCNdw4Ebf7TRQE0xTUbAedPTqXakHAuuwdPv/X2o2KpCLOaZP4fuRgOYMBvfA2veWPLhAk9DC03E7DRr9tQ+u1kA56WBE90+E8xXRtIDcZAYqUk02KJQMM823uW5pLLgoVq2ZgMgHMa2mzpA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VE1PR08MB4974.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(136003)(396003)(366004)(376002)(39850400004)(346002)(230922051799003)(451199024)(64100799003)(186009)(1800799012)(83380400001)(6512007)(26005)(107886003)(41300700001)(4326008)(8676002)(38100700002)(8936002)(2906002)(44832011)(5660300002)(478600001)(966005)(6486002)(6506007)(110136005)(66476007)(66556008)(66946007)(316002)(36756003)(86362001)(31696002)(31686004)(2616005)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?cjU5TVFwVHF3bjVBSXNPbmhzMGUrYUJKU1RKWFljMEpob1VNaFVsaWNFcFE5?= =?utf-8?B?UXZWWjRyOTU3WDRpakxmMGdRS1NQTWtvSnBWQ3NMSlM1eHNQNDJpYThDYVhw?= =?utf-8?B?N2Z2SXJQRjVVRk53cHNrOFo0QmYyMGZvYVR1UmZGK1h2V0xjSS9KajB3OWY5?= =?utf-8?B?R1l6d1JyMkltdS9CRVgxOVRyZGhmY2NPTW5BbTBRbjZ3N0pNQnlWSEgwODJC?= =?utf-8?B?N1VBaUhCRkFyUnlQQk52dUw1SzJ2RnZhTi9udjBlRklVZndWTys4UUlCa3dX?= =?utf-8?B?OGFCVkx2TnBFRU42SEJ4cTc5L2tXSm5xVEhUdFNmQW1SV3J0TFhVZDZuTGZm?= =?utf-8?B?eWdCNFJPVkpSMnpHWWhYYVl1QXA4ckJQaEo0OC9CS3d5bEJwZWk3NHltT0JJ?= =?utf-8?B?djM2RXhkalNtdzV3ZT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ant-Network-Message-Id: f10d922e-e85e-4793-f97b-08dbea558408 X-MS-Exchange-CrossTenant-AuthSource: VE1PR08MB4974.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2023 05:48:41.3050 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: e94ec9da-9183-471e-83b3-51baa8eb804f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ja+1PqiI8V1K5quIJrHQGH35PmfmJSelSsB8ZlaAiRoBCNzgMpROdfRtKDzKiWk8WCX9MVzNlHPT+l1gFOz9UNOUkjGg5OncTZYeJOPUcKI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR08MB5795 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.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 (agentk.vger.email [0.0.0.0]); Mon, 20 Nov 2023 21:48:58 -0800 (PST) The current offset has the scale already applied to it. The ABI documentation defines the offset parameter as "offset to be added to [Y]_raw prior to scaling by [Y]_scale in order to obtain value in the units as specified in [Y]_raw documentation" The right value is obtained at 0 degrees Celsius by the formula provided in the datasheet: T = Tsens_t0 + (Tadc_t - Tadc_t0) / Tadc_res where: T = 0 degrees Celsius Tsens_t0 (reference temperature) = 25 degrees Celsius Tadc_t0 (16-bit format for Tsens_t0) = 17508 Tadc_res = 60.1 LSB/degree Celsius The resulting offset is 16005.5, which has been truncated to 16005 to provide an integer value with a precision loss smaller than the 1-LSB measurement precision. Fix the offset to apply its value prior to scaling. Signed-off-by: Javier Carrasco --- Changes in v2: - Fixed typo in the offset value (16005 instead of 16605) (Jonathan Cameron) - Link to v1: https://lore.kernel.org/r/20231023-topic-tmag5273x1_temp_offset-v1-1-983dca43292c@wolfvision.net --- drivers/iio/magnetometer/tmag5273.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/magnetometer/tmag5273.c b/drivers/iio/magnetometer/tmag5273.c index c5e5c4ad681e..e8c4ca142d21 100644 --- a/drivers/iio/magnetometer/tmag5273.c +++ b/drivers/iio/magnetometer/tmag5273.c @@ -356,7 +356,7 @@ static int tmag5273_read_raw(struct iio_dev *indio_dev, case IIO_CHAN_INFO_OFFSET: switch (chan->type) { case IIO_TEMP: - *val = -266314; + *val = -16005; return IIO_VAL_INT; default: return -EINVAL; --- base-commit: 05d3ef8bba77c1b5f98d941d8b2d4aeab8118ef1 change-id: 20231023-topic-tmag5273x1_temp_offset-17774cbce961 Best regards, -- Javier Carrasco