* [PATCH] KVM: PPC: use assign_bit() where applicable
@ 2026-09-20 2:26 Peng Fan (OSS)
2026-09-21 9:09 ` Shrikanth Hegde
2026-09-21 11:59 ` Gautam Menghani
0 siblings, 2 replies; 4+ messages in thread
From: Peng Fan (OSS) @ 2026-09-20 2:26 UTC (permalink / raw)
To: Madhavan Srinivasan, Nicholas Piggin, Michael Ellerman,
Christophe Leroy (CS GROUP), Ritesh Harjani (IBM),
Shrikanth Hegde
Cc: linux-kernel, Peng Fan, linuxppc-dev, kvm
From: Peng Fan <peng.fan@nxp.com>
Convert open-coded if/else with set_bit/clear_bit to the assign_bit API.
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;
}
--
2.51.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] KVM: PPC: use assign_bit() where applicable
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
2026-09-21 11:59 ` Gautam Menghani
1 sibling, 1 reply; 4+ messages in thread
From: Shrikanth Hegde @ 2026-09-21 9:09 UTC (permalink / raw)
To: Peng Fan (OSS)
Cc: linux-kernel, Peng Fan, linuxppc-dev, kvm, Madhavan Srinivasan,
Nicholas Piggin, Michael Ellerman, Christophe Leroy (CS GROUP),
Ritesh Harjani (IBM)
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/.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] KVM: PPC: use assign_bit() where applicable
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 11:59 ` Gautam Menghani
1 sibling, 0 replies; 4+ messages in thread
From: Gautam Menghani @ 2026-09-21 11:59 UTC (permalink / raw)
To: Peng Fan (OSS)
Cc: Madhavan Srinivasan, Nicholas Piggin, Michael Ellerman,
Christophe Leroy (CS GROUP), Ritesh Harjani (IBM),
Shrikanth Hegde, linux-kernel, Peng Fan, linuxppc-dev, kvm
On Sun, Sep 20, 2026 at 10:26:17AM +0800, 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.
>
> 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;
> }
> --
> 2.51.0
>
>
Thanks for the cleanup.
Reviewed-by: Gautam Menghani <gautam@linux.ibm.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] KVM: PPC: use assign_bit() where applicable
2026-09-21 9:09 ` Shrikanth Hegde
@ 2026-09-21 12:37 ` Peng Fan
0 siblings, 0 replies; 4+ messages in thread
From: Peng Fan @ 2026-09-21 12:37 UTC (permalink / raw)
To: Shrikanth Hegde
Cc: linux-kernel, Peng Fan, linuxppc-dev, kvm, Madhavan Srinivasan,
Nicholas Piggin, Michael Ellerman, Christophe Leroy (CS GROUP),
Ritesh Harjani (IBM)
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
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-09-21 12:34 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2026-09-21 11:59 ` Gautam Menghani
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®