aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLv Zheng <lv.zheng@intel.com>2015-08-05 04:23:57 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2015-08-06 20:42:22 -0400
commita0186bcf7c21907c78ab2b4bc50f3fb2b5047806 (patch)
tree2826d7cbdddc8d61d4cf5660d5d9aee69b6dfe30
parent7901a052a981691d18f4e8f91fc27e40849b7336 (diff)
ACPI / sysfs: Add support to allow leading "\" missing in trace_method_name.
Since _SB.PCI0 can be used as relative path from root and can be easily converted into internal trace_method_name format, we allow users to specify trace_method_name using relative paths from root. Note this is useful for grub2 for which users failed to pass "\" from the grub configuration file. Signed-off-by: Lv Zheng <lv.zheng@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r--drivers/acpi/sysfs.c28
1 files changed, 13 insertions, 15 deletions
diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
index 8979e4a8d066..40a42655227c 100644
--- a/drivers/acpi/sysfs.c
+++ b/drivers/acpi/sysfs.c
@@ -164,14 +164,18 @@ static const struct kernel_param_ops param_ops_debug_level = {
164module_param_cb(debug_layer, &param_ops_debug_layer, &acpi_dbg_layer, 0644); 164module_param_cb(debug_layer, &param_ops_debug_layer, &acpi_dbg_layer, 0644);
165module_param_cb(debug_level, &param_ops_debug_level, &acpi_dbg_level, 0644); 165module_param_cb(debug_level, &param_ops_debug_level, &acpi_dbg_level, 0644);
166 166
167static char* trace_method_name; 167static char trace_method_name[1024];
168static bool trace_method_kmalloced;
169 168
170int param_set_trace_method_name(const char *val, const struct kernel_param *kp) 169int param_set_trace_method_name(const char *val, const struct kernel_param *kp)
171{ 170{
172 u32 saved_flags = 0; 171 u32 saved_flags = 0;
172 bool is_abs_path = true;
173 173
174 if (strlen(val) > 1024) { 174 if (*val != '\\')
175 is_abs_path = false;
176
177 if ((is_abs_path && strlen(val) > 1023) ||
178 (!is_abs_path && strlen(val) > 1022)) {
175 pr_err("%s: string parameter too long\n", kp->name); 179 pr_err("%s: string parameter too long\n", kp->name);
176 return -ENOSPC; 180 return -ENOSPC;
177 } 181 }
@@ -187,19 +191,13 @@ int param_set_trace_method_name(const char *val, const struct kernel_param *kp)
187 acpi_gbl_trace_dbg_layer, 191 acpi_gbl_trace_dbg_layer,
188 0); 192 0);
189 193
190 if (trace_method_kmalloced)
191 kfree(trace_method_name);
192 trace_method_name = NULL;
193 trace_method_kmalloced = false;
194
195 /* This is a hack. We can't kmalloc in early boot. */ 194 /* This is a hack. We can't kmalloc in early boot. */
196 if (slab_is_available()) { 195 if (is_abs_path)
197 trace_method_name = kstrdup(val, GFP_KERNEL); 196 strcpy(trace_method_name, val);
198 if (!trace_method_name) 197 else {
199 return -ENOMEM; 198 trace_method_name[0] = '\\';
200 trace_method_kmalloced = true; 199 strcpy(trace_method_name+1, val);
201 } else 200 }
202 trace_method_name = (char *)val;
203 201
204 /* Restore the original tracer state */ 202 /* Restore the original tracer state */
205 (void)acpi_debug_trace(trace_method_name, 203 (void)acpi_debug_trace(trace_method_name,