Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

firmware/dmi_scan: Uninline dmi_get_bios_year() helper

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.

Suggested-by: Bjorn Helgaas <helgaas@kernel.org>
Suggested-by: Rafael J. Wysocki <rafael@kernel.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rafael J . Wysocki <rjw@rjwysocki.net>
Cc: linux-acpi@vger.kernel.org
Cc: linux-pci@vger.kernel.org
Fixes: 492a1abd61e4 ("dmi: Introduce the dmi_get_bios_year() helper function")
Signed-off-by: Ingo Molnar <mingo@kernel.org>

authored by

Andy Shevchenko and committed by
Ingo Molnar
3af34525 4e07db9c

+22 -9
+20
drivers/firmware/dmi_scan.c
··· 1005 1005 EXPORT_SYMBOL(dmi_get_date); 1006 1006 1007 1007 /** 1008 + * dmi_get_bios_year - get a year out of DMI_BIOS_DATE field 1009 + * 1010 + * Returns year on success, -ENXIO if DMI is not selected, 1011 + * or a different negative error code if DMI field is not present 1012 + * or not parseable. 1013 + */ 1014 + int dmi_get_bios_year(void) 1015 + { 1016 + bool exists; 1017 + int year; 1018 + 1019 + exists = dmi_get_date(DMI_BIOS_DATE, &year, NULL, NULL); 1020 + if (!exists) 1021 + return -ENODATA; 1022 + 1023 + return year ? year : -ERANGE; 1024 + } 1025 + EXPORT_SYMBOL(dmi_get_bios_year); 1026 + 1027 + /** 1008 1028 * dmi_walk - Walk the DMI table and get called back for every record 1009 1029 * @decode: Callback function 1010 1030 * @private_data: Private data to be passed to the callback function
+2 -9
include/linux/dmi.h
··· 106 106 extern void dmi_memdev_walk(void); 107 107 extern void dmi_set_dump_stack_arch_desc(void); 108 108 extern bool dmi_get_date(int field, int *yearp, int *monthp, int *dayp); 109 + extern int dmi_get_bios_year(void); 109 110 extern int dmi_name_in_vendors(const char *str); 110 111 extern int dmi_name_in_serial(const char *str); 111 112 extern int dmi_available; ··· 134 133 *dayp = 0; 135 134 return false; 136 135 } 136 + static inline int dmi_get_bios_year(void) { return -ENXIO; } 137 137 static inline int dmi_name_in_vendors(const char *s) { return 0; } 138 138 static inline int dmi_name_in_serial(const char *s) { return 0; } 139 139 #define dmi_available 0 ··· 148 146 dmi_first_match(const struct dmi_system_id *list) { return NULL; } 149 147 150 148 #endif 151 - 152 - static inline int dmi_get_bios_year(void) 153 - { 154 - int year; 155 - 156 - dmi_get_date(DMI_BIOS_DATE, &year, NULL, NULL); 157 - 158 - return year; 159 - } 160 149 161 150 #endif /* __DMI_H__ */