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

net: phy: fixed_phy: remove struct fixed_mdio_bus

Use two separate static variables instead of the struct, this allows
to simplify the code.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Heiner Kallweit and committed by
Jakub Kicinski
29838255 f8db55c8

+19 -31
+19 -31
drivers/net/phy/fixed_phy.c
··· 23 23 24 24 #include "swphy.h" 25 25 26 - struct fixed_mdio_bus { 27 - struct mii_bus *mii_bus; 28 - struct list_head phys; 29 - }; 30 - 31 26 struct fixed_phy { 32 27 int addr; 33 28 struct phy_device *phydev; ··· 31 36 struct list_head node; 32 37 }; 33 38 34 - static struct fixed_mdio_bus platform_fmb = { 35 - .phys = LIST_HEAD_INIT(platform_fmb.phys), 36 - }; 39 + static struct mii_bus *fmb_mii_bus; 40 + static LIST_HEAD(fmb_phys); 37 41 38 42 static struct fixed_phy *fixed_phy_find(int addr) 39 43 { 40 - struct fixed_mdio_bus *fmb = &platform_fmb; 41 44 struct fixed_phy *fp; 42 45 43 - list_for_each_entry(fp, &fmb->phys, node) { 46 + list_for_each_entry(fp, &fmb_phys, node) { 44 47 if (fp->addr == addr) 45 48 return fp; 46 49 } ··· 112 119 static int __fixed_phy_add(int phy_addr, 113 120 const struct fixed_phy_status *status) 114 121 { 115 - int ret; 116 - struct fixed_mdio_bus *fmb = &platform_fmb; 117 122 struct fixed_phy *fp; 123 + int ret; 118 124 119 125 ret = swphy_validate_state(status); 120 126 if (ret < 0) ··· 126 134 fp->addr = phy_addr; 127 135 fp->status = *status; 128 136 129 - list_add_tail(&fp->node, &fmb->phys); 137 + list_add_tail(&fp->node, &fmb_phys); 130 138 131 139 return 0; 132 140 } ··· 155 163 struct phy_device *fixed_phy_register(const struct fixed_phy_status *status, 156 164 struct device_node *np) 157 165 { 158 - struct fixed_mdio_bus *fmb = &platform_fmb; 159 166 struct phy_device *phy; 160 167 int phy_addr; 161 168 int ret; 162 169 163 - if (!fmb->mii_bus || fmb->mii_bus->state != MDIOBUS_REGISTERED) 170 + if (!fmb_mii_bus || fmb_mii_bus->state != MDIOBUS_REGISTERED) 164 171 return ERR_PTR(-EPROBE_DEFER); 165 172 166 173 /* Get the next available PHY address, up to PHY_MAX_ADDR */ ··· 173 182 return ERR_PTR(ret); 174 183 } 175 184 176 - phy = get_phy_device(fmb->mii_bus, phy_addr, false); 185 + phy = get_phy_device(fmb_mii_bus, phy_addr, false); 177 186 if (IS_ERR(phy)) { 178 187 fixed_phy_del(phy_addr); 179 188 return ERR_PTR(-EINVAL); ··· 238 247 239 248 static int __init fixed_mdio_bus_init(void) 240 249 { 241 - struct fixed_mdio_bus *fmb = &platform_fmb; 242 250 int ret; 243 251 244 - fmb->mii_bus = mdiobus_alloc(); 245 - if (!fmb->mii_bus) 252 + fmb_mii_bus = mdiobus_alloc(); 253 + if (!fmb_mii_bus) 246 254 return -ENOMEM; 247 255 248 - snprintf(fmb->mii_bus->id, MII_BUS_ID_SIZE, "fixed-0"); 249 - fmb->mii_bus->name = "Fixed MDIO Bus"; 250 - fmb->mii_bus->priv = fmb; 251 - fmb->mii_bus->read = &fixed_mdio_read; 252 - fmb->mii_bus->write = &fixed_mdio_write; 253 - fmb->mii_bus->phy_mask = ~0; 256 + snprintf(fmb_mii_bus->id, MII_BUS_ID_SIZE, "fixed-0"); 257 + fmb_mii_bus->name = "Fixed MDIO Bus"; 258 + fmb_mii_bus->read = &fixed_mdio_read; 259 + fmb_mii_bus->write = &fixed_mdio_write; 260 + fmb_mii_bus->phy_mask = ~0; 254 261 255 - ret = mdiobus_register(fmb->mii_bus); 262 + ret = mdiobus_register(fmb_mii_bus); 256 263 if (ret) 257 264 goto err_mdiobus_alloc; 258 265 259 266 return 0; 260 267 261 268 err_mdiobus_alloc: 262 - mdiobus_free(fmb->mii_bus); 269 + mdiobus_free(fmb_mii_bus); 263 270 return ret; 264 271 } 265 272 module_init(fixed_mdio_bus_init); 266 273 267 274 static void __exit fixed_mdio_bus_exit(void) 268 275 { 269 - struct fixed_mdio_bus *fmb = &platform_fmb; 270 276 struct fixed_phy *fp, *tmp; 271 277 272 - mdiobus_unregister(fmb->mii_bus); 273 - mdiobus_free(fmb->mii_bus); 278 + mdiobus_unregister(fmb_mii_bus); 279 + mdiobus_free(fmb_mii_bus); 274 280 275 - list_for_each_entry_safe(fp, tmp, &fmb->phys, node) { 281 + list_for_each_entry_safe(fp, tmp, &fmb_phys, node) { 276 282 list_del(&fp->node); 277 283 kfree(fp); 278 284 }