Skip to content

Commit

Permalink
be2net: replace udelay() with schedule_timeout() in mbox polling
Browse files Browse the repository at this point in the history
As mbox polling is done only in process context, it is better to
use schedule_timeout() instead of udelay().

Signed-off-by: Sathya Perla <sathyap@serverengines.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Sathya Perla authored and David S. Miller committed Jun 1, 2010
1 parent 889cd4b commit f25b03a
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions drivers/net/benet/be_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ static int be_mcc_notify_wait(struct be_adapter *adapter)

static int be_mbox_db_ready_wait(struct be_adapter *adapter, void __iomem *db)
{
int cnt = 0, wait = 5;
int msecs = 0;
u32 ready;

do {
Expand All @@ -201,15 +201,14 @@ static int be_mbox_db_ready_wait(struct be_adapter *adapter, void __iomem *db)
if (ready)
break;

if (cnt > 4000000) {
if (msecs > 4000) {
dev_err(&adapter->pdev->dev, "mbox poll timed out\n");
return -1;
}

if (cnt > 50)
wait = 200;
cnt += wait;
udelay(wait);
set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(msecs_to_jiffies(1));
msecs++;
} while (true);

return 0;
Expand Down

0 comments on commit f25b03a

Please sign in to comment.