diff options
author | Stefan Richter <stefanr@s5r6.in-berlin.de> | 2011-06-22 15:05:08 -0400 |
---|---|---|
committer | Stefan Richter <stefanr@s5r6.in-berlin.de> | 2011-07-09 11:12:08 -0400 |
commit | 215fa444c2a6d571f1f915cf3dc7a8b01cc51a0a (patch) | |
tree | 9279ad6fd8bf755cb059ab9d89dd061ac2147f93 /drivers/firewire/ohci.c | |
parent | b14c369d87d7fbf120ad21919d34a8f1290290f1 (diff) |
firewire: ohci: fix PHY reg access after card ejection
Detect and handle ejection of FireWire CardBus cards in PHY register
accesses:
- The last attempt of firewire-core to reset the bus during shutdown
caused a spurious "firewire_ohci: failed to write phy reg" error
message in the log. Skip this message as well as the prior retry
loop that needlessly took 100 milliseconds.
- In the unlikely case that a PHY register was read right after card
ejection, a bogus value was obtained and possibly acted upon.
Instead, fail the read attempt.
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Diffstat (limited to 'drivers/firewire/ohci.c')
-rw-r--r-- | drivers/firewire/ohci.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c index a818dc834690..448598876278 100644 --- a/drivers/firewire/ohci.c +++ b/drivers/firewire/ohci.c | |||
@@ -527,6 +527,9 @@ static int read_phy_reg(struct fw_ohci *ohci, int addr) | |||
527 | reg_write(ohci, OHCI1394_PhyControl, OHCI1394_PhyControl_Read(addr)); | 527 | reg_write(ohci, OHCI1394_PhyControl, OHCI1394_PhyControl_Read(addr)); |
528 | for (i = 0; i < 3 + 100; i++) { | 528 | for (i = 0; i < 3 + 100; i++) { |
529 | val = reg_read(ohci, OHCI1394_PhyControl); | 529 | val = reg_read(ohci, OHCI1394_PhyControl); |
530 | if (!~val) | ||
531 | return -ENODEV; /* Card was ejected. */ | ||
532 | |||
530 | if (val & OHCI1394_PhyControl_ReadDone) | 533 | if (val & OHCI1394_PhyControl_ReadDone) |
531 | return OHCI1394_PhyControl_ReadData(val); | 534 | return OHCI1394_PhyControl_ReadData(val); |
532 | 535 | ||
@@ -550,6 +553,9 @@ static int write_phy_reg(const struct fw_ohci *ohci, int addr, u32 val) | |||
550 | OHCI1394_PhyControl_Write(addr, val)); | 553 | OHCI1394_PhyControl_Write(addr, val)); |
551 | for (i = 0; i < 3 + 100; i++) { | 554 | for (i = 0; i < 3 + 100; i++) { |
552 | val = reg_read(ohci, OHCI1394_PhyControl); | 555 | val = reg_read(ohci, OHCI1394_PhyControl); |
556 | if (!~val) | ||
557 | return -ENODEV; /* Card was ejected. */ | ||
558 | |||
553 | if (!(val & OHCI1394_PhyControl_WritePending)) | 559 | if (!(val & OHCI1394_PhyControl_WritePending)) |
554 | return 0; | 560 | return 0; |
555 | 561 | ||