[PATCH 02/10] qmi: wda: Add qmi_wda_parse_data_format utility
Denis Kenzior <[email protected]>
| Newsgroups | dev.linux.lists.ofono |
|---|---|
| Message-ID | <[email protected]> |
This utility function parses the response from WDA Set Data Format
result message, and from the WDA Get Data Format result message.
---
drivers/qmimodem/wda.c | 36 ++++++++++++++++++++++++++++++++++++
drivers/qmimodem/wda.h | 2 ++
2 files changed, 38 insertions(+)
diff --git a/drivers/qmimodem/wda.c b/drivers/qmimodem/wda.c
index cf32aa094d69..0ba8914312da 100644
--- a/drivers/qmimodem/wda.c
+++ b/drivers/qmimodem/wda.c
@@ -16,6 +16,42 @@
#include "common.h"
#include "wda.h"
+int qmi_wda_parse_data_format(struct qmi_result *result,
+ struct qmi_wda_data_format *out_format)
+{
+ static const uint8_t RESULT_LL_PROTO = 0x11;
+ static const uint8_t RESULT_UL_AGGREGATION_PROTOCOL = 0x12;
+ static const uint8_t RESULT_DL_AGGREGATION_PROTOCOL = 0x13;
+ static const uint8_t RESULT_DL_MAX_DATAGRAMS = 0x15;
+ static const uint8_t RESULT_DL_MAX_SIZE = 0x16;
+ struct qmi_wda_data_format format;
+
+ if (!qmi_result_get_uint32(result, RESULT_LL_PROTO,
+ &format.ll_protocol))
+ return -ENOENT;
+
+ if (!qmi_result_get_uint32(result, RESULT_UL_AGGREGATION_PROTOCOL,
+ &format.ul_aggregation_protocol))
+ return -ENOENT;
+
+ if (!qmi_result_get_uint32(result, RESULT_DL_AGGREGATION_PROTOCOL,
+ &format.dl_aggregation_protocol))
+ return -ENOENT;
+
+ if (!qmi_result_get_uint32(result, RESULT_DL_MAX_DATAGRAMS,
+ &format.dl_max_datagrams))
+ return -ENOENT;
+
+ if (!qmi_result_get_uint32(result, RESULT_DL_MAX_SIZE,
+ &format.dl_max_size))
+ return -ENOENT;
+
+ if (out_format)
+ memcpy(out_format, &format, sizeof(struct qmi_wda_data_format));
+
+ return 0;
+}
+
uint16_t qmi_wda_set_data_format(struct qmi_service *wda,
const struct qmi_endpoint_info *endpoint_info,
const struct qmi_wda_data_format *format,
diff --git a/drivers/qmimodem/wda.h b/drivers/qmimodem/wda.h
index 4facc0cb6677..608c04947d6a 100644
--- a/drivers/qmimodem/wda.h
+++ b/drivers/qmimodem/wda.h
@@ -34,6 +34,8 @@ struct qmi_wda_data_format {
uint32_t dl_max_size;
};
+int qmi_wda_parse_data_format(struct qmi_result *result,
+ struct qmi_wda_data_format *out_format);
uint16_t qmi_wda_set_data_format(struct qmi_service *wda,
const struct qmi_endpoint_info *endpoint_info,
const struct qmi_wda_data_format *format,
--
2.47.0