public inbox for linux-tegra@vger.kernel.org
 help / color / mirror / Atom feed
From: Jon Hunter <jonathanh@nvidia.com>
To: Bartosz Golaszewski <brgl@kernel.org>,
	Prathamesh Shete <pshete@nvidia.com>
Cc: linusw@kernel.org, thierry.reding@gmail.com,
	linux-gpio@vger.kernel.org, linux-tegra@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] gpio: tegra186: Support multi-socket devices
Date: Tue, 17 Feb 2026 09:31:31 +0000	[thread overview]
Message-ID: <751fdb29-d66d-4245-9abb-714d5dd27c81@nvidia.com> (raw)
In-Reply-To: <CAMRc=MdRL=_nRF5g4MukNjgeYGh=Bz3zN7bXEp7RPsLHHyq8xA@mail.gmail.com>


On 16/02/2026 11:29, Bartosz Golaszewski wrote:
> On Mon, 16 Feb 2026 05:58:42 +0100, Prathamesh Shete <pshete@nvidia.com> said:
>> On Tegra platforms, multiple SoC instances may be present with each
>> defining the same GPIO name. For such devices, this results in
>> duplicate GPIO names.
>>
>> When the device has a valid NUMA node, prepend the NUMA node ID
>> to the GPIO name prefix. The node ID identifies each socket,
>> ensuring GPIO line names remain distinct across multiple sockets.
>>
>> Signed-off-by: Prathamesh Shete <pshete@nvidia.com>
>> ---
>>   drivers/gpio/gpio-tegra186.c | 26 +++++++++++++++++---------
>>   1 file changed, 17 insertions(+), 9 deletions(-)
>>
>> diff --git a/drivers/gpio/gpio-tegra186.c b/drivers/gpio/gpio-tegra186.c
>> index 9c874f07be75..daf5aaffa28a 100644
>> --- a/drivers/gpio/gpio-tegra186.c
>> +++ b/drivers/gpio/gpio-tegra186.c
>> @@ -857,7 +857,8 @@ static int tegra186_gpio_probe(struct platform_device *pdev)
>>   	struct device_node *np;
>>   	struct resource *res;
>>   	char **names;
>> -	int err;
>> +	char *instance = "";
>> +	int node, err;
>>
>>   	gpio = devm_kzalloc(&pdev->dev, sizeof(*gpio), GFP_KERNEL);
>>   	if (!gpio)
>> @@ -937,17 +938,21 @@ static int tegra186_gpio_probe(struct platform_device *pdev)
>>   	if (!names)
>>   		return -ENOMEM;
>>
>> +	node = dev_to_node(&pdev->dev);
>> +	if (node >= 0) {
>> +		instance = devm_kasprintf(gpio->gpio.parent, GFP_KERNEL, "%d-", node);
> 
> I've never noticed it before (and it's not introduced by this patch) but I
> really dislike the child device registering devres nodes with its parent...
> 
>> +		if (!instance)
>> +			return -ENOMEM;
>> +	}
>> +
>>   	for (i = 0, offset = 0; i < gpio->soc->num_ports; i++) {
>>   		const struct tegra_gpio_port *port = &gpio->soc->ports[i];
>>   		char *name;
>>
>>   		for (j = 0; j < port->pins; j++) {
>> -			if (gpio->soc->prefix)
>> -				name = devm_kasprintf(gpio->gpio.parent, GFP_KERNEL, "%s-P%s.%02x",
>> -						      gpio->soc->prefix, port->name, j);
>> -			else
>> -				name = devm_kasprintf(gpio->gpio.parent, GFP_KERNEL, "P%s.%02x",
>> -						      port->name, j);
>> +			name = devm_kasprintf(gpio->gpio.parent, GFP_KERNEL, "%s%sP%s.%02x",
>> +					      instance ?: "", gpio->soc->prefix ?: "",
> 
> instance can't be NULL here, can it? Either print it unconditionally or
> initialize it to NULL.

The other alternative here is that we just use 'instance' without the 
ternary operator because we initialise to "" ...

  name = devm_kasprintf(gpio->gpio.parent, GFP_KERNEL, "%s%sP%s.%02x",
                        instance, gpio->soc->prefix ?: "",
                        port->name, j);

Jon

-- 
nvpublic


      parent reply	other threads:[~2026-02-17  9:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-16  4:58 [PATCH] gpio: tegra186: Support multi-socket devices Prathamesh Shete
2026-02-16 11:29 ` Bartosz Golaszewski
2026-02-16 17:22   ` Jon Hunter
2026-02-16 18:43     ` Bartosz Golaszewski
2026-02-17  9:31   ` Jon Hunter [this message]

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=751fdb29-d66d-4245-9abb-714d5dd27c81@nvidia.com \
    --to=jonathanh@nvidia.com \
    --cc=brgl@kernel.org \
    --cc=linusw@kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=pshete@nvidia.com \
    --cc=thierry.reding@gmail.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