Skip to content

Commit 386cbe7

Browse files
committed
gpio: crystalcove: 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 <[email protected]>
1 parent f2906aa commit 386cbe7

File tree

1 file changed

+25
-15
lines changed

1 file changed

+25
-15
lines changed

drivers/gpio/gpio-crystalcove.c

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <linux/platform_device.h>
1616
#include <linux/regmap.h>
1717
#include <linux/seq_file.h>
18+
#include <linux/types.h>
1819

1920
#define CRYSTALCOVE_GPIO_NUM 16
2021
#define CRYSTALCOVE_VGPIO_NUM 95
@@ -238,34 +239,43 @@ static void crystalcove_bus_sync_unlock(struct irq_data *data)
238239

239240
static void crystalcove_irq_unmask(struct irq_data *data)
240241
{
241-
struct crystalcove_gpio *cg =
242-
gpiochip_get_data(irq_data_get_irq_chip_data(data));
242+
struct gpio_chip *gc = irq_data_get_irq_chip_data(data);
243+
struct crystalcove_gpio *cg = gpiochip_get_data(gc);
244+
irq_hw_number_t hwirq = irqd_to_hwirq(data);
243245

244-
if (data->hwirq < CRYSTALCOVE_GPIO_NUM) {
245-
cg->set_irq_mask = false;
246-
cg->update |= UPDATE_IRQ_MASK;
247-
}
246+
if (hwirq >= CRYSTALCOVE_GPIO_NUM)
247+
return;
248+
249+
gpiochip_enable_irq(gc, hwirq);
250+
251+
cg->set_irq_mask = false;
252+
cg->update |= UPDATE_IRQ_MASK;
248253
}
249254

250255
static void crystalcove_irq_mask(struct irq_data *data)
251256
{
252-
struct crystalcove_gpio *cg =
253-
gpiochip_get_data(irq_data_get_irq_chip_data(data));
257+
struct gpio_chip *gc = irq_data_get_irq_chip_data(data);
258+
struct crystalcove_gpio *cg = gpiochip_get_data(gc);
259+
irq_hw_number_t hwirq = irqd_to_hwirq(data);
254260

255-
if (data->hwirq < CRYSTALCOVE_GPIO_NUM) {
256-
cg->set_irq_mask = true;
257-
cg->update |= UPDATE_IRQ_MASK;
258-
}
261+
if (hwirq >= CRYSTALCOVE_GPIO_NUM)
262+
return;
263+
264+
cg->set_irq_mask = true;
265+
cg->update |= UPDATE_IRQ_MASK;
266+
267+
gpiochip_disable_irq(gc, hwirq);
259268
}
260269

261-
static struct irq_chip crystalcove_irqchip = {
270+
static const struct irq_chip crystalcove_irqchip = {
262271
.name = "Crystal Cove",
263272
.irq_mask = crystalcove_irq_mask,
264273
.irq_unmask = crystalcove_irq_unmask,
265274
.irq_set_type = crystalcove_irq_type,
266275
.irq_bus_lock = crystalcove_bus_lock,
267276
.irq_bus_sync_unlock = crystalcove_bus_sync_unlock,
268-
.flags = IRQCHIP_SKIP_SET_WAKE,
277+
.flags = IRQCHIP_SKIP_SET_WAKE | IRQCHIP_IMMUTABLE,
278+
GPIOCHIP_IRQ_RESOURCE_HELPERS,
269279
};
270280

271281
static irqreturn_t crystalcove_gpio_irq_handler(int irq, void *data)
@@ -353,7 +363,7 @@ static int crystalcove_gpio_probe(struct platform_device *pdev)
353363
cg->regmap = pmic->regmap;
354364

355365
girq = &cg->chip.irq;
356-
girq->chip = &crystalcove_irqchip;
366+
gpio_irq_chip_set_chip(girq, &crystalcove_irqchip);
357367
/* This will let us handle the parent IRQ in the driver */
358368
girq->parent_handler = NULL;
359369
girq->num_parents = 0;

0 commit comments

Comments
 (0)