summaryrefslogtreecommitdiff
path: root/drivers/hwmon/pt5161l.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/pt5161l.c')
-rw-r--r--drivers/hwmon/pt5161l.c52
1 files changed, 12 insertions, 40 deletions
diff --git a/drivers/hwmon/pt5161l.c b/drivers/hwmon/pt5161l.c
index 60361e39c474..20e3cfa625f1 100644
--- a/drivers/hwmon/pt5161l.c
+++ b/drivers/hwmon/pt5161l.c
@@ -63,7 +63,6 @@ struct pt5161l_fw_ver {
/* Each client has this additional data */
struct pt5161l_data {
struct i2c_client *client;
- struct dentry *debugfs;
struct pt5161l_fw_ver fw_ver;
struct mutex lock; /* for atomic I2C transactions */
bool init_done;
@@ -72,8 +71,6 @@ struct pt5161l_data {
bool mm_wide_reg_access; /* MM assisted wide register access */
};
-static struct dentry *pt5161l_debugfs_dir;
-
/*
* Write multiple data bytes to Aries over I2C
*/
@@ -427,7 +424,7 @@ static int pt5161l_read(struct device *dev, enum hwmon_sensor_types type,
struct pt5161l_data *data = dev_get_drvdata(dev);
int ret;
u8 buf[8];
- long adc_code;
+ u32 adc_code;
switch (attr) {
case hwmon_temp_input:
@@ -449,7 +446,7 @@ static int pt5161l_read(struct device *dev, enum hwmon_sensor_types type,
adc_code = buf[3] << 24 | buf[2] << 16 | buf[1] << 8 | buf[0];
if (adc_code == 0 || adc_code >= 0x3ff) {
- dev_dbg(dev, "Invalid adc_code %lx\n", adc_code);
+ dev_dbg(dev, "Invalid adc_code %x\n", adc_code);
return -EIO;
}
@@ -568,21 +565,16 @@ static const struct file_operations pt5161l_debugfs_ops_hb_sts = {
.open = simple_open,
};
-static int pt5161l_init_debugfs(struct pt5161l_data *data)
+static void pt5161l_init_debugfs(struct i2c_client *client, struct pt5161l_data *data)
{
- data->debugfs = debugfs_create_dir(dev_name(&data->client->dev),
- pt5161l_debugfs_dir);
-
- debugfs_create_file("fw_ver", 0444, data->debugfs, data,
+ debugfs_create_file("fw_ver", 0444, client->debugfs, data,
&pt5161l_debugfs_ops_fw_ver);
- debugfs_create_file("fw_load_status", 0444, data->debugfs, data,
+ debugfs_create_file("fw_load_status", 0444, client->debugfs, data,
&pt5161l_debugfs_ops_fw_load_sts);
- debugfs_create_file("heartbeat_status", 0444, data->debugfs, data,
+ debugfs_create_file("heartbeat_status", 0444, client->debugfs, data,
&pt5161l_debugfs_ops_hb_sts);
-
- return 0;
}
static int pt5161l_probe(struct i2c_client *client)
@@ -604,17 +596,12 @@ static int pt5161l_probe(struct i2c_client *client)
data,
&pt5161l_chip_info,
NULL);
+ if (IS_ERR(hwmon_dev))
+ return PTR_ERR(hwmon_dev);
- pt5161l_init_debugfs(data);
-
- return PTR_ERR_OR_ZERO(hwmon_dev);
-}
-
-static void pt5161l_remove(struct i2c_client *client)
-{
- struct pt5161l_data *data = i2c_get_clientdata(client);
+ pt5161l_init_debugfs(client, data);
- debugfs_remove_recursive(data->debugfs);
+ return 0;
}
static const struct of_device_id __maybe_unused pt5161l_of_match[] = {
@@ -630,7 +617,7 @@ static const struct acpi_device_id __maybe_unused pt5161l_acpi_match[] = {
MODULE_DEVICE_TABLE(acpi, pt5161l_acpi_match);
static const struct i2c_device_id pt5161l_id[] = {
- { "pt5161l", 0 },
+ { "pt5161l" },
{}
};
MODULE_DEVICE_TABLE(i2c, pt5161l_id);
@@ -643,24 +630,9 @@ static struct i2c_driver pt5161l_driver = {
.acpi_match_table = ACPI_PTR(pt5161l_acpi_match),
},
.probe = pt5161l_probe,
- .remove = pt5161l_remove,
.id_table = pt5161l_id,
};
-
-static int __init pt5161l_init(void)
-{
- pt5161l_debugfs_dir = debugfs_create_dir("pt5161l", NULL);
- return i2c_add_driver(&pt5161l_driver);
-}
-
-static void __exit pt5161l_exit(void)
-{
- i2c_del_driver(&pt5161l_driver);
- debugfs_remove_recursive(pt5161l_debugfs_dir);
-}
-
-module_init(pt5161l_init);
-module_exit(pt5161l_exit);
+module_i2c_driver(pt5161l_driver);
MODULE_AUTHOR("Cosmo Chou <cosmo.chou@quantatw.com>");
MODULE_DESCRIPTION("Hwmon driver for Astera Labs Aries PCIe retimer");