From patchwork Sun May 17 20:03:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Parth Dixit X-Patchwork-Id: 48636 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D83C721411 for ; Sun, 17 May 2015 20:06:15 +0000 (UTC) Received: by wivs14 with SMTP id s14sf15381442wiv.1 for ; Sun, 17 May 2015 13:06:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:cc:subject:precedence:list-id:list-unsubscribe:list-post :list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list:list-archive; bh=cSXu1Z3LB0jnNOyL1Bk96DIIyvtkEM5UXL+8chwswWA=; b=JDUviXMI1Wq3Woc5koi+AzW1z+/VO5eqcW7NGO71VUbFR1EHPXv3uFkMNCkFOyWDqD Hcybtb6yIvQGK9GYVufLDlpgTrCPYMLLlnEy2C7lJ5O4nW8ZUYuY7WN75LDKSt9VqDIV BED6HgzyZRBuvfPYFAPEScp5iPcsZQuUTIrzGfvy3EjLm/o4XkjEz3dR6+Q/BcdCH5Gs NF9rSSQWeAh/X4PRUY9a6ADoJWENth7JQcQdm38EU5paybYbKeJ/aCVEWTltqHpt6nX2 Q5HfEB3wmvTk1cfwia+zLcwqu3z4XZd6L5b+ewppW1YLbKlZAU+Arx2DraDH8MffI/Pc iamQ== X-Gm-Message-State: ALoCoQn8PKVt0x05ZJCIAMBuaXT/W8oZ3atQYtVf9ECS5bpvcQ/xAfcx0S3nVwp7/6cXKm/V0dTG X-Received: by 10.180.88.226 with SMTP id bj2mr7257677wib.7.1431893175150; Sun, 17 May 2015 13:06:15 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.23.74 with SMTP id k10ls701183laf.30.gmail; Sun, 17 May 2015 13:06:14 -0700 (PDT) X-Received: by 10.152.23.4 with SMTP id i4mr6927394laf.51.1431893174910; Sun, 17 May 2015 13:06:14 -0700 (PDT) Received: from mail-la0-f52.google.com (mail-la0-f52.google.com. [209.85.215.52]) by mx.google.com with ESMTPS id rp1si5341429lbb.29.2015.05.17.13.06.14 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 May 2015 13:06:14 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) client-ip=209.85.215.52; Received: by laat2 with SMTP id t2so191053407laa.1 for ; Sun, 17 May 2015 13:06:14 -0700 (PDT) X-Received: by 10.112.204.72 with SMTP id kw8mr14856017lbc.88.1431893174797; Sun, 17 May 2015 13:06:14 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp3507805lbb; Sun, 17 May 2015 13:06:13 -0700 (PDT) X-Received: by 10.55.43.220 with SMTP id r89mr40876377qkr.27.1431893173410; Sun, 17 May 2015 13:06:13 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id i30si8267421qkh.105.2015.05.17.13.06.12 (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 17 May 2015 13:06:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xen.org designates 50.57.142.19 as permitted sender) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Yu4oV-00023U-Is; Sun, 17 May 2015 20:05:31 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Yu4oU-0001to-L7 for xen-devel@lists.xen.org; Sun, 17 May 2015 20:05:30 +0000 Received: from [85.158.139.211] by server-14.bemta-5.messagelabs.com id F2/DE-02819-984F8555; Sun, 17 May 2015 20:05:29 +0000 X-Env-Sender: parth.dixit@linaro.org X-Msg-Ref: server-7.tower-206.messagelabs.com!1431893127!11174966!1 X-Originating-IP: [209.85.192.172] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.13.15; banners=-,-,- X-VirusChecked: Checked Received: (qmail 27083 invoked from network); 17 May 2015 20:05:29 -0000 Received: from mail-pd0-f172.google.com (HELO mail-pd0-f172.google.com) (209.85.192.172) by server-7.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 17 May 2015 20:05:29 -0000 Received: by pdbqa5 with SMTP id qa5so117364196pdb.0 for ; Sun, 17 May 2015 13:05:27 -0700 (PDT) X-Received: by 10.66.159.106 with SMTP id xb10mr37124849pab.129.1431893127645; Sun, 17 May 2015 13:05:27 -0700 (PDT) Received: from localhost.localdomain ([117.247.24.139]) by mx.google.com with ESMTPSA id j9sm7838401pdm.53.2015.05.17.13.05.23 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 17 May 2015 13:05:27 -0700 (PDT) From: Parth Dixit To: xen-devel@lists.xen.org Date: Mon, 18 May 2015 01:33:43 +0530 Message-Id: <1431893048-5214-17-git-send-email-parth.dixit@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1431893048-5214-1-git-send-email-parth.dixit@linaro.org> References: <1431893048-5214-1-git-send-email-parth.dixit@linaro.org> Cc: keir@xen.org, ian.campbell@citrix.com, andrew.cooper3@citrix.com, tim@xen.org, julien.grall@citrix.com, stefano.stabellini@citrix.com, jbeulich@suse.com, parth.dixit@linaro.org, christoffer.dall@linaro.org Subject: [Xen-devel] [PATCH v2 16/41] acpi : Introduce acpi_parse_entries X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: parth.dixit@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Archive: 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 Signed-off-by: Parth Dixit --- xen/drivers/acpi/tables.c | 60 +++++++++++++++++++++++++++++++++-------------- xen/include/xen/acpi.h | 3 +++ 2 files changed, 45 insertions(+), 18 deletions(-) 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);