From: "Peng Fan (OSS)" <peng.fan@oss.nxp.com>
To: Alasdair Kergon <agk@redhat.com>,
Mike Snitzer <snitzer@kernel.org>,
Mikulas Patocka <mpatocka@redhat.com>,
Benjamin Marzinski <bmarzins@redhat.com>
Cc: linux-kernel@vger.kernel.org, Peng Fan <peng.fan@nxp.com>,
dm-devel@lists.linux.dev
Subject: [Patch V2] dm: use assign_bit() where applicable
Date: Mon, 21 Sep 2026 16:10:07 +0800 [thread overview]
Message-ID: <20260921081009.278532-1-peng.fan@oss.nxp.com> (raw)
From: Peng Fan <peng.fan@nxp.com>
Convert open-coded if/else with set_bit/clear_bit to the assign_bit API.
Done with Coccinelle semantic patch:
// set_bit -> clear_bit => assign_bit
@@
expression cond, bit, addr;
@@
-if (cond)
- set_bit(bit, addr);
-else
- clear_bit(bit, addr);
+assign_bit(bit, addr, cond);
// clear_bit -> set_bit => assign_bit
@@
expression cond, bit, addr;
@@
-if (cond)
- clear_bit(bit, addr);
-else
- set_bit(bit, addr);
+assign_bit(bit, addr, !cond);
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
V2:
Separate device-mapper and mraid
https://lore.kernel.org/all/20260918141737.3023011-1-peng.fan@oss.nxp.com/
drivers/md/dm-mpath.c | 5 +----
drivers/md/dm-zone.c | 6 ++----
drivers/md/persistent-data/dm-bitset.c | 5 +----
3 files changed, 4 insertions(+), 12 deletions(-)
diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
index 7cb7bb6233b6..ae9318f5f21b 100644
--- a/drivers/md/dm-mpath.c
+++ b/drivers/md/dm-mpath.c
@@ -1604,10 +1604,7 @@ static void pg_init_done(void *data, int errors)
goto out;
if (test_bit(MPATHF_PG_INIT_REQUIRED, &m->flags)) {
- if (delay_retry)
- set_bit(MPATHF_PG_INIT_DELAY_RETRY, &m->flags);
- else
- clear_bit(MPATHF_PG_INIT_DELAY_RETRY, &m->flags);
+ assign_bit(MPATHF_PG_INIT_DELAY_RETRY, &m->flags, delay_retry);
if (__pg_init_all_paths(m))
goto out;
diff --git a/drivers/md/dm-zone.c b/drivers/md/dm-zone.c
index f29acf64429a..35916c6e490e 100644
--- a/drivers/md/dm-zone.c
+++ b/drivers/md/dm-zone.c
@@ -447,10 +447,8 @@ void dm_finalize_zone_settings(struct dm_table *t, struct queue_limits *lim)
struct mapped_device *md = t->md;
if (lim->features & BLK_FEAT_ZONED) {
- if (dm_table_supports_zone_append(t))
- clear_bit(DMF_EMULATE_ZONE_APPEND, &md->flags);
- else
- set_bit(DMF_EMULATE_ZONE_APPEND, &md->flags);
+ assign_bit(DMF_EMULATE_ZONE_APPEND, &md->flags,
+ !dm_table_supports_zone_append(t));
} else {
clear_bit(DMF_EMULATE_ZONE_APPEND, &md->flags);
md->disk->nr_zones = 0;
diff --git a/drivers/md/persistent-data/dm-bitset.c b/drivers/md/persistent-data/dm-bitset.c
index 00c0a3f186b7..6680f05c25ec 100644
--- a/drivers/md/persistent-data/dm-bitset.c
+++ b/drivers/md/persistent-data/dm-bitset.c
@@ -59,10 +59,7 @@ static int pack_bits(uint32_t index, void *value, void *context)
if (r)
return r;
- if (bv)
- set_bit(bit, (unsigned long *) &word);
- else
- clear_bit(bit, (unsigned long *) &word);
+ assign_bit(bit, (unsigned long *)&word, bv);
}
*((__le64 *) value) = cpu_to_le64(word);
--
2.51.0
next reply other threads:[~2026-09-21 8:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-21 8:10 Peng Fan (OSS) [this message]
2026-09-21 8:10 ` [Patch V2] md/raid: " Peng Fan (OSS)
2026-09-23 11:15 ` yu kuai
2026-09-21 14:16 ` [Patch V2] dm: " Mikulas Patocka
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=20260921081009.278532-1-peng.fan@oss.nxp.com \
--to=peng.fan@oss.nxp.com \
--cc=agk@redhat.com \
--cc=bmarzins@redhat.com \
--cc=dm-devel@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=mpatocka@redhat.com \
--cc=peng.fan@nxp.com \
--cc=snitzer@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®