Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

platform/x86: alienware-wmi-wmax: Add a DebugFS interface

Add a debugfs interface which exposes thermal private data.

Reviewed-by: Armin Wolf <W_Armin@gmx.de>
Signed-off-by: Kurt Borja <kuurtb@gmail.com>
Link: https://lore.kernel.org/r/20250329-hwm-v7-9-a14ea39d8a94@gmail.com
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

authored by

Kurt Borja and committed by
Ilpo Järvinen
b028fb49 07ac2759

+90
+90
drivers/platform/x86/dell/alienware-wmi-wmax.c
··· 12 12 #include <linux/bitfield.h> 13 13 #include <linux/bitmap.h> 14 14 #include <linux/bits.h> 15 + #include <linux/debugfs.h> 15 16 #include <linux/dmi.h> 16 17 #include <linux/hwmon.h> 17 18 #include <linux/hwmon-sysfs.h> ··· 21 20 #include <linux/moduleparam.h> 22 21 #include <linux/platform_profile.h> 23 22 #include <linux/pm.h> 23 + #include <linux/seq_file.h> 24 24 #include <linux/units.h> 25 25 #include <linux/wmi.h> 26 26 #include "alienware-wmi.h" ··· 1261 1259 return PTR_ERR_OR_ZERO(priv->ppdev); 1262 1260 } 1263 1261 1262 + /* 1263 + * DebugFS 1264 + */ 1265 + static int awcc_debugfs_system_description_read(struct seq_file *seq, void *data) 1266 + { 1267 + struct device *dev = seq->private; 1268 + struct awcc_priv *priv = dev_get_drvdata(dev); 1269 + 1270 + seq_printf(seq, "0x%08x\n", priv->system_description); 1271 + 1272 + return 0; 1273 + } 1274 + 1275 + static int awcc_debugfs_hwmon_data_read(struct seq_file *seq, void *data) 1276 + { 1277 + struct device *dev = seq->private; 1278 + struct awcc_priv *priv = dev_get_drvdata(dev); 1279 + const struct awcc_fan_data *fan; 1280 + unsigned int bit; 1281 + 1282 + seq_printf(seq, "Number of fans: %u\n", priv->fan_count); 1283 + seq_printf(seq, "Number of temperature sensors: %u\n\n", priv->temp_count); 1284 + 1285 + for (u32 i = 0; i < priv->fan_count; i++) { 1286 + fan = priv->fan_data[i]; 1287 + 1288 + seq_printf(seq, "Fan %u:\n", i); 1289 + seq_printf(seq, " ID: 0x%02x\n", fan->id); 1290 + seq_printf(seq, " Related temperature sensors bitmap: %lu\n", 1291 + fan->auto_channels_temp); 1292 + } 1293 + 1294 + seq_puts(seq, "\nTemperature sensor IDs:\n"); 1295 + for_each_set_bit(bit, priv->temp_sensors, AWCC_ID_BITMAP_SIZE) 1296 + seq_printf(seq, " 0x%02x\n", bit); 1297 + 1298 + return 0; 1299 + } 1300 + 1301 + static int awcc_debugfs_pprof_data_read(struct seq_file *seq, void *data) 1302 + { 1303 + struct device *dev = seq->private; 1304 + struct awcc_priv *priv = dev_get_drvdata(dev); 1305 + 1306 + seq_printf(seq, "Number of thermal profiles: %u\n\n", priv->profile_count); 1307 + 1308 + for (u32 i = 0; i < PLATFORM_PROFILE_LAST; i++) { 1309 + if (!priv->supported_profiles[i]) 1310 + continue; 1311 + 1312 + seq_printf(seq, "Platform profile %u:\n", i); 1313 + seq_printf(seq, " ID: 0x%02x\n", priv->supported_profiles[i]); 1314 + } 1315 + 1316 + return 0; 1317 + } 1318 + 1319 + static void awcc_debugfs_remove(void *data) 1320 + { 1321 + struct dentry *root = data; 1322 + 1323 + debugfs_remove(root); 1324 + } 1325 + 1326 + static void awcc_debugfs_init(struct wmi_device *wdev) 1327 + { 1328 + struct dentry *root; 1329 + char name[64]; 1330 + 1331 + scnprintf(name, sizeof(name), "%s-%s", "alienware-wmi", dev_name(&wdev->dev)); 1332 + root = debugfs_create_dir(name, NULL); 1333 + 1334 + debugfs_create_devm_seqfile(&wdev->dev, "system_description", root, 1335 + awcc_debugfs_system_description_read); 1336 + 1337 + if (awcc->hwmon) 1338 + debugfs_create_devm_seqfile(&wdev->dev, "hwmon_data", root, 1339 + awcc_debugfs_hwmon_data_read); 1340 + 1341 + if (awcc->pprof) 1342 + debugfs_create_devm_seqfile(&wdev->dev, "pprof_data", root, 1343 + awcc_debugfs_pprof_data_read); 1344 + 1345 + devm_add_action_or_reset(&wdev->dev, awcc_debugfs_remove, root); 1346 + } 1347 + 1264 1348 static int alienware_awcc_setup(struct wmi_device *wdev) 1265 1349 { 1266 1350 struct awcc_priv *priv; ··· 1384 1296 if (ret) 1385 1297 return ret; 1386 1298 } 1299 + 1300 + awcc_debugfs_init(wdev); 1387 1301 1388 1302 return 0; 1389 1303 }