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

net: phy: move __phy_package_[read|write]_mmd to phy_package.c

Move both functions to phy_package.c, so that phy_core.c no longer
has a dependency on phy_package.c (phy_package_address).

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Link: https://patch.msgid.link/8956fa53-3eda-4079-8203-a8fddcc17bf3@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Heiner Kallweit and committed by
Jakub Kicinski
cbd1ab0c 883af789

+78 -71
+6 -69
drivers/net/phy/phy-core.c
··· 375 375 devad | MII_MMD_CTRL_NOINCR); 376 376 } 377 377 378 - static int mmd_phy_read(struct mii_bus *bus, int phy_addr, bool is_c45, 379 - int devad, u32 regnum) 378 + int mmd_phy_read(struct mii_bus *bus, int phy_addr, bool is_c45, 379 + int devad, u32 regnum) 380 380 { 381 381 if (is_c45) 382 382 return __mdiobus_c45_read(bus, phy_addr, devad, regnum); ··· 385 385 /* Read the content of the MMD's selected register */ 386 386 return __mdiobus_read(bus, phy_addr, MII_MMD_DATA); 387 387 } 388 + EXPORT_SYMBOL_GPL(mmd_phy_read); 388 389 389 - static int mmd_phy_write(struct mii_bus *bus, int phy_addr, bool is_c45, 390 - int devad, u32 regnum, u16 val) 390 + int mmd_phy_write(struct mii_bus *bus, int phy_addr, bool is_c45, 391 + int devad, u32 regnum, u16 val) 391 392 { 392 393 if (is_c45) 393 394 return __mdiobus_c45_write(bus, phy_addr, devad, regnum, val); ··· 397 396 /* Write the data into MMD's selected register */ 398 397 return __mdiobus_write(bus, phy_addr, MII_MMD_DATA, val); 399 398 } 399 + EXPORT_SYMBOL_GPL(mmd_phy_write); 400 400 401 401 /** 402 402 * __phy_read_mmd - Convenience function for reading a register ··· 486 484 return ret; 487 485 } 488 486 EXPORT_SYMBOL(phy_write_mmd); 489 - 490 - /** 491 - * __phy_package_read_mmd - read MMD reg relative to PHY package base addr 492 - * @phydev: The phy_device struct 493 - * @addr_offset: The offset to be added to PHY package base_addr 494 - * @devad: The MMD to read from 495 - * @regnum: The register on the MMD to read 496 - * 497 - * Convenience helper for reading a register of an MMD on a given PHY 498 - * using the PHY package base address. The base address is added to 499 - * the addr_offset value. 500 - * 501 - * Same calling rules as for __phy_read(); 502 - * 503 - * NOTE: It's assumed that the entire PHY package is either C22 or C45. 504 - */ 505 - int __phy_package_read_mmd(struct phy_device *phydev, 506 - unsigned int addr_offset, int devad, 507 - u32 regnum) 508 - { 509 - int addr = phy_package_address(phydev, addr_offset); 510 - 511 - if (addr < 0) 512 - return addr; 513 - 514 - if (regnum > (u16)~0 || devad > 32) 515 - return -EINVAL; 516 - 517 - return mmd_phy_read(phydev->mdio.bus, addr, phydev->is_c45, devad, 518 - regnum); 519 - } 520 - EXPORT_SYMBOL(__phy_package_read_mmd); 521 - 522 - /** 523 - * __phy_package_write_mmd - write MMD reg relative to PHY package base addr 524 - * @phydev: The phy_device struct 525 - * @addr_offset: The offset to be added to PHY package base_addr 526 - * @devad: The MMD to write to 527 - * @regnum: The register on the MMD to write 528 - * @val: value to write to @regnum 529 - * 530 - * Convenience helper for writing a register of an MMD on a given PHY 531 - * using the PHY package base address. The base address is added to 532 - * the addr_offset value. 533 - * 534 - * Same calling rules as for __phy_write(); 535 - * 536 - * NOTE: It's assumed that the entire PHY package is either C22 or C45. 537 - */ 538 - int __phy_package_write_mmd(struct phy_device *phydev, 539 - unsigned int addr_offset, int devad, 540 - u32 regnum, u16 val) 541 - { 542 - int addr = phy_package_address(phydev, addr_offset); 543 - 544 - if (addr < 0) 545 - return addr; 546 - 547 - if (regnum > (u16)~0 || devad > 32) 548 - return -EINVAL; 549 - 550 - return mmd_phy_write(phydev->mdio.bus, addr, phydev->is_c45, devad, 551 - regnum, val); 552 - } 553 - EXPORT_SYMBOL(__phy_package_write_mmd); 554 487 555 488 /** 556 489 * phy_modify_changed - Function for modifying a PHY register
+67 -1
drivers/net/phy/phy_package.c
··· 52 52 } 53 53 EXPORT_SYMBOL_GPL(phy_package_get_priv); 54 54 55 - int phy_package_address(struct phy_device *phydev, unsigned int addr_offset) 55 + static int phy_package_address(struct phy_device *phydev, 56 + unsigned int addr_offset) 56 57 { 57 58 struct phy_package_shared *shared = phydev->shared; 58 59 u8 base_addr = shared->base_addr; ··· 90 89 return __mdiobus_write(phydev->mdio.bus, addr, regnum, val); 91 90 } 92 91 EXPORT_SYMBOL_GPL(__phy_package_write); 92 + 93 + /** 94 + * __phy_package_read_mmd - read MMD reg relative to PHY package base addr 95 + * @phydev: The phy_device struct 96 + * @addr_offset: The offset to be added to PHY package base_addr 97 + * @devad: The MMD to read from 98 + * @regnum: The register on the MMD to read 99 + * 100 + * Convenience helper for reading a register of an MMD on a given PHY 101 + * using the PHY package base address. The base address is added to 102 + * the addr_offset value. 103 + * 104 + * Same calling rules as for __phy_read(); 105 + * 106 + * NOTE: It's assumed that the entire PHY package is either C22 or C45. 107 + */ 108 + int __phy_package_read_mmd(struct phy_device *phydev, 109 + unsigned int addr_offset, int devad, 110 + u32 regnum) 111 + { 112 + int addr = phy_package_address(phydev, addr_offset); 113 + 114 + if (addr < 0) 115 + return addr; 116 + 117 + if (regnum > (u16)~0 || devad > 32) 118 + return -EINVAL; 119 + 120 + return mmd_phy_read(phydev->mdio.bus, addr, phydev->is_c45, devad, 121 + regnum); 122 + } 123 + EXPORT_SYMBOL(__phy_package_read_mmd); 124 + 125 + /** 126 + * __phy_package_write_mmd - write MMD reg relative to PHY package base addr 127 + * @phydev: The phy_device struct 128 + * @addr_offset: The offset to be added to PHY package base_addr 129 + * @devad: The MMD to write to 130 + * @regnum: The register on the MMD to write 131 + * @val: value to write to @regnum 132 + * 133 + * Convenience helper for writing a register of an MMD on a given PHY 134 + * using the PHY package base address. The base address is added to 135 + * the addr_offset value. 136 + * 137 + * Same calling rules as for __phy_write(); 138 + * 139 + * NOTE: It's assumed that the entire PHY package is either C22 or C45. 140 + */ 141 + int __phy_package_write_mmd(struct phy_device *phydev, 142 + unsigned int addr_offset, int devad, 143 + u32 regnum, u16 val) 144 + { 145 + int addr = phy_package_address(phydev, addr_offset); 146 + 147 + if (addr < 0) 148 + return addr; 149 + 150 + if (regnum > (u16)~0 || devad > 32) 151 + return -EINVAL; 152 + 153 + return mmd_phy_write(phydev->mdio.bus, addr, phydev->is_c45, devad, 154 + regnum, val); 155 + } 156 + EXPORT_SYMBOL(__phy_package_write_mmd); 93 157 94 158 static bool __phy_package_set_once(struct phy_device *phydev, unsigned int b) 95 159 {
+5 -1
drivers/net/phy/phylib-internal.h
··· 7 7 #define __PHYLIB_INTERNAL_H 8 8 9 9 struct phy_device; 10 + struct mii_bus; 10 11 11 12 /* 12 13 * phy_supported_speeds - return all speeds currently supported by a PHY device ··· 21 20 int phy_speed_down_core(struct phy_device *phydev); 22 21 void phy_check_downshift(struct phy_device *phydev); 23 22 24 - int phy_package_address(struct phy_device *phydev, unsigned int addr_offset); 23 + int mmd_phy_read(struct mii_bus *bus, int phy_addr, bool is_c45, 24 + int devad, u32 regnum); 25 + int mmd_phy_write(struct mii_bus *bus, int phy_addr, bool is_c45, 26 + int devad, u32 regnum, u16 val); 25 27 26 28 int genphy_c45_read_eee_adv(struct phy_device *phydev, unsigned long *adv); 27 29