Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp2884777ybh; Mon, 5 Aug 2019 08:21:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqx2wvRVJ4fc9IcXYFzjXQHwwUCLUWjM6lLKnwDvLaKREJdfJardmCFsDTdmZkBaECB+A/xl X-Received: by 2002:a17:902:b608:: with SMTP id b8mr147038595pls.303.1565018498123; Mon, 05 Aug 2019 08:21:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565018498; cv=none; d=google.com; s=arc-20160816; b=KfwiXC9KihyehlOj4K/jyOaZSCFKOTJpu18vT0cr7o8PO2SBXJfX66hcKIjh3NDE03 Rc5oqxgJ4a3SS7QAt4HqxeZK459AruVHtOQYjii68OJVxFLBc2STFjKW9ONrfsV/PG4p MO8G3aqjh33gZ8ahknBXRdRZ+OoTEqCv98mPhIuWclTALs40ibcXC+cxkJbcr9ndiAsk vHrLqiVYVpj7LnB68gFj//vMUSSS/d4C+2pMWJ8AhpBIYCIZpXvvmVRexKl4r6w4DxGw s01wx4xt/5CUiA7iBjjraMwVv3K+oz7M6ues2O0BA/ofzPg2c+bNkt46XmfmLzYdVUPs jKPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=Du8ky0RCU1v7ePAmMvVgA3KygFlO9GwPt9oTMtKjPLU=; b=eJ+FGa57feU8FHa4yjfdyfHRLhCiQLlgKXNZgcUOvKamkp7DY462VhK/m31bTLwyPw PHX0L5cTSinG9r5BR7a/U9LYDdpXJq7AeZJpoTZbaYfHNk2SQWQ8sl7jrzwCww3lc2UH eqMimV5cJGyjbCG3pI9No+uq9kOsLoWtbycXTzSrAmdEnFsacxCFI6iaXxpSTXhMx171 cwzwwsq6ZNGBFBDgh7IIoMp86a8TyseCaQu0x/v2+lBuX/euYZCdSYjML3qBfYf6vIJ/ LjLi6F6u7FCT+RW6+QDZThQvYrOsqVOvXnfluElRhCtLgqeV2SoCBAhwkYpjF6dFSnuS o4HQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 14si45186723pgy.255.2019.08.05.08.21.22; Mon, 05 Aug 2019 08:21:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729700AbfHEPUj (ORCPT + 99 others); Mon, 5 Aug 2019 11:20:39 -0400 Received: from mga14.intel.com ([192.55.52.115]:36565 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728468AbfHEPUj (ORCPT ); Mon, 5 Aug 2019 11:20:39 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Aug 2019 08:20:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,350,1559545200"; d="scan'208";a="164679880" Received: from nupurjai-mobl.amr.corp.intel.com (HELO [10.251.149.179]) ([10.251.149.179]) by orsmga007.jf.intel.com with ESMTP; 05 Aug 2019 08:20:25 -0700 Subject: Re: [alsa-devel] [RFC PATCH 02/40] soundwire: cadence_master: add debugfs register dump To: Sanyog Kale Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, tiwai@suse.de, broonie@kernel.org, vkoul@kernel.org, gregkh@linuxfoundation.org, jank@cadence.com, srinivas.kandagatla@linaro.org, slawomir.blauciak@intel.com References: <20190725234032.21152-1-pierre-louis.bossart@linux.intel.com> <20190725234032.21152-3-pierre-louis.bossart@linux.intel.com> <20190805075509.GA22437@buildpc-HP-Z230> From: Pierre-Louis Bossart Message-ID: <37002145-b8dc-ac30-d857-00b277ef4bac@linux.intel.com> Date: Mon, 5 Aug 2019 10:20:25 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190805075509.GA22437@buildpc-HP-Z230> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org >> +static ssize_t cdns_reg_read(struct file *file, char __user *user_buf, >> + size_t count, loff_t *ppos) >> +{ >> + struct sdw_cdns *cdns = file->private_data; >> + char *buf; >> + ssize_t ret; >> + int i, j; >> + >> + buf = kzalloc(RD_BUF, GFP_KERNEL); >> + if (!buf) >> + return -ENOMEM; >> + >> + ret = scnprintf(buf, RD_BUF, "Register Value\n"); >> + ret += scnprintf(buf + ret, RD_BUF - ret, "\nMCP Registers\n"); >> + for (i = 0; i < 8; i++) /* 8 MCP registers */ >> + ret += cdns_sprintf(cdns, buf, ret, i * 4); >> + >> + ret += scnprintf(buf + ret, RD_BUF - ret, >> + "\nStatus & Intr Registers\n"); >> + for (i = 0; i < 13; i++) /* 13 Status & Intr registers */ >> + ret += cdns_sprintf(cdns, buf, ret, CDNS_MCP_STAT + i * 4); >> + >> + ret += scnprintf(buf + ret, RD_BUF - ret, >> + "\nSSP & Clk ctrl Registers\n"); >> + ret += cdns_sprintf(cdns, buf, ret, CDNS_MCP_SSP_CTRL0); >> + ret += cdns_sprintf(cdns, buf, ret, CDNS_MCP_SSP_CTRL1); >> + ret += cdns_sprintf(cdns, buf, ret, CDNS_MCP_CLK_CTRL0); >> + ret += cdns_sprintf(cdns, buf, ret, CDNS_MCP_CLK_CTRL1); >> + >> + ret += scnprintf(buf + ret, RD_BUF - ret, >> + "\nDPn B0 Registers\n"); >> + for (i = 0; i < 7; i++) { >> + ret += scnprintf(buf + ret, RD_BUF - ret, >> + "\nDP-%d\n", i); >> + for (j = 0; j < 6; j++) >> + ret += cdns_sprintf(cdns, buf, ret, >> + CDNS_DPN_B0_CONFIG(i) + j * 4); >> + } >> + >> + ret += scnprintf(buf + ret, RD_BUF - ret, >> + "\nDPn B1 Registers\n"); >> + for (i = 0; i < 7; i++) { >> + ret += scnprintf(buf + ret, RD_BUF - ret, >> + "\nDP-%d\n", i); >> + >> + for (j = 0; j < 6; j++) >> + ret += cdns_sprintf(cdns, buf, ret, >> + CDNS_DPN_B1_CONFIG(i) + j * 4); >> + } >> + >> + ret += scnprintf(buf + ret, RD_BUF - ret, >> + "\nDPn Control Registers\n"); >> + for (i = 0; i < 7; i++) >> + ret += cdns_sprintf(cdns, buf, ret, >> + CDNS_PORTCTRL + i * CDNS_PORT_OFFSET); >> + >> + ret += scnprintf(buf + ret, RD_BUF - ret, >> + "\nPDIn Config Registers\n"); >> + for (i = 0; i < 7; i++) > > please use macros for all the hardcodings. yes, I completely changed that part in the upcoming update by using register start/stop for all loops, it makes the code more consistent and easier to change (SoundWire 1.2 registers will need to be added)