From 74d208768ae462ec9946a58c4977b031771c0b95 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Sun, 24 Jun 2012 22:24:56 -0700 Subject: [PATCH] qmimodem: Add helper function for accessing 64-bit integers --- drivers/qmimodem/qmi.c | 22 ++++++++++++++++++++++ drivers/qmimodem/qmi.h | 2 ++ 2 files changed, 24 insertions(+) diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index b08321d..378da80 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -1320,6 +1320,28 @@ bool qmi_result_get_uint32(struct qmi_result *result, uint8_t type, return true; } +bool qmi_result_get_uint64(struct qmi_result *result, uint8_t type, + uint64_t *value) +{ + const unsigned char *ptr; + uint16_t len; + uint64_t tmp; + + if (!result || !type) + return false; + + ptr = tlv_get(result->data, result->length, type, &len); + if (!ptr) + return false; + + memcpy(&tmp, ptr, 8); + + if (value) + *value = GUINT64_FROM_LE(tmp); + + return true; +} + struct service_create_data { struct qmi_device *device; uint8_t type; diff --git a/drivers/qmimodem/qmi.h b/drivers/qmimodem/qmi.h index 0bfba93..f8f18b9 100644 --- a/drivers/qmimodem/qmi.h +++ b/drivers/qmimodem/qmi.h @@ -114,6 +114,8 @@ bool qmi_result_get_uint16(struct qmi_result *result, uint8_t type, uint16_t *value); bool qmi_result_get_uint32(struct qmi_result *result, uint8_t type, uint32_t *value); +bool qmi_result_get_uint64(struct qmi_result *result, uint8_t type, + uint64_t *value); struct qmi_service; -- 2.7.4