Commit 91694772 authored by Chunfeng Yun's avatar Chunfeng Yun Committed by Vinod Koul

phy: core: add debugfs files

Add a debugfs root for phy class, and create a debugfs directory under
the root when create phy, then phy drivers can add debugfs files.
Signed-off-by: default avatarChunfeng Yun <chunfeng.yun@mediatek.com>
Link: https://lore.kernel.org/r/20230513092218.21139-1-chunfeng.yun@mediatek.comSigned-off-by: default avatarVinod Koul <vkoul@kernel.org>
parent 63c85ad0
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <linux/export.h> #include <linux/export.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/debugfs.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/of.h> #include <linux/of.h>
...@@ -20,6 +21,7 @@ ...@@ -20,6 +21,7 @@
#include <linux/regulator/consumer.h> #include <linux/regulator/consumer.h>
static struct class *phy_class; static struct class *phy_class;
static struct dentry *phy_debugfs_root;
static DEFINE_MUTEX(phy_provider_mutex); static DEFINE_MUTEX(phy_provider_mutex);
static LIST_HEAD(phy_provider_list); static LIST_HEAD(phy_provider_list);
static LIST_HEAD(phys); static LIST_HEAD(phys);
...@@ -996,6 +998,8 @@ struct phy *phy_create(struct device *dev, struct device_node *node, ...@@ -996,6 +998,8 @@ struct phy *phy_create(struct device *dev, struct device_node *node,
pm_runtime_no_callbacks(&phy->dev); pm_runtime_no_callbacks(&phy->dev);
} }
phy->debugfs = debugfs_create_dir(dev_name(&phy->dev), phy_debugfs_root);
return phy; return phy;
put_dev: put_dev:
...@@ -1226,6 +1230,7 @@ static void phy_release(struct device *dev) ...@@ -1226,6 +1230,7 @@ static void phy_release(struct device *dev)
phy = to_phy(dev); phy = to_phy(dev);
dev_vdbg(dev, "releasing '%s'\n", dev_name(dev)); dev_vdbg(dev, "releasing '%s'\n", dev_name(dev));
debugfs_remove_recursive(phy->debugfs);
regulator_put(phy->pwr); regulator_put(phy->pwr);
ida_simple_remove(&phy_ida, phy->id); ida_simple_remove(&phy_ida, phy->id);
kfree(phy); kfree(phy);
...@@ -1242,6 +1247,15 @@ static int __init phy_core_init(void) ...@@ -1242,6 +1247,15 @@ static int __init phy_core_init(void)
phy_class->dev_release = phy_release; phy_class->dev_release = phy_release;
phy_debugfs_root = debugfs_create_dir("phy", NULL);
return 0; return 0;
} }
device_initcall(phy_core_init); device_initcall(phy_core_init);
static void __exit phy_core_exit(void)
{
debugfs_remove_recursive(phy_debugfs_root);
class_destroy(phy_class);
}
module_exit(phy_core_exit);
...@@ -148,6 +148,7 @@ struct phy_attrs { ...@@ -148,6 +148,7 @@ struct phy_attrs {
* @power_count: used to protect when the PHY is used by multiple consumers * @power_count: used to protect when the PHY is used by multiple consumers
* @attrs: used to specify PHY specific attributes * @attrs: used to specify PHY specific attributes
* @pwr: power regulator associated with the phy * @pwr: power regulator associated with the phy
* @debugfs: debugfs directory
*/ */
struct phy { struct phy {
struct device dev; struct device dev;
...@@ -158,6 +159,7 @@ struct phy { ...@@ -158,6 +159,7 @@ struct phy {
int power_count; int power_count;
struct phy_attrs attrs; struct phy_attrs attrs;
struct regulator *pwr; struct regulator *pwr;
struct dentry *debugfs;
}; };
/** /**
......
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