From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.9 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27693C04A6B for ; Mon, 6 May 2019 14:52:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F27A6205ED for ; Mon, 6 May 2019 14:52:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729494AbfEFOsi (ORCPT ); Mon, 6 May 2019 10:48:38 -0400 Received: from mga17.intel.com ([192.55.52.151]:60780 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729476AbfEFOsd (ORCPT ); Mon, 6 May 2019 10:48:33 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 May 2019 07:48:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,438,1549958400"; d="scan'208";a="343986368" Received: from linux.intel.com ([10.54.29.200]) by fmsmga005.fm.intel.com with ESMTP; 06 May 2019 07:48:32 -0700 Received: from slaugust-mobl.amr.corp.intel.com (unknown [10.254.21.102]) by linux.intel.com (Postfix) with ESMTP id 63339580238; Mon, 6 May 2019 07:48:31 -0700 (PDT) Subject: Re: [alsa-devel] [RFC PATCH 5/7] soundwire: add debugfs support To: Greg KH Cc: alsa-devel@alsa-project.org, tiwai@suse.de, linux-kernel@vger.kernel.org, liam.r.girdwood@linux.intel.com, vkoul@kernel.org, broonie@kernel.org, srinivas.kandagatla@linaro.org, jank@cadence.com, joe@perches.com, Sanyog Kale References: <20190504010030.29233-1-pierre-louis.bossart@linux.intel.com> <20190504010030.29233-6-pierre-louis.bossart@linux.intel.com> <20190504070301.GD9770@kroah.com> From: Pierre-Louis Bossart Message-ID: Date: Mon, 6 May 2019 09:48:30 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20190504070301.GD9770@kroah.com> 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 >> @@ -136,6 +139,8 @@ static int sdw_delete_slave(struct device *dev, void *data) >> void sdw_delete_bus_master(struct sdw_bus *bus) >> { >> sdw_sysfs_bus_exit(bus); >> + if (bus->debugfs) >> + sdw_bus_debugfs_exit(bus->debugfs); > > No need to check, just call it. That was on my todo list, will remove. >> +struct sdw_bus_debugfs { >> + struct sdw_bus *bus; > > Why do you need to save this pointer? > >> + struct dentry *fs; > > This really is all you need to have around, right? will check. >> +struct dentry *sdw_bus_debugfs_get_root(struct sdw_bus_debugfs *d) >> +{ >> + if (d) >> + return d->fs; >> + return NULL; >> +} >> +EXPORT_SYMBOL(sdw_bus_debugfs_get_root); > > _GPL()? Oops, that's a big miss. will fix, thanks for spotting this. > > But why is this exported at all? No one calls this function. I will have to check. > >> +struct sdw_slave_debugfs { >> + struct sdw_slave *slave; > > Same question as above, why do you need this pointer? will check. > > And meta-comment, if you _EVER_ save off a pointer to a reference > counted object (like this and the above one), you HAVE to grab a > reference to it, otherwise it can go away at any point in time as that > is the point of reference counted objects. > > So even if you do need/want this, you have to properly handle the > reference count by incrementing/decrementing it as needed. good comment, thank you for the guidance. >> +struct sdw_slave_debugfs *sdw_slave_debugfs_init(struct sdw_slave *slave) >> +{ >> + struct sdw_bus_debugfs *master; >> + struct sdw_slave_debugfs *d; >> + char name[32]; >> + >> + master = slave->bus->debugfs; >> + if (!master) >> + return NULL; >> + >> + d = kzalloc(sizeof(*d), GFP_KERNEL); >> + if (!d) >> + return NULL; >> + >> + /* create the debugfs slave-name */ >> + snprintf(name, sizeof(name), "%s", dev_name(&slave->dev)); >> + d->fs = debugfs_create_dir(name, master->fs); >> + if (IS_ERR_OR_NULL(d->fs)) { >> + dev_err(&slave->dev, "slave debugfs root creation failed\n"); >> + goto err; >> + } > > You never care about the return value of a debugfs call. I have a 100+ > patch series stripping all of this out of the kernel, please don't force > me to add another one to it :) > > Just call debugfs and move on, you can always put the return value of > one call into another one just fine, and your function logic should > never change if debugfs returns an error or not, you do not care. Yes, it's agreed that we should not depend on debugfs or fail here. will fix, no worries. > >> +void sdw_debugfs_init(void) >> +{ >> + sdw_debugfs_root = debugfs_create_dir("soundwire", NULL); >> + if (IS_ERR_OR_NULL(sdw_debugfs_root)) { >> + pr_warn("SoundWire: Failed to create debugfs directory\n"); >> + sdw_debugfs_root = NULL; >> + return; > > Same here, just call the function and return. yep, will do.