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

net: mdio: of: export part of of_mdiobus_register_phy()

This function will be needed in tja11xx driver for secondary PHY
support.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Oleksij Rempel and committed by
David S. Miller
5972157c 8f469506

+55 -35
+45 -34
drivers/of/of_mdio.c
··· 60 60 return register_mii_timestamper(arg.np, arg.args[0]); 61 61 } 62 62 63 + int of_mdiobus_phy_device_register(struct mii_bus *mdio, struct phy_device *phy, 64 + struct device_node *child, u32 addr) 65 + { 66 + int rc; 67 + 68 + rc = of_irq_get(child, 0); 69 + if (rc == -EPROBE_DEFER) 70 + return rc; 71 + 72 + if (rc > 0) { 73 + phy->irq = rc; 74 + mdio->irq[addr] = rc; 75 + } else { 76 + phy->irq = mdio->irq[addr]; 77 + } 78 + 79 + if (of_property_read_bool(child, "broken-turn-around")) 80 + mdio->phy_ignore_ta_mask |= 1 << addr; 81 + 82 + of_property_read_u32(child, "reset-assert-us", 83 + &phy->mdio.reset_assert_delay); 84 + of_property_read_u32(child, "reset-deassert-us", 85 + &phy->mdio.reset_deassert_delay); 86 + 87 + /* Associate the OF node with the device structure so it 88 + * can be looked up later */ 89 + of_node_get(child); 90 + phy->mdio.dev.of_node = child; 91 + phy->mdio.dev.fwnode = of_fwnode_handle(child); 92 + 93 + /* All data is now stored in the phy struct; 94 + * register it */ 95 + rc = phy_device_register(phy); 96 + if (rc) { 97 + of_node_put(child); 98 + return rc; 99 + } 100 + 101 + dev_dbg(&mdio->dev, "registered phy %pOFn at address %i\n", 102 + child, addr); 103 + return 0; 104 + } 105 + EXPORT_SYMBOL(of_mdiobus_phy_device_register); 106 + 63 107 static int of_mdiobus_register_phy(struct mii_bus *mdio, 64 108 struct device_node *child, u32 addr) 65 109 { ··· 130 86 return PTR_ERR(phy); 131 87 } 132 88 133 - rc = of_irq_get(child, 0); 134 - if (rc == -EPROBE_DEFER) { 135 - if (mii_ts) 136 - unregister_mii_timestamper(mii_ts); 137 - phy_device_free(phy); 138 - return rc; 139 - } 140 - if (rc > 0) { 141 - phy->irq = rc; 142 - mdio->irq[addr] = rc; 143 - } else { 144 - phy->irq = mdio->irq[addr]; 145 - } 146 - 147 - if (of_property_read_bool(child, "broken-turn-around")) 148 - mdio->phy_ignore_ta_mask |= 1 << addr; 149 - 150 - of_property_read_u32(child, "reset-assert-us", 151 - &phy->mdio.reset_assert_delay); 152 - of_property_read_u32(child, "reset-deassert-us", 153 - &phy->mdio.reset_deassert_delay); 154 - 155 - /* Associate the OF node with the device structure so it 156 - * can be looked up later */ 157 - of_node_get(child); 158 - phy->mdio.dev.of_node = child; 159 - phy->mdio.dev.fwnode = of_fwnode_handle(child); 160 - 161 - /* All data is now stored in the phy struct; 162 - * register it */ 163 - rc = phy_device_register(phy); 89 + rc = of_mdiobus_phy_device_register(mdio, phy, child, addr); 164 90 if (rc) { 165 91 if (mii_ts) 166 92 unregister_mii_timestamper(mii_ts); 167 93 phy_device_free(phy); 168 - of_node_put(child); 169 94 return rc; 170 95 } 171 96 ··· 145 132 if (mii_ts) 146 133 phy->mii_ts = mii_ts; 147 134 148 - dev_dbg(&mdio->dev, "registered phy %pOFn at address %i\n", 149 - child, addr); 150 135 return 0; 151 136 } 152 137
+10 -1
include/linux/of_mdio.h
··· 30 30 extern int of_phy_register_fixed_link(struct device_node *np); 31 31 extern void of_phy_deregister_fixed_link(struct device_node *np); 32 32 extern bool of_phy_is_fixed_link(struct device_node *np); 33 - 33 + extern int of_mdiobus_phy_device_register(struct mii_bus *mdio, 34 + struct phy_device *phy, 35 + struct device_node *child, u32 addr); 34 36 35 37 static inline int of_mdio_parse_addr(struct device *dev, 36 38 const struct device_node *np) ··· 119 117 static inline bool of_phy_is_fixed_link(struct device_node *np) 120 118 { 121 119 return false; 120 + } 121 + 122 + static inline int of_mdiobus_phy_device_register(struct mii_bus *mdio, 123 + struct phy_device *phy, 124 + struct device_node *child, u32 addr) 125 + { 126 + return -ENOSYS; 122 127 } 123 128 #endif 124 129