[PATCH-for-9.0 v2 1/8] hw/clock: Have clock_set_mul_div() return early when nothing to change

Philippe Mathieu-Daudé posted 8 patches 1 year, 10 months ago
Maintainers: Luc Michel <luc@lmichel.fr>, Damien Hedde <damien.hedde@dahe.fr>, "Cédric Le Goater" <clg@kaod.org>, Peter Maydell <peter.maydell@linaro.org>, Andrew Jeffery <andrew@codeconstruct.com.au>, Joel Stanley <joel@jms.id.au>, Subbaraya Sundeep <sundeep.lkml@gmail.com>, Alistair Francis <alistair@alistair23.me>, Felipe Balbi <balbi@kernel.org>, Alexandre Iooss <erdnaxe@crans.org>, "Edgar E. Iglesias" <edgar.iglesias@gmail.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Arnaud Minier <arnaud.minier@telecom-paris.fr>, "Inès Varhol" <ines.varhol@telecom-paris.fr>
There is a newer version of this series
[PATCH-for-9.0 v2 1/8] hw/clock: Have clock_set_mul_div() return early when nothing to change
Posted by Philippe Mathieu-Daudé 1 year, 10 months ago
Return early when clock_set_mul_div() is called with
same mul/div values the clock has.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/core/clock.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/hw/core/clock.c b/hw/core/clock.c
index d82e44cd1a..c73f0c2f98 100644
--- a/hw/core/clock.c
+++ b/hw/core/clock.c
@@ -147,6 +147,10 @@ void clock_set_mul_div(Clock *clk, uint32_t multiplier, uint32_t divider)
 {
     assert(divider != 0);
 
+    if (clk->multiplier == multiplier && clk->divider == divider) {
+        return;
+    }
+
     trace_clock_set_mul_div(CLOCK_PATH(clk), clk->multiplier, multiplier,
                             clk->divider, divider);
     clk->multiplier = multiplier;
-- 
2.41.0


Re: [PATCH-for-9.0 v2 1/8] hw/clock: Have clock_set_mul_div() return early when nothing to change
Posted by Alistair Francis 1 year, 10 months ago
On Mon, Mar 25, 2024 at 11:34 PM Philippe Mathieu-Daudé
<philmd@linaro.org> wrote:
>
> Return early when clock_set_mul_div() is called with
> same mul/div values the clock has.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  hw/core/clock.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/hw/core/clock.c b/hw/core/clock.c
> index d82e44cd1a..c73f0c2f98 100644
> --- a/hw/core/clock.c
> +++ b/hw/core/clock.c
> @@ -147,6 +147,10 @@ void clock_set_mul_div(Clock *clk, uint32_t multiplier, uint32_t divider)
>  {
>      assert(divider != 0);
>
> +    if (clk->multiplier == multiplier && clk->divider == divider) {
> +        return;
> +    }
> +
>      trace_clock_set_mul_div(CLOCK_PATH(clk), clk->multiplier, multiplier,
>                              clk->divider, divider);
>      clk->multiplier = multiplier;
> --
> 2.41.0
>
>