Skip to content

Commit 393e128

Browse files
author
Marc Zyngier
committed
genirq: Allow irq_chip registration functions to take a const irq_chip
In order to let a const irqchip be fed to the irqchip layer, adjust the various prototypes. An extra cast in irq_set_chip()() is required to avoid a warning. Signed-off-by: Marc Zyngier <maz@kernel.org> Acked-by: Linus Walleij <linus.walleij@linaro.org> Link: https://lore.kernel.org/r/20220209162607.1118325-3-maz@kernel.org
1 parent 45ec846 commit 393e128

2 files changed

Lines changed: 7 additions & 9 deletions

File tree

include/linux/irq.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -710,10 +710,11 @@ extern struct irq_chip no_irq_chip;
710710
extern struct irq_chip dummy_irq_chip;
711711

712712
extern void
713-
irq_set_chip_and_handler_name(unsigned int irq, struct irq_chip *chip,
713+
irq_set_chip_and_handler_name(unsigned int irq, const struct irq_chip *chip,
714714
irq_flow_handler_t handle, const char *name);
715715

716-
static inline void irq_set_chip_and_handler(unsigned int irq, struct irq_chip *chip,
716+
static inline void irq_set_chip_and_handler(unsigned int irq,
717+
const struct irq_chip *chip,
717718
irq_flow_handler_t handle)
718719
{
719720
irq_set_chip_and_handler_name(irq, chip, handle, NULL);
@@ -803,7 +804,7 @@ static inline void irq_set_percpu_devid_flags(unsigned int irq)
803804
}
804805

805806
/* Set/get chip/data for an IRQ: */
806-
extern int irq_set_chip(unsigned int irq, struct irq_chip *chip);
807+
extern int irq_set_chip(unsigned int irq, const struct irq_chip *chip);
807808
extern int irq_set_handler_data(unsigned int irq, void *data);
808809
extern int irq_set_chip_data(unsigned int irq, void *data);
809810
extern int irq_set_irq_type(unsigned int irq, unsigned int type);

kernel/irq/chip.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,15 @@ struct irqaction chained_action = {
3838
* @irq: irq number
3939
* @chip: pointer to irq chip description structure
4040
*/
41-
int irq_set_chip(unsigned int irq, struct irq_chip *chip)
41+
int irq_set_chip(unsigned int irq, const struct irq_chip *chip)
4242
{
4343
unsigned long flags;
4444
struct irq_desc *desc = irq_get_desc_lock(irq, &flags, 0);
4545

4646
if (!desc)
4747
return -EINVAL;
4848

49-
if (!chip)
50-
chip = &no_irq_chip;
51-
52-
desc->irq_data.chip = chip;
49+
desc->irq_data.chip = (struct irq_chip *)(chip ?: &no_irq_chip);
5350
irq_put_desc_unlock(desc, flags);
5451
/*
5552
* For !CONFIG_SPARSE_IRQ make the irq show up in
@@ -1073,7 +1070,7 @@ irq_set_chained_handler_and_data(unsigned int irq, irq_flow_handler_t handle,
10731070
EXPORT_SYMBOL_GPL(irq_set_chained_handler_and_data);
10741071

10751072
void
1076-
irq_set_chip_and_handler_name(unsigned int irq, struct irq_chip *chip,
1073+
irq_set_chip_and_handler_name(unsigned int irq, const struct irq_chip *chip,
10771074
irq_flow_handler_t handle, const char *name)
10781075
{
10791076
irq_set_chip(irq, chip);

0 commit comments

Comments
 (0)