diff options
author | Jiri Slaby <jirislaby@gmail.com> | 2008-12-10 08:07:21 -0500 |
---|---|---|
committer | Jeff Garzik <jgarzik@redhat.com> | 2008-12-29 07:39:34 -0500 |
commit | d61c72e52b98411d1cfef1fdb3f5a8bb070f8966 (patch) | |
tree | a32263f85d0b518cac00cf0758e738eee52a7f73 | |
parent | 5ccfca974f3ce3c33be72f1fcb2b42747714ec79 (diff) |
DMI: add dmi_match
Add a wrapper for testing system_info which will handle also NULL
system infos.
This will be used by the ata PIIX driver.
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Cc: Alexandru Romanescu <a_romanescu@yahoo.co.uk>
Cc: Tejun Heo <tj@kernel.org>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
-rw-r--r-- | drivers/firmware/dmi_scan.c | 16 | ||||
-rw-r--r-- | include/linux/dmi.h | 3 |
2 files changed, 19 insertions, 0 deletions
diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c index 4a597d8c2f70..78b989d202a3 100644 --- a/drivers/firmware/dmi_scan.c +++ b/drivers/firmware/dmi_scan.c | |||
@@ -582,3 +582,19 @@ int dmi_walk(void (*decode)(const struct dmi_header *)) | |||
582 | return 0; | 582 | return 0; |
583 | } | 583 | } |
584 | EXPORT_SYMBOL_GPL(dmi_walk); | 584 | EXPORT_SYMBOL_GPL(dmi_walk); |
585 | |||
586 | /** | ||
587 | * dmi_match - compare a string to the dmi field (if exists) | ||
588 | * | ||
589 | * Returns true if the requested field equals to the str (including NULL). | ||
590 | */ | ||
591 | bool dmi_match(enum dmi_field f, const char *str) | ||
592 | { | ||
593 | const char *info = dmi_get_system_info(f); | ||
594 | |||
595 | if (info == NULL || str == NULL) | ||
596 | return info == str; | ||
597 | |||
598 | return !strcmp(info, str); | ||
599 | } | ||
600 | EXPORT_SYMBOL_GPL(dmi_match); | ||
diff --git a/include/linux/dmi.h b/include/linux/dmi.h index 2bfda178f274..34161907b2f8 100644 --- a/include/linux/dmi.h +++ b/include/linux/dmi.h | |||
@@ -47,6 +47,7 @@ extern int dmi_name_in_vendors(const char *str); | |||
47 | extern int dmi_name_in_serial(const char *str); | 47 | extern int dmi_name_in_serial(const char *str); |
48 | extern int dmi_available; | 48 | extern int dmi_available; |
49 | extern int dmi_walk(void (*decode)(const struct dmi_header *)); | 49 | extern int dmi_walk(void (*decode)(const struct dmi_header *)); |
50 | extern bool dmi_match(enum dmi_field f, const char *str); | ||
50 | 51 | ||
51 | #else | 52 | #else |
52 | 53 | ||
@@ -61,6 +62,8 @@ static inline int dmi_name_in_serial(const char *s) { return 0; } | |||
61 | #define dmi_available 0 | 62 | #define dmi_available 0 |
62 | static inline int dmi_walk(void (*decode)(const struct dmi_header *)) | 63 | static inline int dmi_walk(void (*decode)(const struct dmi_header *)) |
63 | { return -1; } | 64 | { return -1; } |
65 | static inline bool dmi_match(enum dmi_field f, const char *str) | ||
66 | { return false; } | ||
64 | 67 | ||
65 | #endif | 68 | #endif |
66 | 69 | ||