diff options
author | Lv Zheng <lv.zheng@intel.com> | 2016-12-14 02:04:39 -0500 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2016-12-20 20:36:38 -0500 |
commit | 6b11d1d677132816252004426ef220ccd3c92d2f (patch) | |
tree | a512975fe6a4602264de5cbccd8926d0c121a0e6 /drivers/acpi | |
parent | 66360faa4333babc53836c7b59a0cff68cb0a9c6 (diff) |
ACPI / osl: Remove acpi_get_table_with_size()/early_acpi_os_unmap_memory() users
This patch removes the users of the deprectated APIs:
acpi_get_table_with_size()
early_acpi_os_unmap_memory()
The following APIs should be used instead of:
acpi_get_table()
acpi_put_table()
The deprecated APIs are invented to be a replacement of acpi_get_table()
during the early stage so that the early mapped pointer will not be stored
in ACPICA core and thus the late stage acpi_get_table() won't return a
wrong pointer. The mapping size is returned just because it is required by
early_acpi_os_unmap_memory() to unmap the pointer during early stage.
But as the mapping size equals to the acpi_table_header.length
(see acpi_tb_init_table_descriptor() and acpi_tb_validate_table()), when
such a convenient result is returned, driver code will start to use it
instead of accessing acpi_table_header to obtain the length.
Thus this patch cleans up the drivers by replacing returned table size with
acpi_table_header.length, and should be a no-op.
Reported-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/acpi')
-rw-r--r-- | drivers/acpi/nfit/core.c | 3 | ||||
-rw-r--r-- | drivers/acpi/processor_core.c | 8 | ||||
-rw-r--r-- | drivers/acpi/spcr.c | 8 | ||||
-rw-r--r-- | drivers/acpi/tables.c | 17 |
4 files changed, 15 insertions, 21 deletions
diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c index 71a7d07c28c9..0efd3fa9a4d8 100644 --- a/drivers/acpi/nfit/core.c +++ b/drivers/acpi/nfit/core.c | |||
@@ -2781,12 +2781,13 @@ static int acpi_nfit_add(struct acpi_device *adev) | |||
2781 | acpi_size sz; | 2781 | acpi_size sz; |
2782 | int rc = 0; | 2782 | int rc = 0; |
2783 | 2783 | ||
2784 | status = acpi_get_table_with_size(ACPI_SIG_NFIT, 0, &tbl, &sz); | 2784 | status = acpi_get_table(ACPI_SIG_NFIT, 0, &tbl); |
2785 | if (ACPI_FAILURE(status)) { | 2785 | if (ACPI_FAILURE(status)) { |
2786 | /* This is ok, we could have an nvdimm hotplugged later */ | 2786 | /* This is ok, we could have an nvdimm hotplugged later */ |
2787 | dev_dbg(dev, "failed to find NFIT at startup\n"); | 2787 | dev_dbg(dev, "failed to find NFIT at startup\n"); |
2788 | return 0; | 2788 | return 0; |
2789 | } | 2789 | } |
2790 | sz = tbl->length; | ||
2790 | 2791 | ||
2791 | acpi_desc = devm_kzalloc(dev, sizeof(*acpi_desc), GFP_KERNEL); | 2792 | acpi_desc = devm_kzalloc(dev, sizeof(*acpi_desc), GFP_KERNEL); |
2792 | if (!acpi_desc) | 2793 | if (!acpi_desc) |
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c index 5c78ee1860b0..611a5585a902 100644 --- a/drivers/acpi/processor_core.c +++ b/drivers/acpi/processor_core.c | |||
@@ -154,18 +154,16 @@ static phys_cpuid_t map_madt_entry(struct acpi_table_madt *madt, | |||
154 | phys_cpuid_t __init acpi_map_madt_entry(u32 acpi_id) | 154 | phys_cpuid_t __init acpi_map_madt_entry(u32 acpi_id) |
155 | { | 155 | { |
156 | struct acpi_table_madt *madt = NULL; | 156 | struct acpi_table_madt *madt = NULL; |
157 | acpi_size tbl_size; | ||
158 | phys_cpuid_t rv; | 157 | phys_cpuid_t rv; |
159 | 158 | ||
160 | acpi_get_table_with_size(ACPI_SIG_MADT, 0, | 159 | acpi_get_table(ACPI_SIG_MADT, 0, |
161 | (struct acpi_table_header **)&madt, | 160 | (struct acpi_table_header **)&madt); |
162 | &tbl_size); | ||
163 | if (!madt) | 161 | if (!madt) |
164 | return PHYS_CPUID_INVALID; | 162 | return PHYS_CPUID_INVALID; |
165 | 163 | ||
166 | rv = map_madt_entry(madt, 1, acpi_id, true); | 164 | rv = map_madt_entry(madt, 1, acpi_id, true); |
167 | 165 | ||
168 | early_acpi_os_unmap_memory(madt, tbl_size); | 166 | acpi_put_table((struct acpi_table_header *)madt); |
169 | 167 | ||
170 | return rv; | 168 | return rv; |
171 | } | 169 | } |
diff --git a/drivers/acpi/spcr.c b/drivers/acpi/spcr.c index e8d7bc7d4da8..b8019c4c1d38 100644 --- a/drivers/acpi/spcr.c +++ b/drivers/acpi/spcr.c | |||
@@ -33,7 +33,6 @@ int __init parse_spcr(bool earlycon) | |||
33 | { | 33 | { |
34 | static char opts[64]; | 34 | static char opts[64]; |
35 | struct acpi_table_spcr *table; | 35 | struct acpi_table_spcr *table; |
36 | acpi_size table_size; | ||
37 | acpi_status status; | 36 | acpi_status status; |
38 | char *uart; | 37 | char *uart; |
39 | char *iotype; | 38 | char *iotype; |
@@ -43,9 +42,8 @@ int __init parse_spcr(bool earlycon) | |||
43 | if (acpi_disabled) | 42 | if (acpi_disabled) |
44 | return -ENODEV; | 43 | return -ENODEV; |
45 | 44 | ||
46 | status = acpi_get_table_with_size(ACPI_SIG_SPCR, 0, | 45 | status = acpi_get_table(ACPI_SIG_SPCR, 0, |
47 | (struct acpi_table_header **)&table, | 46 | (struct acpi_table_header **)&table); |
48 | &table_size); | ||
49 | 47 | ||
50 | if (ACPI_FAILURE(status)) | 48 | if (ACPI_FAILURE(status)) |
51 | return -ENOENT; | 49 | return -ENOENT; |
@@ -106,6 +104,6 @@ int __init parse_spcr(bool earlycon) | |||
106 | err = add_preferred_console(uart, 0, opts + strlen(uart) + 1); | 104 | err = add_preferred_console(uart, 0, opts + strlen(uart) + 1); |
107 | 105 | ||
108 | done: | 106 | done: |
109 | early_acpi_os_unmap_memory((void __iomem *)table, table_size); | 107 | acpi_put_table((struct acpi_table_header *)table); |
110 | return err; | 108 | return err; |
111 | } | 109 | } |
diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c index cdd56c4657e0..2604189d6cd1 100644 --- a/drivers/acpi/tables.c +++ b/drivers/acpi/tables.c | |||
@@ -333,7 +333,6 @@ acpi_table_parse_entries_array(char *id, | |||
333 | unsigned int max_entries) | 333 | unsigned int max_entries) |
334 | { | 334 | { |
335 | struct acpi_table_header *table_header = NULL; | 335 | struct acpi_table_header *table_header = NULL; |
336 | acpi_size tbl_size; | ||
337 | int count; | 336 | int count; |
338 | u32 instance = 0; | 337 | u32 instance = 0; |
339 | 338 | ||
@@ -346,7 +345,7 @@ acpi_table_parse_entries_array(char *id, | |||
346 | if (!strncmp(id, ACPI_SIG_MADT, 4)) | 345 | if (!strncmp(id, ACPI_SIG_MADT, 4)) |
347 | instance = acpi_apic_instance; | 346 | instance = acpi_apic_instance; |
348 | 347 | ||
349 | acpi_get_table_with_size(id, instance, &table_header, &tbl_size); | 348 | acpi_get_table(id, instance, &table_header); |
350 | if (!table_header) { | 349 | if (!table_header) { |
351 | pr_warn("%4.4s not present\n", id); | 350 | pr_warn("%4.4s not present\n", id); |
352 | return -ENODEV; | 351 | return -ENODEV; |
@@ -355,7 +354,7 @@ acpi_table_parse_entries_array(char *id, | |||
355 | count = acpi_parse_entries_array(id, table_size, table_header, | 354 | count = acpi_parse_entries_array(id, table_size, table_header, |
356 | proc, proc_num, max_entries); | 355 | proc, proc_num, max_entries); |
357 | 356 | ||
358 | early_acpi_os_unmap_memory((char *)table_header, tbl_size); | 357 | acpi_put_table(table_header); |
359 | return count; | 358 | return count; |
360 | } | 359 | } |
361 | 360 | ||
@@ -397,7 +396,6 @@ acpi_table_parse_madt(enum acpi_madt_type id, | |||
397 | int __init acpi_table_parse(char *id, acpi_tbl_table_handler handler) | 396 | int __init acpi_table_parse(char *id, acpi_tbl_table_handler handler) |
398 | { | 397 | { |
399 | struct acpi_table_header *table = NULL; | 398 | struct acpi_table_header *table = NULL; |
400 | acpi_size tbl_size; | ||
401 | 399 | ||
402 | if (acpi_disabled) | 400 | if (acpi_disabled) |
403 | return -ENODEV; | 401 | return -ENODEV; |
@@ -406,13 +404,13 @@ int __init acpi_table_parse(char *id, acpi_tbl_table_handler handler) | |||
406 | return -EINVAL; | 404 | return -EINVAL; |
407 | 405 | ||
408 | if (strncmp(id, ACPI_SIG_MADT, 4) == 0) | 406 | if (strncmp(id, ACPI_SIG_MADT, 4) == 0) |
409 | acpi_get_table_with_size(id, acpi_apic_instance, &table, &tbl_size); | 407 | acpi_get_table(id, acpi_apic_instance, &table); |
410 | else | 408 | else |
411 | acpi_get_table_with_size(id, 0, &table, &tbl_size); | 409 | acpi_get_table(id, 0, &table); |
412 | 410 | ||
413 | if (table) { | 411 | if (table) { |
414 | handler(table); | 412 | handler(table); |
415 | early_acpi_os_unmap_memory(table, tbl_size); | 413 | acpi_put_table(table); |
416 | return 0; | 414 | return 0; |
417 | } else | 415 | } else |
418 | return -ENODEV; | 416 | return -ENODEV; |
@@ -426,16 +424,15 @@ int __init acpi_table_parse(char *id, acpi_tbl_table_handler handler) | |||
426 | static void __init check_multiple_madt(void) | 424 | static void __init check_multiple_madt(void) |
427 | { | 425 | { |
428 | struct acpi_table_header *table = NULL; | 426 | struct acpi_table_header *table = NULL; |
429 | acpi_size tbl_size; | ||
430 | 427 | ||
431 | acpi_get_table_with_size(ACPI_SIG_MADT, 2, &table, &tbl_size); | 428 | acpi_get_table(ACPI_SIG_MADT, 2, &table); |
432 | if (table) { | 429 | if (table) { |
433 | pr_warn("BIOS bug: multiple APIC/MADT found, using %d\n", | 430 | pr_warn("BIOS bug: multiple APIC/MADT found, using %d\n", |
434 | acpi_apic_instance); | 431 | acpi_apic_instance); |
435 | pr_warn("If \"acpi_apic_instance=%d\" works better, " | 432 | pr_warn("If \"acpi_apic_instance=%d\" works better, " |
436 | "notify linux-acpi@vger.kernel.org\n", | 433 | "notify linux-acpi@vger.kernel.org\n", |
437 | acpi_apic_instance ? 0 : 2); | 434 | acpi_apic_instance ? 0 : 2); |
438 | early_acpi_os_unmap_memory(table, tbl_size); | 435 | acpi_put_table(table); |
439 | 436 | ||
440 | } else | 437 | } else |
441 | acpi_apic_instance = 0; | 438 | acpi_apic_instance = 0; |