VisionFive2 Linux kernel

StarFive Tech Linux Kernel for VisionFive (JH7110) boards (mirror)

More than 9999 Commits   35 Branches   59 Tags
d2912cb15bdda drivers/opp/debugfs.c            (Thomas Gleixner    2019-06-04 10:11:33 +0200   1) // SPDX-License-Identifier: GPL-2.0-only
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530   2) /*
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530   3)  * Generic OPP debugfs interface
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530   4)  *
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530   5)  * Copyright (C) 2015-2016 Viresh Kumar <viresh.kumar@linaro.org>
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530   6)  */
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530   7) 
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530   8) #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530   9) 
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530  10) #include <linux/debugfs.h>
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530  11) #include <linux/device.h>
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530  12) #include <linux/err.h>
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530  13) #include <linux/init.h>
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530  14) #include <linux/limits.h>
dfbe4678d709e drivers/base/power/opp/debugfs.c (Viresh Kumar       2016-12-01 16:28:19 +0530  15) #include <linux/slab.h>
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530  16) 
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530  17) #include "opp.h"
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530  18) 
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530  19) static struct dentry *rootdir;
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530  20) 
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530  21) static void opp_set_dev_name(const struct device *dev, char *name)
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530  22) {
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530  23) 	if (dev->parent)
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530  24) 		snprintf(name, NAME_MAX, "%s-%s", dev_name(dev->parent),
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530  25) 			 dev_name(dev));
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530  26) 	else
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530  27) 		snprintf(name, NAME_MAX, "%s", dev_name(dev));
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530  28) }
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530  29) 
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530  30) void opp_debug_remove_one(struct dev_pm_opp *opp)
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530  31) {
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530  32) 	debugfs_remove_recursive(opp->dentry);
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530  33) }
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530  34) 
0430b1d5704b0 drivers/opp/debugfs.c            (Viresh Kumar       2020-05-18 14:25:32 +0300  35) static ssize_t bw_name_read(struct file *fp, char __user *userbuf,
0430b1d5704b0 drivers/opp/debugfs.c            (Viresh Kumar       2020-05-18 14:25:32 +0300  36) 			    size_t count, loff_t *ppos)
0430b1d5704b0 drivers/opp/debugfs.c            (Viresh Kumar       2020-05-18 14:25:32 +0300  37) {
0430b1d5704b0 drivers/opp/debugfs.c            (Viresh Kumar       2020-05-18 14:25:32 +0300  38) 	struct icc_path *path = fp->private_data;
0430b1d5704b0 drivers/opp/debugfs.c            (Viresh Kumar       2020-05-18 14:25:32 +0300  39) 	char buf[64];
0430b1d5704b0 drivers/opp/debugfs.c            (Viresh Kumar       2020-05-18 14:25:32 +0300  40) 	int i;
0430b1d5704b0 drivers/opp/debugfs.c            (Viresh Kumar       2020-05-18 14:25:32 +0300  41) 
0430b1d5704b0 drivers/opp/debugfs.c            (Viresh Kumar       2020-05-18 14:25:32 +0300  42) 	i = scnprintf(buf, sizeof(buf), "%.62s\n", icc_get_name(path));
0430b1d5704b0 drivers/opp/debugfs.c            (Viresh Kumar       2020-05-18 14:25:32 +0300  43) 
0430b1d5704b0 drivers/opp/debugfs.c            (Viresh Kumar       2020-05-18 14:25:32 +0300  44) 	return simple_read_from_buffer(userbuf, count, ppos, buf, i);
0430b1d5704b0 drivers/opp/debugfs.c            (Viresh Kumar       2020-05-18 14:25:32 +0300  45) }
0430b1d5704b0 drivers/opp/debugfs.c            (Viresh Kumar       2020-05-18 14:25:32 +0300  46) 
0430b1d5704b0 drivers/opp/debugfs.c            (Viresh Kumar       2020-05-18 14:25:32 +0300  47) static const struct file_operations bw_name_fops = {
0430b1d5704b0 drivers/opp/debugfs.c            (Viresh Kumar       2020-05-18 14:25:32 +0300  48) 	.open = simple_open,
0430b1d5704b0 drivers/opp/debugfs.c            (Viresh Kumar       2020-05-18 14:25:32 +0300  49) 	.read = bw_name_read,
0430b1d5704b0 drivers/opp/debugfs.c            (Viresh Kumar       2020-05-18 14:25:32 +0300  50) 	.llseek = default_llseek,
0430b1d5704b0 drivers/opp/debugfs.c            (Viresh Kumar       2020-05-18 14:25:32 +0300  51) };
0430b1d5704b0 drivers/opp/debugfs.c            (Viresh Kumar       2020-05-18 14:25:32 +0300  52) 
0430b1d5704b0 drivers/opp/debugfs.c            (Viresh Kumar       2020-05-18 14:25:32 +0300  53) static void opp_debug_create_bw(struct dev_pm_opp *opp,
0430b1d5704b0 drivers/opp/debugfs.c            (Viresh Kumar       2020-05-18 14:25:32 +0300  54) 				struct opp_table *opp_table,
0430b1d5704b0 drivers/opp/debugfs.c            (Viresh Kumar       2020-05-18 14:25:32 +0300  55) 				struct dentry *pdentry)
0430b1d5704b0 drivers/opp/debugfs.c            (Viresh Kumar       2020-05-18 14:25:32 +0300  56) {
0430b1d5704b0 drivers/opp/debugfs.c            (Viresh Kumar       2020-05-18 14:25:32 +0300  57) 	struct dentry *d;
0430b1d5704b0 drivers/opp/debugfs.c            (Viresh Kumar       2020-05-18 14:25:32 +0300  58) 	char name[11];
0430b1d5704b0 drivers/opp/debugfs.c            (Viresh Kumar       2020-05-18 14:25:32 +0300  59) 	int i;
0430b1d5704b0 drivers/opp/debugfs.c            (Viresh Kumar       2020-05-18 14:25:32 +0300  60) 
0430b1d5704b0 drivers/opp/debugfs.c            (Viresh Kumar       2020-05-18 14:25:32 +0300  61) 	for (i = 0; i < opp_table->path_count; i++) {
0430b1d5704b0 drivers/opp/debugfs.c            (Viresh Kumar       2020-05-18 14:25:32 +0300  62) 		snprintf(name, sizeof(name), "icc-path-%.1d", i);
0430b1d5704b0 drivers/opp/debugfs.c            (Viresh Kumar       2020-05-18 14:25:32 +0300  63) 
0430b1d5704b0 drivers/opp/debugfs.c            (Viresh Kumar       2020-05-18 14:25:32 +0300  64) 		/* Create per-path directory */
0430b1d5704b0 drivers/opp/debugfs.c            (Viresh Kumar       2020-05-18 14:25:32 +0300  65) 		d = debugfs_create_dir(name, pdentry);
0430b1d5704b0 drivers/opp/debugfs.c            (Viresh Kumar       2020-05-18 14:25:32 +0300  66) 
0430b1d5704b0 drivers/opp/debugfs.c            (Viresh Kumar       2020-05-18 14:25:32 +0300  67) 		debugfs_create_file("name", S_IRUGO, d, opp_table->paths[i],
0430b1d5704b0 drivers/opp/debugfs.c            (Viresh Kumar       2020-05-18 14:25:32 +0300  68) 				    &bw_name_fops);
0430b1d5704b0 drivers/opp/debugfs.c            (Viresh Kumar       2020-05-18 14:25:32 +0300  69) 		debugfs_create_u32("peak_bw", S_IRUGO, d,
0430b1d5704b0 drivers/opp/debugfs.c            (Viresh Kumar       2020-05-18 14:25:32 +0300  70) 				   &opp->bandwidth[i].peak);
0430b1d5704b0 drivers/opp/debugfs.c            (Viresh Kumar       2020-05-18 14:25:32 +0300  71) 		debugfs_create_u32("avg_bw", S_IRUGO, d,
0430b1d5704b0 drivers/opp/debugfs.c            (Viresh Kumar       2020-05-18 14:25:32 +0300  72) 				   &opp->bandwidth[i].avg);
0430b1d5704b0 drivers/opp/debugfs.c            (Viresh Kumar       2020-05-18 14:25:32 +0300  73) 	}
0430b1d5704b0 drivers/opp/debugfs.c            (Viresh Kumar       2020-05-18 14:25:32 +0300  74) }
0430b1d5704b0 drivers/opp/debugfs.c            (Viresh Kumar       2020-05-18 14:25:32 +0300  75) 
a2dea4cb90702 drivers/opp/debugfs.c            (Greg Kroah-Hartman 2019-01-22 16:21:17 +0100  76) static void opp_debug_create_supplies(struct dev_pm_opp *opp,
dfbe4678d709e drivers/base/power/opp/debugfs.c (Viresh Kumar       2016-12-01 16:28:19 +0530  77) 				      struct opp_table *opp_table,
dfbe4678d709e drivers/base/power/opp/debugfs.c (Viresh Kumar       2016-12-01 16:28:19 +0530  78) 				      struct dentry *pdentry)
dfbe4678d709e drivers/base/power/opp/debugfs.c (Viresh Kumar       2016-12-01 16:28:19 +0530  79) {
dfbe4678d709e drivers/base/power/opp/debugfs.c (Viresh Kumar       2016-12-01 16:28:19 +0530  80) 	struct dentry *d;
1fae788ed640e drivers/base/power/opp/debugfs.c (Viresh Kumar       2017-05-23 09:32:13 +0530  81) 	int i;
dfbe4678d709e drivers/base/power/opp/debugfs.c (Viresh Kumar       2016-12-01 16:28:19 +0530  82) 
1fae788ed640e drivers/base/power/opp/debugfs.c (Viresh Kumar       2017-05-23 09:32:13 +0530  83) 	for (i = 0; i < opp_table->regulator_count; i++) {
d741029a23904 drivers/opp/debugfs.c            (Arvind Yadav       2017-09-21 11:15:36 +0530  84) 		char name[15];
d741029a23904 drivers/opp/debugfs.c            (Arvind Yadav       2017-09-21 11:15:36 +0530  85) 
d741029a23904 drivers/opp/debugfs.c            (Arvind Yadav       2017-09-21 11:15:36 +0530  86) 		snprintf(name, sizeof(name), "supply-%d", i);
dfbe4678d709e drivers/base/power/opp/debugfs.c (Viresh Kumar       2016-12-01 16:28:19 +0530  87) 
dfbe4678d709e drivers/base/power/opp/debugfs.c (Viresh Kumar       2016-12-01 16:28:19 +0530  88) 		/* Create per-opp directory */
dfbe4678d709e drivers/base/power/opp/debugfs.c (Viresh Kumar       2016-12-01 16:28:19 +0530  89) 		d = debugfs_create_dir(name, pdentry);
dfbe4678d709e drivers/base/power/opp/debugfs.c (Viresh Kumar       2016-12-01 16:28:19 +0530  90) 
a2dea4cb90702 drivers/opp/debugfs.c            (Greg Kroah-Hartman 2019-01-22 16:21:17 +0100  91) 		debugfs_create_ulong("u_volt_target", S_IRUGO, d,
a2dea4cb90702 drivers/opp/debugfs.c            (Greg Kroah-Hartman 2019-01-22 16:21:17 +0100  92) 				     &opp->supplies[i].u_volt);
dfbe4678d709e drivers/base/power/opp/debugfs.c (Viresh Kumar       2016-12-01 16:28:19 +0530  93) 
a2dea4cb90702 drivers/opp/debugfs.c            (Greg Kroah-Hartman 2019-01-22 16:21:17 +0100  94) 		debugfs_create_ulong("u_volt_min", S_IRUGO, d,
a2dea4cb90702 drivers/opp/debugfs.c            (Greg Kroah-Hartman 2019-01-22 16:21:17 +0100  95) 				     &opp->supplies[i].u_volt_min);
dfbe4678d709e drivers/base/power/opp/debugfs.c (Viresh Kumar       2016-12-01 16:28:19 +0530  96) 
a2dea4cb90702 drivers/opp/debugfs.c            (Greg Kroah-Hartman 2019-01-22 16:21:17 +0100  97) 		debugfs_create_ulong("u_volt_max", S_IRUGO, d,
a2dea4cb90702 drivers/opp/debugfs.c            (Greg Kroah-Hartman 2019-01-22 16:21:17 +0100  98) 				     &opp->supplies[i].u_volt_max);
dfbe4678d709e drivers/base/power/opp/debugfs.c (Viresh Kumar       2016-12-01 16:28:19 +0530  99) 
a2dea4cb90702 drivers/opp/debugfs.c            (Greg Kroah-Hartman 2019-01-22 16:21:17 +0100 100) 		debugfs_create_ulong("u_amp", S_IRUGO, d,
a2dea4cb90702 drivers/opp/debugfs.c            (Greg Kroah-Hartman 2019-01-22 16:21:17 +0100 101) 				     &opp->supplies[i].u_amp);
1fae788ed640e drivers/base/power/opp/debugfs.c (Viresh Kumar       2017-05-23 09:32:13 +0530 102) 	}
dfbe4678d709e drivers/base/power/opp/debugfs.c (Viresh Kumar       2016-12-01 16:28:19 +0530 103) }
dfbe4678d709e drivers/base/power/opp/debugfs.c (Viresh Kumar       2016-12-01 16:28:19 +0530 104) 
a2dea4cb90702 drivers/opp/debugfs.c            (Greg Kroah-Hartman 2019-01-22 16:21:17 +0100 105) void opp_debug_create_one(struct dev_pm_opp *opp, struct opp_table *opp_table)
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 106) {
2c2709dc6921c drivers/base/power/opp/debugfs.c (Viresh Kumar       2016-02-16 14:17:53 +0530 107) 	struct dentry *pdentry = opp_table->dentry;
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 108) 	struct dentry *d;
a1e8c13600bfd drivers/opp/debugfs.c            (Viresh Kumar       2018-04-06 14:35:45 +0530 109) 	unsigned long id;
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 110) 	char name[25];	/* 20 chars for 64 bit value + 5 (opp:\0) */
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 111) 
a1e8c13600bfd drivers/opp/debugfs.c            (Viresh Kumar       2018-04-06 14:35:45 +0530 112) 	/*
a1e8c13600bfd drivers/opp/debugfs.c            (Viresh Kumar       2018-04-06 14:35:45 +0530 113) 	 * Get directory name for OPP.
a1e8c13600bfd drivers/opp/debugfs.c            (Viresh Kumar       2018-04-06 14:35:45 +0530 114) 	 *
a1e8c13600bfd drivers/opp/debugfs.c            (Viresh Kumar       2018-04-06 14:35:45 +0530 115) 	 * - Normally rate is unique to each OPP, use it to get unique opp-name.
a1e8c13600bfd drivers/opp/debugfs.c            (Viresh Kumar       2018-04-06 14:35:45 +0530 116) 	 * - For some devices rate isn't available, use index instead.
a1e8c13600bfd drivers/opp/debugfs.c            (Viresh Kumar       2018-04-06 14:35:45 +0530 117) 	 */
a1e8c13600bfd drivers/opp/debugfs.c            (Viresh Kumar       2018-04-06 14:35:45 +0530 118) 	if (likely(opp->rate))
a1e8c13600bfd drivers/opp/debugfs.c            (Viresh Kumar       2018-04-06 14:35:45 +0530 119) 		id = opp->rate;
a1e8c13600bfd drivers/opp/debugfs.c            (Viresh Kumar       2018-04-06 14:35:45 +0530 120) 	else
a1e8c13600bfd drivers/opp/debugfs.c            (Viresh Kumar       2018-04-06 14:35:45 +0530 121) 		id = _get_opp_count(opp_table);
a1e8c13600bfd drivers/opp/debugfs.c            (Viresh Kumar       2018-04-06 14:35:45 +0530 122) 
a1e8c13600bfd drivers/opp/debugfs.c            (Viresh Kumar       2018-04-06 14:35:45 +0530 123) 	snprintf(name, sizeof(name), "opp:%lu", id);
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 124) 
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 125) 	/* Create per-opp directory */
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 126) 	d = debugfs_create_dir(name, pdentry);
009acd196fc86 drivers/opp/debugfs.c            (Viresh Kumar       2017-10-11 12:54:14 +0530 127) 
a2dea4cb90702 drivers/opp/debugfs.c            (Greg Kroah-Hartman 2019-01-22 16:21:17 +0100 128) 	debugfs_create_bool("available", S_IRUGO, d, &opp->available);
a2dea4cb90702 drivers/opp/debugfs.c            (Greg Kroah-Hartman 2019-01-22 16:21:17 +0100 129) 	debugfs_create_bool("dynamic", S_IRUGO, d, &opp->dynamic);
a2dea4cb90702 drivers/opp/debugfs.c            (Greg Kroah-Hartman 2019-01-22 16:21:17 +0100 130) 	debugfs_create_bool("turbo", S_IRUGO, d, &opp->turbo);
a2dea4cb90702 drivers/opp/debugfs.c            (Greg Kroah-Hartman 2019-01-22 16:21:17 +0100 131) 	debugfs_create_bool("suspend", S_IRUGO, d, &opp->suspend);
a2dea4cb90702 drivers/opp/debugfs.c            (Greg Kroah-Hartman 2019-01-22 16:21:17 +0100 132) 	debugfs_create_u32("performance_state", S_IRUGO, d, &opp->pstate);
a2dea4cb90702 drivers/opp/debugfs.c            (Greg Kroah-Hartman 2019-01-22 16:21:17 +0100 133) 	debugfs_create_ulong("rate_hz", S_IRUGO, d, &opp->rate);
a2dea4cb90702 drivers/opp/debugfs.c            (Greg Kroah-Hartman 2019-01-22 16:21:17 +0100 134) 	debugfs_create_ulong("clock_latency_ns", S_IRUGO, d,
a2dea4cb90702 drivers/opp/debugfs.c            (Greg Kroah-Hartman 2019-01-22 16:21:17 +0100 135) 			     &opp->clock_latency_ns);
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 136) 
a2dea4cb90702 drivers/opp/debugfs.c            (Greg Kroah-Hartman 2019-01-22 16:21:17 +0100 137) 	opp_debug_create_supplies(opp, opp_table, d);
0430b1d5704b0 drivers/opp/debugfs.c            (Viresh Kumar       2020-05-18 14:25:32 +0300 138) 	opp_debug_create_bw(opp, opp_table, d);
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 139) 
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 140) 	opp->dentry = d;
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 141) }
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 142) 
a2dea4cb90702 drivers/opp/debugfs.c            (Greg Kroah-Hartman 2019-01-22 16:21:17 +0100 143) static void opp_list_debug_create_dir(struct opp_device *opp_dev,
a2dea4cb90702 drivers/opp/debugfs.c            (Greg Kroah-Hartman 2019-01-22 16:21:17 +0100 144) 				      struct opp_table *opp_table)
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 145) {
2c2709dc6921c drivers/base/power/opp/debugfs.c (Viresh Kumar       2016-02-16 14:17:53 +0530 146) 	const struct device *dev = opp_dev->dev;
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 147) 	struct dentry *d;
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 148) 
2c2709dc6921c drivers/base/power/opp/debugfs.c (Viresh Kumar       2016-02-16 14:17:53 +0530 149) 	opp_set_dev_name(dev, opp_table->dentry_name);
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 150) 
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 151) 	/* Create device specific directory */
2c2709dc6921c drivers/base/power/opp/debugfs.c (Viresh Kumar       2016-02-16 14:17:53 +0530 152) 	d = debugfs_create_dir(opp_table->dentry_name, rootdir);
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 153) 
2c2709dc6921c drivers/base/power/opp/debugfs.c (Viresh Kumar       2016-02-16 14:17:53 +0530 154) 	opp_dev->dentry = d;
2c2709dc6921c drivers/base/power/opp/debugfs.c (Viresh Kumar       2016-02-16 14:17:53 +0530 155) 	opp_table->dentry = d;
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 156) }
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 157) 
a2dea4cb90702 drivers/opp/debugfs.c            (Greg Kroah-Hartman 2019-01-22 16:21:17 +0100 158) static void opp_list_debug_create_link(struct opp_device *opp_dev,
a2dea4cb90702 drivers/opp/debugfs.c            (Greg Kroah-Hartman 2019-01-22 16:21:17 +0100 159) 				       struct opp_table *opp_table)
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 160) {
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 161) 	char name[NAME_MAX];
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 162) 
2c2709dc6921c drivers/base/power/opp/debugfs.c (Viresh Kumar       2016-02-16 14:17:53 +0530 163) 	opp_set_dev_name(opp_dev->dev, name);
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 164) 
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 165) 	/* Create device specific directory link */
a2dea4cb90702 drivers/opp/debugfs.c            (Greg Kroah-Hartman 2019-01-22 16:21:17 +0100 166) 	opp_dev->dentry = debugfs_create_symlink(name, rootdir,
a2dea4cb90702 drivers/opp/debugfs.c            (Greg Kroah-Hartman 2019-01-22 16:21:17 +0100 167) 						 opp_table->dentry_name);
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 168) }
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 169) 
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 170) /**
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 171)  * opp_debug_register - add a device opp node to the debugfs 'opp' directory
2c2709dc6921c drivers/base/power/opp/debugfs.c (Viresh Kumar       2016-02-16 14:17:53 +0530 172)  * @opp_dev: opp-dev pointer for device
2c2709dc6921c drivers/base/power/opp/debugfs.c (Viresh Kumar       2016-02-16 14:17:53 +0530 173)  * @opp_table: the device-opp being added
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 174)  *
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 175)  * Dynamically adds device specific directory in debugfs 'opp' directory. If the
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 176)  * device-opp is shared with other devices, then links will be created for all
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 177)  * devices except the first.
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 178)  */
a2dea4cb90702 drivers/opp/debugfs.c            (Greg Kroah-Hartman 2019-01-22 16:21:17 +0100 179) void opp_debug_register(struct opp_device *opp_dev, struct opp_table *opp_table)
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 180) {
2c2709dc6921c drivers/base/power/opp/debugfs.c (Viresh Kumar       2016-02-16 14:17:53 +0530 181) 	if (opp_table->dentry)
a2dea4cb90702 drivers/opp/debugfs.c            (Greg Kroah-Hartman 2019-01-22 16:21:17 +0100 182) 		opp_list_debug_create_link(opp_dev, opp_table);
a2dea4cb90702 drivers/opp/debugfs.c            (Greg Kroah-Hartman 2019-01-22 16:21:17 +0100 183) 	else
a2dea4cb90702 drivers/opp/debugfs.c            (Greg Kroah-Hartman 2019-01-22 16:21:17 +0100 184) 		opp_list_debug_create_dir(opp_dev, opp_table);
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 185) }
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 186) 
2c2709dc6921c drivers/base/power/opp/debugfs.c (Viresh Kumar       2016-02-16 14:17:53 +0530 187) static void opp_migrate_dentry(struct opp_device *opp_dev,
2c2709dc6921c drivers/base/power/opp/debugfs.c (Viresh Kumar       2016-02-16 14:17:53 +0530 188) 			       struct opp_table *opp_table)
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 189) {
2c2709dc6921c drivers/base/power/opp/debugfs.c (Viresh Kumar       2016-02-16 14:17:53 +0530 190) 	struct opp_device *new_dev;
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 191) 	const struct device *dev;
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 192) 	struct dentry *dentry;
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 193) 
2c2709dc6921c drivers/base/power/opp/debugfs.c (Viresh Kumar       2016-02-16 14:17:53 +0530 194) 	/* Look for next opp-dev */
2c2709dc6921c drivers/base/power/opp/debugfs.c (Viresh Kumar       2016-02-16 14:17:53 +0530 195) 	list_for_each_entry(new_dev, &opp_table->dev_list, node)
2c2709dc6921c drivers/base/power/opp/debugfs.c (Viresh Kumar       2016-02-16 14:17:53 +0530 196) 		if (new_dev != opp_dev)
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 197) 			break;
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 198) 
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 199) 	/* new_dev is guaranteed to be valid here */
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 200) 	dev = new_dev->dev;
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 201) 	debugfs_remove_recursive(new_dev->dentry);
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 202) 
2c2709dc6921c drivers/base/power/opp/debugfs.c (Viresh Kumar       2016-02-16 14:17:53 +0530 203) 	opp_set_dev_name(dev, opp_table->dentry_name);
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 204) 
2c2709dc6921c drivers/base/power/opp/debugfs.c (Viresh Kumar       2016-02-16 14:17:53 +0530 205) 	dentry = debugfs_rename(rootdir, opp_dev->dentry, rootdir,
2c2709dc6921c drivers/base/power/opp/debugfs.c (Viresh Kumar       2016-02-16 14:17:53 +0530 206) 				opp_table->dentry_name);
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 207) 	if (!dentry) {
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 208) 		dev_err(dev, "%s: Failed to rename link from: %s to %s\n",
2c2709dc6921c drivers/base/power/opp/debugfs.c (Viresh Kumar       2016-02-16 14:17:53 +0530 209) 			__func__, dev_name(opp_dev->dev), dev_name(dev));
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 210) 		return;
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 211) 	}
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 212) 
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 213) 	new_dev->dentry = dentry;
2c2709dc6921c drivers/base/power/opp/debugfs.c (Viresh Kumar       2016-02-16 14:17:53 +0530 214) 	opp_table->dentry = dentry;
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 215) }
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 216) 
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 217) /**
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 218)  * opp_debug_unregister - remove a device opp node from debugfs opp directory
2c2709dc6921c drivers/base/power/opp/debugfs.c (Viresh Kumar       2016-02-16 14:17:53 +0530 219)  * @opp_dev: opp-dev pointer for device
2c2709dc6921c drivers/base/power/opp/debugfs.c (Viresh Kumar       2016-02-16 14:17:53 +0530 220)  * @opp_table: the device-opp being removed
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 221)  *
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 222)  * Dynamically removes device specific directory from debugfs 'opp' directory.
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 223)  */
2c2709dc6921c drivers/base/power/opp/debugfs.c (Viresh Kumar       2016-02-16 14:17:53 +0530 224) void opp_debug_unregister(struct opp_device *opp_dev,
2c2709dc6921c drivers/base/power/opp/debugfs.c (Viresh Kumar       2016-02-16 14:17:53 +0530 225) 			  struct opp_table *opp_table)
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 226) {
2c2709dc6921c drivers/base/power/opp/debugfs.c (Viresh Kumar       2016-02-16 14:17:53 +0530 227) 	if (opp_dev->dentry == opp_table->dentry) {
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 228) 		/* Move the real dentry object under another device */
2c2709dc6921c drivers/base/power/opp/debugfs.c (Viresh Kumar       2016-02-16 14:17:53 +0530 229) 		if (!list_is_singular(&opp_table->dev_list)) {
2c2709dc6921c drivers/base/power/opp/debugfs.c (Viresh Kumar       2016-02-16 14:17:53 +0530 230) 			opp_migrate_dentry(opp_dev, opp_table);
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 231) 			goto out;
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 232) 		}
2c2709dc6921c drivers/base/power/opp/debugfs.c (Viresh Kumar       2016-02-16 14:17:53 +0530 233) 		opp_table->dentry = NULL;
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 234) 	}
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 235) 
2c2709dc6921c drivers/base/power/opp/debugfs.c (Viresh Kumar       2016-02-16 14:17:53 +0530 236) 	debugfs_remove_recursive(opp_dev->dentry);
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 237) 
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 238) out:
2c2709dc6921c drivers/base/power/opp/debugfs.c (Viresh Kumar       2016-02-16 14:17:53 +0530 239) 	opp_dev->dentry = NULL;
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 240) }
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 241) 
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 242) static int __init opp_debug_init(void)
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 243) {
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 244) 	/* Create /sys/kernel/debug/opp directory */
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 245) 	rootdir = debugfs_create_dir("opp", NULL);
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 246) 
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 247) 	return 0;
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 248) }
deaa51465105a drivers/base/power/opp/debugfs.c (Viresh Kumar       2015-11-11 07:59:01 +0530 249) core_initcall(opp_debug_init);