@@ -164,7 +164,6 @@ struct cp2112_device {
164
164
atomic_t read_avail ;
165
165
atomic_t xfer_avail ;
166
166
struct gpio_chip gc ;
167
- struct irq_chip irq ;
168
167
u8 * in_out_buffer ;
169
168
struct mutex lock ;
170
169
@@ -1079,16 +1078,20 @@ static void cp2112_gpio_irq_mask(struct irq_data *d)
1079
1078
{
1080
1079
struct gpio_chip * gc = irq_data_get_irq_chip_data (d );
1081
1080
struct cp2112_device * dev = gpiochip_get_data (gc );
1081
+ irq_hw_number_t hwirq = irqd_to_hwirq (d );
1082
1082
1083
- __clear_bit (d -> hwirq , & dev -> irq_mask );
1083
+ __clear_bit (hwirq , & dev -> irq_mask );
1084
+ gpiochip_disable_irq (gc , hwirq );
1084
1085
}
1085
1086
1086
1087
static void cp2112_gpio_irq_unmask (struct irq_data * d )
1087
1088
{
1088
1089
struct gpio_chip * gc = irq_data_get_irq_chip_data (d );
1089
1090
struct cp2112_device * dev = gpiochip_get_data (gc );
1091
+ irq_hw_number_t hwirq = irqd_to_hwirq (d );
1090
1092
1091
- __set_bit (d -> hwirq , & dev -> irq_mask );
1093
+ gpiochip_enable_irq (gc , hwirq );
1094
+ __set_bit (hwirq , & dev -> irq_mask );
1092
1095
}
1093
1096
1094
1097
static void cp2112_gpio_poll_callback (struct work_struct * work )
@@ -1174,6 +1177,7 @@ static void cp2112_gpio_irq_shutdown(struct irq_data *d)
1174
1177
struct gpio_chip * gc = irq_data_get_irq_chip_data (d );
1175
1178
struct cp2112_device * dev = gpiochip_get_data (gc );
1176
1179
1180
+ cp2112_gpio_irq_mask (d );
1177
1181
cancel_delayed_work_sync (& dev -> gpio_poll_worker );
1178
1182
}
1179
1183
@@ -1227,6 +1231,18 @@ static int __maybe_unused cp2112_allocate_irq(struct cp2112_device *dev,
1227
1231
return ret ;
1228
1232
}
1229
1233
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
+
1230
1246
static int cp2112_probe (struct hid_device * hdev , const struct hid_device_id * id )
1231
1247
{
1232
1248
struct cp2112_device * dev ;
@@ -1336,17 +1352,8 @@ static int cp2112_probe(struct hid_device *hdev, const struct hid_device_id *id)
1336
1352
dev -> gc .can_sleep = 1 ;
1337
1353
dev -> gc .parent = & hdev -> dev ;
1338
1354
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
-
1348
1355
girq = & dev -> gc .irq ;
1349
- girq -> chip = & dev -> irq ;
1356
+ gpio_irq_chip_set_chip ( girq , & cp2112_gpio_irqchip ) ;
1350
1357
/* The event comes from the outside so no parent handler */
1351
1358
girq -> parent_handler = NULL ;
1352
1359
girq -> num_parents = 0 ;
0 commit comments