lkml.org 
[lkml]   [2019]   [Aug]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [alsa-devel] [RFC PATCH 02/40] soundwire: cadence_master: add debugfs register dump
From
Date

>> +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)

\
 
 \ /
  Last update: 2019-08-05 17:21    [W:0.166 / U:6.828 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site