diff mbox series

[11/25] irqchip/armada-370-xp: Simplify ipi_resume() code

Message ID 20240701170249.8128-12-kabel@kernel.org (mailing list archive)
State Superseded
Headers show
Series armada-370-xp irqchip updates round 2 | expand

Commit Message

Marek Behún July 1, 2024, 5:02 p.m. UTC
Refactor the ipi_resume() function to drop one indentation level.

Signed-off-by: Marek Behún <kabel@kernel.org>
---
 drivers/irqchip/irq-armada-370-xp.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

Comments

Andrew Lunn July 1, 2024, 10:25 p.m. UTC | #1
On Mon, Jul 01, 2024 at 07:02:35PM +0200, Marek Behún wrote:
> Refactor the ipi_resume() function to drop one indentation level.
> 
> Signed-off-by: Marek Behún <kabel@kernel.org>
> ---
>  drivers/irqchip/irq-armada-370-xp.c | 13 +++++--------
>  1 file changed, 5 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/irqchip/irq-armada-370-xp.c b/drivers/irqchip/irq-armada-370-xp.c
> index 22e1a493abae..d8b0609a9160 100644
> --- a/drivers/irqchip/irq-armada-370-xp.c
> +++ b/drivers/irqchip/irq-armada-370-xp.c
> @@ -462,16 +462,13 @@ static const struct irq_domain_ops ipi_domain_ops = {
>  static void ipi_resume(void)
>  {
>  	for (int i = 0; i < IPI_DOORBELL_END; i++) {
> -		int irq;
> +		unsigned int virq = irq_find_mapping(ipi_domain, i);
>  
> -		irq = irq_find_mapping(ipi_domain, i);
> -		if (irq <= 0)
> +		if (!virq || !irq_percpu_is_enabled(virq))
>  			continue;
> -		if (irq_percpu_is_enabled(irq)) {
> -			struct irq_data *d;
> -			d = irq_domain_get_irq_data(ipi_domain, irq);
> -			armada_370_xp_ipi_unmask(d);
> -		}
> +
> +		armada_370_xp_ipi_unmask(irq_domain_get_irq_data(ipi_domain,
> +								 virq));

This one took a while to review. Which suggests the commit message
could be better.

irq is renamed to virq. int becomes unsigned int. That then helps
explain that irq_find_mapping() does not return a negative error code,
just 0 when there is no mapping. Hence <= can become !.

I also think 

> -			struct irq_data *d;
> -			d = irq_domain_get_irq_data(ipi_domain, irq);
> -			armada_370_xp_ipi_unmask(d);

is more readable than

> +		armada_370_xp_ipi_unmask(irq_domain_get_irq_data(ipi_domain,
> +								 virq));

because it avoids the wrapping.

	Andrew
diff mbox series

Patch

diff --git a/drivers/irqchip/irq-armada-370-xp.c b/drivers/irqchip/irq-armada-370-xp.c
index 22e1a493abae..d8b0609a9160 100644
--- a/drivers/irqchip/irq-armada-370-xp.c
+++ b/drivers/irqchip/irq-armada-370-xp.c
@@ -462,16 +462,13 @@  static const struct irq_domain_ops ipi_domain_ops = {
 static void ipi_resume(void)
 {
 	for (int i = 0; i < IPI_DOORBELL_END; i++) {
-		int irq;
+		unsigned int virq = irq_find_mapping(ipi_domain, i);
 
-		irq = irq_find_mapping(ipi_domain, i);
-		if (irq <= 0)
+		if (!virq || !irq_percpu_is_enabled(virq))
 			continue;
-		if (irq_percpu_is_enabled(irq)) {
-			struct irq_data *d;
-			d = irq_domain_get_irq_data(ipi_domain, irq);
-			armada_370_xp_ipi_unmask(d);
-		}
+
+		armada_370_xp_ipi_unmask(irq_domain_get_irq_data(ipi_domain,
+								 virq));
 	}
 }