From patchwork Tue Sep 8 11:07:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: lukasz.anaczkowski@intel.com X-Patchwork-Id: 7140101 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 83A2CBF036 for ; Tue, 8 Sep 2015 11:08:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 86B5520782 for ; Tue, 8 Sep 2015 11:08:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 940C22074E for ; Tue, 8 Sep 2015 11:08:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754665AbbIHLIk (ORCPT ); Tue, 8 Sep 2015 07:08:40 -0400 Received: from mga01.intel.com ([192.55.52.88]:4262 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753367AbbIHLIW (ORCPT ); Tue, 8 Sep 2015 07:08:22 -0400 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP; 08 Sep 2015 04:08:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,489,1437462000"; d="scan'208";a="557469604" Received: from gklab-125-033.igk.intel.com ([10.91.125.33]) by FMSMGA003.fm.intel.com with ESMTP; 08 Sep 2015 04:08:18 -0700 From: Lukasz Anaczkowski To: marc.zyngier@arm.com, lorenzo.pieralisi@arm.com, tomasz.nowicki@linaro.org, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, jason@lakedaemon.net Cc: rjw@rjwysocki.net, len.brown@intel.com, pavel@ucw.cz, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, Lukasz Anaczkowski Subject: [PATCH 3/4] acpi: multi proc support Date: Tue, 8 Sep 2015 13:07:59 +0200 Message-Id: <1441710480-17622-5-git-send-email-lukasz.anaczkowski@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1441710480-17622-4-git-send-email-lukasz.anaczkowski@intel.com> References: <20150827093738.GA21134@red-moon> <1441710480-17622-1-git-send-email-lukasz.anaczkowski@intel.com> <1441710480-17622-2-git-send-email-lukasz.anaczkowski@intel.com> <1441710480-17622-3-git-send-email-lukasz.anaczkowski@intel.com> <1441710480-17622-4-git-send-email-lukasz.anaczkowski@intel.com> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Now, it is possible to pass two or more handlers. Signed-off-by: Lukasz Anaczkowski --- drivers/acpi/tables.c | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c index 33539ee..ececeac 100644 --- a/drivers/acpi/tables.c +++ b/drivers/acpi/tables.c @@ -214,6 +214,22 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header) } } +/** + * acpi_parse_entries - for each proc_num find a subtable with proc->id + * and run proc->handler on it. Assumption is that there's only + * single handler for particular entry id. + * + * @id: table id (for debugging purposes) + * @table_size: single entry size + * @table_header: where does the table start? + * @proc: array of acpi_subtable_proc struct containing entry id + * and associated handler with it + * @proc_num: how big proc is? + * @max_entries: how many entries can we process? + * + * On success returns sum of all matching entries for all proc handlers. + * Oterwise, -ENODEV or -EINVAL is returned. + */ int __init acpi_parse_entries(char *id, unsigned long table_size, struct acpi_table_header *table_header, @@ -247,13 +263,20 @@ acpi_parse_entries(char *id, unsigned long table_size, while (((unsigned long)entry) + sizeof(struct acpi_subtable_header) < table_end) { - if (entry->type == proc->id - && (!max_entries || count < max_entries)) { - if (!proc->handler || proc->handler(entry, table_end)) + if (max_entries && count >= max_entries) + break; + + for (i = 0; i < proc_num; i++) { + if (entry->type != proc[i].id) + continue; + if (!proc->handler || proc[i].handler(entry, table_end)) { return -EINVAL; proc->count++; + break; } + if (i != proc_num) + count++; /* * If entry->length is 0, break from this loop to avoid @@ -268,8 +291,6 @@ acpi_parse_entries(char *id, unsigned long table_size, ((unsigned long)entry + entry->length); } - count = proc->count; - if (max_entries && count > max_entries) { pr_warn("[%4.4s:0x%02x] ignored %i entries of %i found\n", id, proc->id, count - max_entries, count);