LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: Greg KH <gregkh@linuxfoundation.org>
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 <sanyog.r.kale@intel.com>
Subject: Re: [alsa-devel] [RFC PATCH 5/7] soundwire: add debugfs support
Date: Mon, 6 May 2019 09:48:30 -0500	[thread overview]
Message-ID: <a9e1c3d2-fe29-1683-9253-b66034c62010@linux.intel.com> (raw)
In-Reply-To: <20190504070301.GD9770@kroah.com>


>> @@ -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.

  reply	other threads:[~2019-05-06 14:52 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-04  1:00 [RFC PATCH 0/7] soundwire: add sysfs and " Pierre-Louis Bossart
2019-05-04  1:00 ` [RFC PATCH 1/7] soundwire: Add sysfs support for master(s) Pierre-Louis Bossart
2019-05-04  6:52   ` Greg KH
2019-05-06 16:43     ` [alsa-devel] " Pierre-Louis Bossart
2019-05-07  2:24     ` Pierre-Louis Bossart
2019-05-07  5:27       ` Vinod Koul
2019-05-07  5:54         ` Greg KH
2019-05-07 11:03           ` Vinod Koul
2019-05-07 11:19             ` Greg KH
2019-05-07 22:49               ` Pierre-Louis Bossart
2019-05-08  7:46                 ` Vinod Koul
2019-05-08  9:16                   ` Greg KH
2019-05-08 16:42                     ` Pierre-Louis Bossart
2019-05-08 16:59                       ` Greg KH
     [not found]                         ` <0b8d5238-6894-e2b4-5522-28636e40dd63@linux.intel.com>
2019-05-09  4:26                           ` Vinod Koul
2019-05-09 18:18                           ` Greg KH
2019-05-04  1:00 ` [RFC PATCH 2/7] soundwire: add Slave sysfs support Pierre-Louis Bossart
2019-05-04  6:54   ` Greg KH
2019-05-06 14:42     ` [alsa-devel] " Pierre-Louis Bossart
2019-05-06 15:19       ` Greg KH
2019-05-06 16:22         ` Vinod Koul
2019-05-06 16:46           ` Pierre-Louis Bossart
2019-05-07  5:19             ` Vinod Koul
2019-05-07 13:54               ` Pierre-Louis Bossart
2019-05-08  7:40                 ` Vinod Koul
2019-05-08 16:51                   ` Pierre-Louis Bossart
2019-05-04  1:00 ` [RFC PATCH 3/7] ABI: testing: Add description of soundwire master sysfs files Pierre-Louis Bossart
2019-05-04  6:53   ` Greg KH
2019-05-06 16:24   ` Vinod Koul
2019-05-04  1:00 ` [RFC PATCH 4/7] ABI: testing: Add description of soundwire slave " Pierre-Louis Bossart
2019-05-04  1:00 ` [RFC PATCH 5/7] soundwire: add debugfs support Pierre-Louis Bossart
2019-05-04  7:03   ` Greg KH
2019-05-06 14:48     ` Pierre-Louis Bossart [this message]
2019-05-06 16:38       ` [alsa-devel] " Vinod Koul
2019-05-06 16:54         ` Pierre-Louis Bossart
2019-05-07  5:56         ` Greg KH
2019-05-04  1:00 ` [RFC PATCH 6/7] soundwire: cadence_master: add debugfs register dump Pierre-Louis Bossart
2019-05-04  7:03   ` Greg KH
2019-05-06 14:50     ` [alsa-devel] " Pierre-Louis Bossart
2019-05-04  7:04   ` Greg KH
2019-05-04  1:00 ` [RFC PATCH 7/7] soundwire: intel: " Pierre-Louis Bossart
2019-05-04  7:04   ` Greg KH
2019-05-06 14:51     ` [alsa-devel] " Pierre-Louis Bossart

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a9e1c3d2-fe29-1683-9253-b66034c62010@linux.intel.com \
    --to=pierre-louis.bossart@linux.intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jank@cadence.com \
    --cc=joe@perches.com \
    --cc=liam.r.girdwood@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sanyog.r.kale@intel.com \
    --cc=srinivas.kandagatla@linaro.org \
    --cc=tiwai@suse.de \
    --cc=vkoul@kernel.org \
    --subject='Re: [alsa-devel] [RFC PATCH 5/7] soundwire: add debugfs support' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).