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>
This commit is contained in:
parent
7901a052a9
commit
a0186bcf7c
|
@ -164,14 +164,18 @@ static const struct kernel_param_ops param_ops_debug_level = {
|
||||||
module_param_cb(debug_layer, ¶m_ops_debug_layer, &acpi_dbg_layer, 0644);
|
module_param_cb(debug_layer, ¶m_ops_debug_layer, &acpi_dbg_layer, 0644);
|
||||||
module_param_cb(debug_level, ¶m_ops_debug_level, &acpi_dbg_level, 0644);
|
module_param_cb(debug_level, ¶m_ops_debug_level, &acpi_dbg_level, 0644);
|
||||||
|
|
||||||
static char* trace_method_name;
|
static char trace_method_name[1024];
|
||||||
static bool trace_method_kmalloced;
|
|
||||||
|
|
||||||
int param_set_trace_method_name(const char *val, const struct kernel_param *kp)
|
int param_set_trace_method_name(const char *val, const struct kernel_param *kp)
|
||||||
{
|
{
|
||||||
u32 saved_flags = 0;
|
u32 saved_flags = 0;
|
||||||
|
bool is_abs_path = true;
|
||||||
|
|
||||||
if (strlen(val) > 1024) {
|
if (*val != '\\')
|
||||||
|
is_abs_path = false;
|
||||||
|
|
||||||
|
if ((is_abs_path && strlen(val) > 1023) ||
|
||||||
|
(!is_abs_path && strlen(val) > 1022)) {
|
||||||
pr_err("%s: string parameter too long\n", kp->name);
|
pr_err("%s: string parameter too long\n", kp->name);
|
||||||
return -ENOSPC;
|
return -ENOSPC;
|
||||||
}
|
}
|
||||||
|
@ -187,19 +191,13 @@ int param_set_trace_method_name(const char *val, const struct kernel_param *kp)
|
||||||
acpi_gbl_trace_dbg_layer,
|
acpi_gbl_trace_dbg_layer,
|
||||||
0);
|
0);
|
||||||
|
|
||||||
if (trace_method_kmalloced)
|
|
||||||
kfree(trace_method_name);
|
|
||||||
trace_method_name = NULL;
|
|
||||||
trace_method_kmalloced = false;
|
|
||||||
|
|
||||||
/* This is a hack. We can't kmalloc in early boot. */
|
/* This is a hack. We can't kmalloc in early boot. */
|
||||||
if (slab_is_available()) {
|
if (is_abs_path)
|
||||||
trace_method_name = kstrdup(val, GFP_KERNEL);
|
strcpy(trace_method_name, val);
|
||||||
if (!trace_method_name)
|
else {
|
||||||
return -ENOMEM;
|
trace_method_name[0] = '\\';
|
||||||
trace_method_kmalloced = true;
|
strcpy(trace_method_name+1, val);
|
||||||
} else
|
}
|
||||||
trace_method_name = (char *)val;
|
|
||||||
|
|
||||||
/* Restore the original tracer state */
|
/* Restore the original tracer state */
|
||||||
(void)acpi_debug_trace(trace_method_name,
|
(void)acpi_debug_trace(trace_method_name,
|
||||||
|
|
Loading…
Reference in New Issue