diff options
author | Hanjun Guo <hanjun.guo@linaro.org> | 2015-05-11 00:17:13 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2015-05-13 17:28:14 -0400 |
commit | 25956b6612601cf36022392ffa83f6bf97939bcd (patch) | |
tree | f3b8efbce1c45c7ccf5796e38046f13477d22a76 | |
parent | 030bbdbf4c833bc69f502eae58498bc5572db736 (diff) |
ACPI / processor: Introduce invalid_logical_cpuid()
In ACPI processor drivers, we use direct comparisons of cpu logical
id with -1 which are error prone in case logical cpuid is accidentally
assinged an error code and prevents us from returning an error-encoding
cpuid directly in some cases.
So introduce invalid_logical_cpuid() to identify cpu with invalid
logical cpu num, then it will be used to replace the direct comparisons
with -1.
Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r-- | drivers/acpi/acpi_processor.c | 5 | ||||
-rw-r--r-- | drivers/acpi/processor_pdc.c | 5 | ||||
-rw-r--r-- | include/linux/acpi.h | 5 |
3 files changed, 9 insertions, 6 deletions
diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c index 58f335ca2e75..ac6bda030a74 100644 --- a/drivers/acpi/acpi_processor.c +++ b/drivers/acpi/acpi_processor.c | |||
@@ -275,7 +275,8 @@ static int acpi_processor_get_info(struct acpi_device *device) | |||
275 | * Handle UP system running SMP kernel, with no CPU | 275 | * Handle UP system running SMP kernel, with no CPU |
276 | * entry in MADT | 276 | * entry in MADT |
277 | */ | 277 | */ |
278 | if ((cpu_index == -1) && (num_online_cpus() == 1)) | 278 | if (invalid_logical_cpuid(cpu_index) |
279 | && (num_online_cpus() == 1)) | ||
279 | cpu_index = 0; | 280 | cpu_index = 0; |
280 | } | 281 | } |
281 | pr->id = cpu_index; | 282 | pr->id = cpu_index; |
@@ -285,7 +286,7 @@ static int acpi_processor_get_info(struct acpi_device *device) | |||
285 | * less than the max # of CPUs. They should be ignored _iff | 286 | * less than the max # of CPUs. They should be ignored _iff |
286 | * they are physically not present. | 287 | * they are physically not present. |
287 | */ | 288 | */ |
288 | if (pr->id == -1) { | 289 | if (invalid_logical_cpuid(pr->id)) { |
289 | int ret = acpi_processor_hotadd_init(pr); | 290 | int ret = acpi_processor_hotadd_init(pr); |
290 | if (ret) | 291 | if (ret) |
291 | return ret; | 292 | return ret; |
diff --git a/drivers/acpi/processor_pdc.c b/drivers/acpi/processor_pdc.c index e5dd80800930..7cfbda4d7c51 100644 --- a/drivers/acpi/processor_pdc.c +++ b/drivers/acpi/processor_pdc.c | |||
@@ -52,10 +52,7 @@ static bool __init processor_physically_present(acpi_handle handle) | |||
52 | type = (acpi_type == ACPI_TYPE_DEVICE) ? 1 : 0; | 52 | type = (acpi_type == ACPI_TYPE_DEVICE) ? 1 : 0; |
53 | cpuid = acpi_get_cpuid(handle, type, acpi_id); | 53 | cpuid = acpi_get_cpuid(handle, type, acpi_id); |
54 | 54 | ||
55 | if (cpuid == -1) | 55 | return !invalid_logical_cpuid(cpuid); |
56 | return false; | ||
57 | |||
58 | return true; | ||
59 | } | 56 | } |
60 | 57 | ||
61 | static void acpi_set_pdc_bits(u32 *buf) | 58 | static void acpi_set_pdc_bits(u32 *buf) |
diff --git a/include/linux/acpi.h b/include/linux/acpi.h index e4da5e35e29c..913b49f9a6e6 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h | |||
@@ -158,6 +158,11 @@ typedef u32 phys_cpuid_t; | |||
158 | #define PHYS_CPUID_INVALID (phys_cpuid_t)(-1) | 158 | #define PHYS_CPUID_INVALID (phys_cpuid_t)(-1) |
159 | #endif | 159 | #endif |
160 | 160 | ||
161 | static inline bool invalid_logical_cpuid(u32 cpuid) | ||
162 | { | ||
163 | return (int)cpuid < 0; | ||
164 | } | ||
165 | |||
161 | #ifdef CONFIG_ACPI_HOTPLUG_CPU | 166 | #ifdef CONFIG_ACPI_HOTPLUG_CPU |
162 | /* Arch dependent functions for cpu hotplug support */ | 167 | /* Arch dependent functions for cpu hotplug support */ |
163 | int acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, int *pcpu); | 168 | int acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, int *pcpu); |