linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] brcm80211: no need to check return value of debugfs_create functions
@ 2019-01-22 15:21 Greg Kroah-Hartman
  2019-01-22 20:07 ` Arend Van Spriel
  2019-02-01 12:38 ` [PATCH] brcmsmac: " Kalle Valo
  0 siblings, 2 replies; 5+ messages in thread
From: Greg Kroah-Hartman @ 2019-01-22 15:21 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, Arend van Spriel, Franky Lin, Hante Meuleman,
	Chi-Hsien Lin, Wright Feng, Kalle Valo, linux-wireless,
	brcm80211-dev-list.pdl, brcm80211-dev-list

When calling debugfs functions, there is no need to ever check the
return value.  The function can work or not, but the code logic should
never do something different based on this.

Cc: Arend van Spriel <arend.vanspriel@broadcom.com>
Cc: Franky Lin <franky.lin@broadcom.com>
Cc: Hante Meuleman <hante.meuleman@broadcom.com>
Cc: Chi-Hsien Lin <chi-hsien.lin@cypress.com>
Cc: Wright Feng <wright.feng@cypress.com>
Cc: Kalle Valo <kvalo@codeaurora.org>
Cc: linux-wireless@vger.kernel.org
Cc: brcm80211-dev-list.pdl@broadcom.com
Cc: brcm80211-dev-list@cypress.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 .../broadcom/brcm80211/brcmsmac/debug.c       | 26 +++----------------
 .../broadcom/brcm80211/brcmsmac/debug.h       |  2 +-
 2 files changed, 5 insertions(+), 23 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/debug.c b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/debug.c
index 3bd54f125776..6d776ef6ff54 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/debug.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/debug.c
@@ -37,27 +37,18 @@ static struct dentry *root_folder;
 void brcms_debugfs_init(void)
 {
 	root_folder = debugfs_create_dir(KBUILD_MODNAME, NULL);
-	if (IS_ERR(root_folder))
-		root_folder = NULL;
 }
 
 void brcms_debugfs_exit(void)
 {
-	if (!root_folder)
-		return;
-
 	debugfs_remove_recursive(root_folder);
 	root_folder = NULL;
 }
 
-int brcms_debugfs_attach(struct brcms_pub *drvr)
+void brcms_debugfs_attach(struct brcms_pub *drvr)
 {
-	if (!root_folder)
-		return -ENODEV;
-
 	drvr->dbgfs_dir = debugfs_create_dir(
 		 dev_name(&drvr->wlc->hw->d11core->dev), root_folder);
-	return PTR_ERR_OR_ZERO(drvr->dbgfs_dir);
 }
 
 void brcms_debugfs_detach(struct brcms_pub *drvr)
@@ -195,7 +186,7 @@ static const struct file_operations brcms_debugfs_def_ops = {
 	.llseek = seq_lseek
 };
 
