diff mbox

[Xen-devel,v2,16/41] acpi : Introduce acpi_parse_entries

Message ID 1431893048-5214-17-git-send-email-parth.dixit@linaro.org
State New
Headers show

Commit Message

Parth Dixit May 17, 2015, 8:03 p.m. UTC
add new function acpi_parse_entries which takes
acpi table as argument. This will avoid fetching table
everytime in acpi_table_parse_entries.

Signed-off-by: Naresh Bhat <Naresh.Bhat@linaro.org>
Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
---
 xen/drivers/acpi/tables.c | 60 +++++++++++++++++++++++++++++++++--------------
 xen/include/xen/acpi.h    |  3 +++
 2 files changed, 45 insertions(+), 18 deletions(-)

Comments

Parth Dixit May 21, 2015, 9:14 a.m. UTC | #1
On 20 May 2015 at 21:43, Jan Beulich <JBeulich@suse.com> wrote:

> >>> On 17.05.15 at 22:03, <parth.dixit@linaro.org> wrote:
> > add new function acpi_parse_entries which takes
> > acpi table as argument. This will avoid fetching table
> > everytime in acpi_table_parse_entries.
>
> This explanation doesn't make a lot of sense to me - I don't see you
> save anything. Am I missing anything? Are you intending to use the
> new function separately? Also, please don't break indentation like
>
yes, i am fetching the table once and parsing it with this function in
acpi_gicv2_init function in the patch given below
http://lists.xen.org/archives/html/xen-devel/2015-05/msg02208.html

> you do here (and elsewhere).
>
> sure, i'll take care of the indentation.

> Jan
>
>
Parth Dixit July 5, 2015, 1:11 p.m. UTC | #2
+shannon

On 21 May 2015 at 14:50, Jan Beulich <JBeulich@suse.com> wrote:
>>>> On 21.05.15 at 11:14, <parth.dixit@linaro.org> wrote:
>> On 20 May 2015 at 21:43, Jan Beulich <JBeulich@suse.com> wrote:
>>
>>> >>> On 17.05.15 at 22:03, <parth.dixit@linaro.org> wrote:
>>> > add new function acpi_parse_entries which takes
>>> > acpi table as argument. This will avoid fetching table
>>> > everytime in acpi_table_parse_entries.
>>>
>>> This explanation doesn't make a lot of sense to me - I don't see you
>>> save anything. Am I missing anything? Are you intending to use the
>>> new function separately? Also, please don't break indentation like
>>>
>> yes, i am fetching the table once and parsing it with this function in
>> acpi_gicv2_init function in the patch given below
>> http://lists.xen.org/archives/html/xen-devel/2015-05/msg02208.html
>
> So - just like elsewhere - please correct the patch description then.
>
> Jan
>
diff mbox

Patch

diff --git a/xen/drivers/acpi/tables.c b/xen/drivers/acpi/tables.c
index 684d8c9..c4c4256 100644
--- a/xen/drivers/acpi/tables.c
+++ b/xen/drivers/acpi/tables.c
@@ -237,31 +237,29 @@  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;
+    struct acpi_subtable_header *entry;
 	unsigned int count = 0;
 	unsigned long table_end;
 
-	if (!handler)
-		return -EINVAL;
+    if ( !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);
-		return -ENODEV;
-	}
+    if ( !table_header )
+    {
+        printk("Table header not present\n");
+        return -ENODEV;
+    }
 
 	table_end = (unsigned long)table_header + table_header->length;
 
@@ -292,6 +290,32 @@  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;
+
+	if (!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_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
diff --git a/xen/include/xen/acpi.h b/xen/include/xen/acpi.h
index ee6a5ea..3eafd1f 100644
--- a/xen/include/xen/acpi.h
+++ b/xen/include/xen/acpi.h
@@ -74,6 +74,9 @@  int acpi_table_init (void);
 int acpi_table_parse(char *id, acpi_table_handler handler);
 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_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_madt(enum acpi_madt_type id, acpi_table_entry_handler handler, unsigned int max_entries);
 int acpi_table_parse_srat(int id, acpi_madt_entry_handler handler,
 	unsigned int max_entries);