aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/phy/mdio_bus.c
diff options
context:
space:
mode:
authorLennert Buytenhek <buytenh@wantstofly.org>2008-09-29 13:12:35 -0400
committerDavid S. Miller <davem@davemloft.net>2008-10-08 19:38:41 -0400
commit2e888103295f47b8fcbf7e9bb8c5da97dd2ecd76 (patch)
tree210943ed285496352078124fd2a43443b1e5b265 /drivers/net/phy/mdio_bus.c
parent46abc02175b3c246dd5141d878f565a8725060c9 (diff)
phylib: add mdiobus_{read,write}
Add mdiobus_{read,write} routines to allow direct reading/writing of registers on an mii bus without having to go through the PHY abstraction, and make phy_{read,write} use these primitives. Signed-off-by: Lennert Buytenhek <buytenh@marvell.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/phy/mdio_bus.c')
-rw-r--r--drivers/net/phy/mdio_bus.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index fb4c0965b152..6671e2da0d57 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -211,6 +211,55 @@ struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr)
211EXPORT_SYMBOL(mdiobus_scan); 211EXPORT_SYMBOL(mdiobus_scan);
212 212
213/** 213/**
214 * mdiobus_read - Convenience function for reading a given MII mgmt register
215 * @bus: the mii_bus struct
216 * @addr: the phy address
217 * @regnum: register number to read
218 *
219 * NOTE: MUST NOT be called from interrupt context,
220 * because the bus read/write functions may wait for an interrupt
221 * to conclude the operation.
222 */
223int mdiobus_read(struct mii_bus *bus, int addr, u16 regnum)
224{
225 int retval;
226
227 BUG_ON(in_interrupt());
228
229 mutex_lock(&bus->mdio_lock);
230 retval = bus->read(bus, addr, regnum);
231 mutex_unlock(&bus->mdio_lock);
232
233 return retval;
234}
235EXPORT_SYMBOL(mdiobus_read);
236
237/**
238 * mdiobus_write - Convenience function for writing a given MII mgmt register
239 * @bus: the mii_bus struct
240 * @addr: the phy address
241 * @regnum: register number to write
242 * @val: value to write to @regnum
243 *
244 * NOTE: MUST NOT be called from interrupt context,
245 * because the bus read/write functions may wait for an interrupt
246 * to conclude the operation.
247 */
248int mdiobus_write(struct mii_bus *bus, int addr, u16 regnum, u16 val)
249{
250 int err;
251
252 BUG_ON(in_interrupt());
253
254 mutex_lock(&bus->mdio_lock);
255 err = bus->write(bus, addr, regnum, val);
256 mutex_unlock(&bus->mdio_lock);
257
258 return err;
259}
260EXPORT_SYMBOL(mdiobus_write);
261
262/**
214 * mdio_bus_match - determine if given PHY driver supports the given PHY device 263 * mdio_bus_match - determine if given PHY driver supports the given PHY device
215 * @dev: target PHY device 264 * @dev: target PHY device
216 * @drv: given PHY driver 265 * @drv: given PHY driver