LKML Archive mirror
 help / color / mirror / Atom feed
* [PATCH RFT 0/2] i2c: tegra-bpmp: cleanups
@ 2021-03-31  7:51 Wolfram Sang
  2021-03-31  7:51 ` [PATCH RFT 1/2] i2c: tegra-bpmp: don't modify input variable in xlate_flags Wolfram Sang
  2021-03-31  7:51 ` [PATCH RFT 2/2] i2c: tegra-bpmp: make some functions void Wolfram Sang
  0 siblings, 2 replies; 9+ messages in thread
From: Wolfram Sang @ 2021-03-31  7:51 UTC (permalink / raw)
  To: linux-i2c; +Cc: Wolfram Sang, linux-kernel, linux-tegra

While reviewing a patch for this driver, I noticed that we can remove
quite some lines here. Not tested on HW, because I don't have it. Builds
fine, though. I'd appreciate tests / reviews. Thanks!

Wolfram Sang (2):
  i2c: tegra-bpmp: don't modify input variable in xlate_flags
  i2c: tegra-bpmp: make some functions void

 drivers/i2c/busses/i2c-tegra-bpmp.c | 52 +++++++----------------------
 1 file changed, 12 insertions(+), 40 deletions(-)

-- 
2.30.0


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

* [PATCH RFT 1/2] i2c: tegra-bpmp: don't modify input variable in xlate_flags
  2021-03-31  7:51 [PATCH RFT 0/2] i2c: tegra-bpmp: cleanups Wolfram Sang
@ 2021-03-31  7:51 ` Wolfram Sang
  2021-04-01 11:10   ` Thierry Reding
                     ` (2 more replies)
  2021-03-31  7:51 ` [PATCH RFT 2/2] i2c: tegra-bpmp: make some functions void Wolfram Sang
  1 sibling, 3 replies; 9+ messages in thread
From: Wolfram Sang @ 2021-03-31  7:51 UTC (permalink / raw)
  To: linux-i2c
  Cc: Wolfram Sang, Thierry Reding, Jonathan Hunter, linux-tegra,
	linux-kernel

