diff options
Diffstat (limited to 'arch/powerpc/kernel/sysfs.c')
-rw-r--r-- | arch/powerpc/kernel/sysfs.c | 46 |
1 files changed, 8 insertions, 38 deletions
diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c index e235e52dc4fe..c0d8c2006bf4 100644 --- a/arch/powerpc/kernel/sysfs.c +++ b/arch/powerpc/kernel/sysfs.c | |||
@@ -35,7 +35,7 @@ static DEFINE_PER_CPU(struct cpu, cpu_devices); | |||
35 | #ifdef CONFIG_PPC64 | 35 | #ifdef CONFIG_PPC64 |
36 | 36 | ||
37 | /* Time in microseconds we delay before sleeping in the idle loop */ | 37 | /* Time in microseconds we delay before sleeping in the idle loop */ |
38 | DEFINE_PER_CPU(unsigned long, smt_snooze_delay) = { 100 }; | 38 | DEFINE_PER_CPU(long, smt_snooze_delay) = { 100 }; |
39 | 39 | ||
40 | static ssize_t store_smt_snooze_delay(struct sys_device *dev, | 40 | static ssize_t store_smt_snooze_delay(struct sys_device *dev, |
41 | struct sysdev_attribute *attr, | 41 | struct sysdev_attribute *attr, |
@@ -44,9 +44,9 @@ static ssize_t store_smt_snooze_delay(struct sys_device *dev, | |||
44 | { | 44 | { |
45 | struct cpu *cpu = container_of(dev, struct cpu, sysdev); | 45 | struct cpu *cpu = container_of(dev, struct cpu, sysdev); |
46 | ssize_t ret; | 46 | ssize_t ret; |
47 | unsigned long snooze; | 47 | long snooze; |
48 | 48 | ||
49 | ret = sscanf(buf, "%lu", &snooze); | 49 | ret = sscanf(buf, "%ld", &snooze); |
50 | if (ret != 1) | 50 | if (ret != 1) |
51 | return -EINVAL; | 51 | return -EINVAL; |
52 | 52 | ||
@@ -61,53 +61,23 @@ static ssize_t show_smt_snooze_delay(struct sys_device *dev, | |||
61 | { | 61 | { |
62 | struct cpu *cpu = container_of(dev, struct cpu, sysdev); | 62 | struct cpu *cpu = container_of(dev, struct cpu, sysdev); |
63 | 63 | ||
64 | return sprintf(buf, "%lu\n", per_cpu(smt_snooze_delay, cpu->sysdev.id)); | 64 | return sprintf(buf, "%ld\n", per_cpu(smt_snooze_delay, cpu->sysdev.id)); |
65 | } | 65 | } |
66 | 66 | ||
67 | static SYSDEV_ATTR(smt_snooze_delay, 0644, show_smt_snooze_delay, | 67 | static SYSDEV_ATTR(smt_snooze_delay, 0644, show_smt_snooze_delay, |
68 | store_smt_snooze_delay); | 68 | store_smt_snooze_delay); |
69 | 69 | ||
70 | /* Only parse OF options if the matching cmdline option was not specified */ | ||
71 | static int smt_snooze_cmdline; | ||
72 | |||
73 | static int __init smt_setup(void) | ||
74 | { | ||
75 | struct device_node *options; | ||
76 | const unsigned int *val; | ||
77 | unsigned int cpu; | ||
78 | |||
79 | if (!cpu_has_feature(CPU_FTR_SMT)) | ||
80 | return -ENODEV; | ||
81 | |||
82 | options = of_find_node_by_path("/options"); | ||
83 | if (!options) | ||
84 | return -ENODEV; | ||
85 | |||
86 | val = of_get_property(options, "ibm,smt-snooze-delay", NULL); | ||
87 | if (!smt_snooze_cmdline && val) { | ||
88 | for_each_possible_cpu(cpu) | ||
89 | per_cpu(smt_snooze_delay, cpu) = *val; | ||
90 | } | ||
91 | |||
92 | of_node_put(options); | ||
93 | return 0; | ||
94 | } | ||
95 | __initcall(smt_setup); | ||
96 | |||
97 | static int __init setup_smt_snooze_delay(char *str) | 70 | static int __init setup_smt_snooze_delay(char *str) |
98 | { | 71 | { |
99 | unsigned int cpu; | 72 | unsigned int cpu; |
100 | int snooze; | 73 | long snooze; |
101 | 74 | ||
102 | if (!cpu_has_feature(CPU_FTR_SMT)) | 75 | if (!cpu_has_feature(CPU_FTR_SMT)) |
103 | return 1; | 76 | return 1; |
104 | 77 | ||
105 | smt_snooze_cmdline = 1; | 78 | snooze = simple_strtol(str, NULL, 10); |
106 | 79 | for_each_possible_cpu(cpu) | |
107 | if (get_option(&str, &snooze)) { | 80 | per_cpu(smt_snooze_delay, cpu) = snooze; |
108 | for_each_possible_cpu(cpu) | ||
109 | per_cpu(smt_snooze_delay, cpu) = snooze; | ||
110 | } | ||
111 | 81 | ||
112 | return 1; | 82 | return 1; |
113 | } | 83 | } |