* [PATCH v2] i2c: i2c-mxs: Check the return value from stmp_reset_block()
@ 2013-07-11 1:19 Fabio Estevam
[not found] ` <1373505568-21477-1-git-send-email-festevam-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: Fabio Estevam @ 2013-07-11 1:19 UTC (permalink / raw)
To: wsa-z923LK4zBo2bacvFa/9K2g
Cc: marex-ynQEQJNshbs, linux-i2c-u79uwXL29TY76Z2rM5mHXA,
Fabio Estevam
From: Fabio Estevam <fabio.estevam-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
stmp_reset_block() may fail, so let's check its return value and propagate it in
the case of error.
Signed-off-by: Fabio Estevam <fabio.estevam-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
---
Changes since v1:
- Check the return value of all occurences of mxs_i2c_reset()
drivers/i2c/busses/i2c-mxs.c | 26 +++++++++++++++++++-------
1 file changed, 19 insertions(+), 7 deletions(-)
diff --git a/drivers/i2c/busses/i2c-mxs.c b/drivers/i2c/busses/i2c-mxs.c
index df8ff5a..90c052e 100644
--- a/drivers/i2c/busses/i2c-mxs.c
+++ b/drivers/i2c/busses/i2c-mxs.c
@@ -123,9 +123,11 @@ struct mxs_i2c_dev {
bool dma_read;
};
-static void mxs_i2c_reset(struct mxs_i2c_dev *i2c)
+static int mxs_i2c_reset(struct mxs_i2c_dev *i2c)
{
- stmp_reset_block(i2c->regs);
+ int ret = stmp_reset_block(i2c->regs);
+ if (ret)
+ return ret;
/*
* Configure timing for the I2C block. The I2C TIMING2 register has to
@@ -139,6 +141,8 @@ static void mxs_i2c_reset(struct mxs_i2c_dev *i2c)
writel(0x00300030, i2c->regs + MXS_I2C_TIMING2);
writel(MXS_I2C_IRQ_MASK << 8, i2c->regs + MXS_I2C_CTRL1_SET);
+
+ return 0;
}
static void mxs_i2c_dma_finish(struct mxs_i2c_dev *i2c)
@@ -475,7 +479,7 @@ static int mxs_i2c_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg,
int stop)
{
struct mxs_i2c_dev *i2c = i2c_get_adapdata(adap);
- int ret;
+ int ret, err;
int flags;
flags = stop ? MXS_I2C_CTRL0_POST_SEND_STOP : 0;
@@ -495,8 +499,11 @@ static int mxs_i2c_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg,
i2c->cmd_err = 0;
if (msg->len < 8) {
ret = mxs_i2c_pio_setup_xfer(adap, msg, flags);
- if (ret)
- mxs_i2c_reset(i2c);
+ if (ret) {
+ err = mxs_i2c_reset(i2c);
+ if (err)
+ return err;
+ }
} else {
INIT_COMPLETION(i2c->cmd_complete);
ret = mxs_i2c_dma_setup_xfer(adap, msg, flags);
@@ -527,7 +534,10 @@ static int mxs_i2c_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg,
timeout:
dev_dbg(i2c->dev, "Timeout!\n");
mxs_i2c_dma_finish(i2c);
- mxs_i2c_reset(i2c);
+ ret = mxs_i2c_reset(i2c);
+ if (ret)
+ return ret;
+
return -ETIMEDOUT;
}
@@ -683,7 +693,9 @@ static int mxs_i2c_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, i2c);
/* Do reset to enforce correct startup after pinmuxing */
- mxs_i2c_reset(i2c);
+ err = mxs_i2c_reset(i2c);
+ if (err)
+ return err;
adap = &i2c->adapter;
strlcpy(adap->name, "MXS I2C adapter", sizeof(adap->name));
--
1.8.1.2
^ permalink raw reply related [flat|nested] 5+ messages in thread[parent not found: <1373505568-21477-1-git-send-email-festevam-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH v2] i2c: i2c-mxs: Check the return value from stmp_reset_block() [not found] ` <1373505568-21477-1-git-send-email-festevam-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2013-07-11 2:27 ` Marek Vasut 2013-08-15 10:00 ` Wolfram Sang 1 sibling, 0 replies; 5+ messages in thread From: Marek Vasut @ 2013-07-11 2:27 UTC (permalink / raw) To: Fabio Estevam Cc: wsa-z923LK4zBo2bacvFa/9K2g, linux-i2c-u79uwXL29TY76Z2rM5mHXA, Fabio Estevam Dear Fabio Estevam, > From: Fabio Estevam <fabio.estevam-KZfg59tc24xl57MIdRCFDg@public.gmane.org> > > stmp_reset_block() may fail, so let's check its return value and propagate > it in the case of error. > > Signed-off-by: Fabio Estevam <fabio.estevam-KZfg59tc24xl57MIdRCFDg@public.gmane.org> > --- > Changes since v1: > - Check the return value of all occurences of mxs_i2c_reset() > > drivers/i2c/busses/i2c-mxs.c | 26 +++++++++++++++++++------- > 1 file changed, 19 insertions(+), 7 deletions(-) The error handling in mxs_i2c_xfer_msg() is ugly and will need to be reworked, but this is not for this patch. Acked-by: Marek Vasut <marex-ynQEQJNshbs@public.gmane.org> Best regards, Marek Vasut ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] i2c: i2c-mxs: Check the return value from stmp_reset_block() [not found] ` <1373505568-21477-1-git-send-email-festevam-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2013-07-11 2:27 ` Marek Vasut @ 2013-08-15 10:00 ` Wolfram Sang 2013-08-15 21:31 ` Marek Vasut 1 sibling, 1 reply; 5+ messages in thread From: Wolfram Sang @ 2013-08-15 10:00 UTC (permalink / raw) To: Fabio Estevam Cc: marex-ynQEQJNshbs, linux-i2c-u79uwXL29TY76Z2rM5mHXA, Fabio Estevam [-- Attachment #1: Type: text/plain, Size: 454 bytes --] On Wed, Jul 10, 2013 at 10:19:28PM -0300, Fabio Estevam wrote: > From: Fabio Estevam <fabio.estevam-KZfg59tc24xl57MIdRCFDg@public.gmane.org> > > stmp_reset_block() may fail, so let's check its return value and propagate it in > the case of error. > > Signed-off-by: Fabio Estevam <fabio.estevam-KZfg59tc24xl57MIdRCFDg@public.gmane.org> Applied to for-next, thanks! Marek: can you base your pio rework on top of this patch, too? Thanks. [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 836 bytes --] ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] i2c: i2c-mxs: Check the return value from stmp_reset_block() 2013-08-15 10:00 ` Wolfram Sang @ 2013-08-15 21:31 ` Marek Vasut [not found] ` <201308152331.23742.marex-ynQEQJNshbs@public.gmane.org> 0 siblings, 1 reply; 5+ messages in thread From: Marek Vasut @ 2013-08-15 21:31 UTC (permalink / raw) To: Wolfram Sang Cc: Fabio Estevam, linux-i2c-u79uwXL29TY76Z2rM5mHXA, Fabio Estevam Dear Wolfram Sang, > On Wed, Jul 10, 2013 at 10:19:28PM -0300, Fabio Estevam wrote: > > From: Fabio Estevam <fabio.estevam-KZfg59tc24xl57MIdRCFDg@public.gmane.org> > > > > stmp_reset_block() may fail, so let's check its return value and > > propagate it in the case of error. > > > > Signed-off-by: Fabio Estevam <fabio.estevam-KZfg59tc24xl57MIdRCFDg@public.gmane.org> > > Applied to for-next, thanks! > > Marek: can you base your pio rework on top of this patch, too? Yeah, where is this tree/branch please ? Best regards, Marek Vasut ^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <201308152331.23742.marex-ynQEQJNshbs@public.gmane.org>]
* Re: [PATCH v2] i2c: i2c-mxs: Check the return value from stmp_reset_block() [not found] ` <201308152331.23742.marex-ynQEQJNshbs@public.gmane.org> @ 2013-08-16 16:13 ` Wolfram Sang 0 siblings, 0 replies; 5+ messages in thread From: Wolfram Sang @ 2013-08-16 16:13 UTC (permalink / raw) To: Marek Vasut Cc: Fabio Estevam, linux-i2c-u79uwXL29TY76Z2rM5mHXA, Fabio Estevam [-- Attachment #1: Type: text/plain, Size: 783 bytes --] On Thu, Aug 15, 2013 at 11:31:23PM +0200, Marek Vasut wrote: > Dear Wolfram Sang, > > > On Wed, Jul 10, 2013 at 10:19:28PM -0300, Fabio Estevam wrote: > > > From: Fabio Estevam <fabio.estevam-KZfg59tc24xl57MIdRCFDg@public.gmane.org> > > > > > > stmp_reset_block() may fail, so let's check its return value and > > > propagate it in the case of error. > > > > > > Signed-off-by: Fabio Estevam <fabio.estevam-KZfg59tc24xl57MIdRCFDg@public.gmane.org> > > > > Applied to for-next, thanks! > > > > Marek: can you base your pio rework on top of this patch, too? > > Yeah, where is this tree/branch please ? git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/for-next Forgot to push yesterday, will do soon. Lothar's patch will be there as well. [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 836 bytes --] ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-08-16 16:13 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-11 1:19 [PATCH v2] i2c: i2c-mxs: Check the return value from stmp_reset_block() Fabio Estevam
[not found] ` <1373505568-21477-1-git-send-email-festevam-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-07-11 2:27 ` Marek Vasut
2013-08-15 10:00 ` Wolfram Sang
2013-08-15 21:31 ` Marek Vasut
[not found] ` <201308152331.23742.marex-ynQEQJNshbs@public.gmane.org>
2013-08-16 16:13 ` Wolfram Sang
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).