mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Billy Tsai <billy_tsai@aspeedtech.com>
Cc: "Jonathan Cameron" <jic23@kernel.org>,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	"Rob Herring" <robh@kernel.org>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Conor Dooley" <conor+dt@kernel.org>,
	"Joel Stanley" <joel@jms.id.au>,
	"Andrew Jeffery" <andrew@codeconstruct.com.au>,
	"Ryan Chen" <ryan_chen@aspeedtech.com>,
	linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-aspeed@lists.ozlabs.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/3] iio: adc: aspeed: Use syscon phandle for trimming data when available
Date: Fri, 2 Oct 2026 11:34:25 +0300	[thread overview]
Message-ID: <ar9skaV0Vii8oX6G@ashevche-desk.local> (raw)
In-Reply-To: <20261001-ast27xx-adc-upstream-v2-2-2f9c15cc0064@aspeedtech.com>

On Thu, Oct 01, 2026 at 05:50:37PM +0800, Billy Tsai wrote:
> aspeed_adc_set_trim_data() locates the SCU holding the ADC's
> reference-voltage trimming data with of_find_node_by_name(NULL,
> "syscon"), a global search that matches the first device-tree node
> named "syscon" regardless of which SCU instance it actually is.
> 
> On AST2700, which splits its SCU into "syscon0" (soc0) and "syscon1"
> (soc1), both nodes share the same node name "syscon" and only differ
> by label and unit address, so the lookup always resolves to syscon0
> even though the ADC's trimming data lives in syscon1.
> 
> Use the new "aspeed,trim-syscon" phandle property when present to look
> up the correct regmap directly, falling back to the old global by-name
> search when the property is absent so existing device trees keep
> working.

...

> -	syscon = of_find_node_by_name(NULL, "syscon");
> -	if (syscon == NULL) {
> -		dev_warn(data->dev, "Couldn't find syscon node\n");
> -		return -EOPNOTSUPP;
> +	scu = syscon_regmap_lookup_by_phandle_optional(data->dev->of_node, "aspeed,trim-syscon");

Do not dereference of_node, use dev_of_node(), it will help in the future
if we want to reorganise firmware nodes in the struct device.

> +	if (!scu) {
> +		/*
> +		 * No "aspeed,trim-syscon" phandle: either a single-SCU SoC, or a DTB
> +		 * predating the property. Fall back to the old global
> +		 * by-name lookup for backward compatibility.
> +		 */

So, why not doing

	struct device_node *np;
	const char *propname;
	...
	np = dev_of_node(data->dev);
	propname = "aspeed,trim-syscon";
	if (of_property_present(np, propname)) {
		scu = syscon_regmap_lookup_by_phandle(np, propname);
		...
	}
	...

?

> +		syscon = of_find_node_by_name(NULL, "syscon");
> +		if (syscon == NULL) {
> +			dev_warn(data->dev, "Couldn't find syscon node\n");
> +			return -EOPNOTSUPP;
> +		}
> +		scu = syscon_node_to_regmap(syscon);
> +		of_node_put(syscon);
>  	}
> -	scu = syscon_node_to_regmap(syscon);
> -	of_node_put(syscon);
>  	if (IS_ERR(scu)) {
>  		dev_warn(data->dev, "Failed to get syscon regmap\n");
>  		return -EOPNOTSUPP;

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2026-10-02  8:34 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-01  9:50 [PATCH v2 0/3] iio: adc: aspeed: Fix SCU lookup for multi-SCU AST2700 Billy Tsai
2026-10-01  9:50 ` [PATCH v2 1/3] dt-bindings: iio: adc: Add syscon property for multi-SCU SoCs Billy Tsai
2026-10-02  9:03   ` Krzysztof Kozlowski
2026-10-02  9:15     ` Joshua Crofts
2026-10-01  9:50 ` [PATCH v2 2/3] iio: adc: aspeed: Use syscon phandle for trimming data when available Billy Tsai
2026-10-02  8:34   ` Andy Shevchenko [this message]
2026-10-01  9:50 ` [PATCH v2 3/3] arm64: dts: aspeed: Add syscon phandle to AST2700 ADC nodes Billy Tsai
2026-10-02  9:23 ` [PATCH v2 0/3] iio: adc: aspeed: Fix SCU lookup for multi-SCU AST2700 Andy Shevchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ar9skaV0Vii8oX6G@ashevche-desk.local \
    --to=andriy.shevchenko@intel.com \
    --cc=andrew@codeconstruct.com.au \
    --cc=andy@kernel.org \
    --cc=billy_tsai@aspeedtech.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=joel@jms.id.au \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-aspeed@lists.ozlabs.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=robh@kernel.org \
    --cc=ryan_chen@aspeedtech.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®