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

dpaa2-eth: fix an always true condition in dpaa2_mac_get_if_mode

Convert the phy_mode() function to return the if_mode through an
argument, similar to the new form of of_get_phy_mode().
This will help with handling errors in a common manner and also will fix
an always true condition.

Fixes: 0c65b2b90d13 ("net: of_get_phy_mode: Change API to solve int/unit warnings")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Ioana Ciornei and committed by
David S. Miller
226df3ef 90ce9f23

+10 -5
+10 -5
drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
··· 7 7 #define phylink_to_dpaa2_mac(config) \ 8 8 container_of((config), struct dpaa2_mac, phylink_config) 9 9 10 - static phy_interface_t phy_mode(enum dpmac_eth_if eth_if) 10 + static int phy_mode(enum dpmac_eth_if eth_if, phy_interface_t *if_mode) 11 11 { 12 + *if_mode = PHY_INTERFACE_MODE_NA; 13 + 12 14 switch (eth_if) { 13 15 case DPMAC_ETH_IF_RGMII: 14 - return PHY_INTERFACE_MODE_RGMII; 16 + *if_mode = PHY_INTERFACE_MODE_RGMII; 17 + break; 15 18 default: 16 19 return -EINVAL; 17 20 } 21 + 22 + return 0; 18 23 } 19 24 20 25 /* Caller must call of_node_put on the returned value */ ··· 56 51 if (!err) 57 52 return if_mode; 58 53 59 - if_mode = phy_mode(attr.eth_if); 60 - if (if_mode >= 0) 54 + err = phy_mode(attr.eth_if, &if_mode); 55 + if (!err) 61 56 return if_mode; 62 57 63 - return -ENODEV; 58 + return err; 64 59 } 65 60 66 61 static bool dpaa2_mac_phy_mode_mismatch(struct dpaa2_mac *mac,