[PATCH 1/3] memstick: rtsx: dump register using compact format

From: micky_ching
Date: Tue Jan 13 2015 - 21:55:09 EST


From: Micky Ching <micky_ching@xxxxxxxxxxxxxx>

Using more compact format for dump register when error occurs,
this is useful to read debug log and reduce log length.

Signed-off-by: Micky Ching <micky_ching@xxxxxxxxxxxxxx>
---
drivers/memstick/host/rtsx_pci_ms.c | 37 ++++++++++++++++++++-----------------
1 file changed, 20 insertions(+), 17 deletions(-)

diff --git a/drivers/memstick/host/rtsx_pci_ms.c b/drivers/memstick/host/rtsx_pci_ms.c
index 818fa94..baf94db 100644
--- a/drivers/memstick/host/rtsx_pci_ms.c
+++ b/drivers/memstick/host/rtsx_pci_ms.c
@@ -54,26 +54,29 @@ static inline void ms_clear_error(struct realtek_pci_ms *host)
}

#ifdef DEBUG
+static void dump_reg_range(struct realtek_pci_ms *host, u16 start, u16 end)
+{
+ u16 len = end - start + 1;
+ int i;
+ u8 data[8];
+
+ for (i = 0; i < len; i += 8) {
+ int j;
+ int n = min(8, len - i);
+
+ memset(&data, 0, sizeof(data));
+ for (j = 0; j < n; j++)
+ rtsx_pci_read_register(host->pcr, start + i + j,
+ data + j);
+ dev_dbg(ms_dev(host), "0x%04X(%d): %8ph\n",
+ start + i, n, data);
+ }
+}

static void ms_print_debug_regs(struct realtek_pci_ms *host)
{
- struct rtsx_pcr *pcr = host->pcr;
- u16 i;
- u8 *ptr;
-
- /* Print MS host internal registers */
- rtsx_pci_init_cmd(pcr);
- for (i = 0xFD40; i <= 0xFD44; i++)
- rtsx_pci_add_cmd(pcr, READ_REG_CMD, i, 0, 0);
- for (i = 0xFD52; i <= 0xFD69; i++)
- rtsx_pci_add_cmd(pcr, READ_REG_CMD, i, 0, 0);
- rtsx_pci_send_cmd(pcr, 100);
-
- ptr = rtsx_pci_get_cmd_data(pcr);
- for (i = 0xFD40; i <= 0xFD44; i++)
- dev_dbg(ms_dev(host), "0x%04X: 0x%02x\n", i, *(ptr++));
- for (i = 0xFD52; i <= 0xFD69; i++)
- dev_dbg(ms_dev(host), "0x%04X: 0x%02x\n", i, *(ptr++));
+ dump_reg_range(host, 0xFD40, 0xFD44);
+ dump_reg_range(host, 0xFD52, 0xFD69);
}

#else
--
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/