Skip to content

Commit

Permalink
net: wwan: core: make debugfs optional
Browse files Browse the repository at this point in the history
Current WWAN debugfs interface does not take too much space, but it is
useless without driver-specific debugfs interfaces. To avoid overloading
debugfs with empty directories, make the common WWAN debugfs interface
optional. And force its selection if any driver-specific interface (only
IOSM at the moment) is enabled by user.

Signed-off-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
  • Loading branch information
rsa9000 authored and intel-lab-lkp committed Nov 28, 2021
1 parent e71ed63 commit 89654e5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
9 changes: 9 additions & 0 deletions drivers/net/wwan/Kconfig
Expand Up @@ -16,6 +16,14 @@ config WWAN

if WWAN

config WWAN_DEBUGFS
bool "WWAN subsystem common debugfs interface"
depends on DEBUG_FS
help
Enables common debugfs infrastructure for WWAN devices.

If unsure, say N.

config WWAN_HWSIM
tristate "Simulated WWAN device"
help
Expand Down Expand Up @@ -83,6 +91,7 @@ config IOSM
config IOSM_DEBUGFS
bool "IOSM Debugfs support"
depends on IOSM && DEBUG_FS
select WWAN_DEBUGFS
help
Enables debugfs driver interface for traces collection.

Expand Down
8 changes: 8 additions & 0 deletions drivers/net/wwan/wwan_core.c
Expand Up @@ -146,6 +146,7 @@ static struct wwan_device *wwan_dev_get_by_name(const char *name)
return to_wwan_dev(dev);
}

#ifdef CONFIG_WWAN_DEBUGFS
struct dentry *wwan_get_debugfs_dir(struct device *parent)
{
struct wwan_device *wwandev;
Expand All @@ -157,6 +158,7 @@ struct dentry *wwan_get_debugfs_dir(struct device *parent)
return wwandev->debugfs_dir;
}
EXPORT_SYMBOL_GPL(wwan_get_debugfs_dir);
#endif

/* This function allocates and registers a new WWAN device OR if a WWAN device
* already exist for the given parent, it gets a reference and return it.
Expand Down Expand Up @@ -207,8 +209,10 @@ static struct wwan_device *wwan_create_dev(struct device *parent)
}

wwandev_name = kobject_name(&wwandev->dev.kobj);
#ifdef CONFIG_WWAN_DEBUGFS
wwandev->debugfs_dir = debugfs_create_dir(wwandev_name,
wwan_debugfs_dir);
#endif

done_unlock:
mutex_unlock(&wwan_register_lock);
Expand Down Expand Up @@ -240,7 +244,9 @@ static void wwan_remove_dev(struct wwan_device *wwandev)
ret = device_for_each_child(&wwandev->dev, NULL, is_wwan_child);

if (!ret) {
#ifdef CONFIG_WWAN_DEBUGFS
debugfs_remove_recursive(wwandev->debugfs_dir);
#endif
device_unregister(&wwandev->dev);
} else {
put_device(&wwandev->dev);
Expand Down Expand Up @@ -1140,7 +1146,9 @@ static int __init wwan_init(void)
goto destroy;
}

#ifdef CONFIG_WWAN_DEBUGFS
wwan_debugfs_dir = debugfs_create_dir("wwan", NULL);
#endif

return 0;

Expand Down
7 changes: 7 additions & 0 deletions include/linux/wwan.h
Expand Up @@ -171,6 +171,13 @@ int wwan_register_ops(struct device *parent, const struct wwan_ops *ops,

void wwan_unregister_ops(struct device *parent);

#ifdef CONFIG_WWAN_DEBUGFS
struct dentry *wwan_get_debugfs_dir(struct device *parent);
#else
static inline struct dentry *wwan_get_debugfs_dir(struct device *parent)
{
return NULL;
}
#endif

#endif /* __WWAN_H */

0 comments on commit 89654e5

Please sign in to comment.