Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754126AbdHUQmX (ORCPT ); Mon, 21 Aug 2017 12:42:23 -0400 Received: from g9t5009.houston.hpe.com ([15.241.48.73]:41968 "EHLO g9t5009.houston.hpe.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753830AbdHUQmU (ORCPT ); Mon, 21 Aug 2017 12:42:20 -0400 From: "Kani, Toshimitsu" To: "bp@alien8.de" , "rjw@rjwysocki.net" CC: "lenb@kernel.org" , "mchehab@kernel.org" , "tony.luck@intel.com" , "linux-kernel@vger.kernel.org" , "linux-acpi@vger.kernel.org" , "linux-edac@vger.kernel.org" Subject: Re: [PATCH v3 1/5] ACPI / blacklist: add acpi_match_platform_list() Thread-Topic: [PATCH v3 1/5] ACPI / blacklist: add acpi_match_platform_list() Thread-Index: AQHTGFwjnywryIINFUyGdWm/Gs0MS6KOsEQAgABU+oA= Date: Mon, 21 Aug 2017 16:41:38 +0000 Message-ID: <1503333107.2042.163.camel@hpe.com> References: <20170818194644.14538-1-toshi.kani@hpe.com> <20170818194644.14538-2-toshi.kani@hpe.com> <20170821112657.hrtjoeagxhc67rrr@pd.tnic> In-Reply-To: <20170821112657.hrtjoeagxhc67rrr@pd.tnic> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=toshi.kani@hpe.com; x-originating-ip: [15.211.195.8] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DF4PR84MB0140;6:IYPlqTCcOb1Vhh+3b66ze/aQvcMjewnOwlv9rLkjvNqJiSQ5Vbk+2lanYXT+v7rSb07K3W+3dIRVtKCPsrYVzoOB59CHariNR1gvVLwzehpu9ir3Qyat5Wx4qQiUJGDk/Hs5bM7qGpRRukDhfF4K9xEvRTC3mLcuHLsVv8P5cj7LxMAP3BkQeIkTifzEYiwMtz8j4A3zFOg4ODS8EotP1CXD+ZCoY7tLpDNiPOTc6Wec7xn57HhqFxu/9mEr/GmkrU4aZI2U7CiSx+Ni5jz1dcZsCN7Ch1XOrxcMqO1mn4QcEfatilDStwe6VI23OYo56uRS4f0ZvkR7ARFXfdXVOw==;5:lS1ZqE99L4shlldLySkG6qsdLXAKRD76vSL137qpe/IXNfL/zUirkM66364oje2oo7YVWZ9svKfeyXFpTbFrsW37YjmZLjp0u9MzNguHGruFgOBCyC8J7eWd7vuXyqVNOFzUxWrisGCKwHS2fJC7XQ==;24:2Y48uKzYIOsyNLlwovOV1r1YiFsOBo3nvgOPwqFGhlZyMqa9WW3Ey7ilWAlSoeKxe2FPXGiC3gT3s+zVsQ5DCybEHzWdNHvHA//gtM/M9r4=;7:ld912yxyilKZju2rQXAnXaSh7RshRTsNpJGUNhNXhsBYCQsRDOzEo3WFiwifQDD6IDBtvKHcMLZIwxaWoda7Um3Wr80OPcmoWPJC4wCTYP0mtXKodDdJGZjoFwOhWD0MZnxTo01UNsseAiROoYR1IeF5UUUrGJHcQB1ynXID7elpVyGmJpxTaNYu8/hdqBFu55kIAd5BSSWeZkaHYkqzbfNJAaWrnvq9dsugBEaCEMM= x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-correlation-id: 9d0f2db2-0db7-4bb0-86a1-08d4e8b37e8e x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(2017052603031)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:DF4PR84MB0140; x-ms-traffictypediagnostic: DF4PR84MB0140: x-exchange-antispam-report-test: UriScan:(131327999870524); x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(93006095)(93001095)(100000703101)(100105400095)(10201501046)(3002001)(6055026)(6041248)(20161123560025)(20161123562025)(20161123555025)(20161123558100)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:DF4PR84MB0140;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:DF4PR84MB0140; x-forefront-prvs: 040655413E x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(39860400002)(377424004)(199003)(24454002)(189002)(97736004)(54906002)(5660300001)(14454004)(305945005)(4326008)(7736002)(6436002)(105586002)(6506006)(86362001)(53936002)(575784001)(2501003)(6486002)(77096006)(68736007)(6246003)(6512007)(8676002)(76176999)(6116002)(2950100002)(101416001)(54356999)(229853002)(8936002)(3660700001)(102836003)(478600001)(50986999)(106356001)(2900100001)(81166006)(81156014)(25786009)(66066001)(33646002)(189998001)(103116003)(36756003)(2906002)(3280700002)(3846002);DIR:OUT;SFP:1102;SCL:1;SRVR:DF4PR84MB0140;H:DF4PR84MB0187.NAMPRD84.PROD.OUTLOOK.COM;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="utf-8" Content-ID: <06D03BAC07DD274198ACFE6A20494DBB@NAMPRD84.PROD.OUTLOOK.COM> MIME-Version: 1.0 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Aug 2017 16:41:38.4731 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 105b2061-b669-4b31-92ac-24d304d195dc X-MS-Exchange-Transport-CrossTenantHeadersStamped: DF4PR84MB0140 X-OriginatorOrg: hpe.com Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by nfs id v7LGgTKr010139 Content-Length: 3646 Lines: 117 On Mon, 2017-08-21 at 13:27 +0200, Borislav Petkov wrote: > On Fri, Aug 18, 2017 at 01:46:40PM -0600, Toshi Kani wrote: > > ACPI OEM ID / OEM Table ID / Revision can be used to identify > > a platform based on ACPI firmware info.  acpi_blacklisted(), > > intel_pstate_platform_pwr_mgmt_exists(), and some other funcs, > > have been using similar check to detect a list of platforms > > that require special handlings. > > > > Move the platform check in acpi_blacklisted() to a new common > > utility function, acpi_match_platform_list(), so that other > > drivers do not have to implement their own version. > > > > There is no change in functionality. : > > + > > + for (; plat->oem_id[0]; plat++, idx++) { > > + if (ACPI_FAILURE(acpi_get_table_header(plat- > > >table, 0, &hdr))) > > + continue; > > + > > + if (strncmp(plat->oem_id, hdr.oem_id, > > ACPI_OEM_ID_SIZE)) > > + continue; > > + > > + if (strncmp(plat->oem_table_id, hdr.oem_table_id, > > +     ACPI_OEM_TABLE_ID_SIZE)) > > Let that stick out. Putting to a single line leads to "line over 80 characters" warning from checkpatch.pl. Would you still advice to do that? > > + continue; > > + > > + if ((plat->pred == all_versions) || > > +     (plat->pred == less_than_or_equal > > + && hdr.oem_revision <= plat->oem_revision) > > || > > +     (plat->pred == greater_than_or_equal > > + && hdr.oem_revision >= plat->oem_revision) > > || > > +     (plat->pred == equal > > + && hdr.oem_revision == plat- > > >oem_revision)) > > + return idx; > > Make that more readable: > >                 if ((plat->pred == all_versions) || >                     (plat->pred == less_than_or_equal    && > hdr.oem_revision <= plat->oem_revision) || >                     (plat->pred == greater_than_or_equal && > hdr.oem_revision >= plat->oem_revision) || >                     (plat->pred == equal                 && > hdr.oem_revision == plat->oem_revision)) >                         return idx; Same here. These lead to checkpatch warnings. > > + } > > + > > + return -ENODEV; > > +} > > +EXPORT_SYMBOL(acpi_match_platform_list); > > diff --git a/include/linux/acpi.h b/include/linux/acpi.h > > index 27b4b66..a9b6dc2 100644 > > --- a/include/linux/acpi.h > > +++ b/include/linux/acpi.h > > @@ -556,6 +556,25 @@ extern acpi_status > > acpi_pci_osc_control_set(acpi_handle handle, > >  #define ACPI_OST_SC_DRIVER_LOAD_FAILURE 0x81 > >  #define ACPI_OST_SC_INSERT_NOT_SUPPORTED 0x82 > >   > > +enum acpi_predicate { > > + all_versions, > > + less_than_or_equal, > > + equal, > > + greater_than_or_equal, > > +}; > > + > > +/* Table must be terminted by a NULL entry */ > > +struct acpi_platform_list { > > + char oem_id[ACPI_OEM_ID_SIZE]; > > + 1 > > > + char oem_table_id[ACPI_OEM_TABLE_ID_SIZE]; > >    + 1 strncmp() is fine without these, but it'd be prudent in case someone decides to print these strings with printk(). Will do. > > + u32 oem_revision; > > + char *table; > > + enum acpi_predicate pred; > > + char *reason; > > + u32 data; > > Ok, turning that into data from is_critical_error is a step in the > right direction. Let's make it even better: > > u32 flags; > > and do > > #define ACPI_PLAT_IS_CRITICAL_ERROR BIT(0) > > so that future elements add new bits instead of wasting a whole u32 > as a boolean. 'data' here is private to the caller. So, I do not think we need to define the bits. Shall I change the name to 'driver_data' to make it more explicit? Thanks, -Toshi