Skip to content

Commit 2220943

Browse files
lunndavem330
authored andcommitted
phy: Centralise print about attached phy
Many Ethernet drivers contain the same netdev_info() print statement about the attached phy. Move it into the phy device code. Additionally add a varargs function which can be used to append additional information. Signed-off-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 053e7e1 commit 2220943

File tree

25 files changed

+64
-82
lines changed

25 files changed

+64
-82
lines changed

drivers/net/ethernet/adi/bfin_mac.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -444,10 +444,8 @@ static int mii_probe(struct net_device *dev, int phy_mode)
444444
lp->old_duplex = -1;
445445
lp->phydev = phydev;
446446

447-
pr_info("attached PHY driver [%s] "
448-
"(mii_bus:phy_addr=%s, irq=%d, mdc_clk=%dHz(mdc_div=%d)@sclk=%dMHz)\n",
449-
phydev->drv->name, phydev_name(phydev), phydev->irq,
450-
MDC_CLK, mdc_div, sclk/1000000);
447+
phy_attached_print(phydev, "mdc_clk=%dHz(mdc_div=%d)@sclk=%dMHz)\n",
448+
MDC_CLK, mdc_div, sclk / 1000000);
451449

452450
return 0;
453451
}

drivers/net/ethernet/agere/et131x.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3289,9 +3289,7 @@ static int et131x_mii_probe(struct net_device *netdev)
32893289
phydev->autoneg = AUTONEG_ENABLE;
32903290
adapter->phydev = phydev;
32913291

3292-
dev_info(&adapter->pdev->dev,
3293-
"attached PHY driver [%s] (mii_bus:phy_addr=%s)\n",
3294-
phydev->drv->name, phydev_name(phydev));
3292+
phy_attached_info(phydev);
32953293

32963294
return 0;
32973295
}

drivers/net/ethernet/amd/au1000_eth.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -583,9 +583,7 @@ static int au1000_mii_probe(struct net_device *dev)
583583
aup->old_duplex = -1;
584584
aup->phy_dev = phydev;
585585

586-
netdev_info(dev, "attached PHY driver [%s] "
587-
"(mii_bus:phy_addr=%s, irq=%d)\n",
588-
phydev->drv->name, phydev_name(phydev), phydev->irq);
586+
phy_attached_info(phydev);
589587

590588
return 0;
591589
}

drivers/net/ethernet/broadcom/b44.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2315,8 +2315,7 @@ static int b44_register_phy_one(struct b44 *bp)
23152315
bp->old_link = 0;
23162316
bp->phy_addr = phydev->addr;
23172317

2318-
dev_info(sdev->dev, "attached PHY driver [%s] (mii_bus:phy_addr=%s)\n",
2319-
phydev->drv->name, phydev_name(phydev));
2318+
phy_attached_info(phydev);
23202319

23212320
return 0;
23222321

drivers/net/ethernet/broadcom/bcm63xx_enet.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -908,8 +908,7 @@ static int bcm_enet_open(struct net_device *dev)
908908
else
909909
phydev->advertising &= ~SUPPORTED_Pause;
910910

911-
dev_info(kdev, "attached PHY at address %d [%s]\n",
912-
phydev->addr, phydev->drv->name);
911+
phy_attached_info(phydev);
913912

914913
priv->old_link = 0;
915914
priv->old_duplex = -1;

drivers/net/ethernet/broadcom/sb1250-mac.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2388,11 +2388,10 @@ static int sbmac_mii_probe(struct net_device *dev)
23882388
SUPPORTED_MII |
23892389
SUPPORTED_Pause |
23902390
SUPPORTED_Asym_Pause;
2391-
phy_dev->advertising = phy_dev->supported;
23922391

2393-
pr_info("%s: attached PHY driver [%s] (mii_bus:phy_addr=%s, irq=%d)\n",
2394-
dev->name, phy_dev->drv->name,
2395-
dev_name(&phy_dev->dev), phy_dev->irq);
2392+
phy_attached_info(phydev);
2393+
2394+
phy_dev->advertising = phy_dev->supported;
23962395

23972396
sc->phy_dev = phy_dev;
23982397

drivers/net/ethernet/broadcom/tg3.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2128,6 +2128,8 @@ static int tg3_phy_init(struct tg3 *tp)
21282128

21292129
phydev->advertising = phydev->supported;
21302130

2131+
phy_attached_info(phydev);
2132+
21312133
return 0;
21322134
}
21332135

