Skip to content

Commit f1138da

Browse files
committed
gpio: sch: make irq_chip immutable
Since recently, the kernel is nagging about mutable irq_chips: "not an immutable chip, please consider fixing it!" Drop the unneeded copy, flag it as IRQCHIP_IMMUTABLE, add the new helper functions and call the appropriate gpiolib functions. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Bartosz Golaszewski <brgl@bgdev.pl>
1 parent a80fed9 commit f1138da

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

drivers/gpio/gpio-sch.c

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838

3939
struct sch_gpio {
4040
struct gpio_chip chip;
41-
struct irq_chip irqchip;
4241
spinlock_t lock;
4342
unsigned short iobase;
4443
unsigned short resume_base;
@@ -218,11 +217,9 @@ static void sch_irq_ack(struct irq_data *d)
218217
spin_unlock_irqrestore(&sch->lock, flags);
219218
}
220219

221-
static void sch_irq_mask_unmask(struct irq_data *d, int val)
220+
static void sch_irq_mask_unmask(struct gpio_chip *gc, irq_hw_number_t gpio_num, int val)
222221
{
223-
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
224222
struct sch_gpio *sch = gpiochip_get_data(gc);
225-
irq_hw_number_t gpio_num = irqd_to_hwirq(d);
226223
unsigned long flags;
227224

228225
spin_lock_irqsave(&sch->lock, flags);
@@ -232,14 +229,32 @@ static void sch_irq_mask_unmask(struct irq_data *d, int val)
232229

233230
static void sch_irq_mask(struct irq_data *d)
234231
{
235-
sch_irq_mask_unmask(d, 0);
232+
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
233+
irq_hw_number_t gpio_num = irqd_to_hwirq(d);
234+
235+
sch_irq_mask_unmask(gc, gpio_num, 0);
236+
gpiochip_disable_irq(gc, gpio_num);
236237
}
237238

238239
static void sch_irq_unmask(struct irq_data *d)
239240
{
240-
sch_irq_mask_unmask(d, 1);
241+
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
242+
irq_hw_number_t gpio_num = irqd_to_hwirq(d);
243+
244+
gpiochip_enable_irq(gc, gpio_num);
245+
sch_irq_mask_unmask(gc, gpio_num, 1);
241246
}
242247

248+
static const struct irq_chip sch_irqchip = {
249+
.name = "sch_gpio",
250+
.irq_ack = sch_irq_ack,
251+
.irq_mask = sch_irq_mask,
252+
.irq_unmask = sch_irq_unmask,
253+
.irq_set_type = sch_irq_type,
254+
.flags = IRQCHIP_IMMUTABLE,
255+
GPIOCHIP_IRQ_RESOURCE_HELPERS,
256+
};
257+
243258
static u32 sch_gpio_gpe_handler(acpi_handle gpe_device, u32 gpe, void *context)
244259
{
245260
struct sch_gpio *sch = context;
@@ -367,14 +382,8 @@ static int sch_gpio_probe(struct platform_device *pdev)
367382

368383
platform_set_drvdata(pdev, sch);
369384

370-
sch->irqchip.name = "sch_gpio";
371-
sch->irqchip.irq_ack = sch_irq_ack;
372-
sch->irqchip.irq_mask = sch_irq_mask;
373-
sch->irqchip.irq_unmask = sch_irq_unmask;
374-
sch->irqchip.irq_set_type = sch_irq_type;
375-
376385
girq = &sch->chip.irq;
377-
girq->chip = &sch->irqchip;
386+
gpio_irq_chip_set_chip(girq, &sch_irqchip);
378387
girq->num_parents = 0;
379388
girq->parents = NULL;
380389
girq->parent_handler = NULL;

0 commit comments

Comments
 (0)