From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) (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 C56AF1BD00C; Sun, 2 Mar 2025 13:00:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740920428; cv=none; b=se2lqOpg6NnA1mR1L49dRwS70scXWbTuCiP7gd5C63/XHyaUQIkB799JC8BUusa1QN8hWu3h/jastsEFpCVbcvcuAXM0nUtj8mc4t4WtRoCEe42YGS60K9Njy7yhj0XfTdf+5g3rRgILhZ2D2s5ABVQD08eUn06boPUjNZNoVVU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740920428; c=relaxed/simple; bh=F2oW1i7xFQ5yaNfg8aSg4BfxUAemyDWnFE4Dx9ylQcA=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=E4YzJxItOvb6YPpWZLw05FfFVcDfgjzzuYkMBSRruF23RpiFlTJkIFXUUkFiOQEJVRt7OmktVprr1T4785BSy9oxpMb2SEVPPvMFMo/TFXuvC9xi6zGhNLPH9JZqA/UdY6+PAwpe7pE3gYL5P2sh2Grm68qtmbeCmt9c+Elx2+k= 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=j6775vvM; arc=none smtp.client-ip=209.85.208.175 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="j6775vvM" Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-307325f2436so37568901fa.0; Sun, 02 Mar 2025 05:00:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740920425; x=1741525225; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=XfGXlQMIJZXRSzz9b3y/679wpg6DJoBY9Odmd3DiDb8=; b=j6775vvMdKNv0C2lE4kMEGORMN7l3EjJ4xRahIy1G2H4zPngBxYIrq2A6+8uuK3A/J V6czhtZq1suZvKwyp5G1pBQS5fpoD9Yn0dy0imXtwznrTuEcoeIeI5PXPb4Ty65nIGLo BtNOAC4wodPrnoh3WreLUbxTOs6G/pYiWX0HXcsbwDh61Nk6inEL960oG1FT2zQWanvI NQLgzpqy6ko0DTynIY62bJFg2OXZ1gt9JWs5hELAKRAZ8QOa2pqDnz0qqx6XQMJ/CHW2 0m+zmpzrgyg1PidijTfFwXAW87OsV32i1AVzJjOZFyCnNottaxwRcRrFGZ/8Aa00LheB 6wdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740920425; x=1741525225; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=XfGXlQMIJZXRSzz9b3y/679wpg6DJoBY9Odmd3DiDb8=; b=gD1WdXvB09304uS39UCjMSN8Ax+QI7tJV2UVMD96Wxp/Heavr9U+RXToBx4hBNOurw SUVSDOxK1xrXQlml2SmBFPoD87tbisJFn8l4HPweGCKA/CkVu8yBo1VdPGpme6KF9pbB Q+9Hcq9WgsYKk5swOob25oSKnrjiAfI6uW3f/b8mqDDGbpKuRIQRMXgFw62jEBn66U9y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nkQwdP5WDzZViB kNScUBs7FelsWJ+61AhJM8cNtbtc01OQykb/Z0fn9Fa1baI4dalDQ1Q3+LjT2KBGv9YfwAI23yN XJgcHCiZjikLsxZV5oo5rZ2OD+g== X-Google-Smtp-Source: AGHT+IEJBMocHt2Jgr18dEspZ7moKiOE2FRAdMPLkXLThDcOzKqgxp1X7Z/SUDkFQeJFZlY+0pzPtA== X-Received: by 2002:a2e:be15:0:b0:300:26bc:4311 with SMTP id 38308e7fff4ca-30b9326afc7mr48040971fa.18.1740920424456; Sun, 02 Mar 2025 05:00:24 -0800 (PST) Received: from ?IPV6:2a10:a5c0:800d:dd00:8fdf:935a:2c85:d703? ([2a10:a5c0:800d:dd00:8fdf:935a:2c85:d703]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-30ba19df7a0sm5519091fa.34.2025.03.02.05.00.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 02 Mar 2025 05:00:23 -0800 (PST) Message-ID: Date: Sun, 2 Mar 2025 15:00:21 +0200 Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 03/10] iio: adc: add helpers for parsing ADC nodes To: Jonathan Cameron Cc: Matti Vaittinen , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich , Lad Prabhakar , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Hugo Villeneuve , Nuno Sa , David Lechner , Javier Carrasco , Guillaume Stols , Olivier Moysan , 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 References: <23f5ee3e3bf7179930d66c720d5c4c33cdbe8366.1740421248.git.mazziesaccount@gmail.com> <20250302033507.7c166743@jic23-huawei> Content-Language: en-US, en-AU, en-GB, en-BW From: Matti Vaittinen In-Reply-To: <20250302033507.7c166743@jic23-huawei> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 02/03/2025 05:35, Jonathan Cameron wrote: > On Mon, 24 Feb 2025 20:33:16 +0200 > 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. > I think it's worth exploring if we can tweak this slightly to make > that something a driver specifies. Either skip the unspecified or > fill them with default values depending on a parameter. > > Would make this code cover the existing cases better. > Might be a little fiddly as we'd want to maintain ordering so > the code would need to index slightly differently. I've not tried it > so maybe not worth it for now. Thanks for the review! I don't remember seeing users which would have benefited from this (but maybe I just quickly discarded them as unsuitable for this API and forgot them). Anyways, I think it might be cleaner (from the caller's perspective) to have own function for supporting such cases. >> + >> +int iio_adc_device_num_channels(struct device *dev) >> +{ >> + return device_get_child_node_count_named(dev, "channel"); >> +} >> +EXPORT_SYMBOL_GPL(iio_adc_device_num_channels); > > Maybe one to promote to a static inline in the header and avoid need for > the export given it is very simple. Makes sense, thanks. ... >> + >> + if (max_chan_id != -1) >> + if (ch > max_chan_id) >> + return -ERANGE; > > Might as well combine. > if (max_chan_id != -1 && ch > max_chan_id) > return -ERANGE; Ack. Yours, -- Matti