qmimodem: Print error string instead of code if available
authorMarcel Holtmann <marcel@holtmann.org>
Sun, 25 Nov 2012 09:19:40 +0000 (10:19 +0100)
committerMarcel Holtmann <marcel@holtmann.org>
Sun, 25 Nov 2012 09:19:40 +0000 (10:19 +0100)
drivers/qmimodem/qmi.c

index ab34a8e..b2f2276 100644 (file)
@@ -540,9 +540,16 @@ static void __debug_msg(const char dir, const void *buf, size_t len,
                if (tlv->type == 0x02 && tlv_length == QMI_RESULT_CODE_SIZE) {
                        const struct qmi_result_code *result = ptr + offset +
                                                        QMI_TLV_HDR_SIZE;
-
-                       str += sprintf(str, " {type=%d,error=%d}", tlv->type,
-                                               GUINT16_FROM_LE(result->error));
+                       uint16_t error = GUINT16_FROM_LE(result->error);
+                       const char *error_str;
+
+                       error_str = __error_to_string(error);
+                       if (error_str)
+                               str += sprintf(str, " {type=%d,error=%s}",
+                                                       tlv->type, error_str);
+                       else
+                               str += sprintf(str, " {type=%d,error=%d}",
+                                                       tlv->type, error);
                } else {
                        str += sprintf(str, " {type=%d,len=%d}", tlv->type,
                                                                tlv_length);