@@ -17898,13 +17900,7 @@ static int tg3_init_one(struct pci_dev *pdev,
1789817900
tg3_bus_string(tp, str),
1789917901
dev->dev_addr);
1790017902

17901-
if (tp->phy_flags & TG3_PHYFLG_IS_CONNECTED) {
17902-
struct phy_device *phydev;
17903-
phydev = tp->mdio_bus->phy_map[tp->phy_addr];
17904-
netdev_info(dev,
17905-
"attached PHY driver [%s] (mii_bus:phy_addr=%s)\n",
17906-
phydev->drv->name, phydev_name(phydev));
17907-
} else {
17903+
if (!(tp->phy_flags & TG3_PHYFLG_IS_CONNECTED)) {
1790817904
char *ethtype;
1790917905

1791017906
if (tp->phy_flags & TG3_PHYFLG_10_100_ONLY)

drivers/net/ethernet/cadence/macb.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2950,8 +2950,7 @@ static int macb_probe(struct platform_device *pdev)
29502950
dev->base_addr, dev->irq, dev->dev_addr);
29512951

29522952
phydev = bp->phy_dev;
2953-
netdev_info(dev, "attached PHY driver [%s] (mii_bus:phy_addr=%s, irq=%d)\n",
2954-
phydev->drv->name, phydev_name(phydev), phydev->irq);
2953+
phy_attached_info(phydev);
29552954

29562955
return 0;
29572956

drivers/net/ethernet/dnet.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -886,9 +886,7 @@ static int dnet_probe(struct platform_device *pdev)
886886
(bp->capabilities & DNET_HAS_GIGABIT) ? "" : "no ",
887887
(bp->capabilities & DNET_HAS_DMA) ? "" : "no ");
888888
phydev = bp->phy_dev;
889-
dev_info(&pdev->dev, "attached PHY driver [%s] "
890-
"(mii_bus:phy_addr=%s, irq=%d)\n",
891-
phydev->drv->name, phydev_name(phydev), phydev->irq);
889+
phy_attached_info(phydev);
892890

893891
return 0;
894892

drivers/net/ethernet/freescale/fec_main.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1972,9 +1972,7 @@ static int fec_enet_mii_probe(struct net_device *ndev)
19721972
fep->link = 0;
19731973
fep->full_duplex = 0;
19741974

1975-
netdev_info(ndev, "Freescale FEC PHY driver [%s] (mii_bus:phy_addr=%s, irq=%d)\n",
1976-
fep->phy_dev->drv->name, dev_name(&fep->phy_dev->dev),
1977-
fep->phy_dev->irq);
1975+
phy_attached_info(phy_dev);
19781976

19791977
return 0;
19801978
}

drivers/net/ethernet/lantiq_etop.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -408,9 +408,7 @@ ltq_etop_mdio_probe(struct net_device *dev)
408408

409409
phydev->advertising = phydev->supported;
410410
priv->phydev = phydev;
411-
pr_info("%s: attached PHY [%s] (phy_addr=%s, irq=%d)\n",
412-
dev->name, phydev->drv->name,
413-
phydev_name(phydev), phydev->irq);
411+
phy_attached_info(phydev);
414412

415413
return 0;
416414
}

drivers/net/ethernet/nxp/lpc_eth.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -816,9 +816,8 @@ static int lpc_mii_probe(struct net_device *ndev)
816816
pldat->duplex = -1;
817817
pldat->phy_dev = phydev;
818818

819-
netdev_info(ndev,
820-
"attached PHY driver [%s] (mii_bus:phy_addr=%s, irq=%d)\n",
821-
phydev->drv->name, phydev_name(phydev), phydev->irq);
819+
phy_attached_info(phydev);
820+
822821
return 0;
823822
}
824823

drivers/net/ethernet/rdc/r6040.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,9 +1061,7 @@ static int r6040_mii_probe(struct net_device *dev)
10611061
lp->old_link = 0;
10621062
lp->old_duplex = -1;
10631063

1064-
dev_info(&lp->pdev->dev, "attached PHY driver [%s] "
1065-
"(mii_bus:phy_addr=%s)\n",
1066-
phydev->drv->name, phydev_name(phydev));
1064+
phy_attached_info(phydev);
10671065

10681066
return 0;
10691067
}

drivers/net/ethernet/renesas/ravb_main.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -927,8 +927,7 @@ static int ravb_phy_init(struct net_device *ndev)
927927
/* 10BASE is not supported */
928928
phydev->supported &= ~PHY_10BT_FEATURES;
929929

