Skip to content

Commit 3e2977c

Browse files
andy-shevBenjamin Tissoires
authored andcommitted
HID: cp2112: 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]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Benjamin Tissoires <[email protected]>
1 parent 4a3983d commit 3e2977c

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

drivers/hid/hid-cp2112.c

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ struct cp2112_device {
164164
atomic_t read_avail;
165165
atomic_t xfer_avail;
166166
struct gpio_chip gc;
167-
struct irq_chip irq;
168167
u8 *in_out_buffer;
169168
struct mutex lock;
170169

@@ -1079,16 +1078,20 @@ static void cp2112_gpio_irq_mask(struct irq_data *d)
10791078
{
10801079
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
10811080
struct cp2112_device *dev = gpiochip_get_data(gc);
1081+
irq_hw_number_t hwirq = irqd_to_hwirq(d);
10821082

1083-
__clear_bit(d->hwirq, &dev->irq_mask);
1083+
__clear_bit(hwirq, &dev->irq_mask);
1084+
gpiochip_disable_irq(gc, hwirq);
10841085
}
10851086

10861087
static void cp2112_gpio_irq_unmask(struct irq_data *d)
10871088
{
10881089
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
10891090
struct cp2112_device *dev = gpiochip_get_data(gc);
1091+
irq_hw_number_t hwirq = irqd_to_hwirq(d);
10901092

1091-
__set_bit(d->hwirq, &dev->irq_mask);
1093+
gpiochip_enable_irq(gc, hwirq);
1094+
__set_bit(hwirq, &dev->irq_mask);
10921095
}
10931096

10941097
static void cp2112_gpio_poll_callback(struct work_struct *work)
@@ -1174,6 +1177,7 @@ static void cp2112_gpio_irq_shutdown(struct irq_data *d)
11741177
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
11751178
struct cp2112_device *dev = gpiochip_get_data(gc);
11761179

1180+
cp2112_gpio_irq_mask(d);
11771181
cancel_delayed_work_sync(&dev->gpio_poll_worker);
11781182
}
11791183

@@ -1227,6 +1231,18 @@ static int __maybe_unused cp2112_allocate_irq(struct cp2112_device *dev,
12271231
return ret;
12281232
}
12291233

1234+
static const struct irq_chip cp2112_gpio_irqchip = {
1235+
.name = "cp2112-gpio",
1236+
.irq_startup = cp2112_gpio_irq_startup,
1237+
.irq_shutdown = cp2112_gpio_irq_shutdown,
1238+
.irq_ack = cp2112_gpio_irq_ack,
1239+
.irq_mask = cp2112_gpio_irq_mask,
1240+
.irq_unmask = cp2112_gpio_irq_unmask,
1241+
.irq_set_type = cp2112_gpio_irq_type,
1242+
.flags = IRQCHIP_MASK_ON_SUSPEND | IRQCHIP_IMMUTABLE,
1243+
GPIOCHIP_IRQ_RESOURCE_HELPERS,
1244+
};
1245+
12301246
static int cp2112_probe(struct hid_device *hdev, const struct hid_device_id *id)
12311247
{
12321248
struct cp2112_device *dev;
@@ -1336,17 +1352,8 @@ static int cp2112_probe(struct hid_device *hdev, const struct hid_device_id *id)
13361352
dev->gc.can_sleep = 1;
13371353
dev->gc.parent = &hdev->dev;
13381354

1339-
dev->irq.name = "cp2112-gpio";
1340-
dev->irq.irq_startup = cp2112_gpio_irq_startup;
1341-
dev->irq.irq_shutdown = cp2112_gpio_irq_shutdown;
1342-
dev->irq.irq_ack = cp2112_gpio_irq_ack;
1343-
dev->irq.irq_mask = cp2112_gpio_irq_mask;
1344-
dev->irq.irq_unmask = cp2112_gpio_irq_unmask;
1345-
dev->irq.irq_set_type = cp2112_gpio_irq_type;
1346-
dev->irq.flags = IRQCHIP_MASK_ON_SUSPEND;
1347-
13481355
girq = &dev->gc.irq;
1349-
girq->chip = &dev->irq;
1356+
gpio_irq_chip_set_chip(girq, &cp2112_gpio_irqchip);
13501357
/* The event comes from the outside so no parent handler */
13511358
girq->parent_handler = NULL;
13521359
girq->num_parents = 0;

0 commit comments

Comments
 (0)