mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-17 18:36:00 +00:00
mmc: mmc_spi: Simplify busy loop in mmc_spi_skip()
Infinite loops are hard to read and understand because of hidden main loop condition. Simplify such one in mmc_spi_skip(). Using schedule() to schedule (and be friendly to others) is discouraged and cond_resched() should be used instead. Hence, replace schedule() with cond_resched() at the same time. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20210623101731.87885-1-andriy.shevchenko@linux.intel.com Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
This commit is contained in:
parent
575cf10469
commit
696068470e
@ -180,7 +180,7 @@ static int mmc_spi_skip(struct mmc_spi_host *host, unsigned long timeout,
|
|||||||
u8 *cp = host->data->status;
|
u8 *cp = host->data->status;
|
||||||
unsigned long start = jiffies;
|
unsigned long start = jiffies;
|
||||||
|
|
||||||
while (1) {
|
do {
|
||||||
int status;
|
int status;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
@ -193,16 +193,9 @@ static int mmc_spi_skip(struct mmc_spi_host *host, unsigned long timeout,
|
|||||||
return cp[i];
|
return cp[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (time_is_before_jiffies(start + timeout))
|
/* If we need long timeouts, we may release the CPU */
|
||||||
break;
|
cond_resched();
|
||||||
|
} while (time_is_after_jiffies(start + timeout));
|
||||||
/* If we need long timeouts, we may release the CPU.
|
|
||||||
* We use jiffies here because we want to have a relation
|
|
||||||
* between elapsed time and the blocking of the scheduler.
|
|
||||||
*/
|
|
||||||
if (time_is_before_jiffies(start + 1))
|
|
||||||
schedule();
|
|
||||||
}
|
|
||||||
return -ETIMEDOUT;
|
return -ETIMEDOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user