All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] qmimodem: add debug helper qmi_result_tlv_walk
@ 2017-05-16 13:38 Alexander Couzens
  2017-05-16 18:09 ` Denis Kenzior
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander Couzens @ 2017-05-16 13:38 UTC (permalink / raw)
  To: ofono

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

qmi_result_tlv_walk 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..cdeaddaa 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_tlv_walk(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..ec4a479c 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_tlv_walk(struct qmi_result *result);
 
 struct qmi_service;
 
-- 
2.13.0


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

* Re: [PATCH] qmimodem: add debug helper qmi_result_tlv_walk
  2017-05-16 13:38 [PATCH] qmimodem: add debug helper qmi_result_tlv_walk Alexander Couzens
@ 2017-05-16 18:09 ` Denis Kenzior
  0 siblings, 0 replies; 2+ messages in thread
From: Denis Kenzior @ 2017-05-16 18:09 UTC (permalink / raw)
  To: ofono

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

Hi Alexander,

On 05/16/2017 08:38 AM, Alexander Couzens wrote:
> qmi_result_tlv_walk 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(-)
>

<snip>

> -
> +void qmi_result_tlv_walk(struct qmi_result *result);
>

Can we name this a bit more descriptively?  qmi_result_dump, or 
qmi_result_print_tlvs, qmi_result_print, etc.

Regards,
-Denis

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

end of thread, other threads:[~2017-05-16 18:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-16 13:38 [PATCH] qmimodem: add debug helper qmi_result_tlv_walk Alexander Couzens
2017-05-16 18:09 ` 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.