Skip to content

Commit ee65d9e

Browse files
Wolfram Sanggroeck
authored andcommitted
hwmon: (pt5161l) Use per-client debugfs entry
The I2C core now offers a debugfs-directory per client. Use it and remove the custom handling. Signed-off-by: Wolfram Sang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]>
1 parent 2324277 commit ee65d9e

File tree

1 file changed

+9
-37
lines changed

1 file changed

+9
-37
lines changed

drivers/hwmon/pt5161l.c

Lines changed: 9 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ struct pt5161l_fw_ver {
6363
/* Each client has this additional data */
6464
struct pt5161l_data {
6565
struct i2c_client *client;
66-
struct dentry *debugfs;
6766
struct pt5161l_fw_ver fw_ver;
6867
struct mutex lock; /* for atomic I2C transactions */
6968
bool init_done;
@@ -72,8 +71,6 @@ struct pt5161l_data {
7271
bool mm_wide_reg_access; /* MM assisted wide register access */
7372
};
7473

75-
static struct dentry *pt5161l_debugfs_dir;
76-
7774
/*
7875
* Write multiple data bytes to Aries over I2C
7976
*/
@@ -568,21 +565,16 @@ static const struct file_operations pt5161l_debugfs_ops_hb_sts = {
568565
.open = simple_open,
569566
};
570567

571-
static int pt5161l_init_debugfs(struct pt5161l_data *data)
568+
static void pt5161l_init_debugfs(struct i2c_client *client, struct pt5161l_data *data)
572569
{
573-
data->debugfs = debugfs_create_dir(dev_name(&data->client->dev),
574-
pt5161l_debugfs_dir);
575-
576-
debugfs_create_file("fw_ver", 0444, data->debugfs, data,
570+
debugfs_create_file("fw_ver", 0444, client->debugfs, data,
577571
&pt5161l_debugfs_ops_fw_ver);
578572

579-
debugfs_create_file("fw_load_status", 0444, data->debugfs, data,
573+
debugfs_create_file("fw_load_status", 0444, client->debugfs, data,
580574
&pt5161l_debugfs_ops_fw_load_sts);
581575

582-
debugfs_create_file("heartbeat_status", 0444, data->debugfs, data,
576+
debugfs_create_file("heartbeat_status", 0444, client->debugfs, data,
583577
&pt5161l_debugfs_ops_hb_sts);
584-
585-
return 0;
586578
}
587579

588580
static int pt5161l_probe(struct i2c_client *client)
@@ -604,17 +596,12 @@ static int pt5161l_probe(struct i2c_client *client)
604596
data,
605597
&pt5161l_chip_info,
606598
NULL);
599+
if (IS_ERR(hwmon_dev))
600+
return PTR_ERR(hwmon_dev);
607601

608-
pt5161l_init_debugfs(data);
609-
610-
return PTR_ERR_OR_ZERO(hwmon_dev);
611-
}
612-
613-
static void pt5161l_remove(struct i2c_client *client)
614-
{
615-
struct pt5161l_data *data = i2c_get_clientdata(client);
602+
pt5161l_init_debugfs(client, data);
616603

617-
debugfs_remove_recursive(data->debugfs);
604+
return 0;
618605
}
619606

620607
static const struct of_device_id __maybe_unused pt5161l_of_match[] = {
@@ -643,24 +630,9 @@ static struct i2c_driver pt5161l_driver = {
643630
.acpi_match_table = ACPI_PTR(pt5161l_acpi_match),
644631
},
645632
.probe = pt5161l_probe,
646-
.remove = pt5161l_remove,
647633
.id_table = pt5161l_id,
648634
};
649-
650-
static int __init pt5161l_init(void)
651-
{
652-
pt5161l_debugfs_dir = debugfs_create_dir("pt5161l", NULL);
653-
return i2c_add_driver(&pt5161l_driver);
654-
}
655-
656-
static void __exit pt5161l_exit(void)
657-
{
658-
i2c_del_driver(&pt5161l_driver);
659-
debugfs_remove_recursive(pt5161l_debugfs_dir);
660-
}
661-
662-
module_init(pt5161l_init);
663-
module_exit(pt5161l_exit);
635+
module_i2c_driver(pt5161l_driver);
664636

665637
MODULE_AUTHOR("Cosmo Chou <[email protected]>");
666638
MODULE_DESCRIPTION("Hwmon driver for Astera Labs Aries PCIe retimer");

0 commit comments

Comments
 (0)