All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH][v2] qmimodem: add debug helper qmi_result_print_tlvs
@ 2017-05-23 11:47 Alexander Couzens
  2017-05-30 22:29 ` Denis Kenzior
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander Couzens @ 2017-05-23 11:47 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 1523 bytes --]

qmi_result_print_tlvs prints the type and length field
of a result to DBG()
---
 drivers/qmimodem/qmi.c | 17 +++++++++++++++++
 drivers/qmimodem/qmi.h |  2 +-
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c
index 30123723..17c6a6f3 100644
--- a/drivers/qmimodem/qmi.c
+++ b/drivers/qmimodem/qmi.c
@@ -1026,6 +1026,23 @@ void qmi_device_set_close_on_unref(struct qmi_device *device, bool do_close)
 	device->close_on_unref = do_close;
 }
 
+void qmi_result_print_tlvs(struct qmi_result *result)
+{
+	const void *ptr = result->data;
+	uint16_t len = result->length;
+
+	while (len > QMI_TLV_HDR_SIZE) {
+		const struct qmi_tlv_hdr *tlv = ptr;
+		uint16_t tlv_length = GUINT16_FROM_LE(tlv->length);
+
+		DBG("tlv: 0x%02x len 0x%04x", tlv->type, tlv->length);
+
+		ptr += QMI_TLV_HDR_SIZE + tlv_length;
+		len -= QMI_TLV_HDR_SIZE + tlv_length;
+	}
+}
+
+
 static const void *tlv_get(const void *data, uint16_t size,
 					uint8_t type, uint16_t *length)
 {
diff --git a/drivers/qmimodem/qmi.h b/drivers/qmimodem/qmi.h
index 0cd8f7c9..bfe8e6b5 100644
--- a/drivers/qmimodem/qmi.h
+++ b/drivers/qmimodem/qmi.h
@@ -136,7 +136,7 @@ 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);
-
+void qmi_result_print_tlvs(struct qmi_result *result);
 
 struct qmi_service;
 
-- 
2.13.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH][v2] qmimodem: add debug helper qmi_result_print_tlvs
  2017-05-23 11:47 [PATCH][v2] qmimodem: add debug helper qmi_result_print_tlvs Alexander Couzens
@ 2017-05-30 22:29 ` Denis Kenzior
  0 siblings, 0 replies; 2+ messages in thread
From: Denis Kenzior @ 2017-05-30 22:29 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 339 bytes --]

Hi Alexander,

On 05/23/2017 06:47 AM, Alexander Couzens wrote:
> qmi_result_print_tlvs prints the type and length field
> of a result to DBG()
> ---
>  drivers/qmimodem/qmi.c | 17 +++++++++++++++++
>  drivers/qmimodem/qmi.h |  2 +-
>  2 files changed, 18 insertions(+), 1 deletion(-)
>

Applied, thanks.

Regards,
-Denis


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-05-30 22:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-23 11:47 [PATCH][v2] qmimodem: add debug helper qmi_result_print_tlvs Alexander Couzens
2017-05-30 22:29 ` Denis Kenzior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.