930-
netdev_info(ndev, "attached PHY %d (IRQ %d) to driver %s\n",
931-
phydev->addr, phydev->irq, phydev_name(phydev));
930+
phy_attached_info(phydev);
932931

933932
priv->phydev = phydev;
934933

drivers/net/ethernet/renesas/sh_eth.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1826,8 +1826,7 @@ static int sh_eth_phy_init(struct net_device *ndev)
18261826
return PTR_ERR(phydev);
18271827
}
18281828

1829-
netdev_info(ndev, "attached PHY %d (IRQ %d) to driver %s\n",
1830-
phydev->addr, phydev->irq, phydev_name(phydev));
1829+
phy_attached_info(phydev);
18311830

18321831
mdp->phydev = phydev;
18331832

drivers/net/ethernet/smsc/smsc911x.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,9 +1031,7 @@ static int smsc911x_mii_probe(struct net_device *dev)
10311031
return ret;
10321032
}
10331033

1034-
netdev_info(dev,
1035-
"attached PHY driver [%s] (mii_bus:phy_addr=%s, irq=%d)\n",
1036-
phydev->drv->name, phydev_name(phydev), phydev->irq);
1034+
phy_attached_info(phydev);
10371035

10381036
/* mask with MAC supported features */
10391037
phydev->supported &= (PHY_BASIC_FEATURES | SUPPORTED_Pause |

drivers/net/ethernet/smsc/smsc9420.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,10 +1163,6 @@ static int smsc9420_mii_probe(struct net_device *dev)
11631163
return -ENODEV;
11641164
}
11651165

1166-
phydev = pd->mii_bus->phy_map[1];
1167-
netif_info(pd, probe, pd->dev, "PHY addr %d, phy_id 0x%08X\n",
1168-
phydev->addr, phydev->phy_id);
1169-
11701166
phydev = phy_connect(dev, phydev_name(phydev),
11711167
smsc9420_phy_adjust_link, PHY_INTERFACE_MODE_MII);
11721168

@@ -1175,14 +1171,13 @@ static int smsc9420_mii_probe(struct net_device *dev)
11751171
return PTR_ERR(phydev);
11761172
}
11771173

1178-
netdev_info(dev, "attached PHY driver [%s] (mii_bus:phy_addr=%s, irq=%d)\n",
1179-
phydev->drv->name, phydev_name(phydev), phydev->irq);
1180-
11811174
/* mask with MAC supported features */
11821175
phydev->supported &= (PHY_BASIC_FEATURES | SUPPORTED_Pause |
11831176
SUPPORTED_Asym_Pause);
11841177
phydev->advertising = phydev->supported;
11851178

1179+
phy_attached_info(phydev);
1180+
11861181
pd->phy_dev = phydev;
11871182
pd->last_duplex = -1;
11881183
pd->last_carrier = -1;

drivers/net/ethernet/synopsys/dwc_eth_qos.c

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -972,9 +972,7 @@ static int dwceqos_mii_probe(struct net_device *ndev)
972972
}
973973

974974
if (netif_msg_probe(lp))
975-
netdev_dbg(lp->ndev,
976-
"phydev %p, phydev->phy_id 0xa%x, phydev->addr 0x%x\n",
977-
phydev, phydev->phy_id, phydev->addr);
975+
phy_attached_info(phydev);
978976

979977
phydev->supported &= PHY_GBIT_FEATURES;
980978

@@ -983,14 +981,6 @@ static int dwceqos_mii_probe(struct net_device *ndev)
983981
lp->duplex = DUPLEX_UNKNOWN;
984982
lp->phy_dev = phydev;
985983

986-
if (netif_msg_probe(lp)) {
987-
netdev_dbg(lp->ndev, "phy_addr 0x%x, phy_id 0x%08x\n",
988-
lp->phy_dev->addr, lp->phy_dev->phy_id);
989-
990-
netdev_dbg(lp->ndev, "attach [%s] phy driver\n",
991-
lp->phy_dev->drv->name);
992-
}
993-
994984
return 0;
995985
}
996986

