mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: z <zhaojunkui2008@126.com>
To: "Kalle Valo" <kvalo@kernel.org>
Cc: "Jakub Kicinski" <kubakici@wp.pl>,
	"David S. Miller" <davem@davemloft.net>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"Matthias Brugger" <matthias.bgg@gmail.com>,
	linux-wireless@vger.kernel.org, netdev@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org,
	bernard@vivo.com
Subject: Re:Re: [PATCH] mediatek/mt7601u: add debugfs exit function
Date: Fri, 22 Apr 2022 15:58:26 +0800 (CST)	[thread overview]
Message-ID: <6fd91edd.4c2b.1805047850c.Coremail.zhaojunkui2008@126.com> (raw)
In-Reply-To: <87k0bhmuh6.fsf@kernel.org>

HI Kalle Valo:

At 2022-04-22 15:45:57, "Kalle Valo" <kvalo@kernel.org> wrote:
>Bernard Zhao <zhaojunkui2008@126.com> writes:
>
>> When mt7601u loaded, there are two cases:
>> First when mt7601u is loaded, in function mt7601u_probe, if
>> function mt7601u_probe run into error lable err_hw,
>> mt7601u_cleanup didn`t cleanup the debugfs node.
>> Second when the module disconnect, in function mt7601u_disconnect,
>> mt7601u_cleanup didn`t cleanup the debugfs node.
>> This patch add debugfs exit function and try to cleanup debugfs
>> node when mt7601u loaded fail or unloaded.
>>
>> Signed-off-by: Bernard Zhao <zhaojunkui2008@126.com>
>> ---
>>  .../net/wireless/mediatek/mt7601u/debugfs.c   | 25 +++++++++++--------
>>  drivers/net/wireless/mediatek/mt7601u/init.c  |  5 ++++
>>  .../net/wireless/mediatek/mt7601u/mt7601u.h   |  4 +++
>>  3 files changed, 24 insertions(+), 10 deletions(-)
>>
>> diff --git a/drivers/net/wireless/mediatek/mt7601u/debugfs.c b/drivers/net/wireless/mediatek/mt7601u/debugfs.c
>> index 20669eacb66e..1ae3d75d3c9b 100644
>> --- a/drivers/net/wireless/mediatek/mt7601u/debugfs.c
>> +++ b/drivers/net/wireless/mediatek/mt7601u/debugfs.c
>> @@ -124,17 +124,22 @@ DEFINE_SHOW_ATTRIBUTE(mt7601u_eeprom_param);
>>  
>>  void mt7601u_init_debugfs(struct mt7601u_dev *dev)
>>  {
>> -	struct dentry *dir;
>> -
>> -	dir = debugfs_create_dir("mt7601u", dev->hw->wiphy->debugfsdir);
>> -	if (!dir)
>> +	dev->root_dir = debugfs_create_dir("mt7601u", dev->hw->wiphy->debugfsdir);
>> +	if (!dev->root_dir)
>>  		return;
>>  
>> -	debugfs_create_u8("temperature", 0400, dir, &dev->raw_temp);
>> -	debugfs_create_u32("temp_mode", 0400, dir, &dev->temp_mode);
>> +	debugfs_create_u8("temperature", 0400, dev->root_dir, &dev->raw_temp);
>> +	debugfs_create_u32("temp_mode", 0400, dev->root_dir, &dev->temp_mode);
>> +
>> +	debugfs_create_u32("regidx", 0600, dev->root_dir, &dev->debugfs_reg);
>> +	debugfs_create_file("regval", 0600, dev->root_dir, dev, &fops_regval);
>> +	debugfs_create_file("ampdu_stat", 0400, dev->root_dir, dev, &mt7601u_ampdu_stat_fops);
>> +	debugfs_create_file("eeprom_param", 0400, dev->root_dir, dev, &mt7601u_eeprom_param_fops);
>> +}
>>  
>> -	debugfs_create_u32("regidx", 0600, dir, &dev->debugfs_reg);
>> -	debugfs_create_file("regval", 0600, dir, dev, &fops_regval);
>> -	debugfs_create_file("ampdu_stat", 0400, dir, dev, &mt7601u_ampdu_stat_fops);
>> -	debugfs_create_file("eeprom_param", 0400, dir, dev, &mt7601u_eeprom_param_fops);
>> +void mt7601u_exit_debugfs(struct mt7601u_dev *dev)
>> +{
>> +	if (!dev->root_dir)
>> +		return;
>> +	debugfs_remove(dev->root_dir);
>
>debugfs_remove() has IS_ERR_OR_NULL() check, so no need to check for
>null here.
Got it, thanks!

>>  }
>> diff --git a/drivers/net/wireless/mediatek/mt7601u/init.c b/drivers/net/wireless/mediatek/mt7601u/init.c
>> index 5d9e952b2966..1e905ef2ed19 100644
>> --- a/drivers/net/wireless/mediatek/mt7601u/init.c
>> +++ b/drivers/net/wireless/mediatek/mt7601u/init.c
>> @@ -427,6 +427,9 @@ void mt7601u_cleanup(struct mt7601u_dev *dev)
>>  	mt7601u_stop_hardware(dev);
>>  	mt7601u_dma_cleanup(dev);
>>  	mt7601u_mcu_cmd_deinit(dev);
>> +#ifdef CONFIG_DEBUG_FS
>> +	mt7601u_exit_debugfs(dev);
>> +#endif
>>  }
>>  
>>  struct mt7601u_dev *mt7601u_alloc_device(struct device *pdev)
>> @@ -625,7 +628,9 @@ int mt7601u_register_device(struct mt7601u_dev *dev)
>>  	if (ret)
>>  		return ret;
>>  
>> +#ifdef CONFIG_DEBUG_FS
>>  	mt7601u_init_debugfs(dev);
>> +#endif
>
>Are these two ifdefs really needed? debugfs functions are empty
>functions when CONFIG_DEBUG_FS is disabled.
Ifdef doesn't seem to make much sense, thanks for your advice!

>> --- a/drivers/net/wireless/mediatek/mt7601u/mt7601u.h
>> +++ b/drivers/net/wireless/mediatek/mt7601u/mt7601u.h
>> @@ -242,6 +242,9 @@ struct mt7601u_dev {
>>  	u32 rf_pa_mode[2];
>>  
>>  	struct mac_stats stats;
>> +#ifdef CONFIG_DEBUG_FS
>> +	struct dentry *root_dir;
>> +#endif
>
>I would remove this ifdef, it's just saving one pointer size. Less
>ifdefs we have the better.
I would modify the code and resubmit a patch, thank you very much!

BR//Bernard
>-- 
>https://patchwork.kernel.org/project/linux-wireless/list/
>
>https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

  reply	other threads:[~2022-04-22  7:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-22  7:03 Bernard Zhao
2022-04-22  7:45 ` Kalle Valo
2022-04-22  7:58   ` z [this message]
2022-04-22 12:49   ` Jakub Kicinski

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=6fd91edd.4c2b.1805047850c.Coremail.zhaojunkui2008@126.com \
    --to=zhaojunkui2008@126.com \
    --cc=bernard@vivo.com \
    --cc=davem@davemloft.net \
    --cc=kubakici@wp.pl \
    --cc=kvalo@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=matthias.bgg@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®