diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2020-01-09 16:08:25 +0200 |
---|---|---|
committer | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2020-01-10 11:57:22 +0200 |
commit | 81bda12aad60b0dc9f76f6f7a575d7b812533a19 (patch) | |
tree | 48f95d1f8a281f2aa31153b122852c6642975365 /drivers/platform/x86/intel_atomisp2_pm.c | |
parent | a28215844d8db87aadb9bcce040e7897691ff6ba (diff) | |
download | linux-81bda12aad60b0dc9f76f6f7a575d7b812533a19.tar.bz2 |
platform/x86: intel_atomisp2_pm: Refactor timeout loop
The timeout loop look more naturally when done like
unsigned long timeout = ...;
...
do {
...
if (cond)
return %OK;
sleep(...);
} while (time_before(timeout));
...print timeout error...
return %ERROR;
It also saves LOCs. Convert the driver to this format of timeout loop.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Diffstat (limited to 'drivers/platform/x86/intel_atomisp2_pm.c')
-rw-r--r-- | drivers/platform/x86/intel_atomisp2_pm.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/drivers/platform/x86/intel_atomisp2_pm.c b/drivers/platform/x86/intel_atomisp2_pm.c index b0f421fea2a5..6c420032ccf3 100644 --- a/drivers/platform/x86/intel_atomisp2_pm.c +++ b/drivers/platform/x86/intel_atomisp2_pm.c @@ -50,24 +50,20 @@ static int isp_set_power(struct pci_dev *dev, bool enable) * And we do the same for power on. */ timeout = jiffies + msecs_to_jiffies(50); - while (1) { + do { u32 tmp; /* Wait until ISPSSPM0 bit[25:24] shows the right value */ iosf_mbi_read(BT_MBI_UNIT_PMC, MBI_REG_READ, ISPSSPM0, &tmp); tmp = (tmp & ISPSSPM0_ISPSSS_MASK) >> ISPSSPM0_ISPSSS_OFFSET; if (tmp == val) - break; + return 0; - if (time_after(jiffies, timeout)) { - dev_err(&dev->dev, "IUNIT power-%s timeout.\n", - enable ? "on" : "off"); - return -EBUSY; - } usleep_range(1000, 2000); - } + } while (time_before(jiffies, timeout)); - return 0; + dev_err(&dev->dev, "IUNIT power-%s timeout.\n", enable ? "on" : "off"); + return -EBUSY; } static int isp_probe(struct pci_dev *dev, const struct pci_device_id *id) |