Skip to contentSkip to conversation

regmap: irq: Get rid of duplicate check in regmap_del_irq_chip()

PATCH In review Andy Shevchenko 3 participants 4 messages Oct 21 – Oct 22

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 regmap: irq: Get rid of duplicate check in regmap_del_irq_chip()

irq_dispose_mapping() already 0-aware, so there is no need to perform the same test outside of the call. Get rid of duplicate check in regmap_del_irq_chip().

---
 drivers/base/regmap/regmap-irq.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/base/regmap/regmap-irq.c +1 -4
index 715eb9e7aa2a..bd7c89618dd7 100644
@@ -1021,7 +1021,6 @@ EXPORT_SYMBOL_GPL(regmap_add_irq_chip);
  */
 void regmap_del_irq_chip(int irq, struct regmap_irq_chip_data *d)
 {
-	unsigned int virq;
 	int i, hwirq;
 
 	if (!d)
@@ -1039,9 +1038,7 @@ void regmap_del_irq_chip(int irq, struct regmap_irq_chip_data *d)
 		 * Find the virtual irq of hwirq on chip and if it is
 		 * there then dispose it
 		 */
-		virq = irq_find_mapping(d->domain, hwirq);
-		if (virq)
-			irq_dispose_mapping(virq);
+		irq_dispose_mapping(irq_find_mapping(d->domain, hwirq));
 	}
 
 	irq_domain_remove(d->domain);
Signature · 1 line
2.50.1
maintainer
#1 lore raw
Quoted 7 lines · Andy Shevchenko

irq_dispose_mapping() already 0-aware, so there is no need to perform the same test outside of the call. Get rid of duplicate check in regmap_del_irq_chip().

drivers/base/regmap/regmap-irq.c void regmap_del_irq_chip(int irq, struct regmap_irq_chip_data *d) · line 1041

Quoted 7 lines
drivers/base/regmap/regmap-irq.c +1 -3
@@ -1039,9 +1038,7 @@ void regmap_del_irq_chip(int irq, struct regmap_irq_chip_data *d)
 		 * Find the virtual irq of hwirq on chip and if it is
 		 * there then dispose it
 		 */
-		virq = irq_find_mapping(d->domain, hwirq);
-		if (virq)
-			irq_dispose_mapping(virq);
+		irq_dispose_mapping(irq_find_mapping(d->domain, hwirq));

This just makes the code less readable, and for no good reason.

Johan

maintainer
#2 lore raw
Quoted 11 lines · Johan Hovold

drivers/base/regmap/regmap-irq.c void regmap_del_irq_chip(int irq, struct regmap_irq_chip_data *d) · line 1041

Quoted 8 lines · Andy Shevchenko

irq_dispose_mapping() already 0-aware, so there is no need to perform the same test outside of the call. Get rid of duplicate check in regmap_del_irq_chip().

drivers/base/regmap/regmap-irq.c +1 -3
-		virq = irq_find_mapping(d->domain, hwirq);
-		if (virq)
-			irq_dispose_mapping(virq);
+		irq_dispose_mapping(irq_find_mapping(d->domain, hwirq));

This just makes the code less readable, and for no good reason.

Is there intended to be a benefit from the error check? It seems like a microopotimisation that just removes robustness from something that really should not be a hot path.

maintainer
#3 lore raw
Quoted 13 lines · Mark Brown
Quoted 11 lines · Johan Hovold

drivers/base/regmap/regmap-irq.c void regmap_del_irq_chip(int irq, struct regmap_irq_chip_data *d) · line 1041

Quoted 8 lines · Andy Shevchenko

irq_dispose_mapping() already 0-aware, so there is no need to perform the same test outside of the call. Get rid of duplicate check in regmap_del_irq_chip().

drivers/base/regmap/regmap-irq.c +1 -3
-		virq = irq_find_mapping(d->domain, hwirq);
-		if (virq)
-			irq_dispose_mapping(virq);
+		irq_dispose_mapping(irq_find_mapping(d->domain, hwirq));

This just makes the code less readable, and for no good reason.

Quoted 3 lines

Is there intended to be a benefit from the error check? It seems like a microopotimisation that just removes robustness from something that really should not be a hot path.

The code as it stands is easier to read and obviously correct (and matches the preceding comment); you don't need look up the definition of irq_dispose_mapping() and parse a ternary conditional to determine that.

Johan