From patchwork Tue Mar 20 13:54:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 888235 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 405Dv14mX4z9s12 for ; Wed, 21 Mar 2018 00:54:21 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753467AbeCTNyS (ORCPT ); Tue, 20 Mar 2018 09:54:18 -0400 Received: from mga11.intel.com ([192.55.52.93]:65432 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753429AbeCTNyQ (ORCPT ); Tue, 20 Mar 2018 09:54:16 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Mar 2018 06:54:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,335,1517904000"; d="scan'208";a="184429519" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga004.jf.intel.com with ESMTP; 20 Mar 2018 06:54:13 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 1D133A97; Tue, 20 Mar 2018 15:54:12 +0200 (EET) From: Andy Shevchenko To: Bjorn Helgaas , linux-pci@vger.kernel.org, "Rafael J . Wysocki" , linux-acpi@vger.kernel.org, Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , x86@kernel.org, Jean Delvare , Lukas Wunner Cc: Andy Shevchenko Subject: [PATCH v3 2/2] firmware: dmi_scan: Uninline dmi_get_bios_year() helper Date: Tue, 20 Mar 2018 15:54:10 +0200 Message-Id: <20180320135410.11627-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180320135410.11627-1-andriy.shevchenko@linux.intel.com> References: <20180320135410.11627-1-andriy.shevchenko@linux.intel.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Uninline dmi_get_bios_year() which, in particular, allows us to optimize it in the future. While doing this, convert the function to return an error code when BIOS date is not present, parsable or CONFIG_DMI=n. Additionally, during the move, add a bit of documentation. Suggested-by: Bjorn Helgaas Suggested-by: Rafael J. Wysocki Signed-off-by: Andy Shevchenko Reviewed-by: Jean Delvare Reviewed-by: Rafael J. Wysocki --- drivers/firmware/dmi_scan.c | 20 ++++++++++++++++++++ include/linux/dmi.h | 11 ++--------- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c index ae4f1b181c23..bfb6ce6abc83 100644 --- a/drivers/firmware/dmi_scan.c +++ b/drivers/firmware/dmi_scan.c @@ -1040,6 +1040,26 @@ bool dmi_get_date(int field, int *yearp, int *monthp, int *dayp) } EXPORT_SYMBOL(dmi_get_date); +/** + * dmi_get_bios_year - get a year out of DMI_BIOS_DATE field + * + * Returns year on success, -ENXIO if DMI is not selected, + * or a different negative error code if DMI field is not present + * or not parsable. + */ +int dmi_get_bios_year(void) +{ + bool exists; + int year; + + exists = dmi_get_date(DMI_BIOS_DATE, &year, NULL, NULL); + if (!exists) + return -ENODATA; + + return year ? year : -ERANGE; +} +EXPORT_SYMBOL(dmi_get_bios_year); + /** * dmi_walk - Walk the DMI table and get called back for every record * @decode: Callback function diff --git a/include/linux/dmi.h b/include/linux/dmi.h index b5b8c26b04fb..c46fdb36700b 100644 --- a/include/linux/dmi.h +++ b/include/linux/dmi.h @@ -106,6 +106,7 @@ extern void dmi_scan_machine(void); extern void dmi_memdev_walk(void); extern void dmi_set_dump_stack_arch_desc(void); extern bool dmi_get_date(int field, int *yearp, int *monthp, int *dayp); +extern int dmi_get_bios_year(void); extern int dmi_name_in_vendors(const char *str); extern int dmi_name_in_serial(const char *str); extern int dmi_available; @@ -134,6 +135,7 @@ static inline bool dmi_get_date(int field, int *yearp, int *monthp, int *dayp) *dayp = 0; return false; } +static inline int dmi_get_bios_year(void) { return -ENXIO; } static inline int dmi_name_in_vendors(const char *s) { return 0; } static inline int dmi_name_in_serial(const char *s) { return 0; } #define dmi_available 0 @@ -149,13 +151,4 @@ static inline const struct dmi_system_id * #endif -static inline int dmi_get_bios_year(void) -{ - int year; - - dmi_get_date(DMI_BIOS_DATE, &year, NULL, NULL); - - return year; -} - #endif /* __DMI_H__ */