The DCB buffer object has a settable array of 32-bit quantities, and the
maxrate object of 64-bit ones. Adjust dcb_parse_mapping() and related
helpers to support 64-bit values in mappings, and add appropriate helpers.

Signed-off-by: Petr Machata <m...@pmachata.org>
---
 dcb/dcb.c | 22 ++++++++++++++++++----
 dcb/dcb.h |  8 +++++---
 2 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/dcb/dcb.c b/dcb/dcb.c
index 217dd640d7e5..7c0beee43686 100644
--- a/dcb/dcb.c
+++ b/dcb/dcb.c
@@ -229,8 +229,8 @@ void dcb_print_named_array(const char *json_name, const 
char *fp_name,
 }
 
 int dcb_parse_mapping(const char *what_key, __u32 key, __u32 max_key,
-                     const char *what_value, __u32 value, __u32 max_value,
-                     void (*set_array)(__u32 index, __u32 value, void *data),
+                     const char *what_value, __u64 value, __u64 max_value,
+                     void (*set_array)(__u32 index, __u64 value, void *data),
                      void *set_array_data)
 {
        bool is_all = key == (__u32) -1;
@@ -242,7 +242,7 @@ int dcb_parse_mapping(const char *what_key, __u32 key, 
__u32 max_key,
        }
 
        if (value > max_value) {
-               fprintf(stderr, "In %s:%s mapping, %s is expected to be 
0..%d\n",
+               fprintf(stderr, "In %s:%s mapping, %s is expected to be 
0..%llu\n",
                        what_key, what_value, what_value, max_value);
                return -EINVAL;
        }
@@ -257,13 +257,27 @@ int dcb_parse_mapping(const char *what_key, __u32 key, 
__u32 max_key,
        return 0;
 }
 
-void dcb_set_u8(__u32 key, __u32 value, void *data)
+void dcb_set_u8(__u32 key, __u64 value, void *data)
 {
        __u8 *array = data;
 
        array[key] = value;
 }
 
+void dcb_set_u32(__u32 key, __u64 value, void *data)
+{
+       __u32 *array = data;
+
+       array[key] = value;
+}
+
+void dcb_set_u64(__u32 key, __u64 value, void *data)
+{
+       __u64 *array = data;
+
+       array[key] = value;
+}
+
 int dcb_cmd_parse_dev(struct dcb *dcb, int argc, char **argv,
                      int (*and_then)(struct dcb *dcb, const char *dev,
                                      int argc, char **argv),
diff --git a/dcb/dcb.h b/dcb/dcb.h
index 6f135ed06b08..d22176888811 100644
--- a/dcb/dcb.h
+++ b/dcb/dcb.h
@@ -14,15 +14,17 @@ struct dcb {
 };
 
 int dcb_parse_mapping(const char *what_key, __u32 key, __u32 max_key,
-                     const char *what_value, __u32 value, __u32 max_value,
-                     void (*set_array)(__u32 index, __u32 value, void *data),
+                     const char *what_value, __u64 value, __u64 max_value,
+                     void (*set_array)(__u32 index, __u64 value, void *data),
                      void *set_array_data);
 int dcb_cmd_parse_dev(struct dcb *dcb, int argc, char **argv,
                      int (*and_then)(struct dcb *dcb, const char *dev,
                                      int argc, char **argv),
                      void (*help)(void));
 
-void dcb_set_u8(__u32 key, __u32 value, void *data);
+void dcb_set_u8(__u32 key, __u64 value, void *data);
+void dcb_set_u32(__u32 key, __u64 value, void *data);
+void dcb_set_u64(__u32 key, __u64 value, void *data);
 
 int dcb_get_attribute(struct dcb *dcb, const char *dev, int attr,
                      void *data, size_t data_len);
-- 
2.25.1

Reply via email to