Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp1920754rdh; Sat, 25 Nov 2023 07:15:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IETUwIXXfJDLM0My8wRKA128kDh9RJxyDxjC05XsWHS5RXVuxnFKgoYMWKGNA7tZQJmDLO8 X-Received: by 2002:a17:902:f68e:b0:1bd:c7e2:462 with SMTP id l14-20020a170902f68e00b001bdc7e20462mr8624371plg.11.1700925341432; Sat, 25 Nov 2023 07:15:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700925341; cv=none; d=google.com; s=arc-20160816; b=feBqNClHD6Yh+cHQ2rMDh0cwnCftlKNqdokRJSiQMy9cKa7GriYtYh3ZOtJI/0xlCn /mdFdwHKTVTB6SxvNWo13jbs6VwxKgEN1Lw+PCCYAJuGhBX+jvSTGKdO9YMFtuIz/UB4 9TE1zAV9ETrXgmHnimfq98hk6LiqTBK8oG0C17G1P3JQbskeE8Rc+ekAb34xah3+bAwO hF73pVmPQukfR8u7BwUszTUwpSm1jZ0xeChg3P4UAkmHKh0eojLCVozXB3Bf9/CatgBn ZYsmqObRZ6xB/6wlFLpR6kvMs+UCeWmYRTSNdH0NhDTFgcR0YWcUxKfgNEjUMtQD/BWg UHUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=SiZxdfPVQ2WwYyUCfcI5L1OZDspuz1X9t9Q5ZioAlI8=; fh=tgmQcpzivz7ermYuHUQvGO6fdr2zOrCP3RxTTFTMQck=; b=B757cD4AfG/D6MerNrsbuf4kIyNGvY8O+7yxOYsN6AvhYjlZ/KlYH9BpoK5F6pPXG4 drUDzugyaJAtis0ysRX1eMR9c4+0psY7dkSOTDxZquE6JSzQwLw3rCwgPmDzASXCGc5W nl6rUdZkJD2tiKx+6srO21nNhV4wuZBrk6QSJhAvK7JB3rSnBsqnw2X3mD8HRqYPg1wv RPDLmv3tTiw3FaZDOrX3Ks0nnnNZzKLmo9q8xh+jINCQ6/HjZ8kAdg53Gm6In1cXoRnY /B/mohiV4Bsc9SsJowzE2jr+6z9sCM9JuXsQsd2YN+xRKz1OKAkUnIUDSFuQe6e3E9v+ S/9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=L01tF9Jf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id y17-20020a17090322d100b001cfbd271f2esi521005plg.7.2023.11.25.07.15.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Nov 2023 07:15:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=L01tF9Jf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 0C27D807C567; Sat, 25 Nov 2023 07:15:15 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232047AbjKYPOw (ORCPT + 99 others); Sat, 25 Nov 2023 10:14:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229906AbjKYPOv (ORCPT ); Sat, 25 Nov 2023 10:14:51 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09F74FE for ; Sat, 25 Nov 2023 07:14:57 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 663BCC433C7; Sat, 25 Nov 2023 15:14:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700925296; bh=g4MRYZCrwAzR4gcbAiWJD+UTGWXSA2J1PohiCLNeqRQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=L01tF9JfXbr/AXBVcy7UX+7F5ZQi7wKMcDoDw9icfrYuion+xOdd5XFSoQmGnUEwd bGeVQKvJMvI/Fs7dW532kqPBwGTvVhUnZDCs2i4GfTPXJr1Tvhy5vNhKEMPs29enRe r6Vx6StolVibVWQ4Ltq1HMVfcm/0EpPmXIFzzq84zIVmn7glZ4LrJn6SKRgOIZysV2 YCA6e0FFlQOltot57WjUO59KocIqtybXlwyba6nj4/eDGFwoWsnI8h4utvgVbBYB3K k8janE1/fR1viAXR/iffqKc/GrLkY9R1cPtaJAL5V2d/hP9AtlIFfPdBjY//0ugneP v0trWH2z1cTwQ== Date: Sat, 25 Nov 2023 15:14:49 +0000 From: Jonathan Cameron To: Javier Carrasco Cc: Gerald Loacker , Lars-Peter Clausen , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] iio: tmag5273: fix temperature offset Message-ID: <20231125151449.42f2f2ed@jic23-huawei> In-Reply-To: <9879beec-05fc-4fc6-af62-d771e238954e@wolfvision.net> References: <9879beec-05fc-4fc6-af62-d771e238954e@wolfvision.net> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Sat, 25 Nov 2023 07:15:15 -0800 (PST) On Tue, 21 Nov 2023 06:48:39 +0100 Javier Carrasco wrote: > 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 Applied to the fixes-togreg branch of iio.git and marked for stable. Thanks, Jonathan > --- > 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,