Skip to content

Commit 9169477

Browse files
Chunfeng Yunvinodkoul
authored andcommitted
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: Chunfeng Yun <chunfeng.yun@mediatek.com> Link: https://lore.kernel.org/r/20230513092218.21139-1-chunfeng.yun@mediatek.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent 63c85ad commit 9169477

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

drivers/phy/phy-core.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/export.h>
1212
#include <linux/module.h>
1313
#include <linux/err.h>
14+
#include <linux/debugfs.h>
1415
#include <linux/device.h>
1516
#include <linux/slab.h>
1617
#include <linux/of.h>
@@ -20,6 +21,7 @@
2021
#include <linux/regulator/consumer.h>
2122

2223
static struct class *phy_class;
24+
static struct dentry *phy_debugfs_root;
2325
static DEFINE_MUTEX(phy_provider_mutex);
2426
static LIST_HEAD(phy_provider_list);
2527
static LIST_HEAD(phys);
@@ -996,6 +998,8 @@ struct phy *phy_create(struct device *dev, struct device_node *node,
996998
pm_runtime_no_callbacks(&phy->dev);
997999
}
9981000

1001+
phy->debugfs = debugfs_create_dir(dev_name(&phy->dev), phy_debugfs_root);
1002+
9991003
return phy;
10001004

10011005
put_dev:
@@ -1226,6 +1230,7 @@ static void phy_release(struct device *dev)
12261230

12271231
phy = to_phy(dev);
12281232
dev_vdbg(dev, "releasing '%s'\n", dev_name(dev));
1233+
debugfs_remove_recursive(phy->debugfs);
12291234
regulator_put(phy->pwr);
12301235
ida_simple_remove(&phy_ida, phy->id);
12311236
kfree(phy);
@@ -1242,6 +1247,15 @@ static int __init phy_core_init(void)
12421247

12431248
phy_class->dev_release = phy_release;
12441249

1250+
phy_debugfs_root = debugfs_create_dir("phy", NULL);
1251+
12451252
return 0;
12461253
}
12471254
device_initcall(phy_core_init);
1255+
1256+
static void __exit phy_core_exit(void)
1257+
{
1258+
debugfs_remove_recursive(phy_debugfs_root);
1259+
class_destroy(phy_class);
1260+
}
1261+
module_exit(phy_core_exit);

include/linux/phy/phy.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ struct phy_attrs {
148148
* @power_count: used to protect when the PHY is used by multiple consumers
149149
* @attrs: used to specify PHY specific attributes
150150
* @pwr: power regulator associated with the phy
151+
* @debugfs: debugfs directory
151152
*/
152153
struct phy {
153154
struct device dev;
@@ -158,6 +159,7 @@ struct phy {
158159
int power_count;
159160
struct phy_attrs attrs;
160161
struct regulator *pwr;
162+
struct dentry *debugfs;
161163
};
162164

163165
/**

0 commit comments

Comments
 (0)