From: Yegor Yefremov <yegor_sub1-ZJVcf1zZPRSebONBosFW4Q@public.gmane.org>
To: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: Wolfram Sang <w.sang-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>,
khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org
Subject: [PATCH v2] fix i2c_pca_pf_waitforcompletion() return value
Date: Tue, 21 Sep 2010 11:15:47 +0200 [thread overview]
Message-ID: <4C9877C3.30106@visionsystems.de> (raw)
ret is still -1, if during the polling read_byte() returns at once
with I2C_PCA_CON_SI set. So ret > 0 would lead
i2c_pca_pf_waitforcompletion() to return 0, in spite of
the proper behavior.
Solution: get rid of ret and make immediate return where possible.
Signed-off-by: Yegor Yefremov <yegorslists-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>
Index: b/drivers/i2c/busses/i2c-pca-platform.c
===================================================================
--- a/drivers/i2c/busses/i2c-pca-platform.c 2010-09-21 10:53:46.000000000 +0200
+++ b/drivers/i2c/busses/i2c-pca-platform.c 2010-09-21 10:59:18.000000000 +0200
@@ -80,23 +80,26 @@
static int i2c_pca_pf_waitforcompletion(void *pd)
{
struct i2c_pca_pf_data *i2c = pd;
- long ret = ~0;
unsigned long timeout;
if (i2c->irq) {
- ret = wait_event_timeout(i2c->wait,
+ return wait_event_timeout(i2c->wait,
i2c->algo_data.read_byte(i2c, I2C_PCA_CON)
& I2C_PCA_CON_SI, i2c->adap.timeout);
} else {
/* Do polling */
timeout = jiffies + i2c->adap.timeout;
- while (((i2c->algo_data.read_byte(i2c, I2C_PCA_CON)
- & I2C_PCA_CON_SI) == 0)
- && (ret = time_before(jiffies, timeout)))
- udelay(100);
+ while (!(i2c->algo_data.read_byte(i2c, I2C_PCA_CON)
+ & I2C_PCA_CON_SI))
+ {
+ if(time_before(jiffies, timeout))
+ udelay(100);
+ else
+ return 0;
+ }
}
- return ret > 0;
+ return ~0;
}
static void i2c_pca_pf_dummyreset(void *pd)
next reply other threads:[~2010-09-21 9:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-21 9:15 Yegor Yefremov [this message]
[not found] ` <4C9877C3.30106-ZJVcf1zZPRSebONBosFW4Q@public.gmane.org>
2010-09-21 21:04 ` [PATCH v2] fix i2c_pca_pf_waitforcompletion() return value Wolfram Sang
[not found] ` <20100921210448.GA14796-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2010-09-22 8:54 ` Yegor Yefremov
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=4C9877C3.30106@visionsystems.de \
--to=yegor_sub1-zjvcf1zzprsebonbosfw4q@public.gmane.org \
--cc=khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org \
--cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=w.sang-bIcnvbaLZ9MEGnE8C9+IrQ@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