From: Vladimir Oltean <vladimir.oltean@nxp.com>
To: "Bjørn Mork" <bjorn@mork.no>
Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org,
linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org,
"Daniel Golle" <daniel@makrotopia.org>,
"Horatiu Vultur" <horatiu.vultur@microchip.com>,
"Andrew Lunn" <andrew@lunn.ch>,
"Heiner Kallweit" <hkallweit1@gmail.com>,
"Russell King" <linux@armlinux.org.uk>,
"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>,
"Vinod Koul" <vkoul@kernel.org>,
"Neil Armstrong" <neil.armstrong@linaro.org>,
"Matthias Brugger" <matthias.bgg@gmail.com>,
"AngeloGioacchino Del Regno"
<angelogioacchino.delregno@collabora.com>,
"Eric Woudstra" <ericwouds@gmail.com>,
"Marek Behún" <kabel@kernel.org>, "Lee Jones" <lee@kernel.org>,
"Patrice Chotard" <patrice.chotard@foss.st.com>
Subject: Re: [PATCH v2 net-next 05/10] phy: add phy_get_rx_polarity() and phy_get_tx_polarity()
Date: Sat, 10 Jan 2026 20:04:33 +0200 [thread overview]
Message-ID: <20260110180433.bfg2hxbdjkfllkiq@skbuf> (raw)
In-Reply-To: <87jyxtaljn.fsf@miraculix.mork.no> <87jyxtaljn.fsf@miraculix.mork.no>
Hi Bjørn,
On Wed, Jan 07, 2026 at 09:12:28AM +0100, Bjørn Mork wrote:
> Vladimir Oltean <vladimir.oltean@nxp.com> writes:
>
> > +static int fwnode_get_u32_prop_for_name(struct fwnode_handle *fwnode,
> > + const char *name,
> > + const char *props_title,
> > + const char *names_title,
> > + unsigned int default_val,
> > + unsigned int *val)
> > +{
> > + int err, n_props, n_names, idx = -1;
> > + u32 *props;
> > +
> > + if (!name) {
> > + pr_err("Lookup key inside \"%s\" is mandatory\n", names_title);
> > + return -EINVAL;
> > + }
> > +
> > + if (!fwnode) {
> > + *val = default_val;
> > + return 0;
> > + }
> > +
> > + err = fwnode_property_count_u32(fwnode, props_title);
> > + if (err < 0)
> > + return err;
> > + if (err == 0) {
> > + *val = default_val;
> > + return 0;
> > + }
> > + n_props = err;
>
> I tried using this in the air_en8811h driver and started wondering if I
> have misunderstood something.
>
> The problem I have is that fwnode_property_count_u32() returns -EINVAL
> if props_title is missing. So if you have a node with the legacy
> "airoha,pnswap-rx" property instead of "rx-polarity", or more common: no
> polariy property at all, then we see -EINVAL returned from
> phy_get_rx_polarity(). Which is propagated back to config_init() and
> the phy fails to attach. That can't be the intention?
>
> The behaviour I expected is described by this test:
>
>
> /* Test: tx-polarity property is missing */
> static void phy_test_tx_polarity_is_missing(struct kunit *test)
> {
> static const struct property_entry entries[] = {
> {}
> };
> struct fwnode_handle *node;
> unsigned int val;
> int ret;
>
> node = fwnode_create_software_node(entries, NULL);
> KUNIT_ASSERT_NOT_ERR_OR_NULL(test, node);
>
> ret = phy_get_manual_tx_polarity(node, "sgmi", &val);
> KUNIT_EXPECT_EQ(test, ret, 0);
> KUNIT_EXPECT_EQ(test, val, PHY_POL_NORMAL);
>
> fwnode_remove_software_node(node);
> }
Thanks for debugging and for the test! This is a regression from v1,
where I just checked the fwnode_property_count_u32() return code for
being <= 0.
I've integrated your test and added one more for RX. Do you have any
further comments, or shall I send an updated v3?
next prev parent reply other threads:[~2026-01-10 18:05 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-03 21:03 [PATCH v2 net-next 00/10] PHY polarity inversion via generic device tree properties Vladimir Oltean
2026-01-03 21:03 ` [PATCH v2 net-next 01/10] dt-bindings: phy: rename transmit-amplitude.yaml to phy-common-props.yaml Vladimir Oltean
2026-01-03 21:03 ` [PATCH v2 net-next 02/10] dt-bindings: phy-common-props: create a reusable "protocol-names" definition Vladimir Oltean
2026-01-06 18:23 ` Rob Herring (Arm)
2026-01-03 21:03 ` [PATCH v2 net-next 03/10] dt-bindings: phy-common-props: ensure protocol-names are unique Vladimir Oltean
2026-01-06 18:22 ` Rob Herring (Arm)
2026-01-03 21:03 ` [PATCH v2 net-next 04/10] dt-bindings: phy-common-props: RX and TX lane polarity inversion Vladimir Oltean
2026-01-03 21:03 ` [PATCH v2 net-next 05/10] phy: add phy_get_rx_polarity() and phy_get_tx_polarity() Vladimir Oltean
2026-01-07 8:12 ` Bjørn Mork
2026-01-10 18:04 ` Vladimir Oltean [this message]
2026-01-10 18:08 ` Bjørn Mork
2026-01-10 18:19 ` Vladimir Oltean
2026-01-03 21:03 ` [PATCH v2 net-next 06/10] dt-bindings: net: airoha,en8811h: deprecate "airoha,pnswap-rx" and "airoha,pnswap-tx" Vladimir Oltean
2026-01-03 21:04 ` [PATCH v2 net-next 07/10] net: phy: air_en8811h: " Vladimir Oltean
2026-01-06 19:03 ` Bjørn Mork
2026-01-06 22:16 ` Vladimir Oltean
2026-01-10 18:41 ` Vladimir Oltean
2026-01-03 21:04 ` [PATCH v2 net-next 08/10] dt-bindings: net: pcs: mediatek,sgmiisys: deprecate "mediatek,pnswap" Vladimir Oltean
2026-01-06 18:24 ` Rob Herring (Arm)
2026-01-03 21:04 ` [PATCH v2 net-next 09/10] net: pcs: pcs-mtk-lynxi: pass SGMIISYS OF node to PCS Vladimir Oltean
2026-01-03 21:04 ` [PATCH v2 net-next 10/10] net: pcs: pcs-mtk-lynxi: deprecate "mediatek,pnswap" Vladimir Oltean
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=20260110180433.bfg2hxbdjkfllkiq@skbuf \
--to=vladimir.oltean@nxp.com \
--cc=andrew@lunn.ch \
--cc=angelogioacchino.delregno@collabora.com \
--cc=bjorn@mork.no \
--cc=conor+dt@kernel.org \
--cc=daniel@makrotopia.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=ericwouds@gmail.com \
--cc=hkallweit1@gmail.com \
--cc=horatiu.vultur@microchip.com \
--cc=kabel@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=lee@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-phy@lists.infradead.org \
--cc=linux@armlinux.org.uk \
--cc=matthias.bgg@gmail.com \
--cc=neil.armstrong@linaro.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=patrice.chotard@foss.st.com \
--cc=robh@kernel.org \
--cc=vkoul@kernel.org \
/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