From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ot1-f45.google.com (mail-ot1-f45.google.com [209.85.210.45]) (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 DF63223CE for ; Wed, 26 Feb 2025 00:09:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740528550; cv=none; b=u7vgtHxYoOnm+jbTZKNnNoTjKH3SwLvNt2UvPwPsa/WMF2oUScA2QJ7I/hy+8CBmbXPEbCysWzF+cGuHxt3HIn6gVTqE06b/MnYplZGNUAz4G0EVRjIuMzJ05eQxZfhUG9+jV383tOaxsLJ8pgvaA33u/69zPlGryN/enGGcxN8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740528550; c=relaxed/simple; bh=h26bDQt1EvZvwSeo1EG9AJe/Hyqmt8BinkNFg5j8KtQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=so8o2evdHugFiiUg+0/jxRDJdc5Cy7nS4hC1cxQr4DEv9kV+b16M79mHayen6fPT5rHSiWimcXRHG90hGr/YRGbyXj0qp8fhM3YRN8PHr28GBEu+4A1gSMbjgv5x/eDTW70/fgqUkVCy8w1SBBtQ9GCg2SDdtsF9ftYbNP3XtTQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=nu1u8jy7; arc=none smtp.client-ip=209.85.210.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="nu1u8jy7" Received: by mail-ot1-f45.google.com with SMTP id 46e09a7af769-7271cc3d73eso3328666a34.1 for ; Tue, 25 Feb 2025 16:09:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1740528547; x=1741133347; 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=juVLmpm4UqW3CDyHjhGjXXzInD2jAOQrY9jRma953QM=; b=nu1u8jy7tEcmXzkguzmoirxSZw8jGD9slpgpn1qaBCjkesSUqnJPCxx59MkqdkBAlf 5cb+PxFJsGKCADh0TacvGS450pNcTR/RtYgwq7hrkyw7h07je3th7VLogBw4zfg2AxcD 1C00sN+lMFg/1iW94+gtP7tmO+HmoBka5iLWY5FPHvotiHSUnNmB+VQ5HLkV1nwA4keE bHMV6p3V3MBLxaSS/C57SxJs+1fQHAkN7Ms+T4F2nHpPRAFTd3yVoUzIFKNKT9qUmIzF M5w5VWteRDVIUiFVJ5Hituq+tzHTDlVqvX+b1qm7fJeO4RSZpSA+7+dcNZfIZu1RDUJM po5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740528547; x=1741133347; 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=juVLmpm4UqW3CDyHjhGjXXzInD2jAOQrY9jRma953QM=; b=DnUgUTbJcJUjyHpR4sVLQKfHCSSvZ6781Y4Rj/ourhSveXdmNLAzl8hvI1QjGiHKpY 6LjoCJugKydj/+0JaMXbKi+TGSnLagjEGVafkQZLgEz9x20efXaawPC4g+7hBXqp/h/I 8QsvQwbDfhGqn4fbfli0AsFiJ8Vh+bG95ZntwddZlPppPaCEswl4+QbLvuvp3ZsOXOps 4S1YGnZDoZTJXi/eXuyJe63x9jkRGXPXik4tlrWy3y3uPYEdEYk6jpNS8QP0Cf8xtV1Z 0dl/nQSdo0Zy2KaLCFk5Zy82r8EHxxgUYp1u+Lpwf9oSVCHsUGgYaJpgDn9tfykn9iwz wS8A== X-Forwarded-Encrypted: i=1; AJvYcCUhPY/MY43J7UMV8wAmBUjY2Ju7RjsOslU1qCxdWKfm5L/LnohdFWQhV2yAd51lPXUAgiIWyRNDNz5/aDA=@vger.kernel.org X-Gm-Message-State: AOJu0YyWrgZ1X/G6betFRuluaD4pJ2PLrEdc+kPBlFuG0KykJFxZZYoM unGj6506VMbRsN+Xcorm5wyR6YUfFT/iO6X4BRiO92j0Wamy4cZ2qZCFSdOsG6w= X-Gm-Gg: ASbGncuhJgKtHabmr08vwkmuXaCnHLhEEPy2/ZkRr+jLDRvVZb7N2cNZsAyoeMsZM70 xUwgkMkK/ura8Dh2Xest/aknSEcA4/F8IHYT9C3GWNU+ba1UvgvE3jkvLhXFIgnSDJGBo2ZdCZK c4FGK6FTaBZybQfnfjD+ALnLRnDx7EjsnUXxSTND/6HBav2kqYwyQ37I90zpyqVo14oU4kTiMI4 u8Ynq4TBusGp5/puulPog7roiZbDKoDKRcx2wOBK9J9dbZ0DivxUZ40T3nkPFLpzCWgV72lfYNp cefgDDkpwXR3NxsL1Fie+KmQHC59jGL85C5IuiAJwc48s/5iRV4tBJrAiuxlgSM= X-Google-Smtp-Source: AGHT+IFcLe07eLzlySwjtDU+XuKdCvG3TGM5yw/uZ3tgI0c9sfN55oU4icGBmCi8OdnlyMQtoSSFWg== X-Received: by 2002:a05:6830:dc3:b0:727:24ab:3e4 with SMTP id 46e09a7af769-7274c1ac6f4mr15683376a34.9.1740528546779; Tue, 25 Feb 2025 16:09:06 -0800 (PST) Received: from [192.168.0.142] (ip98-183-112-25.ok.ok.cox.net. [98.183.112.25]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7289dee9d50sm497552a34.34.2025.02.25.16.09.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 25 Feb 2025 16:09:06 -0800 (PST) Message-ID: Date: Tue, 25 Feb 2025 18:09:04 -0600 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 07/10] iio: adc: ti-ads7924: Respect device tree config To: Matti Vaittinen , Matti Vaittinen Cc: Jonathan Cameron , 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 , 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: <20dd0e4ea72fe39b90b611f9c08dbd4bc1d5217f.1740421248.git.mazziesaccount@gmail.com> Content-Language: en-US From: David Lechner In-Reply-To: <20dd0e4ea72fe39b90b611f9c08dbd4bc1d5217f.1740421248.git.mazziesaccount@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 2/24/25 12:34 PM, Matti Vaittinen wrote: > The ti-ads7924 driver ignores the device-tree ADC channel specification > and always exposes all 4 channels to users whether they are present in > the device-tree or not. Additionally, the "reg" values in the channel > nodes are ignored, although an error is printed if they are out of range. > > Register only the channels described in the device-tree, and use the reg > property as a channel ID. > > Signed-off-by: Matti Vaittinen > > --- > Revision history: > v3 => v4: > - Adapt to 'drop diff-channel support' changes to ADC-helpers > - select ADC helpers in the Kconfig > v2 => v3: New patch > > Please note that this is potentially breaking existing users if they > have wrong values in the device-tree. I believe the device-tree should > ideally be respected, and if it says device X has only one channel, then > we should believe it and not register 4. Well, we don't live in the > ideal world, so even though I believe this is TheRightThingToDo - it may > cause havoc because correct device-tree has not been required from the > day 1. So, please review and test and apply at your own risk :) The DT bindings on this one are a little weird. Usually, if we don't use any extra properties from adc.yaml, we leave out the channels. In this case it does seem kind of like the original intention was to work like you are suggesting, but hard to say since the driver wasn't actually implemented that way. I would be more inclined to actually not make the breaking change here and instead relax the bindings to make channel nodes optional and just have the driver ignore the channel nodes by dropping the ads7924_get_channels_config() function completely. This would make the driver simpler instead of more complex like this patch does. > > As a side note, this might warrant a fixes tag but the adc-helper -stuff > is hardly worth to be backported... (And I've already exceeded my time > budget with this series - hence I'll leave crafting backportable fix to > TI people ;) ) > > This has only been compile tested! All testing is highly appreciated. > --- ... > -static int ads7924_get_channels_config(struct device *dev) > +static int ads7924_get_channels_config(struct iio_dev *indio_dev, > + struct device *dev) Could get dev from indio_dev->dev.parent and keep only one parameter to this function. > { > - struct fwnode_handle *node; > - int num_channels = 0; > + struct iio_chan_spec *chan_array; > + int num_channels = 0, i; Don't need initialization here. > + static const char * const datasheet_names[] = { > + "AIN0", "AIN1", "AIN2", "AIN3" > + }; >