[PATCH-for-9.0 v3 2/3] hw/misc/stm32l4x5_rcc: Inline clock_update() in clock_mux_update()

Philippe Mathieu-Daudé posted 3 patches 1 year, 10 months ago
Maintainers: Luc Michel <luc@lmichel.fr>, Damien Hedde <damien.hedde@dahe.fr>, Arnaud Minier <arnaud.minier@telecom-paris.fr>, "Inès Varhol" <ines.varhol@telecom-paris.fr>
[PATCH-for-9.0 v3 2/3] hw/misc/stm32l4x5_rcc: Inline clock_update() in clock_mux_update()
Posted by Philippe Mathieu-Daudé 1 year, 10 months ago
Trivial inlining in preliminary patch to make the next
one easier to review.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/misc/stm32l4x5_rcc.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/hw/misc/stm32l4x5_rcc.c b/hw/misc/stm32l4x5_rcc.c
index bc2d63528b..49b90afdf0 100644
--- a/hw/misc/stm32l4x5_rcc.c
+++ b/hw/misc/stm32l4x5_rcc.c
@@ -48,6 +48,8 @@ static void clock_mux_update(RccClockMuxState *mux, bool bypass_source)
     uint64_t src_freq;
     Clock *current_source = mux->srcs[mux->src];
     uint32_t freq_multiplier = 0;
+    bool clk_changed = false;
+
     /*
      * To avoid rounding errors, we use the clock period instead of the
      * frequency.
@@ -60,7 +62,10 @@ static void clock_mux_update(RccClockMuxState *mux, bool bypass_source)
     }
 
     clock_set_mul_div(mux->out, freq_multiplier, mux->multiplier);
-    clock_update(mux->out, clock_get(current_source));
+    clk_changed |= clock_set(mux->out, clock_get(current_source));
+    if (clk_changed) {
+        clock_propagate(mux->out);
+    }
 
     src_freq = clock_get_hz(current_source);
     /* TODO: can we simply detect if the config changed so that we reduce log spam ? */
-- 
2.41.0


Re: [PATCH-for-9.0 v3 2/3] hw/misc/stm32l4x5_rcc: Inline clock_update() in clock_mux_update()
Posted by Alistair Francis 1 year, 10 months ago
On Tue, Mar 26, 2024 at 1:29 AM Philippe Mathieu-Daudé
<philmd@linaro.org> wrote:
>
> Trivial inlining in preliminary patch to make the next
> one easier to review.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>

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

Alistair

> ---
>  hw/misc/stm32l4x5_rcc.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/hw/misc/stm32l4x5_rcc.c b/hw/misc/stm32l4x5_rcc.c
> index bc2d63528b..49b90afdf0 100644
> --- a/hw/misc/stm32l4x5_rcc.c
> +++ b/hw/misc/stm32l4x5_rcc.c
> @@ -48,6 +48,8 @@ static void clock_mux_update(RccClockMuxState *mux, bool bypass_source)
>      uint64_t src_freq;
>      Clock *current_source = mux->srcs[mux->src];
>      uint32_t freq_multiplier = 0;
> +    bool clk_changed = false;
> +
>      /*
>       * To avoid rounding errors, we use the clock period instead of the
>       * frequency.
> @@ -60,7 +62,10 @@ static void clock_mux_update(RccClockMuxState *mux, bool bypass_source)
>      }
>
>      clock_set_mul_div(mux->out, freq_multiplier, mux->multiplier);
> -    clock_update(mux->out, clock_get(current_source));
> +    clk_changed |= clock_set(mux->out, clock_get(current_source));
> +    if (clk_changed) {
> +        clock_propagate(mux->out);
> +    }
>
>      src_freq = clock_get_hz(current_source);
>      /* TODO: can we simply detect if the config changed so that we reduce log spam ? */
> --
> 2.41.0
>
>