mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mikulas Patocka <mpatocka@redhat.com>
To: "Peng Fan (OSS)" <peng.fan@oss.nxp.com>
Cc: Alasdair Kergon <agk@redhat.com>,
	Mike Snitzer <snitzer@kernel.org>,
	 Benjamin Marzinski <bmarzins@redhat.com>,
	linux-kernel@vger.kernel.org,  Peng Fan <peng.fan@nxp.com>,
	dm-devel@lists.linux.dev
Subject: Re: [Patch V2] dm: use assign_bit() where applicable
Date: Mon, 21 Sep 2026 16:16:19 +0200 (CEST)	[thread overview]
Message-ID: <23daf47a-1a1e-2a2d-1fc8-0e9a01183e0d@redhat.com> (raw)
In-Reply-To: <20260921081009.278532-1-peng.fan@oss.nxp.com>

Accepted, thanks.

Mikulas



On Mon, 21 Sep 2026, Peng Fan (OSS) wrote:

> 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
> 


      parent reply	other threads:[~2026-09-21 14:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-21  8:10 Peng Fan (OSS)
2026-09-21  8:10 ` [Patch V2] md/raid: " Peng Fan (OSS)
2026-09-21 14:16 ` Mikulas Patocka [this message]

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=23daf47a-1a1e-2a2d-1fc8-0e9a01183e0d@redhat.com \
    --to=mpatocka@redhat.com \
    --cc=agk@redhat.com \
    --cc=bmarzins@redhat.com \
    --cc=dm-devel@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peng.fan@nxp.com \
    --cc=peng.fan@oss.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®