From: "Christoph Böhmwalder" <christoph.boehmwalder@linbit.com>
To: "Peng Fan (OSS)" <peng.fan@oss.nxp.com>,
Philipp Reisner <philipp.reisner@linbit.com>,
Lars Ellenberg <lars.ellenberg@linbit.com>,
Jens Axboe <axboe@kernel.dk>, Denis Efremov <efremov@linux.com>,
Yuho Choi <dbgh9129@gmail.com>, Peng Fan <peng.fan@nxp.com>,
Hongyan Xu <getshell@seu.edu.cn>,
Mateusz Nowicki <mateusz.nowicki@posteo.net>
Cc: linux-kernel@vger.kernel.org, drbd-dev@lists.linux.dev,
linux-block@vger.kernel.org
Subject: Re: [PATCH] block: use assign_bit() where applicable
Date: Mon, 21 Sep 2026 13:46:04 +0200 [thread overview]
Message-ID: <b0ec8c92-cf1b-4e71-81ee-cbed5db56365@linbit.com> (raw)
In-Reply-To: <20260918141609.3022848-1-peng.fan@oss.nxp.com>
On 9/18/26 16:16, 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>
> ---
> drivers/block/drbd/drbd_nl.c | 16 ++++------------
> drivers/block/drbd/drbd_receiver.c | 5 +----
> drivers/block/floppy.c | 8 ++------
> drivers/block/mtip32xx/mtip32xx.c | 6 ++----
> 4 files changed, 9 insertions(+), 26 deletions(-)
For DRBD:
Reviewed-by: Christoph Böhmwalder <christoph.boehmwalder@linbit.com>
Regards,
Christoph
prev parent reply other threads:[~2026-09-21 11:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-18 14:16 Peng Fan (OSS)
2026-09-21 11:46 ` Christoph Böhmwalder [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=b0ec8c92-cf1b-4e71-81ee-cbed5db56365@linbit.com \
--to=christoph.boehmwalder@linbit.com \
--cc=axboe@kernel.dk \
--cc=dbgh9129@gmail.com \
--cc=drbd-dev@lists.linux.dev \
--cc=efremov@linux.com \
--cc=getshell@seu.edu.cn \
--cc=lars.ellenberg@linbit.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mateusz.nowicki@posteo.net \
--cc=peng.fan@nxp.com \
--cc=peng.fan@oss.nxp.com \
--cc=philipp.reisner@linbit.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
all inboxes | Powered by JetHome®