From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3FF39C3600B for ; Mon, 31 Mar 2025 10:04:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Subject:Cc:To: From:Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=GEb26LE91k7ueHIYN3TzHBL+xhqxCCU1dhJBY4L2Txg=; b=Et0N/8tpo7EIF6VFHwBOdsy1H7 wneabXWPuXqifmU7iF7cRFoYGxM1T4iKIepYXxwz4At1R9LKIiSoc0ijokit2mH6d6oO7Vcz30l0V KMTtsfULF8ZA4b3t6SmMaU3Byo1NkTCGugDA/iCtTcWh/JxT14OzGHf1PzhL4hPrlTJqdFEZqpM3F dJYszzFnZWnZzDyZ+m1Dg3OoEP1t9LXHb57u6eHpY1+v6ZjttU7EiOtW39++ohZoPWLRq9C/s4rw8 QWnfHAj0BroX7pgi/9hXeJt/fS1nZAAe/DskQzb+/l22SYsV/RKWJnPgGmXfMXTINhkSnSSHBBtHe ESsLCejg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.1 #2 (Red Hat Linux)) id 1tzC0M-00000000075-0iy3; Mon, 31 Mar 2025 10:04:30 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.98.1 #2 (Red Hat Linux)) id 1tzBlQ-0000000HZCL-2fk2 for linux-arm-kernel@lists.infradead.org; Mon, 31 Mar 2025 09:49:05 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 054F35C0FD5; Mon, 31 Mar 2025 09:46:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CE06CC4CEE3; Mon, 31 Mar 2025 09:48:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743414543; bh=9MmRAQT7FkmG5GtAiYqFguUGDYdzNTFv3scMm94gPxo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=rbxfz0nQRvHl/a30jPVpQGtLtt86XG3ULJs/CF+eZZkMtvUNiYuJh+0G2eln3liVH KAdkt7f1vTHW5uvqtzm+lcoaDP/ejYuYkP6okHVEwImHA1skjNbh/pPQyw9kOupmBD z08ZVkGlbczdSo5q7zrupGuOmHaQgAFF7B0gIGr+8PhbjuZg118Rf90ZT9uhLPsrPw yv5OgKyCX3o88F/x1xODN1IkZvfTiF3yvEEFsx1ndYH7BQBHKuOk7MUK7DPuydzxZP R67Qy4dU8pw+stj/MfU2o9e1u6NKKgvq0amXF03neIgSaESwh7kySTzLpsAZt/O04t kDZtyJqm8WbYg== Date: Mon, 31 Mar 2025 10:48:49 +0100 From: Jonathan Cameron To: Matti Vaittinen Cc: Marcelo Schmitt , Matti Vaittinen , Lars-Peter Clausen , Andy Shevchenko , Lad Prabhakar , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Nuno Sa , David Lechner , Javier Carrasco , Guillaume Stols , Dumitru Ceclan , Trevor Gamblin , Matteo Martelli , Alisa-Dariana Roman , Ramona Alexandra Nechita , AngeloGioacchino Del Regno , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev Subject: Re: [PATCH v10 3/8] iio: adc: add helpers for parsing ADC nodes Message-ID: <20250331104849.3eb748a8@jic23-huawei> In-Reply-To: <4d66b3b5-bfcb-42f0-9096-7c448c863dfc@gmail.com> References: <4d66b3b5-bfcb-42f0-9096-7c448c863dfc@gmail.com> X-Mailer: Claws Mail 4.3.0 (GTK 3.24.48; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250331_024904_761410_67221708 X-CRM114-Status: GOOD ( 47.61 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, 31 Mar 2025 08:39:35 +0300 Matti Vaittinen wrote: > Hi Marcelo, > > Thanks for the review! > > On 30/03/2025 23:19, Marcelo Schmitt wrote: > > Hi Matti, > > > > The new helpers for ADC drivers look good to me. > > I am now very late to complain about anything but am leaving some minor comments > > below that can be completely ignored. > > > > Reviewed-by: Marcelo Schmitt > > > > Thanks, > > Marcelo > > > > On 03/24, Matti Vaittinen wrote: > >> There are ADC ICs which may have some of the AIN pins usable for other > >> functions. These ICs may have some of the AIN pins wired so that they > >> should not be used for ADC. > >> > >> (Preferred?) way for marking pins which can be used as ADC inputs is to > >> add corresponding channels@N nodes in the device tree as described in > >> the ADC binding yaml. > > Not sure it's preferred to have ADC channels always declared in dt. That > > question was somewhat also raised during ADC doc review [1]. > > I had missed that doc and the review. Interesting read, thanks for > pointing it :) > > We did also do a bit discussion about this during the review of the > earlier versions. I am not sure if we found an ultimate common consensus > though :) > > A recap as seen through my eyes: > > - It is preferred to have either _all_ or _none_ of the channels > described in the device tree. > https://lore.kernel.org/all/20250201162631.2eab9a9a@jic23-huawei/ > > - This, however, is not _always_ required to be followed, and it may be > impractical in some cases: > https://lore.kernel.org/linux-iio/6f6e6550-5246-476f-9168-5e24151ab165@baylibre.com/#t > > - We do have bunch of existing drivers which we need to support. With > some very different approaches to bindings. > https://lore.kernel.org/linux-iio/20250302032054.1fb8a011@jic23-huawei/ > > > My _personal_ thinking is that: > > This means that we can't hide the binding parsing in the IIO-core. We > can't go and change the channels in existing drivers. > > But, we can provide helpers (like this one) for drivers to use. I also > believe we should still try to have common (and preferred!) approach for > the _new_ drivers. Eventually, the new ones will be majority. Some of > the old ones die, and if we keep same practices for new ones, the old > ones will become rare exceptions while majority follows same principles ;) > > > In short, ADC > > channel may and may not be declared under ADC dt node. ADC bindings often don't > > enforce channels to be declared. On IIO side of things, many ADC drivers just > > populate channels even if they are not declared in dt. > > The ADCs you are supporting in the other patches of this series seem to require > > dt declared channels though. > > > > [1]: https://lore.kernel.org/linux-iio/20250118155153.2574dbe5@jic23-huawei/ > > > > Would something like > > > > A common way of marking pins that can be used as ADC inputs is to add > > corresponding channel@N nodes in the device tree as described in the ADC > > binding yaml. > > > > be a good rephrasing of the above paragraph? > > Yes, if we don't want to guide new drivers to either have all usable > channels, or no channels in the device tree. > > I think Jonathan said he'll be rebasing this to rc1. I am a newcomer and > I should not enforce my view over more experienced ones ;) So, feel free > to reword the description as Marcelo suggests if you don't think we > should prefer one direction or the other. I've gone with Marcelo's suggestion because I don't want to be too specific here given the complex history. We can absolutely encourage the all or nothing description going forwards though as it is logical in the vast majority of cases. > > >> > >> Add couple of helper functions which can be used to retrieve the channel > >> information from the device node. > >> > >> Signed-off-by: Matti Vaittinen > >> Reviewed-by: Andy Shevchenko > >> > > ... > >> +static inline int iio_adc_device_num_channels(struct device *dev) > >> +{ > >> + return device_get_named_child_node_count(dev, "channel"); > >> +} > > I wonder if this function name can eventually become misleading. > > > > In Documentation/devicetree/bindings/iio/temperature/adi,ltc2983.yaml we have > > temperature sensor with channel nodes named after external hardware connected to > > the sensor, leading to channels having different node names. Can anything like > > that ever be accepted for ADC bindings? > > My initial thinking is that the hardware which is connected to the ADC > should have it's own node - and there should be only a reference from > the ADC to the other hardware's description. I think the connected > hardware should not be a property of the ADC channel. > > Anyways, the current ADC binding (bindings/iio/adc/adc.yaml) says the > node name must be channel[@xxx] (which, I believe makes sense as it > makes it easier to understand device-trees for ICs which may provide > other nodes but ADC channels too). > > properties: > $nodename: > pattern: "^channel(@[0-9a-f]+)?$" > description: > A channel index should match reg. > > Yours, > -- Matti