Commit 2cc2743d authored by David S. Miller's avatar David S. Miller

Merge branch 'Networking-driver-debugfs-cleanups'

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: default avatarDavid S. Miller <davem@davemloft.net>
parents 38b9e0f6 7e174a49
...@@ -55,11 +55,6 @@ void bond_debug_register(struct bonding *bond) ...@@ -55,11 +55,6 @@ void bond_debug_register(struct bonding *bond)
bond->debug_dir = bond->debug_dir =
debugfs_create_dir(bond->dev->name, bonding_debug_root); 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, debugfs_create_file("rlb_hash_table", 0400, bond->debug_dir,
bond, &bond_debug_rlb_hash_fops); bond, &bond_debug_rlb_hash_fops);
} }
......
...@@ -438,7 +438,6 @@ static const struct file_operations xi2c_reg_value_fops = { ...@@ -438,7 +438,6 @@ static const struct file_operations xi2c_reg_value_fops = {
void xgbe_debugfs_init(struct xgbe_prv_data *pdata) void xgbe_debugfs_init(struct xgbe_prv_data *pdata)
{ {
struct dentry *pfile;
char *buf; char *buf;
/* Set defaults */ /* Set defaults */
...@@ -451,88 +450,48 @@ void xgbe_debugfs_init(struct xgbe_prv_data *pdata) ...@@ -451,88 +450,48 @@ void xgbe_debugfs_init(struct xgbe_prv_data *pdata)
return; return;
pdata->xgbe_debugfs = debugfs_create_dir(buf, NULL); 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, debugfs_create_file("xgmac_register", 0600, pdata->xgbe_debugfs, pdata,
pdata->xgbe_debugfs, pdata, &xgmac_reg_addr_fops);
&xgmac_reg_addr_fops);
if (!pfile)
netdev_err(pdata->netdev, "debugfs_create_file failed\n");
pfile = debugfs_create_file("xgmac_register_value", 0600, debugfs_create_file("xgmac_register_value", 0600, pdata->xgbe_debugfs,
pdata->xgbe_debugfs, pdata, pdata, &xgmac_reg_value_fops);
&xgmac_reg_value_fops);
if (!pfile)
netdev_err(pdata->netdev, "debugfs_create_file failed\n");
pfile = debugfs_create_file("xpcs_mmd", 0600, debugfs_create_file("xpcs_mmd", 0600, pdata->xgbe_debugfs, pdata,
pdata->xgbe_debugfs, pdata, &xpcs_mmd_fops);
&xpcs_mmd_fops);
if (!pfile)
netdev_err(pdata->netdev, "debugfs_create_file failed\n");
pfile = debugfs_create_file("xpcs_register", 0600, debugfs_create_file("xpcs_register", 0600, pdata->xgbe_debugfs, pdata,
pdata->xgbe_debugfs, pdata, &xpcs_reg_addr_fops);
&xpcs_reg_addr_fops);
if (!pfile)
netdev_err(pdata->netdev, "debugfs_create_file failed\n");
pfile = debugfs_create_file("xpcs_register_value", 0600, debugfs_create_file("xpcs_register_value", 0600, pdata->xgbe_debugfs,
pdata->xgbe_debugfs, pdata, pdata, &xpcs_reg_value_fops);
&xpcs_reg_value_fops);
if (!pfile)
netdev_err(pdata->netdev, "debugfs_create_file failed\n");
if (pdata->xprop_regs) { if (pdata->xprop_regs) {
pfile = debugfs_create_file("xprop_register", 0600, debugfs_create_file("xprop_register", 0600, pdata->xgbe_debugfs,
pdata->xgbe_debugfs, pdata, pdata, &xprop_reg_addr_fops);
&xprop_reg_addr_fops);
if (!pfile) debugfs_create_file("xprop_register_value", 0600,
netdev_err(pdata->netdev, pdata->xgbe_debugfs, pdata,
"debugfs_create_file failed\n"); &xprop_reg_value_fops);
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");
} }
if (pdata->xi2c_regs) { if (pdata->xi2c_regs) {
pfile = debugfs_create_file("xi2c_register", 0600, debugfs_create_file("xi2c_register", 0600, pdata->xgbe_debugfs,
pdata->xgbe_debugfs, pdata, pdata, &xi2c_reg_addr_fops);
&xi2c_reg_addr_fops);
if (!pfile) debugfs_create_file("xi2c_register_value", 0600,
netdev_err(pdata->netdev, pdata->xgbe_debugfs, pdata,
"debugfs_create_file failed\n"); &xi2c_reg_value_fops);
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");
} }
if (pdata->vdata->an_cdr_workaround) { if (pdata->vdata->an_cdr_workaround) {
pfile = debugfs_create_bool("an_cdr_workaround", 0600, debugfs_create_bool("an_cdr_workaround", 0600,
pdata->xgbe_debugfs, pdata->xgbe_debugfs,
&pdata->debugfs_an_cdr_workaround); &pdata->debugfs_an_cdr_workaround);
if (!pfile)
netdev_err(pdata->netdev, debugfs_create_bool("an_cdr_track_early", 0600,
"debugfs_create_bool failed\n"); pdata->xgbe_debugfs,
&pdata->debugfs_an_cdr_track_early);
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");
} }
kfree(buf); kfree(buf);
...@@ -546,7 +505,6 @@ void xgbe_debugfs_exit(struct xgbe_prv_data *pdata) ...@@ -546,7 +505,6 @@ void xgbe_debugfs_exit(struct xgbe_prv_data *pdata)
void xgbe_debugfs_rename(struct xgbe_prv_data *pdata) void xgbe_debugfs_rename(struct xgbe_prv_data *pdata)
{ {
struct dentry *pfile;
char *buf; char *buf;
if (!pdata->xgbe_debugfs) if (!pdata->xgbe_debugfs)
...@@ -559,11 +517,8 @@ void xgbe_debugfs_rename(struct xgbe_prv_data *pdata) ...@@ -559,11 +517,8 @@ void xgbe_debugfs_rename(struct xgbe_prv_data *pdata)
if (!strcmp(pdata->xgbe_debugfs->d_name.name, buf)) if (!strcmp(pdata->xgbe_debugfs->d_name.name, buf))
goto out; goto out;
pfile = debugfs_rename(pdata->xgbe_debugfs->d_parent, debugfs_rename(pdata->xgbe_debugfs->d_parent, pdata->xgbe_debugfs,
pdata->xgbe_debugfs, pdata->xgbe_debugfs->d_parent, buf);
pdata->xgbe_debugfs->d_parent, buf);
if (!pfile)
netdev_err(pdata->netdev, "debugfs_rename failed\n");
out: out:
kfree(buf); kfree(buf);
......
...@@ -1724,7 +1724,6 @@ struct bnxt { ...@@ -1724,7 +1724,6 @@ struct bnxt {
u8 switch_id[8]; u8 switch_id[8];
struct bnxt_tc_info *tc_info; struct bnxt_tc_info *tc_info;
struct dentry *debugfs_pdev; struct dentry *debugfs_pdev;
struct dentry *debugfs_dim;
struct device *hwmon_dev; struct device *hwmon_dev;
}; };
......
...@@ -61,45 +61,30 @@ static const struct file_operations debugfs_dim_fops = { ...@@ -61,45 +61,30 @@ static const struct file_operations debugfs_dim_fops = {
.read = debugfs_dim_read, .read = debugfs_dim_read,
}; };
static struct dentry *debugfs_dim_ring_init(struct dim *dim, int ring_idx, static void debugfs_dim_ring_init(struct dim *dim, int ring_idx,
struct dentry *dd) struct dentry *dd)
{ {
static char qname[16]; static char qname[16];
snprintf(qname, 10, "%d", ring_idx); snprintf(qname, 10, "%d", ring_idx);
return debugfs_create_file(qname, 0600, dd, debugfs_create_file(qname, 0600, dd, dim, &debugfs_dim_fops);
dim, &debugfs_dim_fops);
} }
void bnxt_debug_dev_init(struct bnxt *bp) void bnxt_debug_dev_init(struct bnxt *bp)
{ {
const char *pname = pci_name(bp->pdev); const char *pname = pci_name(bp->pdev);
struct dentry *pdevf; struct dentry *dir;
int i; int i;
bp->debugfs_pdev = debugfs_create_dir(pname, bnxt_debug_mnt); bp->debugfs_pdev = debugfs_create_dir(pname, bnxt_debug_mnt);
if (bp->debugfs_pdev) { dir = debugfs_create_dir("dim", 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;
if (cpr && bp->bnapi[i]->rx_ring) { /* create files for each rx ring */
pdevf = debugfs_dim_ring_init(&cpr->dim, i, for (i = 0; i < bp->cp_nr_rings; i++) {
bp->debugfs_dim); struct bnxt_cp_ring_info *cpr = &bp->bnapi[i]->cp_ring;
if (!pdevf)
pr_err("failed to create debugfs entry %s/dim/%d\n", if (cpr && bp->bnapi[i]->rx_ring)
pname, i); debugfs_dim_ring_init(&cpr->dim, i, dir);
}
}
} else {
pr_err("failed to create debugfs entry %s\n", pname);
} }
} }
...@@ -114,8 +99,6 @@ void bnxt_debug_dev_exit(struct bnxt *bp) ...@@ -114,8 +99,6 @@ void bnxt_debug_dev_exit(struct bnxt *bp)
void bnxt_debug_init(void) void bnxt_debug_init(void)
{ {
bnxt_debug_mnt = debugfs_create_dir("bnxt_en", NULL); 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) void bnxt_debug_exit(void)
......
...@@ -3529,7 +3529,6 @@ int t4_setup_debugfs(struct adapter *adap) ...@@ -3529,7 +3529,6 @@ int t4_setup_debugfs(struct adapter *adap)
{ {
int i; int i;
u32 size = 0; u32 size = 0;
struct dentry *de;
static struct t4_debugfs_entry t4_debugfs_files[] = { static struct t4_debugfs_entry t4_debugfs_files[] = {
{ "cim_la", &cim_la_fops, 0400, 0 }, { "cim_la", &cim_la_fops, 0400, 0 },
...@@ -3640,8 +3639,8 @@ int t4_setup_debugfs(struct adapter *adap) ...@@ -3640,8 +3639,8 @@ int t4_setup_debugfs(struct adapter *adap)
} }
} }
de = debugfs_create_file_size("flash", 0400, adap->debugfs_root, adap, debugfs_create_file_size("flash", 0400, adap->debugfs_root, adap,
&flash_debugfs_fops, adap->params.sf_size); &flash_debugfs_fops, adap->params.sf_size);
debugfs_create_bool("use_backdoor", 0600, debugfs_create_bool("use_backdoor", 0600,
adap->debugfs_root, &adap->use_bd); adap->debugfs_root, &adap->use_bd);
debugfs_create_bool("trace_rss", 0600, debugfs_create_bool("trace_rss", 0600,
......
...@@ -6269,10 +6269,7 @@ static int __init cxgb4_init_module(void) ...@@ -6269,10 +6269,7 @@ static int __init cxgb4_init_module(void)
{ {
int ret; int ret;
/* Debugfs support is optional, just warn if this fails */
cxgb4_debugfs_root = debugfs_create_dir(KBUILD_MODNAME, NULL); 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); ret = pci_register_driver(&cxgb4_driver);
if (ret < 0) if (ret < 0)
......
...@@ -2478,11 +2478,10 @@ static int setup_debugfs(struct adapter *adapter) ...@@ -2478,11 +2478,10 @@ static int setup_debugfs(struct adapter *adapter)
* Debugfs support is best effort. * Debugfs support is best effort.
*/ */
for (i = 0; i < ARRAY_SIZE(debugfs_files); i++) for (i = 0; i < ARRAY_SIZE(debugfs_files); i++)
(void)debugfs_create_file(debugfs_files[i].name, debugfs_create_file(debugfs_files[i].name,
debugfs_files[i].mode, debugfs_files[i].mode,
adapter->debugfs_root, adapter->debugfs_root, (void *)adapter,
(void *)adapter, debugfs_files[i].fops);
debugfs_files[i].fops);
return 0; return 0;
} }
...@@ -3257,11 +3256,7 @@ static int cxgb4vf_pci_probe(struct pci_dev *pdev, ...@@ -3257,11 +3256,7 @@ static int cxgb4vf_pci_probe(struct pci_dev *pdev,
adapter->debugfs_root = adapter->debugfs_root =
debugfs_create_dir(pci_name(pdev), debugfs_create_dir(pci_name(pdev),
cxgb4vf_debugfs_root); cxgb4vf_debugfs_root);
if (IS_ERR_OR_NULL(adapter->debugfs_root)) setup_debugfs(adapter);
dev_warn(&pdev->dev, "could not create debugfs"
" directory");
else
setup_debugfs(adapter);
} }
/* /*
...@@ -3486,13 +3481,11 @@ static int __init cxgb4vf_module_init(void) ...@@ -3486,13 +3481,11 @@ static int __init cxgb4vf_module_init(void)
return -EINVAL; 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); 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); ret = pci_register_driver(&cxgb4vf_driver);
if (ret < 0 && !IS_ERR_OR_NULL(cxgb4vf_debugfs_root)) if (ret < 0)
debugfs_remove(cxgb4vf_debugfs_root); debugfs_remove(cxgb4vf_debugfs_root);
return ret; return ret;
} }
......
...@@ -164,70 +164,30 @@ static const struct file_operations dpaa2_dbg_ch_ops = { ...@@ -164,70 +164,30 @@ static const struct file_operations dpaa2_dbg_ch_ops = {
void dpaa2_dbg_add(struct dpaa2_eth_priv *priv) void dpaa2_dbg_add(struct dpaa2_eth_priv *priv)
{ {
if (!dpaa2_dbg_root) struct dentry *dir;
return;
/* Create a directory for the interface */ /* Create a directory for the interface */
priv->dbg.dir = debugfs_create_dir(priv->net_dev->name, dir = debugfs_create_dir(priv->net_dev->name, dpaa2_dbg_root);
dpaa2_dbg_root); priv->dbg.dir = dir;
if (!priv->dbg.dir) {
netdev_err(priv->net_dev, "debugfs_create_dir() failed\n");
return;
}
/* per-cpu stats file */ /* per-cpu stats file */
priv->dbg.cpu_stats = debugfs_create_file("cpu_stats", 0444, debugfs_create_file("cpu_stats", 0444, dir, priv, &dpaa2_dbg_cpu_ops);
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;
}
/* per-fq stats file */ /* per-fq stats file */
priv->dbg.fq_stats = debugfs_create_file("fq_stats", 0444, debugfs_create_file("fq_stats", 0444, dir, priv, &dpaa2_dbg_fq_ops);
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;
}
/* per-fq stats file */ /* per-fq stats file */
priv->dbg.ch_stats = debugfs_create_file("ch_stats", 0444, debugfs_create_file("ch_stats", 0444, dir, priv, &dpaa2_dbg_ch_ops);
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);
} }
void dpaa2_dbg_remove(struct dpaa2_eth_priv *priv) void dpaa2_dbg_remove(struct dpaa2_eth_priv *priv)
{ {
debugfs_remove(priv->dbg.fq_stats); debugfs_remove_recursive(priv->dbg.dir);
debugfs_remove(priv->dbg.ch_stats);
debugfs_remove(priv->dbg.cpu_stats);
debugfs_remove(priv->dbg.dir);
} }
void dpaa2_eth_dbg_init(void) void dpaa2_eth_dbg_init(void)
{ {
dpaa2_dbg_root = debugfs_create_dir(DPAA2_ETH_DBG_ROOT, NULL); 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"); pr_debug("DPAA2-ETH: debugfs created\n");
} }
......
...@@ -11,9 +11,6 @@ struct dpaa2_eth_priv; ...@@ -11,9 +11,6 @@ struct dpaa2_eth_priv;
struct dpaa2_debugfs { struct dpaa2_debugfs {
struct dentry *dir; struct dentry *dir;
struct dentry *fq_stats;
struct dentry *ch_stats;
struct dentry *cpu_stats;
}; };
#ifdef CONFIG_DEBUG_FS #ifdef CONFIG_DEBUG_FS
......
...@@ -376,20 +376,11 @@ static const struct file_operations hns3_dbg_cmd_fops = { ...@@ -376,20 +376,11 @@ static const struct file_operations hns3_dbg_cmd_fops = {
void hns3_dbg_init(struct hnae3_handle *handle) void hns3_dbg_init(struct hnae3_handle *handle)
{ {
const char *name = pci_name(handle->pdev); const char *name = pci_name(handle->pdev);
struct dentry *pfile;
handle->hnae3_dbgfs = debugfs_create_dir(name, hns3_dbgfs_root); handle->hnae3_dbgfs = debugfs_create_dir(name, hns3_dbgfs_root);
if (!handle->hnae3_dbgfs)
return;
pfile = debugfs_create_file("cmd", 0600, handle->hnae3_dbgfs, handle, debugfs_create_file("cmd", 0600, handle->hnae3_dbgfs, handle,
&hns3_dbg_cmd_fops); &hns3_dbg_cmd_fops);
if (!pfile) {
debugfs_remove_recursive(handle->hnae3_dbgfs);
handle->hnae3_dbgfs = NULL;
dev_warn(&handle->pdev->dev, "create file for %s fail\n",
name);
}
} }
void hns3_dbg_uninit(struct hnae3_handle *handle) void hns3_dbg_uninit(struct hnae3_handle *handle)
...@@ -401,10 +392,6 @@ void hns3_dbg_uninit(struct hnae3_handle *handle) ...@@ -401,10 +392,6 @@ void hns3_dbg_uninit(struct hnae3_handle *handle)
void hns3_dbg_register_debugfs(const char *debugfs_dir_name) void hns3_dbg_register_debugfs(const char *debugfs_dir_name)
{ {
hns3_dbgfs_root = debugfs_create_dir(debugfs_dir_name, NULL); hns3_dbgfs_root = debugfs_create_dir(debugfs_dir_name, NULL);
if (!hns3_dbgfs_root) {
pr_warn("Register debugfs for %s fail\n", debugfs_dir_name);
return;
}
} }
void hns3_dbg_unregister_debugfs(void) void hns3_dbg_unregister_debugfs(void)
......
...@@ -160,8 +160,6 @@ void fm10k_dbg_q_vector_init(struct fm10k_q_vector *q_vector) ...@@ -160,8 +160,6 @@ void fm10k_dbg_q_vector_init(struct fm10k_q_vector *q_vector)
snprintf(name, sizeof(name), "q_vector.%03d", q_vector->v_idx); snprintf(name, sizeof(name), "q_vector.%03d", q_vector->v_idx);
q_vector->dbg_q_vector = debugfs_create_dir(name, interface->dbg_intfc); q_vector->dbg_q_vector = debugfs_create_dir(name, interface->dbg_intfc);
if (!q_vector->dbg_q_vector)
return;
/* Generate a file for each rx ring in the q_vector */ /* Generate a file for each rx ring in the q_vector */
for (i = 0; i < q_vector->tx.count; i++) { for (i = 0; i < q_vector->tx.count; i++) {
......
...@@ -1732,29 +1732,15 @@ static const struct file_operations i40e_dbg_netdev_ops_fops = { ...@@ -1732,29 +1732,15 @@ static const struct file_operations i40e_dbg_netdev_ops_fops = {
**/ **/
void i40e_dbg_pf_init(struct i40e_pf *pf) void i40e_dbg_pf_init(struct i40e_pf *pf)
{ {
struct dentry *pfile;
const char *name = pci_name(pf->pdev); const char *name = pci_name(pf->pdev);
const struct device *dev = &pf->pdev->dev;
pf->i40e_dbg_pf = debugfs_create_dir(name, i40e_dbg_root); pf->i40e_dbg_pf = debugfs_create_dir(name, i40e_dbg_root);
if (!pf->i40e_dbg_pf)
return;
pfile = debugfs_create_file("command", 0600, pf->i40e_dbg_pf, pf,
&i40e_dbg_command_fops);
if (!pfile)
goto create_failed;
pfile = debugfs_create_file("netdev_ops", 0600, pf->i40e_dbg_pf, pf, debugfs_create_file("command", 0600, pf->i40e_dbg_pf, pf,
&i40e_dbg_netdev_ops_fops); &i40e_dbg_command_fops);
if (!pfile)
goto create_failed;
return; debugfs_create_file("netdev_ops", 0600, pf->i40e_dbg_pf, pf,
&i40e_dbg_netdev_ops_fops);
create_failed:
dev_info(dev, "debugfs dir/file for %s failed\n", name);
debugfs_remove_recursive(pf->i40e_dbg_pf);
} }
/** /**
......
...@@ -190,22 +190,12 @@ static const struct file_operations ixgbe_dbg_netdev_ops_fops = { ...@@ -190,22 +190,12 @@ static const struct file_operations ixgbe_dbg_netdev_ops_fops = {
void ixgbe_dbg_adapter_init(struct ixgbe_adapter *adapter) void ixgbe_dbg_adapter_init(struct ixgbe_adapter *adapter)
{ {
const char *name = pci_name(adapter->pdev); const char *name = pci_name(adapter->pdev);
struct dentry *pfile;
adapter->ixgbe_dbg_adapter = debugfs_create_dir(name, ixgbe_dbg_root); adapter->ixgbe_dbg_adapter = debugfs_create_dir(name, ixgbe_dbg_root);
if (adapter->ixgbe_dbg_adapter) { debugfs_create_file("reg_ops", 0600, adapter->ixgbe_dbg_adapter,
pfile = debugfs_create_file("reg_ops", 0600, adapter, &ixgbe_dbg_reg_ops_fops);
adapter->ixgbe_dbg_adapter, adapter, debugfs_create_file("netdev_ops", 0600, adapter->ixgbe_dbg_adapter,
&ixgbe_dbg_reg_ops_fops); adapter, &ixgbe_dbg_netdev_ops_fops);
if (!pfile)
e_dev_err("debugfs reg_ops for %s failed\n", name);
pfile = debugfs_create_file("netdev_ops", 0600,
adapter->ixgbe_dbg_adapter, adapter,
&ixgbe_dbg_netdev_ops_fops);
if (!pfile)
e_dev_err("debugfs netdev_ops for %s failed\n", name);
} else {
e_dev_err("debugfs entry for %s failed\n", name);
}
} }
/** /**
...@@ -224,8 +214,6 @@ void ixgbe_dbg_adapter_exit(struct ixgbe_adapter *adapter) ...@@ -224,8 +214,6 @@ void ixgbe_dbg_adapter_exit(struct ixgbe_adapter *adapter)
void ixgbe_dbg_init(void) void ixgbe_dbg_init(void)
{ {
ixgbe_dbg_root = debugfs_create_dir(ixgbe_driver_name, NULL); ixgbe_dbg_root = debugfs_create_dir(ixgbe_driver_name, NULL);
if (ixgbe_dbg_root == NULL)
pr_err("init of debugfs failed\n");
} }
/** /**
......
...@@ -452,8 +452,6 @@ static int mvpp2_dbgfs_flow_port_init(struct dentry *parent, ...@@ -452,8 +452,6 @@ static int mvpp2_dbgfs_flow_port_init(struct dentry *parent,
struct dentry *port_dir; struct dentry *port_dir;
port_dir = debugfs_create_dir(port->dev->name, parent); port_dir = debugfs_create_dir(port->dev->name, parent);
if (IS_ERR(port_dir))
return PTR_ERR(port_dir);
port_entry = &port->priv->dbgfs_entries->port_flow_entries[port->id]; port_entry = &port->priv->dbgfs_entries->port_flow_entries[port->id];
...@@ -480,8 +478,6 @@ static int mvpp2_dbgfs_flow_entry_init(struct dentry *parent, ...@@ -480,8 +478,6 @@ static int mvpp2_dbgfs_flow_entry_init(struct dentry *parent,
sprintf(flow_entry_name, "%02d", flow); sprintf(flow_entry_name, "%02d", flow);
flow_entry_dir = debugfs_create_dir(flow_entry_name, parent); flow_entry_dir = debugfs_create_dir(flow_entry_name, parent);
if (!flow_entry_dir)
return -ENOMEM;
entry = &priv->dbgfs_entries->flow_entries[flow]; entry = &priv->dbgfs_entries->flow_entries[flow];
...@@ -514,8 +510,6 @@ static int mvpp2_dbgfs_flow_init(struct dentry *parent, struct mvpp2 *priv) ...@@ -514,8 +510,6 @@ static int mvpp2_dbgfs_flow_init(struct dentry *parent, struct mvpp2 *priv)
int i, ret; int i, ret;
flow_dir = debugfs_create_dir("flows", parent); flow_dir = debugfs_create_dir("flows", parent);
if (!flow_dir)
return -ENOMEM;
for (i = 0; i < MVPP2_N_PRS_FLOWS; i++) { for (i = 0; i < MVPP2_N_PRS_FLOWS; i++) {
ret = mvpp2_dbgfs_flow_entry_init(flow_dir, priv, i); ret = mvpp2_dbgfs_flow_entry_init(flow_dir, priv, i);
...@@ -539,8 +533,6 @@ static int mvpp2_dbgfs_prs_entry_init(struct dentry *parent, ...@@ -539,8 +533,6 @@ static int mvpp2_dbgfs_prs_entry_init(struct dentry *parent,
sprintf(prs_entry_name, "%03d", tid); sprintf(prs_entry_name, "%03d", tid);
prs_entry_dir = debugfs_create_dir(prs_entry_name, parent); prs_entry_dir = debugfs_create_dir(prs_entry_name, parent);
if (!prs_entry_dir)
return -ENOMEM;
entry = &priv->dbgfs_entries->prs_entries[tid]; entry = &priv->dbgfs_entries->prs_entries[tid];
...@@ -578,8 +570,6 @@ static int mvpp2_dbgfs_prs_init(struct dentry *parent, struct mvpp2 *priv) ...@@ -578,8 +570,6 @@ static int mvpp2_dbgfs_prs_init(struct dentry *parent, struct mvpp2 *priv)
int i, ret; int i, ret;
prs_dir = debugfs_create_dir("parser", parent); prs_dir = debugfs_create_dir("parser", parent);
if (!prs_dir)
return -ENOMEM;
for (i = 0; i < MVPP2_PRS_TCAM_SRAM_SIZE; i++) { for (i = 0; i < MVPP2_PRS_TCAM_SRAM_SIZE; i++) {
ret = mvpp2_dbgfs_prs_entry_init(prs_dir, priv, i); ret = mvpp2_dbgfs_prs_entry_init(prs_dir, priv, i);
...@@ -688,8 +678,6 @@ static int mvpp2_dbgfs_port_init(struct dentry *parent, ...@@ -688,8 +678,6 @@ static int mvpp2_dbgfs_port_init(struct dentry *parent,
struct dentry *port_dir; struct dentry *port_dir;
port_dir = debugfs_create_dir(port->dev->name, parent); port_dir = debugfs_create_dir(port->dev->name, parent);
if (IS_ERR(port_dir))
return PTR_ERR(port_dir);
debugfs_create_file("parser_entries", 0444, port_dir, port, debugfs_create_file("parser_entries", 0444, port_dir, port,
&mvpp2_dbgfs_port_parser_fops); &mvpp2_dbgfs_port_parser_fops);
...@@ -716,15 +704,10 @@ void mvpp2_dbgfs_init(struct mvpp2 *priv, const char *name) ...@@ -716,15 +704,10 @@ void mvpp2_dbgfs_init(struct mvpp2 *priv, const char *name)
int ret, i; int ret, i;
mvpp2_root = debugfs_lookup(MVPP2_DRIVER_NAME, NULL); mvpp2_root = debugfs_lookup(MVPP2_DRIVER_NAME, NULL);
if (!mvpp2_root) { if (!mvpp2_root)
mvpp2_root = debugfs_create_dir(MVPP2_DRIVER_NAME, NULL); mvpp2_root = debugfs_create_dir(MVPP2_DRIVER_NAME, NULL);
if (IS_ERR(mvpp2_root))
return;
}
mvpp2_dir = debugfs_create_dir(name, mvpp2_root); mvpp2_dir = debugfs_create_dir(name, mvpp2_root);
if (IS_ERR(mvpp2_dir))
return;
priv->dbgfs_dir = mvpp2_dir; priv->dbgfs_dir = mvpp2_dir;
priv->dbgfs_entries = kzalloc(sizeof(*priv->dbgfs_entries), GFP_KERNEL); priv->dbgfs_entries = kzalloc(sizeof(*priv->dbgfs_entries), GFP_KERNEL);
......
...@@ -3731,7 +3731,6 @@ static int skge_device_event(struct notifier_block *unused, ...@@ -3731,7 +3731,6 @@ static int skge_device_event(struct notifier_block *unused,
{ {
struct net_device *dev = netdev_notifier_info_to_dev(ptr); struct net_device *dev = netdev_notifier_info_to_dev(ptr);
struct skge_port *skge; struct skge_port *skge;
struct dentry *d;
if (dev->netdev_ops->ndo_open != &skge_up || !skge_debug) if (dev->netdev_ops->ndo_open != &skge_up || !skge_debug)
goto done; goto done;
...@@ -3739,33 +3738,20 @@ static int skge_device_event(struct notifier_block *unused, ...@@ -3739,33 +3738,20 @@ static int skge_device_event(struct notifier_block *unused,
skge = netdev_priv(dev); skge = netdev_priv(dev);
switch (event) { switch (event) {
case NETDEV_CHANGENAME: case NETDEV_CHANGENAME:
if (skge->debugfs) { if (skge->debugfs)
d = debugfs_rename(skge_debug, skge->debugfs, skge->debugfs = debugfs_rename(skge_debug,
skge_debug, dev->name); skge->debugfs,
if (d) skge_debug, dev->name);
skge->debugfs = d;
else {
netdev_info(dev, "rename failed\n");
debugfs_remove(skge->debugfs);
}
}
break; break;
case NETDEV_GOING_DOWN: case NETDEV_GOING_DOWN:
if (skge->debugfs) { debugfs_remove(skge->debugfs);
debugfs_remove(skge->debugfs); skge->debugfs = NULL;
skge->debugfs = NULL;
}
break; break;
case NETDEV_UP: case NETDEV_UP:
d = debugfs_create_file(dev->name, 0444, skge->debugfs = debugfs_create_file(dev->name, 0444, skge_debug,
skge_debug, dev, dev, &skge_debug_fops);
&skge_debug_fops);
if (!d || IS_ERR(d))
netdev_info(dev, "debugfs create failed\n");
else
skge->debugfs = d;
break; break;
} }
...@@ -3780,15 +3766,8 @@ static struct notifier_block skge_notifier = { ...@@ -3780,15 +3766,8 @@ static struct notifier_block skge_notifier = {
static __init void skge_debug_init(void) static __init void skge_debug_init(void)
{ {
struct dentry *ent; skge_debug = debugfs_create_dir("skge", NULL);
ent = debugfs_create_dir("skge", NULL);
if (!ent || IS_ERR(ent)) {
pr_info("debugfs create directory failed\n");
return;
}
skge_debug = ent;
register_netdevice_notifier(&skge_notifier); register_netdevice_notifier(&skge_notifier);
} }
......
...@@ -1368,49 +1368,19 @@ static void clean_debug_files(struct mlx5_core_dev *dev) ...@@ -1368,49 +1368,19 @@ static void clean_debug_files(struct mlx5_core_dev *dev)
debugfs_remove_recursive(dbg->dbg_root); debugfs_remove_recursive(dbg->dbg_root);
} }
static int create_debugfs_files(struct mlx5_core_dev *dev) static void create_debugfs_files(struct mlx5_core_dev *dev)
{ {
struct mlx5_cmd_debug *dbg = &dev->cmd.dbg; struct mlx5_cmd_debug *dbg = &dev->cmd.dbg;
int err = -ENOMEM;
if (!mlx5_debugfs_root)
return 0;
dbg->dbg_root = debugfs_create_dir("cmd", dev->priv.dbg_root); dbg->dbg_root = debugfs_create_dir("cmd", dev->priv.dbg_root);
if (!dbg->dbg_root)
return err;
dbg->dbg_in = debugfs_create_file("in", 0400, dbg->dbg_root,
dev, &dfops);
if (!dbg->dbg_in)
goto err_dbg;
dbg->dbg_out = debugfs_create_file("out", 0200, dbg->dbg_root, debugfs_create_file("in", 0400, dbg->dbg_root, dev, &dfops);
dev, &dfops); debugfs_create_file("out", 0200, dbg->dbg_root, dev, &dfops);
if (!dbg->dbg_out) debugfs_create_file("out_len", 0600, dbg->dbg_root, dev, &olfops);
goto err_dbg; debugfs_create_u8("status", 0600, dbg->dbg_root, &dbg->status);
debugfs_create_file("run", 0200, dbg->dbg_root, dev, &fops);
dbg->dbg_outlen = debugfs_create_file("out_len", 0600, dbg->dbg_root,
dev, &olfops);
if (!dbg->dbg_outlen)
goto err_dbg;
dbg->dbg_status = debugfs_create_u8("status", 0600, dbg->dbg_root,
&dbg->status);
if (!dbg->dbg_status)
goto err_dbg;
dbg->dbg_run = debugfs_create_file("run", 0200, dbg->dbg_root, dev, &fops);
if (!dbg->dbg_run)
goto err_dbg;
mlx5_cmdif_debugfs_init(dev); mlx5_cmdif_debugfs_init(dev);
return 0;
err_dbg:
clean_debug_files(dev);
return err;
} }
static void mlx5_cmd_change_mod(struct mlx5_core_dev *dev, int mode) static void mlx5_cmd_change_mod(struct mlx5_core_dev *dev, int mode)
...@@ -2007,17 +1977,10 @@ int mlx5_cmd_init(struct mlx5_core_dev *dev) ...@@ -2007,17 +1977,10 @@ int mlx5_cmd_init(struct mlx5_core_dev *dev)
goto err_cache; goto err_cache;
} }
err = create_debugfs_files(dev); create_debugfs_files(dev);
if (err) {
err = -ENOMEM;
goto err_wq;
}
return 0; return 0;
err_wq:
destroy_workqueue(cmd->wq);
err_cache: err_cache:
destroy_msg_cache(dev); destroy_msg_cache(dev);
......
...@@ -92,8 +92,6 @@ EXPORT_SYMBOL(mlx5_debugfs_root); ...@@ -92,8 +92,6 @@ EXPORT_SYMBOL(mlx5_debugfs_root);
void mlx5_register_debugfs(void) void mlx5_register_debugfs(void)
{ {
mlx5_debugfs_root = debugfs_create_dir("mlx5", NULL); mlx5_debugfs_root = debugfs_create_dir("mlx5", NULL);
if (IS_ERR_OR_NULL(mlx5_debugfs_root))
mlx5_debugfs_root = NULL;
} }
void mlx5_unregister_debugfs(void) void mlx5_unregister_debugfs(void)
...@@ -101,45 +99,25 @@ void mlx5_unregister_debugfs(void) ...@@ -101,45 +99,25 @@ void mlx5_unregister_debugfs(void)
debugfs_remove(mlx5_debugfs_root); debugfs_remove(mlx5_debugfs_root);
} }
int mlx5_qp_debugfs_init(struct mlx5_core_dev *dev) void mlx5_qp_debugfs_init(struct mlx5_core_dev *dev)
{ {
if (!mlx5_debugfs_root)
return 0;
atomic_set(&dev->num_qps, 0); atomic_set(&dev->num_qps, 0);
dev->priv.qp_debugfs = debugfs_create_dir("QPs", dev->priv.dbg_root); dev->priv.qp_debugfs = debugfs_create_dir("QPs", dev->priv.dbg_root);
if (!dev->priv.qp_debugfs)
return -ENOMEM;
return 0;
} }
void mlx5_qp_debugfs_cleanup(struct mlx5_core_dev *dev) void mlx5_qp_debugfs_cleanup(struct mlx5_core_dev *dev)
{ {
if (!mlx5_debugfs_root)
return;
debugfs_remove_recursive(dev->priv.qp_debugfs); debugfs_remove_recursive(dev->priv.qp_debugfs);
} }
int mlx5_eq_debugfs_init(struct mlx5_core_dev *dev) void mlx5_eq_debugfs_init(struct mlx5_core_dev *dev)
{ {
if (!mlx5_debugfs_root)
return 0;
dev->priv.eq_debugfs = debugfs_create_dir("EQs", dev->priv.dbg_root); dev->priv.eq_debugfs = debugfs_create_dir("EQs", dev->priv.dbg_root);
if (!dev->priv.eq_debugfs)
return -ENOMEM;
return 0;
} }
void mlx5_eq_debugfs_cleanup(struct mlx5_core_dev *dev) void mlx5_eq_debugfs_cleanup(struct mlx5_core_dev *dev)
{ {
if (!mlx5_debugfs_root)
return;
debugfs_remove_recursive(dev->priv.eq_debugfs); debugfs_remove_recursive(dev->priv.eq_debugfs);
} }
...@@ -183,85 +161,41 @@ static const struct file_operations stats_fops = { ...@@ -183,85 +161,41 @@ static const struct file_operations stats_fops = {
.write = average_write, .write = average_write,
}; };
int mlx5_cmdif_debugfs_init(struct mlx5_core_dev *dev) void mlx5_cmdif_debugfs_init(struct mlx5_core_dev *dev)
{ {
struct mlx5_cmd_stats *stats; struct mlx5_cmd_stats *stats;
struct dentry **cmd; struct dentry **cmd;
const char *namep; const char *namep;
int err;
int i; int i;
if (!mlx5_debugfs_root)
return 0;
cmd = &dev->priv.cmdif_debugfs; cmd = &dev->priv.cmdif_debugfs;
*cmd = debugfs_create_dir("commands", dev->priv.dbg_root); *cmd = debugfs_create_dir("commands", dev->priv.dbg_root);
if (!*cmd)
return -ENOMEM;
for (i = 0; i < ARRAY_SIZE(dev->cmd.stats); i++) { for (i = 0; i < ARRAY_SIZE(dev->cmd.stats); i++) {
stats = &dev->cmd.stats[i]; stats = &dev->cmd.stats[i];
namep = mlx5_command_str(i); namep = mlx5_command_str(i);
if (strcmp(namep, "unknown command opcode")) { if (strcmp(namep, "unknown command opcode")) {
stats->root = debugfs_create_dir(namep, *cmd); stats->root = debugfs_create_dir(namep, *cmd);
if (!stats->root) {
mlx5_core_warn(dev, "failed adding command %d\n", debugfs_create_file("average", 0400, stats->root, stats,
i); &stats_fops);
err = -ENOMEM; debugfs_create_u64("n", 0400, stats->root, &stats->n);
goto out;
}
stats->avg = debugfs_create_file("average", 0400,
stats->root, stats,
&stats_fops);
if (!stats->avg) {
mlx5_core_warn(dev, "failed creating debugfs file\n");
err = -ENOMEM;
goto out;
}
stats->count = debugfs_create_u64("n", 0400,
stats->root,
&stats->n);
if (!stats->count) {
mlx5_core_warn(dev, "failed creating debugfs file\n");
err = -ENOMEM;
goto out;
}
} }
} }
return 0;
out:
debugfs_remove_recursive(dev->priv.cmdif_debugfs);
return err;
} }
void mlx5_cmdif_debugfs_cleanup(struct mlx5_core_dev *dev) void mlx5_cmdif_debugfs_cleanup(struct mlx5_core_dev *dev)
{ {
if (!mlx5_debugfs_root)
return;
debugfs_remove_recursive(dev->priv.cmdif_debugfs); debugfs_remove_recursive(dev->priv.cmdif_debugfs);
} }
int mlx5_cq_debugfs_init(struct mlx5_core_dev *dev) void mlx5_cq_debugfs_init(struct mlx5_core_dev *dev)
{ {
if (!mlx5_debugfs_root)
return 0;
dev->priv.cq_debugfs = debugfs_create_dir("CQs", dev->priv.dbg_root); dev->priv.cq_debugfs = debugfs_create_dir("CQs", dev->priv.dbg_root);
if (!dev->priv.cq_debugfs)
return -ENOMEM;
return 0;
} }
void mlx5_cq_debugfs_cleanup(struct mlx5_core_dev *dev) void mlx5_cq_debugfs_cleanup(struct mlx5_core_dev *dev)
{ {
if (!mlx5_debugfs_root)
return;
debugfs_remove_recursive(dev->priv.cq_debugfs); debugfs_remove_recursive(dev->priv.cq_debugfs);
} }
...@@ -484,7 +418,6 @@ static int add_res_tree(struct mlx5_core_dev *dev, enum dbg_rsc_type type, ...@@ -484,7 +418,6 @@ static int add_res_tree(struct mlx5_core_dev *dev, enum dbg_rsc_type type,
{ {
struct mlx5_rsc_debug *d; struct mlx5_rsc_debug *d;
char resn[32]; char resn[32];
int err;
int i; int i;
d = kzalloc(struct_size(d, fields, nfile), GFP_KERNEL); d = kzalloc(struct_size(d, fields, nfile), GFP_KERNEL);
...@@ -496,30 +429,15 @@ static int add_res_tree(struct mlx5_core_dev *dev, enum dbg_rsc_type type, ...@@ -496,30 +429,15 @@ static int add_res_tree(struct mlx5_core_dev *dev, enum dbg_rsc_type type,
d->type = type; d->type = type;
sprintf(resn, "0x%x", rsn); sprintf(resn, "0x%x", rsn);
d->root = debugfs_create_dir(resn, root); d->root = debugfs_create_dir(resn, root);
if (!d->root) {
err = -ENOMEM;
goto out_free;
}
for (i = 0; i < nfile; i++) { for (i = 0; i < nfile; i++) {
d->fields[i].i = i; d->fields[i].i = i;
d->fields[i].dent = debugfs_create_file(field[i], 0400, debugfs_create_file(field[i], 0400, d->root, &d->fields[i],
d->root, &d->fields[i], &fops);
&fops);
if (!d->fields[i].dent) {
err = -ENOMEM;
goto out_rem;
}
} }
*dbg = d; *dbg = d;
return 0; return 0;
out_rem:
debugfs_remove_recursive(d->root);
out_free:
kfree(d);
return err;
} }
static void rem_res_tree(struct mlx5_rsc_debug *d) static void rem_res_tree(struct mlx5_rsc_debug *d)
......
...@@ -411,7 +411,7 @@ void mlx5_eq_del_cq(struct mlx5_eq *eq, struct mlx5_core_cq *cq) ...@@ -411,7 +411,7 @@ void mlx5_eq_del_cq(struct mlx5_eq *eq, struct mlx5_core_cq *cq)
int mlx5_eq_table_init(struct mlx5_core_dev *dev) int mlx5_eq_table_init(struct mlx5_core_dev *dev)
{ {
struct mlx5_eq_table *eq_table; struct mlx5_eq_table *eq_table;
int i, err; int i;
eq_table = kvzalloc(sizeof(*eq_table), GFP_KERNEL); eq_table = kvzalloc(sizeof(*eq_table), GFP_KERNEL);
if (!eq_table) if (!eq_table)
...@@ -419,9 +419,7 @@ int mlx5_eq_table_init(struct mlx5_core_dev *dev) ...@@ -419,9 +419,7 @@ int mlx5_eq_table_init(struct mlx5_core_dev *dev)
dev->priv.eq_table = eq_table; dev->priv.eq_table = eq_table;
err = mlx5_eq_debugfs_init(dev); mlx5_eq_debugfs_init(dev);
if (err)
goto kvfree_eq_table;
mutex_init(&eq_table->lock); mutex_init(&eq_table->lock);
for (i = 0; i < MLX5_EVENT_TYPE_MAX; i++) for (i = 0; i < MLX5_EVENT_TYPE_MAX; i++)
...@@ -429,11 +427,6 @@ int mlx5_eq_table_init(struct mlx5_core_dev *dev) ...@@ -429,11 +427,6 @@ int mlx5_eq_table_init(struct mlx5_core_dev *dev)
eq_table->irq_table = dev->priv.irq_table; eq_table->irq_table = dev->priv.irq_table;
return 0; return 0;
kvfree_eq_table:
kvfree(eq_table);
dev->priv.eq_table = NULL;
return err;
} }
void mlx5_eq_table_cleanup(struct mlx5_core_dev *dev) void mlx5_eq_table_cleanup(struct mlx5_core_dev *dev)
......
...@@ -87,7 +87,7 @@ void mlx5_eq_synchronize_cmd_irq(struct mlx5_core_dev *dev); ...@@ -87,7 +87,7 @@ void mlx5_eq_synchronize_cmd_irq(struct mlx5_core_dev *dev);
int mlx5_debug_eq_add(struct mlx5_core_dev *dev, struct mlx5_eq *eq); int mlx5_debug_eq_add(struct mlx5_core_dev *dev, struct mlx5_eq *eq);
void mlx5_debug_eq_remove(struct mlx5_core_dev *dev, struct mlx5_eq *eq); void mlx5_debug_eq_remove(struct mlx5_core_dev *dev, struct mlx5_eq *eq);
int mlx5_eq_debugfs_init(struct mlx5_core_dev *dev); void mlx5_eq_debugfs_init(struct mlx5_core_dev *dev);
void mlx5_eq_debugfs_cleanup(struct mlx5_core_dev *dev); void mlx5_eq_debugfs_cleanup(struct mlx5_core_dev *dev);
/* This function should only be called after mlx5_cmd_force_teardown_hca */ /* This function should only be called after mlx5_cmd_force_teardown_hca */
......
...@@ -826,11 +826,7 @@ static int mlx5_init_once(struct mlx5_core_dev *dev) ...@@ -826,11 +826,7 @@ static int mlx5_init_once(struct mlx5_core_dev *dev)
goto err_eq_cleanup; goto err_eq_cleanup;
} }
err = mlx5_cq_debugfs_init(dev); mlx5_cq_debugfs_init(dev);
if (err) {
mlx5_core_err(dev, "failed to initialize cq debugfs\n");
goto err_events_cleanup;
}
mlx5_init_qp_table(dev); mlx5_init_qp_table(dev);
...@@ -891,7 +887,6 @@ static int mlx5_init_once(struct mlx5_core_dev *dev) ...@@ -891,7 +887,6 @@ static int mlx5_init_once(struct mlx5_core_dev *dev)
mlx5_cleanup_mkey_table(dev); mlx5_cleanup_mkey_table(dev);
mlx5_cleanup_qp_table(dev); mlx5_cleanup_qp_table(dev);
mlx5_cq_debugfs_cleanup(dev); mlx5_cq_debugfs_cleanup(dev);
err_events_cleanup:
mlx5_events_cleanup(dev); mlx5_events_cleanup(dev);
err_eq_cleanup: err_eq_cleanup:
mlx5_eq_table_cleanup(dev); mlx5_eq_table_cleanup(dev);
......
...@@ -146,7 +146,7 @@ u64 mlx5_read_internal_timer(struct mlx5_core_dev *dev, ...@@ -146,7 +146,7 @@ u64 mlx5_read_internal_timer(struct mlx5_core_dev *dev,
void mlx5_cmd_trigger_completions(struct mlx5_core_dev *dev); void mlx5_cmd_trigger_completions(struct mlx5_core_dev *dev);
void mlx5_cmd_flush(struct mlx5_core_dev *dev); void mlx5_cmd_flush(struct mlx5_core_dev *dev);
int mlx5_cq_debugfs_init(struct mlx5_core_dev *dev); void mlx5_cq_debugfs_init(struct mlx5_core_dev *dev);
void mlx5_cq_debugfs_cleanup(struct mlx5_core_dev *dev); void mlx5_cq_debugfs_cleanup(struct mlx5_core_dev *dev);
int mlx5_query_pcam_reg(struct mlx5_core_dev *dev, u32 *pcam, u8 feature_group, int mlx5_query_pcam_reg(struct mlx5_core_dev *dev, u32 *pcam, u8 feature_group,
......
...@@ -159,19 +159,13 @@ void nfp_net_debugfs_vnic_add(struct nfp_net *nn, struct dentry *ddir) ...@@ -159,19 +159,13 @@ void nfp_net_debugfs_vnic_add(struct nfp_net *nn, struct dentry *ddir)
else else
strcpy(name, "ctrl-vnic"); strcpy(name, "ctrl-vnic");
nn->debugfs_dir = debugfs_create_dir(name, ddir); nn->debugfs_dir = debugfs_create_dir(name, ddir);
if (IS_ERR_OR_NULL(nn->debugfs_dir))
return;
/* Create queue debugging sub-tree */ /* Create queue debugging sub-tree */
queues = debugfs_create_dir("queue", nn->debugfs_dir); queues = debugfs_create_dir("queue", nn->debugfs_dir);
if (IS_ERR_OR_NULL(queues))
return;
rx = debugfs_create_dir("rx", queues); rx = debugfs_create_dir("rx", queues);
tx = debugfs_create_dir("tx", queues); tx = debugfs_create_dir("tx", queues);
xdp = debugfs_create_dir("xdp", queues); xdp = debugfs_create_dir("xdp", queues);
if (IS_ERR_OR_NULL(rx) || IS_ERR_OR_NULL(tx) || IS_ERR_OR_NULL(xdp))
return;
for (i = 0; i < min(nn->max_rx_rings, nn->max_r_vecs); i++) { for (i = 0; i < min(nn->max_rx_rings, nn->max_r_vecs); i++) {
sprintf(name, "%d", i); sprintf(name, "%d", i);
...@@ -190,16 +184,7 @@ void nfp_net_debugfs_vnic_add(struct nfp_net *nn, struct dentry *ddir) ...@@ -190,16 +184,7 @@ void nfp_net_debugfs_vnic_add(struct nfp_net *nn, struct dentry *ddir)
struct dentry *nfp_net_debugfs_device_add(struct pci_dev *pdev) struct dentry *nfp_net_debugfs_device_add(struct pci_dev *pdev)
{ {
struct dentry *dev_dir; return debugfs_create_dir(pci_name(pdev), nfp_dir);
if (IS_ERR_OR_NULL(nfp_dir))
return NULL;
dev_dir = debugfs_create_dir(pci_name(pdev), nfp_dir);
if (IS_ERR_OR_NULL(dev_dir))
return NULL;
return dev_dir;
} }
void nfp_net_debugfs_dir_clean(struct dentry **dir) void nfp_net_debugfs_dir_clean(struct dentry **dir)
......
...@@ -131,17 +131,10 @@ DEFINE_SHOW_ATTRIBUTE(qcaspi_info); ...@@ -131,17 +131,10 @@ DEFINE_SHOW_ATTRIBUTE(qcaspi_info);
void void
qcaspi_init_device_debugfs(struct qcaspi *qca) qcaspi_init_device_debugfs(struct qcaspi *qca)
{ {
struct dentry *device_root; qca->device_root = debugfs_create_dir(dev_name(&qca->net_dev->dev),
NULL);
device_root = debugfs_create_dir(dev_name(&qca->net_dev->dev), NULL); debugfs_create_file("info", S_IFREG | 0444, qca->device_root, qca,
qca->device_root = device_root;
if (IS_ERR(device_root) || !device_root) {
pr_warn("failed to create debugfs directory for %s\n",
dev_name(&qca->net_dev->dev));
return;
}
debugfs_create_file("info", S_IFREG | 0444, device_root, qca,
&qcaspi_info_fops); &qcaspi_info_fops);
} }
......
...@@ -196,8 +196,6 @@ struct stmmac_priv { ...@@ -196,8 +196,6 @@ struct stmmac_priv {
#ifdef CONFIG_DEBUG_FS #ifdef CONFIG_DEBUG_FS
struct dentry *dbgfs_dir; struct dentry *dbgfs_dir;
struct dentry *dbgfs_rings_status;
struct dentry *dbgfs_dma_cap;
#endif #endif
unsigned long state; unsigned long state;
......
...@@ -105,7 +105,7 @@ MODULE_PARM_DESC(chain_mode, "To use chain instead of ring mode"); ...@@ -105,7 +105,7 @@ MODULE_PARM_DESC(chain_mode, "To use chain instead of ring mode");
static irqreturn_t stmmac_interrupt(int irq, void *dev_id); static irqreturn_t stmmac_interrupt(int irq, void *dev_id);
#ifdef CONFIG_DEBUG_FS #ifdef CONFIG_DEBUG_FS
static int stmmac_init_fs(struct net_device *dev); static void stmmac_init_fs(struct net_device *dev);
static void stmmac_exit_fs(struct net_device *dev); static void stmmac_exit_fs(struct net_device *dev);
#endif #endif
...@@ -3988,45 +3988,20 @@ static int stmmac_dma_cap_show(struct seq_file *seq, void *v) ...@@ -3988,45 +3988,20 @@ static int stmmac_dma_cap_show(struct seq_file *seq, void *v)
} }
DEFINE_SHOW_ATTRIBUTE(stmmac_dma_cap); DEFINE_SHOW_ATTRIBUTE(stmmac_dma_cap);
static int stmmac_init_fs(struct net_device *dev) static void stmmac_init_fs(struct net_device *dev)
{ {
struct stmmac_priv *priv = netdev_priv(dev); struct stmmac_priv *priv = netdev_priv(dev);
/* Create per netdev entries */ /* Create per netdev entries */
priv->dbgfs_dir = debugfs_create_dir(dev->name, stmmac_fs_dir); priv->dbgfs_dir = debugfs_create_dir(dev->name, stmmac_fs_dir);
if (!priv->dbgfs_dir || IS_ERR(priv->dbgfs_dir)) {
netdev_err(priv->dev, "ERROR failed to create debugfs directory\n");
return -ENOMEM;
}
/* Entry to report DMA RX/TX rings */ /* Entry to report DMA RX/TX rings */
priv->dbgfs_rings_status = debugfs_create_file("descriptors_status", 0444, priv->dbgfs_dir, dev,
debugfs_create_file("descriptors_status", 0444, &stmmac_rings_status_fops);
priv->dbgfs_dir, dev,
&stmmac_rings_status_fops);
if (!priv->dbgfs_rings_status || IS_ERR(priv->dbgfs_rings_status)) {
netdev_err(priv->dev, "ERROR creating stmmac ring debugfs file\n");
debugfs_remove_recursive(priv->dbgfs_dir);
return -ENOMEM;
}
/* Entry to report the DMA HW features */ /* Entry to report the DMA HW features */
priv->dbgfs_dma_cap = debugfs_create_file("dma_cap", 0444, debugfs_create_file("dma_cap", 0444, priv->dbgfs_dir, dev,
priv->dbgfs_dir, &stmmac_dma_cap_fops);
dev, &stmmac_dma_cap_fops);
if (!priv->dbgfs_dma_cap || IS_ERR(priv->dbgfs_dma_cap)) {
netdev_err(priv->dev, "ERROR creating stmmac MMC debugfs file\n");
debugfs_remove_recursive(priv->dbgfs_dir);
return -ENOMEM;
}
return 0;
} }
static void stmmac_exit_fs(struct net_device *dev) static void stmmac_exit_fs(struct net_device *dev)
...@@ -4482,10 +4457,7 @@ int stmmac_dvr_probe(struct device *device, ...@@ -4482,10 +4457,7 @@ int stmmac_dvr_probe(struct device *device,
} }
#ifdef CONFIG_DEBUG_FS #ifdef CONFIG_DEBUG_FS
ret = stmmac_init_fs(ndev); stmmac_init_fs(ndev);
if (ret < 0)
netdev_warn(priv->dev, "%s: failed debugFS registration\n",
__func__);
#endif #endif
return ret; return ret;
...@@ -4731,16 +4703,8 @@ static int __init stmmac_init(void) ...@@ -4731,16 +4703,8 @@ static int __init stmmac_init(void)
{ {
#ifdef CONFIG_DEBUG_FS #ifdef CONFIG_DEBUG_FS
/* Create debugfs main directory if it doesn't exist yet */ /* Create debugfs main directory if it doesn't exist yet */
if (!stmmac_fs_dir) { if (!stmmac_fs_dir)
stmmac_fs_dir = debugfs_create_dir(STMMAC_RESOURCE_NAME, NULL); stmmac_fs_dir = debugfs_create_dir(STMMAC_RESOURCE_NAME, NULL);
if (!stmmac_fs_dir || IS_ERR(stmmac_fs_dir)) {
pr_err("ERROR %s, debugfs create directory failed\n",
STMMAC_RESOURCE_NAME);
return -ENOMEM;
}
}
#endif #endif
return 0; return 0;
......
...@@ -1158,23 +1158,16 @@ static int adf7242_stats_show(struct seq_file *file, void *offset) ...@@ -1158,23 +1158,16 @@ static int adf7242_stats_show(struct seq_file *file, void *offset)
return 0; return 0;
} }
static int adf7242_debugfs_init(struct adf7242_local *lp) static void adf7242_debugfs_init(struct adf7242_local *lp)
{ {
char debugfs_dir_name[DNAME_INLINE_LEN + 1] = "adf7242-"; char debugfs_dir_name[DNAME_INLINE_LEN + 1] = "adf7242-";
struct dentry *stats;
strncat(debugfs_dir_name, dev_name(&lp->spi->dev), DNAME_INLINE_LEN); strncat(debugfs_dir_name, dev_name(&lp->spi->dev), DNAME_INLINE_LEN);
lp->debugfs_root = debugfs_create_dir(debugfs_dir_name, NULL); lp->debugfs_root = debugfs_create_dir(debugfs_dir_name, NULL);
if (IS_ERR_OR_NULL(lp->debugfs_root))
return PTR_ERR_OR_ZERO(lp->debugfs_root);
stats = debugfs_create_devm_seqfile(&lp->spi->dev, "status", debugfs_create_devm_seqfile(&lp->spi->dev, "status", lp->debugfs_root,
lp->debugfs_root, adf7242_stats_show);
adf7242_stats_show);
return PTR_ERR_OR_ZERO(stats);
return 0;
} }
static const s32 adf7242_powers[] = { static const s32 adf7242_powers[] = {
......
...@@ -1626,24 +1626,16 @@ static int at86rf230_stats_show(struct seq_file *file, void *offset) ...@@ -1626,24 +1626,16 @@ static int at86rf230_stats_show(struct seq_file *file, void *offset)
} }
DEFINE_SHOW_ATTRIBUTE(at86rf230_stats); DEFINE_SHOW_ATTRIBUTE(at86rf230_stats);
static int at86rf230_debugfs_init(struct at86rf230_local *lp) static void at86rf230_debugfs_init(struct at86rf230_local *lp)
{ {
char debugfs_dir_name[DNAME_INLINE_LEN + 1] = "at86rf230-"; char debugfs_dir_name[DNAME_INLINE_LEN + 1] = "at86rf230-";
struct dentry *stats;
strncat(debugfs_dir_name, dev_name(&lp->spi->dev), DNAME_INLINE_LEN); strncat(debugfs_dir_name, dev_name(&lp->spi->dev), DNAME_INLINE_LEN);
at86rf230_debugfs_root = debugfs_create_dir(debugfs_dir_name, NULL); at86rf230_debugfs_root = debugfs_create_dir(debugfs_dir_name, NULL);
if (!at86rf230_debugfs_root)
return -ENOMEM;
stats = debugfs_create_file("trac_stats", 0444,
at86rf230_debugfs_root, lp,
&at86rf230_stats_fops);
if (!stats)
return -ENOMEM;
return 0; debugfs_create_file("trac_stats", 0444, at86rf230_debugfs_root, lp,
&at86rf230_stats_fops);
} }
static void at86rf230_debugfs_remove(void) static void at86rf230_debugfs_remove(void)
...@@ -1651,7 +1643,7 @@ static void at86rf230_debugfs_remove(void) ...@@ -1651,7 +1643,7 @@ static void at86rf230_debugfs_remove(void)
debugfs_remove_recursive(at86rf230_debugfs_root); debugfs_remove_recursive(at86rf230_debugfs_root);
} }
#else #else
static int at86rf230_debugfs_init(struct at86rf230_local *lp) { return 0; } static void at86rf230_debugfs_init(struct at86rf230_local *lp) { }
static void at86rf230_debugfs_remove(void) { } static void at86rf230_debugfs_remove(void) { }
#endif #endif
...@@ -1751,9 +1743,7 @@ static int at86rf230_probe(struct spi_device *spi) ...@@ -1751,9 +1743,7 @@ static int at86rf230_probe(struct spi_device *spi)
/* going into sleep by default */ /* going into sleep by default */
at86rf230_sleep(lp); at86rf230_sleep(lp);
rc = at86rf230_debugfs_init(lp); at86rf230_debugfs_init(lp);
if (rc)
goto free_dev;
rc = ieee802154_register_hw(lp->hw); rc = ieee802154_register_hw(lp->hw);
if (rc) if (rc)
......
...@@ -3019,14 +3019,7 @@ static int ca8210_test_interface_init(struct ca8210_priv *priv) ...@@ -3019,14 +3019,7 @@ static int ca8210_test_interface_init(struct ca8210_priv *priv)
priv, priv,
&test_int_fops &test_int_fops
); );
if (IS_ERR(test->ca8210_dfs_spi_int)) {
dev_err(
&priv->spi->dev,
"Error %ld when creating debugfs node\n",
PTR_ERR(test->ca8210_dfs_spi_int)
);
return PTR_ERR(test->ca8210_dfs_spi_int);
}
debugfs_create_symlink("ca8210", NULL, node_name); debugfs_create_symlink("ca8210", NULL, node_name);
init_waitqueue_head(&test->readq); init_waitqueue_head(&test->readq);
return kfifo_alloc( return kfifo_alloc(
......
...@@ -30,15 +30,6 @@ DEFINE_SIMPLE_ATTRIBUTE(fops_netdev_queue_stopped, ...@@ -30,15 +30,6 @@ DEFINE_SIMPLE_ATTRIBUTE(fops_netdev_queue_stopped,
debugfs_netdev_queue_stopped_get, debugfs_netdev_queue_stopped_get,
NULL, "%llu\n"); NULL, "%llu\n");
static
struct dentry *debugfs_create_netdev_queue_stopped(
const char *name, struct dentry *parent, struct i2400m *i2400m)
{
return debugfs_create_file(name, 0400, parent, i2400m,
&fops_netdev_queue_stopped);
}
/* /*
* We don't allow partial reads of this file, as then the reader would * We don't allow partial reads of this file, as then the reader would
* get weirdly confused data as it is updated. * get weirdly confused data as it is updated.
...@@ -167,15 +158,6 @@ DEFINE_SIMPLE_ATTRIBUTE(fops_i2400m_suspend, ...@@ -167,15 +158,6 @@ DEFINE_SIMPLE_ATTRIBUTE(fops_i2400m_suspend,
NULL, debugfs_i2400m_suspend_set, NULL, debugfs_i2400m_suspend_set,
"%llu\n"); "%llu\n");
static
struct dentry *debugfs_create_i2400m_suspend(
const char *name, struct dentry *parent, struct i2400m *i2400m)
{
return debugfs_create_file(name, 0200, parent, i2400m,
&fops_i2400m_suspend);
}
/* /*
* Reset the device * Reset the device
* *
...@@ -205,73 +187,25 @@ DEFINE_SIMPLE_ATTRIBUTE(fops_i2400m_reset, ...@@ -205,73 +187,25 @@ DEFINE_SIMPLE_ATTRIBUTE(fops_i2400m_reset,
NULL, debugfs_i2400m_reset_set, NULL, debugfs_i2400m_reset_set,
"%llu\n"); "%llu\n");
static void i2400m_debugfs_add(struct i2400m *i2400m)
struct dentry *debugfs_create_i2400m_reset(
const char *name, struct dentry *parent, struct i2400m *i2400m)
{ {
return debugfs_create_file(name, 0200, parent, i2400m,
&fops_i2400m_reset);
}
#define __debugfs_register(prefix, name, parent) \
do { \
result = d_level_register_debugfs(prefix, name, parent); \
if (result < 0) \
goto error; \
} while (0)
int i2400m_debugfs_add(struct i2400m *i2400m)
{
int result;
struct device *dev = i2400m_dev(i2400m);
struct dentry *dentry = i2400m->wimax_dev.debugfs_dentry; struct dentry *dentry = i2400m->wimax_dev.debugfs_dentry;
struct dentry *fd;
dentry = debugfs_create_dir("i2400m", dentry); dentry = debugfs_create_dir("i2400m", dentry);
result = PTR_ERR(dentry);
if (IS_ERR(dentry)) {
if (result == -ENODEV)
result = 0; /* No debugfs support */
goto error;
}
i2400m->debugfs_dentry = dentry; i2400m->debugfs_dentry = dentry;
__debugfs_register("dl_", control, dentry);
__debugfs_register("dl_", driver, dentry);
__debugfs_register("dl_", debugfs, dentry);
__debugfs_register("dl_", fw, dentry);
__debugfs_register("dl_", netdev, dentry);
__debugfs_register("dl_", rfkill, dentry);
__debugfs_register("dl_", rx, dentry);
__debugfs_register("dl_", tx, dentry);
fd = debugfs_create_size_t("tx_in", 0400, dentry,
&i2400m->tx_in);
result = PTR_ERR(fd);
if (IS_ERR(fd) && result != -ENODEV) {
dev_err(dev, "Can't create debugfs entry "
"tx_in: %d\n", result);
goto error;
}
fd = debugfs_create_size_t("tx_out", 0400, dentry, d_level_register_debugfs("dl_", control, dentry);
&i2400m->tx_out); d_level_register_debugfs("dl_", driver, dentry);
result = PTR_ERR(fd); d_level_register_debugfs("dl_", debugfs, dentry);
if (IS_ERR(fd) && result != -ENODEV) { d_level_register_debugfs("dl_", fw, dentry);
dev_err(dev, "Can't create debugfs entry " d_level_register_debugfs("dl_", netdev, dentry);
"tx_out: %d\n", result); d_level_register_debugfs("dl_", rfkill, dentry);
goto error; d_level_register_debugfs("dl_", rx, dentry);
} d_level_register_debugfs("dl_", tx, dentry);
fd = debugfs_create_u32("state", 0600, dentry, debugfs_create_size_t("tx_in", 0400, dentry, &i2400m->tx_in);
&i2400m->state); debugfs_create_size_t("tx_out", 0400, dentry, &i2400m->tx_out);
result = PTR_ERR(fd); debugfs_create_u32("state", 0600, dentry, &i2400m->state);
if (IS_ERR(fd) && result != -ENODEV) {
dev_err(dev, "Can't create debugfs entry "
"state: %d\n", result);
goto error;
}
/* /*
* Trace received messages from user space * Trace received messages from user space
...@@ -295,60 +229,22 @@ int i2400m_debugfs_add(struct i2400m *i2400m) ...@@ -295,60 +229,22 @@ int i2400m_debugfs_add(struct i2400m *i2400m)
* It is not really very atomic, but it is also not too * It is not really very atomic, but it is also not too
* critical. * critical.
*/ */
fd = debugfs_create_u8("trace_msg_from_user", 0600, dentry, debugfs_create_u8("trace_msg_from_user", 0600, dentry,
&i2400m->trace_msg_from_user); &i2400m->trace_msg_from_user);
result = PTR_ERR(fd);
if (IS_ERR(fd) && result != -ENODEV) {
dev_err(dev, "Can't create debugfs entry "
"trace_msg_from_user: %d\n", result);
goto error;
}
fd = debugfs_create_netdev_queue_stopped("netdev_queue_stopped", debugfs_create_file("netdev_queue_stopped", 0400, dentry, i2400m,
dentry, i2400m); &fops_netdev_queue_stopped);
result = PTR_ERR(fd);
if (IS_ERR(fd) && result != -ENODEV) {
dev_err(dev, "Can't create debugfs entry "
"netdev_queue_stopped: %d\n", result);
goto error;
}
fd = debugfs_create_file("rx_stats", 0600, dentry, i2400m, debugfs_create_file("rx_stats", 0600, dentry, i2400m,
&i2400m_rx_stats_fops); &i2400m_rx_stats_fops);
result = PTR_ERR(fd);
if (IS_ERR(fd) && result != -ENODEV) {
dev_err(dev, "Can't create debugfs entry "
"rx_stats: %d\n", result);
goto error;
}
fd = debugfs_create_file("tx_stats", 0600, dentry, i2400m, debugfs_create_file("tx_stats", 0600, dentry, i2400m,
&i2400m_tx_stats_fops); &i2400m_tx_stats_fops);
result = PTR_ERR(fd);
if (IS_ERR(fd) && result != -ENODEV) {
dev_err(dev, "Can't create debugfs entry "
"tx_stats: %d\n", result);
goto error;
}
fd = debugfs_create_i2400m_suspend("suspend", dentry, i2400m); debugfs_create_file("suspend", 0200, dentry, i2400m,
result = PTR_ERR(fd); &fops_i2400m_suspend);
if (IS_ERR(fd) && result != -ENODEV) {
dev_err(dev, "Can't create debugfs entry suspend: %d\n",
result);
goto error;
}
fd = debugfs_create_i2400m_reset("reset", dentry, i2400m); debugfs_create_file("reset", 0200, dentry, i2400m, &fops_i2400m_reset);
result = PTR_ERR(fd);
if (IS_ERR(fd) && result != -ENODEV) {
dev_err(dev, "Can't create debugfs entry reset: %d\n", result);
goto error;
}
result = 0;
error:
return result;
} }
void i2400m_debugfs_rm(struct i2400m *i2400m) void i2400m_debugfs_rm(struct i2400m *i2400m)
......
...@@ -905,11 +905,7 @@ int i2400m_setup(struct i2400m *i2400m, enum i2400m_bri bm_flags) ...@@ -905,11 +905,7 @@ int i2400m_setup(struct i2400m *i2400m, enum i2400m_bri bm_flags)
goto error_sysfs_setup; goto error_sysfs_setup;
} }
result = i2400m_debugfs_add(i2400m); i2400m_debugfs_add(i2400m);
if (result < 0) {
dev_err(dev, "cannot setup i2400m's debugfs: %d\n", result);
goto error_debugfs_setup;
}
result = i2400m_dev_start(i2400m, bm_flags); result = i2400m_dev_start(i2400m, bm_flags);
if (result < 0) if (result < 0)
...@@ -919,7 +915,6 @@ int i2400m_setup(struct i2400m *i2400m, enum i2400m_bri bm_flags) ...@@ -919,7 +915,6 @@ int i2400m_setup(struct i2400m *i2400m, enum i2400m_bri bm_flags)
error_dev_start: error_dev_start:
i2400m_debugfs_rm(i2400m); i2400m_debugfs_rm(i2400m);
error_debugfs_setup:
sysfs_remove_group(&i2400m->wimax_dev.net_dev->dev.kobj, sysfs_remove_group(&i2400m->wimax_dev.net_dev->dev.kobj,
&i2400m_dev_attr_group); &i2400m_dev_attr_group);
error_sysfs_setup: error_sysfs_setup:
......
...@@ -812,13 +812,10 @@ enum i2400m_pt; ...@@ -812,13 +812,10 @@ enum i2400m_pt;
int i2400m_tx(struct i2400m *, const void *, size_t, enum i2400m_pt); int i2400m_tx(struct i2400m *, const void *, size_t, enum i2400m_pt);
#ifdef CONFIG_DEBUG_FS #ifdef CONFIG_DEBUG_FS
int i2400m_debugfs_add(struct i2400m *); void i2400m_debugfs_add(struct i2400m *);
void i2400m_debugfs_rm(struct i2400m *); void i2400m_debugfs_rm(struct i2400m *);
#else #else
static inline int i2400m_debugfs_add(struct i2400m *i2400m) static inline void i2400m_debugfs_add(struct i2400m *i2400m) {}
{
return 0;
}
static inline void i2400m_debugfs_rm(struct i2400m *i2400m) {} static inline void i2400m_debugfs_rm(struct i2400m *i2400m) {}
#endif #endif
......
...@@ -366,61 +366,25 @@ struct d_level D_LEVEL[] = { ...@@ -366,61 +366,25 @@ struct d_level D_LEVEL[] = {
}; };
size_t D_LEVEL_SIZE = ARRAY_SIZE(D_LEVEL); size_t D_LEVEL_SIZE = ARRAY_SIZE(D_LEVEL);
#define __debugfs_register(prefix, name, parent) \
do { \
result = d_level_register_debugfs(prefix, name, parent); \
if (result < 0) \
goto error; \
} while (0)
static static
int i2400mu_debugfs_add(struct i2400mu *i2400mu) void i2400mu_debugfs_add(struct i2400mu *i2400mu)
{ {
int result;
struct device *dev = &i2400mu->usb_iface->dev;
struct dentry *dentry = i2400mu->i2400m.wimax_dev.debugfs_dentry; struct dentry *dentry = i2400mu->i2400m.wimax_dev.debugfs_dentry;
struct dentry *fd;
dentry = debugfs_create_dir("i2400m-usb", dentry); dentry = debugfs_create_dir("i2400m-usb", dentry);
result = PTR_ERR(dentry);
if (IS_ERR(dentry)) {
if (result == -ENODEV)
result = 0; /* No debugfs support */
goto error;
}
i2400mu->debugfs_dentry = dentry; i2400mu->debugfs_dentry = dentry;
__debugfs_register("dl_", usb, dentry);
__debugfs_register("dl_", fw, dentry);
__debugfs_register("dl_", notif, dentry);
__debugfs_register("dl_", rx, dentry);
__debugfs_register("dl_", tx, dentry);
/* Don't touch these if you don't know what you are doing */ d_level_register_debugfs("dl_", usb, dentry);
fd = debugfs_create_u8("rx_size_auto_shrink", 0600, dentry, d_level_register_debugfs("dl_", fw, dentry);
&i2400mu->rx_size_auto_shrink); d_level_register_debugfs("dl_", notif, dentry);
result = PTR_ERR(fd); d_level_register_debugfs("dl_", rx, dentry);
if (IS_ERR(fd) && result != -ENODEV) { d_level_register_debugfs("dl_", tx, dentry);
dev_err(dev, "Can't create debugfs entry "
"rx_size_auto_shrink: %d\n", result);
goto error;
}
fd = debugfs_create_size_t("rx_size", 0600, dentry, /* Don't touch these if you don't know what you are doing */
&i2400mu->rx_size); debugfs_create_u8("rx_size_auto_shrink", 0600, dentry,
result = PTR_ERR(fd); &i2400mu->rx_size_auto_shrink);
if (IS_ERR(fd) && result != -ENODEV) {
dev_err(dev, "Can't create debugfs entry "
"rx_size: %d\n", result);
goto error;
}
return 0;
error: debugfs_create_size_t("rx_size", 0600, dentry, &i2400mu->rx_size);
debugfs_remove_recursive(i2400mu->debugfs_dentry);
return result;
} }
...@@ -534,15 +498,9 @@ int i2400mu_probe(struct usb_interface *iface, ...@@ -534,15 +498,9 @@ int i2400mu_probe(struct usb_interface *iface,
dev_err(dev, "cannot setup device: %d\n", result); dev_err(dev, "cannot setup device: %d\n", result);
goto error_setup; goto error_setup;
} }
result = i2400mu_debugfs_add(i2400mu); i2400mu_debugfs_add(i2400mu);
if (result < 0) {
dev_err(dev, "Can't register i2400mu's debugfs: %d\n", result);
goto error_debugfs_add;
}
return 0; return 0;
error_debugfs_add:
i2400m_release(i2400m);
error_setup: error_setup:
usb_set_intfdata(iface, NULL); usb_set_intfdata(iface, NULL);
usb_put_dev(i2400mu->usb_dev); usb_put_dev(i2400mu->usb_dev);
......
...@@ -189,7 +189,6 @@ enum mlx5_coredev_type { ...@@ -189,7 +189,6 @@ enum mlx5_coredev_type {
}; };
struct mlx5_field_desc { struct mlx5_field_desc {
struct dentry *dent;
int i; int i;
}; };
...@@ -242,11 +241,6 @@ struct mlx5_cmd_msg { ...@@ -242,11 +241,6 @@ struct mlx5_cmd_msg {
struct mlx5_cmd_debug { struct mlx5_cmd_debug {
struct dentry *dbg_root; struct dentry *dbg_root;
struct dentry *dbg_in;
struct dentry *dbg_out;
struct dentry *dbg_outlen;
struct dentry *dbg_status;
struct dentry *dbg_run;
void *in_msg; void *in_msg;
void *out_msg; void *out_msg;
u8 status; u8 status;
...@@ -271,8 +265,6 @@ struct mlx5_cmd_stats { ...@@ -271,8 +265,6 @@ struct mlx5_cmd_stats {
u64 sum; u64 sum;
u64 n; u64 n;
struct dentry *root; struct dentry *root;
struct dentry *avg;
struct dentry *count;
/* protect command average calculations */ /* protect command average calculations */
spinlock_t lock; spinlock_t lock;
}; };
...@@ -972,7 +964,7 @@ int mlx5_vector2eqn(struct mlx5_core_dev *dev, int vector, int *eqn, ...@@ -972,7 +964,7 @@ int mlx5_vector2eqn(struct mlx5_core_dev *dev, int vector, int *eqn,
int mlx5_core_attach_mcg(struct mlx5_core_dev *dev, union ib_gid *mgid, u32 qpn); int mlx5_core_attach_mcg(struct mlx5_core_dev *dev, union ib_gid *mgid, u32 qpn);
int mlx5_core_detach_mcg(struct mlx5_core_dev *dev, union ib_gid *mgid, u32 qpn); int mlx5_core_detach_mcg(struct mlx5_core_dev *dev, union ib_gid *mgid, u32 qpn);
int mlx5_qp_debugfs_init(struct mlx5_core_dev *dev); void mlx5_qp_debugfs_init(struct mlx5_core_dev *dev);
void mlx5_qp_debugfs_cleanup(struct mlx5_core_dev *dev); void mlx5_qp_debugfs_cleanup(struct mlx5_core_dev *dev);
int mlx5_core_access_reg(struct mlx5_core_dev *dev, void *data_in, int mlx5_core_access_reg(struct mlx5_core_dev *dev, void *data_in,
int size_in, void *data_out, int size_out, int size_in, void *data_out, int size_out,
...@@ -984,7 +976,7 @@ int mlx5_db_alloc_node(struct mlx5_core_dev *dev, struct mlx5_db *db, ...@@ -984,7 +976,7 @@ int mlx5_db_alloc_node(struct mlx5_core_dev *dev, struct mlx5_db *db,
void mlx5_db_free(struct mlx5_core_dev *dev, struct mlx5_db *db); void mlx5_db_free(struct mlx5_core_dev *dev, struct mlx5_db *db);
const char *mlx5_command_str(int command); const char *mlx5_command_str(int command);
int mlx5_cmdif_debugfs_init(struct mlx5_core_dev *dev); void mlx5_cmdif_debugfs_init(struct mlx5_core_dev *dev);
void mlx5_cmdif_debugfs_cleanup(struct mlx5_core_dev *dev); void mlx5_cmdif_debugfs_cleanup(struct mlx5_core_dev *dev);
int mlx5_core_create_psv(struct mlx5_core_dev *dev, u32 pdn, int mlx5_core_create_psv(struct mlx5_core_dev *dev, u32 pdn,
int npsvs, u32 *sig_index); int npsvs, u32 *sig_index);
......
...@@ -98,9 +98,7 @@ ...@@ -98,9 +98,7 @@
* To manipulate from user space the levels, create a debugfs dentry * To manipulate from user space the levels, create a debugfs dentry
* and then register each submodule with: * and then register each submodule with:
* *
* result = d_level_register_debugfs("PREFIX_", submodule_X, parent); * d_level_register_debugfs("PREFIX_", submodule_X, parent);
* if (result < 0)
* goto error;
* *
* Where PREFIX_ is a name of your chosing. This will create debugfs * Where PREFIX_ is a name of your chosing. This will create debugfs
* file with a single numeric value that can be use to tweak it. To * file with a single numeric value that can be use to tweak it. To
...@@ -408,25 +406,13 @@ do { \ ...@@ -408,25 +406,13 @@ do { \
* @submodule: name of submodule (not a string, just the name) * @submodule: name of submodule (not a string, just the name)
* @dentry: debugfs parent dentry * @dentry: debugfs parent dentry
* *
* Returns: 0 if ok, < 0 errno on error.
*
* For removing, just use debugfs_remove_recursive() on the parent. * For removing, just use debugfs_remove_recursive() on the parent.
*/ */
#define d_level_register_debugfs(prefix, name, parent) \ #define d_level_register_debugfs(prefix, name, parent) \
({ \ ({ \
int rc; \ debugfs_create_u8( \
struct dentry *fd; \ prefix #name, 0600, parent, \
struct dentry *verify_parent_type = parent; \
fd = debugfs_create_u8( \
prefix #name, 0600, verify_parent_type, \
&(D_LEVEL[__D_SUBMODULE_ ## name].level)); \ &(D_LEVEL[__D_SUBMODULE_ ## name].level)); \
rc = PTR_ERR(fd); \
if (IS_ERR(fd) && rc != -ENODEV) \
printk(KERN_ERR "%s: Can't create debugfs entry %s: " \
"%d\n", __func__, prefix #name, rc); \
else \
rc = 0; \
rc; \
}) })
......
...@@ -13,49 +13,23 @@ ...@@ -13,49 +13,23 @@
#define D_SUBMODULE debugfs #define D_SUBMODULE debugfs
#include "debug-levels.h" #include "debug-levels.h"
void wimax_debugfs_add(struct wimax_dev *wimax_dev)
#define __debugfs_register(prefix, name, parent) \
do { \
result = d_level_register_debugfs(prefix, name, parent); \
if (result < 0) \
goto error; \
} while (0)
int wimax_debugfs_add(struct wimax_dev *wimax_dev)
{ {
int result;
struct net_device *net_dev = wimax_dev->net_dev; struct net_device *net_dev = wimax_dev->net_dev;
struct device *dev = net_dev->dev.parent;
struct dentry *dentry; struct dentry *dentry;
char buf[128]; char buf[128];
snprintf(buf, sizeof(buf), "wimax:%s", net_dev->name); snprintf(buf, sizeof(buf), "wimax:%s", net_dev->name);
dentry = debugfs_create_dir(buf, NULL); dentry = debugfs_create_dir(buf, NULL);
result = PTR_ERR(dentry);
if (IS_ERR(dentry)) {
if (result == -ENODEV)
result = 0; /* No debugfs support */
else
dev_err(dev, "Can't create debugfs dentry: %d\n",
result);
goto out;
}
wimax_dev->debugfs_dentry = dentry; wimax_dev->debugfs_dentry = dentry;
__debugfs_register("wimax_dl_", debugfs, dentry);
__debugfs_register("wimax_dl_", id_table, dentry);
__debugfs_register("wimax_dl_", op_msg, dentry);
__debugfs_register("wimax_dl_", op_reset, dentry);
__debugfs_register("wimax_dl_", op_rfkill, dentry);
__debugfs_register("wimax_dl_", op_state_get, dentry);
__debugfs_register("wimax_dl_", stack, dentry);
result = 0;
out:
return result;
error: d_level_register_debugfs("wimax_dl_", debugfs, dentry);
debugfs_remove_recursive(wimax_dev->debugfs_dentry); d_level_register_debugfs("wimax_dl_", id_table, dentry);
return result; d_level_register_debugfs("wimax_dl_", op_msg, dentry);
d_level_register_debugfs("wimax_dl_", op_reset, dentry);
d_level_register_debugfs("wimax_dl_", op_rfkill, dentry);
d_level_register_debugfs("wimax_dl_", op_state_get, dentry);
d_level_register_debugfs("wimax_dl_", stack, dentry);
} }
void wimax_debugfs_rm(struct wimax_dev *wimax_dev) void wimax_debugfs_rm(struct wimax_dev *wimax_dev)
......
...@@ -481,12 +481,7 @@ int wimax_dev_add(struct wimax_dev *wimax_dev, struct net_device *net_dev) ...@@ -481,12 +481,7 @@ int wimax_dev_add(struct wimax_dev *wimax_dev, struct net_device *net_dev)
/* Set up user-space interaction */ /* Set up user-space interaction */
mutex_lock(&wimax_dev->mutex); mutex_lock(&wimax_dev->mutex);
wimax_id_table_add(wimax_dev); wimax_id_table_add(wimax_dev);
result = wimax_debugfs_add(wimax_dev); wimax_debugfs_add(wimax_dev);
if (result < 0) {
dev_err(dev, "cannot initialize debugfs: %d\n",
result);
goto error_debugfs_add;
}
__wimax_state_set(wimax_dev, WIMAX_ST_DOWN); __wimax_state_set(wimax_dev, WIMAX_ST_DOWN);
mutex_unlock(&wimax_dev->mutex); mutex_unlock(&wimax_dev->mutex);
...@@ -498,10 +493,6 @@ int wimax_dev_add(struct wimax_dev *wimax_dev, struct net_device *net_dev) ...@@ -498,10 +493,6 @@ int wimax_dev_add(struct wimax_dev *wimax_dev, struct net_device *net_dev)
d_fnend(3, dev, "(wimax_dev %p net_dev %p) = 0\n", wimax_dev, net_dev); d_fnend(3, dev, "(wimax_dev %p net_dev %p) = 0\n", wimax_dev, net_dev);
return 0; return 0;
error_debugfs_add:
wimax_id_table_rm(wimax_dev);
mutex_unlock(&wimax_dev->mutex);
wimax_rfkill_rm(wimax_dev);
error_rfkill_add: error_rfkill_add:
d_fnend(3, dev, "(wimax_dev %p net_dev %p) = %d\n", d_fnend(3, dev, "(wimax_dev %p net_dev %p) = %d\n",
wimax_dev, net_dev, result); wimax_dev, net_dev, result);
......
...@@ -57,13 +57,10 @@ void __wimax_state_set(struct wimax_dev *wimax_dev, enum wimax_st state) ...@@ -57,13 +57,10 @@ void __wimax_state_set(struct wimax_dev *wimax_dev, enum wimax_st state)
void __wimax_state_change(struct wimax_dev *, enum wimax_st); void __wimax_state_change(struct wimax_dev *, enum wimax_st);
#ifdef CONFIG_DEBUG_FS #ifdef CONFIG_DEBUG_FS
int wimax_debugfs_add(struct wimax_dev *); void wimax_debugfs_add(struct wimax_dev *);
void wimax_debugfs_rm(struct wimax_dev *); void wimax_debugfs_rm(struct wimax_dev *);
#else #else
static inline int wimax_debugfs_add(struct wimax_dev *wimax_dev) static inline void wimax_debugfs_add(struct wimax_dev *wimax_dev) {}
{
return 0;
}
static inline void wimax_debugfs_rm(struct wimax_dev *wimax_dev) {} static inline void wimax_debugfs_rm(struct wimax_dev *wimax_dev) {}
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment