From patchwork Mon Oct 23 09:50:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 156795 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp1180634vqx; Mon, 23 Oct 2023 02:51:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHgskK/N9N3+udRY0gpXDai39QFJ8oA/6MzXprXW9cYu3szRreQwE6vx3/6oX7/Q3T0h03D X-Received: by 2002:a05:6a00:1ad1:b0:68a:4261:ab7f with SMTP id f17-20020a056a001ad100b0068a4261ab7fmr7439872pfv.31.1698054676202; Mon, 23 Oct 2023 02:51:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1698054676; cv=pass; d=google.com; s=arc-20160816; b=wG5PhjFmryq8Hwx1Zj7p+x6ScSVx1NdLWD4Gt04SZx8QCAa/GRk+3r9wtOJWhKB2BG p/1gcwV7Ab0X22yF3MIg6RVuRGJirZK5xW6uQ7EgroEJcuTKok6RyI5RQ63wpCLeum4Z 1XBgkUeb9wcWX+3Gffprt3qnkltwAiqoTgKO61sWxuAErpu1/ussgty4n/4gDTSDtUcz fjjrw3QgsHZK3RgRXYYAyqHLNH2bHjMSwIwGTaNYR+9SEGYF6vK/E/VoMK1E+OE9viRO lP7bQQ5YTbJwH+ldwIF/zZB+ZrUgZ5eXjTTyaRq6pYk/3CP21hEuBe0D4IKmEsg0NzI3 3afw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:cc:to:message-id :content-transfer-encoding:subject:date:from:dkim-signature; bh=HsZWgVGxEw1SijQBMicQOvHLlV1xVTWpvaiizw4Ea20=; fh=lHb194UoI3hE2GdudDE9iL30O/HczIDPD66GffS+/rA=; b=Dyz9dvIwbxoXEopYs9K68fin5VIExfAP55n0aB+2zpoAG30UiC4iBpzWyGaXjibsAU uDM7FJxIan+O1m27+xXbqdcDKYCXHt0mg1+NutasG1kUODnSVuZJlnis7sbC+T5IddbK mZU8grtHNpQg9CkDmrkETFll/OPI1avXMrXhUOnNEnQlSz7GbNV5kpkjO2F/l0wEVDzB Dtu5fpFvF/TKWpJk9UK0aUXwKfiM3yJuIPx4p9zp/3gWx/Q2WkeDuoRKUzyN5FZ6ryEc YyB/IcVJFXdjL3E0fkGnCWh963gZqqMZacrBTcBgDwWO7IcZpZRmonwM4S2C1ry+Rcqd 2vTQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@wolfvision.net header.s=selector2 header.b=kQH6LIQA; 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 23.128.96.31 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 morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id q8-20020a056a00150800b006be25c80c8fsi6475748pfu.267.2023.10.23.02.51.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 02:51:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@wolfvision.net header.s=selector2 header.b=kQH6LIQA; 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 23.128.96.31 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 morse.vger.email (Postfix) with ESMTP id 665068095DED; Mon, 23 Oct 2023 02:50:39 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230438AbjJWJuU (ORCPT + 27 others); Mon, 23 Oct 2023 05:50:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229825AbjJWJuT (ORCPT ); Mon, 23 Oct 2023 05:50:19 -0400 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2071.outbound.protection.outlook.com [40.107.105.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16FBFDF; Mon, 23 Oct 2023 02:50:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cClyaICvAudeFC/Ov3cPcyKsPRcy5/O+Kf1hHr16Q59QjZg3KxGcfXcdqloh+YdJs7InJc/euBibegIHjwIzBS8CgNc60NzeyiLEbKN+eZXGCb1Fj9OJFLQ29xPHqaSta3VlQ5XnmLd5aXg/qo7Z7oFSMX+UIzE8b3SM4ftJuqcs7/tDdkNjHVGYU6caIhpFZlCsH0kUTen+bX5q5QlqbGUWkVVuutn3Mf7auOQLjBcn8T2KQy97JQjb3vESt2Ck9SobiunYTcQzAM8IBvU7sing7ZXvParr3HWydh9mm13W/vtWEfnmDOILMlcJNAJjssksIImu8cq6Vj/qGFmjUA== 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=HsZWgVGxEw1SijQBMicQOvHLlV1xVTWpvaiizw4Ea20=; b=a0f+a5WgGmTCpBVGknzZSHpc/+0L4/l97p08RtphdwXD79p6FnAqJexZGcPZcqrMSdmMKDTAa/EjFPVOPPcOOGNmnH+EeWqBEbeSyYSpdoD7qVQwK8UkCPnk0IYyoSnpD5EocgcJCQ7qZnkTns7B8KYpVuhgb9p7t0BAVaedDyL9BBaty/3h+7B3JUWYYC0Uc2vYUfdGl6G8f3cGcRF1Nl1HS4hGQaVnyaY+mP+4T99lelnGJRl4bCCp2M1URAZaUlUUo6N9lbzz5+qIAtR9JprX7YixiT/I13AfBZhKabMQx9PoAMVc0Go9D+YFn/G48TcsHd5rLH+UiAqYbl+8aw== 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=HsZWgVGxEw1SijQBMicQOvHLlV1xVTWpvaiizw4Ea20=; b=kQH6LIQAnUoZfM8lL5GTlv6GgnEvnBvadsYdbh5oMeD5M050wa2U1VljxaWVnM9OzBwLGriEz2X1v6R0wK9qZ1PmUuyJkPfbZyrEWItqlF1ZQV8pLzBCz5Gnpzu+aEX/ptFnNL5GqvI8onuRcMjp3HhgKhG8sSrqZcoOi/c5Syg= 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 DBAPR08MB5590.eurprd08.prod.outlook.com (2603:10a6:10:1aa::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.33; Mon, 23 Oct 2023 09:50:13 +0000 Received: from VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::26e:c3c9:b87f:6372]) by VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::26e:c3c9:b87f:6372%4]) with mapi id 15.20.6907.025; Mon, 23 Oct 2023 09:50:13 +0000 From: Javier Carrasco Date: Mon, 23 Oct 2023 11:50:02 +0200 Subject: [PATCH] iio: tmag5273: fix temperature offset Message-Id: <20231023-topic-tmag5273x1_temp_offset-v1-1-983dca43292c@wolfvision.net> X-B4-Tracking: v=1; b=H4sIAMlBNmUC/x2NywrCMBBFf6XM2oBJ1aC/IqVM4qSdRR5kghRK/ 93UxV0cLpyzg1BlEngNO1T6snBOHfRlAL9iWkjxpzOYqxl1n2q5sFct4nI3dtz03CiWOYcg1JS 21t688/R8aOgKh0LKVUx+PSUxojSq51MqBd7+4fd0HD9KtmNriAAAAA== To: Gerald Loacker , Jonathan Cameron , Lars-Peter Clausen Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Javier Carrasco X-Mailer: b4 0.12.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1698054613; l=1645; i=javier.carrasco@wolfvision.net; s=20230509; h=from:subject:message-id; bh=NnHBG4GI1UfRI61xmOhQRV8cRNuKEWfcPQKhuf0xA3M=; b=53zaDEDu6QDz2VHmjHb2kabd3uO5MkIXxxNkJIAsRraP503o8TGHSggxH+hbM31/0YzPwAXPE PNUibpSl1jFDe0SDukNMHSo6lQ+kLTL/jMTcUpqCuJZFVLwj5M5KiyP X-Developer-Key: i=javier.carrasco@wolfvision.net; a=ed25519; pk=tIGJV7M+tCizagNijF0eGMBGcOsPD+0cWGfKjl4h6K8= X-ClientProxiedBy: VI1PR09CA0121.eurprd09.prod.outlook.com (2603:10a6:803:78::44) To VE1PR08MB4974.eurprd08.prod.outlook.com (2603:10a6:803:111::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR08MB4974:EE_|DBAPR08MB5590:EE_ X-MS-Office365-Filtering-Correlation-Id: f261093b-4d8f-4615-a93d-08dbd3ad7418 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: asWG+IT0ptxHlVDm3iTBEVdBrzvCbFR4rDNaT47aie9R5Jt9HxZvYu68SeT1zND/FXKRzqCLKob0EbYzGQHkWdG8EgGcuwwGvruGVYXkIyhmMelF3aDuF83F2A27qLVkO2iWR+R8YALNGeWM+Kv6Jr7xJKh0hW4CWAUD88pFY3Fo86FuGGjWaC4xsIubykW7v3wbDmH5y1gg+HQ0/xl5tlspzeyb1HIyk+bpVSxfYOzVzpKp18eVaS5l70jiOE9M6XE9H7Eofg72rrQZ2rnWtCC/Vl5luaUorgRyG7LtgfWgb0CdHPVqWAAJVJVC/Yqv2yORzN1nP4DYaEJo3sKVCG5rxTNefhzR3amEGHrEuhNNM8pSeVOl8jTNqKWy4a5ucpb9nlkOqYctLwyP9WuAMU5SyurIEOF7GDHsIUd9UcyXEvzGFe9DVDzid9JbCN3+RoA4/H3iNLoYpsCZZS8fTAXO56cOr7rsLOsCqn3akJmk5N/CYDeO9+IHjuzuHySo5lH9bfNlzTBCsjMtBqcj2+7sIB9KPfwvDNX171i2BQV5BijaD45F6UnfU2/jSJd5KddyXON4JxmFBujPB17A8ECjP9iDllDh+rWRSk3jXVDkd5/0SMVHG/7lV9T+nY7E 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)(376002)(366004)(346002)(136003)(39830400003)(396003)(230922051799003)(451199024)(64100799003)(186009)(1800799009)(6666004)(110136005)(86362001)(66476007)(66946007)(66556008)(41300700001)(5660300002)(6506007)(316002)(6512007)(478600001)(6486002)(44832011)(8936002)(4326008)(36756003)(8676002)(2906002)(38100700002)(26005)(2616005)(107886003)(52116002)(83380400001)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-Mess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?utf-8?q?Prb7Agh4spTqacl49efYOs585qvnAxJwGWELIbI/aCO/2e3lYEjcMctJc2bo/eIJh?= =?utf-8?q?Hvyr0s7QKkyyWUBH9N92AfZSgoLmfOEHF5ii5UKMwLiZ2JYgjNidDGL6pc3CouOFN?= =?utf-8?q?A/vmloMXIPVu35YkOY+1MGcJXoXJEBhN5QI2MVcf7cGbDSQXbnuUMHDMcG2I1ce5f?= =?utf-8?q?RaroQzzS9mr9BH+SOCDWPQRljx6MsEGtUsa2HsqxNWXBVZIrqUAbgb2aMxt2op6/3?= =?utf-8?q?mEgdyrj9Sk1I5r7A6ecV5IS7Cw1r2EDSSXzgwSIFzwww/CNg4PvuGZxi7OeSak+5n?= =?utf-8?q?6FbmVEKV4qMyAoruV2uSX8UlwaJGfn5e+VMlDIkEfEcj6yuyyYIq8XijYOA8YSbH9?= =?utf-8?q?6ZTUGZ6f1mgB2oGitw//MO49RYVQjCGkyV9Iiyx5oDU3wMmxnaoCJ5Hfk+/tTq7P6?= =?utf-8?q?ylaWRSEoQc+F35L5gHGVuLS4p+WLgZrTYUglw6HJj9v83nWLgO1XiaKH5C4iGHil1?= =?utf-8?q?u5JTDdGv9VLrUBtqCfLh7yTFzi5zKQdRlsg9eauBnkJFf3F79/sx0g6SDZI73nKZ+?= =?utf-8?q?YWnF2oHrHM3Zt2A5Jl2CyFgi12Bu+6CbtWRsCk3zEi/hBRjMXSVH20FXYNmzxsklB?= =?utf-8?q?wr6GknoTT5jb1mijcgoNW1bVC39w4fi76A/v3LOt4YJoDXU1JlhPOrGVXB5DmgDrz?= =?utf-8?q?wGRFgGQGw9rnTZLJtV6AJSCcerCcmF34yWinNjZsHYAStvxI7UK28ZQ=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: f261093b-4d8f-4615-a93d-08dbd3ad7418 X-MS-Exchange-CrossTenant-AuthSource: VE1PR08MB4974.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Oct 2023 09:50:13.4925 (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: CyH8+krpdFX5W7PXWYLJeOE4RFOn3yHX7qweA63GmnpKBCaBj8vx6wfgL6As5Gh+li2ToxgL1rQruMiYHtm7/vrS5zc4XSdjXbnhByWJYKI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR08MB5590 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,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 morse.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 (morse.vger.email [0.0.0.0]); Mon, 23 Oct 2023 02:50:40 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780539380131876624 X-GMAIL-MSGID: 1780539380131876624 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 16605.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 --- drivers/iio/magnetometer/tmag5273.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- base-commit: 05d3ef8bba77c1b5f98d941d8b2d4aeab8118ef1 change-id: 20231023-topic-tmag5273x1_temp_offset-17774cbce961 Best regards, diff --git a/drivers/iio/magnetometer/tmag5273.c b/drivers/iio/magnetometer/tmag5273.c index c5e5c4ad681e..d22ca39007b6 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 = -16605; return IIO_VAL_INT; default: return -EINVAL;