Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: phy: nxp-c45-tja11xx: fix the PHY ID mismatch issue when using C45

TJA1103/04/20/21 support both C22 and C45 accessing methods.

The TJA11xx driver has implemented the match_phy_device() API.
However, it does not handle the C45 ID. If C45 was used to access
TJA11xx, match_phy_device() would always return false due to
phydev->phy_id only used by C22 being empty, resulting in the
generic phy driver being used for TJA11xx PHYs.

Therefore, check phydev->c45_ids.device_ids[MDIO_MMD_PMAPMD] when
using C45.

Fixes: 1b76b2497aba ("net: phy: nxp-c45-tja11xx: simplify .match_phy_device OP")
Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>
Link: https://patch.msgid.link/20250807040832.2455306-1-xiaoning.wang@nxp.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Clark Wang and committed by
Paolo Abeni
8ee90742 89886abd

+13 -10
+13 -10
drivers/net/phy/nxp-c45-tja11xx.c
··· 1965 1965 return macsec_ability; 1966 1966 } 1967 1967 1968 + static bool tja11xx_phy_id_compare(struct phy_device *phydev, 1969 + const struct phy_driver *phydrv) 1970 + { 1971 + u32 id = phydev->is_c45 ? phydev->c45_ids.device_ids[MDIO_MMD_PMAPMD] : 1972 + phydev->phy_id; 1973 + 1974 + return phy_id_compare(id, phydrv->phy_id, phydrv->phy_id_mask); 1975 + } 1976 + 1968 1977 static int tja11xx_no_macsec_match_phy_device(struct phy_device *phydev, 1969 1978 const struct phy_driver *phydrv) 1970 1979 { 1971 - if (!phy_id_compare(phydev->phy_id, phydrv->phy_id, 1972 - phydrv->phy_id_mask)) 1973 - return 0; 1974 - 1975 - return !nxp_c45_macsec_ability(phydev); 1980 + return tja11xx_phy_id_compare(phydev, phydrv) && 1981 + !nxp_c45_macsec_ability(phydev); 1976 1982 } 1977 1983 1978 1984 static int tja11xx_macsec_match_phy_device(struct phy_device *phydev, 1979 1985 const struct phy_driver *phydrv) 1980 1986 { 1981 - if (!phy_id_compare(phydev->phy_id, phydrv->phy_id, 1982 - phydrv->phy_id_mask)) 1983 - return 0; 1984 - 1985 - return nxp_c45_macsec_ability(phydev); 1987 + return tja11xx_phy_id_compare(phydev, phydrv) && 1988 + nxp_c45_macsec_ability(phydev); 1986 1989 } 1987 1990 1988 1991 static const struct nxp_c45_regmap tja1120_regmap = {