Re: [PATCH] pmdomain: raspberrypi-power: add remove function
From: Ulf Hansson
Date: Thu Jul 16 2026 - 08:28:57 EST
On Wed, Jul 15, 2026 at 10:16 AM Gregor Herburger
<gregor.herburger@xxxxxxxxxxxxx> wrote:
>
> The raspberrypi-power driver registers resources with
> of_genpd_add_provider_onecell and pm_genpd_init but never removes them.
> When the driver gets unbound and bound again this causes error. Add a
> remove function to cleanup all registered resources.
>
> Signed-off-by: Gregor Herburger <gregor.herburger@xxxxxxxxxxxxx>
> ---
> drivers/pmdomain/bcm/raspberrypi-power.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/drivers/pmdomain/bcm/raspberrypi-power.c b/drivers/pmdomain/bcm/raspberrypi-power.c
> index b87ea7adb7bea..2c2135c17afb0 100644
> --- a/drivers/pmdomain/bcm/raspberrypi-power.c
> +++ b/drivers/pmdomain/bcm/raspberrypi-power.c
> @@ -232,6 +232,17 @@ static int rpi_power_probe(struct platform_device *pdev)
> return 0;
> }
>
> +static void rpi_power_remove(struct platform_device *pdev)
> +{
> + struct rpi_power_domains *rpi_domains = platform_get_drvdata(pdev);
> + int nr_domains = RPI_POWER_DOMAIN_COUNT - 1;
> +
> + of_genpd_del_provider(pdev->dev.of_node);
> +
> + for (int i = nr_domains; i >= 0; i--)
> + pm_genpd_remove(&rpi_domains->domains[i].base);
> +}
> +
> static const struct of_device_id rpi_power_of_match[] = {
> { .compatible = "raspberrypi,bcm2835-power", },
> {},
> @@ -244,6 +255,7 @@ static struct platform_driver rpi_power_driver = {
> .of_match_table = rpi_power_of_match,
> },
> .probe = rpi_power_probe,
> + .remove = rpi_power_remove,
In general it's not a good idea to allow unbinding power domain
drivers, as it will probably break consumers and their drivers.
Although, I don't know whether it makes sense in this particular case.
Another option is to prevent user-space from unbinding by adding the below here:
".suppress_bind_attrs = true,"
> };
> builtin_platform_driver(rpi_power_driver);
>
Kind regards
Uffe