From 1cc9f44e93ca1c3e25a6f937f36d99c3f9c8a209 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 9 Jul 2018 16:00:45 +1000 Subject: [PATCH] quirks: add quirks_get_double() Signed-off-by: Peter Hutterer --- src/quirks.c | 20 ++++++++++++++++++++ src/quirks.h | 13 +++++++++++++ tools/shared.c | 1 + 3 files changed, 34 insertions(+) diff --git a/src/quirks.c b/src/quirks.c index c74ecbb4..8d0d6847 100644 --- a/src/quirks.c +++ b/src/quirks.c @@ -54,6 +54,7 @@ enum property_type { PT_BOOL, PT_DIMENSION, PT_RANGE, + PT_DOUBLE, }; /** @@ -74,6 +75,7 @@ struct property { char *s; struct quirk_dimensions dim; struct quirk_range range; + double d; } value; }; @@ -1434,6 +1436,24 @@ quirks_get_uint32(struct quirks *q, enum quirk which, uint32_t *val) return true; } +bool +quirks_get_double(struct quirks *q, enum quirk which, double *val) +{ + struct property *p; + + if (!q) + return false; + + p = quirk_find_prop(q, which); + if (!p) + return false; + + assert(p->type == PT_DOUBLE); + *val = p->value.d; + + return true; +} + bool quirks_get_string(struct quirks *q, enum quirk which, char **val) { diff --git a/src/quirks.h b/src/quirks.h index 36e1e14b..df8b7dd3 100644 --- a/src/quirks.h +++ b/src/quirks.h @@ -216,6 +216,19 @@ quirks_get_int32(struct quirks *q, enum quirk which, int32_t *val); +/** + * Get the value of the given quirk, as double. + * This function will assert if the quirk type does not match the + * requested type. If the quirk is not set for this device, val is + * unchanged. + * + * @return true if the quirk value is valid, false otherwise. + */ +bool +quirks_get_double(struct quirks *q, + enum quirk which, + double *val); + /** * Get the value of the given quirk, as string. * This function will assert if the quirk type does not match the diff --git a/tools/shared.c b/tools/shared.c index 3cda4573..fa03cc75 100644 --- a/tools/shared.c +++ b/tools/shared.c @@ -630,6 +630,7 @@ tools_list_device_quirks(struct quirks_context *ctx, struct quirk_range r; uint32_t v; char *s; + double d; if (!quirks_has_quirk(quirks, *q)) continue;