All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lars-Peter Clausen <lars@metafoo.de>
To: Wolfram Sang <wsa@kernel.org>
Cc: Michal Simek <michal.simek@xilinx.com>,
	Shubhrajyoti Datta <Shubhrajyoti.datta@amd.com>,
	linux-i2c@vger.kernel.org, Lars-Peter Clausen <lars@metafoo.de>
Subject: [PATCH 3/5] i2c: cadence: Remove redundant expression in if clause
Date: Sat,  7 Jan 2023 13:18:12 -0800	[thread overview]
Message-ID: <20230107211814.1179438-4-lars@metafoo.de> (raw)
In-Reply-To: <20230107211814.1179438-1-lars@metafoo.de>

In the mrecv() function the Cadence I2C driver has the following expression
in an if clause.

	((id->p_msg->flags & I2C_M_RECV_LEN) != I2C_M_RECV_LEN) &&
	 (id->recv_count <= CDNS_I2C_FIFO_DEPTH))

Earlier in the same function when I2C_M_RECV_LEN is set the recv_count is
initialized to a value that is larger than CDNS_I2C_FIFO_DEPTH. This means
if the first expression is false the second expression is also false.
Checking the first expression is thus redundant and can be removed.

This slightly simplifies the logic.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/i2c/busses/i2c-cadence.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c
index e2a4cb694cfb..b5d22e7282c2 100644
--- a/drivers/i2c/busses/i2c-cadence.c
+++ b/drivers/i2c/busses/i2c-cadence.c
@@ -612,9 +612,7 @@ static void cdns_i2c_mrecv(struct cdns_i2c *id)
 	}
 
 	/* Determine hold_clear based on number of bytes to receive and hold flag */
-	if (!id->bus_hold_flag &&
-	    ((id->p_msg->flags & I2C_M_RECV_LEN) != I2C_M_RECV_LEN) &&
-	    (id->recv_count <= CDNS_I2C_FIFO_DEPTH)) {
+	if (!id->bus_hold_flag && id->recv_count <= CDNS_I2C_FIFO_DEPTH) {
 		if (cdns_i2c_readreg(CDNS_I2C_CR_OFFSET) & CDNS_I2C_CR_HOLD) {
 			hold_clear = true;
 			if (id->quirks & CDNS_I2C_BROKEN_HOLD_BIT)
-- 
2.30.2


  parent reply	other threads:[~2023-01-07 21:42 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-07 21:18 [PATCH 0/5] i2c: cadence: Small cleanups Lars-Peter Clausen
2023-01-07 21:18 ` [PATCH 1/5] i2c: cadence: Remove unused CDNS_I2C_DATA_INTR_DEPTH define Lars-Peter Clausen
2023-01-16 14:37   ` Michal Simek
2023-01-20  8:56   ` Wolfram Sang
2023-01-07 21:18 ` [PATCH 2/5] i2c: cadence: Remove `irq` field from driver state struct Lars-Peter Clausen
2023-01-16 14:39   ` Michal Simek
2023-01-20  8:56   ` Wolfram Sang
2023-01-07 21:18 ` Lars-Peter Clausen [this message]
2023-01-16 14:44   ` [PATCH 3/5] i2c: cadence: Remove redundant expression in if clause Michal Simek
2023-01-20  8:56   ` Wolfram Sang
2023-01-07 21:18 ` [PATCH 4/5] i2c: cadence: Remove always false ternary operator Lars-Peter Clausen
2023-01-16 15:00   ` Michal Simek
2023-02-27 10:46   ` Michal Simek
2023-03-16 19:29   ` Wolfram Sang
2023-01-07 21:18 ` [PATCH 5/5] i2c: cadence: Remove unnecessary register reads Lars-Peter Clausen
2023-01-16 14:58   ` Michal Simek
2023-01-16 17:14     ` Lars-Peter Clausen
2023-02-27 10:47       ` Michal Simek
2023-03-16 19:28         ` Wolfram Sang
2023-03-16 19:29   ` Wolfram Sang
     [not found] ` <BY5PR12MB4902E8FC89477C6A1038F15281A09@BY5PR12MB4902.namprd12.prod.outlook.com>
2023-02-16  5:18   ` [PATCH 0/5] i2c: cadence: Small cleanups Guntupalli, Manikanta

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=20230107211814.1179438-4-lars@metafoo.de \
    --to=lars@metafoo.de \
    --cc=Shubhrajyoti.datta@amd.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=michal.simek@xilinx.com \
    --cc=wsa@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.