Commit e7a19c5624c66afa8118b10cd59f87ee407646bc
1 parent
ec19920944
Exists in
master
and in
39 other branches
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>
Showing 5 changed files with 21 additions and 16 deletions Side-by-side Diff
drivers/firmware/dmi_scan.c
... | ... | @@ -68,7 +68,8 @@ |
68 | 68 | * pointing to completely the wrong place for example |
69 | 69 | */ |
70 | 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 | 74 | u8 *data = buf; |
74 | 75 | int i = 0; |
... | ... | @@ -89,7 +90,7 @@ |
89 | 90 | while ((data - buf < len - 1) && (data[0] || data[1])) |
90 | 91 | data++; |
91 | 92 | if (data - buf < len - 1) |
92 | - decode(dm); | |
93 | + decode(dm, private_data); | |
93 | 94 | data += 2; |
94 | 95 | i++; |
95 | 96 | } |
... | ... | @@ -99,7 +100,8 @@ |
99 | 100 | static u16 dmi_len; |
100 | 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 | 106 | u8 *buf; |
105 | 107 | |
... | ... | @@ -107,7 +109,7 @@ |
107 | 109 | if (buf == NULL) |
108 | 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 | 114 | dmi_iounmap(buf, dmi_len); |
113 | 115 | return 0; |
... | ... | @@ -295,7 +297,7 @@ |
295 | 297 | * and machine entries. For 2.5 we should pull the smbus controller info |
296 | 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 | 302 | switch(dm->type) { |
301 | 303 | case 0: /* BIOS Information */ |
302 | 304 | |
... | ... | @@ -598,10 +600,12 @@ |
598 | 600 | /** |
599 | 601 | * dmi_walk - Walk the DMI table and get called back for every record |
600 | 602 | * @decode: Callback function |
603 | + * @private_data: Private data to be passed to the callback function | |
601 | 604 | * |
602 | 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 | 610 | u8 *buf; |
607 | 611 | |
... | ... | @@ -612,7 +616,7 @@ |
612 | 616 | if (buf == NULL) |
613 | 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 | 621 | iounmap(buf); |
618 | 622 | return 0; |
drivers/hwmon/fschmd.c
... | ... | @@ -856,7 +856,7 @@ |
856 | 856 | |
857 | 857 | /* DMI decode routine to read voltage scaling factors from special DMI tables, |
858 | 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 | 861 | int i, mult[3] = { 0 }, offset[3] = { 0 }, vref = 0, found = 0; |
862 | 862 | |
... | ... | @@ -991,7 +991,7 @@ |
991 | 991 | |
992 | 992 | /* Read the special DMI table for fscher and newer chips */ |
993 | 993 | if ((kind == fscher || kind >= fschrc) && dmi_vref == -1) { |
994 | - dmi_walk(fschmd_dmi_decode); | |
994 | + dmi_walk(fschmd_dmi_decode, NULL); | |
995 | 995 | if (dmi_vref == -1) { |
996 | 996 | dev_warn(&client->dev, |
997 | 997 | "Couldn't get voltage scaling factors from " |
drivers/platform/x86/dell-laptop.c
... | ... | @@ -103,7 +103,7 @@ |
103 | 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 | 108 | switch (dm->type) { |
109 | 109 | case 0xd4: /* Indexed IO */ |
... | ... | @@ -356,7 +356,7 @@ |
356 | 356 | if (!dmi_check_system(dell_device_table)) |
357 | 357 | return -ENODEV; |
358 | 358 | |
359 | - dmi_walk(find_tokens); | |
359 | + dmi_walk(find_tokens, NULL); | |
360 | 360 | |
361 | 361 | if (!da_tokens) { |
362 | 362 | printk(KERN_INFO "dell-laptop: Unable to find dmi tokens\n"); |
drivers/watchdog/hpwdt.c
... | ... | @@ -380,7 +380,7 @@ |
380 | 380 | * This function checks whether or not a SMBIOS/DMI record is |
381 | 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 | 385 | struct smbios_cru64_info *smbios_cru64_ptr; |
386 | 386 | unsigned long cru_physical_address; |
... | ... | @@ -403,7 +403,7 @@ |
403 | 403 | { |
404 | 404 | cru_rom_addr = NULL; |
405 | 405 | |
406 | - dmi_walk(dmi_find_cru); | |
406 | + dmi_walk(dmi_find_cru, NULL); | |
407 | 407 | |
408 | 408 | /* if cru_rom_addr has been set then we found a CRU service */ |
409 | 409 | return ((cru_rom_addr != NULL) ? 0 : -ENODEV); |
include/linux/dmi.h
... | ... | @@ -47,7 +47,8 @@ |
47 | 47 | extern int dmi_name_in_vendors(const char *str); |
48 | 48 | extern int dmi_name_in_serial(const char *str); |
49 | 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 | 52 | extern bool dmi_match(enum dmi_field f, const char *str); |
52 | 53 | |
53 | 54 | #else |
... | ... | @@ -61,8 +62,8 @@ |
61 | 62 | static inline int dmi_name_in_vendors(const char *s) { return 0; } |
62 | 63 | static inline int dmi_name_in_serial(const char *s) { return 0; } |
63 | 64 | #define dmi_available 0 |
64 | -static inline int dmi_walk(void (*decode)(const struct dmi_header *)) | |
65 | - { return -1; } | |
65 | +static inline int dmi_walk(void (*decode)(const struct dmi_header *, void *), | |
66 | + void *private_data) { return -1; } | |
66 | 67 | static inline bool dmi_match(enum dmi_field f, const char *str) |
67 | 68 | { return false; } |
68 | 69 | static inline const struct dmi_system_id * |