From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D3FD1C7EE2C for ; Fri, 2 Jun 2023 12:35:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234751AbjFBMfL (ORCPT ); Fri, 2 Jun 2023 08:35:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234571AbjFBMfK (ORCPT ); Fri, 2 Jun 2023 08:35:10 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 813741AE; Fri, 2 Jun 2023 05:35:07 -0700 (PDT) Received: from lhrpeml500005.china.huawei.com (unknown [172.18.147.206]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4QXj862q2Rz6D8XS; Fri, 2 Jun 2023 20:32:54 +0800 (CST) Received: from localhost (10.202.227.76) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Fri, 2 Jun 2023 13:35:05 +0100 Date: Fri, 2 Jun 2023 13:35:04 +0100 From: Jonathan Cameron To: Dave Jiang CC: , , "Rafael J. Wysocki" , , , , , , Subject: Re: [PATCH v3 1/4] acpi: Move common tables helper functions to common lib Message-ID: <20230602133504.00001c69@Huawei.com> In-Reply-To: <168565511236.1098279.11767193165079131197.stgit@djiang5-mobl3> References: <168565502116.1098279.131831312990693128.stgit@djiang5-mobl3> <168565511236.1098279.11767193165079131197.stgit@djiang5-mobl3> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 4.1.0 (GTK 3.24.33; x86_64-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.202.227.76] X-ClientProxiedBy: lhrpeml500004.china.huawei.com (7.191.163.9) To lhrpeml500005.china.huawei.com (7.191.163.240) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org On Thu, 01 Jun 2023 14:31:52 -0700 Dave Jiang wrote: > Some of the routines in ACPI driver/acpi/tables.c can be shared with > parsing CDAT. CDAT is a device-provided data structure that is formatted > similar to a platform provided ACPI table. CDAT is used by CXL and can > exist on platforms that do not use ACPI. Split out the common routine > from ACPI to accommodate platforms that do not support ACPI and move that > to /lib. The common routines can be built outside of ACPI if > FIRMWARE_TABLES is selected. > > Link: https://lore.kernel.org/linux-cxl/CAJZ5v0jipbtTNnsA0-o5ozOk8ZgWnOg34m34a9pPenTyRLj=6A@mail.gmail.com/ > Suggested-by: Rafael J. Wysocki > Signed-off-by: Dave Jiang Minor comment to fix inline. With that tidied up Reviewed-by: Jonathan Cameron > diff --git a/include/linux/fw_table.h b/include/linux/fw_table.h > new file mode 100644 > index 000000000000..ff8fa58d5818 > --- /dev/null > +++ b/include/linux/fw_table.h > @@ -0,0 +1,43 @@ > +/* SPDX-License-Identifier: GPL-2.0-or-later */ > +/* > + * fw_tables.h - Parsing support for ACPI and ACPI-like tables provided by > + * platform or device firmware > + * > + * Copyright (C) 2001 Paul Diefenbaugh > + * Copyright (C) 2023 Intel Corp. > + */ > +#ifndef _FW_TABLE_H_ > +#define _FW_TABLE_H_ > + > +union acpi_subtable_headers; > + > +typedef int (*acpi_tbl_entry_handler)(union acpi_subtable_headers *header, > + const unsigned long end); > + > +typedef int (*acpi_tbl_entry_handler_arg)(union acpi_subtable_headers *header, > + void *arg, const unsigned long end); > + > +struct acpi_subtable_proc { > + int id; > + acpi_tbl_entry_handler handler; > + acpi_tbl_entry_handler_arg handler_arg; > + void *arg; > + int count; > +}; > + > +#include > +#include Includes mid way down the files is not a common pattern and I can't see why it's particularly useful to do so here. + linux/acpi.h includes acpi/acpi.h and I can't see that changing any time soon... > + > +union acpi_subtable_headers { > + struct acpi_subtable_header common; > + struct acpi_hmat_structure hmat; > + struct acpi_prmt_module_header prmt; > + struct acpi_cedt_header cedt; > +}; > + > +int acpi_parse_entries_array(char *id, unsigned long table_size, > + struct acpi_table_header *table_header, > + struct acpi_subtable_proc *proc, > + int proc_num, unsigned int max_entries); > + > +#endif