From: David Sterba <dsterba@suse.cz>
To: "Peng Fan (OSS)" <peng.fan@oss.nxp.com>
Cc: David Sterba <dsterba@suse.com>, Chris Mason <mason@kernel.org>,
linux-kernel@vger.kernel.org, Peng Fan <peng.fan@nxp.com>,
linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] btrfs: use assign_bit() where applicable
Date: Mon, 21 Sep 2026 14:55:09 +0200 [thread overview]
Message-ID: <20260921125509.GD54722@twin.jikos.cz> (raw)
In-Reply-To: <20260920022730.3145797-1-peng.fan@oss.nxp.com>
On Sun, Sep 20, 2026 at 10:27:29AM +0800, Peng Fan (OSS) wrote:
> From: Peng Fan <peng.fan@nxp.com>
>
> Convert open-coded if/else with set_bit/clear_bit and their
> non-atomic __set_bit/__clear_bit variants to the assign_bit/__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);
>
> // __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>
Added to for-next, thanks.
prev parent reply other threads:[~2026-09-21 12:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-20 2:27 [PATCH] btrfs: use assign_bit() where applicable Peng Fan (OSS)
2026-09-21 12:55 ` David Sterba [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=20260921125509.GD54722@twin.jikos.cz \
--to=dsterba@suse.cz \
--cc=dsterba@suse.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mason@kernel.org \
--cc=peng.fan@nxp.com \
--cc=peng.fan@oss.nxp.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