[PATCH -next] irqchip/sifive-plic: Make use of __assign_bit() API

Hongbo Li posted 1 patch 1 year, 3 months ago
drivers/irqchip/irq-sifive-plic.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
[PATCH -next] irqchip/sifive-plic: Make use of __assign_bit() API
Posted by Hongbo Li 1 year, 3 months ago
We have for some time the __assign_bit() API to replace
open coded
    if (foo)
        __set_bit(n, bar);
    else
        __clear_bit(n, bar);

Use this API to simplify the code. No functional change
intended.

Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
---
 drivers/irqchip/irq-sifive-plic.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/irqchip/irq-sifive-plic.c b/drivers/irqchip/irq-sifive-plic.c
index 2f6ef5c495bd..c576b9bbeb13 100644
--- a/drivers/irqchip/irq-sifive-plic.c
+++ b/drivers/irqchip/irq-sifive-plic.c
@@ -252,10 +252,8 @@ static int plic_irq_suspend(void)
 	priv = per_cpu_ptr(&plic_handlers, smp_processor_id())->priv;
 
 	for (i = 0; i < priv->nr_irqs; i++)
-		if (readl(priv->regs + PRIORITY_BASE + i * PRIORITY_PER_ID))
-			__set_bit(i, priv->prio_save);
-		else
-			__clear_bit(i, priv->prio_save);
+		__assign_bit(i, priv->prio_save,
+		    readl(priv->regs + PRIORITY_BASE + i * PRIORITY_PER_ID));
 
 	for_each_cpu(cpu, cpu_present_mask) {
 		struct plic_handler *handler = per_cpu_ptr(&plic_handlers, cpu);
-- 
2.34.1
Re: [PATCH -next] irqchip/sifive-plic: Make use of __assign_bit() API
Posted by Palmer Dabbelt 1 year, 3 months ago
On Mon, 02 Sep 2024 06:08:24 PDT (-0700), lihongbo22@huawei.com wrote:
> We have for some time the __assign_bit() API to replace
> open coded
>     if (foo)
>         __set_bit(n, bar);
>     else
>         __clear_bit(n, bar);
>
> Use this API to simplify the code. No functional change
> intended.
>
> Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
> ---
>  drivers/irqchip/irq-sifive-plic.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/irqchip/irq-sifive-plic.c b/drivers/irqchip/irq-sifive-plic.c
> index 2f6ef5c495bd..c576b9bbeb13 100644
> --- a/drivers/irqchip/irq-sifive-plic.c
> +++ b/drivers/irqchip/irq-sifive-plic.c
> @@ -252,10 +252,8 @@ static int plic_irq_suspend(void)
>  	priv = per_cpu_ptr(&plic_handlers, smp_processor_id())->priv;
>
>  	for (i = 0; i < priv->nr_irqs; i++)
> -		if (readl(priv->regs + PRIORITY_BASE + i * PRIORITY_PER_ID))
> -			__set_bit(i, priv->prio_save);
> -		else
> -			__clear_bit(i, priv->prio_save);
> +		__assign_bit(i, priv->prio_save,
> +		    readl(priv->regs + PRIORITY_BASE + i * PRIORITY_PER_ID));
>
>  	for_each_cpu(cpu, cpu_present_mask) {
>  		struct plic_handler *handler = per_cpu_ptr(&plic_handlers, cpu);

Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
[tip: irq/core] irqchip/sifive-plic: Make use of __assign_bit()
Posted by tip-bot2 for Hongbo Li 1 year, 2 months ago
The following commit has been merged into the irq/core branch of tip:

Commit-ID:     40d7af5375a4e27d8576d9d11954ac213d06f09e
Gitweb:        https://git.kernel.org/tip/40d7af5375a4e27d8576d9d11954ac213d06f09e
Author:        Hongbo Li <lihongbo22@huawei.com>
AuthorDate:    Mon, 02 Sep 2024 21:08:24 +08:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Wed, 02 Oct 2024 15:39:39 +02:00

irqchip/sifive-plic: Make use of __assign_bit()

Replace the open coded

if (foo)
        __set_bit(n, bar);
    else
        __clear_bit(n, bar);

with __assign_bit(). No functional change intended.

Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
Link: https://lore.kernel.org/all/20240902130824.2878644-1-lihongbo22@huawei.com

---
 drivers/irqchip/irq-sifive-plic.c |  9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/irqchip/irq-sifive-plic.c b/drivers/irqchip/irq-sifive-plic.c
index 2f6ef5c..a3b199d 100644
--- a/drivers/irqchip/irq-sifive-plic.c
+++ b/drivers/irqchip/irq-sifive-plic.c
@@ -251,11 +251,10 @@ static int plic_irq_suspend(void)
 
 	priv = per_cpu_ptr(&plic_handlers, smp_processor_id())->priv;
 
-	for (i = 0; i < priv->nr_irqs; i++)
-		if (readl(priv->regs + PRIORITY_BASE + i * PRIORITY_PER_ID))
-			__set_bit(i, priv->prio_save);
-		else
-			__clear_bit(i, priv->prio_save);
+	for (i = 0; i < priv->nr_irqs; i++) {
+		__assign_bit(i, priv->prio_save,
+			     readl(priv->regs + PRIORITY_BASE + i * PRIORITY_PER_ID));
+	}
 
 	for_each_cpu(cpu, cpu_present_mask) {
 		struct plic_handler *handler = per_cpu_ptr(&plic_handlers, cpu);