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 | |
| 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>
| -rw-r--r-- | drivers/firmware/dmi_scan.c | 18 | ||||
| -rw-r--r-- | drivers/hwmon/fschmd.c | 4 | ||||
| -rw-r--r-- | drivers/platform/x86/dell-laptop.c | 4 | ||||
| -rw-r--r-- | drivers/watchdog/hpwdt.c | 4 | ||||
| -rw-r--r-- | include/linux/dmi.h | 7 |
5 files changed, 21 insertions, 16 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; |
diff --git a/drivers/hwmon/fschmd.c b/drivers/hwmon/fschmd.c index d07f4ef75092..b557f2ebd9ae 100644 --- a/drivers/hwmon/fschmd.c +++ b/drivers/hwmon/fschmd.c | |||
| @@ -856,7 +856,7 @@ static struct file_operations watchdog_fops = { | |||
| 856 | 856 | ||
| 857 | /* DMI decode routine to read voltage scaling factors from special DMI tables, | 857 | /* DMI decode routine to read voltage scaling factors from special DMI tables, |
| 858 | which are available on FSC machines with an fscher or later chip. */ | 858 | which are available on FSC machines with an fscher or later chip. */ |
| 859 | static void fschmd_dmi_decode(const struct dmi_header *header) | 859 | static void fschmd_dmi_decode(const struct dmi_header *header, void *dummy) |
| 860 | { | 860 | { |
| 861 | int i, mult[3] = { 0 }, offset[3] = { 0 }, vref = 0, found = 0; | 861 | int i, mult[3] = { 0 }, offset[3] = { 0 }, vref = 0, found = 0; |
| 862 | 862 | ||
| @@ -991,7 +991,7 @@ static int fschmd_probe(struct i2c_client *client, | |||
| 991 | 991 | ||
| 992 | /* Read the special DMI table for fscher and newer chips */ | 992 | /* Read the special DMI table for fscher and newer chips */ |
| 993 | if ((kind == fscher || kind >= fschrc) && dmi_vref == -1) { | 993 | if ((kind == fscher || kind >= fschrc) && dmi_vref == -1) { |
| 994 | dmi_walk(fschmd_dmi_decode); | 994 | dmi_walk(fschmd_dmi_decode, NULL); |
| 995 | if (dmi_vref == -1) { | 995 | if (dmi_vref == -1) { |
| 996 | dev_warn(&client->dev, | 996 | dev_warn(&client->dev, |
| 997 | "Couldn't get voltage scaling factors from " | 997 | "Couldn't get voltage scaling factors from " |
diff --git a/drivers/platform/x86/dell-laptop.c b/drivers/platform/x86/dell-laptop.c index 16e11c2ee19a..af9f43021172 100644 --- a/drivers/platform/x86/dell-laptop.c +++ b/drivers/platform/x86/dell-laptop.c | |||
| @@ -103,7 +103,7 @@ static void parse_da_table(const struct dmi_header *dm) | |||
| 103 | da_num_tokens += tokens; | 103 | da_num_tokens += tokens; |
| 104 | } | 104 | } |
| 105 | 105 | ||
| 106 | static void find_tokens(const struct dmi_header *dm) | 106 | static void find_tokens(const struct dmi_header *dm, void *dummy) |
| 107 | { | 107 | { |
| 108 | switch (dm->type) { | 108 | switch (dm->type) { |
| 109 | case 0xd4: /* Indexed IO */ | 109 | case 0xd4: /* Indexed IO */ |
| @@ -356,7 +356,7 @@ static int __init dell_init(void) | |||
| 356 | if (!dmi_check_system(dell_device_table)) | 356 | if (!dmi_check_system(dell_device_table)) |
| 357 | return -ENODEV; | 357 | return -ENODEV; |
| 358 | 358 | ||
| 359 | dmi_walk(find_tokens); | 359 | dmi_walk(find_tokens, NULL); |
| 360 | 360 | ||
| 361 | if (!da_tokens) { | 361 | if (!da_tokens) { |
| 362 | printk(KERN_INFO "dell-laptop: Unable to find dmi tokens\n"); | 362 | printk(KERN_INFO "dell-laptop: Unable to find dmi tokens\n"); |
diff --git a/drivers/watchdog/hpwdt.c b/drivers/watchdog/hpwdt.c index 6cf155d6b350..3137361ccbfe 100644 --- a/drivers/watchdog/hpwdt.c +++ b/drivers/watchdog/hpwdt.c | |||
| @@ -380,7 +380,7 @@ asm(".text \n\t" | |||
| 380 | * This function checks whether or not a SMBIOS/DMI record is | 380 | * This function checks whether or not a SMBIOS/DMI record is |
| 381 | * the 64bit CRU info or not | 381 | * the 64bit CRU info or not |
| 382 | */ | 382 | */ |
| 383 | static void __devinit dmi_find_cru(const struct dmi_header *dm) | 383 | static void __devinit dmi_find_cru(const struct dmi_header *dm, void *dummy) |
| 384 | { | 384 | { |
| 385 | struct smbios_cru64_info *smbios_cru64_ptr; | 385 | struct smbios_cru64_info *smbios_cru64_ptr; |
| 386 | unsigned long cru_physical_address; | 386 | unsigned long cru_physical_address; |
| @@ -403,7 +403,7 @@ static int __devinit detect_cru_service(void) | |||
| 403 | { | 403 | { |
| 404 | cru_rom_addr = NULL; | 404 | cru_rom_addr = NULL; |
| 405 | 405 | ||
| 406 | dmi_walk(dmi_find_cru); | 406 | dmi_walk(dmi_find_cru, NULL); |
| 407 | 407 | ||
| 408 | /* if cru_rom_addr has been set then we found a CRU service */ | 408 | /* if cru_rom_addr has been set then we found a CRU service */ |
| 409 | return ((cru_rom_addr != NULL) ? 0 : -ENODEV); | 409 | return ((cru_rom_addr != NULL) ? 0 : -ENODEV); |
diff --git a/include/linux/dmi.h b/include/linux/dmi.h index d741b9ceb0e0..bb5489c82c99 100644 --- a/include/linux/dmi.h +++ b/include/linux/dmi.h | |||
| @@ -47,7 +47,8 @@ extern int dmi_get_year(int field); | |||
| 47 | extern int dmi_name_in_vendors(const char *str); | 47 | extern int dmi_name_in_vendors(const char *str); |
| 48 | extern int dmi_name_in_serial(const char *str); | 48 | extern int dmi_name_in_serial(const char *str); |
| 49 | extern int dmi_available; | 49 | extern int dmi_available; |
| 50 | extern int dmi_walk(void (*decode)(const struct dmi_header *)); | 50 | extern int dmi_walk(void (*decode)(const struct dmi_header *, void *), |
| 51 | void *private_data); | ||
| 51 | extern bool dmi_match(enum dmi_field f, const char *str); | 52 | extern bool dmi_match(enum dmi_field f, const char *str); |
| 52 | 53 | ||
| 53 | #else | 54 | #else |
| @@ -61,8 +62,8 @@ static inline int dmi_get_year(int year) { return 0; } | |||
| 61 | static inline int dmi_name_in_vendors(const char *s) { return 0; } | 62 | static inline int dmi_name_in_vendors(const char *s) { return 0; } |
| 62 | static inline int dmi_name_in_serial(const char *s) { return 0; } | 63 | static inline int dmi_name_in_serial(const char *s) { return 0; } |
| 63 | #define dmi_available 0 | 64 | #define dmi_available 0 |
| 64 | static inline int dmi_walk(void (*decode)(const struct dmi_header *)) | 65 | static inline int dmi_walk(void (*decode)(const struct dmi_header *, void *), |
| 65 | { return -1; } | 66 | void *private_data) { return -1; } |
| 66 | static inline bool dmi_match(enum dmi_field f, const char *str) | 67 | static inline bool dmi_match(enum dmi_field f, const char *str) |
| 67 | { return false; } | 68 | { return false; } |
| 68 | static inline const struct dmi_system_id * | 69 | static inline const struct dmi_system_id * |
