Skip to content

Commit

Permalink
Merge branch 'Networking-driver-debugfs-cleanups'
Browse files Browse the repository at this point in the history
Greg Kroah-Hartman says:

====================
Networking driver debugfs cleanups

There is no need to test the result of any debugfs call anymore.  The
debugfs core warns the user if something fails, and the return value of
a debugfs call can always be fed back into another debugfs call with no
problems.

Also, debugfs is for debugging, so if there are problems with debugfs
(i.e. the system is out of memory) the rest of the kernel should not
change behavior, so testing for debugfs calls is pointless and not the
goal of debugfs at all.

This series cleans up a lot of networking drivers and some wimax code
that was calling debugfs and trying to do something with the return
value that it didn't need to.  Removing this logic makes the code
smaller, easier to understand, and use less run-time memory in some
cases, all good things.

The series is against net-next, and have no dependancies between any of
them if they want to go through any random tree/order.  Or, if wanted,
I can take them through my driver-core tree where other debugfs cleanups
are being slowly fed during major merge windows.

v3: fix build warning in i2400m, I thought I had caught them all :(
    add acks from some reviewers

v2: fix up build warnings, it's as if I never even built these.  Ugh, so
    sorry for wasting people's time with the v1 series.  I need to stop
    relying on 0-day as it isn't working well anymore :(
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Aug 10, 2019
2 parents 38b9e0f + 7e174a4 commit 2cc2743
Show file tree
Hide file tree
Showing 37 changed files with 175 additions and 805 deletions.
5 changes: 0 additions & 5 deletions drivers/net/bonding/bond_debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@ void bond_debug_register(struct bonding *bond)
bond->debug_dir =
debugfs_create_dir(bond->dev->name, bonding_debug_root);

if (!bond->debug_dir) {
netdev_warn(bond->dev, "failed to register to debugfs\n");
return;
}

debugfs_create_file("rlb_hash_table", 0400, bond->debug_dir,
bond, &bond_debug_rlb_hash_fops);
}
Expand Down
107 changes: 31 additions & 76 deletions drivers/net/ethernet/amd/xgbe/xgbe-debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,6 @@ static const struct file_operations xi2c_reg_value_fops = {

void xgbe_debugfs_init(struct xgbe_prv_data *pdata)
{
struct dentry *pfile;
char *buf;

/* Set defaults */
Expand All @@ -451,88 +450,48 @@ void xgbe_debugfs_init(struct xgbe_prv_data *pdata)
return;

pdata->xgbe_debugfs = debugfs_create_dir(buf, NULL);
if (!pdata->xgbe_debugfs) {
netdev_err(pdata->netdev, "debugfs_create_dir failed\n");
kfree(buf);
return;
}

pfile = debugfs_create_file("xgmac_register", 0600,
pdata->xgbe_debugfs, pdata,
&xgmac_reg_addr_fops);
if (!pfile)
netdev_err(pdata->netdev, "debugfs_create_file failed\n");
debugfs_create_file("xgmac_register", 0600, pdata->xgbe_debugfs, pdata,
&xgmac_reg_addr_fops);

pfile = debugfs_create_file("xgmac_register_value", 0600,
pdata->xgbe_debugfs, pdata,
&xgmac_reg_value_fops);
if (!pfile)
netdev_err(pdata->netdev, "debugfs_create_file failed\n");
debugfs_create_file("xgmac_register_value", 0600, pdata->xgbe_debugfs,
pdata, &xgmac_reg_value_fops);

pfile = debugfs_create_file("xpcs_mmd", 0600,
pdata->xgbe_debugfs, pdata,
&xpcs_mmd_fops);
if (!pfile)
netdev_err(pdata->netdev, "debugfs_create_file failed\n");
debugfs_create_file("xpcs_mmd", 0600, pdata->xgbe_debugfs, pdata,
&xpcs_mmd_fops);

pfile = debugfs_create_file("xpcs_register", 0600,
pdata->xgbe_debugfs, pdata,
&xpcs_reg_addr_fops);
if (!pfile)
netdev_err(pdata->netdev, "debugfs_create_file failed\n");
debugfs_create_file("xpcs_register", 0600, pdata->xgbe_debugfs, pdata,
&xpcs_reg_addr_fops);

pfile = debugfs_create_file("xpcs_register_value", 0600,
pdata->xgbe_debugfs, pdata,
&xpcs_reg_value_fops);
if (!pfile)
netdev_err(pdata->netdev, "debugfs_create_file failed\n");
debugfs_create_file("xpcs_register_value", 0600, pdata->xgbe_debugfs,
pdata, &xpcs_reg_value_fops);

if (pdata->xprop_regs) {
pfile = debugfs_create_file("xprop_register", 0600,
pdata->xgbe_debugfs, pdata,
&xprop_reg_addr_fops);
if (!pfile)
netdev_err(pdata->netdev,
"debugfs_create_file failed\n");

pfile = debugfs_create_file("xprop_register_value", 0600,
pdata->xgbe_debugfs, pdata,
&xprop_reg_value_fops);
if (!pfile)
netdev_err(pdata->netdev,
"debugfs_create_file failed\n");
debugfs_create_file("xprop_register", 0600, pdata->xgbe_debugfs,
pdata, &xprop_reg_addr_fops);

debugfs_create_file("xprop_register_value", 0600,
pdata->xgbe_debugfs, pdata,
&xprop_reg_value_fops);
}

if (pdata->xi2c_regs) {
pfile = debugfs_create_file("xi2c_register", 0600,
pdata->xgbe_debugfs, pdata,
&xi2c_reg_addr_fops);
if (!pfile)
netdev_err(pdata->netdev,
"debugfs_create_file failed\n");

pfile = debugfs_create_file("xi2c_register_value", 0600,
pdata->xgbe_debugfs, pdata,
&xi2c_reg_value_fops);
if (!pfile)
netdev_err(pdata->netdev,
"debugfs_create_file failed\n");
debugfs_create_file("xi2c_register", 0600, pdata->xgbe_debugfs,
pdata, &xi2c_reg_addr_fops);

debugfs_create_file("xi2c_register_value", 0600,
pdata->xgbe_debugfs, pdata,
&xi2c_reg_value_fops);
}

if (pdata->vdata->an_cdr_workaround) {
pfile = debugfs_create_bool("an_cdr_workaround", 0600,
pdata->xgbe_debugfs,
&pdata->debugfs_an_cdr_workaround);
if (!pfile)
netdev_err(pdata->netdev,
"debugfs_create_bool failed\n");

pfile = debugfs_create_bool("an_cdr_track_early", 0600,
pdata->xgbe_debugfs,
&pdata->debugfs_an_cdr_track_early);
if (!pfile)
netdev_err(pdata->netdev,
"debugfs_create_bool failed\n");
debugfs_create_bool("an_cdr_workaround", 0600,
pdata->xgbe_debugfs,
&pdata->debugfs_an_cdr_workaround);

debugfs_create_bool("an_cdr_track_early", 0600,
pdata->xgbe_debugfs,
&pdata->debugfs_an_cdr_track_early);
}

kfree(buf);
Expand All @@ -546,7 +505,6 @@ void xgbe_debugfs_exit(struct xgbe_prv_data *pdata)

void xgbe_debugfs_rename(struct xgbe_prv_data *pdata)
{
struct dentry *pfile;
char *buf;

if (!pdata->xgbe_debugfs)
Expand All @@ -559,11 +517,8 @@ void xgbe_debugfs_rename(struct xgbe_prv_data *pdata)
if (!strcmp(pdata->xgbe_debugfs->d_name.name, buf))
goto out;

pfile = debugfs_rename(pdata->xgbe_debugfs->d_parent,
pdata->xgbe_debugfs,
pdata->xgbe_debugfs->d_parent, buf);
if (!pfile)
netdev_err(pdata->netdev, "debugfs_rename failed\n");
debugfs_rename(pdata->xgbe_debugfs->d_parent, pdata->xgbe_debugfs,
pdata->xgbe_debugfs->d_parent, buf);

out:
kfree(buf);
Expand Down
1 change: 0 additions & 1 deletion drivers/net/ethernet/broadcom/bnxt/bnxt.h
Original file line number Diff line number Diff line change
Expand Up @@ -1724,7 +1724,6 @@ struct bnxt {
u8 switch_id[8];
struct bnxt_tc_info *tc_info;
struct dentry *debugfs_pdev;
struct dentry *debugfs_dim;
struct device *hwmon_dev;
};

Expand Down
39 changes: 11 additions & 28 deletions drivers/net/ethernet/broadcom/bnxt/bnxt_debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,45 +61,30 @@ static const struct file_operations debugfs_dim_fops = {
.read = debugfs_dim_read,
};

static struct dentry *debugfs_dim_ring_init(struct dim *dim, int ring_idx,
struct dentry *dd)
static void debugfs_dim_ring_init(struct dim *dim, int ring_idx,
struct dentry *dd)
{
static char qname[16];

snprintf(qname, 10, "%d", ring_idx);
return debugfs_create_file(qname, 0600, dd,
dim, &debugfs_dim_fops);
debugfs_create_file(qname, 0600, dd, dim, &debugfs_dim_fops);
}

void bnxt_debug_dev_init(struct bnxt *bp)
{
const char *pname = pci_name(bp->pdev);
struct dentry *pdevf;
struct dentry *dir;
int i;

bp->debugfs_pdev = debugfs_create_dir(pname, bnxt_debug_mnt);
if (bp->debugfs_pdev) {
pdevf = debugfs_create_dir("dim", bp->debugfs_pdev);
if (!pdevf) {
pr_err("failed to create debugfs entry %s/dim\n",
pname);
return;
}
bp->debugfs_dim = pdevf;
/* create files for each rx ring */
for (i = 0; i < bp->cp_nr_rings; i++) {
struct bnxt_cp_ring_info *cpr = &bp->bnapi[i]->cp_ring;
dir = debugfs_create_dir("dim", bp->debugfs_pdev);

if (cpr && bp->bnapi[i]->rx_ring) {
pdevf = debugfs_dim_ring_init(&cpr->dim, i,
bp->debugfs_dim);
if (!pdevf)
pr_err("failed to create debugfs entry %s/dim/%d\n",
pname, i);
}
}
} else {
pr_err("failed to create debugfs entry %s\n", pname);
/* create files for each rx ring */
for (i = 0; i < bp->cp_nr_rings; i++) {
struct bnxt_cp_ring_info *cpr = &bp->bnapi[i]->cp_ring;

if (cpr && bp->bnapi[i]->rx_ring)
debugfs_dim_ring_init(&cpr->dim, i, dir);
}
}

Expand All @@ -114,8 +99,6 @@ void bnxt_debug_dev_exit(struct bnxt *bp)
void bnxt_debug_init(void)
{
bnxt_debug_mnt = debugfs_create_dir("bnxt_en", NULL);
if (!bnxt_debug_mnt)
pr_err("failed to init bnxt_en debugfs\n");
}

void bnxt_debug_exit(void)
Expand Down
5 changes: 2 additions & 3 deletions drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -3529,7 +3529,6 @@ int t4_setup_debugfs(struct adapter *adap)
{
int i;
u32 size = 0;
struct dentry *de;

static struct t4_debugfs_entry t4_debugfs_files[] = {
{ "cim_la", &cim_la_fops, 0400, 0 },
Expand Down Expand Up @@ -3640,8 +3639,8 @@ int t4_setup_debugfs(struct adapter *adap)
}
}

de = debugfs_create_file_size("flash", 0400, adap->debugfs_root, adap,
&flash_debugfs_fops, adap->params.sf_size);
debugfs_create_file_size("flash", 0400, adap->debugfs_root, adap,
&flash_debugfs_fops, adap->params.sf_size);
debugfs_create_bool("use_backdoor", 0600,
adap->debugfs_root, &adap->use_bd);
debugfs_create_bool("trace_rss", 0600,
Expand Down
3 changes: 0 additions & 3 deletions drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -6269,10 +6269,7 @@ static int __init cxgb4_init_module(void)
{
int ret;

/* Debugfs support is optional, just warn if this fails */
cxgb4_debugfs_root = debugfs_create_dir(KBUILD_MODNAME, NULL);
if (!cxgb4_debugfs_root)
pr_warn("could not create debugfs entry, continuing\n");

ret = pci_register_driver(&cxgb4_driver);
if (ret < 0)
Expand Down
21 changes: 7 additions & 14 deletions drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2478,11 +2478,10 @@ static int setup_debugfs(struct adapter *adapter)
* Debugfs support is best effort.
*/
for (i = 0; i < ARRAY_SIZE(debugfs_files); i++)
(void)debugfs_create_file(debugfs_files[i].name,
debugfs_files[i].mode,
adapter->debugfs_root,
(void *)adapter,
debugfs_files[i].fops);
debugfs_create_file(debugfs_files[i].name,
debugfs_files[i].mode,
adapter->debugfs_root, (void *)adapter,
debugfs_files[i].fops);

return 0;
}
Expand Down Expand Up @@ -3257,11 +3256,7 @@ static int cxgb4vf_pci_probe(struct pci_dev *pdev,
adapter->debugfs_root =
debugfs_create_dir(pci_name(pdev),
cxgb4vf_debugfs_root);
if (IS_ERR_OR_NULL(adapter->debugfs_root))
dev_warn(&pdev->dev, "could not create debugfs"
" directory");
else
setup_debugfs(adapter);
setup_debugfs(adapter);
}

/*
Expand Down Expand Up @@ -3486,13 +3481,11 @@ static int __init cxgb4vf_module_init(void)
return -EINVAL;
}

/* Debugfs support is optional, just warn if this fails */
/* Debugfs support is optional, debugfs will warn if this fails */
cxgb4vf_debugfs_root = debugfs_create_dir(KBUILD_MODNAME, NULL);
if (IS_ERR_OR_NULL(cxgb4vf_debugfs_root))
pr_warn("could not create debugfs entry, continuing\n");

ret = pci_register_driver(&cxgb4vf_driver);
if (ret < 0 && !IS_ERR_OR_NULL(cxgb4vf_debugfs_root))
if (ret < 0)
debugfs_remove(cxgb4vf_debugfs_root);
return ret;
}
Expand Down
54 changes: 7 additions & 47 deletions drivers/net/ethernet/freescale/dpaa2/dpaa2-eth-debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,70 +164,30 @@ static const struct file_operations dpaa2_dbg_ch_ops = {

void dpaa2_dbg_add(struct dpaa2_eth_priv *priv)
{
if (!dpaa2_dbg_root)
return;
struct dentry *dir;

/* Create a directory for the interface */
priv->dbg.dir = debugfs_create_dir(priv->net_dev->name,
dpaa2_dbg_root);
if (!priv->dbg.dir) {
netdev_err(priv->net_dev, "debugfs_create_dir() failed\n");
return;
}
dir = debugfs_create_dir(priv->net_dev->name, dpaa2_dbg_root);
priv->dbg.dir = dir;

/* per-cpu stats file */
priv->dbg.cpu_stats = debugfs_create_file("cpu_stats", 0444,
priv->dbg.dir, priv,
&dpaa2_dbg_cpu_ops);
if (!priv->dbg.cpu_stats) {
netdev_err(priv->net_dev, "debugfs_create_file() failed\n");
goto err_cpu_stats;
}
debugfs_create_file("cpu_stats", 0444, dir, priv, &dpaa2_dbg_cpu_ops);

/* per-fq stats file */
priv->dbg.fq_stats = debugfs_create_file("fq_stats", 0444,
priv->dbg.dir, priv,
&dpaa2_dbg_fq_ops);
if (!priv->dbg.fq_stats) {
netdev_err(priv->net_dev, "debugfs_create_file() failed\n");
goto err_fq_stats;
}
debugfs_create_file("fq_stats", 0444, dir, priv, &dpaa2_dbg_fq_ops);

/* per-fq stats file */
priv->dbg.ch_stats = debugfs_create_file("ch_stats", 0444,
priv->dbg.dir, priv,
&dpaa2_dbg_ch_ops);
if (!priv->dbg.fq_stats) {
netdev_err(priv->net_dev, "debugfs_create_file() failed\n");
goto err_ch_stats;
}

return;

err_ch_stats:
debugfs_remove(priv->dbg.fq_stats);
err_fq_stats:
debugfs_remove(priv->dbg.cpu_stats);
err_cpu_stats:
debugfs_remove(priv->dbg.dir);
debugfs_create_file("ch_stats", 0444, dir, priv, &dpaa2_dbg_ch_ops);
}

void dpaa2_dbg_remove(struct dpaa2_eth_priv *priv)
{
debugfs_remove(priv->dbg.fq_stats);
debugfs_remove(priv->dbg.ch_stats);
debugfs_remove(priv->dbg.cpu_stats);
debugfs_remove(priv->dbg.dir);
debugfs_remove_recursive(priv->dbg.dir);
}

void dpaa2_eth_dbg_init(void)
{
dpaa2_dbg_root = debugfs_create_dir(DPAA2_ETH_DBG_ROOT, NULL);
if (!dpaa2_dbg_root) {
pr_err("DPAA2-ETH: debugfs create failed\n");
return;
}

pr_debug("DPAA2-ETH: debugfs created\n");
}

Expand Down
3 changes: 0 additions & 3 deletions drivers/net/ethernet/freescale/dpaa2/dpaa2-eth-debugfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ struct dpaa2_eth_priv;

struct dpaa2_debugfs {
struct dentry *dir;
struct dentry *fq_stats;
struct dentry *ch_stats;
struct dentry *cpu_stats;
};

#ifdef CONFIG_DEBUG_FS
Expand Down
Loading

0 comments on commit 2cc2743

Please sign in to comment.