diff options
Diffstat (limited to 'drivers/platform/x86/intel_ips.c')
-rw-r--r-- | drivers/platform/x86/intel_ips.c | 83 |
1 files changed, 16 insertions, 67 deletions
diff --git a/drivers/platform/x86/intel_ips.c b/drivers/platform/x86/intel_ips.c index 225638a1b09e..bffe548187ee 100644 --- a/drivers/platform/x86/intel_ips.c +++ b/drivers/platform/x86/intel_ips.c @@ -1210,13 +1210,7 @@ static void ips_debugfs_cleanup(struct ips_driver *ips) { return; } /* Expose current state and limits in debugfs if possible */ -struct ips_debugfs_node { - struct ips_driver *ips; - char *name; - int (*show)(struct seq_file *m, void *data); -}; - -static int show_cpu_temp(struct seq_file *m, void *data) +static int cpu_temp_show(struct seq_file *m, void *data) { struct ips_driver *ips = m->private; @@ -1225,8 +1219,9 @@ static int show_cpu_temp(struct seq_file *m, void *data) return 0; } +DEFINE_SHOW_ATTRIBUTE(cpu_temp); -static int show_cpu_power(struct seq_file *m, void *data) +static int cpu_power_show(struct seq_file *m, void *data) { struct ips_driver *ips = m->private; @@ -1234,8 +1229,9 @@ static int show_cpu_power(struct seq_file *m, void *data) return 0; } +DEFINE_SHOW_ATTRIBUTE(cpu_power); -static int show_cpu_clamp(struct seq_file *m, void *data) +static int cpu_clamp_show(struct seq_file *m, void *data) { u64 turbo_override; int tdp, tdc; @@ -1255,8 +1251,9 @@ static int show_cpu_clamp(struct seq_file *m, void *data) return 0; } +DEFINE_SHOW_ATTRIBUTE(cpu_clamp); -static int show_mch_temp(struct seq_file *m, void *data) +static int mch_temp_show(struct seq_file *m, void *data) { struct ips_driver *ips = m->private; @@ -1265,8 +1262,9 @@ static int show_mch_temp(struct seq_file *m, void *data) return 0; } +DEFINE_SHOW_ATTRIBUTE(mch_temp); -static int show_mch_power(struct seq_file *m, void *data) +static int mch_power_show(struct seq_file *m, void *data) { struct ips_driver *ips = m->private; @@ -1274,68 +1272,22 @@ static int show_mch_power(struct seq_file *m, void *data) return 0; } - -static struct ips_debugfs_node ips_debug_files[] = { - { NULL, "cpu_temp", show_cpu_temp }, - { NULL, "cpu_power", show_cpu_power }, - { NULL, "cpu_clamp", show_cpu_clamp }, - { NULL, "mch_temp", show_mch_temp }, - { NULL, "mch_power", show_mch_power }, -}; - -static int ips_debugfs_open(struct inode *inode, struct file *file) -{ - struct ips_debugfs_node *node = inode->i_private; - - return single_open(file, node->show, node->ips); -} - -static const struct file_operations ips_debugfs_ops = { - .owner = THIS_MODULE, - .open = ips_debugfs_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; +DEFINE_SHOW_ATTRIBUTE(mch_power); static void ips_debugfs_cleanup(struct ips_driver *ips) { - if (ips->debug_root) - debugfs_remove_recursive(ips->debug_root); - return; + debugfs_remove_recursive(ips->debug_root); } static void ips_debugfs_init(struct ips_driver *ips) { - int i; - ips->debug_root = debugfs_create_dir("ips", NULL); - if (!ips->debug_root) { - dev_err(ips->dev, "failed to create debugfs entries: %ld\n", - PTR_ERR(ips->debug_root)); - return; - } - for (i = 0; i < ARRAY_SIZE(ips_debug_files); i++) { - struct dentry *ent; - struct ips_debugfs_node *node = &ips_debug_files[i]; - - node->ips = ips; - ent = debugfs_create_file(node->name, S_IFREG | S_IRUGO, - ips->debug_root, node, - &ips_debugfs_ops); - if (!ent) { - dev_err(ips->dev, "failed to create debug file: %ld\n", - PTR_ERR(ent)); - goto err_cleanup; - } - } - - return; - -err_cleanup: - ips_debugfs_cleanup(ips); - return; + debugfs_create_file("cpu_temp", 0444, ips->debug_root, ips, &cpu_temp_fops); + debugfs_create_file("cpu_power", 0444, ips->debug_root, ips, &cpu_power_fops); + debugfs_create_file("cpu_clamp", 0444, ips->debug_root, ips, &cpu_clamp_fops); + debugfs_create_file("mch_temp", 0444, ips->debug_root, ips, &mch_temp_fops); + debugfs_create_file("mch_power", 0444, ips->debug_root, ips, &mch_power_fops); } #endif /* CONFIG_DEBUG_FS */ @@ -1646,9 +1598,6 @@ static void ips_remove(struct pci_dev *dev) struct ips_driver *ips = pci_get_drvdata(dev); u64 turbo_override; - if (!ips) - return; - ips_debugfs_cleanup(ips); /* Release i915 driver */ |