aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/phy/phy.c
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2008-10-14 20:31:54 -0400
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2008-10-14 20:31:54 -0400
commit6dc6472581f693b5fc95aebedf67b4960fb85cf0 (patch)
tree06a5a9a08519950575505273eabced331ed51405 /drivers/net/phy/phy.c
parentee673eaa72d8d185012b1027a05e25aba18c267f (diff)
parent8acd3a60bcca17c6d89c73cee3ad6057eb83ba1e (diff)
Merge commit 'origin'
Manual fixup of conflicts on: arch/powerpc/include/asm/dcr-regs.h drivers/net/ibm_newemac/core.h
Diffstat (limited to 'drivers/net/phy/phy.c')
-rw-r--r--drivers/net/phy/phy.c60
1 files changed, 9 insertions, 51 deletions
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 45cc2914d347..df4e6257d4a7 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -58,55 +58,6 @@ EXPORT_SYMBOL(phy_print_status);
58 58
59 59
60/** 60/**
61 * phy_read - Convenience function for reading a given PHY register
62 * @phydev: the phy_device struct
63 * @regnum: register number to read
64 *
65 * NOTE: MUST NOT be called from interrupt context,
66 * because the bus read/write functions may wait for an interrupt
67 * to conclude the operation.
68 */
69int phy_read(struct phy_device *phydev, u16 regnum)
70{
71 int retval;
72 struct mii_bus *bus = phydev->bus;
73
74 BUG_ON(in_interrupt());
75
76 mutex_lock(&bus->mdio_lock);
77 retval = bus->read(bus, phydev->addr, regnum);
78 mutex_unlock(&bus->mdio_lock);
79
80 return retval;
81}
82EXPORT_SYMBOL(phy_read);
83
84/**
85 * phy_write - Convenience function for writing a given PHY register
86 * @phydev: the phy_device struct
87 * @regnum: register number to write
88 * @val: value to write to @regnum
89 *
90 * NOTE: MUST NOT be called from interrupt context,
91 * because the bus read/write functions may wait for an interrupt
92 * to conclude the operation.
93 */
94int phy_write(struct phy_device *phydev, u16 regnum, u16 val)
95{
96 int err;
97 struct mii_bus *bus = phydev->bus;
98
99 BUG_ON(in_interrupt());
100
101 mutex_lock(&bus->mdio_lock);
102 err = bus->write(bus, phydev->addr, regnum, val);
103 mutex_unlock(&bus->mdio_lock);
104
105 return err;
106}
107EXPORT_SYMBOL(phy_write);
108
109/**
110 * phy_clear_interrupt - Ack the phy device's interrupt 61 * phy_clear_interrupt - Ack the phy device's interrupt
111 * @phydev: the phy_device struct 62 * @phydev: the phy_device struct
112 * 63 *
@@ -366,7 +317,8 @@ int phy_mii_ioctl(struct phy_device *phydev,
366 switch (cmd) { 317 switch (cmd) {
367 case SIOCGMIIPHY: 318 case SIOCGMIIPHY:
368 mii_data->phy_id = phydev->addr; 319 mii_data->phy_id = phydev->addr;
369 break; 320 /* fall through */
321
370 case SIOCGMIIREG: 322 case SIOCGMIIREG:
371 mii_data->val_out = phy_read(phydev, mii_data->reg_num); 323 mii_data->val_out = phy_read(phydev, mii_data->reg_num);
372 break; 324 break;
@@ -413,7 +365,7 @@ int phy_mii_ioctl(struct phy_device *phydev,
413 break; 365 break;
414 366
415 default: 367 default:
416 return -ENOTTY; 368 return -EOPNOTSUPP;
417 } 369 }
418 370
419 return 0; 371 return 0;
@@ -728,6 +680,12 @@ static void phy_change(struct work_struct *work)
728 if (err) 680 if (err)
729 goto irq_enable_err; 681 goto irq_enable_err;
730 682
683 /* Stop timer and run the state queue now. The work function for
684 * state_queue will start the timer up again.
685 */
686 del_timer(&phydev->phy_timer);
687 schedule_work(&phydev->state_queue);
688
731 return; 689 return;
732 690
733irq_enable_err: 691irq_enable_err: