]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
regmap: Allow setting IRQ domain name suffix
authorMatti Vaittinen <mazziesaccount@gmail.com>
Thu, 8 Aug 2024 12:36:28 +0000 (15:36 +0300)
committerMark Brown <broonie@kernel.org>
Tue, 13 Aug 2024 11:45:01 +0000 (12:45 +0100)
When multiple IRQ domains are created from the same device-tree node they
will get the same name based on the device-tree path. This will cause a
naming collision in debugFS when IRQ domain specific entries are created.

The regmap-IRQ creates per instance IRQ domains. This will lead to a
domain name conflict when a device which provides more than one
interrupt line uses the regmap-IRQ.

Add support for specifying an IRQ domain name suffix when creating a
regmap-IRQ controller.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Link: https://patch.msgid.link/776bc4996969e5081bcf61b9bdb5517e537147a3.1723120028.git.mazziesaccount@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/base/regmap/regmap-irq.c
include/linux/regmap.h

index d3ec1345b5b53a423c04bc274bf850bdb32b2d80..a750e48a26b87c50f7a80df41b711f713cecac23 100644 (file)
@@ -608,6 +608,30 @@ int regmap_irq_set_type_config_simple(unsigned int **buf, unsigned int type,
 }
 EXPORT_SYMBOL_GPL(regmap_irq_set_type_config_simple);
 
+static int regmap_irq_create_domain(struct fwnode_handle *fwnode, int irq_base,
+                                   const struct regmap_irq_chip *chip,
+                                   struct regmap_irq_chip_data *d)
+{
+       struct irq_domain_info info = {
+               .fwnode = fwnode,
+               .size = chip->num_irqs,
+               .hwirq_max = chip->num_irqs,
+               .virq_base = irq_base,
+               .ops = &regmap_domain_ops,
+               .host_data = d,
+               .name_suffix = chip->domain_suffix,
+       };
+
+       d->domain = irq_domain_instantiate(&info);
+       if (IS_ERR(d->domain)) {
+               dev_err(d->map->dev, "Failed to create IRQ domain\n");
+               return PTR_ERR(d->domain);
+       }
+
+       return 0;
+}
+
+
 /**
  * regmap_add_irq_chip_fwnode() - Use standard regmap IRQ controller handling
  *
@@ -856,18 +880,9 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,
                }
        }
 
-       if (irq_base)
-               d->domain = irq_domain_create_legacy(fwnode, chip->num_irqs,
-                                                    irq_base, 0,
-                                                    &regmap_domain_ops, d);
-       else
-               d->domain = irq_domain_create_linear(fwnode, chip->num_irqs,
-                                                    &regmap_domain_ops, d);
-       if (!d->domain) {
-               dev_err(map->dev, "Failed to create IRQ domain\n");
-               ret = -ENOMEM;
+       ret = regmap_irq_create_domain(fwnode, irq_base, chip, d);
+       if (ret)
                goto err_alloc;
-       }
 
        ret = request_threaded_irq(irq, NULL, regmap_irq_thread,
                                   irq_flags | IRQF_ONESHOT,
index 122e38161acb8d5d066ae1e0845f6a1d0971a717..f9ccad32fc5cbad8b8ea7d32a20a738c27cca271 100644 (file)
@@ -1521,6 +1521,9 @@ struct regmap_irq_chip_data;
  * struct regmap_irq_chip - Description of a generic regmap irq_chip.
  *
  * @name:        Descriptive name for IRQ controller.
+ * @domain_suffix: Name suffix to be appended to end of IRQ domain name. Needed
+ *                when multiple regmap-IRQ controllers are created from same
+ *                device.
  *
  * @main_status: Base main status register address. For chips which have
  *              interrupts arranged in separate sub-irq blocks with own IRQ
@@ -1606,6 +1609,7 @@ struct regmap_irq_chip_data;
  */
 struct regmap_irq_chip {
        const char *name;
+       const char *domain_suffix;
 
        unsigned int main_status;
        unsigned int num_main_status_bits;