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

phy: Change mii_bus id field to a string

Having the id field be an int was making more complex bus topologies
excessively difficult. For now, just convert it to a string, and
change all instances of "bus->id = val" to
snprintf(id, MII_BUS_ID_LEN, "%x", val).

Signed-off-by: Andy Fleming <afleming@freescale.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>

authored by

Andy Fleming and committed by
Jeff Garzik
9d9326d3 d080cd63

+36 -32
+1 -1
arch/powerpc/platforms/82xx/ep8248e.c
··· 138 138 139 139 bus->name = "ep8248e-mdio-bitbang"; 140 140 bus->dev = &ofdev->dev; 141 - bus->id = res.start; 141 + snprintf(bus->id, MII_BUS_ID_SIZE, "%x", res.start); 142 142 143 143 return mdiobus_register(bus); 144 144 }
+1 -1
arch/powerpc/platforms/pasemi/gpio_mdio.c
··· 241 241 new_bus->reset = &gpio_mdio_reset; 242 242 243 243 prop = of_get_property(np, "reg", NULL); 244 - new_bus->id = *prop; 244 + snprintf(new_bus->id, MII_BUS_ID_SIZE, "%x", *prop); 245 245 new_bus->priv = priv; 246 246 247 247 new_bus->phy_mask = 0;
+3 -2
arch/powerpc/sysdev/fsl_soc.c
··· 341 341 goto unreg; 342 342 } 343 343 344 - gfar_data.bus_id = 0; 344 + snprintf(gfar_data.bus_id, MII_BUS_ID_SIZE, "0"); 345 345 gfar_data.phy_id = fixed_link[0]; 346 346 } else { 347 347 phy = of_find_node_by_phandle(*ph); ··· 362 362 } 363 363 364 364 gfar_data.phy_id = *id; 365 - gfar_data.bus_id = res.start; 365 + snprintf(gfar_data.bus_id, MII_BUS_ID_SIZE, "%x", 366 + res.start); 366 367 367 368 of_node_put(phy); 368 369 of_node_put(mdio);
+3 -3
drivers/net/au1000_eth.c
··· 701 701 aup->mii_bus.write = mdiobus_write; 702 702 aup->mii_bus.reset = mdiobus_reset; 703 703 aup->mii_bus.name = "au1000_eth_mii"; 704 - aup->mii_bus.id = aup->mac_id; 704 + snprintf(aup->mii_bus.id, MII_BUS_ID_SIZE, "%x", aup->mac_id); 705 705 aup->mii_bus.irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL); 706 706 for(i = 0; i < PHY_MAX_ADDR; ++i) 707 707 aup->mii_bus.irq[i] = PHY_POLL; ··· 709 709 /* if known, set corresponding PHY IRQs */ 710 710 #if defined(AU1XXX_PHY_STATIC_CONFIG) 711 711 # if defined(AU1XXX_PHY0_IRQ) 712 - if (AU1XXX_PHY0_BUSID == aup->mii_bus.id) 712 + if (AU1XXX_PHY0_BUSID == aup->mac_id) 713 713 aup->mii_bus.irq[AU1XXX_PHY0_ADDR] = AU1XXX_PHY0_IRQ; 714 714 # endif 715 715 # if defined(AU1XXX_PHY1_IRQ) 716 - if (AU1XXX_PHY1_BUSID == aup->mii_bus.id) 716 + if (AU1XXX_PHY1_BUSID == aup->mac_id) 717 717 aup->mii_bus.irq[AU1XXX_PHY1_ADDR] = AU1XXX_PHY1_IRQ; 718 718 # endif 719 719 #endif
+1 -1
drivers/net/bfin_mac.c
··· 969 969 lp->mii_bus.write = mdiobus_write; 970 970 lp->mii_bus.reset = mdiobus_reset; 971 971 lp->mii_bus.name = "bfin_mac_mdio"; 972 - lp->mii_bus.id = 0; 972 + snprintf(lp->mii_bus.id, MII_BUS_ID_SIZE, "0"); 973 973 lp->mii_bus.irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL); 974 974 for (i = 0; i < PHY_MAX_ADDR; ++i) 975 975 lp->mii_bus.irq[i] = PHY_POLL;
+2 -3
drivers/net/cpmac.c
··· 987 987 static int __devinit cpmac_probe(struct platform_device *pdev) 988 988 { 989 989 int rc, phy_id, i; 990 - int mdio_bus_id = cpmac_mii.id; 990 + char *mdio_bus_id = "0"; 991 991 struct resource *mem; 992 992 struct cpmac_priv *priv; 993 993 struct net_device *dev; ··· 1007 1007 if (phy_id == PHY_MAX_ADDR) { 1008 1008 if (external_switch || dumb_switch) { 1009 1009 struct fixed_phy_status status = {}; 1010 - 1011 - mdio_bus_id = 0; 1012 1010 1013 1011 /* 1014 1012 * FIXME: this should be in the platform code! ··· 1141 1143 } 1142 1144 1143 1145 cpmac_mii.phy_mask = ~(mask | 0x80000000); 1146 + snprintf(cpmac_mii.id, MII_BUS_ID_SIZE, "0"); 1144 1147 1145 1148 res = mdiobus_register(&cpmac_mii); 1146 1149 if (res)
+1 -1
drivers/net/fec_mpc52xx.c
··· 198 198 struct phy_device *phydev; 199 199 char phy_id[BUS_ID_SIZE]; 200 200 201 - snprintf(phy_id, BUS_ID_SIZE, PHY_ID_FMT, 201 + snprintf(phy_id, BUS_ID_SIZE, "%x:%02x", 202 202 (unsigned int)dev->base_addr, priv->phy_addr); 203 203 204 204 priv->link = PHY_DOWN;
+1 -1
drivers/net/fec_mpc52xx_phy.c
··· 124 124 goto out_free; 125 125 } 126 126 127 - bus->id = res.start; 127 + snprintf(bus->id, MII_BUS_ID_SIZE, "%x", res.start); 128 128 bus->priv = priv; 129 129 130 130 bus->dev = dev;
+2 -2
drivers/net/fs_enet/fs_enet-main.c
··· 1178 1178 1179 1179 data = of_get_property(np, "fixed-link", NULL); 1180 1180 if (data) { 1181 - snprintf(fpi->bus_id, 16, PHY_ID_FMT, 0, *data); 1181 + snprintf(fpi->bus_id, 16, "%x:%02x", 0, *data); 1182 1182 return 0; 1183 1183 } 1184 1184 ··· 1202 1202 if (!data || len != 4) 1203 1203 goto out_put_mdio; 1204 1204 1205 - snprintf(fpi->bus_id, 16, PHY_ID_FMT, res.start, *data); 1205 + snprintf(fpi->bus_id, 16, "%x:%02x", res.start, *data); 1206 1206 1207 1207 out_put_mdio: 1208 1208 of_node_put(mdionode);
+2 -2
drivers/net/fs_enet/mii-bitbang.c
··· 130 130 * we get is an int, and the odds of multiple bitbang mdio buses 131 131 * is low enough that it's not worth going too crazy. 132 132 */ 133 - bus->id = res.start; 133 + snprintf(bus->id, MII_BUS_ID_SIZE, "%x", res.start); 134 134 135 135 data = of_get_property(np, "fsl,mdio-pin", &len); 136 136 if (!data || len != 4) ··· 307 307 return -ENOMEM; 308 308 309 309 new_bus->name = "BB MII Bus", 310 - new_bus->id = pdev->id; 310 + snprintf(new_bus->id, MII_BUS_ID_SIZE, "%x", pdev->id); 311 311 312 312 new_bus->phy_mask = ~0x9; 313 313 pdata = (struct fs_mii_bb_platform_info *)pdev->dev.platform_data;
+2 -2
drivers/net/fs_enet/mii-fec.c
··· 196 196 if (ret) 197 197 return ret; 198 198 199 - new_bus->id = res.start; 199 + snprintf(new_bus->id, MII_BUS_ID_SIZE, "%x", res.start); 200 200 201 201 fec->fecp = ioremap(res.start, res.end - res.start + 1); 202 202 if (!fec->fecp) ··· 309 309 new_bus->read = &fs_enet_fec_mii_read, 310 310 new_bus->write = &fs_enet_fec_mii_write, 311 311 new_bus->reset = &fs_enet_fec_mii_reset, 312 - new_bus->id = pdev->id; 312 + snprintf(new_bus->id, MII_BUS_ID_SIZE, "%x", pdev->id); 313 313 314 314 pdata = (struct fs_mii_fec_platform_info *)pdev->dev.platform_data; 315 315
+1 -1
drivers/net/gianfar_mii.c
··· 173 173 new_bus->read = &gfar_mdio_read, 174 174 new_bus->write = &gfar_mdio_write, 175 175 new_bus->reset = &gfar_mdio_reset, 176 - new_bus->id = pdev->id; 176 + snprintf(new_bus->id, MII_BUS_ID_SIZE, "%x", pdev->id); 177 177 178 178 pdata = (struct gianfar_mdio_data *)pdev->dev.platform_data; 179 179
+1 -1
drivers/net/macb.c
··· 246 246 bp->mii_bus.read = &macb_mdio_read; 247 247 bp->mii_bus.write = &macb_mdio_write; 248 248 bp->mii_bus.reset = &macb_mdio_reset; 249 - bp->mii_bus.id = bp->pdev->id; 249 + snprintf(bp->mii_bus.id, MII_BUS_ID_SIZE, "%x", bp->pdev->id); 250 250 bp->mii_bus.priv = bp; 251 251 bp->mii_bus.dev = &bp->dev->dev; 252 252 pdata = bp->pdev->dev.platform_data;
+1 -1
drivers/net/pasemi_mac.c
··· 1012 1012 goto err; 1013 1013 1014 1014 phy_id = *prop; 1015 - snprintf(mac->phy_id, BUS_ID_SIZE, PHY_ID_FMT, (int)r.start, phy_id); 1015 + snprintf(mac->phy_id, BUS_ID_SIZE, "%x:%02x", (int)r.start, phy_id); 1016 1016 1017 1017 of_node_put(phy_dn); 1018 1018
+1 -1
drivers/net/phy/fixed.c
··· 213 213 goto err_pdev; 214 214 } 215 215 216 - fmb->mii_bus.id = 0; 216 + snprintf(fmb->mii_bus.id, MII_BUS_ID_SIZE, "0"); 217 217 fmb->mii_bus.name = "Fixed MDIO Bus"; 218 218 fmb->mii_bus.dev = &pdev->dev; 219 219 fmb->mii_bus.read = &fixed_mdio_read;
+1 -1
drivers/net/sb1250-mac.c
··· 2374 2374 dev->name, base, print_mac(mac, eaddr)); 2375 2375 2376 2376 sc->mii_bus.name = sbmac_mdio_string; 2377 - sc->mii_bus.id = idx; 2377 + snprintf(sc->mii_bus.id, MII_BUS_ID_SIZE, "%x", idx); 2378 2378 sc->mii_bus.priv = sc; 2379 2379 sc->mii_bus.read = sbmac_mii_read; 2380 2380 sc->mii_bus.write = sbmac_mii_write;
+1 -1
drivers/net/ucc_geth.c
··· 3954 3954 if (err) 3955 3955 return -1; 3956 3956 3957 - ug_info->mdio_bus = res.start; 3957 + snprintf(ug_info->mdio_bus, MII_BUS_ID_SIZE, "%x", res.start); 3958 3958 } 3959 3959 3960 3960 /* get the phy interface type, or default to MII */
+1 -1
drivers/net/ucc_geth.h
··· 1156 1156 u16 pausePeriod; 1157 1157 u16 extensionField; 1158 1158 u8 phy_address; 1159 - u32 mdio_bus; 1159 + char mdio_bus[MII_BUS_ID_SIZE]; 1160 1160 u8 weightfactor[NUM_TX_QUEUES]; 1161 1161 u8 interruptcoalescingmaxvalue[NUM_RX_QUEUES]; 1162 1162 u8 l2qt[UCC_GETH_VLAN_PRIORITY_MAX];
+1 -1
drivers/net/ucc_geth_mii.c
··· 157 157 if (err) 158 158 goto reg_map_fail; 159 159 160 - new_bus->id = res.start; 160 + snprintf(new_bus->id, MII_BUS_ID_SIZE, "%x", res.start); 161 161 162 162 new_bus->irq = kmalloc(32 * sizeof(int), GFP_KERNEL); 163 163
+1 -1
include/linux/fsl_devices.h
··· 50 50 u32 device_flags; 51 51 /* board specific information */ 52 52 u32 board_flags; 53 - u32 bus_id; 53 + char bus_id[MII_BUS_ID_SIZE]; 54 54 u32 phy_id; 55 55 u8 mac_addr[6]; 56 56 phy_interface_t interface;
+8 -4
include/linux/phy.h
··· 63 63 PHY_INTERFACE_MODE_RTBI 64 64 } phy_interface_t; 65 65 66 - #define MII_BUS_MAX 4 67 - 68 66 69 67 #define PHY_INIT_TIMEOUT 100000 70 68 #define PHY_STATE_TIME 1 ··· 72 74 #define PHY_MAX_ADDR 32 73 75 74 76 /* Used when trying to connect to a specific phy (mii bus id:phy device id) */ 75 - #define PHY_ID_FMT "%x:%02x" 77 + #define PHY_ID_FMT "%s:%02x" 78 + 79 + /* 80 + * Need to be a little smaller than phydev->dev.bus_id to leave room 81 + * for the ":%02x" 82 + */ 83 + #define MII_BUS_ID_SIZE (BUS_ID_SIZE - 3) 76 84 77 85 /* The Bus class for PHYs. Devices which provide access to 78 86 * PHYs should register using this structure */ 79 87 struct mii_bus { 80 88 const char *name; 81 - int id; 89 + char id[MII_BUS_ID_SIZE]; 82 90 void *priv; 83 91 int (*read)(struct mii_bus *bus, int phy_id, int regnum); 84 92 int (*write)(struct mii_bus *bus, int phy_id, int regnum, u16 val);