]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/xen.git/commitdiff
ACPI / table: add new function to get table entries
authorAshwin Chaugule <ashwin.chaugule@linaro.org>
Mon, 18 Jan 2016 13:54:08 +0000 (14:54 +0100)
committerJan Beulich <jbeulich@suse.com>
Mon, 18 Jan 2016 13:54:08 +0000 (14:54 +0100)
The acpi_table_parse() function has a callback that
passes a pointer to a table_header. Add a new function
which takes this pointer and parses its entries. This
eliminates the need to re-traverse all the tables for
each call. e.g. as in acpi_table_parse_madt() which is
normally called after acpi_table_parse().

Acked-by: Grant Likely <grant.likely@linaro.org>
Signed-off-by: Ashwin Chaugule <ashwin.chaugule@linaro.org>
Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org>
Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
[Linux commit f08bb472bff3c0397fb7d6f47bc5cec41dad76e3]
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
xen/drivers/acpi/tables.c
xen/include/xen/acpi.h

index 39f12231ff4bb4aacb27412606610233e740fbe6..4e590de5298d443b2eee14643bdb5b78fa1e7863 100644 (file)
@@ -199,27 +199,23 @@ void __init acpi_table_print_madt_entry(struct acpi_subtable_header *header)
 
 
 int __init
-acpi_table_parse_entries(char *id,
-                            unsigned long table_size,
-                            int entry_id,
-                            acpi_table_entry_handler handler,
-                            unsigned int max_entries)
+acpi_parse_entries(char *id, unsigned long table_size,
+                  acpi_table_entry_handler handler,
+                  struct acpi_table_header *table_header,
+                  int entry_id, unsigned int max_entries)
 {
-       struct acpi_table_header *table_header = NULL;
        struct acpi_subtable_header *entry;
-       unsigned int count = 0;
+       int count = 0;
        unsigned long table_end;
 
        if (acpi_disabled)
                return -ENODEV;
 
-       if (!handler)
+       if (!id || !handler)
                return -EINVAL;
 
-       if (strncmp(id, ACPI_SIG_MADT, 4) == 0)
-               acpi_get_table(id, acpi_apic_instance, &table_header);
-       else
-               acpi_get_table(id, 0, &table_header);
+       if (!table_size)
+               return -EINVAL;
 
        if (!table_header) {
                printk(KERN_WARNING PREFIX "%4.4s not present\n", id);
@@ -252,6 +248,7 @@ acpi_table_parse_entries(char *id,
                entry = (struct acpi_subtable_header *)
                    ((unsigned long)entry + entry->length);
        }
+
        if (max_entries && count > max_entries) {
                printk(KERN_WARNING PREFIX "[%4.4s:%#x] ignored %i entries of "
                       "%i found\n", id, entry_id, count - max_entries, count);
@@ -260,6 +257,35 @@ acpi_table_parse_entries(char *id,
        return count;
 }
 
+int __init
+acpi_table_parse_entries(char *id,
+                        unsigned long table_size,
+                        int entry_id,
+                        acpi_table_entry_handler handler,
+                        unsigned int max_entries)
+{
+       struct acpi_table_header *table_header = NULL;
+       u32 instance = 0;
+
+       if (acpi_disabled)
+               return -ENODEV;
+
+       if (!id || !handler)
+               return -EINVAL;
+
+       if (!strncmp(id, ACPI_SIG_MADT, 4))
+               instance = acpi_apic_instance;
+
+       acpi_get_table(id, instance, &table_header);
+       if (!table_header) {
+               printk(KERN_WARNING PREFIX "%4.4s not present\n", id);
+               return -ENODEV;
+       }
+
+       return acpi_parse_entries(id, table_size, handler, table_header,
+                                 entry_id, max_entries);
+}
+
 int __init
 acpi_table_parse_madt(enum acpi_madt_type id,
                      acpi_table_entry_handler handler, unsigned int max_entries)
index 0f1077d0b4b1fac2804ebbbad53abc7c72bc0f07..65e53a6ed1a57f23c80a34c2789d6591c1853806 100644 (file)
@@ -64,6 +64,10 @@ void acpi_hest_init(void);
 
 int acpi_table_init (void);
 int acpi_table_parse(char *id, acpi_table_handler handler);
+int acpi_parse_entries(char *id, unsigned long table_size,
+                      acpi_table_entry_handler handler,
+                      struct acpi_table_header *table_header,
+                      int entry_id, unsigned int max_entries);
 int acpi_table_parse_entries(char *id, unsigned long table_size,
        int entry_id, acpi_table_entry_handler handler, unsigned int max_entries);
 int acpi_table_parse_madt(enum acpi_madt_type id, acpi_table_entry_handler handler, unsigned int max_entries);