From patchwork Thu Aug 4 14:55:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Birsan X-Patchwork-Id: 9263767 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C710A6048B for ; Thu, 4 Aug 2016 14:59:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B876328407 for ; Thu, 4 Aug 2016 14:59:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ACFCA2840D; Thu, 4 Aug 2016 14:59:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9460928407 for ; Thu, 4 Aug 2016 14:59:27 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bVK6D-000843-Pp; Thu, 04 Aug 2016 14:58:17 +0000 Received: from smtpout.microchip.com ([198.175.253.82] helo=email.microchip.com) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bVK5W-0007t7-8F for linux-arm-kernel@lists.infradead.org; Thu, 04 Aug 2016 14:57:35 +0000 Received: from cristi-lnx.microchip.com (10.10.76.4) by chn-sv-exch07.mchp-main.com (10.10.76.108) with Microsoft SMTP Server id 14.3.181.6; Thu, 4 Aug 2016 07:57:17 -0700 From: Cristian Birsan To: Subject: [PATCH 2/2] regmap: debugfs: Add support for dumping write only device registers Date: Thu, 4 Aug 2016 17:55:58 +0300 Message-ID: <1470322558-7501-3-git-send-email-cristian.birsan@microchip.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1470322558-7501-1-git-send-email-cristian.birsan@microchip.com> References: <1470322558-7501-1-git-send-email-cristian.birsan@microchip.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160804_075734_375278_8C300066 X-CRM114-Status: GOOD ( 11.96 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: boris.brezillon@free-electrons.com, nicolas.ferre@atmel.com, linux-kernel@vger.kernel.org, ludovic.desroches@atmel.com, alexandre.belloni@free-electrons.com, cristian.birsan@microchip.com, ce3a@gmx.de, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Add support for dumping write only device registers in debugfs. This is useful for audio codecs that have write only registers (like WM8731). The logic that decides if a value can be printed is moved to regmap_printable() function to allow for easier future updates. Signed-off-by: Cristian Birsan --- drivers/base/regmap/regmap-debugfs.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/drivers/base/regmap/regmap-debugfs.c b/drivers/base/regmap/regmap-debugfs.c index 3f0a7e2..8db10e9 100644 --- a/drivers/base/regmap/regmap-debugfs.c +++ b/drivers/base/regmap/regmap-debugfs.c @@ -77,6 +77,17 @@ static void regmap_debugfs_free_dump_cache(struct regmap *map) } } +static bool regmap_printable(struct regmap *map, unsigned int reg) +{ + if (regmap_precious(map, reg)) + return false; + + if (!regmap_readable(map, reg) && !regmap_cached(map, reg)) + return false; + + return true; +} + /* * Work out where the start offset maps into register numbers, bearing * in mind that we suppress hidden registers. @@ -105,8 +116,7 @@ static unsigned int regmap_debugfs_get_dump_start(struct regmap *map, if (list_empty(&map->debugfs_off_cache)) { for (; i <= map->max_register; i += map->reg_stride) { /* Skip unprinted registers, closing off cache entry */ - if (!regmap_readable(map, i) || - regmap_precious(map, i)) { + if (!regmap_printable(map, i)) { if (c) { c->max = p - 1; c->max_reg = i - map->reg_stride; @@ -204,7 +214,7 @@ static ssize_t regmap_read_debugfs(struct regmap *map, unsigned int from, start_reg = regmap_debugfs_get_dump_start(map, from, *ppos, &p); for (i = start_reg; i <= to; i += map->reg_stride) { - if (!regmap_readable(map, i)) + if (!regmap_readable(map, i) && !regmap_cached(map, i)) continue; if (regmap_precious(map, i)) @@ -222,7 +232,11 @@ static ssize_t regmap_read_debugfs(struct regmap *map, unsigned int from, buf_pos += map->debugfs_reg_len + 2; /* Format the value, write all X if we can't read */ - ret = regmap_read(map, i, &val); + if (regmap_readable(map, i)) + ret = regmap_read(map, i, &val); + else + ret = regcache_read(map, i, &val); + if (ret == 0) snprintf(buf + buf_pos, count - buf_pos, "%.*x", map->debugfs_val_len, val);