Skip to content

Commit 0a04d76

Browse files
committed
pinctrl: sx150x: Use irqchip template
This makes the driver use the irqchip template to assign properties to the gpio_irq_chip instead of using the explicit calls to gpiochip_irqchip_add_nested() and gpiochip_set_nested_irqchip(). The irqchip is instead added while adding the gpiochip. Signed-off-by: Linus Walleij <[email protected]> Acked-by: Neil Armstrong <[email protected]> Cc: Peter Rosin <[email protected]> Cc: Andrey Smirnov <[email protected]> Cc: Neil Armstrong <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent b8e73b5 commit 0a04d76

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

drivers/pinctrl/pinctrl-sx150x.c

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,17 +1187,10 @@ static int sx150x_probe(struct i2c_client *client,
11871187
if (pctl->data->model != SX150X_789)
11881188
pctl->gpio.set_multiple = sx150x_gpio_set_multiple;
11891189

1190-
ret = devm_gpiochip_add_data(dev, &pctl->gpio, pctl);
1191-
if (ret)
1192-
return ret;
1193-
1194-
ret = gpiochip_add_pin_range(&pctl->gpio, dev_name(dev),
1195-
0, 0, pctl->data->npins);
1196-
if (ret)
1197-
return ret;
1198-
11991190
/* Add Interrupt support if an irq is specified */
12001191
if (client->irq > 0) {
1192+
struct gpio_irq_chip *girq;
1193+
12011194
pctl->irq_chip.irq_mask = sx150x_irq_mask;
12021195
pctl->irq_chip.irq_unmask = sx150x_irq_unmask;
12031196
pctl->irq_chip.irq_set_type = sx150x_irq_set_type;
@@ -1213,22 +1206,24 @@ static int sx150x_probe(struct i2c_client *client,
12131206

12141207
/*
12151208
* Because sx150x_irq_threaded_fn invokes all of the
1216-
* nested interrrupt handlers via handle_nested_irq,
1217-
* any "handler" passed to gpiochip_irqchip_add()
1209+
* nested interrupt handlers via handle_nested_irq,
1210+
* any "handler" assigned to struct gpio_irq_chip
12181211
* below is going to be ignored, so the choice of the
12191212
* function does not matter that much.
12201213
*
12211214
* We set it to handle_bad_irq to avoid confusion,
12221215
* plus it will be instantly noticeable if it is ever
12231216
* called (should not happen)
12241217
*/
1225-
ret = gpiochip_irqchip_add_nested(&pctl->gpio,
1226-
&pctl->irq_chip, 0,
1227-
handle_bad_irq, IRQ_TYPE_NONE);
1228-
if (ret) {
1229-
dev_err(dev, "could not connect irqchip to gpiochip\n");
1230-
return ret;
1231-
}
1218+
girq = &pctl->gpio.irq;
1219+
girq->chip = &pctl->irq_chip;
1220+
/* This will let us handle the parent IRQ in the driver */
1221+
girq->parent_handler = NULL;
1222+
girq->num_parents = 0;
1223+
girq->parents = NULL;
1224+
girq->default_type = IRQ_TYPE_NONE;
1225+
girq->handler = handle_bad_irq;
1226+
girq->threaded = true;
12321227

12331228
ret = devm_request_threaded_irq(dev, client->irq, NULL,
12341229
sx150x_irq_thread_fn,
@@ -1237,12 +1232,17 @@ static int sx150x_probe(struct i2c_client *client,
12371232
pctl->irq_chip.name, pctl);
12381233
if (ret < 0)
12391234
return ret;
1240-
1241-
gpiochip_set_nested_irqchip(&pctl->gpio,
1242-
&pctl->irq_chip,
1243-
client->irq);
12441235
}
12451236

1237+
ret = devm_gpiochip_add_data(dev, &pctl->gpio, pctl);
1238+
if (ret)
1239+
return ret;
1240+
1241+
ret = gpiochip_add_pin_range(&pctl->gpio, dev_name(dev),
1242+
0, 0, pctl->data->npins);
1243+
if (ret)
1244+
return ret;
1245+
12461246
return 0;
12471247
}
12481248

0 commit comments

Comments
 (0)