generic: 6.1: fixup QCA807x upstream PHY
[openwrt/openwrt.git] / target / linux / generic / pending-6.1 / 778-net-phy-qca807x-move-interface-mode-check-to-.config.patch
1 From 824d6c9747fb46eadf763b879fb1c072e541a65a Mon Sep 17 00:00:00 2001
2 From: Robert Marko <robimarko@gmail.com>
3 Date: Mon, 12 Feb 2024 12:26:41 +0100
4 Subject: [PATCH net-next] net: phy: qca807x: move interface mode check to
5 .config_init_once
6
7 Currently, we are checking whether the PHY package mode matches the
8 individual PHY interface modes at PHY package probe time, but at that time
9 we only know the PHY package mode and not the individual PHY interface
10 modes as of_get_phy_mode() that populates it will only get called once the
11 netdev to which PHY-s are attached to is being probed and thus this check
12 will always fail and return -EINVAL.
13
14 So, lets move this check to .config_init_once as at that point individual
15 PHY interface modes should be populated.
16
17 Fixes: d1cb613efbd3 ("net: phy: qcom: add support for QCA807x PHY Family")
18 Signed-off-by: Robert Marko <robimarko@gmail.com>
19 ---
20 drivers/net/phy/qcom/qca807x.c | 10 +++++-----
21 1 file changed, 5 insertions(+), 5 deletions(-)
22
23 --- a/drivers/net/phy/qcom/qca807x.c
24 +++ b/drivers/net/phy/qcom/qca807x.c
25 @@ -562,6 +562,11 @@ static int qca807x_phy_package_config_in
26 struct qca807x_shared_priv *priv = shared->priv;
27 int val, ret;
28
29 + /* Make sure PHY follow PHY package mode if enforced */
30 + if (priv->package_mode != PHY_INTERFACE_MODE_NA &&
31 + phydev->interface != priv->package_mode)
32 + return -EINVAL;
33 +
34 phy_lock_mdio_bus(phydev);
35
36 /* Set correct PHY package mode */
37 @@ -718,11 +723,6 @@ static int qca807x_probe(struct phy_devi
38 shared = phydev->shared;
39 shared_priv = shared->priv;
40
41 - /* Make sure PHY follow PHY package mode if enforced */
42 - if (shared_priv->package_mode != PHY_INTERFACE_MODE_NA &&
43 - phydev->interface != shared_priv->package_mode)
44 - return -EINVAL;
45 -
46 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
47 if (!priv)
48 return -ENOMEM;