aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/dmi.h
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2009-08-16 08:02:36 -0400
committerJeff Garzik <jgarzik@redhat.com>2009-09-08 21:17:48 -0400
commit3e5cd1f2576c720f1d0705fdd7ba64f27e8836b7 (patch)
tree631d41c950d2dc93c110ca86e779cb749c9a8987 /include/linux/dmi.h
parent02c24fa87724bb3af969463cd74dc3b3feb24740 (diff)
dmi: extend dmi_get_year() to dmi_get_date()
There are cases where full date information is required instead of just the year. Add month and day parsing to dmi_get_year() and rename it to dmi_get_date(). As the original function only required '/' followed by any number of parseable characters at the end of the string, keep that behavior to avoid upsetting existing users. The new function takes dates of format [mm[/dd]]/yy[yy]. Year, month and date are checked to be in the ranges of [1-9999], [1-12] and [1-31] respectively and any invalid or out-of-range component is returned as zero. The dummy implementation is updated accordingly but the return value is updated to indicate field not found which is consistent with how other dummy functions behave. Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'include/linux/dmi.h')
-rw-r--r--include/linux/dmi.h13
1 files changed, 11 insertions, 2 deletions
diff --git a/include/linux/dmi.h b/include/linux/dmi.h
index bb5489c82c99..a8a3e1ac281d 100644
--- a/include/linux/dmi.h
+++ b/include/linux/dmi.h
@@ -43,7 +43,7 @@ extern const char * dmi_get_system_info(int field);
43extern const struct dmi_device * dmi_find_device(int type, const char *name, 43extern const struct dmi_device * dmi_find_device(int type, const char *name,
44 const struct dmi_device *from); 44 const struct dmi_device *from);
45extern void dmi_scan_machine(void); 45extern void dmi_scan_machine(void);
46extern int dmi_get_year(int field); 46extern bool dmi_get_date(int field, int *yearp, int *monthp, int *dayp);
47extern int dmi_name_in_vendors(const char *str); 47extern int dmi_name_in_vendors(const char *str);
48extern int dmi_name_in_serial(const char *str); 48extern int dmi_name_in_serial(const char *str);
49extern int dmi_available; 49extern int dmi_available;
@@ -58,7 +58,16 @@ static inline const char * dmi_get_system_info(int field) { return NULL; }
58static inline const struct dmi_device * dmi_find_device(int type, const char *name, 58static inline const struct dmi_device * dmi_find_device(int type, const char *name,
59 const struct dmi_device *from) { return NULL; } 59 const struct dmi_device *from) { return NULL; }
60static inline void dmi_scan_machine(void) { return; } 60static inline void dmi_scan_machine(void) { return; }
61static inline int dmi_get_year(int year) { return 0; } 61static inline bool dmi_get_date(int field, int *yearp, int *monthp, int *dayp)
62{
63 if (yearp)
64 *yearp = 0;
65 if (monthp)
66 *monthp = 0;
67 if (dayp)
68 *dayp = 0;
69 return false;
70}
62static inline int dmi_name_in_vendors(const char *s) { return 0; } 71static inline int dmi_name_in_vendors(const char *s) { return 0; }
63static inline int dmi_name_in_serial(const char *s) { return 0; } 72static inline int dmi_name_in_serial(const char *s) { return 0; }
64#define dmi_available 0 73#define dmi_available 0