Skip to content

Commit 3aba840

Browse files
author
Bartosz Golaszewski
committed
gpio: grgpio: remove remove()
Use devres to automatically manage resources and remove the remove() callback. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bartosz Golaszewski <[email protected]>
1 parent d036ae4 commit 3aba840

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

drivers/gpio/gpio-grgpio.c

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,13 @@ static void grgpio_irq_unmap(struct irq_domain *d, unsigned int irq)
318318
raw_spin_unlock_irqrestore(&priv->gc.bgpio_lock, flags);
319319
}
320320

321+
static void grgpio_irq_domain_remove(void *data)
322+
{
323+
struct irq_domain *domain = data;
324+
325+
irq_domain_remove(domain);
326+
}
327+
321328
static const struct irq_domain_ops grgpio_irq_domain_ops = {
322329
.map = grgpio_irq_map,
323330
.unmap = grgpio_irq_unmap,
@@ -394,6 +401,11 @@ static int grgpio_probe(struct platform_device *ofdev)
394401
return -EINVAL;
395402
}
396403

404+
err = devm_add_action_or_reset(dev, grgpio_irq_domain_remove,
405+
priv->domain);
406+
if (err)
407+
return err;
408+
397409
for (i = 0; i < gc->ngpio; i++) {
398410
struct grgpio_lirq *lirq;
399411
int ret;
@@ -416,13 +428,9 @@ static int grgpio_probe(struct platform_device *ofdev)
416428
}
417429
}
418430

419-
platform_set_drvdata(ofdev, priv);
420-
421-
err = gpiochip_add_data(gc, priv);
431+
err = devm_gpiochip_add_data(dev, gc, priv);
422432
if (err) {
423433
dev_err(dev, "Could not add gpiochip\n");
424-
if (priv->domain)
425-
irq_domain_remove(priv->domain);
426434
return err;
427435
}
428436

@@ -432,16 +440,6 @@ static int grgpio_probe(struct platform_device *ofdev)
432440
return 0;
433441
}
434442

435-
static void grgpio_remove(struct platform_device *ofdev)
436-
{
437-
struct grgpio_priv *priv = platform_get_drvdata(ofdev);
438-
439-
gpiochip_remove(&priv->gc);
440-
441-
if (priv->domain)
442-
irq_domain_remove(priv->domain);
443-
}
444-
445443
static const struct of_device_id grgpio_match[] = {
446444
{.name = "GAISLER_GPIO"},
447445
{.name = "01_01a"},
@@ -456,7 +454,6 @@ static struct platform_driver grgpio_driver = {
456454
.of_match_table = grgpio_match,
457455
},
458456
.probe = grgpio_probe,
459-
.remove = grgpio_remove,
460457
};
461458
module_platform_driver(grgpio_driver);
462459

0 commit comments

Comments
 (0)