Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp1451539rdb; Sat, 3 Feb 2024 06:54:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IGLZotmvLEMp8DFYQu8AQCfv6JSEcWEQqoiLOLuWR08+SbuJG1v4RLHiOB5LEFB4lHJJ4FB X-Received: by 2002:a0c:f3c8:0:b0:686:7256:c9f4 with SMTP id f8-20020a0cf3c8000000b006867256c9f4mr1406707qvm.9.1706972056196; Sat, 03 Feb 2024 06:54:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706972056; cv=pass; d=google.com; s=arc-20160816; b=tvh0ZZDCUeuSi9d5UXKbH8qWlSDHCZCX7sEnGbH5Bg0X+ghA0QPdP6L2ZerlPiV6Sp Lu5j5IELo5ZT4hEaIiKRknmgcC6vF0HFMyBOCcEfwL7RpqekTAhrCpTQ6P0I7UhV4YoN 5B4y+20eSAzdH1lOTO3AG3KZLsg3M77X2GARgj7usyaWKea90EqxRDFcfOnTqGtzRNue zPRIR+7OJVo4OaKJa+Hqs1R1ksEKicBp65i8EVTRdYCOGr81472VS77LUuZHCo0uywqL 0uIJJe8CYStaSi3D6RWI9YeD2r6RU/bgNx3zQnfoF/V93me1DiwYQvlVtweLLm4EASC/ /kAw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=/ePAtovw+k3zbA+OWhit8yy/P/cL4JvFGKoi/21GByA=; fh=AmDvtq09KZR811gpid31h9LY7cQF/5QSX4uh4DJ3e80=; b=vqgIARSepz3pLDeU02uIEFHiihphBesJBCUhpsYTyQot68PqhrNUX1MOC17KA1dk+4 njEmrW3/aEXlYON0jLqKM37iec66PAaplItyhRzyFNkMqWwtbcRf1oSoGrLWLGuvVV6L 4OlOAZ+CyI+DVtsV26DVYsPhb0DRzcbiktmR1MBfHwZSvXwp949P0RdiC9LFWSt1b/Uc 5FwJFomZ+ESAAkiJ1wa0XDg3CviAZrRBOL+5oEqVuc4Acqy9sheJdGRYSPgHmV2nBCtR igAJzkxwClaxqJL08c/ZCpyEG2tFjGBR1hSmPc4R1me6719iqf9BU1C78OuHlC/j0Rhu IWaA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=UE9kFe4Z; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-51126-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51126-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=1; AJvYcCX4pPdpBz9S4VkMNFZCoLjnlQo1YoAIT9B1PjjBXjZRCM6P8qKU2Gg308+6pn2TC1jKgXyF+ZmtPctSjaVDZkCTlhTRj2sIcwjZp+X2nw== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id c10-20020a0ce64a000000b006816d954535si4383585qvn.424.2024.02.03.06.54.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Feb 2024 06:54:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-51126-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=UE9kFe4Z; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-51126-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51126-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id A11151C216B7 for ; Sat, 3 Feb 2024 14:54:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6C1895EE9B; Sat, 3 Feb 2024 14:54:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UE9kFe4Z" Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 107DB5EE75; Sat, 3 Feb 2024 14:54:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706972047; cv=none; b=TFHFEaoxrfH61xBUT3p7MiEj4W9Zz8PzNrYE00DHNSzurd7N0h8pkIMVQQgRA8b4PH7PFoWnRSdmmfgqM6OEMQgFIrP4Hw6rspTXE0W8U06HUM2v7/PAu5KDbJj9sNKvwiICvD68NxeHvL/PVuohvZQSUMutwf28nCpatv+xe7c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706972047; c=relaxed/simple; bh=Zcd+iH5Y0Ii9p4R4z+n/nvtDelVSfGxKcxHReLO5oTE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=HzVbHHtHGnYta9fYypVh7gp7vfyXaLvm6jXAkyV/QgA/poDJsax4nyjvSnXEqpEJ6VufhkC6I2YRhB2gJZbXWCr8qXn72S+6Ba6f4X5yFAj8ookz4UdyZg5ZJ5RqiekLGOSp1B93tKYCVnHPiQVryJRDqKEEfiT4IJHuyxWJGNU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=UE9kFe4Z; arc=none smtp.client-ip=209.85.128.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-40fc6578423so14208685e9.0; Sat, 03 Feb 2024 06:54:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706972044; x=1707576844; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=/ePAtovw+k3zbA+OWhit8yy/P/cL4JvFGKoi/21GByA=; b=UE9kFe4ZQhxUrRRZUPUvb8qSEjuZMBCvtxQn4XxgHf5BW9VSiwFUzpKj5+4FJS9AmM 3Rp1P0CN7/dpEpnm3Seewn0pgV3JsFhS5eXAI74VM5xS6p6TvSbOrf4TpxU0pxz9ZJ+1 LxHc4ky7UlnDkw1ewLTOQ76TaZI3FtZRTR9IUA62KLK69HOXJlyAx0/TqMVyDdBx0mZT WFbAb810HTFOtFuMuAMITDweoxxdS/TJeDsb+IIdo/OAwnWoEcdrNmDai7npT5Ki/Gdp 6oMxQPxg4lfI2ewDA2eYo0/z6qusoRKknKuUlBJDICH3FNf+6asLatvXfRtM61aScO/4 CgJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706972044; x=1707576844; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=/ePAtovw+k3zbA+OWhit8yy/P/cL4JvFGKoi/21GByA=; b=pyQvKVVOUObpp6FeA3bod0/70jakQyykMxUg/Z7XLk+A/v8dGJ4Ll6/KbD+cV2bIGT yxVfq4f8vE1K9Kvxkedy6hT9mjml/LCa0ZMLWBwAD3q0yAWc9QBdAfI6HmvbY5AbNxio CistGvYh9XBsGidgz05D8QY+L9hlPpSo5hVa+c2SpgDPTEADBvemdUtlZpdJM/iNHFd3 6NlKBhLs82ex19MU7WzwFvqIvYuQbhKlVlVY/f0N/TbAIN7hq/XFo7Ur36tzbetOQu1j x8RekUbKCOqyCuvLFbMwOViaqNcPZeWatfOHV2tIVALtV1EV5Pf6Nku/XOaf+O7OOQn2 4Wsg== X-Gm-Message-State: AOJu0YyFCW1OffROWYNDtZHVuHwhZCT1rKtQ24wCbzOHXX8ko3nXQtcY 2ir1TPepxbK9kCWbj9/5gRhUhaJYYhBM1A5UbQTqlF44oqkPYaOMm70tX9gm X-Received: by 2002:adf:eccf:0:b0:33b:295f:4e6 with SMTP id s15-20020adfeccf000000b0033b295f04e6mr1863399wro.55.1706972044033; Sat, 03 Feb 2024 06:54:04 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCUcBQHNzSNfwu0bq76K4EN4l5Pbu/RUYCFqvKYawM2sLGcGAerRm3q9ft8bZu2sROSM/oAbYQ5uQta9u3YJhvMmrSUCfxl85kZ22cvsKixXKFm4AwA+HLzBUmkYOX8+DCmDQZ4mANeomq56CxK3e1/NJ9w+HZukz4FQ8/tpNeRLsbEpvs1fhi2LG6nL5iaeVtScoPUprPD+HIVPHJQ= Received: from debian ([93.184.186.109]) by smtp.gmail.com with ESMTPSA id fg5-20020a056402548500b0055fec2accffsm1680644edb.45.2024.02.03.06.54.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Feb 2024 06:54:03 -0800 (PST) Date: Sat, 3 Feb 2024 15:54:01 +0100 From: Dimitri Fedrau To: Javier Carrasco Cc: Christophe JAILLET , 579lpy@gmail.com, jic23@kernel.org, lars@metafoo.de, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] iio: humidity: hdc3020: add threshold events support Message-ID: <20240203145401.GC3727@debian> References: <20240203090530.53374-1-dima.fedrau@gmail.com> <236dc9db-8525-413e-a77b-54df198c86f5@wanadoo.fr> 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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Am Sat, Feb 03, 2024 at 11:06:02AM +0100 schrieb Javier Carrasco: > On 03.02.24 10:58, Christophe JAILLET wrote: > > Le 03/02/2024 à 10:05, Dimitri Fedrau a écrit : > >> [...] > >> drivers/iio/humidity/hdc3020.c | 339 +++++++++++++++++++++++++++++++++ > >> 1 file changed, 339 insertions(+) > > ... > > >> + guard(mutex)(&data->lock); > >> + switch (chan->type) { > >> + case IIO_TEMP: > >> + /* > >> + * Store truncated temperature threshold into 9 LSBs while > >> + * keeping the old humidity threshold in the 7 MSBs. > >> + */ > >> + val = (((val + 45) * 65535 / 175) >> HDC3020_THRESH_TEMP_SHIFT); > > > > Why 175? > > If the span is -40/+120, I guess it should be 160 and if it is -45/+120, > > 165. No? > > > > Maybe something like: > > #define MIN_TEMP -45 (or -40) > > #define MAX_TEMP 120 > > in order to avoid hard coded constant? > > > > the 45 and 175 values come from the conversion formula provided in the > datasheet (page 13), even though the sensor range is from –40°C to 125°C. > Will add following constants: #define MIN_TEMP -40 #define MAX_TEMP 125 It's the supported temperature range by the chip as Javier already explained. Thanks for finding this. > >> [...] Best regards, Dimitri