Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp2821217lqo; Mon, 20 May 2024 19:34:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUxH0bGPKYZFRvl0Yhtr/50Zkz28JvMxtKweCzDbiY915Hn0fzbQ/oanHRkdMmtvTBVnA4mxB4gasyHAMq0Jofu/jGIzkF/j8VpbnsuAQ== X-Google-Smtp-Source: AGHT+IHvzWDCgBiN2IlHm0WSUtA5KPhzf7Bqn/9ctkH7CcNcJ9mz+ubvTNsayBJa0+KTulwECFwe X-Received: by 2002:a05:622a:148a:b0:43a:dc29:a219 with SMTP id d75a77b69052e-43dfda8e639mr374844801cf.2.1716258845953; Mon, 20 May 2024 19:34:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716258845; cv=pass; d=google.com; s=arc-20160816; b=SoRBUFLDN7lBizDIHj7cSPP0gP09D9MTij4BT0puxJY9ki7T3EUlJmZ7xYlkDFBbRg a31lpSGdFlFvkg9jsEzaRUHkDVsyakgkQETOo0hjO5WTl6uT66OhQ19263WIklFpiwCx aJFhX+YKKQdhYC/3Gx9avSFAXVH73yZgk1093E2BEvznEoscE2a1UohZl9sxguv3c27R ifxv5u7C/iu5JBo//Tdraw/viNxpVOFKbSJ29qDo7De6E6++NGfmdRzGbIjoOkbnBgdH 5kjAtTJUvDSLUzEFy8f+zMeA/dfGfse3w+CRJVLviA4o6DRoJ22MtBdVaShUWm9salzF sYYA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=iWaHaAPhmhUih0P5E+3/squCGgKZImlbCGWTxIoVtmU=; fh=Ey8r8RCdPJo2NzYveJs/jds5qpp9xjruxfbHq82FGqA=; b=dlGC5f3AQKo1MPKg4kUVSx6mL/UHxzfNDNNIBJWFFy+CCJnHeXIdHs6ctnLrxCUZgQ /qbTlhBDuf116kYoQZEbGjrrtNsxZO0czYn4KLlRIyt5mB/VcTLtMz50yiECWTnPjiLx O/WG/aDmFGyoNJ0z4ZZVkvPXAF3YKzgECoIauXggZGRn8p+CWdKV7bzt+y6eNd7hbMuP 3+IFAaTsrwUAqshAFD8FjmuJQRmVpcc04HwT8AMWfAn/i+HI1hrfmMBsWLJvPIUSmTjp JC3Qv2XvSHEHGi099gnsSDZHwtyqvSjCoqv7HiuyybmlFnqi2w2rPF1/oNraDdvOFX3P 7yAQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=temperror (no key for signature) header.i=@ahepp.dev header.s=x header.b=R+0IK7Ws; arc=pass (i=1 spf=pass spfdomain=ahepp.dev); spf=pass (google.com: domain of linux-kernel+bounces-184370-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-184370-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d75a77b69052e-43df567099bsi57674451cf.370.2024.05.20.19.34.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 May 2024 19:34:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-184370-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=temperror (no key for signature) header.i=@ahepp.dev header.s=x header.b=R+0IK7Ws; arc=pass (i=1 spf=pass spfdomain=ahepp.dev); spf=pass (google.com: domain of linux-kernel+bounces-184370-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-184370-linux.lists.archive=gmail.com@vger.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 401DC1C20F99 for ; Tue, 21 May 2024 02:34:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 61E9C12E71; Tue, 21 May 2024 02:33:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=ahepp.dev header.i=@ahepp.dev header.b="R+0IK7Ws" Received: from mail-108-mta85.mxroute.com (mail-108-mta85.mxroute.com [136.175.108.85]) (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 829D517C64 for ; Tue, 21 May 2024 02:33:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=136.175.108.85 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716258836; cv=none; b=UgB5Z7Pj5Rz1RI9jVsiFt78es6MuhqNHq5gAHCR4bR2oPPLK3bSv2IeWthh4w7S7w0dk7qjx4sN4GrPFSwIManTyVBLFIX1PQkolepsOe9J1KLxSJ4hk3Rwfhd9XpVkEWdWRFCjed3CXlfSwH4bbxHR5ZagGbJoYW4eEfmQza04= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716258836; c=relaxed/simple; bh=zmXrS54sHl2ot3sb0GSDnnJCgcLWipCPzke2GVOr8Ds=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=MXJbDS9DTf/X6+zNUqpR1USBhkO+Moorp6rhlTsUN4ptLY1c78H/c5oYd/WCSuZVxBAeIDRzRDisLA1AZ+s1TkeNZdZStoIO4OWOkqhd/ZyZpbYKJGR8qFjtllRZfjyd/IZeYoiyzKdLSZ4AwQiNmnu/WnXJRJWtkUtoKWVUZBQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ahepp.dev; spf=pass smtp.mailfrom=ahepp.dev; dkim=fail (0-bit key) header.d=ahepp.dev header.i=@ahepp.dev header.b=R+0IK7Ws reason="key not found in DNS"; arc=none smtp.client-ip=136.175.108.85 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ahepp.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ahepp.dev Received: from filter006.mxroute.com ([136.175.111.3] filter006.mxroute.com) (Authenticated sender: mN4UYu2MZsgR) by mail-108-mta85.mxroute.com (ZoneMTA) with ESMTPSA id 18f98faac6c000efce.007 for (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Tue, 21 May 2024 02:28:36 +0000 X-Zone-Loop: 4bc457d50bc189acf096ad054bd702988649ae685ef6 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=ahepp.dev; s=x; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:From:References:Cc: To:Subject:MIME-Version:Date:Message-ID:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=iWaHaAPhmhUih0P5E+3/squCGgKZImlbCGWTxIoVtmU=; b=R+0IK7Wsi9kaNB0UenGOVgeVnd IK7juYKmsAkINgqylrSS/Na05o+Xd39u5o7GOgXoZBzroVuJTtD8HBFfbbG1BZcOExfyZD2MKnL/X VUKl8kDeTHmIPPrRMcMZcifw4f8PIFYUkcfwni54ycK05PqwrGKanJAtv4LO4bbinCMahMUs2TiC6 WM4PoV5JY9TM/TsV953t56wl6SDsaxS7j8wbwkMq4cjHXuY24YUspHL1YyIYipPkixxSUCkhykMMT OLO8QxiNnA6l6gGhED2xo7TbqczUZdZRwmDX6Uk+XM0BMj+qTMeU2MGdPNsZU0tGjlsQYg9f3bXD8 Yi95XZzg==; Message-ID: <23efcf4c-b5b2-d245-931f-0420e61701fe@ahepp.dev> Date: Mon, 20 May 2024 22:28:10 -0400 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [PATCH v2 1/2] iio: temperature: mcp9600: Provide index for both channels Content-Language: en-US To: Jonathan Cameron , Dimitri Fedrau Cc: Lars-Peter Clausen , Marcelo Schmitt , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?Q?Nuno_S=c3=a1?= References: <20240517081050.168698-1-dima.fedrau@gmail.com> <20240517081050.168698-2-dima.fedrau@gmail.com> <20240519171438.08810789@jic23-huawei> From: Andrew Hepp In-Reply-To: <20240519171438.08810789@jic23-huawei> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Authenticated-Id: andrew.hepp@ahepp.dev Hi all, I attempted to send this yesterday, but I guess I leaked some HTML into the message and it was rejected from the lists. I am resending it now as plain text. Apologies for any inconvenience or confusion. On 5/19/24 12:14 PM, Jonathan Cameron wrote: > On Fri, 17 May 2024 10:10:49 +0200 > Dimitri Fedrau wrote: > >> The mapping from cold junction to ambient temperature is inaccurate. We >> provide an index for hot and cold junction temperatures. >> >> Suggested-by: Jonathan Cameron >> Signed-off-by: Dimitri Fedrau > Hi Dmitri, > > I'm not sure you replied to the question in previous review of what > sysfs files exist for this device. Whilst I am at least a little > open to changing the ABI, I'd like to fully understand what > is currently presented and why iio_info is having trouble with it. > > I also want an ack from Andrew on this one given might break it existing > usage. I’m not actively using the cold junction temperature reading, so I would be happy to see any deficiencies in the ABI corrected. > > The current interface is perhaps less than ideal, but I don't think it > is wrong as such. Whilst I wasn't particularly keen on the cold junction > == ambient I'm not sure moving to just indexed is an improvement. > Hence looking for input from Andrew. +CC Nuno as someone who is both > active in IIO and has written thermocouple front end drivers in > the past. The ABI docs state The ambient and object modifiers distinguish between ambient (reference) and distant temperatures for contactless measurements Reading more of the Linux Driver API docs, those say that .modified is "used to indicate a physically unique characteristic of the channel”, and that .indexed is "simply another instance”. I’m not sure whether measuring temperature at a different location meets the bar of a “physically unique characteristic”. Maybe it does. But I don’t think of the cold junction temperature as “simply another instance”. Perhaps that’s a mistake on my behalf. Reviewing temperature drivers using IIO_MOD_TEMP_AMBIENT, they all seem to be reporting die temperatures. Some are IR sensors, but there are a couple other thermocouples like the MCP9600. Reviewing drivers using “.indexed”, one is an IR sensor and one is a thermocouple. In both cases, the indexed channels seem to represent a “full featured” channel. The IR sensor also reports IIO_MOD_TEMP_AMBIENT, so they chose not to make it an additional index. It seems to me that using IIO_MOD_TEMP_AMBIENT is more in line with what has been done in the past. But I may be misunderstanding something and I am not opposed to using and index if it’s determined that is more correct. Thanks, Andrew > > Jonathan > > >> --- >> drivers/iio/temperature/mcp9600.c | 9 +++++++-- >> 1 file changed, 7 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/iio/temperature/mcp9600.c b/drivers/iio/temperature/mcp9600.c >> index 46845804292b..22451d1d9e1f 100644 >> --- a/drivers/iio/temperature/mcp9600.c >> +++ b/drivers/iio/temperature/mcp9600.c >> @@ -14,6 +14,9 @@ >> >> #include >> >> +#define MCP9600_CHAN_HOT_JUNCTION 0 >> +#define MCP9600_CHAN_COLD_JUNCTION 1 >> + >> /* MCP9600 registers */ >> #define MCP9600_HOT_JUNCTION 0x0 >> #define MCP9600_COLD_JUNCTION 0x2 >> @@ -25,17 +28,19 @@ >> static const struct iio_chan_spec mcp9600_channels[] = { >> { >> .type = IIO_TEMP, >> + .channel = MCP9600_CHAN_HOT_JUNCTION, >> .address = MCP9600_HOT_JUNCTION, >> .info_mask_separate = >> BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE), >> + .indexed = 1, >> }, >> { >> .type = IIO_TEMP, >> + .channel = MCP9600_CHAN_COLD_JUNCTION, >> .address = MCP9600_COLD_JUNCTION, >> - .channel2 = IIO_MOD_TEMP_AMBIENT, >> - .modified = 1, >> .info_mask_separate = >> BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE), >> + .indexed = 1, >> }, >> }; >> >