Commit ebf2ef8f authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Wolfram Sang

i2c: designware-baytrail: baytrail_i2c_acquire() might sleep

This patch marks baytrail_i2c_acquire() that it might sleep. Also it chages
while-loop to do-while and, though it is matter of taste, gives a chance to
check one more time before report a timeout.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: default avatarDavid E. Box <david.e.box@linux.intel.com>
Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
parent 30be774b
...@@ -68,6 +68,8 @@ static int baytrail_i2c_acquire(struct dw_i2c_dev *dev) ...@@ -68,6 +68,8 @@ static int baytrail_i2c_acquire(struct dw_i2c_dev *dev)
int ret; int ret;
unsigned long start, end; unsigned long start, end;
might_sleep();
if (!dev || !dev->dev) if (!dev || !dev->dev)
return -ENODEV; return -ENODEV;
...@@ -85,7 +87,7 @@ static int baytrail_i2c_acquire(struct dw_i2c_dev *dev) ...@@ -85,7 +87,7 @@ static int baytrail_i2c_acquire(struct dw_i2c_dev *dev)
/* host driver waits for bit 0 to be set in semaphore register */ /* host driver waits for bit 0 to be set in semaphore register */
start = jiffies; start = jiffies;
end = start + msecs_to_jiffies(SEMAPHORE_TIMEOUT); end = start + msecs_to_jiffies(SEMAPHORE_TIMEOUT);
while (!time_after(jiffies, end)) { do {
ret = get_sem(dev->dev, &sem); ret = get_sem(dev->dev, &sem);
if (!ret && sem) { if (!ret && sem) {
acquired = jiffies; acquired = jiffies;
...@@ -95,7 +97,7 @@ static int baytrail_i2c_acquire(struct dw_i2c_dev *dev) ...@@ -95,7 +97,7 @@ static int baytrail_i2c_acquire(struct dw_i2c_dev *dev)
} }
usleep_range(1000, 2000); usleep_range(1000, 2000);
} } while (time_before(jiffies, end));
dev_err(dev->dev, "punit semaphore timed out, resetting\n"); dev_err(dev->dev, "punit semaphore timed out, resetting\n");
reset_semaphore(dev->dev); reset_semaphore(dev->dev);
......
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