From patchwork Tue Nov 21 05:48:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 167503 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2b07:b0:403:3b70:6f57 with SMTP id io7csp417276vqb; Mon, 20 Nov 2023 21:51:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IFUOJUOx5yIdsulWsitt5KLTvneYWc7fX2saDm89VGiYusaMT9VOYuYMQwQSycqPiD+txQ6 X-Received: by 2002:a25:d192:0:b0:da0:c581:6663 with SMTP id i140-20020a25d192000000b00da0c5816663mr9798440ybg.28.1700545867979; Mon, 20 Nov 2023 21:51:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700545867; cv=pass; d=google.com; s=arc-20160816; b=o+mjnKknGFUBhdv/JEHcQZiBidpFMi84Ykwj/41TAf15gvShyE3VTIvTO08V9DFaoI Rc9RO+Q5kZaedjcRV80hKBkMgISrtaoHhvfI1DGrKn4YWzVusY5zzGrmA6Ibx4Kzjico 0SXoTQFC/ZVKMDJYawPV5NbeWoRs1omf+2IlP4eRCUu8kz2vabrtZJaaVUgL+Q/svkqA 85G5jSnWum/2fR2W280dJRx0+D4+6bZI1MXjpvHwXp5KWOJ3mbzrcNz4FfvztYeuYWaX 1/ey4wSUg0AZo7WVl6II09nAGv9TeBF5uaVSqKwj8eWI2c7CWTi9BpWrgGHNW91VM0ig 3GDg== 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 Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id h5-20020a636c05000000b005b88c8a25e4si9750214pgc.491.2023.11.20.21.51.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 21:51:07 -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 98D2580A07F6; Mon, 20 Nov 2023 21:48:50 -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 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?q?r59MQpTqwn5AIsOnhs0e+aBJSTJX?= =?utf-8?q?Yc0JhoUMhUlicEpQ9QvVZ4r957X4ijLf0gQKSPMkoJpVCsLJS5xsP42ia8CaXp7fv?= =?utf-8?q?IrPF5UFNwpsk8Z4Bf20foaTuRfF+XvWLcI/Jj0w9f9GYzwRr2Imu/BEX19Trdhfcc?= =?utf-8?q?OMnAm0Qn6w7JMByVHH082B7UAiHBFArRyPBNvuL5K2vFvaN/nv0eFIUfwVO+8QIBk?= =?utf-8?q?wW8aBVLvNpEEN6HBxq79/kWJnqTHTtSfAmRWrtLXUd6nLffygB4ROVJR2zGYhXaYu?= =?utf-8?q?Ap8rBPhJ48/BKwylBpei74ymOBIv36ExdjSmw5we7++tpDdf1NhUoU4L7AAaFwr5T?= =?utf-8?q?OOf2oRoS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?utf-8?q?ALc7uK0HGU2Ip2DbuJ36lCCxELypGCdgFQa2K/v3KfoKNE/GIg98Gycj6nvPP9iLa?= =?utf-8?q?DZjLwWhVa/6B/fqpTkxjFaQavEKKzJCuFaldhPY57qgJWr+7qtUW5fIFMM0/K4+/r?= =?utf-8?q?XlPdMGoQAu830+GUuYSi1bOQMOrIF6dV8OvhP9t81QUZiUTVpgFHFyVtGJxM+NNkb?= =?utf-8?q?iREZ7wuNUXD2q0Pe8Wu8ksjtZfBEbI0Hx9R5BC6cD0BDHSoZM82Bdw0rvCjG9ja8s?= =?utf-8?q?kq013CPDRNsc8AIG9FTLE/3gGaTn9BtRhiPZw4DBOCBCr9/CrIrvtPr7hydLO0rIu?= =?utf-8?q?Sf3UA+AZ/y03fmU4TGcMfuZOPIh+Is4G9rA2xZoTOgupRI1QSntc7TU=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-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:50 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783151583990662625 X-GMAIL-MSGID: 1783151583990662625 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(-) --- 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..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;