Skip to content

Commit

Permalink
brcmsmac: no need to check return value of debugfs_create functions
Browse files Browse the repository at this point in the history
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
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
  • Loading branch information
Greg Kroah-Hartman authored and Kalle Valo committed Feb 1, 2019
1 parent 32b4ebf commit 9ae4998
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 23 deletions.
26 changes: 4 additions & 22 deletions drivers/net/wireless/broadcom/brcm80211/brcmsmac/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -195,35 +186,26 @@ 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))
{
struct device *dev = &drvr->wlc->hw->d11core->dev;
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);
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/wireless/broadcom/brcm80211/brcmsmac/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 9ae4998

Please sign in to comment.