From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Bjorn Helgaas <bhelgaas@google.com>,
linux-pci@vger.kernel.org,
"Rafael J . Wysocki" <rjw@rjwysocki.net>,
linux-acpi@vger.kernel.org, Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, "H . Peter Anvin" <hpa@zytor.com>,
x86@kernel.org, Jean Delvare <jdelvare@suse.de>,
Lukas Wunner <lukas@wunner.de>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH v4 1/2] firmware: dmi_scan: Uninline dmi_get_bios_year() helper
Date: Tue, 20 Mar 2018 20:07:59 +0200 [thread overview]
Message-ID: <20180320180800.63179-2-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20180320180800.63179-1-andriy.shevchenko@linux.intel.com>
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 or not parsable, or CONFIG_DMI=n.
Additionally, during the move, add a bit of documentation.
Fixes: 492a1abd61e4 ("dmi: Introduce the dmi_get_bios_year() helper function")
Suggested-by: Bjorn Helgaas <helgaas@kernel.org>
Suggested-by: Rafael J. Wysocki <rafael@kernel.org>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
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__ */
--
2.16.2
next prev parent reply other threads:[~2018-03-20 18:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-20 18:07 [PATCH v4 0/2] x86, dmi: Uninline dmi_get_bios_year() Andy Shevchenko
2018-03-20 18:07 ` Andy Shevchenko [this message]
2018-03-27 9:33 ` [PATCH v4 1/2] firmware: dmi_scan: Uninline dmi_get_bios_year() helper Ingo Molnar
2018-03-20 18:08 ` [PATCH v4 2/2] x86/PCI: Fix a potential regression when use dmi_get_bios_year() Andy Shevchenko
2018-03-26 17:14 ` [PATCH v4 0/2] x86, dmi: Uninline dmi_get_bios_year() Andy Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180320180800.63179-2-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=bhelgaas@google.com \
--cc=hpa@zytor.com \
--cc=jdelvare@suse.de \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lukas@wunner.de \
--cc=mingo@redhat.com \
--cc=rjw@rjwysocki.net \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.