net: of_get_phy_mode: Change API to solve int/unit warnings
authorAndrew Lunn <andrew@lunn.ch>
Mon, 4 Nov 2019 01:40:33 +0000 (02:40 +0100)
committerDavid S. Miller <davem@davemloft.net>
Mon, 4 Nov 2019 19:21:25 +0000 (11:21 -0800)
Before this change of_get_phy_mode() returned an enum,
phy_interface_t. On error, -ENODEV etc, is returned. If the result of
the function is stored in a variable of type phy_interface_t, and the
compiler has decided to represent this as an unsigned int, comparision
with -ENODEV etc, is a signed vs unsigned comparision.

Fix this problem by changing the API. Make the function return an
error, or 0 on success, and pass a pointer, of type phy_interface_t,
where the phy mode should be stored.

v2:
Return with *interface set to PHY_INTERFACE_MODE_NA on error.
Add error checks to all users of of_get_phy_mode()
Fixup a few reverse christmas tree errors
Fixup a few slightly malformed reverse christmas trees

v3:
Fix 0-day reported errors.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
53 files changed:
drivers/net/dsa/bcm_sf2.c
drivers/net/dsa/microchip/ksz_common.c
drivers/net/dsa/mt7530.c
drivers/net/dsa/qca8k.c
drivers/net/dsa/sja1105/sja1105_main.c
drivers/net/ethernet/altera/altera_tse_main.c
drivers/net/ethernet/arc/emac_arc.c
drivers/net/ethernet/arc/emac_rockchip.c
drivers/net/ethernet/atheros/ag71xx.c
drivers/net/ethernet/aurora/nb8800.c
drivers/net/ethernet/aurora/nb8800.h
drivers/net/ethernet/broadcom/bcmsysport.c
drivers/net/ethernet/broadcom/genet/bcmmii.c
drivers/net/ethernet/cadence/macb_main.c
drivers/net/ethernet/faraday/ftgmac100.c
drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
drivers/net/ethernet/freescale/enetc/enetc_pf.c
drivers/net/ethernet/freescale/fec_main.c
drivers/net/ethernet/freescale/fman/mac.c
drivers/net/ethernet/freescale/gianfar.c
drivers/net/ethernet/hisilicon/hip04_eth.c
drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
drivers/net/ethernet/ibm/emac/core.c
drivers/net/ethernet/marvell/mv643xx_eth.c
drivers/net/ethernet/marvell/mvneta.c
drivers/net/ethernet/marvell/pxa168_eth.c
drivers/net/ethernet/mediatek/mtk_eth_soc.c
drivers/net/ethernet/mscc/ocelot_board.c
drivers/net/ethernet/ni/nixge.c
drivers/net/ethernet/renesas/ravb_main.c
drivers/net/ethernet/renesas/sh_eth.c
drivers/net/ethernet/samsung/sxgbe/sxgbe_platform.c
drivers/net/ethernet/socionext/sni_ave.c
drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c
drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c
drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c
drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c
drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
drivers/net/ethernet/ti/cpsw.c
drivers/net/ethernet/ti/cpsw_priv.h
drivers/net/ethernet/ti/netcp_ethss.c
drivers/net/ethernet/xilinx/xilinx_axienet_main.c
drivers/of/of_mdio.c
drivers/of/of_net.c
include/linux/of_net.h
include/linux/stmmac.h
include/linux/sxgbe_platform.h
net/dsa/port.c
net/dsa/slave.c

