From: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
To: Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>,
Mika Westerberg
<mika.westerberg-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>,
David Box <david.e.box-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>,
linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Jarkko Nikula
<jarkko.nikula-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Cc: Andy Shevchenko
<andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Subject: [PATCH v1 5/5] i2c-designware-baytrail: baytrail_i2c_acquire() might sleep
Date: Tue, 10 Feb 2015 19:06:10 +0200 [thread overview]
Message-ID: <1423587970-19136-5-git-send-email-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <1423587970-19136-1-git-send-email-andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
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: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
drivers/i2c/busses/i2c-designware-baytrail.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/i2c/busses/i2c-designware-baytrail.c b/drivers/i2c/busses/i2c-designware-baytrail.c
index 036d9bdc0..7d7ae97 100644
--- a/drivers/i2c/busses/i2c-designware-baytrail.c
+++ b/drivers/i2c/busses/i2c-designware-baytrail.c
@@ -68,6 +68,8 @@ static int baytrail_i2c_acquire(struct dw_i2c_dev *dev)
int ret;
unsigned long start, end;
+ might_sleep();
+
if (!dev || !dev->dev)
return -ENODEV;
@@ -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 */
start = jiffies;
end = start + msecs_to_jiffies(SEMAPHORE_TIMEOUT);
- while (!time_after(jiffies, end)) {
+ do {
ret = get_sem(dev->dev, &sem);
if (!ret && sem) {
acquired = jiffies;
@@ -95,7 +97,7 @@ static int baytrail_i2c_acquire(struct dw_i2c_dev *dev)
}
usleep_range(1000, 2000);
- }
+ } while (time_before(jiffies, end));
dev_err(dev->dev, "punit semaphore timed out, resetting\n");
reset_semaphore(dev->dev);
--
2.1.4
next prev parent reply other threads:[~2015-02-10 17:06 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-10 17:06 [PATCH v1 1/5] i2c-designware-baytrail: describe magic numbers Andy Shevchenko
[not found] ` <1423587970-19136-1-git-send-email-andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2015-02-10 17:06 ` [PATCH v1 2/5] i2c-designware-baytrail: fix typo in error path Andy Shevchenko
[not found] ` <1423587970-19136-2-git-send-email-andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2015-02-11 16:38 ` David E. Box
2015-02-11 16:46 ` Wolfram Sang
2015-02-11 16:59 ` Andy Shevchenko
[not found] ` <1423673991.31903.535.camel-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2015-02-11 18:04 ` David E. Box
2015-02-23 12:54 ` Andy Shevchenko
[not found] ` <1424696051.14897.13.camel-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2015-02-23 18:42 ` Wolfram Sang
2015-02-24 10:06 ` Andy Shevchenko
2015-02-10 17:06 ` [PATCH v1 3/5] i2c-designware-baytrail: fix sparse warnings Andy Shevchenko
[not found] ` <1423587970-19136-3-git-send-email-andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2015-02-11 16:44 ` David E. Box
2015-02-10 17:06 ` [PATCH v1 4/5] i2c-designware-baytrail: cross-check lock functions Andy Shevchenko
[not found] ` <1423587970-19136-4-git-send-email-andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2015-02-11 16:46 ` David E. Box
2015-02-10 17:06 ` Andy Shevchenko [this message]
[not found] ` <1423587970-19136-5-git-send-email-andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2015-02-11 16:48 ` [PATCH v1 5/5] i2c-designware-baytrail: baytrail_i2c_acquire() might sleep David E. Box
2015-02-11 16:35 ` [PATCH v1 1/5] i2c-designware-baytrail: describe magic numbers David E. Box
2015-03-07 0:11 ` Wolfram Sang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1423587970-19136-5-git-send-email-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko-vuqaysv1563yd54fqh9/ca@public.gmane.org \
--cc=david.e.box-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
--cc=jarkko.nikula-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
--cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=mika.westerberg-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
--cc=wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).