Since commit bc1c2048abbe ("i2c: bpmp-tegra: Ignore unknown I2C_M
flags") we don't need to mask out flags and can keep the input variable
as is to save quite some lines.

Signed-off-by: Wolfram Sang <wsa@kernel.org>
---
 drivers/i2c/busses/i2c-tegra-bpmp.c | 32 ++++++++---------------------
 1 file changed, 8 insertions(+), 24 deletions(-)

diff --git a/drivers/i2c/busses/i2c-tegra-bpmp.c b/drivers/i2c/busses/i2c-tegra-bpmp.c
index c934d636f625..295286ad6d6c 100644
--- a/drivers/i2c/busses/i2c-tegra-bpmp.c
+++ b/drivers/i2c/busses/i2c-tegra-bpmp.c
@@ -40,45 +40,29 @@ struct tegra_bpmp_i2c {
  */
 static int tegra_bpmp_xlate_flags(u16 flags, u16 *out)
 {
-	if (flags & I2C_M_TEN) {
+	if (flags & I2C_M_TEN)
 		*out |= SERIALI2C_TEN;
-		flags &= ~I2C_M_TEN;
-	}
 
-	if (flags & I2C_M_RD) {
+	if (flags & I2C_M_RD)
 		*out |= SERIALI2C_RD;
-		flags &= ~I2C_M_RD;
-	}
 
-	if (flags & I2C_M_STOP) {
+	if (flags & I2C_M_STOP)
 		*out |= SERIALI2C_STOP;
-		flags &= ~I2C_M_STOP;
-	}
 
-	if (flags & I2C_M_NOSTART) {
+	if (flags & I2C_M_NOSTART)
 		*out |= SERIALI2C_NOSTART;
-		flags &= ~I2C_M_NOSTART;
-	}
 
-	if (flags & I2C_M_REV_DIR_ADDR) {
+	if (flags & I2C_M_REV_DIR_ADDR)
 		*out |= SERIALI2C_REV_DIR_ADDR;
-		flags &= ~I2C_M_REV_DIR_ADDR;
-	}
 
-	if (flags & I2C_M_IGNORE_NAK) {
+	if (flags & I2C_M_IGNORE_NAK)
 		*out |= SERIALI2C_IGNORE_NAK;
-		flags &= ~I2C_M_IGNORE_NAK;
-	}
 
-	if (flags & I2C_M_NO_RD_ACK) {
+	if (flags & I2C_M_NO_RD_ACK)
 		*out |= SERIALI2C_NO_RD_ACK;
-		flags &= ~I2C_M_NO_RD_ACK;
-	}
 
-	if (flags & I2C_M_RECV_LEN) {
+	if (flags & I2C_M_RECV_LEN)
 		*out |= SERIALI2C_RECV_LEN;
-		flags &= ~I2C_M_RECV_LEN;
-	}
 
 	return 0;
 }
-- 
2.30.0


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

* [PATCH RFT 2/2] i2c: tegra-bpmp: make some functions void
  2021-03-31  7:51 [PATCH RFT 0/2] i2c: tegra-bpmp: cleanups Wolfram Sang
  2021-03-31  7:51 ` [PATCH RFT 1/2] i2c: tegra-bpmp: don't modify input variable in xlate_flags Wolfram Sang
@ 2021-03-31  7:51 ` Wolfram Sang
  2021-04-01 11:11   ` Thierry Reding
                     ` (2 more replies)
  1 sibling, 3 replies; 9+ messages in thread
From: Wolfram Sang @ 2021-03-31  7:51 UTC (permalink / raw)
  To: linux-i2c
  Cc: Wolfram Sang, Thierry Reding, Jonathan Hunter, linux-tegra,
	linux-kernel

They return 0 always, so save some lines and code.

Signed-off-by: Wolfram Sang <wsa@kernel.org>
---
 drivers/i2c/busses/i2c-tegra-bpmp.c | 20 ++++----------------
 1 file changed, 4 insertions(+), 16 deletions(-)

diff --git a/drivers/i2c/busses/i2c-tegra-bpmp.c b/drivers/i2c/busses/i2c-tegra-bpmp.c
index 295286ad6d6c..3680d608698b 100644
--- a/drivers/i2c/busses/i2c-tegra-bpmp.c
+++ b/drivers/i2c/busses/i2c-tegra-bpmp.c
@@ -38,7 +38,7 @@ struct tegra_bpmp_i2c {
  * firmware I2C driver to avoid any issues in future if Linux I2C flags are
  * changed.
  */
-static int tegra_bpmp_xlate_flags(u16 flags, u16 *out)
+static void tegra_bpmp_xlate_flags(u16 flags, u16 *out)
 {
 	if (flags & I2C_M_TEN)
 		*out |= SERIALI2C_TEN;
@@ -63,8 +63,6 @@ static int tegra_bpmp_xlate_flags(u16 flags, u16 *out)
 
 	if (flags & I2C_M_RECV_LEN)
 		*out |= SERIALI2C_RECV_LEN;
-
-	return 0;
 }
 
 /**
@@ -81,22 +79,19 @@ static int tegra_bpmp_xlate_flags(u16 flags, u16 *out)
  *
  * See deserialize_i2c documentation for the data format in the other direction.
  */
-static int tegra_bpmp_serialize_i2c_msg(struct tegra_bpmp_i2c *i2c,
+static void tegra_bpmp_serialize_i2c_msg(struct tegra_bpmp_i2c *i2c,
 					struct mrq_i2c_request *request,
 					struct i2c_msg *msgs,
 					unsigned int num)
 {
 	char *buf = request->xfer.data_buf;
 	unsigned int i, j, pos = 0;
-	int err;
 
 	for (i = 0; i < num; i++) {
 		struct i2c_msg *msg = &msgs[i];
 		u16 flags = 0;
 
-		err = tegra_bpmp_xlate_flags(msg->flags, &flags);
-		if (err < 0)
-			return err;
+		tegra_bpmp_xlate_flags(msg->flags, &flags);
 
 		buf[pos++] = msg->addr & 0xff;
 		buf[pos++] = (msg->addr & 0xff00) >> 8;
@@ -112,8 +107,6 @@ static int tegra_bpmp_serialize_i2c_msg(struct tegra_bpmp_i2c *i2c,
 	}
 
 	request->xfer.data_size = pos;
-
-	return 0;
 }
 
 /**
@@ -247,12 +240,7 @@ static int tegra_bpmp_i2c_xfer_common(struct i2c_adapter *adapter,
 	memset(&request, 0, sizeof(request));
 	memset(&response, 0, sizeof(response));
 
-	err = tegra_bpmp_serialize_i2c_msg(i2c, &request, msgs, num);
-	if (err < 0) {
-		dev_err(i2c->dev, "failed to serialize message: %d\n", err);
-		return err;
-	}
-
+	tegra_bpmp_serialize_i2c_msg(i2c, &request, msgs, num);
 	err = tegra_bpmp_i2c_msg_xfer(i2c, &request, &response, atomic);
 	if (err < 0) {
 		dev_err(i2c->dev, "failed to transfer message: %d\n", err);
-- 
2.30.0


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

* Re: [PATCH RFT 1/2] i2c: tegra-bpmp: don't modify input variable in xlate_flags
  2021-03-31  7:51 ` [PATCH RFT 1/2] i2c: tegra-bpmp: don't modify input variable in xlate_flags Wolfram Sang
@ 2021-04-01 11:10   ` Thierry Reding
  2021-04-01 13:23   ` Thierry Reding
  2021-04-05 21:02   ` Wolfram Sang
  2 siblings, 0 replies; 9+ messages in thread
From: Thierry Reding @ 2021-04-01 11:10 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: linux-i2c, Jonathan Hunter, linux-tegra, linux-kernel

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

On Wed, Mar 31, 2021 at 09:51:40AM +0200, Wolfram Sang wrote:
> Since commit bc1c2048abbe ("i2c: bpmp-tegra: Ignore unknown I2C_M
> flags") we don't need to mask out flags and can keep the input variable
> as is to save quite some lines.
> 
> Signed-off-by: Wolfram Sang <wsa@kernel.org>
> ---
>  drivers/i2c/busses/i2c-tegra-bpmp.c | 32 ++++++++---------------------
>  1 file changed, 8 insertions(+), 24 deletions(-)

Heh... good catch!

Acked-by: Thierry Reding <treding@nvidia.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH RFT 2/2] i2c: tegra-bpmp: make some functions void
  2021-03-31  7:51 ` [PATCH RFT 2/2] i2c: tegra-bpmp: make some functions void Wolfram Sang
@ 2021-04-01 11:11   ` Thierry Reding
  2021-04-01 13:23   ` Thierry Reding
  2021-04-05 21:03   ` Wolfram Sang
  2 siblings, 0 replies; 9+ messages in thread
From: Thierry Reding @ 2021-04-01 11:11 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: linux-i2c, Jonathan Hunter, linux-tegra, linux-kernel

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

On Wed, Mar 31, 2021 at 09:51:41AM +0200, Wolfram Sang wrote:
> They return 0 always, so save some lines and code.
> 
> Signed-off-by: Wolfram Sang <wsa@kernel.org>
> ---
>  drivers/i2c/busses/i2c-tegra-bpmp.c | 20 ++++----------------
>  1 file changed, 4 insertions(+), 16 deletions(-)

Acked-by: Thierry Reding <treding@nvidia.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH RFT 1/2] i2c: tegra-bpmp: don't modify input variable in xlate_flags
  2021-03-31  7:51 ` [PATCH RFT 1/2] i2c: tegra-bpmp: don't modify input variable in xlate_flags Wolfram Sang
  2021-04-01 11:10   ` Thierry Reding
@ 2021-04-01 13:23   ` Thierry Reding
  2021-04-05 21:02   ` Wolfram Sang
  2 siblings, 0 replies; 9+ messages in thread
From: Thierry Reding @ 2021-04-01 13:23 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: linux-i2c, Jonathan Hunter, linux-tegra, linux-kernel

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

On Wed, Mar 31, 2021 at 09:51:40AM +0200, Wolfram Sang wrote:
> Since commit bc1c2048abbe ("i2c: bpmp-tegra: Ignore unknown I2C_M
> flags") we don't need to mask out flags and can keep the input variable
> as is to save quite some lines.
> 
> Signed-off-by: Wolfram Sang <wsa@kernel.org>
> ---
>  drivers/i2c/busses/i2c-tegra-bpmp.c | 32 ++++++++---------------------
>  1 file changed, 8 insertions(+), 24 deletions(-)

I've applied this to my local development tree and ran this on Tegra194,
didn't see any issues, so:

Tested-by: Thierry Reding <treding@nvidia.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH RFT 2/2] i2c: tegra-bpmp: make some functions void
  2021-03-31  7:51 ` [PATCH RFT 2/2] i2c: tegra-bpmp: make some functions void Wolfram Sang
  2021-04-01 11:11   ` Thierry Reding
@ 2021-04-01 13:23   ` Thierry Reding
  2021-04-05 21:03   ` Wolfram Sang
  2 siblings, 0 replies; 9+ messages in thread
From: Thierry Reding @ 2021-04-01 13:23 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: linux-i2c, Jonathan Hunter, linux-tegra, linux-kernel

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

On Wed, Mar 31, 2021 at 09:51:41AM +0200, Wolfram Sang wrote:
> They return 0 always, so save some lines and code.
> 
> Signed-off-by: Wolfram Sang <wsa@kernel.org>
> ---
>  drivers/i2c/busses/i2c-tegra-bpmp.c | 20 ++++----------------
>  1 file changed, 4 insertions(+), 16 deletions(-)

Tested-by: Thierry Reding <treding@nvidia.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH RFT 1/2] i2c: tegra-bpmp: don't modify input variable in xlate_flags
  2021-03-31  7:51 ` [PATCH RFT 1/2] i2c: tegra-bpmp: don't modify input variable in xlate_flags Wolfram Sang
  2021-04-01 11:10   ` Thierry Reding
  2021-04-01 13:23   ` Thierry Reding
@ 2021-04-05 21:02   ` Wolfram Sang
  2 siblings, 0 replies; 9+ messages in thread
From: Wolfram Sang @ 2021-04-05 21:02 UTC (permalink / raw)
  To: linux-i2c; +Cc: Thierry Reding, Jonathan Hunter, linux-tegra, linux-kernel

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

On Wed, Mar 31, 2021 at 09:51:40AM +0200, Wolfram Sang wrote:
> Since commit bc1c2048abbe ("i2c: bpmp-tegra: Ignore unknown I2C_M
> flags") we don't need to mask out flags and can keep the input variable
> as is to save quite some lines.
> 
> Signed-off-by: Wolfram Sang <wsa@kernel.org>

Applied to for-next, thanks!


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH RFT 2/2] i2c: tegra-bpmp: make some functions void
  2021-03-31  7:51 ` [PATCH RFT 2/2] i2c: tegra-bpmp: make some functions void Wolfram Sang
  2021-04-01 11:11   ` Thierry Reding
  2021-04-01 13:23   ` Thierry Reding
@ 2021-04-05 21:03   ` Wolfram Sang
  2 siblings, 0 replies; 9+ messages in thread
From: Wolfram Sang @ 2021-04-05 21:03 UTC (permalink / raw)
  To: linux-i2c; +Cc: Thierry Reding, Jonathan Hunter, linux-tegra, linux-kernel

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

On Wed, Mar 31, 2021 at 09:51:41AM +0200, Wolfram Sang wrote:
> They return 0 always, so save some lines and code.
> 
> Signed-off-by: Wolfram Sang <wsa@kernel.org>

Applied to for-next, thanks!


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2021-04-05 21:03 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-31  7:51 [PATCH RFT 0/2] i2c: tegra-bpmp: cleanups Wolfram Sang
2021-03-31  7:51 ` [PATCH RFT 1/2] i2c: tegra-bpmp: don't modify input variable in xlate_flags Wolfram Sang
2021-04-01 11:10   ` Thierry Reding
2021-04-01 13:23   ` Thierry Reding
2021-04-05 21:02   ` Wolfram Sang
2021-03-31  7:51 ` [PATCH RFT 2/2] i2c: tegra-bpmp: make some functions void Wolfram Sang
2021-04-01 11:11   ` Thierry Reding
2021-04-01 13:23   ` Thierry Reding
2021-04-05 21:03   ` 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 read-only IMAP folder(s) and NNTP newsgroup(s).