index 9add84c79dd6901d6d1bfaa8c557638b9fe32e57..67125a5487e124892e4190f286b7c6e121ebf03b 100644 (file)
@@ -381,8 +381,9 @@ static void bcm_sf2_identify_ports(struct bcm_sf2_priv *priv,
                                   struct device_node *dn)
 {
        struct device_node *port;
-       int mode;
        unsigned int port_num;
+       phy_interface_t mode;
+       int err;
 
        priv->moca_port = -1;
 
@@ -395,8 +396,8 @@ static void bcm_sf2_identify_ports(struct bcm_sf2_priv *priv,
                 * has completed, since they might be turned off at that
                 * time
                 */
-               mode = of_get_phy_mode(port);
-               if (mode < 0)
+               err = of_get_phy_mode(port, &mode);
+               if (err)
                        continue;
 
                if (mode == PHY_INTERFACE_MODE_INTERNAL)
index 5d08e44308249164d96020162f23ccf848c78f27..d8fda4a02640e0cdf4f592f25a135b9f3b7d9b6b 100644 (file)
@@ -422,6 +422,7 @@ EXPORT_SYMBOL(ksz_switch_alloc);
 int ksz_switch_register(struct ksz_device *dev,
                        const struct ksz_dev_ops *ops)
 {
+       phy_interface_t interface;
        int ret;
 
        if (dev->pdata)
@@ -456,9 +457,9 @@ int ksz_switch_register(struct ksz_device *dev,
         * device tree.
         */
        if (dev->dev->of_node) {
-               ret = of_get_phy_mode(dev->dev->of_node);
-               if (ret >= 0)
-                       dev->interface = ret;
+               ret = of_get_phy_mode(dev->dev->of_node, &interface);
+               if (ret == 0)
+                       dev->interface = interface;
                dev->synclko_125 = of_property_read_bool(dev->dev->of_node,
                                                         "microchip,synclko-125");
        }
index add9e42791763be7182ee32d1aa1d70a9fcaa9b7..ed1ec10ec62b294d9652fff417fcb1ac407979dc 100644 (file)
@@ -1340,7 +1340,9 @@ mt7530_setup(struct dsa_switch *ds)
 
        if (!dsa_is_unused_port(ds, 5)) {
                priv->p5_intf_sel = P5_INTF_SEL_GMAC5;
-               interface = of_get_phy_mode(dsa_to_port(ds, 5)->dn);
+               ret = of_get_phy_mode(dsa_to_port(ds, 5)->dn, &interface);
+               if (ret && ret != -ENODEV)
+                       return ret;
        } else {
                /* Scan the ethernet nodes. look for GMAC1, lookup used phy */
                for_each_child_of_node(dn, mac_np) {
@@ -1354,7 +1356,9 @@ mt7530_setup(struct dsa_switch *ds)
 
                        phy_node = of_parse_phandle(mac_np, "phy-handle", 0);
                        if (phy_node->parent == priv->dev->of_node->parent) {
-                               interface = of_get_phy_mode(mac_np);
+                               ret = of_get_phy_mode(mac_np, &interface);
+                               if (ret && ret != -ENODEV)
+                                       return ret;
                                id = of_mdio_parse_addr(ds->dev, phy_node);
                                if (id == 0)
                                        priv->p5_intf_sel = P5_INTF_SEL_PHY_P0;
index 36c6ed98f8e7cd9d330fe462bbe01606192632dd..e548289df31eec11cff3b95c87e37a4c755280d1 100644 (file)
@@ -639,7 +639,8 @@ static int
 qca8k_setup(struct dsa_switch *ds)
 {
        struct qca8k_priv *priv = (struct qca8k_priv *)ds->priv;
-       int ret, i, phy_mode = -1;
+       phy_interface_t phy_mode = PHY_INTERFACE_MODE_NA;
+       int ret, i;
        u32 mask;
 
        /* Make sure that port 0 is the cpu port */
@@ -661,10 +662,10 @@ qca8k_setup(struct dsa_switch *ds)
                return ret;
 
        /* Initialize CPU port pad mode (xMII type, delays...) */
-       phy_mode = of_get_phy_mode(dsa_to_port(ds, QCA8K_CPU_PORT)->dn);
-       if (phy_mode < 0) {
+       ret = of_get_phy_mode(dsa_to_port(ds, QCA8K_CPU_PORT)->dn, &phy_mode);
+       if (ret) {
                pr_err("Can't find phy-mode for master device\n");
-               return phy_mode;
+               return ret;
        }
        ret = qca8k_set_pad_ctrl(priv, QCA8K_CPU_PORT, phy_mode);
        if (ret < 0)
index 2ae84a9dea59a01a707f5bcf1ca0d5ef33be85df..d5dfda335aa160b69680175e194f3767875111a0 100644 (file)
@@ -584,8 +584,9 @@ static int sja1105_parse_ports_node(struct sja1105_private *priv,
 
        for_each_child_of_node(ports_node, child) {
                struct device_node *phy_node;
-               int phy_mode;
+               phy_interface_t phy_mode;
                u32 index;
+               int err;
 
                /* Get switch port number from DT */
                if (of_property_read_u32(child, "reg", &index) < 0) {
@@ -596,8 +597,8 @@ static int sja1105_parse_ports_node(struct sja1105_private *priv,
                }
 
                /* Get PHY mode from DT */
-               phy_mode = of_get_phy_mode(child);
-               if (phy_mode < 0) {
+               err = of_get_phy_mode(child, &phy_mode);
+               if (err) {
                        dev_err(dev, "Failed to read phy-mode or "
                                "phy-interface-type property for port %d\n",
                                index);
index bb032be7fe31edf950f04754608bec104e885665..4cd53fc338b5da69a93c01fa4510f868294a5fa2 100644 (file)
@@ -730,12 +730,12 @@ static int altera_tse_phy_get_addr_mdio_create(struct net_device *dev)
 {
        struct altera_tse_private *priv = netdev_priv(dev);
        struct device_node *np = priv->device->of_node;
-       int ret = 0;
+       int ret;
 
-       priv->phy_iface = of_get_phy_mode(np);
+       ret = of_get_phy_mode(np, &priv->phy_iface);
 
        /* Avoid get phy addr and create mdio if no phy is present */
-       if (!priv->phy_iface)
+       if (ret)
                return 0;
 
        /* try to get PHY address from device tree, use PHY autodetection if
index 78e52d217e56faa8575e3348bbe90b99e0df4a83..5391661129931c938aa7b190e5714a1de8aa5db4 100644 (file)
 static int emac_arc_probe(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
-       struct net_device *ndev;
        struct arc_emac_priv *priv;
-       int interface, err;
+       phy_interface_t interface;
+       struct net_device *ndev;
+       int err;
 
        if (!dev->of_node)
                return -ENODEV;
@@ -37,9 +38,13 @@ static int emac_arc_probe(struct platform_device *pdev)
        priv->drv_name = DRV_NAME;
        priv->drv_version = DRV_VERSION;
 
-       interface = of_get_phy_mode(dev->of_node);
-       if (interface < 0)
-               interface = PHY_INTERFACE_MODE_MII;
+       err = of_get_phy_mode(dev->of_node, &interface);
+       if (err) {
+               if (err == -ENODEV)
+                       interface = PHY_INTERFACE_MODE_MII;
+               else
+                       goto out_netdev;
+       }
 
        priv->clk = devm_clk_get(dev, "hclk");
        if (IS_ERR(priv->clk)) {
index 664d664e09250ef94167485fe52914005de99e4d..aae231c5224fe8d99e5a11e14da4c6310f6a7fe6 100644 (file)
@@ -97,8 +97,9 @@ static int emac_rockchip_probe(struct platform_device *pdev)
        struct net_device *ndev;
        struct rockchip_priv_data *priv;
        const struct of_device_id *match;
+       phy_interface_t interface;
        u32 data;
-       int err, interface;
+       int err;
 
        if (!pdev->dev.of_node)
                return -ENODEV;
@@ -114,7 +115,9 @@ static int emac_rockchip_probe(struct platform_device *pdev)
        priv->emac.drv_version = DRV_VERSION;
        priv->emac.set_mac_speed = emac_rockchip_set_mac_speed;
 
-       interface = of_get_phy_mode(dev->of_node);
+       err = of_get_phy_mode(dev->of_node, &interface);
+       if (err)
+               goto out_netdev;
 
        /* RK3036/RK3066/RK3188 SoCs only support RMII */
        if (interface != PHY_INTERFACE_MODE_RMII) {
index 1b1a09095c0dcfc3a40d127d306349e4ec690b26..8f5021091eeed5a138ed33056e0e71ee23912012 100644 (file)
@@ -1744,10 +1744,9 @@ static int ag71xx_probe(struct platform_device *pdev)
                eth_random_addr(ndev->dev_addr);
        }
 
-       ag->phy_if_mode = of_get_phy_mode(np);
-       if (ag->phy_if_mode < 0) {
+       err = of_get_phy_mode(np, ag->phy_if_mode);
+       if (err) {
                netif_err(ag, probe, ndev, "missing phy-mode property in DT\n");
-               err = ag->phy_if_mode;
                goto err_free;
        }
 
index 37752d9514e7f3596b6b62420743f1f319436f27..30b455013bf3d193c97feae1388947947ec91c8a 100644 (file)
@@ -1371,8 +1371,8 @@ static int nb8800_probe(struct platform_device *pdev)
        priv = netdev_priv(dev);
        priv->base = base;
 
-       priv->phy_mode = of_get_phy_mode(pdev->dev.of_node);
-       if (priv->phy_mode < 0)
+       ret = of_get_phy_mode(pdev->dev.of_node, &priv->phy_mode);
+       if (ret)
                priv->phy_mode = PHY_INTERFACE_MODE_RGMII;
 
        priv->clk = devm_clk_get(&pdev->dev, NULL);
index aacc3cce2cc02325820d9fdf7469b5fbaba25ee4..40941fb6065bc537af2194e2305ddd3bb6e100e3 100644 (file)
@@ -287,7 +287,7 @@ struct nb8800_priv {
        struct device_node              *phy_node;
 
        /* PHY connection type from DT */
-       int                             phy_mode;
+       phy_interface_t                 phy_mode;
 
        /* Current link status */
        int                             speed;
index a977a459bd20daffb5a0a3b81126480449979080..825af709708ef7674795158be92fa7fb01fab303 100644 (file)
@@ -2479,9 +2479,9 @@ static int bcm_sysport_probe(struct platform_device *pdev)
        priv->netdev = dev;
        priv->pdev = pdev;
 
-       priv->phy_interface = of_get_phy_mode(dn);
+       ret = of_get_phy_mode(dn, &priv->phy_interface);
        /* Default to GMII interface mode */
-       if ((int)priv->phy_interface < 0)
+       if (ret)
                priv->phy_interface = PHY_INTERFACE_MODE_GMII;
 
        /* In the case of a fixed PHY, the DT node associated
index 17bb8d60a157cb4da2a792521c9bcb8aa97b851d..b797a7e59a53608f50d5587e38f7d1292592b96f 100644 (file)
@@ -436,7 +436,7 @@ static int bcmgenet_mii_of_init(struct bcmgenet_priv *priv)
        struct device_node *dn = priv->pdev->dev.of_node;
        struct device *kdev = &priv->pdev->dev;
        struct phy_device *phydev;
-       int phy_mode;
+       phy_interface_t phy_mode;
        int ret;
 
        /* Fetch the PHY phandle */
@@ -454,10 +454,10 @@ static int bcmgenet_mii_of_init(struct bcmgenet_priv *priv)
        }
 
        /* Get the link mode */
-       phy_mode = of_get_phy_mode(dn);
-       if (phy_mode < 0) {
+       ret = of_get_phy_mode(dn, &phy_mode);
+       if (ret) {
                dev_err(kdev, "invalid PHY mode property\n");
-               return phy_mode;
+               return ret;
        }
 
        priv->phy_interface = phy_mode;
index 1e1b774e19536611f54b641068bbfda9925c5601..b884cf7f339bc1dca864c2d500b5991051805e8e 100644 (file)
@@ -4182,6 +4182,7 @@ static int macb_probe(struct platform_device *pdev)
        unsigned int queue_mask, num_queues;
        bool native_io;
        struct phy_device *phydev;
+       phy_interface_t interface;
        struct net_device *dev;
        struct resource *regs;
        void __iomem *mem;
@@ -4308,12 +4309,12 @@ static int macb_probe(struct platform_device *pdev)
                macb_get_hwaddr(bp);
        }
 
-       err = of_get_phy_mode(np);
-       if (err < 0)
+       err = of_get_phy_mode(np, &interface);
+       if (err)
                /* not found in DT, MII by default */
                bp->phy_interface = PHY_INTERFACE_MODE_MII;
        else
-               bp->phy_interface = err;
+               bp->phy_interface = interface;
 
        /* IP specific init */
        err = init(pdev);
index da0c506349d133d4af0b39f2ce9bcdae4a71e48b..a6f2063f147545bfd86a65a6540dbc5044fbda94 100644 (file)
@@ -1612,7 +1612,7 @@ static int ftgmac100_setup_mdio(struct net_device *netdev)
 {
        struct ftgmac100 *priv = netdev_priv(netdev);
        struct platform_device *pdev = to_platform_device(priv->dev);
-       int phy_intf = PHY_INTERFACE_MODE_RGMII;
+       phy_interface_t phy_intf = PHY_INTERFACE_MODE_RGMII;
        struct device_node *np = pdev->dev.of_node;
        int i, err = 0;
        u32 reg;
@@ -1637,8 +1637,8 @@ static int ftgmac100_setup_mdio(struct net_device *netdev)
        /* Get PHY mode from device-tree */
        if (np) {
                /* Default to RGMII. It's a gigabit part after all */
-               phy_intf = of_get_phy_mode(np);
-               if (phy_intf < 0)
+               err = of_get_phy_mode(np, &phy_intf);
+               if (err)
                        phy_intf = PHY_INTERFACE_MODE_RGMII;
 
                /* Aspeed only supports these. I don't know about other IP
index fea388d86f20a06a439eb1b15a0219df56467157..b713739f4804a9519b2fe7cee4d24fd2aaa608ec 100644 (file)
@@ -44,10 +44,11 @@ static struct device_node *dpaa2_mac_get_node(u16 dpmac_id)
 static int dpaa2_mac_get_if_mode(struct device_node *node,
                                 struct dpmac_attr attr)
 {
-       int if_mode;
+       phy_interface_t if_mode;
+       int err;
 
-       if_mode = of_get_phy_mode(node);
-       if (if_mode >= 0)
+       err = of_get_phy_mode(node, &if_mode);
+       if (!err)
                return if_mode;
 
        if_mode = phy_mode(attr.eth_if);
index b73421c3e25b17fe9fcac66b138fb722bf4d46ae..7da79b816416106a439184dc98ef5239a4a6d844 100644 (file)
@@ -784,8 +784,8 @@ static int enetc_of_get_phy(struct enetc_ndev_priv *priv)
                }
        }
 
-       priv->if_mode = of_get_phy_mode(np);
-       if ((int)priv->if_mode < 0) {
+       err = of_get_phy_mode(np, &priv->if_mode);
+       if (err) {
                dev_err(priv->dev, "missing phy type\n");
                of_node_put(priv->phy_node);
                if (of_phy_is_fixed_link(np))
index 7d37ba9f68199beebbbaea0a4898882c1a202e63..d4d6c2e941f169790d062dabf3ec129384508fd2 100644 (file)
@@ -3393,6 +3393,7 @@ fec_probe(struct platform_device *pdev)
 {
        struct fec_enet_private *fep;
        struct fec_platform_data *pdata;
+       phy_interface_t interface;
        struct net_device *ndev;
        int i, irq, ret = 0;
        const struct of_device_id *of_id;
@@ -3465,15 +3466,15 @@ fec_probe(struct platform_device *pdev)
        }
        fep->phy_node = phy_node;
 
-       ret = of_get_phy_mode(pdev->dev.of_node);
-       if (ret < 0) {
+       ret = of_get_phy_mode(pdev->dev.of_node, &interface);
+       if (ret) {
                pdata = dev_get_platdata(&pdev->dev);
                if (pdata)
                        fep->phy_interface = pdata->phy;
                else
                        fep->phy_interface = PHY_INTERFACE_MODE_MII;
        } else {
-               fep->phy_interface = ret;
+               fep->phy_interface = interface;
        }
 
        fep->clk_ipg = devm_clk_get(&pdev->dev, "ipg");
index 7ab8095db1928a68a36810161d644b0b0b60c260..f0806ace1ae29ea1202af6fcfadf5c1eb1d8d046 100644 (file)
@@ -608,7 +608,7 @@ static int mac_probe(struct platform_device *_of_dev)
        const u8                *mac_addr;
        u32                      val;
        u8                      fman_id;
-       int                     phy_if;
+       phy_interface_t          phy_if;
 
        dev = &_of_dev->dev;
        mac_node = dev->of_node;
@@ -776,8 +776,8 @@ static int mac_probe(struct platform_device *_of_dev)
        }
 
        /* Get the PHY connection type */
-       phy_if = of_get_phy_mode(mac_node);
-       if (phy_if < 0) {
+       err = of_get_phy_mode(mac_node, &phy_if);
+       if (err) {
                dev_warn(dev,
                         "of_get_phy_mode() for %pOF failed. Defaulting to SGMII\n",
                         mac_node);
index 51ad86417cb13b3d3034e3ff321c8cf0f0a73001..72868a28b621d29c4fe0347776300c9e9f0f68e5 100644 (file)
@@ -641,6 +641,7 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev)
        const char *model;
        const void *mac_addr;
        int err = 0, i;
+       phy_interface_t interface;
        struct net_device *dev = NULL;
        struct gfar_private *priv = NULL;
        struct device_node *np = ofdev->dev.of_node;
@@ -805,9 +806,9 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev)
         * rgmii-id really needs to be specified. Other types can be
         * detected by hardware
         */
-       err = of_get_phy_mode(np);
-       if (err >= 0)
-               priv->interface = err;
+       err = of_get_phy_mode(np, &interface);
+       if (!err)
+               priv->interface = interface;
        else
                priv->interface = gfar_get_interface(dev);
 
index 4606a7e4a6d19a2471adb6cdb2f2c5f810bc8c37..3e9b6d543c77072b97bccc7aeb374a5eacdc69a3 100644 (file)
@@ -211,7 +211,7 @@ struct hip04_priv {
 #if defined(CONFIG_HI13X1_GMAC)
        void __iomem *sysctrl_base;
 #endif
-       int phy_mode;
+       phy_interface_t phy_mode;
        int chan;
        unsigned int port;
        unsigned int group;
@@ -961,10 +961,9 @@ static int hip04_mac_probe(struct platform_device *pdev)
                goto init_fail;
        }
 
-       priv->phy_mode = of_get_phy_mode(node);
-       if (priv->phy_mode < 0) {
+       ret = of_get_phy_mode(node, &priv->phy_mode);
+       if (ret) {
                dev_warn(d, "not find phy-mode\n");
-               ret = -EINVAL;
                goto init_fail;
        }
 
index c41b19c760f8d5d5e22b22299139f6f0b9b13e72..247de9105d108d69c08b92ce40fdabbddf38f53b 100644 (file)
@@ -1193,10 +1193,9 @@ static int hix5hd2_dev_probe(struct platform_device *pdev)
        if (ret)
                goto err_free_mdio;
 
-       priv->phy_mode = of_get_phy_mode(node);
-       if ((int)priv->phy_mode < 0) {
+       ret = of_get_phy_mode(node, &priv->phy_mode);
+       if (ret) {
                netdev_err(ndev, "not find phy-mode\n");
-               ret = -EINVAL;
                goto err_mdiobus;
        }
 
index 9e43c9ace9c27a52cf5acd9c40895901f9ec8584..2e40425d8a34efc2f7cfcff4647cd38b0d6d7b15 100644 (file)
@@ -2849,6 +2849,7 @@ static int emac_init_config(struct emac_instance *dev)
 {
        struct device_node *np = dev->ofdev->dev.of_node;
        const void *p;
+       int err;
 
        /* Read config from device-tree */
        if (emac_read_uint_prop(np, "mal-device", &dev->mal_ph, 1))
@@ -2897,8 +2898,8 @@ static int emac_init_config(struct emac_instance *dev)
                dev->mal_burst_size = 256;
 
        /* PHY mode needs some decoding */
-       dev->phy_mode = of_get_phy_mode(np);
-       if (dev->phy_mode < 0)
+       err = of_get_phy_mode(np, &dev->phy_mode);
+       if (err)
                dev->phy_mode = PHY_INTERFACE_MODE_NA;
 
        /* Check EMAC version */
index 82ea55ae5053da4e7124a3769e04cb27874fdcb9..d5b644131cff5cba613157b3d85f665f2a29d8a5 100644 (file)
@@ -2959,15 +2959,16 @@ static void set_params(struct mv643xx_eth_private *mp,
 static int get_phy_mode(struct mv643xx_eth_private *mp)
 {
        struct device *dev = mp->dev->dev.parent;
-       int iface = -1;
+       phy_interface_t iface;
+       int err;
 
        if (dev->of_node)
-               iface = of_get_phy_mode(dev->of_node);
+               err = of_get_phy_mode(dev->of_node, &iface);
 
        /* Historical default if unspecified. We could also read/write
         * the interface state in the PSC1
         */
-       if (iface < 0)
+       if (!dev->of_node || err)
                iface = PHY_INTERFACE_MODE_GMII;
        return iface;
 }
index 8f9df6efda610bbda98a5c7056079a0593202244..274ac39c0f0f6a73017a4dfa946a53f1c438e215 100644 (file)
@@ -4797,9 +4797,9 @@ static int mvneta_probe(struct platform_device *pdev)
        struct phy *comphy;
        const char *dt_mac_addr;
        char hw_mac_addr[ETH_ALEN];
+       phy_interface_t phy_mode;
        const char *mac_from;
        int tx_csum_limit;
-       int phy_mode;
        int err;
        int cpu;
 
@@ -4812,10 +4812,9 @@ static int mvneta_probe(struct platform_device *pdev)
        if (dev->irq == 0)
                return -EINVAL;
 
-       phy_mode = of_get_phy_mode(dn);
-       if (phy_mode < 0) {
+       err = of_get_phy_mode(dn, &phy_mode);
+       if (err) {
                dev_err(&pdev->dev, "incorrect phy-mode\n");
-               err = -EINVAL;
                goto err_free_irq;
        }
 
index 51b77c2de400aa0b646c31fc24471bee2f9053ec..3fb7ee3d4d13f4d74823a6210e3265f0d984c617 100644 (file)
@@ -1489,8 +1489,10 @@ static int pxa168_eth_probe(struct platform_device *pdev)
                        goto err_netdev;
                }
                of_property_read_u32(np, "reg", &pep->phy_addr);
-               pep->phy_intf = of_get_phy_mode(pdev->dev.of_node);
                of_node_put(np);
+               err = of_get_phy_mode(pdev->dev.of_node, &pep->phy_intf);
+               if (err && err != -ENODEV)
+                       goto err_netdev;
        }
 
        /* Hardware supports only 3 ports */
index 703adb96429e24abe453e681f6f815ba1fb526de..385a4ab9ec9949ec30f5415df40a32152ff870d8 100644 (file)
@@ -2758,9 +2758,10 @@ static const struct net_device_ops mtk_netdev_ops = {
 static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np)
 {
        const __be32 *_id = of_get_property(np, "reg", NULL);
+       phy_interface_t phy_mode;
        struct phylink *phylink;
-       int phy_mode, id, err;
        struct mtk_mac *mac;
+       int id, err;
 
        if (!_id) {
                dev_err(eth->dev, "missing mac id\n");
@@ -2805,10 +2806,9 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np)
        mac->hw_stats->reg_offset = id * MTK_STAT_OFFSET;
 
        /* phylink create */
-       phy_mode = of_get_phy_mode(np);
-       if (phy_mode < 0) {
+       err = of_get_phy_mode(np, &phy_mode);
+       if (err) {
                dev_err(eth->dev, "incorrect phy-mode\n");
-               err = -EINVAL;
                goto free_netdev;
        }
 
index aac115136720f2611c12df013748613b78f0139e..723724bdc1392ad90c6a3e88975e9761527b3887 100644 (file)
@@ -364,12 +364,12 @@ static int mscc_ocelot_probe(struct platform_device *pdev)
 
        for_each_available_child_of_node(ports, portnp) {
                struct device_node *phy_node;
+               phy_interface_t phy_mode;
                struct phy_device *phy;
                struct resource *res;
                struct phy *serdes;
                void __iomem *regs;
                char res_name[8];
-               int phy_mode;
                u32 port;
 
                if (of_property_read_u32(portnp, "reg", &port))
@@ -398,11 +398,11 @@ static int mscc_ocelot_probe(struct platform_device *pdev)
                        goto out_put_ports;
                }
 
-               phy_mode = of_get_phy_mode(portnp);
-               if (phy_mode < 0)
-                       ocelot->ports[port]->phy_mode = PHY_INTERFACE_MODE_NA;
-               else
-                       ocelot->ports[port]->phy_mode = phy_mode;
+               err = of_get_phy_mode(portnp, &phy_mode);
+               if (err && err != -ENODEV)
+                       goto out_put_ports;
+
+               ocelot->ports[port]->phy_mode = phy_mode;
 
                switch (ocelot->ports[port]->phy_mode) {
                case PHY_INTERFACE_MODE_NA:
index 2761f3a3ae50886cd2688cd03a51f5e5915dc298..49c7987c2abd23a1bc04966c3e42146f3e325751 100644 (file)
@@ -1346,10 +1346,9 @@ static int nixge_probe(struct platform_device *pdev)
                }
        }
 
-       priv->phy_mode = of_get_phy_mode(pdev->dev.of_node);
-       if ((int)priv->phy_mode < 0) {
+       err = of_get_phy_mode(pdev->dev.of_node, &priv->phy_mode);
+       if (err) {
                netdev_err(ndev, "not find \"phy-mode\" property\n");
-               err = -EINVAL;
                goto unregister_mdio;
        }
 
index de9aa8c47f1c1508eb1bcc9376e30d804c31bf47..5ea14b5fbed842a925fe3dcc2bd6bf09784fb0cb 100644 (file)
@@ -2046,7 +2046,9 @@ static int ravb_probe(struct platform_device *pdev)
        spin_lock_init(&priv->lock);
        INIT_WORK(&priv->work, ravb_tx_timeout_work);
 
-       priv->phy_interface = of_get_phy_mode(np);
+       error = of_get_phy_mode(np, &priv->phy_interface);
+       if (error && error != -ENODEV)
+               goto out_release;
 
        priv->no_avb_link = of_property_read_bool(np, "renesas,no-ether-link");
        priv->avb_link_active_low =
index 7ba35a0bdb2922ca54cab2276ff7174a76e3e9fd..e19b49c4013ed321e53c0bc684676697342be6b8 100644 (file)
@@ -3183,6 +3183,7 @@ static struct sh_eth_plat_data *sh_eth_parse_dt(struct device *dev)
 {
        struct device_node *np = dev->of_node;
        struct sh_eth_plat_data *pdata;
+       phy_interface_t interface;
        const char *mac_addr;
        int ret;
 
@@ -3190,10 +3191,10 @@ static struct sh_eth_plat_data *sh_eth_parse_dt(struct device *dev)
        if (!pdata)
                return NULL;
 
-       ret = of_get_phy_mode(np);
-       if (ret < 0)
+       ret = of_get_phy_mode(np, &interface);
+       if (ret)
                return NULL;
-       pdata->phy_interface = ret;
+       pdata->phy_interface = interface;
 
        mac_addr = of_get_mac_address(np);
        if (!IS_ERR(mac_addr))
index 2412c87561e00f3796a060490b4e305c511888df..33f79402850d4fb4f252500eb96046c90a54e810 100644 (file)
@@ -30,12 +30,15 @@ static int sxgbe_probe_config_dt(struct platform_device *pdev,
 {
        struct device_node *np = pdev->dev.of_node;
        struct sxgbe_dma_cfg *dma_cfg;
+       int err;
 
        if (!np)
                return -ENODEV;
 
        *mac = of_get_mac_address(np);
-       plat->interface = of_get_phy_mode(np);
+       err = of_get_phy_mode(np, &plat->interface);
+       if (err && err != -ENODEV)
+               return err;
 
        plat->bus_id = of_alias_get_id(np, "ethernet");
        if (plat->bus_id < 0)
index 6e984d5a729fe9d0ea176b0cb87313e94a18a616..f7e927ad67fac36ec5c02eaeeb0972a39b351a7b 100644 (file)
@@ -1565,10 +1565,10 @@ static int ave_probe(struct platform_device *pdev)
                return -EINVAL;
 
        np = dev->of_node;
-       phy_mode = of_get_phy_mode(np);
-       if ((int)phy_mode < 0) {
+       ret = of_get_phy_mode(np, &phy_mode);
+       if (ret) {
                dev_err(dev, "phy-mode not found\n");
-               return -EINVAL;
+               return ret;
        }
 
        irq = platform_get_irq(pdev, 0);
index 527f93320a5aebb2fe18ea75e0d76085c28e0fec..d0d2d0fc5f0a9a78da74c9f4c042b3de631fdd29 100644 (file)
@@ -61,9 +61,10 @@ static void anarion_gmac_exit(struct platform_device *pdev, void *priv)
 
 static struct anarion_gmac *anarion_config_dt(struct platform_device *pdev)
 {
-       int phy_mode;
-       void __iomem *ctl_block;
        struct anarion_gmac *gmac;
+       phy_interface_t phy_mode;
+       void __iomem *ctl_block;
+       int err;
 
        ctl_block = devm_platform_ioremap_resource(pdev, 1);
        if (IS_ERR(ctl_block)) {
@@ -78,7 +79,10 @@ static struct anarion_gmac *anarion_config_dt(struct platform_device *pdev)
 
        gmac->ctl_block = (uintptr_t)ctl_block;
 
-       phy_mode = of_get_phy_mode(pdev->dev.of_node);
+       err = of_get_phy_mode(pdev->dev.of_node, &phy_mode);
+       if (err)
+               return ERR_PTR(err);
+
        switch (phy_mode) {
        case PHY_INTERFACE_MODE_RGMII:          /* Fall through */
        case PHY_INTERFACE_MODE_RGMII_ID        /* Fall through */:
index 0d21082ceb93d1d0b0e2fb1e7edbb6653ab76385..6ae13dc195105571e9ac572fc268d103ef9b8f09 100644 (file)
@@ -189,9 +189,10 @@ static int ipq806x_gmac_set_speed(struct ipq806x_gmac *gmac, unsigned int speed)
 static int ipq806x_gmac_of_parse(struct ipq806x_gmac *gmac)
 {
        struct device *dev = &gmac->pdev->dev;
+       int ret;
 
-       gmac->phy_mode = of_get_phy_mode(dev->of_node);
-       if ((int)gmac->phy_mode < 0) {
+       ret = of_get_phy_mode(dev->of_node, &gmac->phy_mode);
+       if (ret) {
                dev_err(dev, "missing phy mode property\n");
                return -EINVAL;
        }
index cea7a0c7ce689f902ab3d7b5e7234d2dd054cc3e..bdb80421acac66bf25737abc5d75949851bf2501 100644 (file)
@@ -54,7 +54,7 @@ struct mediatek_dwmac_plat_data {
        struct device_node *np;
        struct regmap *peri_regmap;
        struct device *dev;
-       int phy_mode;
+       phy_interface_t phy_mode;
        bool rmii_rxc;
 };
 
@@ -243,6 +243,7 @@ static int mediatek_dwmac_config_dt(struct mediatek_dwmac_plat_data *plat)
 {
        struct mac_delay_struct *mac_delay = &plat->mac_delay;
        u32 tx_delay_ps, rx_delay_ps;
+       int err;
 
        plat->peri_regmap = syscon_regmap_lookup_by_phandle(plat->np, "mediatek,pericfg");
        if (IS_ERR(plat->peri_regmap)) {
@@ -250,10 +251,10 @@ static int mediatek_dwmac_config_dt(struct mediatek_dwmac_plat_data *plat)
                return PTR_ERR(plat->peri_regmap);
        }
 
-       plat->phy_mode = of_get_phy_mode(plat->np);
-       if (plat->phy_mode < 0) {
+       err = of_get_phy_mode(plat->np, &plat->phy_mode);
+       if (err) {
                dev_err(plat->dev, "not find phy-mode\n");
-               return -EINVAL;
+               return err;
        }
 
        if (!of_property_read_u32(plat->np, "mediatek,tx-delay-ps", &tx_delay_ps)) {
index 306da8f6b7d541d4d2d3656f77a911f3237a2eb4..bd6c01004913a0853348cefd7a93d1f9285c1472 100644 (file)
@@ -338,10 +338,9 @@ static int meson8b_dwmac_probe(struct platform_device *pdev)
        }
 
        dwmac->dev = &pdev->dev;
-       dwmac->phy_mode = of_get_phy_mode(pdev->dev.of_node);
-       if ((int)dwmac->phy_mode < 0) {
+       ret = of_get_phy_mode(pdev->dev.of_node, &dwmac->phy_mode);
+       if (ret) {
                dev_err(&pdev->dev, "missing phy-mode property\n");
-               ret = -EINVAL;
                goto err_remove_config_dt;
        }
 
index e2e469c37a4d0713fcaf5e96b5bc3050503cf133..dc50ba13a7468e5ec42ffcc2456e0fcdb4410432 100644 (file)
@@ -37,7 +37,7 @@ struct rk_gmac_ops {
 
 struct rk_priv_data {
        struct platform_device *pdev;
-       int phy_iface;
+       phy_interface_t phy_iface;
        struct regulator *regulator;
        bool suspended;
        const struct rk_gmac_ops *ops;
@@ -1224,7 +1224,7 @@ static struct rk_priv_data *rk_gmac_setup(struct platform_device *pdev,
        if (!bsp_priv)
                return ERR_PTR(-ENOMEM);
 
-       bsp_priv->phy_iface = of_get_phy_mode(dev->of_node);
+       of_get_phy_mode(dev->of_node, &bsp_priv->phy_iface);
        bsp_priv->ops = ops;
 
        bsp_priv->regulator = devm_regulator_get_optional(dev, "phy");
index e9fd661f79952ba2348a5520e052b1d6d3f5b59b..e1b63df6f96f76dbbf5bca49102643ef8ee5607b 100644 (file)
 #define ETH_PHY_SEL_MII                0x0
 
 struct sti_dwmac {
-       int interface;          /* MII interface */
+       phy_interface_t interface;      /* MII interface */
        bool ext_phyclk;        /* Clock from external PHY */
        u32 tx_retime_src;      /* TXCLK Retiming*/
        struct clk *clk;        /* PHY clock */
@@ -269,7 +269,12 @@ static int sti_dwmac_parse_data(struct sti_dwmac *dwmac,
                return err;
        }
 
-       dwmac->interface = of_get_phy_mode(np);
+       err = of_get_phy_mode(np, &dwmac->interface);
+       if (err && err != -ENODEV) {
+               dev_err(dev, "Can't get phy-mode\n");
+               return err;
+       }
+
        dwmac->regmap = regmap;
        dwmac->gmac_en = of_property_read_bool(np, "st,gmac_en");
        dwmac->ext_phyclk = of_property_read_bool(np, "st,ext-phyclk");
index ddcc191febdb22db310fe9833bb39facfbc1de74..eefb06d918c8ab9da8af209e0beca575931886f8 100644 (file)
@@ -1105,6 +1105,7 @@ static int sun8i_dwmac_probe(struct platform_device *pdev)
        struct stmmac_resources stmmac_res;
        struct sunxi_priv_data *gmac;
        struct device *dev = &pdev->dev;
+       phy_interface_t interface;
        int ret;
        struct stmmac_priv *priv;
        struct net_device *ndev;
@@ -1178,10 +1179,10 @@ static int sun8i_dwmac_probe(struct platform_device *pdev)
                return ret;
        }
 
-       ret = of_get_phy_mode(dev->of_node);
-       if (ret < 0)
+       ret = of_get_phy_mode(dev->of_node, &interface);
+       if (ret)
                return -EINVAL;
-       plat_dat->interface = ret;
+       plat_dat->interface = interface;
 
        /* platform data specifying hardware features and callbacks.
         * hardware features were copied from Allwinner drivers.
index a299da3971b40639c73ac5ba7c386d8150a5777d..26353ef616b8bf1329f332ce01d8ae692ab617f1 100644 (file)
@@ -18,7 +18,7 @@
 #include "stmmac_platform.h"
 
 struct sunxi_priv_data {
-       int interface;
+       phy_interface_t interface;
        int clk_enabled;
        struct clk *tx_clk;
        struct regulator *regulator;
@@ -118,7 +118,11 @@ static int sun7i_gmac_probe(struct platform_device *pdev)
                goto err_remove_config_dt;
        }
 
-       gmac->interface = of_get_phy_mode(dev->of_node);
+       ret = of_get_phy_mode(dev->of_node, &gmac->interface);
+       if (ret && ret != -ENODEV) {
+               dev_err(dev, "Can't get phy-mode\n");
+               goto err_remove_config_dt;
+       }
 
        gmac->tx_clk = devm_clk_get(dev, "allwinner_gmac_tx");
        if (IS_ERR(gmac->tx_clk)) {
index 170c3a052b14bf18e159eff4c42e5cb7a0cb8f69..bedaff0c13bded337997b21b87d076104f16de49 100644 (file)
@@ -412,9 +412,9 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
                *mac = NULL;
        }
 
-       plat->phy_interface = of_get_phy_mode(np);
-       if (plat->phy_interface < 0)
-               return ERR_PTR(plat->phy_interface);
+       rc = of_get_phy_mode(np, &plat->phy_interface);
+       if (rc)
+               return ERR_PTR(rc);
 
        plat->interface = stmmac_of_get_mac_mode(np);
        if (plat->interface < 0)
index f298d714efd64a608ce89edba7fae0c3fc555f10..329671e66fe43ed0d754513b42aec74e49a20ac5 100644 (file)
@@ -2619,11 +2619,10 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,
                                i);
                        goto no_phy_slave;
                }
-               slave_data->phy_if = of_get_phy_mode(slave_node);
-               if (slave_data->phy_if < 0) {
+               ret = of_get_phy_mode(slave_node, &slave_data->phy_if);
+               if (ret) {
                        dev_err(&pdev->dev, "Missing or malformed slave[%d] phy-mode property\n",
                                i);
-                       ret = slave_data->phy_if;
                        goto err_node_put;
                }
 
index 362c5a986869aecdf3d05783dd4f2b9701637a57..8bfa761fa5524cfb74643a1eb3e01d567f145174 100644 (file)
@@ -275,7 +275,7 @@ struct cpsw_slave_data {
        struct device_node *slave_node;
        struct device_node *phy_node;
        char            phy_id[MII_BUS_ID_SIZE];
-       int             phy_if;
+       phy_interface_t phy_if;
        u8              mac_addr[ETH_ALEN];
        u16             dual_emac_res_vlan;     /* Reserved VLAN for DualEMAC */
        struct phy      *ifphy;
index 2c1fac33136cd43c7a389d51c8b88b467d7572f1..86a3f42a3dcc01371db5996747b1764c3e09843c 100644 (file)
@@ -2291,6 +2291,7 @@ static int gbe_slave_open(struct gbe_intf *gbe_intf)
        struct gbe_slave *slave = gbe_intf->slave;
        phy_interface_t phy_mode;
        bool has_phy = false;
+       int err;
 
        void (*hndlr)(struct net_device *) = gbe_adjust_link;
 
@@ -2320,11 +2321,11 @@ static int gbe_slave_open(struct gbe_intf *gbe_intf)
                slave->phy_port_t = PORT_MII;
        } else if (slave->link_interface == RGMII_LINK_MAC_PHY) {
                has_phy = true;
-               phy_mode = of_get_phy_mode(slave->node);
+               err = of_get_phy_mode(slave->node, &phy_mode);
                /* if phy-mode is not present, default to
                 * PHY_INTERFACE_MODE_RGMII
                 */
-               if (phy_mode < 0)
+               if (err)
                        phy_mode = PHY_INTERFACE_MODE_RGMII;
 
                if (!phy_interface_mode_is_rgmii(phy_mode)) {
index 676006f32f91368b63a93af927d030ca856daaff..867726d696e2ddea0e32b8c8b5411993491818e0 100644 (file)
@@ -1761,11 +1761,9 @@ static int axienet_probe(struct platform_device *pdev)
                        goto free_netdev;
                }
        } else {
-               lp->phy_mode = of_get_phy_mode(pdev->dev.of_node);
-               if ((int)lp->phy_mode < 0) {
-                       ret = -EINVAL;
+               ret = of_get_phy_mode(pdev->dev.of_node, &lp->phy_mode);
+               if (ret)
                        goto free_netdev;
-               }
        }
 
        /* Find the DMA node, map the DMA registers, and decode the DMA IRQs */
index bd6129db641782c653b14c56dcb887d47124ad51..c6b87ce2b0cc4170dae2837346c4f3e5a1c7f4cd 100644 (file)
@@ -361,8 +361,8 @@ struct phy_device *of_phy_get_and_connect(struct net_device *dev,
        struct phy_device *phy;
        int ret;
 
-       iface = of_get_phy_mode(np);
-       if ((int)iface < 0)
+       ret = of_get_phy_mode(np, &iface);
+       if (ret)
                return NULL;
        if (of_phy_is_fixed_link(np)) {
                ret = of_phy_register_fixed_link(np);
index b02734aff8c147ae65db32a00d1b04c916dc4402..6e411821583e4f2fd71d108687dee528b767a7a0 100644 (file)
 /**
  * of_get_phy_mode - Get phy mode for given device_node
  * @np:        Pointer to the given device_node
+ * @interface: Pointer to the result
  *
  * The function gets phy interface string from property 'phy-mode' or
- * 'phy-connection-type', and return its index in phy_modes table, or errno in
- * error case.
+ * 'phy-connection-type'. The index in phy_modes table is set in
+ * interface and 0 returned. In case of error interface is set to
+ * PHY_INTERFACE_MODE_NA and an errno is returned, e.g. -ENODEV.
  */
-int of_get_phy_mode(struct device_node *np)
+int of_get_phy_mode(struct device_node *np, phy_interface_t *interface)
 {
        const char *pm;
        int err, i;
 
+       *interface = PHY_INTERFACE_MODE_NA;
+
        err = of_property_read_string(np, "phy-mode", &pm);
        if (err < 0)
                err = of_property_read_string(np, "phy-connection-type", &pm);
@@ -32,8 +36,10 @@ int of_get_phy_mode(struct device_node *np)
                return err;
 
        for (i = 0; i < PHY_INTERFACE_MODE_MAX; i++)
-               if (!strcasecmp(pm, phy_modes(i)))
-                       return i;
+               if (!strcasecmp(pm, phy_modes(i))) {
+                       *interface = i;
+                       return 0;
+               }
 
        return -ENODEV;
 }
index 6aeaea1775e66219b8d7b200ed1f2370a7a908e5..71bbfcf3adcd9127c61985a3710e102f020f4bb5 100644 (file)
@@ -6,15 +6,18 @@
 #ifndef __LINUX_OF_NET_H
 #define __LINUX_OF_NET_H
 
+#include <linux/phy.h>
+
 #ifdef CONFIG_OF_NET
 #include <linux/of.h>
 
 struct net_device;
-extern int of_get_phy_mode(struct device_node *np);
+extern int of_get_phy_mode(struct device_node *np, phy_interface_t *interface);
 extern const void *of_get_mac_address(struct device_node *np);
 extern struct net_device *of_find_net_device_by_node(struct device_node *np);
 #else
-static inline int of_get_phy_mode(struct device_node *np)
+static inline int of_get_phy_mode(struct device_node *np,
+                                 phy_interface_t *interface)
 {
        return -ENODEV;
 }
index 86f9464c3f5deef9279d129c7738628cac4f6497..d4bcd9387136c6c7d804a244a0233398847e7a7f 100644 (file)
@@ -13,6 +13,7 @@
 #define __STMMAC_PLATFORM_DATA
 
 #include <linux/platform_device.h>
+#include <linux/phy.h>
 
 #define MTL_MAX_RX_QUEUES      8
 #define MTL_MAX_TX_QUEUES      8
@@ -132,7 +133,7 @@ struct plat_stmmacenet_data {
        int bus_id;
        int phy_addr;
        int interface;
-       int phy_interface;
+       phy_interface_t phy_interface;
        struct stmmac_mdio_bus_data *mdio_bus_data;
        struct device_node *phy_node;
        struct device_node *phylink_node;
index 2673691105840d163d2f1f43f586f488a398f0bc..85ec745767bd91b0728ef0acd6b813cbcf37a871 100644 (file)
@@ -10,6 +10,8 @@
 #ifndef __SXGBE_PLATFORM_H__
 #define __SXGBE_PLATFORM_H__
 
+#include <linux/phy.h>
+
 /* MDC Clock Selection define*/
 #define SXGBE_CSR_100_150M     0x0     /* MDC = clk_scr_i/62 */
 #define SXGBE_CSR_150_250M     0x1     /* MDC = clk_scr_i/102 */
@@ -38,7 +40,7 @@ struct sxgbe_plat_data {
        char *phy_bus_name;
        int bus_id;
        int phy_addr;
-       int interface;
+       phy_interface_t interface;
        struct sxgbe_mdio_bus_data *mdio_bus_data;
        struct sxgbe_dma_cfg *dma_cfg;
        int clk_csr;
index 9b54e5a76297c4bb0d89c54b1468921f4aae02f3..6e93c36bf0c07cefca3fc65d4f8913dc57acbced 100644 (file)
@@ -561,7 +561,7 @@ static int dsa_port_fixed_link_register_of(struct dsa_port *dp)
        struct dsa_switch *ds = dp->ds;
        struct phy_device *phydev;
        int port = dp->index;
-       int mode;
+       phy_interface_t mode;
        int err;
 
        err = of_phy_register_fixed_link(dn);
@@ -574,8 +574,8 @@ static int dsa_port_fixed_link_register_of(struct dsa_port *dp)
 
        phydev = of_phy_find_device(dn);
 
-       mode = of_get_phy_mode(dn);
-       if (mode < 0)
+       err = of_get_phy_mode(dn, &mode);
+       if (err)
                mode = PHY_INTERFACE_MODE_NA;
        phydev->interface = mode;
 
@@ -593,10 +593,11 @@ static int dsa_port_phylink_register(struct dsa_port *dp)
 {
        struct dsa_switch *ds = dp->ds;
        struct device_node *port_dn = dp->dn;
-       int mode, err;
+       phy_interface_t mode;
+       int err;
 
-       mode = of_get_phy_mode(port_dn);
-       if (mode < 0)
+       err = of_get_phy_mode(port_dn, &mode);
+       if (err)
                mode = PHY_INTERFACE_MODE_NA;
 
        dp->pl_config.dev = ds->dev;
index d1876164975406d3fc1a552623c59ed5d6b58846..78ffc87dc25eb06114ee9165ed1a1dfd869720da 100644 (file)
@@ -1313,11 +1313,12 @@ static int dsa_slave_phy_setup(struct net_device *slave_dev)
        struct dsa_port *dp = dsa_slave_to_port(slave_dev);
        struct device_node *port_dn = dp->dn;
        struct dsa_switch *ds = dp->ds;
+       phy_interface_t mode;
        u32 phy_flags = 0;
-       int mode, ret;
+       int ret;
 
-       mode = of_get_phy_mode(port_dn);
-       if (mode < 0)
+       ret = of_get_phy_mode(port_dn, &mode);
+       if (ret)
                mode = PHY_INTERFACE_MODE_NA;
 
        dp->pl_config.dev = &slave_dev->dev;