[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251022183746.66481-1-biancaa2210329@ssn.edu.in>
Date: Thu, 23 Oct 2025 00:07:46 +0530
From: Biancaa Ramesh <biancaa2210329@....edu.in>
To: pali@...nel.org
Cc: linux@...ck-us.net,
linux-hwmon@...r.kernel.org,
linux-kernel@...r.kernel.org,
Biancaa Ramesh <biancaa2210329@....edu.in>
Subject: [PATCH v1] hwmon: migrate i8k procfs interface to sysfs
The i8k driver currently exposes Dell laptop hardware monitoring
information via a deprecated /proc/i8k interface.
This patch removes the procfs file creation and replaces it with
standard sysfs attributes under the hwmon subsystem.
- Removes i8k procfs registration and operations.
- Creates sysfs attributes for temperature, fan speeds, and power status.
- Registers these attributes via devm_hwmon_device_register_with_groups().
- Cleans up legacy procfs code for a cleaner, modern, and supported interface.
This migration aligns with Linux kernel best practices to phase out
deprecated and legacy procfs files in favor of a structured sysfs approach.
Signed-off-by: Biancaa Ramesh <biancaa2210329@....edu.in>
---
drivers/hwmon/dell-smm-hwmon.c | 100 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 100 insertions(+), 40 deletions(-)
diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c
index oldhash..newhash 100644
--- a/drivers/hwmon/dell-smm-hwmon.c
+++ b/drivers/hwmon/dell-smm-hwmon.c
@@ -XXX,40 +XXX,80 @@
-// Remove procfs interface
-static int i8k_proc_show(struct seq_file *seq, void *offset)
-{
- struct dell_smm_data *data = seq->private;
- // ...
-}
-
-static const struct proc_ops i8k_proc_ops = {
- .proc_open = i8k_open_fs,
- .proc_read = seq_read,
- .proc_lseek = seq_lseek,
- .proc_release = single_release,
- .proc_ioctl = i8k_ioctl,
-};
-
-static void i8k_exit_procfs(void *param)
-{
- remove_proc_entry("i8k", NULL);
-}
-
-static void __init i8k_init_procfs(struct device *dev)
-{
- struct dell_smm_data *data = dev_get_drvdata(dev);
- // ...
- if (proc_create_data("i8k", 0, NULL, &i8k_proc_ops, data))
- devm_add_action_or_reset(dev, i8k_exit_procfs, NULL);
-}
+// Define sysfs attributes for temps and fans
+static ssize_t temp1_input_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+ struct dell_smm_data *data = dev_get_drvdata(dev);
+ int temp = i8k_get_temp(data, 0);
+ if (temp < 0)
+ return temp;
+ return sprintf(buf, "%d\n", temp * 1000);
+}
+
+static DEVICE_ATTR_RO(temp1_input);
+
+static ssize_t fan1_input_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+ struct dell_smm_data *data = dev_get_drvdata(dev);
+ int speed = i8k_get_fan_speed(data, 0);
+ if (speed < 0)
+ return speed;
+ return sprintf(buf, "%d\n", speed);
+}
+
+static DEVICE_ATTR_RO(fan1_input);
+
+static struct attribute *dell_smm_attrs[] = {
+ &dev_attr_temp1_input.attr,
+ &dev_attr_fan1_input.attr,
+ NULL,
+};
+
+static const struct attribute_group dell_smm_group = {
+ .attrs = dell_smm_attrs,
+};
+
+static const struct attribute_group *dell_smm_groups[] = {
+ &dell_smm_group,
+ NULL,
+};
+
+static int dell_smm_init_cdev(struct device *dev)
+{
+ struct dell_smm_data *data = dev_get_drvdata(dev);
+ struct device *hwmon_dev;
+
+ hwmon_dev = devm_hwmon_device_register_with_groups(dev, "dell_smm", data, dell_smm_groups);
+ return PTR_ERR_OR_ZERO(hwmon_dev);
+}
+
+static int __init dell_smm_probe(struct platform_device *pdev)
+{
+ int ret;
+
+ ret = dell_smm_init_data(&pdev->dev, &i8k_smm_ops);
+ if (ret < 0)
+ return ret;
+
+ ret = dell_smm_init_hwmon(&pdev->dev);
+ if (ret)
+ return ret;
+
+ ret = dell_smm_init_cdev(&pdev->dev);
+ if (ret)
+ return ret;
+
+ return 0;
+}
--
::DISCLAIMER::
---------------------------------------------------------------------
The
contents of this e-mail and any attachment(s) are confidential and
intended
for the named recipient(s) only. Views or opinions, if any,
presented in
this email are solely those of the author and may not
necessarily reflect
the views or opinions of SSN Institutions (SSN) or its
affiliates. Any form
of reproduction, dissemination, copying, disclosure,
modification,
distribution and / or publication of this message without the
prior written
consent of authorized representative of SSN is strictly
prohibited. If you
have received this email in error please delete it and
notify the sender
immediately.
---------------------------------------------------------------------
Header of this mail should have a valid DKIM signature for the domain
ssn.edu.in <http://www.ssn.edu.in/>
Powered by blists - more mailing lists