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

platform/x86: intel_ips: Convert to use DEFINE_SHOW_ATTRIBUTE macro

Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

+15 -44
+15 -44
drivers/platform/x86/intel_ips.c
··· 1210 1210 1211 1211 /* Expose current state and limits in debugfs if possible */ 1212 1212 1213 - struct ips_debugfs_node { 1214 - struct ips_driver *ips; 1215 - char *name; 1216 - int (*show)(struct seq_file *m, void *data); 1217 - }; 1218 - 1219 - static int show_cpu_temp(struct seq_file *m, void *data) 1213 + static int cpu_temp_show(struct seq_file *m, void *data) 1220 1214 { 1221 1215 struct ips_driver *ips = m->private; 1222 1216 ··· 1219 1225 1220 1226 return 0; 1221 1227 } 1228 + DEFINE_SHOW_ATTRIBUTE(cpu_temp); 1222 1229 1223 - static int show_cpu_power(struct seq_file *m, void *data) 1230 + static int cpu_power_show(struct seq_file *m, void *data) 1224 1231 { 1225 1232 struct ips_driver *ips = m->private; 1226 1233 ··· 1229 1234 1230 1235 return 0; 1231 1236 } 1237 + DEFINE_SHOW_ATTRIBUTE(cpu_power); 1232 1238 1233 - static int show_cpu_clamp(struct seq_file *m, void *data) 1239 + static int cpu_clamp_show(struct seq_file *m, void *data) 1234 1240 { 1235 1241 u64 turbo_override; 1236 1242 int tdp, tdc; ··· 1251 1255 1252 1256 return 0; 1253 1257 } 1258 + DEFINE_SHOW_ATTRIBUTE(cpu_clamp); 1254 1259 1255 - static int show_mch_temp(struct seq_file *m, void *data) 1260 + static int mch_temp_show(struct seq_file *m, void *data) 1256 1261 { 1257 1262 struct ips_driver *ips = m->private; 1258 1263 ··· 1262 1265 1263 1266 return 0; 1264 1267 } 1268 + DEFINE_SHOW_ATTRIBUTE(mch_temp); 1265 1269 1266 - static int show_mch_power(struct seq_file *m, void *data) 1270 + static int mch_power_show(struct seq_file *m, void *data) 1267 1271 { 1268 1272 struct ips_driver *ips = m->private; 1269 1273 ··· 1272 1274 1273 1275 return 0; 1274 1276 } 1275 - 1276 - static struct ips_debugfs_node ips_debug_files[] = { 1277 - { NULL, "cpu_temp", show_cpu_temp }, 1278 - { NULL, "cpu_power", show_cpu_power }, 1279 - { NULL, "cpu_clamp", show_cpu_clamp }, 1280 - { NULL, "mch_temp", show_mch_temp }, 1281 - { NULL, "mch_power", show_mch_power }, 1282 - }; 1283 - 1284 - static int ips_debugfs_open(struct inode *inode, struct file *file) 1285 - { 1286 - struct ips_debugfs_node *node = inode->i_private; 1287 - 1288 - return single_open(file, node->show, node->ips); 1289 - } 1290 - 1291 - static const struct file_operations ips_debugfs_ops = { 1292 - .owner = THIS_MODULE, 1293 - .open = ips_debugfs_open, 1294 - .read = seq_read, 1295 - .llseek = seq_lseek, 1296 - .release = single_release, 1297 - }; 1277 + DEFINE_SHOW_ATTRIBUTE(mch_power); 1298 1278 1299 1279 static void ips_debugfs_cleanup(struct ips_driver *ips) 1300 1280 { ··· 1281 1305 1282 1306 static void ips_debugfs_init(struct ips_driver *ips) 1283 1307 { 1284 - int i; 1285 - 1286 1308 ips->debug_root = debugfs_create_dir("ips", NULL); 1287 1309 1288 - for (i = 0; i < ARRAY_SIZE(ips_debug_files); i++) { 1289 - struct ips_debugfs_node *node = &ips_debug_files[i]; 1290 - 1291 - node->ips = ips; 1292 - debugfs_create_file(node->name, S_IFREG | S_IRUGO, 1293 - ips->debug_root, node, 1294 - &ips_debugfs_ops); 1295 - } 1310 + debugfs_create_file("cpu_temp", 0444, ips->debug_root, ips, &cpu_temp_fops); 1311 + debugfs_create_file("cpu_power", 0444, ips->debug_root, ips, &cpu_power_fops); 1312 + debugfs_create_file("cpu_clamp", 0444, ips->debug_root, ips, &cpu_clamp_fops); 1313 + debugfs_create_file("mch_temp", 0444, ips->debug_root, ips, &mch_temp_fops); 1314 + debugfs_create_file("mch_power", 0444, ips->debug_root, ips, &mch_power_fops); 1296 1315 } 1297 1316 #endif /* CONFIG_DEBUG_FS */ 1298 1317