public inbox for linux-kernel-mentees@lists.linux-foundation.org
 help / color / mirror / Atom feed
From: I Viswanath <viswanathiyyappan@gmail.com>
To: akhilesh@ee.iitb.ac.in
Cc: peda@axentia.se, wsa+renesas@sang-engineering.com,
	linux-i2c@vger.kernel.org, skhan@linuxfoundation.org,
	linux-kernel-mentees@lists.linux.dev,
	I Viswanath <viswanathiyyappan@gmail.com>
Subject: [PATCH v2] i2c: i2c-mux: Simplify boolean assignment in i2c_mux_alloc
Date: Mon, 25 Aug 2025 08:44:30 +0530	[thread overview]
Message-ID: <20250825031430.3001-1-viswanathiyyappan@gmail.com> (raw)
In-Reply-To: <aKu8tBBOWqltEstx@bhairav-test.ee.iitb.ac.in>

Refactor boolean field assignments of the form `if (a) b = true` to `b = a`
in i2c_mux_alloc

Signed-off-by: I Viswanath <viswanathiyyappan@gmail.com>
---
v2:
- Converted the assigned expressions to 1 bit values before assignment to make
the bitfield assignment more explict according to Akhilesh Patil's suggestion.

 drivers/i2c/i2c-mux.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/i2c/i2c-mux.c b/drivers/i2c/i2c-mux.c
index 4d8690981a55..d59644e50f14 100644
--- a/drivers/i2c/i2c-mux.c
+++ b/drivers/i2c/i2c-mux.c
@@ -241,12 +241,9 @@ struct i2c_mux_core *i2c_mux_alloc(struct i2c_adapter *parent,
 
 	muxc->parent = parent;
 	muxc->dev = dev;
-	if (flags & I2C_MUX_LOCKED)
-		muxc->mux_locked = true;
-	if (flags & I2C_MUX_ARBITRATOR)
-		muxc->arbitrator = true;
-	if (flags & I2C_MUX_GATE)
-		muxc->gate = true;
+	muxc->mux_locked = !!(flags & I2C_MUX_LOCKED);
+	muxc->arbitrator = !!(flags & I2C_MUX_ARBITRATOR);
+	muxc->gate = !!(flags & I2C_MUX_GATE);
 	muxc->select = select;
 	muxc->deselect = deselect;
 	muxc->max_adapters = max_adapters;
-- 
2.50.1


  reply	other threads:[~2025-08-25  3:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-24 18:14 [PATCH] i2c: i2c-mux: Simplify boolean assignment in i2c_mux_alloc I Viswanath
2025-08-25  1:30 ` Akhilesh Patil
2025-08-25  3:14   ` I Viswanath [this message]
2025-09-25 21:41     ` [PATCH v2] " Wolfram Sang

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=20250825031430.3001-1-viswanathiyyappan@gmail.com \
    --to=viswanathiyyappan@gmail.com \
    --cc=akhilesh@ee.iitb.ac.in \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel-mentees@lists.linux.dev \
    --cc=peda@axentia.se \
    --cc=skhan@linuxfoundation.org \
    --cc=wsa+renesas@sang-engineering.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox