Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp126710ybi; Fri, 26 Jul 2019 07:10:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqxyLdf1xzq6ggLwad/F9bs7R89iq0eqKO1oN5zQfyYkHm8KADV3P5b0B47yKGlOtrg+quij X-Received: by 2002:a65:528d:: with SMTP id y13mr2444949pgp.120.1564150240077; Fri, 26 Jul 2019 07:10:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564150240; cv=none; d=google.com; s=arc-20160816; b=ApaV6xr9QAeiHiXNrFcStD6Alx5hzD9JbWT0CA+Ky6otUHdShfWxwfRuf3faQrVpwN xyUXUyyq0kJHP+E0VQNCcAkZIgkBpgiJXnlMqIbEPO+eB3mPh3hJkmyRxlWECK5fDjAn UzosvYEvYnSoN+eYq4E3xmiKoe3zYc0wOK2m5BYSdGm+hgiUUdIXwv+y3B1MTu8+fIfH bFBCX8CkwiCN3KD5+D09IGWS7ZrBjOTm5YhFb39Zu3FN6mWNseji7a79NLs8Xs+t9JDx VaLGz44LZV5RsAdx4GabKYAT3Fpphay3J31AQJpLGU5aQS4v9oaBA6ECM+0isUmkrEhC zrIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=VSOTbLmhwAOtHbPbaewi2hjEXmmRU4csAWxuNFxvdZE=; b=vqYuDP9FSKdXmCwIXLmwKLB16ZGteUF6Fsz4H6RBt26jb09CDtpZGREGk4yEBRBh0e 6cKNfTdhKTqJ0LVvUC2K5PDys/6IeXd7e8kcGsXXPyGMhR2fCbfTaU9474vg07SbaRSp +xJRLW0GicWOsJmkxHraUVfWYtQ7unqVXNK4U3W5+u0Vh15rMlCTL2Dh8vLHQlUaiCk+ zMXa6RWVq6dndxfIGP3GzwCrdN1XKuyhTM/MeFVjJgecgDtVI+/fv77ksO+ZFAko6vJf 8Sdf46E96IOcpwKXUTjTnM0PYCxVrhJUFsF10jJKsqdHf9v6V5ZkoVLWlnBeaNKLXsKL ju0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pTDmpDVZ; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y2si18755822pgg.533.2019.07.26.07.10.24; Fri, 26 Jul 2019 07:10:40 -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; dkim=pass header.i=@kernel.org header.s=default header.b=pTDmpDVZ; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727421AbfGZOJ0 (ORCPT + 99 others); Fri, 26 Jul 2019 10:09:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:44880 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726902AbfGZOJ0 (ORCPT ); Fri, 26 Jul 2019 10:09:26 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 334BC21850; Fri, 26 Jul 2019 14:09:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564150165; bh=0+3MSmx+qJhUrDrjQL6BneIaHl/nbDAanbN39/Pki5w=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=pTDmpDVZkpnP1M/pyDjd5YbEUz82p1pljhgmYCuRRg0pXN6eqBfxmtJ5D//H/a3vm /toBXPT3R52QT00OmObrGaywEZ2Sf3jkQ3lKaHT+tg/ipbzm7rT+SL939qss4PgGhO MkIrvgu7uG9rqR1DZA2GjDhW5QOJCsUD5lOZSOfQ= Date: Fri, 26 Jul 2019 16:09:22 +0200 From: Greg KH To: Pierre-Louis Bossart Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, tiwai@suse.de, broonie@kernel.org, vkoul@kernel.org, jank@cadence.com, srinivas.kandagatla@linaro.org, slawomir.blauciak@intel.com, Sanyog Kale Subject: Re: [RFC PATCH 02/40] soundwire: cadence_master: add debugfs register dump Message-ID: <20190726140922.GD8767@kroah.com> References: <20190725234032.21152-1-pierre-louis.bossart@linux.intel.com> <20190725234032.21152-3-pierre-louis.bossart@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190725234032.21152-3-pierre-louis.bossart@linux.intel.com> User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 25, 2019 at 06:39:54PM -0500, Pierre-Louis Bossart wrote: > Add debugfs file to dump the Cadence master registers > > Credits: this patch is based on an earlier internal contribution by > Vinod Koul, Sanyog Kale, Shreyas Nc and Hardik Shah. The main change > is the use of scnprintf to avoid known issues with snprintf. > > Signed-off-by: Pierre-Louis Bossart > --- > drivers/soundwire/cadence_master.c | 98 ++++++++++++++++++++++++++++++ > drivers/soundwire/cadence_master.h | 2 + > 2 files changed, 100 insertions(+) > > diff --git a/drivers/soundwire/cadence_master.c b/drivers/soundwire/cadence_master.c > index ff4badc9b3de..91e8bacb83e3 100644 > --- a/drivers/soundwire/cadence_master.c > +++ b/drivers/soundwire/cadence_master.c > @@ -8,6 +8,7 @@ > > #include > #include > +#include > #include > #include > #include > @@ -223,6 +224,103 @@ static int cdns_clear_bit(struct sdw_cdns *cdns, int offset, u32 value) > return -EAGAIN; > } > > +/* > + * debugfs > + */ > + > +#define RD_BUF (2 * PAGE_SIZE) > + > +static ssize_t cdns_sprintf(struct sdw_cdns *cdns, > + char *buf, size_t pos, unsigned int reg) > +{ > + return scnprintf(buf + pos, RD_BUF - pos, > + "%4x\t%4x\n", reg, cdns_readl(cdns, reg)); > +} > + > +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++) > + ret += cdns_sprintf(cdns, buf, ret, CDNS_PDI_CONFIG(i)); > + > + ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret); > + kfree(buf); > + > + return ret; > +} > + > +static const struct file_operations cdns_reg_fops = { > + .open = simple_open, > + .read = cdns_reg_read, > + .llseek = default_llseek, > +}; DEFINE_SHOW_ATTRIBUTE()? thanks, greg k-h