All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peng Fan <peng.fan@oss.nxp.com>
To: Shrikanth Hegde <sshegde@linux.ibm.com>
Cc: linux-kernel@vger.kernel.org, Peng Fan <peng.fan@nxp.com>,
	linuxppc-dev@lists.ozlabs.org, kvm@vger.kernel.org,
	Madhavan Srinivasan <maddy@linux.ibm.com>,
	Nicholas Piggin <npiggin@gmail.com>,
	Michael Ellerman <mpe@ellerman.id.au>,
	"Christophe Leroy (CS GROUP)" <chleroy@kernel.org>,
	"Ritesh Harjani (IBM)" <ritesh.list@gmail.com>
Subject: Re: [PATCH] KVM: PPC: use assign_bit() where applicable
Date: Mon, 21 Sep 2026 20:37:58 +0800	[thread overview]
Message-ID: <arElJku644yUmTUY@shlinux89> (raw)
In-Reply-To: <aed4e6a7-1678-4e27-9091-d621d3fe1535@linux.ibm.com>

Hi Shrikanth,
On Mon, Sep 21, 2026 at 02:39:34PM +0530, Shrikanth Hegde wrote:
>Hi Peng.
>
>On 9/20/26 7:56 AM, 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.
>> 
>
>Reviewed-by: Shrikanth Hegde <sshegde@linux.ibm.com>
>
>> Signed-off-by: Peng Fan <peng.fan@nxp.com>
>> ---
>>   arch/powerpc/kvm/powerpc.c | 5 +----
>>   1 file changed, 1 insertion(+), 4 deletions(-)
>> 
>> diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
>> index 9194cf492d1c..a567b63a5f1f 100644
>> --- a/arch/powerpc/kvm/powerpc.c
>> +++ b/arch/powerpc/kvm/powerpc.c
>> @@ -2210,10 +2210,7 @@ int kvm_vm_ioctl_enable_cap(struct kvm *kvm,
>>   			break;
>>   		if (!kvmppc_book3s_hcall_implemented(kvm, hcall))
>>   			break;
>> -		if (cap->args[1])
>> -			set_bit(hcall / 4, kvm->arch.enabled_hcalls);
>> -		else
>> -			clear_bit(hcall / 4, kvm->arch.enabled_hcalls);
>> +		assign_bit(hcall / 4, kvm->arch.enabled_hcalls, cap->args[1]);
>>   		r = 0;
>>   		break;
>>   	}
>
>
>Just ensure you have covered all such possible open coding where applicable
>in arch/powerpc/.

My cocci rule as below, only one candicate for arch/powerpc/ is found.

// 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);

Thanks
Peng
>


  reply	other threads:[~2026-09-21 12:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-20  2:26 [PATCH] KVM: PPC: use assign_bit() where applicable Peng Fan (OSS)
2026-09-21  9:09 ` Shrikanth Hegde
2026-09-21 12:37   ` Peng Fan [this message]
2026-09-21 11:59 ` Gautam Menghani

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=arElJku644yUmTUY@shlinux89 \
    --to=peng.fan@oss.nxp.com \
    --cc=chleroy@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maddy@linux.ibm.com \
    --cc=mpe@ellerman.id.au \
    --cc=npiggin@gmail.com \
    --cc=peng.fan@nxp.com \
    --cc=ritesh.list@gmail.com \
    --cc=sshegde@linux.ibm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.