public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: "Bjørn Mork" <bjorn@mork.no>
To: Vladimir Oltean <vladimir.oltean@nxp.com>
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: Wed, 07 Jan 2026 09:12:28 +0100	[thread overview]
Message-ID: <87jyxtaljn.fsf@miraculix.mork.no> (raw)
In-Reply-To: <20260103210403.438687-6-vladimir.oltean@nxp.com> (Vladimir Oltean's message of "Sat, 3 Jan 2026 23:03:58 +0200")

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);
}



Bjørn

  reply	other threads:[~2026-01-07  8:13 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 [this message]
2026-01-10 18:04     ` Vladimir Oltean
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=87jyxtaljn.fsf@miraculix.mork.no \
    --to=bjorn@mork.no \
    --cc=andrew@lunn.ch \
    --cc=angelogioacchino.delregno@collabora.com \
    --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 \
    --cc=vladimir.oltean@nxp.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