1 From 1855256c497ecfefc730df6032243f26855ce52c Mon Sep 17 00:00:00 2001
2 From: Jeff Garzik <jeff@garzik.org>
3 Date: Wed, 3 Oct 2007 15:15:40 -0400
4 Subject: [PATCH] drivers/firmware: const-ify DMI API and internals
6 Three main sets of changes:
8 1) dmi_get_system_info() return value should have been marked const,
9 since callers should not be changing that data.
11 2) const-ify DMI internals, since DMI firmware tables should,
12 whenever possible, be marked const to ensure we never ever write to
15 3) const-ify DMI API, to enable marking tables const where possible
18 And if we're really lucky, this might enable some additional
19 optimizations on the part of the compiler.
21 The bulk of the changes are #2 and #3, which are interrelated. #1 could
22 have been a separate patch, but it was so small compared to the others,
23 it was easier to roll it into this changeset.
25 Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
27 arch/i386/kernel/acpi/boot.c | 8 ++--
28 arch/i386/kernel/acpi/sleep.c | 2 +-
29 arch/i386/kernel/apm.c | 18 ++++----
30 arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c | 4 +-
31 arch/i386/kernel/reboot.c | 2 +-
32 arch/i386/kernel/tsc.c | 2 +-
33 arch/i386/mach-generic/bigsmp.c | 4 +-
34 arch/i386/pci/common.c | 4 +-
35 arch/i386/pci/irq.c | 4 +-
36 drivers/acpi/osl.c | 2 +-
37 drivers/acpi/processor_idle.c | 2 +-
38 drivers/acpi/sleep/main.c | 2 +-
39 drivers/acpi/thermal.c | 8 ++--
40 drivers/ata/ata_piix.c | 4 +-
41 drivers/ata/pata_ali.c | 2 +-
42 drivers/ata/pata_cs5530.c | 2 +-
43 drivers/ata/pata_via.c | 2 +-
44 drivers/char/i8k.c | 4 +-
45 drivers/char/ipmi/ipmi_si_intf.c | 9 ++--
46 drivers/firmware/dmi_scan.c | 57 ++++++++++++++------------
47 drivers/hwmon/abituguru.c | 2 +-
48 drivers/hwmon/applesmc.c | 2 +-
49 drivers/hwmon/hdaps.c | 4 +-
50 drivers/ide/pci/alim15x3.c | 2 +-
51 drivers/ide/pci/via82cxxx.c | 2 +-
52 drivers/input/misc/wistron_btns.c | 2 +-
53 drivers/input/mouse/lifebook.c | 6 +-
54 drivers/input/mouse/synaptics.c | 2 +-
55 drivers/misc/msi-laptop.c | 2 +-
56 drivers/misc/sony-laptop.c | 4 +-
57 drivers/misc/thinkpad_acpi.c | 2 +-
58 drivers/pnp/pnpbios/core.c | 2 +-
59 drivers/usb/host/uhci-hcd.c | 2 +-
60 drivers/video/imacfb.c | 2 +-
61 include/linux/dmi.h | 22 +++++-----
62 35 files changed, 103 insertions(+), 97 deletions(-)
64 diff --git a/arch/i386/kernel/acpi/boot.c b/arch/i386/kernel/acpi/boot.c
65 index cacdd88..afd2afe 100644
66 --- a/arch/i386/kernel/acpi/boot.c
67 +++ b/arch/i386/kernel/acpi/boot.c
68 @@ -907,7 +907,7 @@ static void __init acpi_process_madt(void)
72 -static int __init disable_acpi_irq(struct dmi_system_id *d)
73 +static int __init disable_acpi_irq(const struct dmi_system_id *d)
76 printk(KERN_NOTICE "%s detected: force use of acpi=noirq\n",
77 @@ -917,7 +917,7 @@ static int __init disable_acpi_irq(struct dmi_system_id *d)
81 -static int __init disable_acpi_pci(struct dmi_system_id *d)
82 +static int __init disable_acpi_pci(const struct dmi_system_id *d)
85 printk(KERN_NOTICE "%s detected: force use of pci=noacpi\n",
86 @@ -927,7 +927,7 @@ static int __init disable_acpi_pci(struct dmi_system_id *d)
90 -static int __init dmi_disable_acpi(struct dmi_system_id *d)
91 +static int __init dmi_disable_acpi(const struct dmi_system_id *d)
94 printk(KERN_NOTICE "%s detected: acpi off\n", d->ident);
95 @@ -942,7 +942,7 @@ static int __init dmi_disable_acpi(struct dmi_system_id *d)
97 * Limit ACPI to CPU enumeration for HT
99 -static int __init force_acpi_ht(struct dmi_system_id *d)
100 +static int __init force_acpi_ht(const struct dmi_system_id *d)
103 printk(KERN_NOTICE "%s detected: force use of acpi=ht\n",
104 diff --git a/arch/i386/kernel/acpi/sleep.c b/arch/i386/kernel/acpi/sleep.c
105 index c42b5ab..1069948 100644
106 --- a/arch/i386/kernel/acpi/sleep.c
107 +++ b/arch/i386/kernel/acpi/sleep.c
108 @@ -84,7 +84,7 @@ __setup("acpi_sleep=", acpi_sleep_setup);
110 /* Ouch, we want to delete this. We already have better version in userspace, in
111 s2ram from suspend.sf.net project */
112 -static __init int reset_videomode_after_s3(struct dmi_system_id *d)
113 +static __init int reset_videomode_after_s3(const struct dmi_system_id *d)
115 acpi_realmode_flags |= 2;
117 diff --git a/arch/i386/kernel/apm.c b/arch/i386/kernel/apm.c
118 index f02a8ac..32f2365 100644
119 --- a/arch/i386/kernel/apm.c
120 +++ b/arch/i386/kernel/apm.c
121 @@ -1869,7 +1869,7 @@ static struct miscdevice apm_device = {
124 /* Simple "print if true" callback */
125 -static int __init print_if_true(struct dmi_system_id *d)
126 +static int __init print_if_true(const struct dmi_system_id *d)
128 printk("%s\n", d->ident);
130 @@ -1879,14 +1879,14 @@ static int __init print_if_true(struct dmi_system_id *d)
131 * Some Bioses enable the PS/2 mouse (touchpad) at resume, even if it was
132 * disabled before the suspend. Linux used to get terribly confused by that.
134 -static int __init broken_ps2_resume(struct dmi_system_id *d)
135 +static int __init broken_ps2_resume(const struct dmi_system_id *d)
137 printk(KERN_INFO "%s machine detected. Mousepad Resume Bug workaround hopefully not needed.\n", d->ident);
141 /* Some bioses have a broken protected mode poweroff and need to use realmode */
142 -static int __init set_realmode_power_off(struct dmi_system_id *d)
143 +static int __init set_realmode_power_off(const struct dmi_system_id *d)
145 if (apm_info.realmode_power_off == 0) {
146 apm_info.realmode_power_off = 1;
147 @@ -1896,7 +1896,7 @@ static int __init set_realmode_power_off(struct dmi_system_id *d)
150 /* Some laptops require interrupts to be enabled during APM calls */
151 -static int __init set_apm_ints(struct dmi_system_id *d)
152 +static int __init set_apm_ints(const struct dmi_system_id *d)
154 if (apm_info.allow_ints == 0) {
155 apm_info.allow_ints = 1;
156 @@ -1906,7 +1906,7 @@ static int __init set_apm_ints(struct dmi_system_id *d)
159 /* Some APM bioses corrupt memory or just plain do not work */
160 -static int __init apm_is_horked(struct dmi_system_id *d)
161 +static int __init apm_is_horked(const struct dmi_system_id *d)
163 if (apm_info.disabled == 0) {
164 apm_info.disabled = 1;
165 @@ -1915,7 +1915,7 @@ static int __init apm_is_horked(struct dmi_system_id *d)
169 -static int __init apm_is_horked_d850md(struct dmi_system_id *d)
170 +static int __init apm_is_horked_d850md(const struct dmi_system_id *d)
172 if (apm_info.disabled == 0) {
173 apm_info.disabled = 1;
174 @@ -1927,7 +1927,7 @@ static int __init apm_is_horked_d850md(struct dmi_system_id *d)
177 /* Some APM bioses hang on APM idle calls */
178 -static int __init apm_likes_to_melt(struct dmi_system_id *d)
179 +static int __init apm_likes_to_melt(const struct dmi_system_id *d)
181 if (apm_info.forbid_idle == 0) {
182 apm_info.forbid_idle = 1;
183 @@ -1951,7 +1951,7 @@ static int __init apm_likes_to_melt(struct dmi_system_id *d)
184 * Phoenix A04 08/24/2000 is known bad (Dell Inspiron 5000e)
185 * Phoenix A07 09/29/2000 is known good (Dell Inspiron 5000)
187 -static int __init broken_apm_power(struct dmi_system_id *d)
188 +static int __init broken_apm_power(const struct dmi_system_id *d)
190 apm_info.get_power_status_broken = 1;
191 printk(KERN_WARNING "BIOS strings suggest APM bugs, disabling power status reporting.\n");
192 @@ -1962,7 +1962,7 @@ static int __init broken_apm_power(struct dmi_system_id *d)
193 * This bios swaps the APM minute reporting bytes over (Many sony laptops
194 * have this problem).
196 -static int __init swab_apm_power_in_minutes(struct dmi_system_id *d)
197 +static int __init swab_apm_power_in_minutes(const struct dmi_system_id *d)
199 apm_info.get_power_status_swabinminutes = 1;
200 printk(KERN_WARNING "BIOS strings suggest APM reports battery life in minutes and wrong byte order.\n");
201 diff --git a/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c b/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
202 index 705e13a..b6434a7 100644
203 --- a/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
204 +++ b/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
205 @@ -533,13 +533,13 @@ static int __init acpi_cpufreq_early_init(void)
207 static int bios_with_sw_any_bug;
209 -static int sw_any_bug_found(struct dmi_system_id *d)
210 +static int sw_any_bug_found(const struct dmi_system_id *d)
212 bios_with_sw_any_bug = 1;
216 -static struct dmi_system_id sw_any_bug_dmi_table[] = {
217 +static const struct dmi_system_id sw_any_bug_dmi_table[] = {
219 .callback = sw_any_bug_found,
220 .ident = "Supermicro Server X6DLP",
221 diff --git a/arch/i386/kernel/reboot.c b/arch/i386/kernel/reboot.c
222 index 0d79624..b37ed22 100644
223 --- a/arch/i386/kernel/reboot.c
224 +++ b/arch/i386/kernel/reboot.c
225 @@ -79,7 +79,7 @@ __setup("reboot=", reboot_setup);
227 * Some machines require the "reboot=b" commandline option, this quirk makes that automatic.
229 -static int __init set_bios_reboot(struct dmi_system_id *d)
230 +static int __init set_bios_reboot(const struct dmi_system_id *d)
232 if (!reboot_thru_bios) {
233 reboot_thru_bios = 1;
234 diff --git a/arch/i386/kernel/tsc.c b/arch/i386/kernel/tsc.c
235 index a39280b..3ed0ae8 100644
236 --- a/arch/i386/kernel/tsc.c
237 +++ b/arch/i386/kernel/tsc.c
238 @@ -305,7 +305,7 @@ void mark_tsc_unstable(char *reason)
240 EXPORT_SYMBOL_GPL(mark_tsc_unstable);
242 -static int __init dmi_mark_tsc_unstable(struct dmi_system_id *d)
243 +static int __init dmi_mark_tsc_unstable(const struct dmi_system_id *d)
245 printk(KERN_NOTICE "%s detected: marking TSC unstable.\n",
247 diff --git a/arch/i386/mach-generic/bigsmp.c b/arch/i386/mach-generic/bigsmp.c
248 index 58a477b..292a225 100644
249 --- a/arch/i386/mach-generic/bigsmp.c
250 +++ b/arch/i386/mach-generic/bigsmp.c
253 static int dmi_bigsmp; /* can be set by dmi scanners */
255 -static int hp_ht_bigsmp(struct dmi_system_id *d)
256 +static int hp_ht_bigsmp(const struct dmi_system_id *d)
258 #ifdef CONFIG_X86_GENERICARCH
259 printk(KERN_NOTICE "%s detected: force use of apic=bigsmp\n", d->ident);
260 @@ -31,7 +31,7 @@ static int hp_ht_bigsmp(struct dmi_system_id *d)
264 -static struct dmi_system_id bigsmp_dmi_table[] = {
265 +static const struct dmi_system_id bigsmp_dmi_table[] = {
266 { hp_ht_bigsmp, "HP ProLiant DL760 G2", {
267 DMI_MATCH(DMI_BIOS_VENDOR, "HP"),
268 DMI_MATCH(DMI_BIOS_VERSION, "P44-"),
269 diff --git a/arch/i386/pci/common.c b/arch/i386/pci/common.c
270 index ebc6f3c..07d5223 100644
271 --- a/arch/i386/pci/common.c
272 +++ b/arch/i386/pci/common.c
273 @@ -123,7 +123,7 @@ void __devinit pcibios_fixup_bus(struct pci_bus *b)
274 * on the kernel command line (which was parsed earlier).
277 -static int __devinit set_bf_sort(struct dmi_system_id *d)
278 +static int __devinit set_bf_sort(const struct dmi_system_id *d)
280 if (pci_bf_sort == pci_bf_sort_default) {
281 pci_bf_sort = pci_dmi_bf;
282 @@ -136,7 +136,7 @@ static int __devinit set_bf_sort(struct dmi_system_id *d)
283 * Enable renumbering of PCI bus# ranges to reach all PCI busses (Cardbus)
286 -static int __devinit assign_all_busses(struct dmi_system_id *d)
287 +static int __devinit assign_all_busses(const struct dmi_system_id *d)
289 pci_probe |= PCI_ASSIGN_ALL_BUSSES;
290 printk(KERN_INFO "%s detected: enabling PCI bus# renumbering"
291 diff --git a/arch/i386/pci/irq.c b/arch/i386/pci/irq.c
292 index 8434f23..d98c6b0 100644
293 --- a/arch/i386/pci/irq.c
294 +++ b/arch/i386/pci/irq.c
295 @@ -1010,7 +1010,7 @@ static void __init pcibios_fixup_irqs(void)
296 * Work around broken HP Pavilion Notebooks which assign USB to
297 * IRQ 9 even though it is actually wired to IRQ 11
299 -static int __init fix_broken_hp_bios_irq9(struct dmi_system_id *d)
300 +static int __init fix_broken_hp_bios_irq9(const struct dmi_system_id *d)
302 if (!broken_hp_bios_irq9) {
303 broken_hp_bios_irq9 = 1;
304 @@ -1023,7 +1023,7 @@ static int __init fix_broken_hp_bios_irq9(struct dmi_system_id *d)
305 * Work around broken Acer TravelMate 360 Notebooks which assign
306 * Cardbus to IRQ 11 even though it is actually wired to IRQ 10
308 -static int __init fix_acer_tm360_irqrouting(struct dmi_system_id *d)
309 +static int __init fix_acer_tm360_irqrouting(const struct dmi_system_id *d)
311 if (!acer_tm360_irqrouting) {
312 acer_tm360_irqrouting = 1;
313 diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
314 index 12c09fa..352cf81 100644
315 --- a/drivers/acpi/osl.c
316 +++ b/drivers/acpi/osl.c
317 @@ -1214,7 +1214,7 @@ acpi_os_validate_address (
321 -static int dmi_osi_linux(struct dmi_system_id *d)
322 +static int dmi_osi_linux(const struct dmi_system_id *d)
324 printk(KERN_NOTICE "%s detected: enabling _OSI(Linux)\n", d->ident);
326 diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
327 index f182613..1e8287b 100644
328 --- a/drivers/acpi/processor_idle.c
329 +++ b/drivers/acpi/processor_idle.c
330 @@ -92,7 +92,7 @@ module_param(bm_history, uint, 0644);
332 * To skip this limit, boot/load with a large max_cstate limit.
334 -static int set_max_cstate(struct dmi_system_id *id)
335 +static int set_max_cstate(const struct dmi_system_id *id)
337 if (max_cstate > ACPI_PROCESSOR_MAX_POWER)
339 diff --git a/drivers/acpi/sleep/main.c b/drivers/acpi/sleep/main.c
340 index 2cbb9aa..5055acf 100644
341 --- a/drivers/acpi/sleep/main.c
342 +++ b/drivers/acpi/sleep/main.c
343 @@ -215,7 +215,7 @@ static struct pm_ops acpi_pm_ops = {
344 * Toshiba fails to preserve interrupts over S1, reinitialization
345 * of 8259 is needed after S1 resume.
347 -static int __init init_ints_after_s1(struct dmi_system_id *d)
348 +static int __init init_ints_after_s1(const struct dmi_system_id *d)
350 printk(KERN_WARNING "%s with broken S1 detected.\n", d->ident);
351 init_8259A_after_S1 = 1;
352 diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
353 index bc6d586..ad898e1 100644
354 --- a/drivers/acpi/thermal.c
355 +++ b/drivers/acpi/thermal.c
356 @@ -1360,7 +1360,7 @@ static int acpi_thermal_resume(struct acpi_device *device)
360 -static int thermal_act(struct dmi_system_id *d) {
361 +static int thermal_act(const struct dmi_system_id *d) {
364 printk(KERN_NOTICE "ACPI: %s detected: "
365 @@ -1369,14 +1369,14 @@ static int thermal_act(struct dmi_system_id *d) {
369 -static int thermal_nocrt(struct dmi_system_id *d) {
370 +static int thermal_nocrt(const struct dmi_system_id *d) {
372 printk(KERN_NOTICE "ACPI: %s detected: "
373 "disabling all critical thermal trip point actions.\n", d->ident);
377 -static int thermal_tzp(struct dmi_system_id *d) {
378 +static int thermal_tzp(const struct dmi_system_id *d) {
381 printk(KERN_NOTICE "ACPI: %s detected: "
382 @@ -1385,7 +1385,7 @@ static int thermal_tzp(struct dmi_system_id *d) {
386 -static int thermal_psv(struct dmi_system_id *d) {
387 +static int thermal_psv(const struct dmi_system_id *d) {
390 printk(KERN_NOTICE "ACPI: %s detected: "
391 diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c
392 index 6996eb5..92c2d50 100644
393 --- a/drivers/ata/ata_piix.c
394 +++ b/drivers/ata/ata_piix.c
395 @@ -919,7 +919,7 @@ static void ich_set_dmamode (struct ata_port *ap, struct ata_device *adev)
397 static int piix_broken_suspend(void)
399 - static struct dmi_system_id sysids[] = {
400 + static const struct dmi_system_id sysids[] = {
404 @@ -1183,7 +1183,7 @@ static void __devinit piix_init_sata_map(struct pci_dev *pdev,
406 static void piix_iocfg_bit18_quirk(struct pci_dev *pdev)
408 - static struct dmi_system_id sysids[] = {
409 + static const struct dmi_system_id sysids[] = {
411 /* Clevo M570U sets IOCFG bit 18 if the cdrom
412 * isn't used to boot the system which
413 diff --git a/drivers/ata/pata_ali.c b/drivers/ata/pata_ali.c
414 index 71bdc3b..32a10c9 100644
415 --- a/drivers/ata/pata_ali.c
416 +++ b/drivers/ata/pata_ali.c
418 * Cable special cases
421 -static struct dmi_system_id cable_dmi_table[] = {
422 +static const struct dmi_system_id cable_dmi_table[] = {
424 .ident = "HP Pavilion N5430",
426 diff --git a/drivers/ata/pata_cs5530.c b/drivers/ata/pata_cs5530.c
427 index c6066aa..eaaea84 100644
428 --- a/drivers/ata/pata_cs5530.c
429 +++ b/drivers/ata/pata_cs5530.c
430 @@ -214,7 +214,7 @@ static struct ata_port_operations cs5530_port_ops = {
431 .port_start = ata_port_start,
434 -static struct dmi_system_id palmax_dmi_table[] = {
435 +static const struct dmi_system_id palmax_dmi_table[] = {
437 .ident = "Palmax PD1100",
439 diff --git a/drivers/ata/pata_via.c b/drivers/ata/pata_via.c
440 index 636c4f1..f143db4 100644
441 --- a/drivers/ata/pata_via.c
442 +++ b/drivers/ata/pata_via.c
443 @@ -129,7 +129,7 @@ static const struct via_isa_bridge {
444 * Cable special cases
447 -static struct dmi_system_id cable_dmi_table[] = {
448 +static const struct dmi_system_id cable_dmi_table[] = {
450 .ident = "Acer Ferrari 3400",
452 diff --git a/drivers/char/i8k.c b/drivers/char/i8k.c
453 index 0289705..cd40641 100644
454 --- a/drivers/char/i8k.c
455 +++ b/drivers/char/i8k.c
456 @@ -98,9 +98,9 @@ struct smm_regs {
457 unsigned int edi __attribute__ ((packed));
460 -static inline char *i8k_get_dmi_data(int field)
461 +static inline const char *i8k_get_dmi_data(int field)
463 - char *dmi_data = dmi_get_system_info(field);
464 + const char *dmi_data = dmi_get_system_info(field);
466 return dmi_data && *dmi_data ? dmi_data : "?";
468 diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
469 index dd441ff..7901d5f 100644
470 --- a/drivers/char/ipmi/ipmi_si_intf.c
471 +++ b/drivers/char/ipmi/ipmi_si_intf.c
472 @@ -1965,10 +1965,10 @@ struct dmi_ipmi_data
476 -static int __devinit decode_dmi(struct dmi_header *dm,
477 +static int __devinit decode_dmi(const struct dmi_header *dm,
478 struct dmi_ipmi_data *dmi)
480 - u8 *data = (u8 *)dm;
481 + const u8 *data = (const u8 *)dm;
482 unsigned long base_addr;
485 @@ -2091,13 +2091,14 @@ static __devinit void try_init_dmi(struct dmi_ipmi_data *ipmi_data)
487 static void __devinit dmi_find_bmc(void)
489 - struct dmi_device *dev = NULL;
490 + const struct dmi_device *dev = NULL;
491 struct dmi_ipmi_data data;
494 while ((dev = dmi_find_device(DMI_DEV_TYPE_IPMI, NULL, dev))) {
495 memset(&data, 0, sizeof(data));
496 - rv = decode_dmi((struct dmi_header *) dev->device_data, &data);
497 + rv = decode_dmi((const struct dmi_header *) dev->device_data,
502 diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
503 index f7318b3..0cdadea 100644
504 --- a/drivers/firmware/dmi_scan.c
505 +++ b/drivers/firmware/dmi_scan.c
507 #include <linux/slab.h>
510 -static char * __init dmi_string(struct dmi_header *dm, u8 s)
511 +static char * __init dmi_string(const struct dmi_header *dm, u8 s)
513 - u8 *bp = ((u8 *) dm) + dm->length;
514 + const u8 *bp = ((u8 *) dm) + dm->length;
518 @@ -37,7 +37,7 @@ static char * __init dmi_string(struct dmi_header *dm, u8 s)
519 * pointing to completely the wrong place for example
521 static int __init dmi_table(u32 base, int len, int num,
522 - void (*decode)(struct dmi_header *))
523 + void (*decode)(const struct dmi_header *))
527 @@ -53,7 +53,8 @@ static int __init dmi_table(u32 base, int len, int num,
528 * OR we run off the end of the table (also happens)
530 while ((i < num) && (data - buf + sizeof(struct dmi_header)) <= len) {
531 - struct dmi_header *dm = (struct dmi_header *)data;
532 + const struct dmi_header *dm = (const struct dmi_header *)data;
535 * We want to know the total length (formated area and strings)
536 * before decoding to make sure we won't run off the table in
537 @@ -71,7 +72,7 @@ static int __init dmi_table(u32 base, int len, int num,
541 -static int __init dmi_checksum(u8 *buf)
542 +static int __init dmi_checksum(const u8 *buf)
546 @@ -89,9 +90,10 @@ int dmi_available;
550 -static void __init dmi_save_ident(struct dmi_header *dm, int slot, int string)
551 +static void __init dmi_save_ident(const struct dmi_header *dm, int slot, int string)
553 - char *p, *d = (char*) dm;
554 + const char *d = (const char*) dm;
559 @@ -103,9 +105,9 @@ static void __init dmi_save_ident(struct dmi_header *dm, int slot, int string)
563 -static void __init dmi_save_uuid(struct dmi_header *dm, int slot, int index)
564 +static void __init dmi_save_uuid(const struct dmi_header *dm, int slot, int index)
566 - u8 *d = (u8*) dm + index;
567 + const u8 *d = (u8*) dm + index;
569 int is_ff = 1, is_00 = 1, i;
571 @@ -132,9 +134,9 @@ static void __init dmi_save_uuid(struct dmi_header *dm, int slot, int index)
575 -static void __init dmi_save_type(struct dmi_header *dm, int slot, int index)
576 +static void __init dmi_save_type(const struct dmi_header *dm, int slot, int index)
578 - u8 *d = (u8*) dm + index;
579 + const u8 *d = (u8*) dm + index;
583 @@ -148,13 +150,13 @@ static void __init dmi_save_type(struct dmi_header *dm, int slot, int index)
587 -static void __init dmi_save_devices(struct dmi_header *dm)
588 +static void __init dmi_save_devices(const struct dmi_header *dm)
590 int i, count = (dm->length - sizeof(struct dmi_header)) / 2;
591 struct dmi_device *dev;
593 for (i = 0; i < count; i++) {
594 - char *d = (char *)(dm + 1) + (i * 2);
595 + const char *d = (char *)(dm + 1) + (i * 2);
597 /* Skip disabled device */
598 if ((*d & 0x80) == 0)
599 @@ -173,7 +175,7 @@ static void __init dmi_save_devices(struct dmi_header *dm)
603 -static void __init dmi_save_oem_strings_devices(struct dmi_header *dm)
604 +static void __init dmi_save_oem_strings_devices(const struct dmi_header *dm)
606 int i, count = *(u8 *)(dm + 1);
607 struct dmi_device *dev;
608 @@ -194,7 +196,7 @@ static void __init dmi_save_oem_strings_devices(struct dmi_header *dm)
612 -static void __init dmi_save_ipmi_device(struct dmi_header *dm)
613 +static void __init dmi_save_ipmi_device(const struct dmi_header *dm)
615 struct dmi_device *dev;
617 @@ -225,7 +227,7 @@ static void __init dmi_save_ipmi_device(struct dmi_header *dm)
618 * and machine entries. For 2.5 we should pull the smbus controller info
621 -static void __init dmi_decode(struct dmi_header *dm)
622 +static void __init dmi_decode(const struct dmi_header *dm)
625 case 0: /* BIOS Information */
626 @@ -265,9 +267,10 @@ static void __init dmi_decode(struct dmi_header *dm)
630 -static int __init dmi_present(char __iomem *p)
631 +static int __init dmi_present(const char __iomem *p)
635 memcpy_fromio(buf, p, 15);
636 if ((memcmp(buf, "_DMI_", 5) == 0) && dmi_checksum(buf)) {
637 u16 num = (buf[13] << 8) | buf[12];
638 @@ -348,10 +351,10 @@ void __init dmi_scan_machine(void)
639 * returns non zero or we hit the end. Callback function is called for
640 * each successful match. Returns the number of matches.
642 -int dmi_check_system(struct dmi_system_id *list)
643 +int dmi_check_system(const struct dmi_system_id *list)
646 - struct dmi_system_id *d = list;
647 + const struct dmi_system_id *d = list;
650 for (i = 0; i < ARRAY_SIZE(d->matches); i++) {
651 @@ -380,7 +383,7 @@ EXPORT_SYMBOL(dmi_check_system);
652 * Returns one DMI data value, can be used to perform
653 * complex DMI data checks.
655 -char *dmi_get_system_info(int field)
656 +const char *dmi_get_system_info(int field)
658 return dmi_ident[field];
660 @@ -391,7 +394,7 @@ EXPORT_SYMBOL(dmi_get_system_info);
661 * dmi_name_in_vendors - Check if string is anywhere in the DMI vendor information.
662 * @str: Case sensitive Name
664 -int dmi_name_in_vendors(char *str)
665 +int dmi_name_in_vendors(const char *str)
667 static int fields[] = { DMI_BIOS_VENDOR, DMI_BIOS_VERSION, DMI_SYS_VENDOR,
668 DMI_PRODUCT_NAME, DMI_PRODUCT_VERSION, DMI_BOARD_VENDOR,
669 @@ -418,13 +421,15 @@ EXPORT_SYMBOL(dmi_name_in_vendors);
670 * A new search is initiated by passing %NULL as the @from argument.
671 * If @from is not %NULL, searches continue from next device.
673 -struct dmi_device * dmi_find_device(int type, const char *name,
674 - struct dmi_device *from)
675 +const struct dmi_device * dmi_find_device(int type, const char *name,
676 + const struct dmi_device *from)
678 - struct list_head *d, *head = from ? &from->list : &dmi_devices;
679 + const struct list_head *head = from ? &from->list : &dmi_devices;
680 + struct list_head *d;
682 for(d = head->next; d != &dmi_devices; d = d->next) {
683 - struct dmi_device *dev = list_entry(d, struct dmi_device, list);
684 + const struct dmi_device *dev =
685 + list_entry(d, struct dmi_device, list);
687 if (((type == DMI_DEV_TYPE_ANY) || (dev->type == type)) &&
688 ((name == NULL) || (strcmp(dev->name, name) == 0)))
689 @@ -444,7 +449,7 @@ EXPORT_SYMBOL(dmi_find_device);
690 int dmi_get_year(int field)
693 - char *s = dmi_get_system_info(field);
694 + const char *s = dmi_get_system_info(field);
698 diff --git a/drivers/hwmon/abituguru.c b/drivers/hwmon/abituguru.c
699 index d575ee9..2317f4b 100644
700 --- a/drivers/hwmon/abituguru.c
701 +++ b/drivers/hwmon/abituguru.c
702 @@ -1449,7 +1449,7 @@ static int __init abituguru_init(void)
703 struct resource res = { .flags = IORESOURCE_IO };
706 - char *board_vendor = dmi_get_system_info(DMI_BOARD_VENDOR);
707 + const char *board_vendor = dmi_get_system_info(DMI_BOARD_VENDOR);
709 /* safety check, refuse to load on non Abit motherboards */
710 if (!force && (!board_vendor ||
711 diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
712 index 941729a..56213b7 100644
713 --- a/drivers/hwmon/applesmc.c
714 +++ b/drivers/hwmon/applesmc.c
715 @@ -1071,7 +1071,7 @@ static const struct attribute_group temperature_attributes_group =
717 * applesmc_dmi_match - found a match. return one, short-circuiting the hunt.
719 -static int applesmc_dmi_match(struct dmi_system_id *id)
720 +static int applesmc_dmi_match(const struct dmi_system_id *id)
723 struct dmi_match_data* dmi_data = id->driver_data;
724 diff --git a/drivers/hwmon/hdaps.c b/drivers/hwmon/hdaps.c
725 index e0cf5e6..a7c6d40 100644
726 --- a/drivers/hwmon/hdaps.c
727 +++ b/drivers/hwmon/hdaps.c
728 @@ -480,14 +480,14 @@ static struct attribute_group hdaps_attribute_group = {
731 /* hdaps_dmi_match - found a match. return one, short-circuiting the hunt. */
732 -static int __init hdaps_dmi_match(struct dmi_system_id *id)
733 +static int __init hdaps_dmi_match(const struct dmi_system_id *id)
735 printk(KERN_INFO "hdaps: %s detected.\n", id->ident);
739 /* hdaps_dmi_match_invert - found an inverted match. */
740 -static int __init hdaps_dmi_match_invert(struct dmi_system_id *id)
741 +static int __init hdaps_dmi_match_invert(const struct dmi_system_id *id)
744 printk(KERN_INFO "hdaps: inverting axis readings.\n");
745 diff --git a/drivers/ide/pci/alim15x3.c b/drivers/ide/pci/alim15x3.c
746 index 11ecb61..20ebe3b 100644
747 --- a/drivers/ide/pci/alim15x3.c
748 +++ b/drivers/ide/pci/alim15x3.c
749 @@ -588,7 +588,7 @@ out:
750 * Cable special cases
753 -static struct dmi_system_id cable_dmi_table[] = {
754 +static const struct dmi_system_id cable_dmi_table[] = {
756 .ident = "HP Pavilion N5430",
758 diff --git a/drivers/ide/pci/via82cxxx.c b/drivers/ide/pci/via82cxxx.c
759 index a7be779..c10203a 100644
760 --- a/drivers/ide/pci/via82cxxx.c
761 +++ b/drivers/ide/pci/via82cxxx.c
762 @@ -419,7 +419,7 @@ static unsigned int __devinit init_chipset_via82cxxx(struct pci_dev *dev, const
763 * Cable special cases
766 -static struct dmi_system_id cable_dmi_table[] = {
767 +static const struct dmi_system_id cable_dmi_table[] = {
769 .ident = "Acer Ferrari 3400",
771 diff --git a/drivers/input/misc/wistron_btns.c b/drivers/input/misc/wistron_btns.c
772 index 60121f1..b438d99 100644
773 --- a/drivers/input/misc/wistron_btns.c
774 +++ b/drivers/input/misc/wistron_btns.c
775 @@ -247,7 +247,7 @@ static int have_wifi;
776 static int have_bluetooth;
777 static int have_leds;
779 -static int __init dmi_matched(struct dmi_system_id *dmi)
780 +static int __init dmi_matched(const struct dmi_system_id *dmi)
782 const struct key_entry *key;
784 diff --git a/drivers/input/mouse/lifebook.c b/drivers/input/mouse/lifebook.c
785 index 91109b4..608674d 100644
786 --- a/drivers/input/mouse/lifebook.c
787 +++ b/drivers/input/mouse/lifebook.c
788 @@ -27,7 +27,7 @@ struct lifebook_data {
790 static const char *desired_serio_phys;
792 -static int lifebook_set_serio_phys(struct dmi_system_id *d)
793 +static int lifebook_set_serio_phys(const struct dmi_system_id *d)
795 desired_serio_phys = d->driver_data;
797 @@ -35,13 +35,13 @@ static int lifebook_set_serio_phys(struct dmi_system_id *d)
799 static unsigned char lifebook_use_6byte_proto;
801 -static int lifebook_set_6byte_proto(struct dmi_system_id *d)
802 +static int lifebook_set_6byte_proto(const struct dmi_system_id *d)
804 lifebook_use_6byte_proto = 1;
808 -static struct dmi_system_id lifebook_dmi_table[] = {
809 +static const struct dmi_system_id lifebook_dmi_table[] = {
811 .ident = "FLORA-ie 55mi",
813 diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
814 index 666ad3a..d349c4a 100644
815 --- a/drivers/input/mouse/synaptics.c
816 +++ b/drivers/input/mouse/synaptics.c
817 @@ -602,7 +602,7 @@ static int synaptics_reconnect(struct psmouse *psmouse)
819 #if defined(__i386__)
820 #include <linux/dmi.h>
821 -static struct dmi_system_id toshiba_dmi_table[] = {
822 +static const struct dmi_system_id toshiba_dmi_table[] = {
824 .ident = "Toshiba Satellite",
826 diff --git a/drivers/misc/msi-laptop.c b/drivers/misc/msi-laptop.c
827 index 349be93..83679c7 100644
828 --- a/drivers/misc/msi-laptop.c
829 +++ b/drivers/misc/msi-laptop.c
830 @@ -283,7 +283,7 @@ static struct platform_device *msipf_device;
834 -static int dmi_check_cb(struct dmi_system_id *id)
835 +static int dmi_check_cb(const struct dmi_system_id *id)
837 printk("msi-laptop: Identified laptop model '%s'.\n", id->ident);
839 diff --git a/drivers/misc/sony-laptop.c b/drivers/misc/sony-laptop.c
840 index d38ddce..e73a71f 100644
841 --- a/drivers/misc/sony-laptop.c
842 +++ b/drivers/misc/sony-laptop.c
843 @@ -807,7 +807,7 @@ static struct sony_nc_event *sony_nc_events;
844 /* Vaio C* --maybe also FE*, N* and AR* ?-- special init sequence
847 -static int sony_nc_C_enable(struct dmi_system_id *id)
848 +static int sony_nc_C_enable(const struct dmi_system_id *id)
852 @@ -845,7 +845,7 @@ static struct sony_nc_event sony_C_events[] = {
855 /* SNC-only model map */
856 -static struct dmi_system_id sony_nc_ids[] = {
857 +static const struct dmi_system_id sony_nc_ids[] = {
859 .ident = "Sony Vaio FE Series",
860 .callback = sony_nc_C_enable,
861 diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
862 index 0222bba..6c0b2f0 100644
863 --- a/drivers/misc/thinkpad_acpi.c
864 +++ b/drivers/misc/thinkpad_acpi.c
865 @@ -4448,7 +4448,7 @@ static void ibm_exit(struct ibm_struct *ibm)
867 static void __init get_thinkpad_model_data(struct thinkpad_id_data *tp)
869 - struct dmi_device *dev = NULL;
870 + const struct dmi_device *dev = NULL;
871 char ec_fw_string[18];
874 diff --git a/drivers/pnp/pnpbios/core.c b/drivers/pnp/pnpbios/core.c
875 index 0691f47..4e9fd37 100644
876 --- a/drivers/pnp/pnpbios/core.c
877 +++ b/drivers/pnp/pnpbios/core.c
878 @@ -500,7 +500,7 @@ static int __init pnpbios_probe_system(void)
882 -static int __init exploding_pnp_bios(struct dmi_system_id *d)
883 +static int __init exploding_pnp_bios(const struct dmi_system_id *d)
885 printk(KERN_WARNING "%s detected. Disabling PnPBIOS\n", d->ident);
887 diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c
888 index 805e5fc..4db17f7 100644
889 --- a/drivers/usb/host/uhci-hcd.c
890 +++ b/drivers/usb/host/uhci-hcd.c
891 @@ -237,7 +237,7 @@ static int resume_detect_interrupts_are_broken(struct uhci_hcd *uhci)
892 static int remote_wakeup_is_broken(struct uhci_hcd *uhci)
896 + const char *sys_info;
897 static char bad_Asus_board[] = "A7V8X";
899 /* One of Asus's motherboards has a bug which causes it to
900 diff --git a/drivers/video/imacfb.c b/drivers/video/imacfb.c
901 index 18ea4a5..6455fd2 100644
902 --- a/drivers/video/imacfb.c
903 +++ b/drivers/video/imacfb.c
904 @@ -58,7 +58,7 @@ static int model = M_UNKNOWN;
905 static int manual_height;
906 static int manual_width;
908 -static int set_system(struct dmi_system_id *id)
909 +static int set_system(const struct dmi_system_id *id)
911 printk(KERN_INFO "imacfb: %s detected - set system to %ld\n",
912 id->ident, (long)id->driver_data);
913 diff --git a/include/linux/dmi.h b/include/linux/dmi.h
914 index b8ac7b0..00fc7a9 100644
915 --- a/include/linux/dmi.h
916 +++ b/include/linux/dmi.h
917 @@ -54,7 +54,7 @@ struct dmi_strmatch {
920 struct dmi_system_id {
921 - int (*callback)(struct dmi_system_id *);
922 + int (*callback)(const struct dmi_system_id *);
924 struct dmi_strmatch matches[4];
926 @@ -71,22 +71,22 @@ struct dmi_device {
930 -extern int dmi_check_system(struct dmi_system_id *list);
931 -extern char * dmi_get_system_info(int field);
932 -extern struct dmi_device * dmi_find_device(int type, const char *name,
933 - struct dmi_device *from);
934 +extern int dmi_check_system(const struct dmi_system_id *list);
935 +extern const char * dmi_get_system_info(int field);
936 +extern const struct dmi_device * dmi_find_device(int type, const char *name,
937 + const struct dmi_device *from);
938 extern void dmi_scan_machine(void);
939 extern int dmi_get_year(int field);
940 -extern int dmi_name_in_vendors(char *str);
941 +extern int dmi_name_in_vendors(const char *str);
945 -static inline int dmi_check_system(struct dmi_system_id *list) { return 0; }
946 -static inline char * dmi_get_system_info(int field) { return NULL; }
947 -static inline struct dmi_device * dmi_find_device(int type, const char *name,
948 - struct dmi_device *from) { return NULL; }
949 +static inline int dmi_check_system(const struct dmi_system_id *list) { return 0; }
950 +static inline const char * dmi_get_system_info(int field) { return NULL; }
951 +static inline const struct dmi_device * dmi_find_device(int type, const char *name,
952 + const struct dmi_device *from) { return NULL; }
953 static inline int dmi_get_year(int year) { return 0; }
954 -static inline int dmi_name_in_vendors(char *s) { return 0; }
955 +static inline int dmi_name_in_vendors(const char *s) { return 0; }