Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp267170ybi; Fri, 26 Jul 2019 09:21:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqwzLjcEEj/UTCQpyGEOrmtRfeTnQddio8n+l6Kd0EbrAuurkAOB/7u1FZRwCRCapoLdi3f4 X-Received: by 2002:a65:500a:: with SMTP id f10mr61314706pgo.105.1564158117208; Fri, 26 Jul 2019 09:21:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564158117; cv=none; d=google.com; s=arc-20160816; b=aaJxMoq81omAcf+uoREeIiZjEuZGhIcQx9Ti4GS2mOirHyTBnP6hGd+3ydsdm+tI/j Df3pw1Vy+m2OzyWJSxax4pQD7RSrhrRUptvUZES8UQtVlC9/Q9MF0Dis+Ef01b7DzUAv FJQ3mxTmdyJVGF7N63Q4LPSPvrKvPaV2QBqI0emPe4PzvaAqtQNdHYHytftR/2wviPzz 2Lfrf8vu6c0ecda676MXTxY219f6vKSQ7hO+pnHiNTiypT0Wvh9iS4yN4Pa3J9Asri/1 S/KW9/ev6bFNzN9pmq611dNVrSz4KqIiqNwE8E9jYJa4+OkYgrKQ58u7lZeFoemA/F9X /LMg== 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=hW8kZ3vNtUIAbgtOQ1tlqCQ7Q1zScIqmqgevxfgXQOQ=; b=KHolHvpM9cUr01+liFVB9pZxbRSoGiHpkG4+50LU4ZNr6KE4mDAnH8ZYOeO4i5JYUZ nYwF9+vhs2e5Z8BfH7nMJpo7k5WmIlQMN2QrqL83r6sYhwC3zu5UAynOZXBOf/oUkCvq o/Io03bOUCU/IN9aXqsRsF3jajGVIQVJ0yMlYHih4ONmcdE1x6vMlGrA8tTL/pDR2vJL wuelabYLNgVejcNg2ptS/wFOZn9Qxw+m6nNF1VromhRxBhpeNOdx7AdeVD+uodrk36VG OVEmcJMWgWFj7jHhIERJIbyzGMt/q2fVMnAb0PlnM5bUPj9lFo8BiOeNm1TE5inPEWx9 KVJQ== 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 d1si5593739pgn.512.2019.07.26.09.21.42; Fri, 26 Jul 2019 09:21:57 -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 S2388241AbfGZNnd (ORCPT + 99 others); Fri, 26 Jul 2019 09:43:33 -0400 Received: from mga14.intel.com ([192.55.52.115]:61886 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388209AbfGZNn2 (ORCPT ); Fri, 26 Jul 2019 09:43:28 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Jul 2019 06:43:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,311,1559545200"; d="scan'208";a="322042154" Received: from msmall-mobl.amr.corp.intel.com (HELO [10.251.154.62]) ([10.251.154.62]) by orsmga004.jf.intel.com with ESMTP; 26 Jul 2019 06:43:26 -0700 Subject: Re: [alsa-devel] [RFC PATCH 01/40] soundwire: add debugfs support To: Guennadi Liakhovetski Cc: alsa-devel@alsa-project.org, tiwai@suse.de, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, vkoul@kernel.org, broonie@kernel.org, srinivas.kandagatla@linaro.org, jank@cadence.com, slawomir.blauciak@intel.com, Sanyog Kale References: <20190725234032.21152-1-pierre-louis.bossart@linux.intel.com> <20190725234032.21152-2-pierre-louis.bossart@linux.intel.com> <20190725221554.GA16003@ubuntu> From: Pierre-Louis Bossart Message-ID: <3a45625f-72a8-cb0c-1467-460000d1d8f7@linux.intel.com> Date: Fri, 26 Jul 2019 08:43:26 -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: <20190725221554.GA16003@ubuntu> 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 On 7/25/19 5:15 PM, Guennadi Liakhovetski wrote: > Hi Pierre, > > A couple of nitpicks: Thanks for the feedback! >> create mode 100644 drivers/soundwire/debugfs.c > > [snip] > >> diff --git a/drivers/soundwire/bus.h b/drivers/soundwire/bus.h >> index 3048ca153f22..06ac4adb0074 100644 >> --- a/drivers/soundwire/bus.h >> +++ b/drivers/soundwire/bus.h >> @@ -18,6 +18,30 @@ static inline int sdw_acpi_find_slaves(struct sdw_bus *bus) >> void sdw_extract_slave_id(struct sdw_bus *bus, >> u64 addr, struct sdw_slave_id *id); >> >> +#ifdef CONFIG_DEBUG_FS >> +struct dentry *sdw_bus_debugfs_init(struct sdw_bus *bus); >> +void sdw_bus_debugfs_exit(struct dentry *d); >> +struct dentry *sdw_slave_debugfs_init(struct sdw_slave *slave); >> +void sdw_slave_debugfs_exit(struct dentry *d); >> +void sdw_debugfs_init(void); >> +void sdw_debugfs_exit(void); >> +#else >> +struct dentry *sdw_bus_debugfs_init(struct sdw_bus *bus) >> +{ return NULL; } > > static? > >> + >> +void sdw_bus_debugfs_exit(struct dentry *d) {} >> + >> +struct dentry *sdw_slave_debugfs_init(struct sdw_slave *slave) >> +{ return NULL; } >> + >> +void sdw_slave_debugfs_exit(struct dentry *d) {} >> + >> +void sdw_debugfs_init(void) {} >> + >> +void sdw_debugfs_exit(void) {} > > Same for all the above. You could also declare them inline, but I really hope > the compiler will be smart enough to do that itself. yes, I'll add static inline for all this. >> +struct dentry *sdw_bus_debugfs_init(struct sdw_bus *bus) >> +{ >> + struct dentry *d; > > I would remove the above > >> + char name[16]; >> + >> + if (!sdw_debugfs_root) >> + return NULL; >> + >> + /* create the debugfs master-N */ >> + snprintf(name, sizeof(name), "master-%d", bus->link_id); >> + d = debugfs_create_dir(name, sdw_debugfs_root); >> + >> + return d; > > And just do > > + return debugfs_create_dir(name, sdw_debugfs_root); yep, will do. >> +static ssize_t sdw_sprintf(struct sdw_slave *slave, >> + char *buf, size_t pos, unsigned int reg) >> +{ >> + int value; >> + >> + value = sdw_read(slave, reg); > > I personally would join the two lines above, but that's just a personal > preference. I prefer splitting variables and code, I just can't mentally split the two. > >> + >> + if (value < 0) >> + return scnprintf(buf + pos, RD_BUF - pos, "%3x\tXX\n", reg); >> + else > > I think it's advised to not use an else in such cases. > > Thanks > Guennadi > >> + return scnprintf(buf + pos, RD_BUF - pos, >> + "%3x\t%2x\n", reg, value); >> +} The intent was to provide a visual cue that the register is not implemented, which is quite useful. Not all registers are mandatory and not all vendors document the entire set of registers, so it's a good way to figure things out. The value is not used for any functional purpose, it's just a register dump for the integrator to look at. I'll add a note to explain the idea.