Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp390561lqb; Fri, 24 May 2024 01:10:09 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUmQLFfNGrZn5Uls4UIPd+PKm2L+9ldc/F8V9+Cc+SDRRTN2DqkO5uU9OZkpfh4Ttf0kBWbCe3zszzBjIoHdJYcVcAshsfZwghtKPHXDQ== X-Google-Smtp-Source: AGHT+IGH1ev9ocFt0mLRnpRAZ4v9tGcRQFn+zwQgImeXhRFDKG2Vuz9Pzp0dSJhwBOYg9C6Ib6p2 X-Received: by 2002:a17:906:3896:b0:a61:bd80:7ba6 with SMTP id a640c23a62f3a-a62641a56c3mr83998966b.3.1716538208954; Fri, 24 May 2024 01:10:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716538208; cv=pass; d=google.com; s=arc-20160816; b=YgHjNahAJkI0vTUEwNIQCtC0Sqn9bxl3LyfyRowUj/KGm8zeOYxefQN3RYcxSTeq7Z A+SDen0zH5VKqhBAAWv6BlsQUeyanREf1XmtP/MnsFZ8dJrSO+VJDaqrg2IXvwWg9oD7 /5lEw3McD0pThhF/M+rZaD0O6DK8T5T1DLnF9C+DEkJPgVhi9PBAzAw2fNaBB5hsdtt8 rDvbH4cdfnNIuFqSOIJwR49vbeDPEY+GsoPCLwbKMugjhk6gzHbSMWS7+0k/GhmumY4p vUp/9Kzs0nf+StKLHe6AYqCD4XU+xF57s3hy04xWtFyVCk7dJOB9Ejk8loTA+nUOGMLM +0rQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=4yIHQCHYwlijZ4SpXyonBPl2dHneQaT20En64+i282k=; fh=0h0riRD6R+ImMsIbkbUO4xHS06SwqkMPPaI+7bYpZRk=; b=CBeYmecUpmV5iue8w5uZnuF031ZbRS4e6FPUlLeqGxEyQRtR1QmemDD55Iuy98Wz+G UgK/r3+QZl/wPsip4u4GfU232a72V/JAx0J/cNkd8inHCzTYtp0PVANNguoZybYr9b2J xV45JrvjH8TMzaBZv4aPfFV63ld/jqyvueyc3cWOqF/rnLA9TtRW7Rpqe9+xRXIL8aK5 Cdb1jHsbYILF4w2uYhz0Xp1Nhwrw1bAW93dSjInm88FABuu85aZ563IrkFyeVxqvxvc0 q+Mc3oMLcWrpdOGFmB8W4nuhSb4PCVXUWQAGoipOX4kBlCUo34zJtbBrTq6dfszZF4mk trjg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ih6yKeUp; 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-188438-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-188438-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a626cc384f2si52910966b.467.2024.05.24.01.10.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 May 2024 01:10:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-188438-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ih6yKeUp; 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-188438-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-188438-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 887BE1F227A3 for ; Fri, 24 May 2024 08:10:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BD2601292E5; Fri, 24 May 2024 08:09:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ih6yKeUp" Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) (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 3ABAD17578; Fri, 24 May 2024 08:09:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716538194; cv=none; b=oJyqApwQyuIQrorMdnxc4iryETqlvYjpgFZAx+Jcq/l+6AlIC6ZwWk5vWsGEMqmFwrXEpfI71LgFNMsljgiUqyUFIYG8JILCWlqe69sbVrZpT8ojIXXBHPc9OCD2j+4e1MPHYuKfpzYo3Fm5tKoyGb14hJjCmHtdLw3Kp7mmbgU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716538194; c=relaxed/simple; bh=IYoee1FMSOG0vcSBxpfqmaB1YmFYngFTvOE+LzRYYrs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=lUXie78zLjqAwstWhq2g2wPo1Xp0L32AD5TbnLpQMTW8jBrokCwD1F9hFuZK60+v3EU/H/4Ne1LbwwQ8pDnCRZPUGcMqlXy8+zQ0QOWEtGj7gNvi4gTIjnMZqKf5DSDRQ9JzkT5vSyZdC6PV5dLTu4YOjIRcYqfx5nXaB7mUj3M= 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=ih6yKeUp; arc=none smtp.client-ip=209.85.218.47 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-ej1-f47.google.com with SMTP id a640c23a62f3a-a61b70394c0so627730366b.1; Fri, 24 May 2024 01:09:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716538191; x=1717142991; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=4yIHQCHYwlijZ4SpXyonBPl2dHneQaT20En64+i282k=; b=ih6yKeUpPupE+dey+V0DtDmEDYzmZdLlftyuS3m8NWnQmaSLFaJo3QgnUv0By6Anv/ bawpQq0Jvm1qlVmLFLcI2M374WU8z+Vl+erLS1KUbyCxe6EjSBIlsEwU/gFRwu5qSyce HHgrU0ihvWsaYFRX8n46br4MzZU4TsbJ13QkfCtxiWpNtD/OvVBMkIR4VHyGybay62XL g8oFE2s1wc6vNH6IIKHu7NDXR7rXt0wabZf10A+Dhm4/sP8b9N50YtCC2YegOA1wRw0x 8abKkBa5E7zNF5n0bCMhlXphJLc/F/qn+KkNK71p8A/h+CLDyZyff6nz5d8PHWp3s69L hrcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716538191; x=1717142991; h=in-reply-to: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=4yIHQCHYwlijZ4SpXyonBPl2dHneQaT20En64+i282k=; b=lzcqOY6liDaUVodxGzh5PvG5j9Gzo5sMlkw60/gviDzecKMBACSnUWLOuRsRvMoJkm 4u77Poo+tYspqVAWq0XKy0l3qKLVy7RqoCfWPejvECXMivWLwkoxUumkBF1MLCm6Hm5O 5M1H4k38f5P4eth415Lv1a+7lHAca5SG7dka5qd4qT2fXmVWSENGJ5E+yjImLSz0R1uo lXOaxGsbkOdIazlTXa3aO/VisqDMZFD5Gva8/lUyx1m2NIYxaMamXTcnZPx2OhH91G27 aRa7qpKtpVM8VrQgl1huWuuFAHQNbZyF3ufG+5hi5Lo1QrfhUXWzjYP86xOhh6P06QCU Lcjg== X-Forwarded-Encrypted: i=1; AJvYcCV9cV2F77/TOQ1jcuuDH4HBJSJbVrChghv5X3RELoVJOsXch5+U/Owqcqc2rzLe5s7zlq/61NJ78ilPYc27381Vxl4CEjBXEd1X3RJFraSY/6Z7K4qnrXSQjARt2PuVe1eCTyOCqjet X-Gm-Message-State: AOJu0YynA6ZJsdkGaUgszbDRvVAM5wafzPJuIJZmkUumt5WeA+MwQOyK nv3SJAOMK68vPft4mtq0hOjNh2XepzqUiZ35GGXnXior6WRqEYFf X-Received: by 2002:a17:906:605:b0:a5a:8b64:df00 with SMTP id a640c23a62f3a-a62641dfde4mr93034666b.28.1716538191130; Fri, 24 May 2024 01:09:51 -0700 (PDT) Received: from debian ([93.184.186.109]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a626c817b15sm91382266b.40.2024.05.24.01.09.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 May 2024 01:09:50 -0700 (PDT) Date: Fri, 24 May 2024 10:09:48 +0200 From: Dimitri Fedrau To: Javier Carrasco Cc: Li peiyu <579lpy@gmail.com>, Jonathan Cameron , Lars-Peter Clausen , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] iio: humidity: hdc3020: fix hysteresis representation Message-ID: <20240524080948.GA560140@debian> References: <20240523114336.532428-1-dima.fedrau@gmail.com> <20240523142849.GA558466@debian> <17adc0d0-55c1-4608-a4c0-93f9911296f8@gmail.com> 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-Disposition: inline In-Reply-To: <17adc0d0-55c1-4608-a4c0-93f9911296f8@gmail.com> Am Thu, May 23, 2024 at 05:45:34PM +0200 schrieb Javier Carrasco: > On 23/05/2024 16:28, Dimitri Fedrau wrote: > > Am Thu, May 23, 2024 at 04:12:37PM +0200 schrieb Javier Carrasco: > >> Hi Dimitri, a few comments inline. > >> > >> On 23/05/2024 13:43, 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. > >>> > >>> Fixes: 3ad0e7e5f0cb ("iio: humidity: hdc3020: add threshold events support") > >>> Signed-off-by: Dimitri Fedrau > >>> --- > >>> > >>> Since absolute values are used on the device, the hysteresis values are > >>> influenced by setting thresholds. Is this behavior in line with the ABI docs ? > >>> It can be fixed by readjusting the threshold clear value whenever setting > >>> thresholds to have the same hysteresis value as before. See some example below: > >>> > >>> # echo 25 > /sys/bus/iio/devices/iio\:device0/events/in_temp_thresh_rising_value > >>> # cat /sys/bus/iio/devices/iio\:device0/events/in_temp_thresh_rising_value > >>> 24.727626459 > >>> # echo 5 > /sys/bus/iio/devices/iio\:device0/events/in_temp_thresh_rising_hysteresis > >>> # cat /sys/bus/iio/devices/iio\:device0/events/in_temp_thresh_rising_hysteresis > >>> 5.127031357 > >>> # echo 35 > /sys/bus/iio/devices/iio\:device0/events/in_temp_thresh_rising_value > >>> # cat /sys/bus/iio/devices/iio\:device0/events/in_temp_thresh_rising_hysteresis > >>> 15.381094071 > >>> > > > Hi Javier, > > > > thanks for reviewing so quickly. Do you think I should correct the clear > > threshold values once I changed the threshold. I have an example > > provided where I set the threshold and hysteresis. After setting the > > threshold again the hysteresis value also changes. > > > > Dimitri > > I am not sure if I got that right. Did the rising hysteresis change its > value automatically from ~5 to ~15 by just adding 10 to the threshold? > If we are treating the hysteresis as an offset, then it should not > change its value i.e. it should keep the configured value. > > Best regards, > Javier Carrasco You got it right and I also think that the hysteresis value should keep the configured value. The doc states that the hysteresis is represented as offset to the threshold, but I didn't find anything related to the changing hysteresis value. Propably because most devices implement the hysteresis value as offset !? Would change this behavior in the next version of the patch if Jonathan agrees. Thanks again for taking time to review. Dimitri