-static int
+static void
 brcms_debugfs_add_entry(struct brcms_pub *drvr, const char *fn,
 			int (*read_fn)(struct seq_file *seq, void *data))
 {
@@ -203,27 +194,18 @@ brcms_debugfs_add_entry(struct brcms_pub *drvr, const char *fn,
 	struct dentry *dentry =  drvr->dbgfs_dir;
 	struct brcms_debugfs_entry *entry;
 
-	if (IS_ERR_OR_NULL(dentry))
-		return -ENOENT;
-
 	entry = devm_kzalloc(dev, sizeof(*entry), GFP_KERNEL);
 	if (!entry)
-		return -ENOMEM;
+		return;
 
 	entry->read = read_fn;
 	entry->drvr = drvr;
 
-	dentry = debugfs_create_file(fn, 0444, dentry, entry,
-				     &brcms_debugfs_def_ops);
-
-	return PTR_ERR_OR_ZERO(dentry);
+	debugfs_create_file(fn, 0444, dentry, entry, &brcms_debugfs_def_ops);
 }
 
 void brcms_debugfs_create_files(struct brcms_pub *drvr)
 {
-	if (IS_ERR_OR_NULL(drvr->dbgfs_dir))
-		return;
-
 	brcms_debugfs_add_entry(drvr, "hardware", brcms_debugfs_hardware_read);
 	brcms_debugfs_add_entry(drvr, "macstat", brcms_debugfs_macstat_read);
 }
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/debug.h b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/debug.h
index 822781cf15d4..56898e6d789d 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/debug.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/debug.h
@@ -68,7 +68,7 @@ void __brcms_dbg(struct device *dev, u32 level, const char *func,
 struct brcms_pub;
 void brcms_debugfs_init(void);
 void brcms_debugfs_exit(void);
-int brcms_debugfs_attach(struct brcms_pub *drvr);
+void brcms_debugfs_attach(struct brcms_pub *drvr);
 void brcms_debugfs_detach(struct brcms_pub *drvr);
 struct dentry *brcms_debugfs_get_devdir(struct brcms_pub *drvr);
 void brcms_debugfs_create_files(struct brcms_pub *drvr);
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] brcm80211: no need to check return value of debugfs_create functions
  2019-01-22 15:21 [PATCH] brcm80211: no need to check return value of debugfs_create functions Greg Kroah-Hartman
@ 2019-01-22 20:07 ` Arend Van Spriel
  2019-01-22 20:43   ` Greg Kroah-Hartman
  2019-01-23  5:11   ` Kalle Valo
  2019-02-01 12:38 ` [PATCH] brcmsmac: " Kalle Valo
  1 sibling, 2 replies; 5+ messages in thread
From: Arend Van Spriel @ 2019-01-22 20:07 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel
  Cc: Franky Lin, Hante Meuleman, Chi-Hsien Lin, Wright Feng,
	Kalle Valo, linux-wireless, brcm80211-dev-list.pdl,
	brcm80211-dev-list

The prefix should be 'brcmsmac'.

On 1/22/2019 4:21 PM, Greg Kroah-Hartman wrote:
> When calling debugfs functions, there is no need to ever check the
> return value.  The function can work or not, but the code logic should
> never do something different based on this.

I could argue that if above is true it would be better to make the 
debugfs function return void, but I won't ;-p

In start_creating() the parent dentry is indeed checked for IS_ERR() so...

Acked-by: Arend van Spriel

> Cc: Arend van Spriel <arend.vanspriel@broadcom.com>
> Cc: Franky Lin <franky.lin@broadcom.com>
> Cc: Hante Meuleman <hante.meuleman@broadcom.com>
> Cc: Chi-Hsien Lin <chi-hsien.lin@cypress.com>
> Cc: Wright Feng <wright.feng@cypress.com>
> Cc: Kalle Valo <kvalo@codeaurora.org>
> Cc: linux-wireless@vger.kernel.org
> Cc: brcm80211-dev-list.pdl@broadcom.com
> Cc: brcm80211-dev-list@cypress.com
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
>   .../broadcom/brcm80211/brcmsmac/debug.c       | 26 +++----------------
>   .../broadcom/brcm80211/brcmsmac/debug.h       |  2 +-
>   2 files changed, 5 insertions(+), 23 deletions(-)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] brcm80211: no need to check return value of debugfs_create functions
  2019-01-22 20:07 ` Arend Van Spriel
@ 2019-01-22 20:43   ` Greg Kroah-Hartman
  2019-01-23  5:11   ` Kalle Valo
  1 sibling, 0 replies; 5+ messages in thread
From: Greg Kroah-Hartman @ 2019-01-22 20:43 UTC (permalink / raw)
  To: Arend Van Spriel
  Cc: linux-kernel, Franky Lin, Hante Meuleman, Chi-Hsien Lin,
	Wright Feng, Kalle Valo, linux-wireless, brcm80211-dev-list.pdl,
	brcm80211-dev-list

On Tue, Jan 22, 2019 at 09:07:48PM +0100, Arend Van Spriel wrote:
> The prefix should be 'brcmsmac'.
> 
> On 1/22/2019 4:21 PM, Greg Kroah-Hartman wrote:
> > When calling debugfs functions, there is no need to ever check the
> > return value.  The function can work or not, but the code logic should
> > never do something different based on this.
> 
> I could argue that if above is true it would be better to make the debugfs
> function return void, but I won't ;-p

I would really want to do that, but sometimes you need that return value
to pass to other debugfs functions :(

> In start_creating() the parent dentry is indeed checked for IS_ERR() so...
> 
> Acked-by: Arend van Spriel

thanks for the review!

greg k-h

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] brcm80211: no need to check return value of debugfs_create functions
  2019-01-22 20:07 ` Arend Van Spriel
  2019-01-22 20:43   ` Greg Kroah-Hartman
@ 2019-01-23  5:11   ` Kalle Valo
  1 sibling, 0 replies; 5+ messages in thread
From: Kalle Valo @ 2019-01-23  5:11 UTC (permalink / raw)
  To: Arend Van Spriel
  Cc: Greg Kroah-Hartman, linux-kernel, Franky Lin, Hante Meuleman,
	Chi-Hsien Lin, Wright Feng, linux-wireless,
	brcm80211-dev-list.pdl, brcm80211-dev-list

Arend Van Spriel <arend.vanspriel@broadcom.com> writes:

> The prefix should be 'brcmsmac'.

I can fix that during commit.

-- 
Kalle Valo

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] brcmsmac: no need to check return value of debugfs_create functions
  2019-01-22 15:21 [PATCH] brcm80211: no need to check return value of debugfs_create functions Greg Kroah-Hartman
  2019-01-22 20:07 ` Arend Van Spriel
@ 2019-02-01 12:38 ` Kalle Valo
  1 sibling, 0 replies; 5+ messages in thread
From: Kalle Valo @ 2019-02-01 12:38 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, Greg Kroah-Hartman, Arend van Spriel, Franky Lin,
	Hante Meuleman, Chi-Hsien Lin, Wright Feng, linux-wireless,
	brcm80211-dev-list.pdl, brcm80211-dev-list

Greg Kroah-Hartman <gregkh@linuxfoundation.org> wrote:

> When calling debugfs functions, there is no need to ever check the
> return value.  The function can work or not, but the code logic should
> never do something different based on this.
> 
> Cc: Arend van Spriel <arend.vanspriel@broadcom.com>
> Cc: Franky Lin <franky.lin@broadcom.com>
> Cc: Hante Meuleman <hante.meuleman@broadcom.com>
> Cc: Chi-Hsien Lin <chi-hsien.lin@cypress.com>
> Cc: Wright Feng <wright.feng@cypress.com>
> Cc: Kalle Valo <kvalo@codeaurora.org>
> Cc: linux-wireless@vger.kernel.org
> Cc: brcm80211-dev-list.pdl@broadcom.com
> Cc: brcm80211-dev-list@cypress.com
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Acked-by: Arend van Spriel

Patch applied to wireless-drivers-next.git, thanks.

9ae49980bdca brcmsmac: no need to check return value of debugfs_create functions

-- 
https://patchwork.kernel.org/patch/10775745/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-02-01 12:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-22 15:21 [PATCH] brcm80211: no need to check return value of debugfs_create functions Greg Kroah-Hartman
2019-01-22 20:07 ` Arend Van Spriel
2019-01-22 20:43   ` Greg Kroah-Hartman
2019-01-23  5:11   ` Kalle Valo
2019-02-01 12:38 ` [PATCH] brcmsmac: " Kalle Valo

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