Skip to contentSkip to conversation

bcma: host_soc: convert to devres and drop remove callback

PATCH New Rosen Penev 1 participant 1 message Jun 29 Broadcom specific amba driver (bcma)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bcma: host_soc: convert to devres and drop remove callback

Replace of_iomap with devm_platform_ioremap_resource to let the device resource framework handle unmapping. Use devm_add_action_or_reset to schedule bcma_bus_unregister on device removal, allowing the explicit remove callback to be dropped entirely.

Assisted-by opencode:big-pickle
---
 drivers/bcma/host_soc.c | 42 ++++++++++++-----------------------------
 1 file changed, 12 insertions(+), 30 deletions(-)
drivers/bcma/host_soc.c +12 -30
index 20b1816c570b..411cfbf53f7b 100644
@@ -188,22 +188,20 @@ int __init bcma_host_soc_register(struct bcma_soc *soc)
 
 int __init bcma_host_soc_init(struct bcma_soc *soc)
 {
-	struct bcma_bus *bus = &soc->bus;
-	int err;
+	return bcma_bus_early_register(&soc->bus);
+}
 
-	/* Scan bus and initialize it */
-	err = bcma_bus_early_register(bus);
-	if (err)
-		iounmap(bus->mmio);
+#ifdef CONFIG_OF
+static void bcma_host_soc_unregister(void *data)
+{
+	struct bcma_bus *bus = data;
 
-	return err;
+	bcma_bus_unregister(bus);
 }
 
-#ifdef CONFIG_OF
 static int bcma_host_soc_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
-	struct device_node *np = dev->of_node;
 	struct bcma_bus *bus;
 	int err;
 
@@ -215,9 +213,9 @@ static int bcma_host_soc_probe(struct platform_device *pdev)
 	bus->dev = dev;
 
 	/* Map MMIO */
-	bus->mmio = of_iomap(np, 0);
-	if (!bus->mmio)
-		return -ENOMEM;
+	bus->mmio = devm_platform_ioremap_resource(pdev, 0);
+	if (IS_ERR(bus->mmio))
+		return PTR_ERR(bus->mmio);
 
 	/* Host specific */
 	bus->hosttype = BCMA_HOSTTYPE_SOC;
@@ -229,24 +227,9 @@ static int bcma_host_soc_probe(struct platform_device *pdev)
 	/* Register */
 	err = bcma_bus_register(bus);
 	if (err)
-		goto err_unmap_mmio;
-
-	platform_set_drvdata(pdev, bus);
-
-	return err;
-
-err_unmap_mmio:
-	iounmap(bus->mmio);
-	return err;
-}
-
-static void bcma_host_soc_remove(struct platform_device *pdev)
-{
-	struct bcma_bus *bus = platform_get_drvdata(pdev);
+		return err;
 
-	bcma_bus_unregister(bus);
-	iounmap(bus->mmio);
-	platform_set_drvdata(pdev, NULL);
+	return devm_add_action_or_reset(dev, bcma_host_soc_unregister, bus);
 }
 
 static const struct of_device_id bcma_host_soc_of_match[] = {
@@ -261,7 +244,6 @@ static struct platform_driver bcma_host_soc_driver = {
 		.of_match_table = bcma_host_soc_of_match,
 	},
 	.probe		= bcma_host_soc_probe,
-	.remove		= bcma_host_soc_remove,
 };
 
 int __init bcma_host_soc_register_driver(void)
Signature · 1 line
2.54.0