Skip to content

Commit 3655502

Browse files
author
Marc Zyngier
committed
irqchip/lpc32xx: Switch to dynamic chip name output
Instead of overriding the name field with the device name, use the relevant callback. This allows us to make the irq_chip structure const. Signed-off-by: Marc Zyngier <maz@kernel.org> Acked-by: Linus Walleij <linus.walleij@linaro.org> Link: https://lore.kernel.org/r/20220209162607.1118325-5-maz@kernel.org
1 parent 745f1fb commit 3655502

1 file changed

Lines changed: 22 additions & 12 deletions

File tree

drivers/irqchip/irq-lpc32xx.c

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/of_address.h>
1212
#include <linux/of_irq.h>
1313
#include <linux/of_platform.h>
14+
#include <linux/seq_file.h>
1415
#include <linux/slab.h>
1516
#include <asm/exception.h>
1617

@@ -25,8 +26,8 @@
2526

2627
struct lpc32xx_irq_chip {
2728
void __iomem *base;
29+
phys_addr_t addr;
2830
struct irq_domain *domain;
29-
struct irq_chip chip;
3031
};
3132

3233
static struct lpc32xx_irq_chip *lpc32xx_mic_irqc;
@@ -118,6 +119,24 @@ static int lpc32xx_irq_set_type(struct irq_data *d, unsigned int type)
118119
return 0;
119120
}
120121

122+
static void lpc32xx_irq_print_chip(struct irq_data *d, struct seq_file *p)
123+
{
124+
struct lpc32xx_irq_chip *ic = irq_data_get_irq_chip_data(d);
125+
126+
if (ic == lpc32xx_mic_irqc)
127+
seq_printf(p, "%08x.mic", ic->addr);
128+
else
129+
seq_printf(p, "%08x.sic", ic->addr);
130+
}
131+
132+
static const struct irq_chip lpc32xx_chip = {
133+
.irq_ack = lpc32xx_irq_ack,
134+
.irq_mask = lpc32xx_irq_mask,
135+
.irq_unmask = lpc32xx_irq_unmask,
136+
.irq_set_type = lpc32xx_irq_set_type,
137+
.irq_print_chip = lpc32xx_irq_print_chip,
138+
};
139+
121140
static void __exception_irq_entry lpc32xx_handle_irq(struct pt_regs *regs)
122141
{
123142
struct lpc32xx_irq_chip *ic = lpc32xx_mic_irqc;
@@ -153,7 +172,7 @@ static int lpc32xx_irq_domain_map(struct irq_domain *id, unsigned int virq,
153172
struct lpc32xx_irq_chip *ic = id->host_data;
154173

155174
irq_set_chip_data(virq, ic);
156-
irq_set_chip_and_handler(virq, &ic->chip, handle_level_irq);
175+
irq_set_chip_and_handler(virq, &lpc32xx_chip, handle_level_irq);
157176
irq_set_status_flags(virq, IRQ_LEVEL);
158177
irq_set_noprobe(virq);
159178

@@ -183,28 +202,19 @@ static int __init lpc32xx_of_ic_init(struct device_node *node,
183202
if (!irqc)
184203
return -ENOMEM;
185204

205+
irqc->addr = addr;
186206
irqc->base = of_iomap(node, 0);
187207
if (!irqc->base) {
188208
pr_err("%pOF: unable to map registers\n", node);
189209
kfree(irqc);
190210
return -EINVAL;
191211
}
192212

193-
irqc->chip.irq_ack = lpc32xx_irq_ack;
194-
irqc->chip.irq_mask = lpc32xx_irq_mask;
195-
irqc->chip.irq_unmask = lpc32xx_irq_unmask;
196-
irqc->chip.irq_set_type = lpc32xx_irq_set_type;
197-
if (is_mic)
198-
irqc->chip.name = kasprintf(GFP_KERNEL, "%08x.mic", addr);
199-
else
200-
irqc->chip.name = kasprintf(GFP_KERNEL, "%08x.sic", addr);
201-
202213
irqc->domain = irq_domain_add_linear(node, NR_LPC32XX_IC_IRQS,
203214
&lpc32xx_irq_domain_ops, irqc);
204215
if (!irqc->domain) {
205216
pr_err("unable to add irq domain\n");
206217
iounmap(irqc->base);
207-
kfree(irqc->chip.name);
208218
kfree(irqc);
209219
return -ENODEV;
210220
}

0 commit comments

Comments
 (0)