drivers/net/ethernet/ti/cpsw.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,8 +1159,8 @@ static void cpsw_slave_open(struct cpsw_slave *slave, struct cpsw_priv *priv)
11591159
slave->data->phy_id, slave->slave_num);
11601160
slave->phy = NULL;
11611161
} else {
1162-
dev_info(priv->dev, "phy found : id is : 0x%x\n",
1163-
slave->phy->phy_id);
1162+
phy_attached_info(slave->phy);
1163+
11641164
phy_start(slave->phy);
11651165

11661166
/* Configure GMII_SEL register */

drivers/net/ethernet/ti/davinci_emac.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1644,10 +1644,7 @@ static int emac_dev_open(struct net_device *ndev)
16441644
priv->speed = 0;
16451645
priv->duplex = ~0;
16461646

1647-
dev_info(emac_dev, "attached PHY driver [%s] "
1648-
"(mii_bus:phy_addr=%s, id=%x)\n",
1649-
priv->phydev->drv->name, phydev_name(priv->phydev),
1650-
priv->phydev->phy_id);
1647+
phy_attached_info(priv->phydev);
16511648
}
16521649

16531650
if (!priv->phydev) {

drivers/net/ethernet/toshiba/tc35815.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -638,10 +638,8 @@ static int tc_mii_probe(struct net_device *dev)
638638
printk(KERN_ERR "%s: Could not attach to PHY\n", dev->name);
639639
return PTR_ERR(phydev);
640640
}
641-
printk(KERN_INFO "%s: attached PHY driver [%s] "
642-
"(mii_bus:phy_addr=%s, id=%x)\n",
643-
dev->name, phydev->drv->name, phydev_name(phydev),
644-
phydev->phy_id);
641+
642+
phy_attached_info(phydev);
645643

646644
/* mask with MAC supported features */
647645
phydev->supported &= PHY_BASIC_FEATURES;

drivers/net/phy/phy_device.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,33 @@ int phy_init_hw(struct phy_device *phydev)
607607
}
608608
EXPORT_SYMBOL(phy_init_hw);
609609

610+
void phy_attached_info(struct phy_device *phydev)
611+
{
612+
phy_attached_print(phydev, NULL);
613+
}
614+
EXPORT_SYMBOL(phy_attached_info);
615+
616+
#define ATTACHED_FMT "attached PHY driver [%s] (mii_bus:phy_addr=%s, irq=%d)"
617+
void phy_attached_print(struct phy_device *phydev, const char *fmt, ...)
618+
{
619+
if (!fmt) {
620+
dev_info(&phydev->dev, ATTACHED_FMT "\n",
621+
phydev->drv->name, phydev_name(phydev),
622+
phydev->irq);
623+
} else {
624+
va_list ap;
625+
626+
dev_info(&phydev->dev, ATTACHED_FMT,
627+
phydev->drv->name, phydev_name(phydev),
628+
phydev->irq);
629+
630+
va_start(ap, fmt);
631+
vprintk(fmt, ap);
632+
va_end(ap);
633+
}
634+
}
635+
EXPORT_SYMBOL(phy_attached_print);
636+
610637
/**
611638
* phy_attach_direct - attach a network device to a given PHY device pointer
612639
* @dev: network device to attach

drivers/staging/netlogic/xlr_net.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -854,8 +854,7 @@ static int xlr_mii_probe(struct xlr_net_priv *priv)
854854
| ADVERTISED_MII);
855855

856856
phydev->advertising = phydev->supported;
857-
pr_info("attached PHY driver [%s] (mii_bus:phy_addr=%s\n",
858-
phydev->drv->name, phydev_name(phydev));
857+
phy_attached_info(phydev);
859858
return 0;
860859
}
861860

include/linux/phy.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#ifndef __PHY_H
1717
#define __PHY_H
1818

19+
#include <linux/compiler.h>
1920
#include <linux/spinlock.h>
2021
#include <linux/ethtool.h>
2122
#include <linux/mdio.h>
@@ -785,6 +786,9 @@ static inline const char *phydev_name(const struct phy_device *phydev)
785786
return dev_name(&phydev->dev);
786787
}
787788

789+
void phy_attached_print(struct phy_device *phydev, const char *fmt, ...)
790+
__printf(2, 3);
791+
void phy_attached_info(struct phy_device *phydev);
788792
int genphy_config_init(struct phy_device *phydev);
789793
int genphy_setup_forced(struct phy_device *phydev);
790794
int genphy_restart_aneg(struct phy_device *phydev);

net/dsa/slave.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,11 +1080,10 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p,
10801080
netdev_err(slave_dev, "failed to connect to port %d: %d\n", p->port, ret);
10811081
return ret;
10821082
}
1083-
} else {
1084-
netdev_info(slave_dev, "attached PHY at address %d [%s]\n",
1085-
p->phy->addr, p->phy->drv->name);
10861083
}
10871084

1085+
phy_attached_info(p->phy);
1086+
10881087
return 0;
10891088
}
10901089

0 commit comments

Comments
 (0)