Commit 41e1bf81 authored by Samuil Ivanov's avatar Samuil Ivanov Committed by Greg Kroah-Hartman

Staging: qlge: Rewrite two while loops as simple for loops

This is a task from the TODO list of qlge driver:
 - some "while" loops could be rewritten with simple "for"

The change is in functions ql_wait_reg_rdy and ql_wait_cfg in qlge_main.c.
The while loops are basically count based
(they decrement on each iteration),
and it makes more sense to be a for loop construction instead.
Signed-off-by: default avatarSamuil Ivanov <samuil.ivanovbg@gmail.com>
Link: https://lore.kernel.org/r/20191023205855.GA1841@samuil-ThinkCentre-M92PSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent f29acb9c
...@@ -167,9 +167,9 @@ void ql_sem_unlock(struct ql_adapter *qdev, u32 sem_mask) ...@@ -167,9 +167,9 @@ void ql_sem_unlock(struct ql_adapter *qdev, u32 sem_mask)
int ql_wait_reg_rdy(struct ql_adapter *qdev, u32 reg, u32 bit, u32 err_bit) int ql_wait_reg_rdy(struct ql_adapter *qdev, u32 reg, u32 bit, u32 err_bit)
{ {
u32 temp; u32 temp;
int count = UDELAY_COUNT; int count;
while (count) { for (count = 0; count < UDELAY_COUNT; count++) {
temp = ql_read32(qdev, reg); temp = ql_read32(qdev, reg);
/* check for errors */ /* check for errors */
...@@ -181,7 +181,6 @@ int ql_wait_reg_rdy(struct ql_adapter *qdev, u32 reg, u32 bit, u32 err_bit) ...@@ -181,7 +181,6 @@ int ql_wait_reg_rdy(struct ql_adapter *qdev, u32 reg, u32 bit, u32 err_bit)
} else if (temp & bit) } else if (temp & bit)
return 0; return 0;
udelay(UDELAY_DELAY); udelay(UDELAY_DELAY);
count--;
} }
netif_alert(qdev, probe, qdev->ndev, netif_alert(qdev, probe, qdev->ndev,
"Timed out waiting for reg %x to come ready.\n", reg); "Timed out waiting for reg %x to come ready.\n", reg);
...@@ -193,17 +192,16 @@ int ql_wait_reg_rdy(struct ql_adapter *qdev, u32 reg, u32 bit, u32 err_bit) ...@@ -193,17 +192,16 @@ int ql_wait_reg_rdy(struct ql_adapter *qdev, u32 reg, u32 bit, u32 err_bit)
*/ */
static int ql_wait_cfg(struct ql_adapter *qdev, u32 bit) static int ql_wait_cfg(struct ql_adapter *qdev, u32 bit)
{ {
int count = UDELAY_COUNT; int count;
u32 temp; u32 temp;
while (count) { for (count = 0; count < UDELAY_COUNT; count++) {
temp = ql_read32(qdev, CFG); temp = ql_read32(qdev, CFG);
if (temp & CFG_LE) if (temp & CFG_LE)
return -EIO; return -EIO;
if (!(temp & bit)) if (!(temp & bit))
return 0; return 0;
udelay(UDELAY_DELAY); udelay(UDELAY_DELAY);
count--;
} }
return -ETIMEDOUT; return -ETIMEDOUT;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment