linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/3] R-Car I2C driver: some cleanups
@ 2014-09-14 20:12 Sergei Shtylyov
  2014-09-14 20:14 ` [PATCH v2 1/3] i2c-rcar: simplify check for last message Sergei Shtylyov
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Sergei Shtylyov @ 2014-09-14 20:12 UTC (permalink / raw)
  To: wsa-z923LK4zBo2bacvFa/9K2g, linux-i2c-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-sh-u79uwXL29TY76Z2rM5mHXA

Hello.

   Here's the set of 3 patches against Wolfram Sang's 'linux.git' repo's
'i2c/for-next' branch.

[1/3] i2c-rcar: simplify check for last message
[2/3] i2c-rcar: make rcar_i2c_prepare_msg() *void*
[3/3] i2c-rcar: make rcar_i2c_irq_recv() *void*

WBR, Sergei

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2 1/3] i2c-rcar: simplify check for last message
  2014-09-14 20:12 [PATCH v2 0/3] R-Car I2C driver: some cleanups Sergei Shtylyov
@ 2014-09-14 20:14 ` Sergei Shtylyov
  2014-09-20  9:41   ` Wolfram Sang
  2014-09-14 20:15 ` [PATCH v2 2/3] i2c-rcar: make rcar_i2c_prepare_msg() *void* Sergei Shtylyov
  2014-09-14 20:17 ` [PATCH v2 3/3] i2c-rcar: make rcar_i2c_irq_recv() *void* Sergei Shtylyov
  2 siblings, 1 reply; 7+ messages in thread
From: Sergei Shtylyov @ 2014-09-14 20:14 UTC (permalink / raw)
  To: wsa, linux-i2c; +Cc: linux-sh

rcar_i2c_master_xfer() needlessly compares the message pointers (using indirect
addressing) in order to detect the last I2C message, while it's enough to only
compare the message indexes.

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>

---
Changes in version 2:
- refreshed patch.

 drivers/i2c/busses/i2c-rcar.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux/drivers/i2c/busses/i2c-rcar.c
===================================================================
--- linux.orig/drivers/i2c/busses/i2c-rcar.c
+++ linux/drivers/i2c/busses/i2c-rcar.c
@@ -453,7 +453,7 @@ static int rcar_i2c_master_xfer(struct i
 		priv->msg	= &msgs[i];
 		priv->pos	= 0;
 		priv->flags	= 0;
-		if (priv->msg == &msgs[num - 1])
+		if (i == num - 1)
 			rcar_i2c_flags_set(priv, ID_LAST_MSG);
 
 		ret = rcar_i2c_prepare_msg(priv);


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2 2/3] i2c-rcar: make rcar_i2c_prepare_msg() *void*
  2014-09-14 20:12 [PATCH v2 0/3] R-Car I2C driver: some cleanups Sergei Shtylyov
  2014-09-14 20:14 ` [PATCH v2 1/3] i2c-rcar: simplify check for last message Sergei Shtylyov
@ 2014-09-14 20:15 ` Sergei Shtylyov
  2014-09-20  9:44   ` Wolfram Sang
  2014-09-14 20:17 ` [PATCH v2 3/3] i2c-rcar: make rcar_i2c_irq_recv() *void* Sergei Shtylyov
  2 siblings, 1 reply; 7+ messages in thread
From: Sergei Shtylyov @ 2014-09-14 20:15 UTC (permalink / raw)
  To: wsa, linux-i2c; +Cc: linux-sh

rcar_i2c_prepare_msg() always returns 0, so we can make this function return
*void* and thus remove the result check in rcar_i2c_master_xfer().

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>

---
Changes in version 2:
- resolved reject, refreshed patch.

 drivers/i2c/busses/i2c-rcar.c |    9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

Index: linux/drivers/i2c/busses/i2c-rcar.c
===================================================================
--- linux.orig/drivers/i2c/busses/i2c-rcar.c
+++ linux/drivers/i2c/busses/i2c-rcar.c
@@ -245,7 +245,7 @@ scgd_find:
 	return 0;
 }
 
-static int rcar_i2c_prepare_msg(struct rcar_i2c_priv *priv)
+static void rcar_i2c_prepare_msg(struct rcar_i2c_priv *priv)
 {
 	int read = !!rcar_i2c_is_recv(priv);
 
@@ -253,8 +253,6 @@ static int rcar_i2c_prepare_msg(struct r
 	rcar_i2c_write(priv, ICMSR, 0);
 	rcar_i2c_write(priv, ICMCR, RCAR_BUS_PHASE_START);
 	rcar_i2c_write(priv, ICMIER, read ? RCAR_IRQ_RECV : RCAR_IRQ_SEND);
-
-	return 0;
 }
 
 /*
@@ -456,14 +454,11 @@ static int rcar_i2c_master_xfer(struct i
 		if (i == num - 1)
 			rcar_i2c_flags_set(priv, ID_LAST_MSG);
 
-		ret = rcar_i2c_prepare_msg(priv);
+		rcar_i2c_prepare_msg(priv);
 
 		spin_unlock_irqrestore(&priv->lock, flags);
 		/*-------------- spin unlock -----------------*/
 
-		if (ret < 0)
-			break;
-
 		timeout = wait_event_timeout(priv->wait,
 					     rcar_i2c_flags_has(priv, ID_DONE),
 					     5 * HZ);


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2 3/3] i2c-rcar: make rcar_i2c_irq_recv() *void*
  2014-09-14 20:12 [PATCH v2 0/3] R-Car I2C driver: some cleanups Sergei Shtylyov
  2014-09-14 20:14 ` [PATCH v2 1/3] i2c-rcar: simplify check for last message Sergei Shtylyov
  2014-09-14 20:15 ` [PATCH v2 2/3] i2c-rcar: make rcar_i2c_prepare_msg() *void* Sergei Shtylyov
@ 2014-09-14 20:17 ` Sergei Shtylyov
  2014-09-20  9:45   ` Wolfram Sang
  2 siblings, 1 reply; 7+ messages in thread
From: Sergei Shtylyov @ 2014-09-14 20:17 UTC (permalink / raw)
  To: wsa, linux-i2c; +Cc: linux-sh

rcar_i2c_irq_recv() always returns 0, so we can make this function return
*void* and also remove rcar_i2c_flags_set() invocation in rcar_i2c_irq().

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>

---
Changes in version 2:
- refreshed patch.

 drivers/i2c/busses/i2c-rcar.c |    8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

Index: linux/drivers/i2c/busses/i2c-rcar.c
===================================================================
--- linux.orig/drivers/i2c/busses/i2c-rcar.c
+++ linux/drivers/i2c/busses/i2c-rcar.c
@@ -319,7 +319,7 @@ static int rcar_i2c_irq_send(struct rcar
 	return 0;
 }
 
-static int rcar_i2c_irq_recv(struct rcar_i2c_priv *priv, u32 msr)
+static void rcar_i2c_irq_recv(struct rcar_i2c_priv *priv, u32 msr)
 {
 	struct i2c_msg *msg = priv->msg;
 
@@ -329,7 +329,7 @@ static int rcar_i2c_irq_recv(struct rcar
 	 * Do nothing
 	 */
 	if (!(msr & MDR))
-		return 0;
+		return;
 
 	if (msr & MAT) {
 		/*
@@ -356,8 +356,6 @@ static int rcar_i2c_irq_recv(struct rcar
 		rcar_i2c_write(priv, ICMCR, RCAR_BUS_PHASE_DATA);
 
 	rcar_i2c_write(priv, ICMSR, RCAR_IRQ_ACK_RECV);
-
-	return 0;
 }
 
 static irqreturn_t rcar_i2c_irq(int irq, void *ptr)
@@ -395,7 +393,7 @@ static irqreturn_t rcar_i2c_irq(int irq,
 	}
 
 	if (rcar_i2c_is_recv(priv))
-		rcar_i2c_flags_set(priv, rcar_i2c_irq_recv(priv, msr));
+		rcar_i2c_irq_recv(priv, msr);
 	else
 		rcar_i2c_flags_set(priv, rcar_i2c_irq_send(priv, msr));
 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 1/3] i2c-rcar: simplify check for last message
  2014-09-14 20:14 ` [PATCH v2 1/3] i2c-rcar: simplify check for last message Sergei Shtylyov
