diff options
author | Jean Delvare <khali@linux-fr.org> | 2009-03-30 15:46:44 -0400 |
---|---|---|
committer | Jean Delvare <khali@linux-fr.org> | 2009-03-30 15:46:44 -0400 |
commit | e7a19c5624c66afa8118b10cd59f87ee407646bc (patch) | |
tree | 4e70f99aa84cdd18f13c673980afebe4a268359e /drivers/firmware/dmi_scan.c | |
parent | ec19920944246b4686c7772a58507a20c361dc9d (diff) |
dmi: Let dmi_walk() users pass private data
At the moment, dmi_walk() lacks flexibility, users can't pass data to
the callback function. Add a pointer for private data to make this
function more flexible.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Matthew Garrett <mjg@redhat.com>
Cc: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/firmware/dmi_scan.c')
-rw-r--r-- | drivers/firmware/dmi_scan.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c index 8f0f7c449305..5f1b5400d96a 100644 --- a/drivers/firmware/dmi_scan.c +++ b/drivers/firmware/dmi_scan.c | |||
@@ -68,7 +68,8 @@ static char * __init dmi_string(const struct dmi_header *dm, u8 s) | |||
68 | * pointing to completely the wrong place for example | 68 | * pointing to completely the wrong place for example |
69 | */ | 69 | */ |
70 | static void dmi_table(u8 *buf, int len, int num, | 70 | static void dmi_table(u8 *buf, int len, int num, |
71 | void (*decode)(const struct dmi_header *)) | 71 | void (*decode)(const struct dmi_header *, void *), |
72 | void *private_data) | ||
72 | { | 73 | { |
73 | u8 *data = buf; | 74 | u8 *data = buf; |
74 | int i = 0; | 75 | int i = 0; |
@@ -89,7 +90,7 @@ static void dmi_table(u8 *buf, int len, int num, | |||
89 | while ((data - buf < len - 1) && (data[0] || data[1])) | 90 | while ((data - buf < len - 1) && (data[0] || data[1])) |
90 | data++; | 91 | data++; |
91 | if (data - buf < len - 1) | 92 | if (data - buf < len - 1) |
92 | decode(dm); | 93 | decode(dm, private_data); |
93 | data += 2; | 94 | data += 2; |
94 | i++; | 95 | i++; |
95 | } | 96 | } |
@@ -99,7 +100,8 @@ static u32 dmi_base; | |||
99 | static u16 dmi_len; | 100 | static u16 dmi_len; |
100 | static u16 dmi_num; | 101 | static u16 dmi_num; |
101 | 102 | ||
102 | static int __init dmi_walk_early(void (*decode)(const struct dmi_header *)) | 103 | static int __init dmi_walk_early(void (*decode)(const struct dmi_header *, |
104 | void *)) | ||
103 | { | 105 | { |
104 | u8 *buf; | 106 | u8 *buf; |
105 | 107 | ||
@@ -107,7 +109,7 @@ static int __init dmi_walk_early(void (*decode)(const struct dmi_header *)) | |||
107 | if (buf == NULL) | 109 | if (buf == NULL) |
108 | return -1; | 110 | return -1; |
109 | 111 | ||
110 | dmi_table(buf, dmi_len, dmi_num, decode); | 112 | dmi_table(buf, dmi_len, dmi_num, decode, NULL); |
111 | 113 | ||
112 | dmi_iounmap(buf, dmi_len); | 114 | dmi_iounmap(buf, dmi_len); |
113 | return 0; | 115 | return 0; |
@@ -295,7 +297,7 @@ static void __init dmi_save_extended_devices(const struct dmi_header *dm) | |||
295 | * and machine entries. For 2.5 we should pull the smbus controller info | 297 | * and machine entries. For 2.5 we should pull the smbus controller info |
296 | * out of here. | 298 | * out of here. |
297 | */ | 299 | */ |
298 | static void __init dmi_decode(const struct dmi_header *dm) | 300 | static void __init dmi_decode(const struct dmi_header *dm, void *dummy) |
299 | { | 301 | { |
300 | switch(dm->type) { | 302 | switch(dm->type) { |
301 | case 0: /* BIOS Information */ | 303 | case 0: /* BIOS Information */ |
@@ -598,10 +600,12 @@ int dmi_get_year(int field) | |||
598 | /** | 600 | /** |
599 | * dmi_walk - Walk the DMI table and get called back for every record | 601 | * dmi_walk - Walk the DMI table and get called back for every record |
600 | * @decode: Callback function | 602 | * @decode: Callback function |
603 | * @private_data: Private data to be passed to the callback function | ||
601 | * | 604 | * |
602 | * Returns -1 when the DMI table can't be reached, 0 on success. | 605 | * Returns -1 when the DMI table can't be reached, 0 on success. |
603 | */ | 606 | */ |
604 | int dmi_walk(void (*decode)(const struct dmi_header *)) | 607 | int dmi_walk(void (*decode)(const struct dmi_header *, void *), |
608 | void *private_data) | ||
605 | { | 609 | { |
606 | u8 *buf; | 610 | u8 *buf; |
607 | 611 | ||
@@ -612,7 +616,7 @@ int dmi_walk(void (*decode)(const struct dmi_header *)) | |||
612 | if (buf == NULL) | 616 | if (buf == NULL) |
613 | return -1; | 617 | return -1; |
614 | 618 | ||
615 | dmi_table(buf, dmi_len, dmi_num, decode); | 619 | dmi_table(buf, dmi_len, dmi_num, decode, private_data); |
616 | 620 | ||
617 | iounmap(buf); | 621 | iounmap(buf); |
618 | return 0; | 622 | return 0; |