diff mbox series

[v2,05/10] soc: bcm: raspberrypi-power: Release firmware handle on unbind

Message ID 20201022155858.20867-6-nsaenzjulienne@suse.de
State New
Headers show
Series Raspberry Pi PoE HAT fan support | expand

Commit Message

Nicolas Saenz Julienne Oct. 22, 2020, 3:58 p.m. UTC
Upon unbinding the device make sure we release RPi's firmware interface.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
---
 drivers/soc/bcm/raspberrypi-power.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
diff mbox series

Patch

diff --git a/drivers/soc/bcm/raspberrypi-power.c b/drivers/soc/bcm/raspberrypi-power.c
index 5d1aacdd84ef..a0b38db5886c 100644
--- a/drivers/soc/bcm/raspberrypi-power.c
+++ b/drivers/soc/bcm/raspberrypi-power.c
@@ -225,6 +225,20 @@  static int rpi_power_probe(struct platform_device *pdev)
 	return 0;
 }
 
+static int rpi_power_remove(struct platform_device *pdev)
+{
+	struct rpi_power_domains *rpi_domains = platform_get_drvdata(pdev);
+
+	of_genpd_del_provider(dev->of_node);
+
+	for (i = 0; i < RPI_POWER_DOMAIN_COUNT; i++)
+		pm_genpd_remove(&rpi_domains->domains[i].base);
+
+	rpi_firmware_put(rpi_domaina->fw);
+
+	return 0;
+}
+
 static const struct of_device_id rpi_power_of_match[] = {
 	{ .compatible = "raspberrypi,bcm2835-power", },
 	{},
@@ -237,6 +251,7 @@  static struct platform_driver rpi_power_driver = {
 		.of_match_table = rpi_power_of_match,
 	},
 	.probe		= rpi_power_probe,
+	.remove		= rpi_power_remove,
 };
 builtin_platform_driver(rpi_power_driver);