public inbox for devicetree@vger.kernel.org
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <krzk@kernel.org>
To: Jon Hunter <jonathanh@nvidia.com>
Cc: Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Thierry Reding <thierry.reding@gmail.com>,
	netdev@vger.kernel.org, devicetree@vger.kernel.org,
	linux-tegra@vger.kernel.org
Subject: Re: [PATCH V3 1/3] net: stmmac: Fix PTP ref clock for Tegra234
Date: Tue, 31 Mar 2026 12:18:01 +0200	[thread overview]
Message-ID: <5b3eaba5-eba2-43f9-8ef5-d305ca50ddf0@kernel.org> (raw)
In-Reply-To: <01f56e6f-5459-4a96-9042-8a003a340fab@nvidia.com>

On 31/03/2026 12:14, Jon Hunter wrote:
> 
> On 26/03/2026 08:32, Krzysztof Kozlowski wrote:
> 
> ...
> 
>>> @@ -257,9 +258,23 @@ static int tegra_mgbe_probe(struct platform_device *pdev)
>>>   	if (!mgbe->clks)
>>>   		return -ENOMEM;
>>>   
>>> -	for (i = 0; i <  ARRAY_SIZE(mgbe_clks); i++)
>>> +	/*
>>> +	 * Older device-trees use 'ptp-ref' rather than 'ptp_ref'.
>>> +	 * Fall back to the legacy name when 'ptp_ref' is absent.
>>> +	 */
>>> +	use_legacy_ptp = of_property_match_string(pdev->dev.of_node,
>>> +						  "clock-names", "ptp_ref") < 0;
>>> +
>>> +	for (i = 0; i < ARRAY_SIZE(mgbe_clks); i++) {
>>>   		mgbe->clks[i].id = mgbe_clks[i];
>>>   
>>> +		if (use_legacy_ptp && !strcmp(mgbe_clks[i], "ptp_ref")) {
>>
>> Why index 0 is not valid? And why -EINVAL would be considered as legacy
>> clock present?
> 
> Index 0 is valid. However, yes I guess that treating an -EINVAL from 
> of_property_match_string() is not correct. I will switch the logic to be ...
> 
>   use_legacy_ptp = of_property_match_string(pdev->dev.of_node,
>                                     "clock-names", "ptp-ref") >= 0;

No, apologies, I think my comment was not correct and your reply made me
rethink. I missed final "< 0" in of_property_match_string().

So the code is good, you do not store index in 'use_legacy_ptp', but the
error return value.

Can you however make it more obvious code, so something like:

if (of_property_match_string...))
	use_legacy_ptp = true;;



Best regards,
Krzysztof

  reply	other threads:[~2026-03-31 10:18 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-25 13:58 [PATCH V3 0/3] net: stmmac: Fix Tegra234 MGBE clock Jon Hunter
2026-03-25 13:58 ` [PATCH V3 1/3] net: stmmac: Fix PTP ref clock for Tegra234 Jon Hunter
2026-03-26  8:32   ` Krzysztof Kozlowski
2026-03-31 10:14     ` Jon Hunter
2026-03-31 10:18       ` Krzysztof Kozlowski [this message]
2026-03-31 10:48         ` Jon Hunter
2026-03-25 13:58 ` [PATCH V3 2/3] dt-bindings: net: Fix Tegra234 MGBE PTP clock Jon Hunter
2026-03-25 14:07   ` Krzysztof Kozlowski
2026-03-25 14:09     ` Krzysztof Kozlowski
2026-03-25 14:26       ` Jon Hunter
2026-03-26  8:30   ` Krzysztof Kozlowski
2026-03-25 13:58 ` [PATCH V3 3/3] arm64: tegra: " Jon Hunter
2026-03-26  8:30   ` Krzysztof Kozlowski

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=5b3eaba5-eba2-43f9-8ef5-d305ca50ddf0@kernel.org \
    --to=krzk@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=conor+dt@kernel.org \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=edumazet@google.com \
    --cc=jonathanh@nvidia.com \
    --cc=krzk+dt@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=robh@kernel.org \
    --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