@ 2014-09-20  9:41   ` Wolfram Sang
  0 siblings, 0 replies; 7+ messages in thread
From: Wolfram Sang @ 2014-09-20  9:41 UTC (permalink / raw)
  To: Sergei Shtylyov; +Cc: linux-i2c, linux-sh

[-- Attachment #1: Type: text/plain, Size: 376 bytes --]

On Mon, Sep 15, 2014 at 12:14:14AM +0400, Sergei Shtylyov wrote:
> rcar_i2c_master_xfer() needlessly compares the message pointers (using indirect
> addressing) in order to detect the last I2C message, while it's enough to only
> compare the message indexes.
> 
> Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
> 

Applied to for-next, thanks!


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 2/3] i2c-rcar: make rcar_i2c_prepare_msg() *void*
  2014-09-14 20:15 ` [PATCH v2 2/3] i2c-rcar: make rcar_i2c_prepare_msg() *void* Sergei Shtylyov
@ 2014-09-20  9:44   ` Wolfram Sang
  0 siblings, 0 replies; 7+ messages in thread
From: Wolfram Sang @ 2014-09-20  9:44 UTC (permalink / raw)
  To: Sergei Shtylyov; +Cc: linux-i2c, linux-sh

[-- Attachment #1: Type: text/plain, Size: 329 bytes --]

On Mon, Sep 15, 2014 at 12:15:46AM +0400, Sergei Shtylyov wrote:
> rcar_i2c_prepare_msg() always returns 0, so we can make this function return
> *void* and thus remove the result check in rcar_i2c_master_xfer().
> 
> Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
> 

Applied to for-next, thanks!


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 3/3] i2c-rcar: make rcar_i2c_irq_recv() *void*
  2014-09-14 20:17 ` [PATCH v2 3/3] i2c-rcar: make rcar_i2c_irq_recv() *void* Sergei Shtylyov
@ 2014-09-20  9:45   ` Wolfram Sang
  0 siblings, 0 replies; 7+ messages in thread
From: Wolfram Sang @ 2014-09-20  9:45 UTC (permalink / raw)
  To: Sergei Shtylyov; +Cc: linux-i2c, linux-sh

[-- Attachment #1: Type: text/plain, Size: 397 bytes --]

On Mon, Sep 15, 2014 at 12:17:34AM +0400, Sergei Shtylyov wrote:
> rcar_i2c_irq_recv() always returns 0, so we can make this function return
> *void* and also remove rcar_i2c_flags_set() invocation in rcar_i2c_irq().
> 
> Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>

I prefer to skip this patch to have more similarity between the
send_irq and recv_irq routines.


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-09-20  9:45 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-14 20:12 [PATCH v2 0/3] R-Car I2C driver: some cleanups Sergei Shtylyov
2014-09-14 20:14 ` [PATCH v2 1/3] i2c-rcar: simplify check for last message Sergei Shtylyov
2014-09-20  9:41   ` Wolfram Sang
2014-09-14 20:15 ` [PATCH v2 2/3] i2c-rcar: make rcar_i2c_prepare_msg() *void* Sergei Shtylyov
2014-09-20  9:44   ` Wolfram Sang
2014-09-14 20:17 ` [PATCH v2 3/3] i2c-rcar: make rcar_i2c_irq_recv() *void* Sergei Shtylyov
2014-09-20  9:45   ` 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).