Received: by 2002:ab2:68c1:0:b0:1fd:9a81:d0e4 with SMTP id e1csp437162lqp; Sun, 9 Jun 2024 03:06:47 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXNVetE84ZGQWm+EQsbnD2/fpO8l50SHl50I65s/+OupVjx/iU5MZE3TFpfSwat1YfUQ7V2z2ADs0ZogPXW8xi9873PQc8seFepOn+Pbg== X-Google-Smtp-Source: AGHT+IEQCAdt6V20QLdZqkrDdZ8PjHuVPcMSWpkQnOxpXHI59+MLOOrMGZxCpDnDTxQaMWsMZVIY X-Received: by 2002:a05:6e02:1c8b:b0:374:9427:6dd3 with SMTP id e9e14a558f8ab-375803a2d0dmr76020735ab.27.1717927606793; Sun, 09 Jun 2024 03:06:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717927606; cv=pass; d=google.com; s=arc-20160816; b=US4aRn7mO31MXlwNiRqgUyzYAqaT8u0KSTo+GwHdKI6JKIK0YPxyxCC0NsJp/Y44MM 9GwKLDV3rgCCJg/LYR4EvwY7psZs60kZCqg/FkOsunpasp8juk1dl9OOqPMT9S/et+Ni MXowYpvfyswOKhwt65f/MeCL2PdXm5qa2Py3IaVOdMWMJps5gj0mF0F5CpRqzhal1sry bD1eFSg1+BULfv7u2ku54dtdd2MUmKbBYW5Yeu8bZY9J+hKy5bPTvJr1+yUNGjEWHl92 ks9Y6QBBm7FAJvBQBFfQ8ACIFqFEZ9Bz7DwRdK4ZaDbFfs26MCRaaCzJ8V8STGvnp4sZ sAlg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=mMVN9gBBj4op8++vPvOzCjwC2+6tWPC1bqxcP8SBPPQ=; fh=QiPoPdKnxWaD7w8oPan8NUz1Z3neCOeH6w0I6mmEL60=; b=W+xYnCVYwFB5R8usqP3OO3vkJfwDVAx+fnrHFLLBIQbY7PYb4/KeZLbO6gvQVkRcRL cEJAJc4y6PZggoQOoLSSa5YhC+ZRRZMMOYrJ9mZbLVG2wVe8N0Tr1p7GsEllAVpINJXp axUl5m+7HbH/jyS/1fMiemcAUZhrYRI60Ykrb+uDABA1AxyF0OBNW40fqSL1rEDvE28O pDTRq4uQAvlJzRy0RLgJJnl1/EJp6esiZXdrsEFHj1wWuZI8V6efvXAe5P1lKIr24IG2 ubehfwKcDOHdzjoxZsOFr6eXb/0dYSDp4V6Zr8hBzCszCJlfH2wgTYKdrPA2IwENz9Tb e5gA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=p7X6hI+e; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-207313-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207313-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 41be03b00d2f7-6e6c2edd065si2612330a12.33.2024.06.09.03.06.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jun 2024 03:06:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-207313-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=p7X6hI+e; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-207313-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207313-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id BF232B20C6C for ; Sun, 9 Jun 2024 10:06:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 984C52033A; Sun, 9 Jun 2024 10:06:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="p7X6hI+e" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BCB85E57D; Sun, 9 Jun 2024 10:06:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717927586; cv=none; b=uo1lJ8nqcqMqHfL+2mzSpUuSpc12ldxp+Dm3Ilgm/NbNGsQ1/MgK7p9uymYntwid8lZPpERwMfApYt3ifzb16JCK2ICBy/Gz9c9+mGvEMUr9DcVTWZ2jmbLicOc47COJhbLbaOrQSgc+QpL9+DobryUJwTmJc5Tu+T9mZ0iDy+E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717927586; c=relaxed/simple; bh=9L8bzw15Z46JWpcMuG3nSdT2H5VUywWmWmUxC82X2OM=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=C31SCm8Nk88RVABM0lFJVnVNC9vthj1rmpVvGxV2khUpmQr+S+FnXITCbpTWDlpbjG2cs7hnzgDQcHAqXJuYqxVkf8GDKC5vlft+sPku/HGlrG3WTXOZ8NHwAX8pjHSX1tMoVJbSwcmDgL6Te0SHVfooMtZwaro6YeuEpH9X6Fw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=p7X6hI+e; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 29598C2BD10; Sun, 9 Jun 2024 10:06:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717927586; bh=9L8bzw15Z46JWpcMuG3nSdT2H5VUywWmWmUxC82X2OM=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=p7X6hI+efA2wwfAGaBdb/JQXE9B/bKimn7bPUNYkQAZYIgvywBu+hzmYXpGjLNCfR Fqt8rkwtHI3XLrYkFatBQTrixGpazw9ToRUjTfTjPqTyQXtSoCBsk9ThXc7MKijO05 ap0M1prqmXrEQTLLwUmM3GLDgHjISpq1jh03c3+Mslk9XuWLo3ki8/Ytjq95vLrMWR WFDD++ujX6zQ/XmNlU6Dus3suDmozFrdVR2cl+3W/dr1hJTG+Us7+u9BMZ0MWVZRf9 /Ejocf/Mq1bBToF+7teK7g3w5d7x1+lKFsHZAG5CQeT8SJ53oUWQucArmp2K+YMr3o SbX//z1UBaeIw== Date: Sun, 9 Jun 2024 11:05:58 +0100 From: Jonathan Cameron To: Javier Carrasco Cc: Dimitri Fedrau , Li peiyu <579lpy@gmail.com>, Lars-Peter Clausen , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3] iio: humidity: hdc3020: fix hysteresis representation Message-ID: <20240609110558.0fd08074@jic23-huawei> In-Reply-To: <6481f8ab-5082-4952-a29c-075a57239472@gmail.com> References: <20240605192136.38146-1-dima.fedrau@gmail.com> <6481f8ab-5082-4952-a29c-075a57239472@gmail.com> X-Mailer: Claws Mail 4.2.0 (GTK 3.24.42; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Thu, 6 Jun 2024 16:34:39 +0200 Javier Carrasco wrote: > On 05/06/2024 21:21, Dimitri Fedrau wrote: > > According to the ABI docs hysteresis values are represented as offsets to > > threshold values. Current implementation represents hysteresis values as > > absolute values which is wrong. Nevertheless the device stores them as > > absolute values and the datasheet refers to them as clear thresholds. Fix > > the reading and writing of hysteresis values by including thresholds into > > calculations. Hysteresis values that result in threshold clear values > > that are out of limits will be truncated. > > > > To check that the threshold clear values are correct, registers are read > > out using i2ctransfer and the corresponding temperature and relative > > humidity thresholds are calculated using the formulas in the datasheet. > > > > Fixes: 3ad0e7e5f0cb ("iio: humidity: hdc3020: add threshold events support") > > Signed-off-by: Dimitri Fedrau > > --- > > > > Changes in V3: > > - Add missing changes > > - Remove math.h, already included in math64.h > > - Drop range comments > > - Fix typo devide divide > > - Add empty line before return in hdc3020_write_thresh > > - Keep hysteresis value when changing the threshold > > > > --- > > drivers/iio/humidity/hdc3020.c | 325 +++++++++++++++++++++++++-------- > > 1 file changed, 249 insertions(+), 76 deletions(-) > > > > diff --git a/drivers/iio/humidity/hdc3020.c b/drivers/iio/humidity/hdc3020.c > > index cdc4789213ba..cf00999b826d 100644 > > --- a/drivers/iio/humidity/hdc3020.c > > +++ b/drivers/iio/humidity/hdc3020.c > > @@ -19,6 +19,7 @@ > > #include > > #include > > #include > > +#include > > #include > > #include > > #include > > @@ -66,8 +67,10 @@ > > > > #define HDC3020_CRC8_POLYNOMIAL 0x31 > > > > -#define HDC3020_MIN_TEMP -40 > > -#define HDC3020_MAX_TEMP 125 > > +#define HDC3020_MIN_TEMP_MICRO -39872968 > > +#define HDC3020_MAX_TEMP_MICRO 124875639 > > +#define HDC3020_MAX_TEMP_HYST_MICRO 164748607 > > +#define HDC3020_MAX_HUM_MICRO 99220264 > > > > struct hdc3020_data { > > struct i2c_client *client; > > @@ -368,6 +371,105 @@ static int hdc3020_write_raw(struct iio_dev *indio_dev, > > return -EINVAL; > > } > > > > Nit: "thresh" instead of "tresh" (applies to several lines of your patch). I fixed that up whilst applying. > > > +static int hdc3020_tresh_get_temp(u16 thresh) > > +{ > > + int temp; > > + > > + /* > > > Reviewed-by: Javier Carrasco > Applied to the fixes-togreg branch of iio.git and marked for stable. Thanks, Jonathan