You've already forked linux-rockchip
mirror of
https://github.com/armbian/linux-rockchip.git
synced 2026-01-06 11:08:10 -08:00
net: of_get_phy_mode: Change API to solve int/unit warnings
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>
This commit is contained in:
committed by
David S. Miller
parent
5d1fcaf35d
commit
0c65b2b90d
@@ -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)
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -20,9 +20,10 @@
|
||||
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)) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user