Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions drivers/net/ethernet/stmicro/stmmac/stmmac.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ struct stmmac_priv {
int use_riwt;
int irq_wake;
spinlock_t ptp_lock;
#ifdef CONFIG_STMMAC_DEBUG_FS
struct dentry *dbgfs_dir;
struct dentry *dbgfs_rings_status;
struct dentry *dbgfs_dma_cap;
#endif
};

int stmmac_mdio_unregister(struct net_device *ndev);
Expand Down
126 changes: 73 additions & 53 deletions drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ static irqreturn_t stmmac_interrupt(int irq, void *dev_id);

#ifdef CONFIG_STMMAC_DEBUG_FS
static int stmmac_init_fs(struct net_device *dev);
static void stmmac_exit_fs(void);
static void stmmac_exit_fs(struct net_device *dev);
#endif

#define STMMAC_COAL_TIMER(x) (jiffies + usecs_to_jiffies(x))
Expand Down Expand Up @@ -2399,7 +2399,7 @@ static int stmmac_release(struct net_device *dev)
netif_carrier_off(dev);

#ifdef CONFIG_STMMAC_DEBUG_FS
stmmac_exit_fs();
stmmac_exit_fs(dev);
#endif

stmmac_release_ptp(priv);
Expand Down Expand Up @@ -2991,8 +2991,6 @@ static int stmmac_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)

#ifdef CONFIG_STMMAC_DEBUG_FS
static struct dentry *stmmac_fs_dir;
static struct dentry *stmmac_rings_status;
static struct dentry *stmmac_dma_cap;

static void sysfs_display_ring(void *head, int size, int extend_desc,
struct seq_file *seq)
Expand Down Expand Up @@ -3131,48 +3129,51 @@ static const struct file_operations stmmac_dma_cap_fops = {

static int stmmac_init_fs(struct net_device *dev)
{
/* Create debugfs entries */
stmmac_fs_dir = debugfs_create_dir(STMMAC_RESOURCE_NAME, NULL);
struct stmmac_priv *priv = netdev_priv(dev);

/* Create per netdev entries */
priv->dbgfs_dir = debugfs_create_dir(dev->name, stmmac_fs_dir);

if (!stmmac_fs_dir || IS_ERR(stmmac_fs_dir)) {
pr_err("ERROR %s, debugfs create directory failed\n",
STMMAC_RESOURCE_NAME);
if (!priv->dbgfs_dir || IS_ERR(priv->dbgfs_dir)) {
pr_err("ERROR %s/%s, debugfs create directory failed\n",
STMMAC_RESOURCE_NAME, dev->name);

return -ENOMEM;
}

/* Entry to report DMA RX/TX rings */
stmmac_rings_status = debugfs_create_file("descriptors_status",
S_IRUGO, stmmac_fs_dir, dev,
&stmmac_rings_status_fops);
priv->dbgfs_rings_status =
debugfs_create_file("descriptors_status", S_IRUGO,
priv->dbgfs_dir, dev,
&stmmac_rings_status_fops);

if (!stmmac_rings_status || IS_ERR(stmmac_rings_status)) {
pr_debug("ERROR creating stmmac ring debugfs file\n");
debugfs_remove(stmmac_fs_dir);
if (!priv->dbgfs_rings_status || IS_ERR(priv->dbgfs_rings_status)) {
pr_info("ERROR creating stmmac ring debugfs file\n");
debugfs_remove_recursive(priv->dbgfs_dir);

return -ENOMEM;
}

/* Entry to report the DMA HW features */
stmmac_dma_cap = debugfs_create_file("dma_cap", S_IRUGO, stmmac_fs_dir,
dev, &stmmac_dma_cap_fops);
priv->dbgfs_dma_cap = debugfs_create_file("dma_cap", S_IRUGO,
priv->dbgfs_dir,
dev, &stmmac_dma_cap_fops);

if (!stmmac_dma_cap || IS_ERR(stmmac_dma_cap)) {
pr_debug("ERROR creating stmmac MMC debugfs file\n");
debugfs_remove(stmmac_rings_status);
debugfs_remove(stmmac_fs_dir);
if (!priv->dbgfs_dma_cap || IS_ERR(priv->dbgfs_dma_cap)) {
pr_info("ERROR creating stmmac MMC debugfs file\n");
debugfs_remove_recursive(priv->dbgfs_dir);

return -ENOMEM;
}

return 0;
}

static void stmmac_exit_fs(void)
static void stmmac_exit_fs(struct net_device *dev)
{
debugfs_remove(stmmac_rings_status);
debugfs_remove(stmmac_dma_cap);
debugfs_remove(stmmac_fs_dir);
struct stmmac_priv *priv = netdev_priv(dev);

debugfs_remove_recursive(priv->dbgfs_dir);
}
#endif /* CONFIG_STMMAC_DEBUG_FS */

Expand Down Expand Up @@ -3563,34 +3564,6 @@ int stmmac_resume(struct net_device *ndev)
}
#endif /* CONFIG_PM */

/* Driver can be configured w/ and w/ both PCI and Platf drivers
* depending on the configuration selected.
*/
static int __init stmmac_init(void)
{
int ret;

ret = stmmac_register_platform();
if (ret)
goto err;
ret = stmmac_register_pci();
if (ret)
goto err_pci;
return 0;
err_pci:
stmmac_unregister_platform();
err:
pr_err("stmmac: driver registration failed\n");
return ret;
}
static void __exit stmmac_exit(void)
{
stmmac_unregister_platform();
stmmac_unregister_pci();
}

module_init(stmmac_init);
module_exit(stmmac_exit);

#ifndef MODULE
static int __init stmmac_cmdline_opt(char *str)
Expand Down Expand Up @@ -3645,6 +3618,53 @@ static int __init stmmac_cmdline_opt(char *str)
__setup("stmmaceth=", stmmac_cmdline_opt);
#endif /* MODULE */

/* Driver can be configured w/ and w/ both PCI and Platf drivers
* depending on the configuration selected.
*/
static int __init stmmac_init(void)
{
#ifdef CONFIG_STMMAC_DEBUG_FS
/* Create debugfs main directory if it doesn't exist yet */
if (!stmmac_fs_dir) {
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
int ret;

ret = stmmac_register_platform();
if (ret)
goto err;
ret = stmmac_register_pci();
if (ret)
goto err_pci;
return 0;
err_pci:
stmmac_unregister_platform();
err:
pr_err("stmmac: driver registration failed\n");
return ret;
}

static void __exit stmmac_exit(void)
{
stmmac_unregister_platform();
stmmac_unregister_pci();
#ifdef CONFIG_STMMAC_DEBUG_FS
debugfs_remove_recursive(stmmac_fs_dir);
#endif
}

module_init(stmmac_init)
module_exit(stmmac_exit)


MODULE_DESCRIPTION("STMMAC 10/100/1000 Ethernet device driver");
MODULE_AUTHOR("Giuseppe Cavallaro <peppe.cavallaro@st.com>");
MODULE_LICENSE("GPL");