Patchwork [2/2] target-i386: use visit_type_suffixed_int() to parse tsc_freq property value

login
register
mail settings
Submitter Igor Mammedov
Date Dec. 10, 2012, 9:33 p.m.
Message ID <1355175187-11470-3-git-send-email-imammedo@redhat.com>
Download mbox | patch
Permalink /patch/205038/
State New
Headers show

Comments

Igor Mammedov - Dec. 10, 2012, 9:33 p.m.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
  v3:
   - s/visit_type_unit_suffixed_int/visit_type_suffixed_int/
  v2:
   - replace visit_type_freq() with visit_type_unit_suffixed_int()
     in x86_cpuid_set_tsc_freq()
---
 target-i386/cpu.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Eduardo Habkost - Dec. 12, 2012, 6:16 p.m.
On Mon, Dec 10, 2012 at 10:33:07PM +0100, Igor Mammedov wrote:
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>

Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>

Like I said in the previous patch, maybe it would be nice to have a
visit_type_frequency() helper, to hide the specific details/parameters
required to parse frequency values.


> ---
>   v3:
>    - s/visit_type_unit_suffixed_int/visit_type_suffixed_int/
>   v2:
>    - replace visit_type_freq() with visit_type_unit_suffixed_int()
>      in x86_cpuid_set_tsc_freq()
> ---
>  target-i386/cpu.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/target-i386/cpu.c b/target-i386/cpu.c
> index 7be3ad8..18adff4 100644
> --- a/target-i386/cpu.c
> +++ b/target-i386/cpu.c
> @@ -1194,8 +1194,9 @@ static void x86_cpuid_set_tsc_freq(Object *obj, Visitor *v, void *opaque,
>      const int64_t min = 0;
>      const int64_t max = INT64_MAX;
>      int64_t value;
> +    const int kHz_factor = 1000;
>  
> -    visit_type_int(v, &value, name, errp);
> +    visit_type_suffixed_int(v, &value, name, kHz_factor, errp);
>      if (error_is_set(errp)) {
>          return;
>      }
> -- 
> 1.7.11.7
> 
>

Patch

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 7be3ad8..18adff4 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1194,8 +1194,9 @@  static void x86_cpuid_set_tsc_freq(Object *obj, Visitor *v, void *opaque,
     const int64_t min = 0;
     const int64_t max = INT64_MAX;
     int64_t value;
+    const int kHz_factor = 1000;
 
-    visit_type_int(v, &value, name, errp);
+    visit_type_suffixed_int(v, &value, name, kHz_factor, errp);
     if (error_is_set(errp)) {
         return;
     }