Skip to content

Commit 10af027

Browse files
dthompsoBartosz Golaszewski
authored andcommitted
gpio: mlxbf3: only get IRQ for device instance 0
The gpio-mlxbf3 driver interfaces with two GPIO controllers, device instance 0 and 1. There is a single IRQ resource shared between the two controllers, and it is found in the ACPI table for device instance 0. The driver should not attempt to get an IRQ resource when probing device instance 1, otherwise the following error is logged: mlxbf3_gpio MLNXBF33:01: error -ENXIO: IRQ index 0 not found Signed-off-by: David Thompson <[email protected]> Reviewed-by: Shravan Kumar Ramani <[email protected]> Fixes: cd33f21 ("gpio: mlxbf3: Add gpio driver support") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bartosz Golaszewski <[email protected]>
1 parent 0a1db19 commit 10af027

File tree

1 file changed

+35
-19
lines changed

1 file changed

+35
-19
lines changed

drivers/gpio/gpio-mlxbf3.c

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,9 @@ static int mlxbf3_gpio_probe(struct platform_device *pdev)
190190
struct mlxbf3_gpio_context *gs;
191191
struct gpio_irq_chip *girq;
192192
struct gpio_chip *gc;
193+
char *colon_ptr;
193194
int ret, irq;
195+
long num;
194196

195197
gs = devm_kzalloc(dev, sizeof(*gs), GFP_KERNEL);
196198
if (!gs)
@@ -227,25 +229,39 @@ static int mlxbf3_gpio_probe(struct platform_device *pdev)
227229
gc->owner = THIS_MODULE;
228230
gc->add_pin_ranges = mlxbf3_gpio_add_pin_ranges;
229231

230-
irq = platform_get_irq(pdev, 0);
231-
if (irq >= 0) {
232-
girq = &gs->gc.irq;
233-
gpio_irq_chip_set_chip(girq, &gpio_mlxbf3_irqchip);
234-
girq->default_type = IRQ_TYPE_NONE;
235-
/* This will let us handle the parent IRQ in the driver */
236-
girq->num_parents = 0;
237-
girq->parents = NULL;
238-
girq->parent_handler = NULL;
239-
girq->handler = handle_bad_irq;
240-
241-
/*
242-
* Directly request the irq here instead of passing
243-
* a flow-handler because the irq is shared.
244-
*/
245-
ret = devm_request_irq(dev, irq, mlxbf3_gpio_irq_handler,
246-
IRQF_SHARED, dev_name(dev), gs);
247-
if (ret)
248-
return dev_err_probe(dev, ret, "failed to request IRQ");
232+
colon_ptr = strchr(dev_name(dev), ':');
233+
if (!colon_ptr) {
234+
dev_err(dev, "invalid device name format\n");
235+
return -EINVAL;
236+
}
237+
238+
ret = kstrtol(++colon_ptr, 16, &num);
239+
if (ret) {
240+
dev_err(dev, "invalid device instance\n");
241+
return ret;
242+
}
243+
244+
if (!num) {
245+
irq = platform_get_irq(pdev, 0);
246+
if (irq >= 0) {
247+
girq = &gs->gc.irq;
248+
gpio_irq_chip_set_chip(girq, &gpio_mlxbf3_irqchip);
249+
girq->default_type = IRQ_TYPE_NONE;
250+
/* This will let us handle the parent IRQ in the driver */
251+
girq->num_parents = 0;
252+
girq->parents = NULL;
253+
girq->parent_handler = NULL;
254+
girq->handler = handle_bad_irq;
255+
256+
/*
257+
* Directly request the irq here instead of passing
258+
* a flow-handler because the irq is shared.
259+
*/
260+
ret = devm_request_irq(dev, irq, mlxbf3_gpio_irq_handler,
261+
IRQF_SHARED, dev_name(dev), gs);
262+
if (ret)
263+
return dev_err_probe(dev, ret, "failed to request IRQ");
264+
}
249265
}
250266

251267
platform_set_drvdata(pdev, gs);

0 commit comments

Comments
 (0)