diff mbox series

[7/7] pwm: sifive: Shut down hardware only after pwmchip_remove() completed

Message ID 20220721103129.304697-7-u.kleine-koenig@pengutronix.de (mailing list archive)
State New, archived
Headers show
Series [1/7] pwm: sifive: Simplify offset calculation for PWMCMP registers | expand

Commit Message

Uwe Kleine-König July 21, 2022, 10:31 a.m. UTC
The PWMs are expected to be functional until pwmchip_remove() is called.
So disable the clks only afterwards.

Fixes: 9e37a53eb051 ("pwm: sifive: Add a driver for SiFive SoC PWM")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/pwm/pwm-sifive.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Emil Renner Berthing July 22, 2022, 5:45 p.m. UTC | #1
On Thu, 21 Jul 2022 at 12:32, Uwe Kleine-König
<u.kleine-koenig@pengutronix.de> wrote:
> The PWMs are expected to be functional until pwmchip_remove() is called.
> So disable the clks only afterwards.
>
> Fixes: 9e37a53eb051 ("pwm: sifive: Add a driver for SiFive SoC PWM")
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

Hi Uwe,

You didn't send a cover letter so unsure which mail to respond to, but
I tested this series with

https://lore.kernel.org/linux-riscv/20220705210143.315151-1-emil.renner.berthing@canonical.com/

..and everything keeps working, so

Tested-by: Emil Renner Berhing <emil.renner.berthing@canonical.com>

/Emil
> ---
>  drivers/pwm/pwm-sifive.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/pwm/pwm-sifive.c b/drivers/pwm/pwm-sifive.c
> index da40ade0ebdf..2d4fa5e5fdd4 100644
> --- a/drivers/pwm/pwm-sifive.c
> +++ b/drivers/pwm/pwm-sifive.c
> @@ -308,6 +308,9 @@ static int pwm_sifive_remove(struct platform_device *dev)
>         struct pwm_device *pwm;
>         int ch;
>
> +       pwmchip_remove(&ddata->chip);
> +       clk_notifier_unregister(ddata->clk, &ddata->notifier);
> +
>         for (ch = 0; ch < ddata->chip.npwm; ch++) {
>                 pwm = &ddata->chip.pwms[ch];
>                 if (pwm->state.enabled)
> @@ -315,8 +318,6 @@ static int pwm_sifive_remove(struct platform_device *dev)
>         }
>
>         clk_unprepare(ddata->clk);
> -       pwmchip_remove(&ddata->chip);
> -       clk_notifier_unregister(ddata->clk, &ddata->notifier);
>
>         return 0;
>  }
> --
> 2.36.1
>
>
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv
Thierry Reding July 28, 2022, 5:12 p.m. UTC | #2
On Fri, Jul 22, 2022 at 07:45:32PM +0200, Emil Renner Berthing wrote:
> On Thu, 21 Jul 2022 at 12:32, Uwe Kleine-König
> <u.kleine-koenig@pengutronix.de> wrote:
> > The PWMs are expected to be functional until pwmchip_remove() is called.
> > So disable the clks only afterwards.
> >
> > Fixes: 9e37a53eb051 ("pwm: sifive: Add a driver for SiFive SoC PWM")
> > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> 
> Hi Uwe,
> 
> You didn't send a cover letter so unsure which mail to respond to, but
> I tested this series with
> 
> https://lore.kernel.org/linux-riscv/20220705210143.315151-1-emil.renner.berthing@canonical.com/
> 
> ..and everything keeps working, so
> 
> Tested-by: Emil Renner Berhing <emil.renner.berthing@canonical.com>

This is fine, I've applied the tag to the whole series since you said
that you had tested the whole series. I'm not sure, but I don't think
patchwork automatically adds tags to all patches if they are given to
the cover letter, so in those cases a bit of manual intervention can
be necessary. Perhaps b4 can do this automatically. I should probably
test that at some point.

Thierry
Conor Dooley July 28, 2022, 5:45 p.m. UTC | #3
On 28/07/2022 18:12, Thierry Reding wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> On Fri, Jul 22, 2022 at 07:45:32PM +0200, Emil Renner Berthing wrote:
>> On Thu, 21 Jul 2022 at 12:32, Uwe Kleine-König
>> <u.kleine-koenig@pengutronix.de> wrote:
>>> The PWMs are expected to be functional until pwmchip_remove() is called.
>>> So disable the clks only afterwards.
>>>
>>> Fixes: 9e37a53eb051 ("pwm: sifive: Add a driver for SiFive SoC PWM")
>>> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
>>
>> Hi Uwe,
>>
>> You didn't send a cover letter so unsure which mail to respond to, but
>> I tested this series with
>>
>> https://lore.kernel.org/linux-riscv/20220705210143.315151-1-emil.renner.berthing@canonical.com/
>>
>> ..and everything keeps working, so
>>
>> Tested-by: Emil Renner Berhing <emil.renner.berthing@canonical.com>
                             ^
Pretty minor I guess, but that should be "Berthing"

> 
> This is fine, I've applied the tag to the whole series since you said
> that you had tested the whole series. I'm not sure, but I don't think
> patchwork automatically adds tags to all patches if they are given to
> the cover letter, so in those cases a bit of manual intervention can
> be necessary. Perhaps b4 can do this automatically. I should probably
> test that at some point.

The -t flag for b4 am will do it automatically for tags applied to the
cove. In fact it prompts you if you don't pass -t and the cover has
tags.

Thanks,
Conor.
diff mbox series

Patch

diff --git a/drivers/pwm/pwm-sifive.c b/drivers/pwm/pwm-sifive.c
index da40ade0ebdf..2d4fa5e5fdd4 100644
--- a/drivers/pwm/pwm-sifive.c
+++ b/drivers/pwm/pwm-sifive.c
@@ -308,6 +308,9 @@  static int pwm_sifive_remove(struct platform_device *dev)
 	struct pwm_device *pwm;
 	int ch;
 
+	pwmchip_remove(&ddata->chip);
+	clk_notifier_unregister(ddata->clk, &ddata->notifier);
+
 	for (ch = 0; ch < ddata->chip.npwm; ch++) {
 		pwm = &ddata->chip.pwms[ch];
 		if (pwm->state.enabled)
@@ -315,8 +318,6 @@  static int pwm_sifive_remove(struct platform_device *dev)
 	}
 
 	clk_unprepare(ddata->clk);
-	pwmchip_remove(&ddata->chip);
-	clk_notifier_unregister(ddata->clk, &ddata->notifier);
 
 	return 0;
 }