Skip to contentSkip to conversation

irq_sim updates for v4.17

PATCH New Bartosz Golaszewski 2 participants 7 messages Mar 4, 2018 – Mar 9, 2018 IRQ

lore
Share & tools
lore
#0 lore raw

cover irq_sim updates for v4.17

This series contains changes that have been discussed a while ago with Marc - irq_sim_init() should return the base of the allocated interrupt range so that users don't need the irq_sim API to map the interrupt number to its offset in the array of allocated interrupts.

All external users have already been converted to correctly checking the return value (rv < 0 opposed to !rv). We can now change the implementation.

Include a small fix for irq_sim.c in the series as well.

Bartosz Golaszewski (3):
irq/irq_sim: explicitly pull in slab.h
irq/irq_sim: modify the return value check for irq_sim_init() irq/irq_sim: return the base of the irq range from irq_sim_init()

 kernel/irq/irq_sim.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
Signature · 1 line
2.16.1
#3 lore raw

PATCH 2/3 irq/irq_sim: modify the return value check for irq_sim_init()

As discussed with Marc Zyngier: irq_sim_init() and its devres variant should return the base of the allocated interrupt range on success rather than 0. This will be modified later - first, change the way devm_irq_sim_init() check the return value.

---
 kernel/irq/irq_sim.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/irq/irq_sim.c +1 -1
index bd7dc1db6a80..05f0d7c1698a 100644
@@ -124,7 +124,7 @@ int devm_irq_sim_init(struct device *dev, struct irq_sim *sim,
 		return -ENOMEM;
 
 	rv = irq_sim_init(sim, num_irqs);
-	if (rv) {
+	if (rv < 0) {
 		devres_free(dr);
 		return rv;
 	}
Signature · 1 line
2.16.1
#5 lore raw

PATCH 3/3 irq/irq_sim: return the base of the irq range from irq_sim_init()

In reply to Bartosz Golaszewski

Returning the base of the allocated interrupt range from irq_sim_init() and devm_irq_sim_init() will allow users to handle the logic of associating irq numbers with any other driver-specific resources without having to use irq_sim_irqnum().

---
 kernel/irq/irq_sim.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
kernel/irq/irq_sim.c +6 -4
index 05f0d7c1698a..85690859a2a8 100644
@@ -50,7 +50,8 @@ static void irq_sim_handle_irq(struct irq_work *work)
  * @sim:        The interrupt simulator object to initialize.
  * @num_irqs:   Number of interrupts to allocate
  *
- * Returns 0 on success and a negative error number on failure.
+ * On success: return the base of the allocated interrupt range.
+ * On failure: a negative errno.
  */
 int irq_sim_init(struct irq_sim *sim, unsigned int num_irqs)
 {
@@ -79,7 +80,7 @@ int irq_sim_init(struct irq_sim *sim, unsigned int num_irqs)
 	init_irq_work(&sim->work_ctx.work, irq_sim_handle_irq);
 	sim->irq_count = num_irqs;
 
-	return 0;
+	return sim->irq_base;
 }
 EXPORT_SYMBOL_GPL(irq_sim_init);
 
@@ -111,7 +112,8 @@ static void devm_irq_sim_release(struct device *dev, void *res)
  * @sim:        The interrupt simulator object to initialize.
  * @num_irqs:   Number of interrupts to allocate
  *
- * Returns 0 on success and a negative error number on failure.
+ * On success: return the base of the allocated interrupt range.
+ * On failure: a negative errno.
  */
 int devm_irq_sim_init(struct device *dev, struct irq_sim *sim,
 		      unsigned int num_irqs)
@@ -132,7 +134,7 @@ int devm_irq_sim_init(struct device *dev, struct irq_sim *sim,
 	dr->sim = sim;
 	devres_add(dev, dr);
 
-	return 0;
+	return rv;
 }
 EXPORT_SYMBOL_GPL(devm_irq_sim_init);
 
Signature · 1 line
2.16.1
#1 lore raw

PATCH 1/3 irq/irq_sim: explicitly pull in slab.h

In reply to Bartosz Golaszewski

We're calling kfree() in the irq_sim code but slab.h is pulled in indirectly via irq.h. Include it explicitly.

---
 kernel/irq/irq_sim.c | 1 +
 1 file changed, 1 insertion(+)
kernel/irq/irq_sim.c +1 -0
index 24caabf1a0f7..bd7dc1db6a80 100644
@@ -7,6 +7,7 @@
  * option) any later version.
  */
 
+#include <linux/slab.h>
 #include <linux/irq_sim.h>
 #include <linux/irq.h>
 
Signature · 1 line
2.16.1
#2 lore raw

[tip:irq/core] genirq/irq_sim: Explicitly include slab.h

genirq/irq_sim: Explicitly include slab.h
Commit-ID:  34a866bd45d69754da1979e83a37bec6defc6295
Gitweb:     https://git.kernel.org/tip/34a866bd45d69754da1979e83a37bec6defc6295
Author:     Bartosz Golaszewski <[email protected]>
AuthorDate: Sun, 4 Mar 2018 13:10:16 +0100
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Fri, 9 Mar 2018 11:44:03 +0100

genirq/irq_sim: Explicitly include slab.h

kfree() is used in the irq_sim code but slab.h is pulled in indirectly via irq.h. Include it explicitly.

---
 kernel/irq/irq_sim.c | 1 +
 1 file changed, 1 insertion(+)
kernel/irq/irq_sim.c +1 -0
index 24caabf1a0f7..bd7dc1db6a80 100644
@@ -7,6 +7,7 @@
  * option) any later version.
  */
 
