Thread (2 messages) flat view 2 messages, 2 authors, 2015-08-17

[PATCH v2 1/2] i2c: add i2c-lpc2k driver

From: Joachim Eastwood <hidden>
Date: 2015-08-17 20:37:19
Also in: linux-devicetree, linux-i2c

On 17 August 2015 at 22:18, Ezequiel Garcia
[off-list ref] wrote:
On 16 Aug 08:10 PM, Joachim Eastwood wrote:
[..]
quoted
+
+static int 2(struct lpc2k_i2c *i2c)
+{
+     unsigned long timeout = jiffies + msecs_to_jiffies(1000);
+
+     /*1
+      * If the transfer needs to abort for some reason, we'll try to
+      * force a stop condition to clear any pending bus conditions
+      */
+     writel(LPC24XX_STO, i2c->base + LPC24XX_I2CONSET);
+
+     /* Wait for status change */
+     while (readl(i2c->base + LPC24XX_I2STAT) != M_I2C_IDLE) {
+             if (time_after(jiffies, timeout)) {
+                     /* Bus was not idle, try to reset adapter */
+                     i2c_lpc2k_reset(i2c);
+                     return -EBUSY;
+             }
+
+             cpu_relax();
+     }
I believe you can use readl_{relaxed}_poll_timeout_{atomic} here.
I did consider it, but since I don't have a good to way test the code
path I left it as it was.
Also since readl_{relaxed}_poll_timeout_{atomic} takes parameters in
us it seemed unsuitable for a 1s total sleep, but I may be wrong.
Ccing Ariel, maybe he can help with a test.
That would be great.

regards,
Joachim Eastwood
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help