irqchip/ls-extirq: Convert to a platform driver to make it work again

Starting with the blamed commit, the ls-extirq driver stopped working. This
is because ls-extirq, being one of the interrupt-map property abusers, does
not pass the DT checks added by the referenced commit, making it unable to
determine its interrupt parent:

irq-ls-extirq: Cannot find parent domain
OF: of_irq_init: Failed to init /soc/syscon@1f70000/interrupt-controller@14
((____ptrval____)), parent 0000000000000000

Instead of reverting the referenced commit, convert the ls-extirq to a
platform driver to avoid the irqchip_init() -> of_irq_init() code path
completely.

As part of the conversion, use the managed resources APIs and
dev_err_probe() so that there is no need for a .remove() callback or for
complicated error handling.

Fixes: 1b1f04d8271e ("of/irq: Ignore interrupt parent for nodes without interrupts")
Co-developed-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Link: https://patch.msgid.link/20260122134034.3274053-2-ioana.ciornei@nxp.com

authored by Ioana Ciornei and committed by Thomas Gleixner 05cd6548 63804fed

+36 -39
+36 -39
drivers/irqchip/irq-ls-extirq.c
··· 168 168 return 0; 169 169 } 170 170 171 - static int __init 172 - ls_extirq_of_init(struct device_node *node, struct device_node *parent) 171 + static int ls_extirq_probe(struct platform_device *pdev) 173 172 { 174 173 struct irq_domain *domain, *parent_domain; 174 + struct device_node *node, *parent; 175 + struct device *dev = &pdev->dev; 175 176 struct ls_extirq_data *priv; 176 177 int ret; 177 178 179 + node = dev->of_node; 180 + parent = of_irq_find_parent(node); 181 + if (!parent) 182 + return dev_err_probe(dev, -ENODEV, "Failed to get IRQ parent node\n"); 183 + 178 184 parent_domain = irq_find_host(parent); 179 - if (!parent_domain) { 180 - pr_err("Cannot find parent domain\n"); 181 - ret = -ENODEV; 182 - goto err_irq_find_host; 183 - } 185 + if (!parent_domain) 186 + return dev_err_probe(dev, -EPROBE_DEFER, "Cannot find parent domain\n"); 184 187 185 - priv = kzalloc(sizeof(*priv), GFP_KERNEL); 186 - if (!priv) { 187 - ret = -ENOMEM; 188 - goto err_alloc_priv; 189 - } 188 + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); 189 + if (!priv) 190 + return dev_err_probe(dev, -ENOMEM, "Failed to allocate memory\n"); 190 191 191 - /* 192 - * All extirq OF nodes are under a scfg/syscon node with 193 - * the 'ranges' property 194 - */ 195 - priv->intpcr = of_iomap(node, 0); 196 - if (!priv->intpcr) { 197 - pr_err("Cannot ioremap OF node %pOF\n", node); 198 - ret = -ENOMEM; 199 - goto err_iomap; 200 - } 192 + priv->intpcr = devm_of_iomap(dev, node, 0, NULL); 193 + if (!priv->intpcr) 194 + return dev_err_probe(dev, -ENOMEM, "Cannot ioremap OF node %pOF\n", node); 201 195 202 196 ret = ls_extirq_parse_map(priv, node); 203 197 if (ret) 204 - goto err_parse_map; 198 + return dev_err_probe(dev, ret, "Failed to parse IRQ map\n"); 205 199 206 200 priv->big_endian = of_device_is_big_endian(node->parent); 207 201 priv->is_ls1021a_or_ls1043a = of_device_is_compatible(node, "fsl,ls1021a-extirq") || ··· 204 210 205 211 domain = irq_domain_create_hierarchy(parent_domain, 0, priv->nirq, of_fwnode_handle(node), 206 212 &extirq_domain_ops, priv); 207 - if (!domain) { 208 - ret = -ENOMEM; 209 - goto err_add_hierarchy; 210 - } 213 + if (!domain) 214 + return dev_err_probe(dev, -ENOMEM, "Failed to add IRQ domain\n"); 211 215 212 216 return 0; 213 - 214 - err_add_hierarchy: 215 - err_parse_map: 216 - iounmap(priv->intpcr); 217 - err_iomap: 218 - kfree(priv); 219 - err_alloc_priv: 220 - err_irq_find_host: 221 - return ret; 222 217 } 223 218 224 - IRQCHIP_DECLARE(ls1021a_extirq, "fsl,ls1021a-extirq", ls_extirq_of_init); 225 - IRQCHIP_DECLARE(ls1043a_extirq, "fsl,ls1043a-extirq", ls_extirq_of_init); 226 - IRQCHIP_DECLARE(ls1088a_extirq, "fsl,ls1088a-extirq", ls_extirq_of_init); 219 + static const struct of_device_id ls_extirq_dt_ids[] = { 220 + { .compatible = "fsl,ls1021a-extirq" }, 221 + { .compatible = "fsl,ls1043a-extirq" }, 222 + { .compatible = "fsl,ls1088a-extirq" }, 223 + {} 224 + }; 225 + MODULE_DEVICE_TABLE(of, ls_extirq_dt_ids); 226 + 227 + static struct platform_driver ls_extirq_driver = { 228 + .probe = ls_extirq_probe, 229 + .driver = { 230 + .name = "ls-extirq", 231 + .of_match_table = ls_extirq_dt_ids, 232 + } 233 + }; 234 + 235 + builtin_platform_driver(ls_extirq_driver);