Skip to content

Commit

Permalink
firewire: ohci: skip soft reset retries after card ejection
Browse files Browse the repository at this point in the history
The software reset in firewire-ohci's pci_remove does not have a great
prospect of success if the card was already physically removed at this
point.  So let's skip the 500 ms that were spent in retries here.

Also, replace a defined constant by its open-coded value.  This is not a
constant from a specification but an arbitrarily chosen retry limit.  It
was only used in this single place.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
  • Loading branch information
Stefan Richter committed Jul 9, 2011
1 parent 215fa44 commit 9f42617
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions drivers/firewire/ohci.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ static inline struct fw_ohci *fw_ohci(struct fw_card *card)
#define OHCI1394_MAX_PHYS_RESP_RETRIES 0x8

#define OHCI1394_REGISTER_SIZE 0x800
#define OHCI_LOOP_COUNT 500
#define OHCI1394_PCI_HCI_Control 0x40
#define SELF_ID_BUF_SIZE 0x800
#define OHCI_TCODE_PHY_PACKET 0x0e
Expand Down Expand Up @@ -1967,14 +1966,18 @@ static irqreturn_t irq_handler(int irq, void *data)

static int software_reset(struct fw_ohci *ohci)
{
u32 val;
int i;

reg_write(ohci, OHCI1394_HCControlSet, OHCI1394_HCControl_softReset);
for (i = 0; i < 500; i++) {
val = reg_read(ohci, OHCI1394_HCControlSet);
if (!~val)
return -ENODEV; /* Card was ejected. */

for (i = 0; i < OHCI_LOOP_COUNT; i++) {
if ((reg_read(ohci, OHCI1394_HCControlSet) &
OHCI1394_HCControl_softReset) == 0)
if (!(val & OHCI1394_HCControl_softReset))
return 0;

msleep(1);
}

Expand Down

0 comments on commit 9f42617

Please sign in to comment.