hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/platform/x86/intel_ips.c
....@@ -1,17 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * Copyright (c) 2009-2010 Intel Corporation
3
- *
4
- * This program is free software; you can redistribute it and/or modify it
5
- * under the terms and conditions of the GNU General Public License,
6
- * version 2, as published by the Free Software Foundation.
7
- *
8
- * This program is distributed in the hope it will be useful, but WITHOUT
9
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11
- * more details.
12
- *
13
- * The full GNU General Public License is included in this distribution in
14
- * the file called "COPYING".
154 *
165 * Authors:
176 * Jesse Barnes <jbarnes@virtuousgeek.org>
....@@ -1221,13 +1210,7 @@
12211210
12221211 /* Expose current state and limits in debugfs if possible */
12231212
1224
-struct ips_debugfs_node {
1225
- struct ips_driver *ips;
1226
- char *name;
1227
- int (*show)(struct seq_file *m, void *data);
1228
-};
1229
-
1230
-static int show_cpu_temp(struct seq_file *m, void *data)
1213
+static int cpu_temp_show(struct seq_file *m, void *data)
12311214 {
12321215 struct ips_driver *ips = m->private;
12331216
....@@ -1236,8 +1219,9 @@
12361219
12371220 return 0;
12381221 }
1222
+DEFINE_SHOW_ATTRIBUTE(cpu_temp);
12391223
1240
-static int show_cpu_power(struct seq_file *m, void *data)
1224
+static int cpu_power_show(struct seq_file *m, void *data)
12411225 {
12421226 struct ips_driver *ips = m->private;
12431227
....@@ -1245,8 +1229,9 @@
12451229
12461230 return 0;
12471231 }
1232
+DEFINE_SHOW_ATTRIBUTE(cpu_power);
12481233
1249
-static int show_cpu_clamp(struct seq_file *m, void *data)
1234
+static int cpu_clamp_show(struct seq_file *m, void *data)
12501235 {
12511236 u64 turbo_override;
12521237 int tdp, tdc;
....@@ -1266,8 +1251,9 @@
12661251
12671252 return 0;
12681253 }
1254
+DEFINE_SHOW_ATTRIBUTE(cpu_clamp);
12691255
1270
-static int show_mch_temp(struct seq_file *m, void *data)
1256
+static int mch_temp_show(struct seq_file *m, void *data)
12711257 {
12721258 struct ips_driver *ips = m->private;
12731259
....@@ -1276,8 +1262,9 @@
12761262
12771263 return 0;
12781264 }
1265
+DEFINE_SHOW_ATTRIBUTE(mch_temp);
12791266
1280
-static int show_mch_power(struct seq_file *m, void *data)
1267
+static int mch_power_show(struct seq_file *m, void *data)
12811268 {
12821269 struct ips_driver *ips = m->private;
12831270
....@@ -1285,68 +1272,22 @@
12851272
12861273 return 0;
12871274 }
1288
-
1289
-static struct ips_debugfs_node ips_debug_files[] = {
1290
- { NULL, "cpu_temp", show_cpu_temp },
1291
- { NULL, "cpu_power", show_cpu_power },
1292
- { NULL, "cpu_clamp", show_cpu_clamp },
1293
- { NULL, "mch_temp", show_mch_temp },
1294
- { NULL, "mch_power", show_mch_power },
1295
-};
1296
-
1297
-static int ips_debugfs_open(struct inode *inode, struct file *file)
1298
-{
1299
- struct ips_debugfs_node *node = inode->i_private;
1300
-
1301
- return single_open(file, node->show, node->ips);
1302
-}
1303
-
1304
-static const struct file_operations ips_debugfs_ops = {
1305
- .owner = THIS_MODULE,
1306
- .open = ips_debugfs_open,
1307
- .read = seq_read,
1308
- .llseek = seq_lseek,
1309
- .release = single_release,
1310
-};
1275
+DEFINE_SHOW_ATTRIBUTE(mch_power);
13111276
13121277 static void ips_debugfs_cleanup(struct ips_driver *ips)
13131278 {
1314
- if (ips->debug_root)
1315
- debugfs_remove_recursive(ips->debug_root);
1316
- return;
1279
+ debugfs_remove_recursive(ips->debug_root);
13171280 }
13181281
13191282 static void ips_debugfs_init(struct ips_driver *ips)
13201283 {
1321
- int i;
1322
-
13231284 ips->debug_root = debugfs_create_dir("ips", NULL);
1324
- if (!ips->debug_root) {
1325
- dev_err(ips->dev, "failed to create debugfs entries: %ld\n",
1326
- PTR_ERR(ips->debug_root));
1327
- return;
1328
- }
13291285
1330
- for (i = 0; i < ARRAY_SIZE(ips_debug_files); i++) {
1331
- struct dentry *ent;
1332
- struct ips_debugfs_node *node = &ips_debug_files[i];
1333
-
1334
- node->ips = ips;
1335
- ent = debugfs_create_file(node->name, S_IFREG | S_IRUGO,
1336
- ips->debug_root, node,
1337
- &ips_debugfs_ops);
1338
- if (!ent) {
1339
- dev_err(ips->dev, "failed to create debug file: %ld\n",
1340
- PTR_ERR(ent));
1341
- goto err_cleanup;
1342
- }
1343
- }
1344
-
1345
- return;
1346
-
1347
-err_cleanup:
1348
- ips_debugfs_cleanup(ips);
1349
- return;
1286
+ debugfs_create_file("cpu_temp", 0444, ips->debug_root, ips, &cpu_temp_fops);
1287
+ debugfs_create_file("cpu_power", 0444, ips->debug_root, ips, &cpu_power_fops);
1288
+ debugfs_create_file("cpu_clamp", 0444, ips->debug_root, ips, &cpu_clamp_fops);
1289
+ debugfs_create_file("mch_temp", 0444, ips->debug_root, ips, &mch_temp_fops);
1290
+ debugfs_create_file("mch_power", 0444, ips->debug_root, ips, &mch_power_fops);
13501291 }
13511292 #endif /* CONFIG_DEBUG_FS */
13521293
....@@ -1657,9 +1598,6 @@
16571598 struct ips_driver *ips = pci_get_drvdata(dev);
16581599 u64 turbo_override;
16591600
1660
- if (!ips)
1661
- return;
1662
-
16631601 ips_debugfs_cleanup(ips);
16641602
16651603 /* Release i915 driver */
....@@ -1697,6 +1635,6 @@
16971635
16981636 module_pci_driver(ips_pci_driver);
16991637
1700
-MODULE_LICENSE("GPL");
1638
+MODULE_LICENSE("GPL v2");
17011639 MODULE_AUTHOR("Jesse Barnes <jbarnes@virtuousgeek.org>");
17021640 MODULE_DESCRIPTION("Intelligent Power Sharing Driver");