diff options
| -rw-r--r-- | drivers/opp/core.c | 11 | ||||
| -rw-r--r-- | drivers/opp/debugfs.c | 110 | ||||
| -rw-r--r-- | drivers/opp/opp.h | 15 |
3 files changed, 38 insertions, 98 deletions
diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 57d88a275de0..fa15aa8e00b0 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c | |||
| @@ -792,7 +792,6 @@ static struct opp_device *_add_opp_dev_unlocked(const struct device *dev, | |||
| 792 | struct opp_table *opp_table) | 792 | struct opp_table *opp_table) |
| 793 | { | 793 | { |
| 794 | struct opp_device *opp_dev; | 794 | struct opp_device *opp_dev; |
| 795 | int ret; | ||
| 796 | 795 | ||
| 797 | opp_dev = kzalloc(sizeof(*opp_dev), GFP_KERNEL); | 796 | opp_dev = kzalloc(sizeof(*opp_dev), GFP_KERNEL); |
| 798 | if (!opp_dev) | 797 | if (!opp_dev) |
| @@ -804,10 +803,7 @@ static struct opp_device *_add_opp_dev_unlocked(const struct device *dev, | |||
| 804 | list_add(&opp_dev->node, &opp_table->dev_list); | 803 | list_add(&opp_dev->node, &opp_table->dev_list); |
| 805 | 804 | ||
| 806 | /* Create debugfs entries for the opp_table */ | 805 | /* Create debugfs entries for the opp_table */ |
| 807 | ret = opp_debug_register(opp_dev, opp_table); | 806 | opp_debug_register(opp_dev, opp_table); |
| 808 | if (ret) | ||
| 809 | dev_err(dev, "%s: Failed to register opp debugfs (%d)\n", | ||
| 810 | __func__, ret); | ||
| 811 | 807 | ||
| 812 | return opp_dev; | 808 | return opp_dev; |
| 813 | } | 809 | } |
| @@ -1175,10 +1171,7 @@ int _opp_add(struct device *dev, struct dev_pm_opp *new_opp, | |||
| 1175 | new_opp->opp_table = opp_table; | 1171 | new_opp->opp_table = opp_table; |
| 1176 | kref_init(&new_opp->kref); | 1172 | kref_init(&new_opp->kref); |
| 1177 | 1173 | ||
| 1178 | ret = opp_debug_create_one(new_opp, opp_table); | 1174 | opp_debug_create_one(new_opp, opp_table); |
| 1179 | if (ret) | ||
| 1180 | dev_err(dev, "%s: Failed to register opp to debugfs (%d)\n", | ||
| 1181 | __func__, ret); | ||
| 1182 | 1175 | ||
| 1183 | if (!_opp_supported_by_regulators(new_opp, opp_table)) { | 1176 | if (!_opp_supported_by_regulators(new_opp, opp_table)) { |
| 1184 | new_opp->available = false; | 1177 | new_opp->available = false; |
diff --git a/drivers/opp/debugfs.c b/drivers/opp/debugfs.c index e6828e5f81b0..a1c57fe14de4 100644 --- a/drivers/opp/debugfs.c +++ b/drivers/opp/debugfs.c | |||
| @@ -35,7 +35,7 @@ void opp_debug_remove_one(struct dev_pm_opp *opp) | |||
| 35 | debugfs_remove_recursive(opp->dentry); | 35 | debugfs_remove_recursive(opp->dentry); |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | static bool opp_debug_create_supplies(struct dev_pm_opp *opp, | 38 | static void opp_debug_create_supplies(struct dev_pm_opp *opp, |
| 39 | struct opp_table *opp_table, | 39 | struct opp_table *opp_table, |
| 40 | struct dentry *pdentry) | 40 | struct dentry *pdentry) |
| 41 | { | 41 | { |
| @@ -50,30 +50,21 @@ static bool opp_debug_create_supplies(struct dev_pm_opp *opp, | |||
| 50 | /* Create per-opp directory */ | 50 | /* Create per-opp directory */ |
| 51 | d = debugfs_create_dir(name, pdentry); | 51 | d = debugfs_create_dir(name, pdentry); |
| 52 | 52 | ||
| 53 | if (!d) | 53 | debugfs_create_ulong("u_volt_target", S_IRUGO, d, |
| 54 | return false; | 54 | &opp->supplies[i].u_volt); |
| 55 | 55 | ||
| 56 | if (!debugfs_create_ulong("u_volt_target", S_IRUGO, d, | 56 | debugfs_create_ulong("u_volt_min", S_IRUGO, d, |
| 57 | &opp->supplies[i].u_volt)) | 57 | &opp->supplies[i].u_volt_min); |
| 58 | return false; | ||
| 59 | 58 | ||
| 60 | if (!debugfs_create_ulong("u_volt_min", S_IRUGO, d, | 59 | debugfs_create_ulong("u_volt_max", S_IRUGO, d, |
| 61 | &opp->supplies[i].u_volt_min)) | 60 | &opp->supplies[i].u_volt_max); |
| 62 | return false; | ||
| 63 | 61 | ||
| 64 | if (!debugfs_create_ulong("u_volt_max", S_IRUGO, d, | 62 | debugfs_create_ulong("u_amp", S_IRUGO, d, |
| 65 | &opp->supplies[i].u_volt_max)) | 63 | &opp->supplies[i].u_amp); |
| 66 | return false; | ||
| 67 | |||
| 68 | if (!debugfs_create_ulong("u_amp", S_IRUGO, d, | ||
| 69 | &opp->supplies[i].u_amp)) | ||
| 70 | return false; | ||
| 71 | } | 64 | } |
| 72 | |||
| 73 | return true; | ||
| 74 | } | 65 | } |
| 75 | 66 | ||
| 76 | int opp_debug_create_one(struct dev_pm_opp *opp, struct opp_table *opp_table) | 67 | void opp_debug_create_one(struct dev_pm_opp *opp, struct opp_table *opp_table) |
| 77 | { | 68 | { |
| 78 | struct dentry *pdentry = opp_table->dentry; | 69 | struct dentry *pdentry = opp_table->dentry; |
| 79 | struct dentry *d; | 70 | struct dentry *d; |
| @@ -95,40 +86,23 @@ int opp_debug_create_one(struct dev_pm_opp *opp, struct opp_table *opp_table) | |||
| 95 | 86 | ||
| 96 | /* Create per-opp directory */ | 87 | /* Create per-opp directory */ |
| 97 | d = debugfs_create_dir(name, pdentry); | 88 | d = debugfs_create_dir(name, pdentry); |
| 98 | if (!d) | ||
| 99 | return -ENOMEM; | ||
| 100 | |||
| 101 | if (!debugfs_create_bool("available", S_IRUGO, d, &opp->available)) | ||
| 102 | return -ENOMEM; | ||
| 103 | |||
| 104 | if (!debugfs_create_bool("dynamic", S_IRUGO, d, &opp->dynamic)) | ||
| 105 | return -ENOMEM; | ||
| 106 | |||
| 107 | if (!debugfs_create_bool("turbo", S_IRUGO, d, &opp->turbo)) | ||
| 108 | return -ENOMEM; | ||
| 109 | |||
| 110 | if (!debugfs_create_bool("suspend", S_IRUGO, d, &opp->suspend)) | ||
| 111 | return -ENOMEM; | ||
| 112 | |||
| 113 | if (!debugfs_create_u32("performance_state", S_IRUGO, d, &opp->pstate)) | ||
| 114 | return -ENOMEM; | ||
| 115 | 89 | ||
| 116 | if (!debugfs_create_ulong("rate_hz", S_IRUGO, d, &opp->rate)) | 90 | debugfs_create_bool("available", S_IRUGO, d, &opp->available); |
| 117 | return -ENOMEM; | 91 | debugfs_create_bool("dynamic", S_IRUGO, d, &opp->dynamic); |
| 92 | debugfs_create_bool("turbo", S_IRUGO, d, &opp->turbo); | ||
| 93 | debugfs_create_bool("suspend", S_IRUGO, d, &opp->suspend); | ||
| 94 | debugfs_create_u32("performance_state", S_IRUGO, d, &opp->pstate); | ||
| 95 | debugfs_create_ulong("rate_hz", S_IRUGO, d, &opp->rate); | ||
| 96 | debugfs_create_ulong("clock_latency_ns", S_IRUGO, d, | ||
| 97 | &opp->clock_latency_ns); | ||
| 118 | 98 | ||
| 119 | if (!opp_debug_create_supplies(opp, opp_table, d)) | 99 | opp_debug_create_supplies(opp, opp_table, d); |
| 120 | return -ENOMEM; | ||
| 121 | |||
| 122 | if (!debugfs_create_ulong("clock_latency_ns", S_IRUGO, d, | ||
| 123 | &opp->clock_latency_ns)) | ||
| 124 | return -ENOMEM; | ||
| 125 | 100 | ||
| 126 | opp->dentry = d; | 101 | opp->dentry = d; |
| 127 | return 0; | ||
| 128 | } | 102 | } |
| 129 | 103 | ||
| 130 | static int opp_list_debug_create_dir(struct opp_device *opp_dev, | 104 | static void opp_list_debug_create_dir(struct opp_device *opp_dev, |
| 131 | struct opp_table *opp_table) | 105 | struct opp_table *opp_table) |
| 132 | { | 106 | { |
| 133 | const struct device *dev = opp_dev->dev; | 107 | const struct device *dev = opp_dev->dev; |
| 134 | struct dentry *d; | 108 | struct dentry *d; |
| @@ -137,36 +111,21 @@ static int opp_list_debug_create_dir(struct opp_device *opp_dev, | |||
| 137 | 111 | ||
| 138 | /* Create device specific directory */ | 112 | /* Create device specific directory */ |
| 139 | d = debugfs_create_dir(opp_table->dentry_name, rootdir); | 113 | d = debugfs_create_dir(opp_table->dentry_name, rootdir); |
| 140 | if (!d) { | ||
| 141 | dev_err(dev, "%s: Failed to create debugfs dir\n", __func__); | ||
| 142 | return -ENOMEM; | ||
| 143 | } | ||
| 144 | 114 | ||
| 145 | opp_dev->dentry = d; | 115 | opp_dev->dentry = d; |
| 146 | opp_table->dentry = d; | 116 | opp_table->dentry = d; |
| 147 | |||
| 148 | return 0; | ||
| 149 | } | 117 | } |
| 150 | 118 | ||
| 151 | static int opp_list_debug_create_link(struct opp_device *opp_dev, | 119 | static void opp_list_debug_create_link(struct opp_device *opp_dev, |
| 152 | struct opp_table *opp_table) | 120 | struct opp_table *opp_table) |
| 153 | { | 121 | { |
| 154 | const struct device *dev = opp_dev->dev; | ||
| 155 | char name[NAME_MAX]; | 122 | char name[NAME_MAX]; |
| 156 | struct dentry *d; | ||
| 157 | 123 | ||
| 158 | opp_set_dev_name(opp_dev->dev, name); | 124 | opp_set_dev_name(opp_dev->dev, name); |
| 159 | 125 | ||
| 160 | /* Create device specific directory link */ | 126 | /* Create device specific directory link */ |
| 161 | d = debugfs_create_symlink(name, rootdir, opp_table->dentry_name); | 127 | opp_dev->dentry = debugfs_create_symlink(name, rootdir, |
| 162 | if (!d) { | 128 | opp_table->dentry_name); |
| 163 | dev_err(dev, "%s: Failed to create link\n", __func__); | ||
| 164 | return -ENOMEM; | ||
| 165 | } | ||
| 166 | |||
| 167 | opp_dev->dentry = d; | ||
| 168 | |||
| 169 | return 0; | ||
| 170 | } | 129 | } |
| 171 | 130 | ||
| 172 | /** | 131 | /** |
| @@ -177,20 +136,13 @@ static int opp_list_debug_create_link(struct opp_device *opp_dev, | |||
| 177 | * Dynamically adds device specific directory in debugfs 'opp' directory. If the | 136 | * Dynamically adds device specific directory in debugfs 'opp' directory. If the |
| 178 | * device-opp is shared with other devices, then links will be created for all | 137 | * device-opp is shared with other devices, then links will be created for all |
| 179 | * devices except the first. | 138 | * devices except the first. |
| 180 | * | ||
| 181 | * Return: 0 on success, otherwise negative error. | ||
| 182 | */ | 139 | */ |
| 183 | int opp_debug_register(struct opp_device *opp_dev, struct opp_table *opp_table) | 140 | void opp_debug_register(struct opp_device *opp_dev, struct opp_table *opp_table) |
| 184 | { | 141 | { |
| 185 | if (!rootdir) { | ||
| 186 | pr_debug("%s: Uninitialized rootdir\n", __func__); | ||
| 187 | return -EINVAL; | ||
| 188 | } | ||
| 189 | |||
| 190 | if (opp_table->dentry) | 142 | if (opp_table->dentry) |
| 191 | return opp_list_debug_create_link(opp_dev, opp_table); | 143 | opp_list_debug_create_link(opp_dev, opp_table); |
| 192 | 144 | else | |
| 193 | return opp_list_debug_create_dir(opp_dev, opp_table); | 145 | opp_list_debug_create_dir(opp_dev, opp_table); |
| 194 | } | 146 | } |
| 195 | 147 | ||
| 196 | static void opp_migrate_dentry(struct opp_device *opp_dev, | 148 | static void opp_migrate_dentry(struct opp_device *opp_dev, |
| @@ -252,10 +204,6 @@ static int __init opp_debug_init(void) | |||
| 252 | { | 204 | { |
| 253 | /* Create /sys/kernel/debug/opp directory */ | 205 | /* Create /sys/kernel/debug/opp directory */ |
| 254 | rootdir = debugfs_create_dir("opp", NULL); | 206 | rootdir = debugfs_create_dir("opp", NULL); |
| 255 | if (!rootdir) { | ||
| 256 | pr_err("%s: Failed to create root directory\n", __func__); | ||
| 257 | return -ENOMEM; | ||
| 258 | } | ||
| 259 | 207 | ||
| 260 | return 0; | 208 | return 0; |
| 261 | } | 209 | } |
diff --git a/drivers/opp/opp.h b/drivers/opp/opp.h index e24d81497375..810a85b9a66d 100644 --- a/drivers/opp/opp.h +++ b/drivers/opp/opp.h | |||
| @@ -236,18 +236,17 @@ static inline void _of_opp_free_required_opps(struct opp_table *opp_table, | |||
| 236 | 236 | ||
| 237 | #ifdef CONFIG_DEBUG_FS | 237 | #ifdef CONFIG_DEBUG_FS |
| 238 | void opp_debug_remove_one(struct dev_pm_opp *opp); | 238 | void opp_debug_remove_one(struct dev_pm_opp *opp); |
| 239 | int opp_debug_create_one(struct dev_pm_opp *opp, struct opp_table *opp_table); | 239 | void opp_debug_create_one(struct dev_pm_opp *opp, struct opp_table *opp_table); |
| 240 | int opp_debug_register(struct opp_device *opp_dev, struct opp_table *opp_table); | 240 | void opp_debug_register(struct opp_device *opp_dev, struct opp_table *opp_table); |
| 241 | void opp_debug_unregister(struct opp_device *opp_dev, struct opp_table *opp_table); | 241 | void opp_debug_unregister(struct opp_device *opp_dev, struct opp_table *opp_table); |
| 242 | #else | 242 | #else |
| 243 | static inline void opp_debug_remove_one(struct dev_pm_opp *opp) {} | 243 | static inline void opp_debug_remove_one(struct dev_pm_opp *opp) {} |
| 244 | 244 | ||
| 245 | static inline int opp_debug_create_one(struct dev_pm_opp *opp, | 245 | static inline void opp_debug_create_one(struct dev_pm_opp *opp, |
| 246 | struct opp_table *opp_table) | 246 | struct opp_table *opp_table) { } |
| 247 | { return 0; } | 247 | |
| 248 | static inline int opp_debug_register(struct opp_device *opp_dev, | 248 | static inline void opp_debug_register(struct opp_device *opp_dev, |
| 249 | struct opp_table *opp_table) | 249 | struct opp_table *opp_table) { } |
| 250 | { return 0; } | ||
| 251 | 250 | ||
| 252 | static inline void opp_debug_unregister(struct opp_device *opp_dev, | 251 | static inline void opp_debug_unregister(struct opp_device *opp_dev, |
| 253 | struct opp_table *opp_table) | 252 | struct opp_table *opp_table) |
