linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: <micky_ching@realsil.com.cn>
To: sameo@linux.intel.com, lee.jones@linaro.org, chris@printf.net,
	ulf.hansson@linaro.org
Cc: gregkh@linuxfoundation.org, linux-mmc@vger.kernel.org,
	linux-kernel@vger.kernel.org, wei_wang@realsil.com.cn,
	rogerable@realtek.com, devel@linuxdriverproject.org,
	dan.carpenter@oracle.com
Subject: [PATCH v4 2/6] mmc: rtsx: add dump_reg_range to simplify dump register
Date: Fri, 5 Dec 2014 13:54:27 +0800	[thread overview]
Message-ID: <dcd9add1d29623726bdde4819c7e5267966d2f4f.1417758564.git.micky_ching@realsil.com.cn> (raw)
In-Reply-To: <cover.1417758564.git.micky_ching@realsil.com.cn>

From: Micky Ching <micky_ching@realsil.com.cn>

Add a new function to dump register within a range.
We print 1 register a line before this patch,
this may make debug info too long when we add more register to dump.

The new dump_reg_range() dump to 8 register a line,
and it is easy to use.

Signed-off-by: Micky Ching <micky_ching@realsil.com.cn>
---
 drivers/mmc/host/rtsx_pci_sdmmc.c | 38 +++++++++++++++++++++-----------------
 1 file changed, 21 insertions(+), 17 deletions(-)

diff --git a/drivers/mmc/host/rtsx_pci_sdmmc.c b/drivers/mmc/host/rtsx_pci_sdmmc.c
index c70b602..b1390f0 100644
--- a/drivers/mmc/host/rtsx_pci_sdmmc.c
+++ b/drivers/mmc/host/rtsx_pci_sdmmc.c
@@ -71,25 +71,29 @@ static inline void sd_clear_error(struct realtek_pci_sdmmc *host)
 }
 
 #ifdef DEBUG
-static void sd_print_debug_regs(struct realtek_pci_sdmmc *host)
+static void dump_reg_range(struct realtek_pci_sdmmc *host, u16 start, u16 end)
 {
-	struct rtsx_pcr *pcr = host->pcr;
-	u16 i;
-	u8 *ptr;
+	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(sdmmc_dev(host), "0x%04X(%d): %8ph\n",
+			start + i, n, data);
+	}
+}
 
-	/* Print SD host internal registers */
-	rtsx_pci_init_cmd(pcr);
-	for (i = 0xFDA0; i <= 0xFDAE; 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 = 0xFDA0; i <= 0xFDAE; i++)
-		dev_dbg(sdmmc_dev(host), "0x%04X: 0x%02x\n", i, *(ptr++));
-	for (i = 0xFD52; i <= 0xFD69; i++)
-		dev_dbg(sdmmc_dev(host), "0x%04X: 0x%02x\n", i, *(ptr++));
+static void sd_print_debug_regs(struct realtek_pci_sdmmc *host)
+{
+	dump_reg_range(host, 0xFDA0, 0xFDB3);
+	dump_reg_range(host, 0xFD52, 0xFD69);
 }
 #else
 #define sd_print_debug_regs(host)
-- 
1.9.1

  parent reply	other threads:[~2014-12-05  5:54 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-05  5:54 [PATCH v4 0/6] mmc: rtsx: add support for sdio card micky_ching
2014-12-05  5:54 ` [PATCH v4 1/6] mfd: rtsx: add func to split u32 into register micky_ching
2014-12-05  9:27   ` 敬锐
2014-12-08  8:49   ` Lee Jones
2014-12-08  9:49     ` 敬锐
2014-12-08  9:57       ` Lee Jones
2014-12-08  9:59         ` 敬锐
2014-12-08  9:57   ` Lee Jones
2014-12-08 10:21     ` Ulf Hansson
2014-12-08 13:01       ` Lee Jones
2014-12-05  5:54 ` micky_ching [this message]
2014-12-05  5:54 ` [PATCH v4 3/6] mmc: rtsx: init cookie at probe/card_event micky_ching
2014-12-05  5:54 ` [PATCH v4 4/6] mmc: rtsx: add helper function to simplify code micky_ching
2014-12-05  5:54 ` [PATCH v4 5/6] mmc: rtsx: add support for sdio card micky_ching
2014-12-05  5:54 ` [PATCH v4 6/6] mmc: rtsx: swap function position to avoid pre declaration micky_ching
2014-12-19 10:36 ` [PATCH v4 0/6] mmc: rtsx: add support for sdio card Ulf Hansson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=dcd9add1d29623726bdde4819c7e5267966d2f4f.1417758564.git.micky_ching@realsil.com.cn \
    --to=micky_ching@realsil.com.cn \
    --cc=chris@printf.net \
    --cc=dan.carpenter@oracle.com \
    --cc=devel@linuxdriverproject.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=lee.jones@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=rogerable@realtek.com \
    --cc=sameo@linux.intel.com \
    --cc=ulf.hansson@linaro.org \
    --cc=wei_wang@realsil.com.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).