diff mbox series

[RFC,PATCH-for-6.1,v2,1/6] target/mips/cpu: Use clock_has_source() instead of clock_get()

Message ID 20210409093623.2402750-2-f4bug@amsat.org
State New
Headers show
Series target/mips/cp0_timer: Use new clock_ns_to_ticks() | expand

Commit Message

Philippe Mathieu-Daudé April 9, 2021, 9:36 a.m. UTC
clock_get() returns the clock period. With an unconnected clock
we get 0. This is not what we want here. Use the API properly
by using the clock_has_source() function instead.

Fixes: a0713e85bfa ("target/mips/cpu: Allow the CPU to use dynamic frequencies")
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 target/mips/cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Richard Henderson April 9, 2021, 4:13 p.m. UTC | #1
On 4/9/21 2:36 AM, Philippe Mathieu-Daudé wrote:
> clock_get() returns the clock period. With an unconnected clock
> we get 0. This is not what we want here. Use the API properly
> by using the clock_has_source() function instead.
> 
> Fixes: a0713e85bfa ("target/mips/cpu: Allow the CPU to use dynamic frequencies")
> Signed-off-by: Philippe Mathieu-Daudé<f4bug@amsat.org>
> ---
>   target/mips/cpu.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~
diff mbox series

Patch

diff --git a/target/mips/cpu.c b/target/mips/cpu.c
index dce1e166bde..aa0b00256e6 100644
--- a/target/mips/cpu.c
+++ b/target/mips/cpu.c
@@ -612,7 +612,7 @@  static void mips_cpu_realizefn(DeviceState *dev, Error **errp)
     MIPSCPUClass *mcc = MIPS_CPU_GET_CLASS(dev);
     Error *local_err = NULL;
 
-    if (!clock_get(cpu->clock)) {
+    if (!clock_has_source(cpu->clock)) {
 #ifndef CONFIG_USER_ONLY
         if (!qtest_enabled()) {
             g_autofree char *cpu_freq_str = freq_to_str(CPU_FREQ_HZ_DEFAULT);