+#include <linux/slab.h>
 #include <linux/irq_sim.h>
 #include <linux/irq.h>
 
#4 lore raw

[tip:irq/core] genirq/irq_sim: Check the return value of irq_sim_init() for error codes

In reply to Bartosz Golaszewski
genirq/irq_sim: Check the return value of irq_sim_init() for error codes
Commit-ID:  28b6afa7d4456e759031bf83706b4be3689fba94
Gitweb:     https://git.kernel.org/tip/28b6afa7d4456e759031bf83706b4be3689fba94
Author:     Bartosz Golaszewski <[email protected]>
AuthorDate: Sun, 4 Mar 2018 13:10:17 +0100
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Fri, 9 Mar 2018 11:44:03 +0100

genirq/irq_sim: Check the return value of irq_sim_init() for error codes

As discussed with Marc Zyngier: irq_sim_init() and its devres variant should return the base of the allocated interrupt range on success rather than 0.

Make devm_irq_sim_init() check for an error code. This is a preparatory change for modifying irq_sim_init() itself.

---
 kernel/irq/irq_sim.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/irq/irq_sim.c +1 -1
index bd7dc1db6a80..05f0d7c1698a 100644
@@ -124,7 +124,7 @@ int devm_irq_sim_init(struct device *dev, struct irq_sim *sim,
 		return -ENOMEM;
 
 	rv = irq_sim_init(sim, num_irqs);
-	if (rv) {
+	if (rv < 0) {
 		devres_free(dr);
 		return rv;
 	}
#6 lore raw

[tip:irq/core] genirq/irq_sim: Return the base of the irq range from irq_sim_init()

In reply to Bartosz Golaszewski
genirq/irq_sim: Return the base of the irq range from irq_sim_init()
Commit-ID:  f09777fa891327ee0dd892e83619f156bf1c37e6
Gitweb:     https://git.kernel.org/tip/f09777fa891327ee0dd892e83619f156bf1c37e6
Author:     Bartosz Golaszewski <[email protected]>
AuthorDate: Sun, 4 Mar 2018 13:10:18 +0100
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Fri, 9 Mar 2018 11:44:03 +0100

genirq/irq_sim: Return the base of the irq range from irq_sim_init()

Returning the base of the allocated interrupt range from irq_sim_init() and devm_irq_sim_init() allows users to handle the logic of associating irq numbers with any other driver-specific resources without having to use irq_sim_irqnum().

---
 kernel/irq/irq_sim.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
kernel/irq/irq_sim.c +6 -4
index 05f0d7c1698a..85690859a2a8 100644
@@ -50,7 +50,8 @@ static void irq_sim_handle_irq(struct irq_work *work)
  * @sim:        The interrupt simulator object to initialize.
  * @num_irqs:   Number of interrupts to allocate
  *
- * Returns 0 on success and a negative error number on failure.
+ * On success: return the base of the allocated interrupt range.
+ * On failure: a negative errno.
  */
 int irq_sim_init(struct irq_sim *sim, unsigned int num_irqs)
 {
@@ -79,7 +80,7 @@ int irq_sim_init(struct irq_sim *sim, unsigned int num_irqs)
 	init_irq_work(&sim->work_ctx.work, irq_sim_handle_irq);
 	sim->irq_count = num_irqs;
 
-	return 0;
+	return sim->irq_base;
 }
 EXPORT_SYMBOL_GPL(irq_sim_init);
 
@@ -111,7 +112,8 @@ static void devm_irq_sim_release(struct device *dev, void *res)
  * @sim:        The interrupt simulator object to initialize.
  * @num_irqs:   Number of interrupts to allocate
  *
- * Returns 0 on success and a negative error number on failure.
+ * On success: return the base of the allocated interrupt range.
+ * On failure: a negative errno.
  */
 int devm_irq_sim_init(struct device *dev, struct irq_sim *sim,
 		      unsigned int num_irqs)
@@ -132,7 +134,7 @@ int devm_irq_sim_init(struct device *dev, struct irq_sim *sim,
 	dr->sim = sim;
 	devres_add(dev, dr);
 
-	return 0;
+	return rv;
 }
 EXPORT_SYMBOL_GPL(devm_irq_sim_init);