Skip to content

Commit 7bb8a0c

Browse files
Uwe Kleine-Königbrgl
authored andcommitted
gpio: adp5588: Remove support for platform setup and teardown callbacks
If the teardown callback failed in the gpio driver, it fails to free the irq (if there is one). The device is removed anyhow. If later on the irq triggers, all sorts of unpleasant things might happen (e.g. accessing the struct adp5588_gpio which is already freed in the meantime or starting i2c bus transfers for an unregistered device). Even before irq support was added to this driver, exiting early was wrong; back then it failed to unregister the gpiochip. Fortunately these callbacks aren't used any more since at least blackfin was removed in 2018. So just drop them. Note that they are not removed from struct adp5588_gpio_platform_data because the keyboard driver adp5588-keys.c also makes use of them. (I didn't check if the callbacks might have been called twice, maybe there is another reason hidden to better not call these functions.) This patch is a preparation for making i2c remove callbacks return void. Fixes: 8088409 ("gpio: adp5588-gpio: new driver for ADP5588 GPIO expanders") Signed-off-by: Uwe Kleine-König <[email protected]> Reviewed-by: Linus Walleij <[email protected]> Acked-by: Michael Hennerich <[email protected]> Signed-off-by: Bartosz Golaszewski <[email protected]>
1 parent 43624ed commit 7bb8a0c

File tree

1 file changed

+0
-19
lines changed

1 file changed

+0
-19
lines changed

drivers/gpio/gpio-adp5588.c

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -406,33 +406,14 @@ static int adp5588_gpio_probe(struct i2c_client *client)
406406
if (ret)
407407
return ret;
408408

409-
if (pdata && pdata->setup) {
410-
ret = pdata->setup(client, gc->base, gc->ngpio, pdata->context);
411-
if (ret < 0)
412-
dev_warn(&client->dev, "setup failed, %d\n", ret);
413-
}
414-
415409
i2c_set_clientdata(client, dev);
416410

417411
return 0;
418412
}
419413

420414
static int adp5588_gpio_remove(struct i2c_client *client)
421415
{
422-
struct adp5588_gpio_platform_data *pdata =
423-
dev_get_platdata(&client->dev);
424416
struct adp5588_gpio *dev = i2c_get_clientdata(client);
425-
int ret;
426-
427-
if (pdata && pdata->teardown) {
428-
ret = pdata->teardown(client,
429-
dev->gpio_chip.base, dev->gpio_chip.ngpio,
430-
pdata->context);
431-
if (ret < 0) {
432-
dev_err(&client->dev, "teardown failed %d\n", ret);
433-
return ret;
434-
}
435-
}
436417

437418
if (dev->client->irq)
438419
free_irq(dev->client->irq, dev);

0 commit comments

Comments
 (0)