diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-27 15:25:47 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-27 15:25:47 -0500 |
commit | 0ca7ffb356063c5ece847687da457dfe748612a2 (patch) | |
tree | f7858236ba482814c8cacf45447a3f96548a1688 | |
parent | 30acd906b02470e7eb346401de966a33864d9af4 (diff) | |
parent | 423a8155facf23719078ff63911c1e85ba40970b (diff) |
Merge branch 'kbuild' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild
Pull kbuild changes from Michal Marek:
- Alias generation in modpost is cross-compile safe.
- kernel/timeconst.h is now generated using a bc script instead of
perl.
- scripts/link-vmlinux.sh now works with an alternative
$KCONFIG_CONFIG.
- destination-y for exported headers is supported in Kbuild files
again.
- depmod is called with -P $CONFIG_SYMBOL_PREFIX on architectures that
need it.
- CONFIG_DEBUG_INFO_REDUCED disables var-tracking
- scripts/setlocalversion works with too much translated locales ;)
* 'kbuild' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild:
kbuild: Fix reading of .config in link-vmlinux.sh
kbuild: Unset language specific variables in setlocalversion script
Kbuild: Disable var tracking with CONFIG_DEBUG_INFO_REDUCED
depmod: pass -P $CONFIG_SYMBOL_PREFIX
kbuild: Fix destination-y for installed headers
scripts/link-vmlinux.sh: source variables from KCONFIG_CONFIG
kernel: Replace timeconst.pl with a bc script
mod/file2alias: make modalias generation safe for cross compiling
-rw-r--r-- | Makefile | 6 | ||||
-rw-r--r-- | include/linux/mod_devicetable.h | 58 | ||||
-rw-r--r-- | kernel/Makefile | 16 | ||||
-rw-r--r-- | kernel/timeconst.bc | 108 | ||||
-rw-r--r-- | kernel/timeconst.pl | 376 | ||||
-rw-r--r-- | scripts/Makefile.headersinst | 6 | ||||
-rw-r--r-- | scripts/Makefile.modpost | 7 | ||||
-rwxr-xr-x | scripts/depmod.sh | 26 | ||||
-rw-r--r-- | scripts/link-vmlinux.sh | 9 | ||||
-rw-r--r-- | scripts/mod/.gitignore | 1 | ||||
-rw-r--r-- | scripts/mod/Makefile | 35 | ||||
-rw-r--r-- | scripts/mod/devicetable-offsets.c | 178 | ||||
-rw-r--r-- | scripts/mod/file2alias.c | 674 | ||||
-rw-r--r-- | scripts/mod/modpost.c | 5 | ||||
-rwxr-xr-x | scripts/setlocalversion | 2 |
15 files changed, 749 insertions, 758 deletions
@@ -192,7 +192,6 @@ SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \ | |||
192 | # "make" in the configured kernel build directory always uses that. | 192 | # "make" in the configured kernel build directory always uses that. |
193 | # Default value for CROSS_COMPILE is not to prefix executables | 193 | # Default value for CROSS_COMPILE is not to prefix executables |
194 | # Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile | 194 | # Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile |
195 | export KBUILD_BUILDHOST := $(SUBARCH) | ||
196 | ARCH ?= $(SUBARCH) | 195 | ARCH ?= $(SUBARCH) |
197 | CROSS_COMPILE ?= $(CONFIG_CROSS_COMPILE:"%"=%) | 196 | CROSS_COMPILE ?= $(CONFIG_CROSS_COMPILE:"%"=%) |
198 | 197 | ||
@@ -620,7 +619,8 @@ KBUILD_AFLAGS += -gdwarf-2 | |||
620 | endif | 619 | endif |
621 | 620 | ||
622 | ifdef CONFIG_DEBUG_INFO_REDUCED | 621 | ifdef CONFIG_DEBUG_INFO_REDUCED |
623 | KBUILD_CFLAGS += $(call cc-option, -femit-struct-debug-baseonly) | 622 | KBUILD_CFLAGS += $(call cc-option, -femit-struct-debug-baseonly) \ |
623 | $(call cc-option,-fno-var-tracking) | ||
624 | endif | 624 | endif |
625 | 625 | ||
626 | ifdef CONFIG_FUNCTION_TRACER | 626 | ifdef CONFIG_FUNCTION_TRACER |
@@ -1398,7 +1398,7 @@ quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files)) | |||
1398 | # Run depmod only if we have System.map and depmod is executable | 1398 | # Run depmod only if we have System.map and depmod is executable |
1399 | quiet_cmd_depmod = DEPMOD $(KERNELRELEASE) | 1399 | quiet_cmd_depmod = DEPMOD $(KERNELRELEASE) |
1400 | cmd_depmod = $(CONFIG_SHELL) $(srctree)/scripts/depmod.sh $(DEPMOD) \ | 1400 | cmd_depmod = $(CONFIG_SHELL) $(srctree)/scripts/depmod.sh $(DEPMOD) \ |
1401 | $(KERNELRELEASE) | 1401 | $(KERNELRELEASE) "$(patsubst "%",%,$(CONFIG_SYMBOL_PREFIX))" |
1402 | 1402 | ||
1403 | # Create temporary dir for module support files | 1403 | # Create temporary dir for module support files |
1404 | # clean it up only when building all modules | 1404 | # clean it up only when building all modules |
diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h index fed3def62818..779cf7c4a3d1 100644 --- a/include/linux/mod_devicetable.h +++ b/include/linux/mod_devicetable.h | |||
@@ -33,8 +33,7 @@ struct ieee1394_device_id { | |||
33 | __u32 model_id; | 33 | __u32 model_id; |
34 | __u32 specifier_id; | 34 | __u32 specifier_id; |
35 | __u32 version; | 35 | __u32 version; |
36 | kernel_ulong_t driver_data | 36 | kernel_ulong_t driver_data; |
37 | __attribute__((aligned(sizeof(kernel_ulong_t)))); | ||
38 | }; | 37 | }; |
39 | 38 | ||
40 | 39 | ||
@@ -148,8 +147,7 @@ struct hid_device_id { | |||
148 | __u16 group; | 147 | __u16 group; |
149 | __u32 vendor; | 148 | __u32 vendor; |
150 | __u32 product; | 149 | __u32 product; |
151 | kernel_ulong_t driver_data | 150 | kernel_ulong_t driver_data; |
152 | __attribute__((aligned(sizeof(kernel_ulong_t)))); | ||
153 | }; | 151 | }; |
154 | 152 | ||
155 | /* s390 CCW devices */ | 153 | /* s390 CCW devices */ |
@@ -173,8 +171,6 @@ struct ccw_device_id { | |||
173 | struct ap_device_id { | 171 | struct ap_device_id { |
174 | __u16 match_flags; /* which fields to match against */ | 172 | __u16 match_flags; /* which fields to match against */ |
175 | __u8 dev_type; /* device type */ | 173 | __u8 dev_type; /* device type */ |
176 | __u8 pad1; | ||
177 | __u32 pad2; | ||
178 | kernel_ulong_t driver_info; | 174 | kernel_ulong_t driver_info; |
179 | }; | 175 | }; |
180 | 176 | ||
@@ -184,13 +180,10 @@ struct ap_device_id { | |||
184 | struct css_device_id { | 180 | struct css_device_id { |
185 | __u8 match_flags; | 181 | __u8 match_flags; |
186 | __u8 type; /* subchannel type */ | 182 | __u8 type; /* subchannel type */ |
187 | __u16 pad2; | ||
188 | __u32 pad3; | ||
189 | kernel_ulong_t driver_data; | 183 | kernel_ulong_t driver_data; |
190 | }; | 184 | }; |
191 | 185 | ||
192 | #define ACPI_ID_LEN 16 /* only 9 bytes needed here, 16 bytes are used */ | 186 | #define ACPI_ID_LEN 9 |
193 | /* to workaround crosscompile issues */ | ||
194 | 187 | ||
195 | struct acpi_device_id { | 188 | struct acpi_device_id { |
196 | __u8 id[ACPI_ID_LEN]; | 189 | __u8 id[ACPI_ID_LEN]; |
@@ -231,11 +224,7 @@ struct of_device_id | |||
231 | char name[32]; | 224 | char name[32]; |
232 | char type[32]; | 225 | char type[32]; |
233 | char compatible[128]; | 226 | char compatible[128]; |
234 | #ifdef __KERNEL__ | ||
235 | const void *data; | 227 | const void *data; |
236 | #else | ||
237 | kernel_ulong_t data; | ||
238 | #endif | ||
239 | }; | 228 | }; |
240 | 229 | ||
241 | /* VIO */ | 230 | /* VIO */ |
@@ -260,24 +249,14 @@ struct pcmcia_device_id { | |||
260 | /* for pseudo multi-function devices */ | 249 | /* for pseudo multi-function devices */ |
261 | __u8 device_no; | 250 | __u8 device_no; |
262 | 251 | ||
263 | __u32 prod_id_hash[4] | 252 | __u32 prod_id_hash[4]; |
264 | __attribute__((aligned(sizeof(__u32)))); | ||
265 | 253 | ||
266 | /* not matched against in kernelspace*/ | 254 | /* not matched against in kernelspace*/ |
267 | #ifdef __KERNEL__ | ||
268 | const char * prod_id[4]; | 255 | const char * prod_id[4]; |
269 | #else | ||
270 | kernel_ulong_t prod_id[4] | ||
271 | __attribute__((aligned(sizeof(kernel_ulong_t)))); | ||
272 | #endif | ||
273 | 256 | ||
274 | /* not matched against */ | 257 | /* not matched against */ |
275 | kernel_ulong_t driver_info; | 258 | kernel_ulong_t driver_info; |
276 | #ifdef __KERNEL__ | ||
277 | char * cisfile; | 259 | char * cisfile; |
278 | #else | ||
279 | kernel_ulong_t cisfile; | ||
280 | #endif | ||
281 | }; | 260 | }; |
282 | 261 | ||
283 | #define PCMCIA_DEV_ID_MATCH_MANF_ID 0x0001 | 262 | #define PCMCIA_DEV_ID_MATCH_MANF_ID 0x0001 |
@@ -373,8 +352,7 @@ struct sdio_device_id { | |||
373 | __u8 class; /* Standard interface or SDIO_ANY_ID */ | 352 | __u8 class; /* Standard interface or SDIO_ANY_ID */ |
374 | __u16 vendor; /* Vendor or SDIO_ANY_ID */ | 353 | __u16 vendor; /* Vendor or SDIO_ANY_ID */ |
375 | __u16 device; /* Device ID or SDIO_ANY_ID */ | 354 | __u16 device; /* Device ID or SDIO_ANY_ID */ |
376 | kernel_ulong_t driver_data /* Data private to the driver */ | 355 | kernel_ulong_t driver_data; /* Data private to the driver */ |
377 | __attribute__((aligned(sizeof(kernel_ulong_t)))); | ||
378 | }; | 356 | }; |
379 | 357 | ||
380 | /* SSB core, see drivers/ssb/ */ | 358 | /* SSB core, see drivers/ssb/ */ |
@@ -420,8 +398,7 @@ struct virtio_device_id { | |||
420 | */ | 398 | */ |
421 | struct hv_vmbus_device_id { | 399 | struct hv_vmbus_device_id { |
422 | __u8 guid[16]; | 400 | __u8 guid[16]; |
423 | kernel_ulong_t driver_data /* Data private to the driver */ | 401 | kernel_ulong_t driver_data; /* Data private to the driver */ |
424 | __attribute__((aligned(sizeof(kernel_ulong_t)))); | ||
425 | }; | 402 | }; |
426 | 403 | ||
427 | /* rpmsg */ | 404 | /* rpmsg */ |
@@ -440,8 +417,7 @@ struct rpmsg_device_id { | |||
440 | 417 | ||
441 | struct i2c_device_id { | 418 | struct i2c_device_id { |
442 | char name[I2C_NAME_SIZE]; | 419 | char name[I2C_NAME_SIZE]; |
443 | kernel_ulong_t driver_data /* Data private to the driver */ | 420 | kernel_ulong_t driver_data; /* Data private to the driver */ |
444 | __attribute__((aligned(sizeof(kernel_ulong_t)))); | ||
445 | }; | 421 | }; |
446 | 422 | ||
447 | /* spi */ | 423 | /* spi */ |
@@ -451,8 +427,7 @@ struct i2c_device_id { | |||
451 | 427 | ||
452 | struct spi_device_id { | 428 | struct spi_device_id { |
453 | char name[SPI_NAME_SIZE]; | 429 | char name[SPI_NAME_SIZE]; |
454 | kernel_ulong_t driver_data /* Data private to the driver */ | 430 | kernel_ulong_t driver_data; /* Data private to the driver */ |
455 | __attribute__((aligned(sizeof(kernel_ulong_t)))); | ||
456 | }; | 431 | }; |
457 | 432 | ||
458 | /* dmi */ | 433 | /* dmi */ |
@@ -484,15 +459,6 @@ struct dmi_strmatch { | |||
484 | char substr[79]; | 459 | char substr[79]; |
485 | }; | 460 | }; |
486 | 461 | ||
487 | #ifndef __KERNEL__ | ||
488 | struct dmi_system_id { | ||
489 | kernel_ulong_t callback; | ||
490 | kernel_ulong_t ident; | ||
491 | struct dmi_strmatch matches[4]; | ||
492 | kernel_ulong_t driver_data | ||
493 | __attribute__((aligned(sizeof(kernel_ulong_t)))); | ||
494 | }; | ||
495 | #else | ||
496 | struct dmi_system_id { | 462 | struct dmi_system_id { |
497 | int (*callback)(const struct dmi_system_id *); | 463 | int (*callback)(const struct dmi_system_id *); |
498 | const char *ident; | 464 | const char *ident; |
@@ -506,7 +472,6 @@ struct dmi_system_id { | |||
506 | * error: storage size of '__mod_dmi_device_table' isn't known | 472 | * error: storage size of '__mod_dmi_device_table' isn't known |
507 | */ | 473 | */ |
508 | #define dmi_device_id dmi_system_id | 474 | #define dmi_device_id dmi_system_id |
509 | #endif | ||
510 | 475 | ||
511 | #define DMI_MATCH(a, b) { a, b } | 476 | #define DMI_MATCH(a, b) { a, b } |
512 | 477 | ||
@@ -515,8 +480,7 @@ struct dmi_system_id { | |||
515 | 480 | ||
516 | struct platform_device_id { | 481 | struct platform_device_id { |
517 | char name[PLATFORM_NAME_SIZE]; | 482 | char name[PLATFORM_NAME_SIZE]; |
518 | kernel_ulong_t driver_data | 483 | kernel_ulong_t driver_data; |
519 | __attribute__((aligned(sizeof(kernel_ulong_t)))); | ||
520 | }; | 484 | }; |
521 | 485 | ||
522 | #define MDIO_MODULE_PREFIX "mdio:" | 486 | #define MDIO_MODULE_PREFIX "mdio:" |
@@ -572,11 +536,7 @@ struct isapnp_device_id { | |||
572 | struct amba_id { | 536 | struct amba_id { |
573 | unsigned int id; | 537 | unsigned int id; |
574 | unsigned int mask; | 538 | unsigned int mask; |
575 | #ifndef __KERNEL__ | ||
576 | kernel_ulong_t data; | ||
577 | #else | ||
578 | void *data; | 539 | void *data; |
579 | #endif | ||
580 | }; | 540 | }; |
581 | 541 | ||
582 | /* | 542 | /* |
diff --git a/kernel/Makefile b/kernel/Makefile index eceac38f3c65..05949c0510c5 100644 --- a/kernel/Makefile +++ b/kernel/Makefile | |||
@@ -127,11 +127,19 @@ $(obj)/config_data.h: $(obj)/config_data.gz FORCE | |||
127 | 127 | ||
128 | $(obj)/time.o: $(obj)/timeconst.h | 128 | $(obj)/time.o: $(obj)/timeconst.h |
129 | 129 | ||
130 | quiet_cmd_timeconst = TIMEC $@ | 130 | quiet_cmd_hzfile = HZFILE $@ |
131 | cmd_timeconst = $(PERL) $< $(CONFIG_HZ) > $@ | 131 | cmd_hzfile = echo "hz=$(CONFIG_HZ)" > $@ |
132 | |||
133 | targets += hz.bc | ||
134 | $(obj)/hz.bc: $(objtree)/include/config/hz.h FORCE | ||
135 | $(call if_changed,hzfile) | ||
136 | |||
137 | quiet_cmd_bc = BC $@ | ||
138 | cmd_bc = bc -q $(filter-out FORCE,$^) > $@ | ||
139 | |||
132 | targets += timeconst.h | 140 | targets += timeconst.h |
133 | $(obj)/timeconst.h: $(src)/timeconst.pl FORCE | 141 | $(obj)/timeconst.h: $(obj)/hz.bc $(src)/timeconst.bc FORCE |
134 | $(call if_changed,timeconst) | 142 | $(call if_changed,bc) |
135 | 143 | ||
136 | ifeq ($(CONFIG_MODULE_SIG),y) | 144 | ifeq ($(CONFIG_MODULE_SIG),y) |
137 | # | 145 | # |
diff --git a/kernel/timeconst.bc b/kernel/timeconst.bc new file mode 100644 index 000000000000..511bdf2cafda --- /dev/null +++ b/kernel/timeconst.bc | |||
@@ -0,0 +1,108 @@ | |||
1 | scale=0 | ||
2 | |||
3 | define gcd(a,b) { | ||
4 | auto t; | ||
5 | while (b) { | ||
6 | t = b; | ||
7 | b = a % b; | ||
8 | a = t; | ||
9 | } | ||
10 | return a; | ||
11 | } | ||
12 | |||
13 | /* Division by reciprocal multiplication. */ | ||
14 | define fmul(b,n,d) { | ||
15 | return (2^b*n+d-1)/d; | ||
16 | } | ||
17 | |||
18 | /* Adjustment factor when a ceiling value is used. Use as: | ||
19 | (imul * n) + (fmulxx * n + fadjxx) >> xx) */ | ||
20 | define fadj(b,n,d) { | ||
21 | auto v; | ||
22 | d = d/gcd(n,d); | ||
23 | v = 2^b*(d-1)/d; | ||
24 | return v; | ||
25 | } | ||
26 | |||
27 | /* Compute the appropriate mul/adj values as well as a shift count, | ||
28 | which brings the mul value into the range 2^b-1 <= x < 2^b. Such | ||
29 | a shift value will be correct in the signed integer range and off | ||
30 | by at most one in the upper half of the unsigned range. */ | ||
31 | define fmuls(b,n,d) { | ||
32 | auto s, m; | ||
33 | for (s = 0; 1; s++) { | ||
34 | m = fmul(s,n,d); | ||
35 | if (m >= 2^(b-1)) | ||
36 | return s; | ||
37 | } | ||
38 | return 0; | ||
39 | } | ||
40 | |||
41 | define timeconst(hz) { | ||
42 | print "/* Automatically generated by kernel/timeconst.bc */\n" | ||
43 | print "/* Time conversion constants for HZ == ", hz, " */\n" | ||
44 | print "\n" | ||
45 | |||
46 | print "#ifndef KERNEL_TIMECONST_H\n" | ||
47 | print "#define KERNEL_TIMECONST_H\n\n" | ||
48 | |||
49 | print "#include <linux/param.h>\n" | ||
50 | print "#include <linux/types.h>\n\n" | ||
51 | |||
52 | print "#if HZ != ", hz, "\n" | ||
53 | print "#error \qkernel/timeconst.h has the wrong HZ value!\q\n" | ||
54 | print "#endif\n\n" | ||
55 | |||
56 | if (hz < 2) { | ||
57 | print "#error Totally bogus HZ value!\n" | ||
58 | } else { | ||
59 | s=fmuls(32,1000,hz) | ||
60 | obase=16 | ||
61 | print "#define HZ_TO_MSEC_MUL32\tU64_C(0x", fmul(s,1000,hz), ")\n" | ||
62 | print "#define HZ_TO_MSEC_ADJ32\tU64_C(0x", fadj(s,1000,hz), ")\n" | ||
63 | obase=10 | ||
64 | print "#define HZ_TO_MSEC_SHR32\t", s, "\n" | ||
65 | |||
66 | s=fmuls(32,hz,1000) | ||
67 | obase=16 | ||
68 | print "#define MSEC_TO_HZ_MUL32\tU64_C(0x", fmul(s,hz,1000), ")\n" | ||
69 | print "#define MSEC_TO_HZ_ADJ32\tU64_C(0x", fadj(s,hz,1000), ")\n" | ||
70 | obase=10 | ||
71 | print "#define MSEC_TO_HZ_SHR32\t", s, "\n" | ||
72 | |||
73 | obase=10 | ||
74 | cd=gcd(hz,1000) | ||
75 | print "#define HZ_TO_MSEC_NUM\t\t", 1000/cd, "\n" | ||
76 | print "#define HZ_TO_MSEC_DEN\t\t", hz/cd, "\n" | ||
77 | print "#define MSEC_TO_HZ_NUM\t\t", hz/cd, "\n" | ||
78 | print "#define MSEC_TO_HZ_DEN\t\t", 1000/cd, "\n" | ||
79 | print "\n" | ||
80 | |||
81 | s=fmuls(32,1000000,hz) | ||
82 | obase=16 | ||
83 | print "#define HZ_TO_USEC_MUL32\tU64_C(0x", fmul(s,1000000,hz), ")\n" | ||
84 | print "#define HZ_TO_USEC_ADJ32\tU64_C(0x", fadj(s,1000000,hz), ")\n" | ||
85 | obase=10 | ||
86 | print "#define HZ_TO_USEC_SHR32\t", s, "\n" | ||
87 | |||
88 | s=fmuls(32,hz,1000000) | ||
89 | obase=16 | ||
90 | print "#define USEC_TO_HZ_MUL32\tU64_C(0x", fmul(s,hz,1000000), ")\n" | ||
91 | print "#define USEC_TO_HZ_ADJ32\tU64_C(0x", fadj(s,hz,1000000), ")\n" | ||
92 | obase=10 | ||
93 | print "#define USEC_TO_HZ_SHR32\t", s, "\n" | ||
94 | |||
95 | obase=10 | ||
96 | cd=gcd(hz,1000000) | ||
97 | print "#define HZ_TO_USEC_NUM\t\t", 1000000/cd, "\n" | ||
98 | print "#define HZ_TO_USEC_DEN\t\t", hz/cd, "\n" | ||
99 | print "#define USEC_TO_HZ_NUM\t\t", hz/cd, "\n" | ||
100 | print "#define USEC_TO_HZ_DEN\t\t", 1000000/cd, "\n" | ||
101 | print "\n" | ||
102 | |||
103 | print "#endif /* KERNEL_TIMECONST_H */\n" | ||
104 | } | ||
105 | halt | ||
106 | } | ||
107 | |||
108 | timeconst(hz) | ||
diff --git a/kernel/timeconst.pl b/kernel/timeconst.pl deleted file mode 100644 index 3f42652a6a37..000000000000 --- a/kernel/timeconst.pl +++ /dev/null | |||
@@ -1,376 +0,0 @@ | |||
1 | #!/usr/bin/perl | ||
2 | # ----------------------------------------------------------------------- | ||
3 | # | ||
4 | # Copyright 2007-2008 rPath, Inc. - All Rights Reserved | ||
5 | # | ||
6 | # This file is part of the Linux kernel, and is made available under | ||
7 | # the terms of the GNU General Public License version 2 or (at your | ||
8 | # option) any later version; incorporated herein by reference. | ||
9 | # | ||
10 | # ----------------------------------------------------------------------- | ||
11 | # | ||
12 | |||
13 | # | ||
14 | # Usage: timeconst.pl HZ > timeconst.h | ||
15 | # | ||
16 | |||
17 | # Precomputed values for systems without Math::BigInt | ||
18 | # Generated by: | ||
19 | # timeconst.pl --can 24 32 48 64 100 122 128 200 250 256 300 512 1000 1024 1200 | ||
20 | %canned_values = ( | ||
21 | 24 => [ | ||
22 | '0xa6aaaaab','0x2aaaaaa',26, | ||
23 | 125,3, | ||
24 | '0xc49ba5e4','0x1fbe76c8b4',37, | ||
25 | 3,125, | ||
26 | '0xa2c2aaab','0xaaaa',16, | ||
27 | 125000,3, | ||
28 | '0xc9539b89','0x7fffbce4217d',47, | ||
29 | 3,125000, | ||
30 | ], 32 => [ | ||
31 | '0xfa000000','0x6000000',27, | ||
32 | 125,4, | ||
33 | '0x83126e98','0xfdf3b645a',36, | ||
34 | 4,125, | ||
35 | '0xf4240000','0x0',17, | ||
36 | 31250,1, | ||
37 | '0x8637bd06','0x3fff79c842fa',46, | ||
38 | 1,31250, | ||
39 | ], 48 => [ | ||
40 | '0xa6aaaaab','0x6aaaaaa',27, | ||
41 | 125,6, | ||
42 | '0xc49ba5e4','0xfdf3b645a',36, | ||
43 | 6,125, | ||
44 | '0xa2c2aaab','0x15555',17, | ||
45 | 62500,3, | ||
46 | '0xc9539b89','0x3fffbce4217d',46, | ||
47 | 3,62500, | ||
48 | ], 64 => [ | ||
49 | '0xfa000000','0xe000000',28, | ||
50 | 125,8, | ||
51 | '0x83126e98','0x7ef9db22d',35, | ||
52 | 8,125, | ||
53 | '0xf4240000','0x0',18, | ||
54 | 15625,1, | ||
55 | '0x8637bd06','0x1fff79c842fa',45, | ||
56 | 1,15625, | ||
57 | ], 100 => [ | ||
58 | '0xa0000000','0x0',28, | ||
59 | 10,1, | ||
60 | '0xcccccccd','0x733333333',35, | ||
61 | 1,10, | ||
62 | '0x9c400000','0x0',18, | ||
63 | 10000,1, | ||
64 | '0xd1b71759','0x1fff2e48e8a7',45, | ||
65 | 1,10000, | ||
66 | ], 122 => [ | ||
67 | '0x8325c53f','0xfbcda3a',28, | ||
68 | 500,61, | ||
69 | '0xf9db22d1','0x7fbe76c8b',35, | ||
70 | 61,500, | ||
71 | '0x8012e2a0','0x3ef36',18, | ||
72 | 500000,61, | ||
73 | '0xffda4053','0x1ffffbce4217',45, | ||
74 | 61,500000, | ||
75 | ], 128 => [ | ||
76 | '0xfa000000','0x1e000000',29, | ||
77 | 125,16, | ||
78 | '0x83126e98','0x3f7ced916',34, | ||
79 | 16,125, | ||
80 | '0xf4240000','0x40000',19, | ||
81 | 15625,2, | ||
82 | '0x8637bd06','0xfffbce4217d',44, | ||
83 | 2,15625, | ||
84 | ], 200 => [ | ||
85 | '0xa0000000','0x0',29, | ||
86 | 5,1, | ||
87 | '0xcccccccd','0x333333333',34, | ||
88 | 1,5, | ||
89 | '0x9c400000','0x0',19, | ||
90 | 5000,1, | ||
91 | '0xd1b71759','0xfff2e48e8a7',44, | ||
92 | 1,5000, | ||
93 | ], 250 => [ | ||
94 | '0x80000000','0x0',29, | ||
95 | 4,1, | ||
96 | '0x80000000','0x180000000',33, | ||
97 | 1,4, | ||
98 | '0xfa000000','0x0',20, | ||
99 | 4000,1, | ||
100 | '0x83126e98','0x7ff7ced9168',43, | ||
101 | 1,4000, | ||
102 | ], 256 => [ | ||
103 | '0xfa000000','0x3e000000',30, | ||
104 | 125,32, | ||
105 | '0x83126e98','0x1fbe76c8b',33, | ||
106 | 32,125, | ||
107 | '0xf4240000','0xc0000',20, | ||
108 | 15625,4, | ||
109 | '0x8637bd06','0x7ffde7210be',43, | ||
110 | 4,15625, | ||
111 | ], 300 => [ | ||
112 | '0xd5555556','0x2aaaaaaa',30, | ||
113 | 10,3, | ||
114 | '0x9999999a','0x1cccccccc',33, | ||
115 | 3,10, | ||
116 | '0xd0555556','0xaaaaa',20, | ||
117 | 10000,3, | ||
118 | '0x9d495183','0x7ffcb923a29',43, | ||
119 | 3,10000, | ||
120 | ], 512 => [ | ||
121 | '0xfa000000','0x7e000000',31, | ||
122 | 125,64, | ||
123 | '0x83126e98','0xfdf3b645',32, | ||
124 | 64,125, | ||
125 | '0xf4240000','0x1c0000',21, | ||
126 | 15625,8, | ||
127 | '0x8637bd06','0x3ffef39085f',42, | ||
128 | 8,15625, | ||
129 | ], 1000 => [ | ||
130 | '0x80000000','0x0',31, | ||
131 | 1,1, | ||
132 | '0x80000000','0x0',31, | ||
133 | 1,1, | ||
134 | '0xfa000000','0x0',22, | ||
135 | 1000,1, | ||
136 | '0x83126e98','0x1ff7ced9168',41, | ||
137 | 1,1000, | ||
138 | ], 1024 => [ | ||
139 | '0xfa000000','0xfe000000',32, | ||
140 | 125,128, | ||
141 | '0x83126e98','0x7ef9db22',31, | ||
142 | 128,125, | ||
143 | '0xf4240000','0x3c0000',22, | ||
144 | 15625,16, | ||
145 | '0x8637bd06','0x1fff79c842f',41, | ||
146 | 16,15625, | ||
147 | ], 1200 => [ | ||
148 | '0xd5555556','0xd5555555',32, | ||
149 | 5,6, | ||
150 | '0x9999999a','0x66666666',31, | ||
151 | 6,5, | ||
152 | '0xd0555556','0x2aaaaa',22, | ||
153 | 2500,3, | ||
154 | '0x9d495183','0x1ffcb923a29',41, | ||
155 | 3,2500, | ||
156 | ] | ||
157 | ); | ||
158 | |||
159 | $has_bigint = eval 'use Math::BigInt qw(bgcd); 1;'; | ||
160 | |||
161 | sub bint($) | ||
162 | { | ||
163 | my($x) = @_; | ||
164 | return Math::BigInt->new($x); | ||
165 | } | ||
166 | |||
167 | # | ||
168 | # Constants for division by reciprocal multiplication. | ||
169 | # (bits, numerator, denominator) | ||
170 | # | ||
171 | sub fmul($$$) | ||
172 | { | ||
173 | my ($b,$n,$d) = @_; | ||
174 | |||
175 | $n = bint($n); | ||
176 | $d = bint($d); | ||
177 | |||
178 | return scalar (($n << $b)+$d-bint(1))/$d; | ||
179 | } | ||
180 | |||
181 | sub fadj($$$) | ||
182 | { | ||
183 | my($b,$n,$d) = @_; | ||
184 | |||
185 | $n = bint($n); | ||
186 | $d = bint($d); | ||
187 | |||
188 | $d = $d/bgcd($n, $d); | ||
189 | return scalar (($d-bint(1)) << $b)/$d; | ||
190 | } | ||
191 | |||
192 | sub fmuls($$$) { | ||
193 | my($b,$n,$d) = @_; | ||
194 | my($s,$m); | ||
195 | my($thres) = bint(1) << ($b-1); | ||
196 | |||
197 | $n = bint($n); | ||
198 | $d = bint($d); | ||
199 | |||
200 | for ($s = 0; 1; $s++) { | ||
201 | $m = fmul($s,$n,$d); | ||
202 | return $s if ($m >= $thres); | ||
203 | } | ||
204 | return 0; | ||
205 | } | ||
206 | |||
207 | # Generate a hex value if the result fits in 64 bits; | ||
208 | # otherwise skip. | ||
209 | sub bignum_hex($) { | ||
210 | my($x) = @_; | ||
211 | my $s = $x->as_hex(); | ||
212 | |||
213 | return (length($s) > 18) ? undef : $s; | ||
214 | } | ||
215 | |||
216 | # Provides mul, adj, and shr factors for a specific | ||
217 | # (bit, time, hz) combination | ||
218 | sub muladj($$$) { | ||
219 | my($b, $t, $hz) = @_; | ||
220 | my $s = fmuls($b, $t, $hz); | ||
221 | my $m = fmul($s, $t, $hz); | ||
222 | my $a = fadj($s, $t, $hz); | ||
223 | return (bignum_hex($m), bignum_hex($a), $s); | ||
224 | } | ||
225 | |||
226 | # Provides numerator, denominator values | ||
227 | sub numden($$) { | ||
228 | my($n, $d) = @_; | ||
229 | my $g = bgcd($n, $d); | ||
230 | return ($n/$g, $d/$g); | ||
231 | } | ||
232 | |||
233 | # All values for a specific (time, hz) combo | ||
234 | sub conversions($$) { | ||
235 | my ($t, $hz) = @_; | ||
236 | my @val = (); | ||
237 | |||
238 | # HZ_TO_xx | ||
239 | push(@val, muladj(32, $t, $hz)); | ||
240 | push(@val, numden($t, $hz)); | ||
241 | |||
242 | # xx_TO_HZ | ||
243 | push(@val, muladj(32, $hz, $t)); | ||
244 | push(@val, numden($hz, $t)); | ||
245 | |||
246 | return @val; | ||
247 | } | ||
248 | |||
249 | sub compute_values($) { | ||
250 | my($hz) = @_; | ||
251 | my @val = (); | ||
252 | my $s, $m, $a, $g; | ||
253 | |||
254 | if (!$has_bigint) { | ||
255 | die "$0: HZ == $hz not canned and ". | ||
256 | "Math::BigInt not available\n"; | ||
257 | } | ||
258 | |||
259 | # MSEC conversions | ||
260 | push(@val, conversions(1000, $hz)); | ||
261 | |||
262 | # USEC conversions | ||
263 | push(@val, conversions(1000000, $hz)); | ||
264 | |||
265 | return @val; | ||
266 | } | ||
267 | |||
268 | sub outputval($$) | ||
269 | { | ||
270 | my($name, $val) = @_; | ||
271 | my $csuf; | ||
272 | |||
273 | if (defined($val)) { | ||
274 | if ($name !~ /SHR/) { | ||
275 | $val = "U64_C($val)"; | ||
276 | } | ||
277 | printf "#define %-23s %s\n", $name.$csuf, $val.$csuf; | ||
278 | } | ||
279 | } | ||
280 | |||
281 | sub output($@) | ||
282 | { | ||
283 | my($hz, @val) = @_; | ||
284 | my $pfx, $bit, $suf, $s, $m, $a; | ||
285 | |||
286 | print "/* Automatically generated by kernel/timeconst.pl */\n"; | ||
287 | print "/* Conversion constants for HZ == $hz */\n"; | ||
288 | print "\n"; | ||
289 | print "#ifndef KERNEL_TIMECONST_H\n"; | ||
290 | print "#define KERNEL_TIMECONST_H\n"; | ||
291 | print "\n"; | ||
292 | |||
293 | print "#include <linux/param.h>\n"; | ||
294 | print "#include <linux/types.h>\n"; | ||
295 | |||
296 | print "\n"; | ||
297 | print "#if HZ != $hz\n"; | ||
298 | print "#error \"kernel/timeconst.h has the wrong HZ value!\"\n"; | ||
299 | print "#endif\n"; | ||
300 | print "\n"; | ||
301 | |||
302 | foreach $pfx ('HZ_TO_MSEC','MSEC_TO_HZ', | ||
303 | 'HZ_TO_USEC','USEC_TO_HZ') { | ||
304 | foreach $bit (32) { | ||
305 | foreach $suf ('MUL', 'ADJ', 'SHR') { | ||
306 | outputval("${pfx}_$suf$bit", shift(@val)); | ||
307 | } | ||
308 | } | ||
309 | foreach $suf ('NUM', 'DEN') { | ||
310 | outputval("${pfx}_$suf", shift(@val)); | ||
311 | } | ||
312 | } | ||
313 | |||
314 | print "\n"; | ||
315 | print "#endif /* KERNEL_TIMECONST_H */\n"; | ||
316 | } | ||
317 | |||
318 | # Pretty-print Perl values | ||
319 | sub perlvals(@) { | ||
320 | my $v; | ||
321 | my @l = (); | ||
322 | |||
323 | foreach $v (@_) { | ||
324 | if (!defined($v)) { | ||
325 | push(@l, 'undef'); | ||
326 | } elsif ($v =~ /^0x/) { | ||
327 | push(@l, "\'".$v."\'"); | ||
328 | } else { | ||
329 | push(@l, $v.''); | ||
330 | } | ||
331 | } | ||
332 | return join(',', @l); | ||
333 | } | ||
334 | |||
335 | ($hz) = @ARGV; | ||
336 | |||
337 | # Use this to generate the %canned_values structure | ||
338 | if ($hz eq '--can') { | ||
339 | shift(@ARGV); | ||
340 | @hzlist = sort {$a <=> $b} (@ARGV); | ||
341 | |||
342 | print "# Precomputed values for systems without Math::BigInt\n"; | ||
343 | print "# Generated by:\n"; | ||
344 | print "# timeconst.pl --can ", join(' ', @hzlist), "\n"; | ||
345 | print "\%canned_values = (\n"; | ||
346 | my $pf = "\t"; | ||
347 | foreach $hz (@hzlist) { | ||
348 | my @values = compute_values($hz); | ||
349 | print "$pf$hz => [\n"; | ||
350 | while (scalar(@values)) { | ||
351 | my $bit; | ||
352 | foreach $bit (32) { | ||
353 | my $m = shift(@values); | ||
354 | my $a = shift(@values); | ||
355 | my $s = shift(@values); | ||
356 | print "\t\t", perlvals($m,$a,$s), ",\n"; | ||
357 | } | ||
358 | my $n = shift(@values); | ||
359 | my $d = shift(@values); | ||
360 | print "\t\t", perlvals($n,$d), ",\n"; | ||
361 | } | ||
362 | print "\t]"; | ||
363 | $pf = ', '; | ||
364 | } | ||
365 | print "\n);\n"; | ||
366 | } else { | ||
367 | $hz += 0; # Force to number | ||
368 | if ($hz < 1) { | ||
369 | die "Usage: $0 HZ\n"; | ||
370 | } | ||
371 | |||
372 | $cv = $canned_values{$hz}; | ||
373 | @val = defined($cv) ? @$cv : compute_values($hz); | ||
374 | output($hz, @val); | ||
375 | } | ||
376 | exit 0; | ||
diff --git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst index 06ba4a70bd4d..25f216a841d5 100644 --- a/scripts/Makefile.headersinst +++ b/scripts/Makefile.headersinst | |||
@@ -7,15 +7,15 @@ | |||
7 | # | 7 | # |
8 | # ========================================================================== | 8 | # ========================================================================== |
9 | 9 | ||
10 | # called may set destination dir (when installing to asm/) | ||
11 | _dst := $(or $(destination-y),$(dst),$(obj)) | ||
12 | |||
13 | # generated header directory | 10 | # generated header directory |
14 | gen := $(if $(gen),$(gen),$(subst include/,include/generated/,$(obj))) | 11 | gen := $(if $(gen),$(gen),$(subst include/,include/generated/,$(obj))) |
15 | 12 | ||
16 | kbuild-file := $(srctree)/$(obj)/Kbuild | 13 | kbuild-file := $(srctree)/$(obj)/Kbuild |
17 | include $(kbuild-file) | 14 | include $(kbuild-file) |
18 | 15 | ||
16 | # called may set destination dir (when installing to asm/) | ||
17 | _dst := $(or $(destination-y),$(dst),$(obj)) | ||
18 | |||
19 | old-kbuild-file := $(srctree)/$(subst uapi/,,$(obj))/Kbuild | 19 | old-kbuild-file := $(srctree)/$(subst uapi/,,$(obj))/Kbuild |
20 | ifneq ($(wildcard $(old-kbuild-file)),) | 20 | ifneq ($(wildcard $(old-kbuild-file)),) |
21 | include $(old-kbuild-file) | 21 | include $(old-kbuild-file) |
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index a1cb0222ebe6..cf82c832458f 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost | |||
@@ -66,10 +66,6 @@ modules := $(patsubst %.o,%.ko, $(wildcard $(__modules:.ko=.o))) | |||
66 | # Stop after building .o files if NOFINAL is set. Makes compile tests quicker | 66 | # Stop after building .o files if NOFINAL is set. Makes compile tests quicker |
67 | _modpost: $(if $(KBUILD_MODPOST_NOFINAL), $(modules:.ko:.o),$(modules)) | 67 | _modpost: $(if $(KBUILD_MODPOST_NOFINAL), $(modules:.ko:.o),$(modules)) |
68 | 68 | ||
69 | ifneq ($(KBUILD_BUILDHOST),$(ARCH)) | ||
70 | cross_build := 1 | ||
71 | endif | ||
72 | |||
73 | # Step 2), invoke modpost | 69 | # Step 2), invoke modpost |
74 | # Includes step 3,4 | 70 | # Includes step 3,4 |
75 | modpost = scripts/mod/modpost \ | 71 | modpost = scripts/mod/modpost \ |
@@ -80,8 +76,7 @@ modpost = scripts/mod/modpost \ | |||
80 | $(if $(KBUILD_EXTRA_SYMBOLS), $(patsubst %, -e %,$(KBUILD_EXTRA_SYMBOLS))) \ | 76 | $(if $(KBUILD_EXTRA_SYMBOLS), $(patsubst %, -e %,$(KBUILD_EXTRA_SYMBOLS))) \ |
81 | $(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \ | 77 | $(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \ |
82 | $(if $(CONFIG_DEBUG_SECTION_MISMATCH),,-S) \ | 78 | $(if $(CONFIG_DEBUG_SECTION_MISMATCH),,-S) \ |
83 | $(if $(KBUILD_EXTMOD)$(KBUILD_MODPOST_WARN),-w) \ | 79 | $(if $(KBUILD_EXTMOD)$(KBUILD_MODPOST_WARN),-w) |
84 | $(if $(cross_build),-c) | ||
85 | 80 | ||
86 | quiet_cmd_modpost = MODPOST $(words $(filter-out vmlinux FORCE, $^)) modules | 81 | quiet_cmd_modpost = MODPOST $(words $(filter-out vmlinux FORCE, $^)) modules |
87 | cmd_modpost = $(modpost) -s | 82 | cmd_modpost = $(modpost) -s |
diff --git a/scripts/depmod.sh b/scripts/depmod.sh index 2ae481703141..122599b1c13b 100755 --- a/scripts/depmod.sh +++ b/scripts/depmod.sh | |||
@@ -2,16 +2,36 @@ | |||
2 | # | 2 | # |
3 | # A depmod wrapper used by the toplevel Makefile | 3 | # A depmod wrapper used by the toplevel Makefile |
4 | 4 | ||
5 | if test $# -ne 2; then | 5 | if test $# -ne 3; then |
6 | echo "Usage: $0 /sbin/depmod <kernelrelease>" >&2 | 6 | echo "Usage: $0 /sbin/depmod <kernelrelease> <symbolprefix>" >&2 |
7 | exit 1 | 7 | exit 1 |
8 | fi | 8 | fi |
9 | DEPMOD=$1 | 9 | DEPMOD=$1 |
10 | KERNELRELEASE=$2 | 10 | KERNELRELEASE=$2 |
11 | SYMBOL_PREFIX=$3 | ||
11 | 12 | ||
12 | if ! test -r System.map -a -x "$DEPMOD"; then | 13 | if ! test -r System.map -a -x "$DEPMOD"; then |
13 | exit 0 | 14 | exit 0 |
14 | fi | 15 | fi |
16 | |||
17 | # older versions of depmod don't support -P <symbol-prefix> | ||
18 | # support was added in module-init-tools 3.13 | ||
19 | if test -n "$SYMBOL_PREFIX"; then | ||
20 | release=$("$DEPMOD" --version) | ||
21 | package=$(echo "$release" | cut -d' ' -f 1) | ||
22 | if test "$package" = "module-init-tools"; then | ||
23 | version=$(echo "$release" | cut -d' ' -f 2) | ||
24 | later=$(printf '%s\n' "$version" "3.13" | sort -V | tail -n 1) | ||
25 | if test "$later" != "$version"; then | ||
26 | # module-init-tools < 3.13, drop the symbol prefix | ||
27 | SYMBOL_PREFIX="" | ||
28 | fi | ||
29 | fi | ||
30 | if test -n "$SYMBOL_PREFIX"; then | ||
31 | SYMBOL_PREFIX="-P $SYMBOL_PREFIX" | ||
32 | fi | ||
33 | fi | ||
34 | |||
15 | # older versions of depmod require the version string to start with three | 35 | # older versions of depmod require the version string to start with three |
16 | # numbers, so we cheat with a symlink here | 36 | # numbers, so we cheat with a symlink here |
17 | depmod_hack_needed=true | 37 | depmod_hack_needed=true |
@@ -34,7 +54,7 @@ set -- -ae -F System.map | |||
34 | if test -n "$INSTALL_MOD_PATH"; then | 54 | if test -n "$INSTALL_MOD_PATH"; then |
35 | set -- "$@" -b "$INSTALL_MOD_PATH" | 55 | set -- "$@" -b "$INSTALL_MOD_PATH" |
36 | fi | 56 | fi |
37 | "$DEPMOD" "$@" "$KERNELRELEASE" | 57 | "$DEPMOD" "$@" "$KERNELRELEASE" $SYMBOL_PREFIX |
38 | ret=$? | 58 | ret=$? |
39 | 59 | ||
40 | if $depmod_hack_needed; then | 60 | if $depmod_hack_needed; then |
diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh index b3d907eb93a9..3d569d6022c2 100644 --- a/scripts/link-vmlinux.sh +++ b/scripts/link-vmlinux.sh | |||
@@ -132,7 +132,14 @@ if [ "$1" = "clean" ]; then | |||
132 | fi | 132 | fi |
133 | 133 | ||
134 | # We need access to CONFIG_ symbols | 134 | # We need access to CONFIG_ symbols |
135 | . ./.config | 135 | case "${KCONFIG_CONFIG}" in |
136 | */*) | ||
137 | . "${KCONFIG_CONFIG}" | ||
138 | ;; | ||
139 | *) | ||
140 | # Force using a file from the current directory | ||
141 | . "./${KCONFIG_CONFIG}" | ||
142 | esac | ||
136 | 143 | ||
137 | #link vmlinux.o | 144 | #link vmlinux.o |
138 | info LD vmlinux.o | 145 | info LD vmlinux.o |
diff --git a/scripts/mod/.gitignore b/scripts/mod/.gitignore index e9b7abe7b95b..33bae0df4de5 100644 --- a/scripts/mod/.gitignore +++ b/scripts/mod/.gitignore | |||
@@ -1,4 +1,5 @@ | |||
1 | elfconfig.h | 1 | elfconfig.h |
2 | mk_elfconfig | 2 | mk_elfconfig |
3 | modpost | 3 | modpost |
4 | devicetable-offsets.h | ||
4 | 5 | ||
diff --git a/scripts/mod/Makefile b/scripts/mod/Makefile index ff954f8168c1..9415b5663364 100644 --- a/scripts/mod/Makefile +++ b/scripts/mod/Makefile | |||
@@ -3,9 +3,44 @@ always := $(hostprogs-y) empty.o | |||
3 | 3 | ||
4 | modpost-objs := modpost.o file2alias.o sumversion.o | 4 | modpost-objs := modpost.o file2alias.o sumversion.o |
5 | 5 | ||
6 | devicetable-offsets-file := devicetable-offsets.h | ||
7 | |||
8 | define sed-y | ||
9 | "/^->/{s:->#\(.*\):/* \1 */:; \ | ||
10 | s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \ | ||
11 | s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \ | ||
12 | s:->::; p;}" | ||
13 | endef | ||
14 | |||
15 | quiet_cmd_offsets = GEN $@ | ||
16 | define cmd_offsets | ||
17 | (set -e; \ | ||
18 | echo "#ifndef __DEVICEVTABLE_OFFSETS_H__"; \ | ||
19 | echo "#define __DEVICEVTABLE_OFFSETS_H__"; \ | ||
20 | echo "/*"; \ | ||
21 | echo " * DO NOT MODIFY."; \ | ||
22 | echo " *"; \ | ||
23 | echo " * This file was generated by Kbuild"; \ | ||
24 | echo " *"; \ | ||
25 | echo " */"; \ | ||
26 | echo ""; \ | ||
27 | sed -ne $(sed-y) $<; \ | ||
28 | echo ""; \ | ||
29 | echo "#endif" ) > $@ | ||
30 | endef | ||
31 | |||
32 | # We use internal kbuild rules to avoid the "is up to date" message from make | ||
33 | scripts/mod/devicetable-offsets.s: scripts/mod/devicetable-offsets.c FORCE | ||
34 | $(Q)mkdir -p $(dir $@) | ||
35 | $(call if_changed_dep,cc_s_c) | ||
36 | |||
37 | $(obj)/$(devicetable-offsets-file): scripts/mod/devicetable-offsets.s | ||
38 | $(call cmd,offsets) | ||
39 | |||
6 | # dependencies on generated files need to be listed explicitly | 40 | # dependencies on generated files need to be listed explicitly |
7 | 41 | ||
8 | $(obj)/modpost.o $(obj)/file2alias.o $(obj)/sumversion.o: $(obj)/elfconfig.h | 42 | $(obj)/modpost.o $(obj)/file2alias.o $(obj)/sumversion.o: $(obj)/elfconfig.h |
43 | $(obj)/file2alias.o: $(obj)/$(devicetable-offsets-file) | ||
9 | 44 | ||
10 | quiet_cmd_elfconfig = MKELF $@ | 45 | quiet_cmd_elfconfig = MKELF $@ |
11 | cmd_elfconfig = $(obj)/mk_elfconfig < $< > $@ | 46 | cmd_elfconfig = $(obj)/mk_elfconfig < $< > $@ |
diff --git a/scripts/mod/devicetable-offsets.c b/scripts/mod/devicetable-offsets.c new file mode 100644 index 000000000000..b45260bfeaa0 --- /dev/null +++ b/scripts/mod/devicetable-offsets.c | |||
@@ -0,0 +1,178 @@ | |||
1 | #include <linux/kbuild.h> | ||
2 | #include <linux/mod_devicetable.h> | ||
3 | |||
4 | #define DEVID(devid) DEFINE(SIZE_##devid, sizeof(struct devid)) | ||
5 | #define DEVID_FIELD(devid, field) \ | ||
6 | DEFINE(OFF_##devid##_##field, offsetof(struct devid, field)) | ||
7 | |||
8 | int main(void) | ||
9 | { | ||
10 | DEVID(usb_device_id); | ||
11 | DEVID_FIELD(usb_device_id, match_flags); | ||
12 | DEVID_FIELD(usb_device_id, idVendor); | ||
13 | DEVID_FIELD(usb_device_id, idProduct); | ||
14 | DEVID_FIELD(usb_device_id, bcdDevice_lo); | ||
15 | DEVID_FIELD(usb_device_id, bcdDevice_hi); | ||
16 | DEVID_FIELD(usb_device_id, bDeviceClass); | ||
17 | DEVID_FIELD(usb_device_id, bDeviceSubClass); | ||
18 | DEVID_FIELD(usb_device_id, bDeviceProtocol); | ||
19 | DEVID_FIELD(usb_device_id, bInterfaceClass); | ||
20 | DEVID_FIELD(usb_device_id, bInterfaceSubClass); | ||
21 | DEVID_FIELD(usb_device_id, bInterfaceProtocol); | ||
22 | DEVID_FIELD(usb_device_id, bInterfaceNumber); | ||
23 | |||
24 | DEVID(hid_device_id); | ||
25 | DEVID_FIELD(hid_device_id, bus); | ||
26 | DEVID_FIELD(hid_device_id, group); | ||
27 | DEVID_FIELD(hid_device_id, vendor); | ||
28 | DEVID_FIELD(hid_device_id, product); | ||
29 | |||
30 | DEVID(ieee1394_device_id); | ||
31 | DEVID_FIELD(ieee1394_device_id, match_flags); | ||
32 | DEVID_FIELD(ieee1394_device_id, vendor_id); | ||
33 | DEVID_FIELD(ieee1394_device_id, model_id); | ||
34 | DEVID_FIELD(ieee1394_device_id, specifier_id); | ||
35 | DEVID_FIELD(ieee1394_device_id, version); | ||
36 | |||
37 | DEVID(pci_device_id); | ||
38 | DEVID_FIELD(pci_device_id, vendor); | ||
39 | DEVID_FIELD(pci_device_id, device); | ||
40 | DEVID_FIELD(pci_device_id, subvendor); | ||
41 | DEVID_FIELD(pci_device_id, subdevice); | ||
42 | DEVID_FIELD(pci_device_id, class); | ||
43 | DEVID_FIELD(pci_device_id, class_mask); | ||
44 | |||
45 | DEVID(ccw_device_id); | ||
46 | DEVID_FIELD(ccw_device_id, match_flags); | ||
47 | DEVID_FIELD(ccw_device_id, cu_type); | ||
48 | DEVID_FIELD(ccw_device_id, cu_model); | ||
49 | DEVID_FIELD(ccw_device_id, dev_type); | ||
50 | DEVID_FIELD(ccw_device_id, dev_model); | ||
51 | |||
52 | DEVID(ap_device_id); | ||
53 | DEVID_FIELD(ap_device_id, dev_type); | ||
54 | |||
55 | DEVID(css_device_id); | ||
56 | DEVID_FIELD(css_device_id, type); | ||
57 | |||
58 | DEVID(serio_device_id); | ||
59 | DEVID_FIELD(serio_device_id, type); | ||
60 | DEVID_FIELD(serio_device_id, proto); | ||
61 | DEVID_FIELD(serio_device_id, id); | ||
62 | DEVID_FIELD(serio_device_id, extra); | ||
63 | |||
64 | DEVID(acpi_device_id); | ||
65 | DEVID_FIELD(acpi_device_id, id); | ||
66 | |||
67 | DEVID(pnp_device_id); | ||
68 | DEVID_FIELD(pnp_device_id, id); | ||
69 | |||
70 | DEVID(pnp_card_device_id); | ||
71 | DEVID_FIELD(pnp_card_device_id, devs); | ||
72 | |||
73 | DEVID(pcmcia_device_id); | ||
74 | DEVID_FIELD(pcmcia_device_id, match_flags); | ||
75 | DEVID_FIELD(pcmcia_device_id, manf_id); | ||
76 | DEVID_FIELD(pcmcia_device_id, card_id); | ||
77 | DEVID_FIELD(pcmcia_device_id, func_id); | ||
78 | DEVID_FIELD(pcmcia_device_id, function); | ||
79 | DEVID_FIELD(pcmcia_device_id, device_no); | ||
80 | DEVID_FIELD(pcmcia_device_id, prod_id_hash); | ||
81 | |||
82 | DEVID(of_device_id); | ||
83 | DEVID_FIELD(of_device_id, name); | ||
84 | DEVID_FIELD(of_device_id, type); | ||
85 | DEVID_FIELD(of_device_id, compatible); | ||
86 | |||
87 | DEVID(vio_device_id); | ||
88 | DEVID_FIELD(vio_device_id, type); | ||
89 | DEVID_FIELD(vio_device_id, compat); | ||
90 | |||
91 | DEVID(input_device_id); | ||
92 | DEVID_FIELD(input_device_id, flags); | ||
93 | DEVID_FIELD(input_device_id, bustype); | ||
94 | DEVID_FIELD(input_device_id, vendor); | ||
95 | DEVID_FIELD(input_device_id, product); | ||
96 | DEVID_FIELD(input_device_id, version); | ||
97 | DEVID_FIELD(input_device_id, evbit); | ||
98 | DEVID_FIELD(input_device_id, keybit); | ||
99 | DEVID_FIELD(input_device_id, relbit); | ||
100 | DEVID_FIELD(input_device_id, absbit); | ||
101 | DEVID_FIELD(input_device_id, mscbit); | ||
102 | DEVID_FIELD(input_device_id, ledbit); | ||
103 | DEVID_FIELD(input_device_id, sndbit); | ||
104 | DEVID_FIELD(input_device_id, ffbit); | ||
105 | DEVID_FIELD(input_device_id, swbit); | ||
106 | |||
107 | DEVID(eisa_device_id); | ||
108 | DEVID_FIELD(eisa_device_id, sig); | ||
109 | |||
110 | DEVID(parisc_device_id); | ||
111 | DEVID_FIELD(parisc_device_id, hw_type); | ||
112 | DEVID_FIELD(parisc_device_id, hversion); | ||
113 | DEVID_FIELD(parisc_device_id, hversion_rev); | ||
114 | DEVID_FIELD(parisc_device_id, sversion); | ||
115 | |||
116 | DEVID(sdio_device_id); | ||
117 | DEVID_FIELD(sdio_device_id, class); | ||
118 | DEVID_FIELD(sdio_device_id, vendor); | ||
119 | DEVID_FIELD(sdio_device_id, device); | ||
120 | |||
121 | DEVID(ssb_device_id); | ||
122 | DEVID_FIELD(ssb_device_id, vendor); | ||
123 | DEVID_FIELD(ssb_device_id, coreid); | ||
124 | DEVID_FIELD(ssb_device_id, revision); | ||
125 | |||
126 | DEVID(bcma_device_id); | ||
127 | DEVID_FIELD(bcma_device_id, manuf); | ||
128 | DEVID_FIELD(bcma_device_id, id); | ||
129 | DEVID_FIELD(bcma_device_id, rev); | ||
130 | DEVID_FIELD(bcma_device_id, class); | ||
131 | |||
132 | DEVID(virtio_device_id); | ||
133 | DEVID_FIELD(virtio_device_id, device); | ||
134 | DEVID_FIELD(virtio_device_id, vendor); | ||
135 | |||
136 | DEVID(hv_vmbus_device_id); | ||
137 | DEVID_FIELD(hv_vmbus_device_id, guid); | ||
138 | |||
139 | DEVID(i2c_device_id); | ||
140 | DEVID_FIELD(i2c_device_id, name); | ||
141 | |||
142 | DEVID(spi_device_id); | ||
143 | DEVID_FIELD(spi_device_id, name); | ||
144 | |||
145 | DEVID(dmi_system_id); | ||
146 | DEVID_FIELD(dmi_system_id, matches); | ||
147 | |||
148 | DEVID(platform_device_id); | ||
149 | DEVID_FIELD(platform_device_id, name); | ||
150 | |||
151 | DEVID(mdio_device_id); | ||
152 | DEVID_FIELD(mdio_device_id, phy_id); | ||
153 | DEVID_FIELD(mdio_device_id, phy_id_mask); | ||
154 | |||
155 | DEVID(zorro_device_id); | ||
156 | DEVID_FIELD(zorro_device_id, id); | ||
157 | |||
158 | DEVID(isapnp_device_id); | ||
159 | DEVID_FIELD(isapnp_device_id, vendor); | ||
160 | DEVID_FIELD(isapnp_device_id, function); | ||
161 | |||
162 | DEVID(ipack_device_id); | ||
163 | DEVID_FIELD(ipack_device_id, format); | ||
164 | DEVID_FIELD(ipack_device_id, vendor); | ||
165 | DEVID_FIELD(ipack_device_id, device); | ||
166 | |||
167 | DEVID(amba_id); | ||
168 | DEVID_FIELD(amba_id, id); | ||
169 | DEVID_FIELD(amba_id, mask); | ||
170 | |||
171 | DEVID(x86_cpu_id); | ||
172 | DEVID_FIELD(x86_cpu_id, feature); | ||
173 | DEVID_FIELD(x86_cpu_id, family); | ||
174 | DEVID_FIELD(x86_cpu_id, model); | ||
175 | DEVID_FIELD(x86_cpu_id, vendor); | ||
176 | |||
177 | return 0; | ||
178 | } | ||
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index df4fc23dd836..771ac17f635d 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c | |||
@@ -11,6 +11,7 @@ | |||
11 | */ | 11 | */ |
12 | 12 | ||
13 | #include "modpost.h" | 13 | #include "modpost.h" |
14 | #include "devicetable-offsets.h" | ||
14 | 15 | ||
15 | /* We use the ELF typedefs for kernel_ulong_t but bite the bullet and | 16 | /* We use the ELF typedefs for kernel_ulong_t but bite the bullet and |
16 | * use either stdint.h or inttypes.h for the rest. */ | 17 | * use either stdint.h or inttypes.h for the rest. */ |
@@ -84,13 +85,25 @@ extern struct devtable *__start___devtable[], *__stop___devtable[]; | |||
84 | # define __used __attribute__((__used__)) | 85 | # define __used __attribute__((__used__)) |
85 | #endif | 86 | #endif |
86 | 87 | ||
88 | /* Define a variable f that holds the value of field f of struct devid | ||
89 | * based at address m. | ||
90 | */ | ||
91 | #define DEF_FIELD(m, devid, f) \ | ||
92 | typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f)) | ||
93 | /* Define a variable f that holds the address of field f of struct devid | ||
94 | * based at address m. Due to the way typeof works, for a field of type | ||
95 | * T[N] the variable has type T(*)[N], _not_ T*. | ||
96 | */ | ||
97 | #define DEF_FIELD_ADDR(m, devid, f) \ | ||
98 | typeof(((struct devid *)0)->f) *f = ((m) + OFF_##devid##_##f) | ||
99 | |||
87 | /* Add a table entry. We test function type matches while we're here. */ | 100 | /* Add a table entry. We test function type matches while we're here. */ |
88 | #define ADD_TO_DEVTABLE(device_id, type, function) \ | 101 | #define ADD_TO_DEVTABLE(device_id, type, function) \ |
89 | static struct devtable __cat(devtable,__LINE__) = { \ | 102 | static struct devtable __cat(devtable,__LINE__) = { \ |
90 | device_id + 0*sizeof((function)((const char *)NULL, \ | 103 | device_id + 0*sizeof((function)((const char *)NULL, \ |
91 | (type *)NULL, \ | 104 | (void *)NULL, \ |
92 | (char *)NULL)), \ | 105 | (char *)NULL)), \ |
93 | sizeof(type), (function) }; \ | 106 | SIZE_##type, (function) }; \ |
94 | static struct devtable *SECTION(__devtable) __used \ | 107 | static struct devtable *SECTION(__devtable) __used \ |
95 | __cat(devtable_ptr,__LINE__) = &__cat(devtable,__LINE__) | 108 | __cat(devtable_ptr,__LINE__) = &__cat(devtable,__LINE__) |
96 | 109 | ||
@@ -116,7 +129,6 @@ static inline void add_wildcard(char *str) | |||
116 | strcat(str + len, "*"); | 129 | strcat(str + len, "*"); |
117 | } | 130 | } |
118 | 131 | ||
119 | unsigned int cross_build = 0; | ||
120 | /** | 132 | /** |
121 | * Check that sizeof(device_id type) are consistent with size of section | 133 | * Check that sizeof(device_id type) are consistent with size of section |
122 | * in .o file. If in-consistent then userspace and kernel does not agree | 134 | * in .o file. If in-consistent then userspace and kernel does not agree |
@@ -131,8 +143,6 @@ static void device_id_check(const char *modname, const char *device_id, | |||
131 | int i; | 143 | int i; |
132 | 144 | ||
133 | if (size % id_size || size < id_size) { | 145 | if (size % id_size || size < id_size) { |
134 | if (cross_build != 0) | ||
135 | return; | ||
136 | fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo " | 146 | fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo " |
137 | "of the size of section __mod_%s_device_table=%lu.\n" | 147 | "of the size of section __mod_%s_device_table=%lu.\n" |
138 | "Fix definition of struct %s_device_id " | 148 | "Fix definition of struct %s_device_id " |
@@ -157,17 +167,29 @@ static void device_id_check(const char *modname, const char *device_id, | |||
157 | 167 | ||
158 | /* USB is special because the bcdDevice can be matched against a numeric range */ | 168 | /* USB is special because the bcdDevice can be matched against a numeric range */ |
159 | /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipNinN" */ | 169 | /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipNinN" */ |
160 | static void do_usb_entry(struct usb_device_id *id, | 170 | static void do_usb_entry(void *symval, |
161 | unsigned int bcdDevice_initial, int bcdDevice_initial_digits, | 171 | unsigned int bcdDevice_initial, int bcdDevice_initial_digits, |
162 | unsigned char range_lo, unsigned char range_hi, | 172 | unsigned char range_lo, unsigned char range_hi, |
163 | unsigned char max, struct module *mod) | 173 | unsigned char max, struct module *mod) |
164 | { | 174 | { |
165 | char alias[500]; | 175 | char alias[500]; |
176 | DEF_FIELD(symval, usb_device_id, match_flags); | ||
177 | DEF_FIELD(symval, usb_device_id, idVendor); | ||
178 | DEF_FIELD(symval, usb_device_id, idProduct); | ||
179 | DEF_FIELD(symval, usb_device_id, bcdDevice_lo); | ||
180 | DEF_FIELD(symval, usb_device_id, bDeviceClass); | ||
181 | DEF_FIELD(symval, usb_device_id, bDeviceSubClass); | ||
182 | DEF_FIELD(symval, usb_device_id, bDeviceProtocol); | ||
183 | DEF_FIELD(symval, usb_device_id, bInterfaceClass); | ||
184 | DEF_FIELD(symval, usb_device_id, bInterfaceSubClass); | ||
185 | DEF_FIELD(symval, usb_device_id, bInterfaceProtocol); | ||
186 | DEF_FIELD(symval, usb_device_id, bInterfaceNumber); | ||
187 | |||
166 | strcpy(alias, "usb:"); | 188 | strcpy(alias, "usb:"); |
167 | ADD(alias, "v", id->match_flags&USB_DEVICE_ID_MATCH_VENDOR, | 189 | ADD(alias, "v", match_flags&USB_DEVICE_ID_MATCH_VENDOR, |
168 | id->idVendor); | 190 | idVendor); |
169 | ADD(alias, "p", id->match_flags&USB_DEVICE_ID_MATCH_PRODUCT, | 191 | ADD(alias, "p", match_flags&USB_DEVICE_ID_MATCH_PRODUCT, |
170 | id->idProduct); | 192 | idProduct); |
171 | 193 | ||
172 | strcat(alias, "d"); | 194 | strcat(alias, "d"); |
173 | if (bcdDevice_initial_digits) | 195 | if (bcdDevice_initial_digits) |
@@ -190,29 +212,23 @@ static void do_usb_entry(struct usb_device_id *id, | |||
190 | range_lo); | 212 | range_lo); |
191 | } | 213 | } |
192 | } | 214 | } |
193 | if (bcdDevice_initial_digits < (sizeof(id->bcdDevice_lo) * 2 - 1)) | 215 | if (bcdDevice_initial_digits < (sizeof(bcdDevice_lo) * 2 - 1)) |
194 | strcat(alias, "*"); | 216 | strcat(alias, "*"); |
195 | 217 | ||
196 | ADD(alias, "dc", id->match_flags&USB_DEVICE_ID_MATCH_DEV_CLASS, | 218 | ADD(alias, "dc", match_flags&USB_DEVICE_ID_MATCH_DEV_CLASS, |
197 | id->bDeviceClass); | 219 | bDeviceClass); |
198 | ADD(alias, "dsc", | 220 | ADD(alias, "dsc", match_flags&USB_DEVICE_ID_MATCH_DEV_SUBCLASS, |
199 | id->match_flags&USB_DEVICE_ID_MATCH_DEV_SUBCLASS, | 221 | bDeviceSubClass); |
200 | id->bDeviceSubClass); | 222 | ADD(alias, "dp", match_flags&USB_DEVICE_ID_MATCH_DEV_PROTOCOL, |
201 | ADD(alias, "dp", | 223 | bDeviceProtocol); |
202 | id->match_flags&USB_DEVICE_ID_MATCH_DEV_PROTOCOL, | 224 | ADD(alias, "ic", match_flags&USB_DEVICE_ID_MATCH_INT_CLASS, |
203 | id->bDeviceProtocol); | 225 | bInterfaceClass); |
204 | ADD(alias, "ic", | 226 | ADD(alias, "isc", match_flags&USB_DEVICE_ID_MATCH_INT_SUBCLASS, |
205 | id->match_flags&USB_DEVICE_ID_MATCH_INT_CLASS, | 227 | bInterfaceSubClass); |
206 | id->bInterfaceClass); | 228 | ADD(alias, "ip", match_flags&USB_DEVICE_ID_MATCH_INT_PROTOCOL, |
207 | ADD(alias, "isc", | 229 | bInterfaceProtocol); |
208 | id->match_flags&USB_DEVICE_ID_MATCH_INT_SUBCLASS, | 230 | ADD(alias, "in", match_flags&USB_DEVICE_ID_MATCH_INT_NUMBER, |
209 | id->bInterfaceSubClass); | 231 | bInterfaceNumber); |
210 | ADD(alias, "ip", | ||
211 | id->match_flags&USB_DEVICE_ID_MATCH_INT_PROTOCOL, | ||
212 | id->bInterfaceProtocol); | ||
213 | ADD(alias, "in", | ||
214 | id->match_flags&USB_DEVICE_ID_MATCH_INT_NUMBER, | ||
215 | id->bInterfaceNumber); | ||
216 | 232 | ||
217 | add_wildcard(alias); | 233 | add_wildcard(alias); |
218 | buf_printf(&mod->dev_table_buf, | 234 | buf_printf(&mod->dev_table_buf, |
@@ -258,24 +274,28 @@ static unsigned int incbcd(unsigned int *bcd, | |||
258 | return init; | 274 | return init; |
259 | } | 275 | } |
260 | 276 | ||
261 | static void do_usb_entry_multi(struct usb_device_id *id, struct module *mod) | 277 | static void do_usb_entry_multi(void *symval, struct module *mod) |
262 | { | 278 | { |
263 | unsigned int devlo, devhi; | 279 | unsigned int devlo, devhi; |
264 | unsigned char chi, clo, max; | 280 | unsigned char chi, clo, max; |
265 | int ndigits; | 281 | int ndigits; |
266 | 282 | ||
267 | id->match_flags = TO_NATIVE(id->match_flags); | 283 | DEF_FIELD(symval, usb_device_id, match_flags); |
268 | id->idVendor = TO_NATIVE(id->idVendor); | 284 | DEF_FIELD(symval, usb_device_id, idVendor); |
269 | id->idProduct = TO_NATIVE(id->idProduct); | 285 | DEF_FIELD(symval, usb_device_id, idProduct); |
286 | DEF_FIELD(symval, usb_device_id, bcdDevice_lo); | ||
287 | DEF_FIELD(symval, usb_device_id, bcdDevice_hi); | ||
288 | DEF_FIELD(symval, usb_device_id, bDeviceClass); | ||
289 | DEF_FIELD(symval, usb_device_id, bInterfaceClass); | ||
270 | 290 | ||
271 | devlo = id->match_flags & USB_DEVICE_ID_MATCH_DEV_LO ? | 291 | devlo = match_flags & USB_DEVICE_ID_MATCH_DEV_LO ? |
272 | TO_NATIVE(id->bcdDevice_lo) : 0x0U; | 292 | bcdDevice_lo : 0x0U; |
273 | devhi = id->match_flags & USB_DEVICE_ID_MATCH_DEV_HI ? | 293 | devhi = match_flags & USB_DEVICE_ID_MATCH_DEV_HI ? |
274 | TO_NATIVE(id->bcdDevice_hi) : ~0x0U; | 294 | bcdDevice_hi : ~0x0U; |
275 | 295 | ||
276 | /* Figure out if this entry is in bcd or hex format */ | 296 | /* Figure out if this entry is in bcd or hex format */ |
277 | max = 0x9; /* Default to decimal format */ | 297 | max = 0x9; /* Default to decimal format */ |
278 | for (ndigits = 0 ; ndigits < sizeof(id->bcdDevice_lo) * 2 ; ndigits++) { | 298 | for (ndigits = 0 ; ndigits < sizeof(bcdDevice_lo) * 2 ; ndigits++) { |
279 | clo = (devlo >> (ndigits << 2)) & 0xf; | 299 | clo = (devlo >> (ndigits << 2)) & 0xf; |
280 | chi = ((devhi > 0x9999 ? 0x9999 : devhi) >> (ndigits << 2)) & 0xf; | 300 | chi = ((devhi > 0x9999 ? 0x9999 : devhi) >> (ndigits << 2)) & 0xf; |
281 | if (clo > max || chi > max) { | 301 | if (clo > max || chi > max) { |
@@ -288,11 +308,11 @@ static void do_usb_entry_multi(struct usb_device_id *id, struct module *mod) | |||
288 | * Some modules (visor) have empty slots as placeholder for | 308 | * Some modules (visor) have empty slots as placeholder for |
289 | * run-time specification that results in catch-all alias | 309 | * run-time specification that results in catch-all alias |
290 | */ | 310 | */ |
291 | if (!(id->idVendor | id->idProduct | id->bDeviceClass | id->bInterfaceClass)) | 311 | if (!(idVendor | idProduct | bDeviceClass | bInterfaceClass)) |
292 | return; | 312 | return; |
293 | 313 | ||
294 | /* Convert numeric bcdDevice range into fnmatch-able pattern(s) */ | 314 | /* Convert numeric bcdDevice range into fnmatch-able pattern(s) */ |
295 | for (ndigits = sizeof(id->bcdDevice_lo) * 2 - 1; devlo <= devhi; ndigits--) { | 315 | for (ndigits = sizeof(bcdDevice_lo) * 2 - 1; devlo <= devhi; ndigits--) { |
296 | clo = devlo & 0xf; | 316 | clo = devlo & 0xf; |
297 | chi = devhi & 0xf; | 317 | chi = devhi & 0xf; |
298 | if (chi > max) /* If we are in bcd mode, truncate if necessary */ | 318 | if (chi > max) /* If we are in bcd mode, truncate if necessary */ |
@@ -301,20 +321,20 @@ static void do_usb_entry_multi(struct usb_device_id *id, struct module *mod) | |||
301 | devhi >>= 4; | 321 | devhi >>= 4; |
302 | 322 | ||
303 | if (devlo == devhi || !ndigits) { | 323 | if (devlo == devhi || !ndigits) { |
304 | do_usb_entry(id, devlo, ndigits, clo, chi, max, mod); | 324 | do_usb_entry(symval, devlo, ndigits, clo, chi, max, mod); |
305 | break; | 325 | break; |
306 | } | 326 | } |
307 | 327 | ||
308 | if (clo > 0x0) | 328 | if (clo > 0x0) |
309 | do_usb_entry(id, | 329 | do_usb_entry(symval, |
310 | incbcd(&devlo, 1, max, | 330 | incbcd(&devlo, 1, max, |
311 | sizeof(id->bcdDevice_lo) * 2), | 331 | sizeof(bcdDevice_lo) * 2), |
312 | ndigits, clo, max, max, mod); | 332 | ndigits, clo, max, max, mod); |
313 | 333 | ||
314 | if (chi < max) | 334 | if (chi < max) |
315 | do_usb_entry(id, | 335 | do_usb_entry(symval, |
316 | incbcd(&devhi, -1, max, | 336 | incbcd(&devhi, -1, max, |
317 | sizeof(id->bcdDevice_lo) * 2), | 337 | sizeof(bcdDevice_lo) * 2), |
318 | ndigits, 0x0, chi, max, mod); | 338 | ndigits, 0x0, chi, max, mod); |
319 | } | 339 | } |
320 | } | 340 | } |
@@ -323,7 +343,7 @@ static void do_usb_table(void *symval, unsigned long size, | |||
323 | struct module *mod) | 343 | struct module *mod) |
324 | { | 344 | { |
325 | unsigned int i; | 345 | unsigned int i; |
326 | const unsigned long id_size = sizeof(struct usb_device_id); | 346 | const unsigned long id_size = SIZE_usb_device_id; |
327 | 347 | ||
328 | device_id_check(mod->name, "usb", size, id_size, symval); | 348 | device_id_check(mod->name, "usb", size, id_size, symval); |
329 | 349 | ||
@@ -336,81 +356,81 @@ static void do_usb_table(void *symval, unsigned long size, | |||
336 | 356 | ||
337 | /* Looks like: hid:bNvNpN */ | 357 | /* Looks like: hid:bNvNpN */ |
338 | static int do_hid_entry(const char *filename, | 358 | static int do_hid_entry(const char *filename, |
339 | struct hid_device_id *id, char *alias) | 359 | void *symval, char *alias) |
340 | { | 360 | { |
341 | id->bus = TO_NATIVE(id->bus); | 361 | DEF_FIELD(symval, hid_device_id, bus); |
342 | id->group = TO_NATIVE(id->group); | 362 | DEF_FIELD(symval, hid_device_id, group); |
343 | id->vendor = TO_NATIVE(id->vendor); | 363 | DEF_FIELD(symval, hid_device_id, vendor); |
344 | id->product = TO_NATIVE(id->product); | 364 | DEF_FIELD(symval, hid_device_id, product); |
345 | 365 | ||
346 | sprintf(alias, "hid:"); | 366 | sprintf(alias, "hid:"); |
347 | ADD(alias, "b", id->bus != HID_BUS_ANY, id->bus); | 367 | ADD(alias, "b", bus != HID_BUS_ANY, bus); |
348 | ADD(alias, "g", id->group != HID_GROUP_ANY, id->group); | 368 | ADD(alias, "g", group != HID_GROUP_ANY, group); |
349 | ADD(alias, "v", id->vendor != HID_ANY_ID, id->vendor); | 369 | ADD(alias, "v", vendor != HID_ANY_ID, vendor); |
350 | ADD(alias, "p", id->product != HID_ANY_ID, id->product); | 370 | ADD(alias, "p", product != HID_ANY_ID, product); |
351 | 371 | ||
352 | return 1; | 372 | return 1; |
353 | } | 373 | } |
354 | ADD_TO_DEVTABLE("hid", struct hid_device_id, do_hid_entry); | 374 | ADD_TO_DEVTABLE("hid", hid_device_id, do_hid_entry); |
355 | 375 | ||
356 | /* Looks like: ieee1394:venNmoNspNverN */ | 376 | /* Looks like: ieee1394:venNmoNspNverN */ |
357 | static int do_ieee1394_entry(const char *filename, | 377 | static int do_ieee1394_entry(const char *filename, |
358 | struct ieee1394_device_id *id, char *alias) | 378 | void *symval, char *alias) |
359 | { | 379 | { |
360 | id->match_flags = TO_NATIVE(id->match_flags); | 380 | DEF_FIELD(symval, ieee1394_device_id, match_flags); |
361 | id->vendor_id = TO_NATIVE(id->vendor_id); | 381 | DEF_FIELD(symval, ieee1394_device_id, vendor_id); |
362 | id->model_id = TO_NATIVE(id->model_id); | 382 | DEF_FIELD(symval, ieee1394_device_id, model_id); |
363 | id->specifier_id = TO_NATIVE(id->specifier_id); | 383 | DEF_FIELD(symval, ieee1394_device_id, specifier_id); |
364 | id->version = TO_NATIVE(id->version); | 384 | DEF_FIELD(symval, ieee1394_device_id, version); |
365 | 385 | ||
366 | strcpy(alias, "ieee1394:"); | 386 | strcpy(alias, "ieee1394:"); |
367 | ADD(alias, "ven", id->match_flags & IEEE1394_MATCH_VENDOR_ID, | 387 | ADD(alias, "ven", match_flags & IEEE1394_MATCH_VENDOR_ID, |
368 | id->vendor_id); | 388 | vendor_id); |
369 | ADD(alias, "mo", id->match_flags & IEEE1394_MATCH_MODEL_ID, | 389 | ADD(alias, "mo", match_flags & IEEE1394_MATCH_MODEL_ID, |
370 | id->model_id); | 390 | model_id); |
371 | ADD(alias, "sp", id->match_flags & IEEE1394_MATCH_SPECIFIER_ID, | 391 | ADD(alias, "sp", match_flags & IEEE1394_MATCH_SPECIFIER_ID, |
372 | id->specifier_id); | 392 | specifier_id); |
373 | ADD(alias, "ver", id->match_flags & IEEE1394_MATCH_VERSION, | 393 | ADD(alias, "ver", match_flags & IEEE1394_MATCH_VERSION, |
374 | id->version); | 394 | version); |
375 | 395 | ||
376 | add_wildcard(alias); | 396 | add_wildcard(alias); |
377 | return 1; | 397 | return 1; |
378 | } | 398 | } |
379 | ADD_TO_DEVTABLE("ieee1394", struct ieee1394_device_id, do_ieee1394_entry); | 399 | ADD_TO_DEVTABLE("ieee1394", ieee1394_device_id, do_ieee1394_entry); |
380 | 400 | ||
381 | /* Looks like: pci:vNdNsvNsdNbcNscNiN. */ | 401 | /* Looks like: pci:vNdNsvNsdNbcNscNiN. */ |
382 | static int do_pci_entry(const char *filename, | 402 | static int do_pci_entry(const char *filename, |
383 | struct pci_device_id *id, char *alias) | 403 | void *symval, char *alias) |
384 | { | 404 | { |
385 | /* Class field can be divided into these three. */ | 405 | /* Class field can be divided into these three. */ |
386 | unsigned char baseclass, subclass, interface, | 406 | unsigned char baseclass, subclass, interface, |
387 | baseclass_mask, subclass_mask, interface_mask; | 407 | baseclass_mask, subclass_mask, interface_mask; |
388 | 408 | ||
389 | id->vendor = TO_NATIVE(id->vendor); | 409 | DEF_FIELD(symval, pci_device_id, vendor); |
390 | id->device = TO_NATIVE(id->device); | 410 | DEF_FIELD(symval, pci_device_id, device); |
391 | id->subvendor = TO_NATIVE(id->subvendor); | 411 | DEF_FIELD(symval, pci_device_id, subvendor); |
392 | id->subdevice = TO_NATIVE(id->subdevice); | 412 | DEF_FIELD(symval, pci_device_id, subdevice); |
393 | id->class = TO_NATIVE(id->class); | 413 | DEF_FIELD(symval, pci_device_id, class); |
394 | id->class_mask = TO_NATIVE(id->class_mask); | 414 | DEF_FIELD(symval, pci_device_id, class_mask); |
395 | 415 | ||
396 | strcpy(alias, "pci:"); | 416 | strcpy(alias, "pci:"); |
397 | ADD(alias, "v", id->vendor != PCI_ANY_ID, id->vendor); | 417 | ADD(alias, "v", vendor != PCI_ANY_ID, vendor); |
398 | ADD(alias, "d", id->device != PCI_ANY_ID, id->device); | 418 | ADD(alias, "d", device != PCI_ANY_ID, device); |
399 | ADD(alias, "sv", id->subvendor != PCI_ANY_ID, id->subvendor); | 419 | ADD(alias, "sv", subvendor != PCI_ANY_ID, subvendor); |
400 | ADD(alias, "sd", id->subdevice != PCI_ANY_ID, id->subdevice); | 420 | ADD(alias, "sd", subdevice != PCI_ANY_ID, subdevice); |
401 | 421 | ||
402 | baseclass = (id->class) >> 16; | 422 | baseclass = (class) >> 16; |
403 | baseclass_mask = (id->class_mask) >> 16; | 423 | baseclass_mask = (class_mask) >> 16; |
404 | subclass = (id->class) >> 8; | 424 | subclass = (class) >> 8; |
405 | subclass_mask = (id->class_mask) >> 8; | 425 | subclass_mask = (class_mask) >> 8; |
406 | interface = id->class; | 426 | interface = class; |
407 | interface_mask = id->class_mask; | 427 | interface_mask = class_mask; |
408 | 428 | ||
409 | if ((baseclass_mask != 0 && baseclass_mask != 0xFF) | 429 | if ((baseclass_mask != 0 && baseclass_mask != 0xFF) |
410 | || (subclass_mask != 0 && subclass_mask != 0xFF) | 430 | || (subclass_mask != 0 && subclass_mask != 0xFF) |
411 | || (interface_mask != 0 && interface_mask != 0xFF)) { | 431 | || (interface_mask != 0 && interface_mask != 0xFF)) { |
412 | warn("Can't handle masks in %s:%04X\n", | 432 | warn("Can't handle masks in %s:%04X\n", |
413 | filename, id->class_mask); | 433 | filename, class_mask); |
414 | return 0; | 434 | return 0; |
415 | } | 435 | } |
416 | 436 | ||
@@ -420,101 +440,105 @@ static int do_pci_entry(const char *filename, | |||
420 | add_wildcard(alias); | 440 | add_wildcard(alias); |
421 | return 1; | 441 | return 1; |
422 | } | 442 | } |
423 | ADD_TO_DEVTABLE("pci", struct pci_device_id, do_pci_entry); | 443 | ADD_TO_DEVTABLE("pci", pci_device_id, do_pci_entry); |
424 | 444 | ||
425 | /* looks like: "ccw:tNmNdtNdmN" */ | 445 | /* looks like: "ccw:tNmNdtNdmN" */ |
426 | static int do_ccw_entry(const char *filename, | 446 | static int do_ccw_entry(const char *filename, |
427 | struct ccw_device_id *id, char *alias) | 447 | void *symval, char *alias) |
428 | { | 448 | { |
429 | id->match_flags = TO_NATIVE(id->match_flags); | 449 | DEF_FIELD(symval, ccw_device_id, match_flags); |
430 | id->cu_type = TO_NATIVE(id->cu_type); | 450 | DEF_FIELD(symval, ccw_device_id, cu_type); |
431 | id->cu_model = TO_NATIVE(id->cu_model); | 451 | DEF_FIELD(symval, ccw_device_id, cu_model); |
432 | id->dev_type = TO_NATIVE(id->dev_type); | 452 | DEF_FIELD(symval, ccw_device_id, dev_type); |
433 | id->dev_model = TO_NATIVE(id->dev_model); | 453 | DEF_FIELD(symval, ccw_device_id, dev_model); |
434 | 454 | ||
435 | strcpy(alias, "ccw:"); | 455 | strcpy(alias, "ccw:"); |
436 | ADD(alias, "t", id->match_flags&CCW_DEVICE_ID_MATCH_CU_TYPE, | 456 | ADD(alias, "t", match_flags&CCW_DEVICE_ID_MATCH_CU_TYPE, |
437 | id->cu_type); | 457 | cu_type); |
438 | ADD(alias, "m", id->match_flags&CCW_DEVICE_ID_MATCH_CU_MODEL, | 458 | ADD(alias, "m", match_flags&CCW_DEVICE_ID_MATCH_CU_MODEL, |
439 | id->cu_model); | 459 | cu_model); |
440 | ADD(alias, "dt", id->match_flags&CCW_DEVICE_ID_MATCH_DEVICE_TYPE, | 460 | ADD(alias, "dt", match_flags&CCW_DEVICE_ID_MATCH_DEVICE_TYPE, |
441 | id->dev_type); | 461 | dev_type); |
442 | ADD(alias, "dm", id->match_flags&CCW_DEVICE_ID_MATCH_DEVICE_MODEL, | 462 | ADD(alias, "dm", match_flags&CCW_DEVICE_ID_MATCH_DEVICE_MODEL, |
443 | id->dev_model); | 463 | dev_model); |
444 | add_wildcard(alias); | 464 | add_wildcard(alias); |
445 | return 1; | 465 | return 1; |
446 | } | 466 | } |
447 | ADD_TO_DEVTABLE("ccw", struct ccw_device_id, do_ccw_entry); | 467 | ADD_TO_DEVTABLE("ccw", ccw_device_id, do_ccw_entry); |
448 | 468 | ||
449 | /* looks like: "ap:tN" */ | 469 | /* looks like: "ap:tN" */ |
450 | static int do_ap_entry(const char *filename, | 470 | static int do_ap_entry(const char *filename, |
451 | struct ap_device_id *id, char *alias) | 471 | void *symval, char *alias) |
452 | { | 472 | { |
453 | sprintf(alias, "ap:t%02X*", id->dev_type); | 473 | DEF_FIELD(symval, ap_device_id, dev_type); |
474 | |||
475 | sprintf(alias, "ap:t%02X*", dev_type); | ||
454 | return 1; | 476 | return 1; |
455 | } | 477 | } |
456 | ADD_TO_DEVTABLE("ap", struct ap_device_id, do_ap_entry); | 478 | ADD_TO_DEVTABLE("ap", ap_device_id, do_ap_entry); |
457 | 479 | ||
458 | /* looks like: "css:tN" */ | 480 | /* looks like: "css:tN" */ |
459 | static int do_css_entry(const char *filename, | 481 | static int do_css_entry(const char *filename, |
460 | struct css_device_id *id, char *alias) | 482 | void *symval, char *alias) |
461 | { | 483 | { |
462 | sprintf(alias, "css:t%01X", id->type); | 484 | DEF_FIELD(symval, css_device_id, type); |
485 | |||
486 | sprintf(alias, "css:t%01X", type); | ||
463 | return 1; | 487 | return 1; |
464 | } | 488 | } |
465 | ADD_TO_DEVTABLE("css", struct css_device_id, do_css_entry); | 489 | ADD_TO_DEVTABLE("css", css_device_id, do_css_entry); |
466 | 490 | ||
467 | /* Looks like: "serio:tyNprNidNexN" */ | 491 | /* Looks like: "serio:tyNprNidNexN" */ |
468 | static int do_serio_entry(const char *filename, | 492 | static int do_serio_entry(const char *filename, |
469 | struct serio_device_id *id, char *alias) | 493 | void *symval, char *alias) |
470 | { | 494 | { |
471 | id->type = TO_NATIVE(id->type); | 495 | DEF_FIELD(symval, serio_device_id, type); |
472 | id->proto = TO_NATIVE(id->proto); | 496 | DEF_FIELD(symval, serio_device_id, proto); |
473 | id->id = TO_NATIVE(id->id); | 497 | DEF_FIELD(symval, serio_device_id, id); |
474 | id->extra = TO_NATIVE(id->extra); | 498 | DEF_FIELD(symval, serio_device_id, extra); |
475 | 499 | ||
476 | strcpy(alias, "serio:"); | 500 | strcpy(alias, "serio:"); |
477 | ADD(alias, "ty", id->type != SERIO_ANY, id->type); | 501 | ADD(alias, "ty", type != SERIO_ANY, type); |
478 | ADD(alias, "pr", id->proto != SERIO_ANY, id->proto); | 502 | ADD(alias, "pr", proto != SERIO_ANY, proto); |
479 | ADD(alias, "id", id->id != SERIO_ANY, id->id); | 503 | ADD(alias, "id", id != SERIO_ANY, id); |
480 | ADD(alias, "ex", id->extra != SERIO_ANY, id->extra); | 504 | ADD(alias, "ex", extra != SERIO_ANY, extra); |
481 | 505 | ||
482 | add_wildcard(alias); | 506 | add_wildcard(alias); |
483 | return 1; | 507 | return 1; |
484 | } | 508 | } |
485 | ADD_TO_DEVTABLE("serio", struct serio_device_id, do_serio_entry); | 509 | ADD_TO_DEVTABLE("serio", serio_device_id, do_serio_entry); |
486 | 510 | ||
487 | /* looks like: "acpi:ACPI0003 or acpi:PNP0C0B" or "acpi:LNXVIDEO" */ | 511 | /* looks like: "acpi:ACPI0003 or acpi:PNP0C0B" or "acpi:LNXVIDEO" */ |
488 | static int do_acpi_entry(const char *filename, | 512 | static int do_acpi_entry(const char *filename, |
489 | struct acpi_device_id *id, char *alias) | 513 | void *symval, char *alias) |
490 | { | 514 | { |
491 | sprintf(alias, "acpi*:%s:*", id->id); | 515 | DEF_FIELD_ADDR(symval, acpi_device_id, id); |
516 | sprintf(alias, "acpi*:%s:*", *id); | ||
492 | return 1; | 517 | return 1; |
493 | } | 518 | } |
494 | ADD_TO_DEVTABLE("acpi", struct acpi_device_id, do_acpi_entry); | 519 | ADD_TO_DEVTABLE("acpi", acpi_device_id, do_acpi_entry); |
495 | 520 | ||
496 | /* looks like: "pnp:dD" */ | 521 | /* looks like: "pnp:dD" */ |
497 | static void do_pnp_device_entry(void *symval, unsigned long size, | 522 | static void do_pnp_device_entry(void *symval, unsigned long size, |
498 | struct module *mod) | 523 | struct module *mod) |
499 | { | 524 | { |
500 | const unsigned long id_size = sizeof(struct pnp_device_id); | 525 | const unsigned long id_size = SIZE_pnp_device_id; |
501 | const unsigned int count = (size / id_size)-1; | 526 | const unsigned int count = (size / id_size)-1; |
502 | const struct pnp_device_id *devs = symval; | ||
503 | unsigned int i; | 527 | unsigned int i; |
504 | 528 | ||
505 | device_id_check(mod->name, "pnp", size, id_size, symval); | 529 | device_id_check(mod->name, "pnp", size, id_size, symval); |
506 | 530 | ||
507 | for (i = 0; i < count; i++) { | 531 | for (i = 0; i < count; i++) { |
508 | const char *id = (char *)devs[i].id; | 532 | DEF_FIELD_ADDR(symval + i*id_size, pnp_device_id, id); |
509 | char acpi_id[sizeof(devs[0].id)]; | 533 | char acpi_id[sizeof(*id)]; |
510 | int j; | 534 | int j; |
511 | 535 | ||
512 | buf_printf(&mod->dev_table_buf, | 536 | buf_printf(&mod->dev_table_buf, |
513 | "MODULE_ALIAS(\"pnp:d%s*\");\n", id); | 537 | "MODULE_ALIAS(\"pnp:d%s*\");\n", *id); |
514 | 538 | ||
515 | /* fix broken pnp bus lowercasing */ | 539 | /* fix broken pnp bus lowercasing */ |
516 | for (j = 0; j < sizeof(acpi_id); j++) | 540 | for (j = 0; j < sizeof(acpi_id); j++) |
517 | acpi_id[j] = toupper(id[j]); | 541 | acpi_id[j] = toupper((*id)[j]); |
518 | buf_printf(&mod->dev_table_buf, | 542 | buf_printf(&mod->dev_table_buf, |
519 | "MODULE_ALIAS(\"acpi*:%s:*\");\n", acpi_id); | 543 | "MODULE_ALIAS(\"acpi*:%s:*\");\n", acpi_id); |
520 | } | 544 | } |
@@ -524,19 +548,18 @@ static void do_pnp_device_entry(void *symval, unsigned long size, | |||
524 | static void do_pnp_card_entries(void *symval, unsigned long size, | 548 | static void do_pnp_card_entries(void *symval, unsigned long size, |
525 | struct module *mod) | 549 | struct module *mod) |
526 | { | 550 | { |
527 | const unsigned long id_size = sizeof(struct pnp_card_device_id); | 551 | const unsigned long id_size = SIZE_pnp_card_device_id; |
528 | const unsigned int count = (size / id_size)-1; | 552 | const unsigned int count = (size / id_size)-1; |
529 | const struct pnp_card_device_id *cards = symval; | ||
530 | unsigned int i; | 553 | unsigned int i; |
531 | 554 | ||
532 | device_id_check(mod->name, "pnp", size, id_size, symval); | 555 | device_id_check(mod->name, "pnp", size, id_size, symval); |
533 | 556 | ||
534 | for (i = 0; i < count; i++) { | 557 | for (i = 0; i < count; i++) { |
535 | unsigned int j; | 558 | unsigned int j; |
536 | const struct pnp_card_device_id *card = &cards[i]; | 559 | DEF_FIELD_ADDR(symval + i*id_size, pnp_card_device_id, devs); |
537 | 560 | ||
538 | for (j = 0; j < PNP_MAX_DEVICES; j++) { | 561 | for (j = 0; j < PNP_MAX_DEVICES; j++) { |
539 | const char *id = (char *)card->devs[j].id; | 562 | const char *id = (char *)(*devs)[j].id; |
540 | int i2, j2; | 563 | int i2, j2; |
541 | int dup = 0; | 564 | int dup = 0; |
542 | 565 | ||
@@ -545,10 +568,10 @@ static void do_pnp_card_entries(void *symval, unsigned long size, | |||
545 | 568 | ||
546 | /* find duplicate, already added value */ | 569 | /* find duplicate, already added value */ |
547 | for (i2 = 0; i2 < i && !dup; i2++) { | 570 | for (i2 = 0; i2 < i && !dup; i2++) { |
548 | const struct pnp_card_device_id *card2 = &cards[i2]; | 571 | DEF_FIELD_ADDR(symval + i2*id_size, pnp_card_device_id, devs); |
549 | 572 | ||
550 | for (j2 = 0; j2 < PNP_MAX_DEVICES; j2++) { | 573 | for (j2 = 0; j2 < PNP_MAX_DEVICES; j2++) { |
551 | const char *id2 = (char *)card2->devs[j2].id; | 574 | const char *id2 = (char *)(*devs)[j2].id; |
552 | 575 | ||
553 | if (!id2[0]) | 576 | if (!id2[0]) |
554 | break; | 577 | break; |
@@ -562,7 +585,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size, | |||
562 | 585 | ||
563 | /* add an individual alias for every device entry */ | 586 | /* add an individual alias for every device entry */ |
564 | if (!dup) { | 587 | if (!dup) { |
565 | char acpi_id[sizeof(card->devs[0].id)]; | 588 | char acpi_id[PNP_ID_LEN]; |
566 | int k; | 589 | int k; |
567 | 590 | ||
568 | buf_printf(&mod->dev_table_buf, | 591 | buf_printf(&mod->dev_table_buf, |
@@ -580,54 +603,58 @@ static void do_pnp_card_entries(void *symval, unsigned long size, | |||
580 | 603 | ||
581 | /* Looks like: pcmcia:mNcNfNfnNpfnNvaNvbNvcNvdN. */ | 604 | /* Looks like: pcmcia:mNcNfNfnNpfnNvaNvbNvcNvdN. */ |
582 | static int do_pcmcia_entry(const char *filename, | 605 | static int do_pcmcia_entry(const char *filename, |
583 | struct pcmcia_device_id *id, char *alias) | 606 | void *symval, char *alias) |
584 | { | 607 | { |
585 | unsigned int i; | 608 | unsigned int i; |
586 | 609 | DEF_FIELD(symval, pcmcia_device_id, match_flags); | |
587 | id->match_flags = TO_NATIVE(id->match_flags); | 610 | DEF_FIELD(symval, pcmcia_device_id, manf_id); |
588 | id->manf_id = TO_NATIVE(id->manf_id); | 611 | DEF_FIELD(symval, pcmcia_device_id, card_id); |
589 | id->card_id = TO_NATIVE(id->card_id); | 612 | DEF_FIELD(symval, pcmcia_device_id, func_id); |
590 | id->func_id = TO_NATIVE(id->func_id); | 613 | DEF_FIELD(symval, pcmcia_device_id, function); |
591 | id->function = TO_NATIVE(id->function); | 614 | DEF_FIELD(symval, pcmcia_device_id, device_no); |
592 | id->device_no = TO_NATIVE(id->device_no); | 615 | DEF_FIELD_ADDR(symval, pcmcia_device_id, prod_id_hash); |
593 | 616 | ||
594 | for (i=0; i<4; i++) { | 617 | for (i=0; i<4; i++) { |
595 | id->prod_id_hash[i] = TO_NATIVE(id->prod_id_hash[i]); | 618 | (*prod_id_hash)[i] = TO_NATIVE((*prod_id_hash)[i]); |
596 | } | 619 | } |
597 | 620 | ||
598 | strcpy(alias, "pcmcia:"); | 621 | strcpy(alias, "pcmcia:"); |
599 | ADD(alias, "m", id->match_flags & PCMCIA_DEV_ID_MATCH_MANF_ID, | 622 | ADD(alias, "m", match_flags & PCMCIA_DEV_ID_MATCH_MANF_ID, |
600 | id->manf_id); | 623 | manf_id); |
601 | ADD(alias, "c", id->match_flags & PCMCIA_DEV_ID_MATCH_CARD_ID, | 624 | ADD(alias, "c", match_flags & PCMCIA_DEV_ID_MATCH_CARD_ID, |
602 | id->card_id); | 625 | card_id); |
603 | ADD(alias, "f", id->match_flags & PCMCIA_DEV_ID_MATCH_FUNC_ID, | 626 | ADD(alias, "f", match_flags & PCMCIA_DEV_ID_MATCH_FUNC_ID, |
604 | id->func_id); | 627 | func_id); |
605 | ADD(alias, "fn", id->match_flags & PCMCIA_DEV_ID_MATCH_FUNCTION, | 628 | ADD(alias, "fn", match_flags & PCMCIA_DEV_ID_MATCH_FUNCTION, |
606 | id->function); | 629 | function); |
607 | ADD(alias, "pfn", id->match_flags & PCMCIA_DEV_ID_MATCH_DEVICE_NO, | 630 | ADD(alias, "pfn", match_flags & PCMCIA_DEV_ID_MATCH_DEVICE_NO, |
608 | id->device_no); | 631 | device_no); |
609 | ADD(alias, "pa", id->match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID1, id->prod_id_hash[0]); | 632 | ADD(alias, "pa", match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID1, (*prod_id_hash)[0]); |
610 | ADD(alias, "pb", id->match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID2, id->prod_id_hash[1]); | 633 | ADD(alias, "pb", match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID2, (*prod_id_hash)[1]); |
611 | ADD(alias, "pc", id->match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID3, id->prod_id_hash[2]); | 634 | ADD(alias, "pc", match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID3, (*prod_id_hash)[2]); |
612 | ADD(alias, "pd", id->match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID4, id->prod_id_hash[3]); | 635 | ADD(alias, "pd", match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID4, (*prod_id_hash)[3]); |
613 | 636 | ||
614 | add_wildcard(alias); | 637 | add_wildcard(alias); |
615 | return 1; | 638 | return 1; |
616 | } | 639 | } |
617 | ADD_TO_DEVTABLE("pcmcia", struct pcmcia_device_id, do_pcmcia_entry); | 640 | ADD_TO_DEVTABLE("pcmcia", pcmcia_device_id, do_pcmcia_entry); |
618 | 641 | ||
619 | static int do_of_entry (const char *filename, struct of_device_id *of, char *alias) | 642 | static int do_of_entry (const char *filename, void *symval, char *alias) |
620 | { | 643 | { |
621 | int len; | 644 | int len; |
622 | char *tmp; | 645 | char *tmp; |
646 | DEF_FIELD_ADDR(symval, of_device_id, name); | ||
647 | DEF_FIELD_ADDR(symval, of_device_id, type); | ||
648 | DEF_FIELD_ADDR(symval, of_device_id, compatible); | ||
649 | |||
623 | len = sprintf (alias, "of:N%sT%s", | 650 | len = sprintf (alias, "of:N%sT%s", |
624 | of->name[0] ? of->name : "*", | 651 | (*name)[0] ? *name : "*", |
625 | of->type[0] ? of->type : "*"); | 652 | (*type)[0] ? *type : "*"); |
626 | 653 | ||
627 | if (of->compatible[0]) | 654 | if (compatible[0]) |
628 | sprintf (&alias[len], "%sC%s", | 655 | sprintf (&alias[len], "%sC%s", |
629 | of->type[0] ? "*" : "", | 656 | (*type)[0] ? "*" : "", |
630 | of->compatible); | 657 | *compatible); |
631 | 658 | ||
632 | /* Replace all whitespace with underscores */ | 659 | /* Replace all whitespace with underscores */ |
633 | for (tmp = alias; tmp && *tmp; tmp++) | 660 | for (tmp = alias; tmp && *tmp; tmp++) |
@@ -637,15 +664,17 @@ static int do_of_entry (const char *filename, struct of_device_id *of, char *ali | |||
637 | add_wildcard(alias); | 664 | add_wildcard(alias); |
638 | return 1; | 665 | return 1; |
639 | } | 666 | } |
640 | ADD_TO_DEVTABLE("of", struct of_device_id, do_of_entry); | 667 | ADD_TO_DEVTABLE("of", of_device_id, do_of_entry); |
641 | 668 | ||
642 | static int do_vio_entry(const char *filename, struct vio_device_id *vio, | 669 | static int do_vio_entry(const char *filename, void *symval, |
643 | char *alias) | 670 | char *alias) |
644 | { | 671 | { |
645 | char *tmp; | 672 | char *tmp; |
673 | DEF_FIELD_ADDR(symval, vio_device_id, type); | ||
674 | DEF_FIELD_ADDR(symval, vio_device_id, compat); | ||
646 | 675 | ||
647 | sprintf(alias, "vio:T%sS%s", vio->type[0] ? vio->type : "*", | 676 | sprintf(alias, "vio:T%sS%s", (*type)[0] ? *type : "*", |
648 | vio->compat[0] ? vio->compat : "*"); | 677 | (*compat)[0] ? *compat : "*"); |
649 | 678 | ||
650 | /* Replace all whitespace with underscores */ | 679 | /* Replace all whitespace with underscores */ |
651 | for (tmp = alias; tmp && *tmp; tmp++) | 680 | for (tmp = alias; tmp && *tmp; tmp++) |
@@ -655,7 +684,7 @@ static int do_vio_entry(const char *filename, struct vio_device_id *vio, | |||
655 | add_wildcard(alias); | 684 | add_wildcard(alias); |
656 | return 1; | 685 | return 1; |
657 | } | 686 | } |
658 | ADD_TO_DEVTABLE("vio", struct vio_device_id, do_vio_entry); | 687 | ADD_TO_DEVTABLE("vio", vio_device_id, do_vio_entry); |
659 | 688 | ||
660 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) | 689 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) |
661 | 690 | ||
@@ -664,154 +693,172 @@ static void do_input(char *alias, | |||
664 | { | 693 | { |
665 | unsigned int i; | 694 | unsigned int i; |
666 | 695 | ||
696 | for (i = min / BITS_PER_LONG; i < max / BITS_PER_LONG + 1; i++) | ||
697 | arr[i] = TO_NATIVE(arr[i]); | ||
667 | for (i = min; i < max; i++) | 698 | for (i = min; i < max; i++) |
668 | if (arr[i / BITS_PER_LONG] & (1L << (i%BITS_PER_LONG))) | 699 | if (arr[i / BITS_PER_LONG] & (1L << (i%BITS_PER_LONG))) |
669 | sprintf(alias + strlen(alias), "%X,*", i); | 700 | sprintf(alias + strlen(alias), "%X,*", i); |
670 | } | 701 | } |
671 | 702 | ||
672 | /* input:b0v0p0e0-eXkXrXaXmXlXsXfXwX where X is comma-separated %02X. */ | 703 | /* input:b0v0p0e0-eXkXrXaXmXlXsXfXwX where X is comma-separated %02X. */ |
673 | static int do_input_entry(const char *filename, struct input_device_id *id, | 704 | static int do_input_entry(const char *filename, void *symval, |
674 | char *alias) | 705 | char *alias) |
675 | { | 706 | { |
707 | DEF_FIELD(symval, input_device_id, flags); | ||
708 | DEF_FIELD(symval, input_device_id, bustype); | ||
709 | DEF_FIELD(symval, input_device_id, vendor); | ||
710 | DEF_FIELD(symval, input_device_id, product); | ||
711 | DEF_FIELD(symval, input_device_id, version); | ||
712 | DEF_FIELD_ADDR(symval, input_device_id, evbit); | ||
713 | DEF_FIELD_ADDR(symval, input_device_id, keybit); | ||
714 | DEF_FIELD_ADDR(symval, input_device_id, relbit); | ||
715 | DEF_FIELD_ADDR(symval, input_device_id, absbit); | ||
716 | DEF_FIELD_ADDR(symval, input_device_id, mscbit); | ||
717 | DEF_FIELD_ADDR(symval, input_device_id, ledbit); | ||
718 | DEF_FIELD_ADDR(symval, input_device_id, sndbit); | ||
719 | DEF_FIELD_ADDR(symval, input_device_id, ffbit); | ||
720 | DEF_FIELD_ADDR(symval, input_device_id, swbit); | ||
721 | |||
676 | sprintf(alias, "input:"); | 722 | sprintf(alias, "input:"); |
677 | 723 | ||
678 | ADD(alias, "b", id->flags & INPUT_DEVICE_ID_MATCH_BUS, id->bustype); | 724 | ADD(alias, "b", flags & INPUT_DEVICE_ID_MATCH_BUS, bustype); |
679 | ADD(alias, "v", id->flags & INPUT_DEVICE_ID_MATCH_VENDOR, id->vendor); | 725 | ADD(alias, "v", flags & INPUT_DEVICE_ID_MATCH_VENDOR, vendor); |
680 | ADD(alias, "p", id->flags & INPUT_DEVICE_ID_MATCH_PRODUCT, id->product); | 726 | ADD(alias, "p", flags & INPUT_DEVICE_ID_MATCH_PRODUCT, product); |
681 | ADD(alias, "e", id->flags & INPUT_DEVICE_ID_MATCH_VERSION, id->version); | 727 | ADD(alias, "e", flags & INPUT_DEVICE_ID_MATCH_VERSION, version); |
682 | 728 | ||
683 | sprintf(alias + strlen(alias), "-e*"); | 729 | sprintf(alias + strlen(alias), "-e*"); |
684 | if (id->flags & INPUT_DEVICE_ID_MATCH_EVBIT) | 730 | if (flags & INPUT_DEVICE_ID_MATCH_EVBIT) |
685 | do_input(alias, id->evbit, 0, INPUT_DEVICE_ID_EV_MAX); | 731 | do_input(alias, *evbit, 0, INPUT_DEVICE_ID_EV_MAX); |
686 | sprintf(alias + strlen(alias), "k*"); | 732 | sprintf(alias + strlen(alias), "k*"); |
687 | if (id->flags & INPUT_DEVICE_ID_MATCH_KEYBIT) | 733 | if (flags & INPUT_DEVICE_ID_MATCH_KEYBIT) |
688 | do_input(alias, id->keybit, | 734 | do_input(alias, *keybit, |
689 | INPUT_DEVICE_ID_KEY_MIN_INTERESTING, | 735 | INPUT_DEVICE_ID_KEY_MIN_INTERESTING, |
690 | INPUT_DEVICE_ID_KEY_MAX); | 736 | INPUT_DEVICE_ID_KEY_MAX); |
691 | sprintf(alias + strlen(alias), "r*"); | 737 | sprintf(alias + strlen(alias), "r*"); |
692 | if (id->flags & INPUT_DEVICE_ID_MATCH_RELBIT) | 738 | if (flags & INPUT_DEVICE_ID_MATCH_RELBIT) |
693 | do_input(alias, id->relbit, 0, INPUT_DEVICE_ID_REL_MAX); | 739 | do_input(alias, *relbit, 0, INPUT_DEVICE_ID_REL_MAX); |
694 | sprintf(alias + strlen(alias), "a*"); | 740 | sprintf(alias + strlen(alias), "a*"); |
695 | if (id->flags & INPUT_DEVICE_ID_MATCH_ABSBIT) | 741 | if (flags & INPUT_DEVICE_ID_MATCH_ABSBIT) |
696 | do_input(alias, id->absbit, 0, INPUT_DEVICE_ID_ABS_MAX); | 742 | do_input(alias, *absbit, 0, INPUT_DEVICE_ID_ABS_MAX); |
697 | sprintf(alias + strlen(alias), "m*"); | 743 | sprintf(alias + strlen(alias), "m*"); |
698 | if (id->flags & INPUT_DEVICE_ID_MATCH_MSCIT) | 744 | if (flags & INPUT_DEVICE_ID_MATCH_MSCIT) |
699 | do_input(alias, id->mscbit, 0, INPUT_DEVICE_ID_MSC_MAX); | 745 | do_input(alias, *mscbit, 0, INPUT_DEVICE_ID_MSC_MAX); |
700 | sprintf(alias + strlen(alias), "l*"); | 746 | sprintf(alias + strlen(alias), "l*"); |
701 | if (id->flags & INPUT_DEVICE_ID_MATCH_LEDBIT) | 747 | if (flags & INPUT_DEVICE_ID_MATCH_LEDBIT) |
702 | do_input(alias, id->ledbit, 0, INPUT_DEVICE_ID_LED_MAX); | 748 | do_input(alias, *ledbit, 0, INPUT_DEVICE_ID_LED_MAX); |
703 | sprintf(alias + strlen(alias), "s*"); | 749 | sprintf(alias + strlen(alias), "s*"); |
704 | if (id->flags & INPUT_DEVICE_ID_MATCH_SNDBIT) | 750 | if (flags & INPUT_DEVICE_ID_MATCH_SNDBIT) |
705 | do_input(alias, id->sndbit, 0, INPUT_DEVICE_ID_SND_MAX); | 751 | do_input(alias, *sndbit, 0, INPUT_DEVICE_ID_SND_MAX); |
706 | sprintf(alias + strlen(alias), "f*"); | 752 | sprintf(alias + strlen(alias), "f*"); |
707 | if (id->flags & INPUT_DEVICE_ID_MATCH_FFBIT) | 753 | if (flags & INPUT_DEVICE_ID_MATCH_FFBIT) |
708 | do_input(alias, id->ffbit, 0, INPUT_DEVICE_ID_FF_MAX); | 754 | do_input(alias, *ffbit, 0, INPUT_DEVICE_ID_FF_MAX); |
709 | sprintf(alias + strlen(alias), "w*"); | 755 | sprintf(alias + strlen(alias), "w*"); |
710 | if (id->flags & INPUT_DEVICE_ID_MATCH_SWBIT) | 756 | if (flags & INPUT_DEVICE_ID_MATCH_SWBIT) |
711 | do_input(alias, id->swbit, 0, INPUT_DEVICE_ID_SW_MAX); | 757 | do_input(alias, *swbit, 0, INPUT_DEVICE_ID_SW_MAX); |
712 | return 1; | 758 | return 1; |
713 | } | 759 | } |
714 | ADD_TO_DEVTABLE("input", struct input_device_id, do_input_entry); | 760 | ADD_TO_DEVTABLE("input", input_device_id, do_input_entry); |
715 | 761 | ||
716 | static int do_eisa_entry(const char *filename, struct eisa_device_id *eisa, | 762 | static int do_eisa_entry(const char *filename, void *symval, |
717 | char *alias) | 763 | char *alias) |
718 | { | 764 | { |
719 | if (eisa->sig[0]) | 765 | DEF_FIELD_ADDR(symval, eisa_device_id, sig); |
720 | sprintf(alias, EISA_DEVICE_MODALIAS_FMT "*", eisa->sig); | 766 | if (sig[0]) |
767 | sprintf(alias, EISA_DEVICE_MODALIAS_FMT "*", *sig); | ||
721 | else | 768 | else |
722 | strcat(alias, "*"); | 769 | strcat(alias, "*"); |
723 | return 1; | 770 | return 1; |
724 | } | 771 | } |
725 | ADD_TO_DEVTABLE("eisa", struct eisa_device_id, do_eisa_entry); | 772 | ADD_TO_DEVTABLE("eisa", eisa_device_id, do_eisa_entry); |
726 | 773 | ||
727 | /* Looks like: parisc:tNhvNrevNsvN */ | 774 | /* Looks like: parisc:tNhvNrevNsvN */ |
728 | static int do_parisc_entry(const char *filename, struct parisc_device_id *id, | 775 | static int do_parisc_entry(const char *filename, void *symval, |
729 | char *alias) | 776 | char *alias) |
730 | { | 777 | { |
731 | id->hw_type = TO_NATIVE(id->hw_type); | 778 | DEF_FIELD(symval, parisc_device_id, hw_type); |
732 | id->hversion = TO_NATIVE(id->hversion); | 779 | DEF_FIELD(symval, parisc_device_id, hversion); |
733 | id->hversion_rev = TO_NATIVE(id->hversion_rev); | 780 | DEF_FIELD(symval, parisc_device_id, hversion_rev); |
734 | id->sversion = TO_NATIVE(id->sversion); | 781 | DEF_FIELD(symval, parisc_device_id, sversion); |
735 | 782 | ||
736 | strcpy(alias, "parisc:"); | 783 | strcpy(alias, "parisc:"); |
737 | ADD(alias, "t", id->hw_type != PA_HWTYPE_ANY_ID, id->hw_type); | 784 | ADD(alias, "t", hw_type != PA_HWTYPE_ANY_ID, hw_type); |
738 | ADD(alias, "hv", id->hversion != PA_HVERSION_ANY_ID, id->hversion); | 785 | ADD(alias, "hv", hversion != PA_HVERSION_ANY_ID, hversion); |
739 | ADD(alias, "rev", id->hversion_rev != PA_HVERSION_REV_ANY_ID, id->hversion_rev); | 786 | ADD(alias, "rev", hversion_rev != PA_HVERSION_REV_ANY_ID, hversion_rev); |
740 | ADD(alias, "sv", id->sversion != PA_SVERSION_ANY_ID, id->sversion); | 787 | ADD(alias, "sv", sversion != PA_SVERSION_ANY_ID, sversion); |
741 | 788 | ||
742 | add_wildcard(alias); | 789 | add_wildcard(alias); |
743 | return 1; | 790 | return 1; |
744 | } | 791 | } |
745 | ADD_TO_DEVTABLE("parisc", struct parisc_device_id, do_parisc_entry); | 792 | ADD_TO_DEVTABLE("parisc", parisc_device_id, do_parisc_entry); |
746 | 793 | ||
747 | /* Looks like: sdio:cNvNdN. */ | 794 | /* Looks like: sdio:cNvNdN. */ |
748 | static int do_sdio_entry(const char *filename, | 795 | static int do_sdio_entry(const char *filename, |
749 | struct sdio_device_id *id, char *alias) | 796 | void *symval, char *alias) |
750 | { | 797 | { |
751 | id->class = TO_NATIVE(id->class); | 798 | DEF_FIELD(symval, sdio_device_id, class); |
752 | id->vendor = TO_NATIVE(id->vendor); | 799 | DEF_FIELD(symval, sdio_device_id, vendor); |
753 | id->device = TO_NATIVE(id->device); | 800 | DEF_FIELD(symval, sdio_device_id, device); |
754 | 801 | ||
755 | strcpy(alias, "sdio:"); | 802 | strcpy(alias, "sdio:"); |
756 | ADD(alias, "c", id->class != (__u8)SDIO_ANY_ID, id->class); | 803 | ADD(alias, "c", class != (__u8)SDIO_ANY_ID, class); |
757 | ADD(alias, "v", id->vendor != (__u16)SDIO_ANY_ID, id->vendor); | 804 | ADD(alias, "v", vendor != (__u16)SDIO_ANY_ID, vendor); |
758 | ADD(alias, "d", id->device != (__u16)SDIO_ANY_ID, id->device); | 805 | ADD(alias, "d", device != (__u16)SDIO_ANY_ID, device); |
759 | add_wildcard(alias); | 806 | add_wildcard(alias); |
760 | return 1; | 807 | return 1; |
761 | } | 808 | } |
762 | ADD_TO_DEVTABLE("sdio", struct sdio_device_id, do_sdio_entry); | 809 | ADD_TO_DEVTABLE("sdio", sdio_device_id, do_sdio_entry); |
763 | 810 | ||
764 | /* Looks like: ssb:vNidNrevN. */ | 811 | /* Looks like: ssb:vNidNrevN. */ |
765 | static int do_ssb_entry(const char *filename, | 812 | static int do_ssb_entry(const char *filename, |
766 | struct ssb_device_id *id, char *alias) | 813 | void *symval, char *alias) |
767 | { | 814 | { |
768 | id->vendor = TO_NATIVE(id->vendor); | 815 | DEF_FIELD(symval, ssb_device_id, vendor); |
769 | id->coreid = TO_NATIVE(id->coreid); | 816 | DEF_FIELD(symval, ssb_device_id, coreid); |
770 | id->revision = TO_NATIVE(id->revision); | 817 | DEF_FIELD(symval, ssb_device_id, revision); |
771 | 818 | ||
772 | strcpy(alias, "ssb:"); | 819 | strcpy(alias, "ssb:"); |
773 | ADD(alias, "v", id->vendor != SSB_ANY_VENDOR, id->vendor); | 820 | ADD(alias, "v", vendor != SSB_ANY_VENDOR, vendor); |
774 | ADD(alias, "id", id->coreid != SSB_ANY_ID, id->coreid); | 821 | ADD(alias, "id", coreid != SSB_ANY_ID, coreid); |
775 | ADD(alias, "rev", id->revision != SSB_ANY_REV, id->revision); | 822 | ADD(alias, "rev", revision != SSB_ANY_REV, revision); |
776 | add_wildcard(alias); | 823 | add_wildcard(alias); |
777 | return 1; | 824 | return 1; |
778 | } | 825 | } |
779 | ADD_TO_DEVTABLE("ssb", struct ssb_device_id, do_ssb_entry); | 826 | ADD_TO_DEVTABLE("ssb", ssb_device_id, do_ssb_entry); |
780 | 827 | ||
781 | /* Looks like: bcma:mNidNrevNclN. */ | 828 | /* Looks like: bcma:mNidNrevNclN. */ |
782 | static int do_bcma_entry(const char *filename, | 829 | static int do_bcma_entry(const char *filename, |
783 | struct bcma_device_id *id, char *alias) | 830 | void *symval, char *alias) |
784 | { | 831 | { |
785 | id->manuf = TO_NATIVE(id->manuf); | 832 | DEF_FIELD(symval, bcma_device_id, manuf); |
786 | id->id = TO_NATIVE(id->id); | 833 | DEF_FIELD(symval, bcma_device_id, id); |
787 | id->rev = TO_NATIVE(id->rev); | 834 | DEF_FIELD(symval, bcma_device_id, rev); |
788 | id->class = TO_NATIVE(id->class); | 835 | DEF_FIELD(symval, bcma_device_id, class); |
789 | 836 | ||
790 | strcpy(alias, "bcma:"); | 837 | strcpy(alias, "bcma:"); |
791 | ADD(alias, "m", id->manuf != BCMA_ANY_MANUF, id->manuf); | 838 | ADD(alias, "m", manuf != BCMA_ANY_MANUF, manuf); |
792 | ADD(alias, "id", id->id != BCMA_ANY_ID, id->id); | 839 | ADD(alias, "id", id != BCMA_ANY_ID, id); |
793 | ADD(alias, "rev", id->rev != BCMA_ANY_REV, id->rev); | 840 | ADD(alias, "rev", rev != BCMA_ANY_REV, rev); |
794 | ADD(alias, "cl", id->class != BCMA_ANY_CLASS, id->class); | 841 | ADD(alias, "cl", class != BCMA_ANY_CLASS, class); |
795 | add_wildcard(alias); | 842 | add_wildcard(alias); |
796 | return 1; | 843 | return 1; |
797 | } | 844 | } |
798 | ADD_TO_DEVTABLE("bcma", struct bcma_device_id, do_bcma_entry); | 845 | ADD_TO_DEVTABLE("bcma", bcma_device_id, do_bcma_entry); |
799 | 846 | ||
800 | /* Looks like: virtio:dNvN */ | 847 | /* Looks like: virtio:dNvN */ |
801 | static int do_virtio_entry(const char *filename, struct virtio_device_id *id, | 848 | static int do_virtio_entry(const char *filename, void *symval, |
802 | char *alias) | 849 | char *alias) |
803 | { | 850 | { |
804 | id->device = TO_NATIVE(id->device); | 851 | DEF_FIELD(symval, virtio_device_id, device); |
805 | id->vendor = TO_NATIVE(id->vendor); | 852 | DEF_FIELD(symval, virtio_device_id, vendor); |
806 | 853 | ||
807 | strcpy(alias, "virtio:"); | 854 | strcpy(alias, "virtio:"); |
808 | ADD(alias, "d", id->device != VIRTIO_DEV_ANY_ID, id->device); | 855 | ADD(alias, "d", device != VIRTIO_DEV_ANY_ID, device); |
809 | ADD(alias, "v", id->vendor != VIRTIO_DEV_ANY_ID, id->vendor); | 856 | ADD(alias, "v", vendor != VIRTIO_DEV_ANY_ID, vendor); |
810 | 857 | ||
811 | add_wildcard(alias); | 858 | add_wildcard(alias); |
812 | return 1; | 859 | return 1; |
813 | } | 860 | } |
814 | ADD_TO_DEVTABLE("virtio", struct virtio_device_id, do_virtio_entry); | 861 | ADD_TO_DEVTABLE("virtio", virtio_device_id, do_virtio_entry); |
815 | 862 | ||
816 | /* | 863 | /* |
817 | * Looks like: vmbus:guid | 864 | * Looks like: vmbus:guid |
@@ -819,41 +866,44 @@ ADD_TO_DEVTABLE("virtio", struct virtio_device_id, do_virtio_entry); | |||
819 | * in the name. | 866 | * in the name. |
820 | */ | 867 | */ |
821 | 868 | ||
822 | static int do_vmbus_entry(const char *filename, struct hv_vmbus_device_id *id, | 869 | static int do_vmbus_entry(const char *filename, void *symval, |
823 | char *alias) | 870 | char *alias) |
824 | { | 871 | { |
825 | int i; | 872 | int i; |
826 | char guid_name[((sizeof(id->guid) + 1)) * 2]; | 873 | DEF_FIELD_ADDR(symval, hv_vmbus_device_id, guid); |
874 | char guid_name[(sizeof(*guid) + 1) * 2]; | ||
827 | 875 | ||
828 | for (i = 0; i < (sizeof(id->guid) * 2); i += 2) | 876 | for (i = 0; i < (sizeof(*guid) * 2); i += 2) |
829 | sprintf(&guid_name[i], "%02x", id->guid[i/2]); | 877 | sprintf(&guid_name[i], "%02x", TO_NATIVE((*guid)[i/2])); |
830 | 878 | ||
831 | strcpy(alias, "vmbus:"); | 879 | strcpy(alias, "vmbus:"); |
832 | strcat(alias, guid_name); | 880 | strcat(alias, guid_name); |
833 | 881 | ||
834 | return 1; | 882 | return 1; |
835 | } | 883 | } |
836 | ADD_TO_DEVTABLE("vmbus", struct hv_vmbus_device_id, do_vmbus_entry); | 884 | ADD_TO_DEVTABLE("vmbus", hv_vmbus_device_id, do_vmbus_entry); |
837 | 885 | ||
838 | /* Looks like: i2c:S */ | 886 | /* Looks like: i2c:S */ |
839 | static int do_i2c_entry(const char *filename, struct i2c_device_id *id, | 887 | static int do_i2c_entry(const char *filename, void *symval, |
840 | char *alias) | 888 | char *alias) |
841 | { | 889 | { |
842 | sprintf(alias, I2C_MODULE_PREFIX "%s", id->name); | 890 | DEF_FIELD_ADDR(symval, i2c_device_id, name); |
891 | sprintf(alias, I2C_MODULE_PREFIX "%s", *name); | ||
843 | 892 | ||
844 | return 1; | 893 | return 1; |
845 | } | 894 | } |
846 | ADD_TO_DEVTABLE("i2c", struct i2c_device_id, do_i2c_entry); | 895 | ADD_TO_DEVTABLE("i2c", i2c_device_id, do_i2c_entry); |
847 | 896 | ||
848 | /* Looks like: spi:S */ | 897 | /* Looks like: spi:S */ |
849 | static int do_spi_entry(const char *filename, struct spi_device_id *id, | 898 | static int do_spi_entry(const char *filename, void *symval, |
850 | char *alias) | 899 | char *alias) |
851 | { | 900 | { |
852 | sprintf(alias, SPI_MODULE_PREFIX "%s", id->name); | 901 | DEF_FIELD_ADDR(symval, spi_device_id, name); |
902 | sprintf(alias, SPI_MODULE_PREFIX "%s", *name); | ||
853 | 903 | ||
854 | return 1; | 904 | return 1; |
855 | } | 905 | } |
856 | ADD_TO_DEVTABLE("spi", struct spi_device_id, do_spi_entry); | 906 | ADD_TO_DEVTABLE("spi", spi_device_id, do_spi_entry); |
857 | 907 | ||
858 | static const struct dmifield { | 908 | static const struct dmifield { |
859 | const char *prefix; | 909 | const char *prefix; |
@@ -885,21 +935,21 @@ static void dmi_ascii_filter(char *d, const char *s) | |||
885 | } | 935 | } |
886 | 936 | ||
887 | 937 | ||
888 | static int do_dmi_entry(const char *filename, struct dmi_system_id *id, | 938 | static int do_dmi_entry(const char *filename, void *symval, |
889 | char *alias) | 939 | char *alias) |
890 | { | 940 | { |
891 | int i, j; | 941 | int i, j; |
892 | 942 | DEF_FIELD_ADDR(symval, dmi_system_id, matches); | |
893 | sprintf(alias, "dmi*"); | 943 | sprintf(alias, "dmi*"); |
894 | 944 | ||
895 | for (i = 0; i < ARRAY_SIZE(dmi_fields); i++) { | 945 | for (i = 0; i < ARRAY_SIZE(dmi_fields); i++) { |
896 | for (j = 0; j < 4; j++) { | 946 | for (j = 0; j < 4; j++) { |
897 | if (id->matches[j].slot && | 947 | if ((*matches)[j].slot && |
898 | id->matches[j].slot == dmi_fields[i].field) { | 948 | (*matches)[j].slot == dmi_fields[i].field) { |
899 | sprintf(alias + strlen(alias), ":%s*", | 949 | sprintf(alias + strlen(alias), ":%s*", |
900 | dmi_fields[i].prefix); | 950 | dmi_fields[i].prefix); |
901 | dmi_ascii_filter(alias + strlen(alias), | 951 | dmi_ascii_filter(alias + strlen(alias), |
902 | id->matches[j].substr); | 952 | (*matches)[j].substr); |
903 | strcat(alias, "*"); | 953 | strcat(alias, "*"); |
904 | } | 954 | } |
905 | } | 955 | } |
@@ -908,27 +958,30 @@ static int do_dmi_entry(const char *filename, struct dmi_system_id *id, | |||
908 | strcat(alias, ":"); | 958 | strcat(alias, ":"); |
909 | return 1; | 959 | return 1; |
910 | } | 960 | } |
911 | ADD_TO_DEVTABLE("dmi", struct dmi_system_id, do_dmi_entry); | 961 | ADD_TO_DEVTABLE("dmi", dmi_system_id, do_dmi_entry); |
912 | 962 | ||
913 | static int do_platform_entry(const char *filename, | 963 | static int do_platform_entry(const char *filename, |
914 | struct platform_device_id *id, char *alias) | 964 | void *symval, char *alias) |
915 | { | 965 | { |
916 | sprintf(alias, PLATFORM_MODULE_PREFIX "%s", id->name); | 966 | DEF_FIELD_ADDR(symval, platform_device_id, name); |
967 | sprintf(alias, PLATFORM_MODULE_PREFIX "%s", *name); | ||
917 | return 1; | 968 | return 1; |
918 | } | 969 | } |
919 | ADD_TO_DEVTABLE("platform", struct platform_device_id, do_platform_entry); | 970 | ADD_TO_DEVTABLE("platform", platform_device_id, do_platform_entry); |
920 | 971 | ||
921 | static int do_mdio_entry(const char *filename, | 972 | static int do_mdio_entry(const char *filename, |
922 | struct mdio_device_id *id, char *alias) | 973 | void *symval, char *alias) |
923 | { | 974 | { |
924 | int i; | 975 | int i; |
976 | DEF_FIELD(symval, mdio_device_id, phy_id); | ||
977 | DEF_FIELD(symval, mdio_device_id, phy_id_mask); | ||
925 | 978 | ||
926 | alias += sprintf(alias, MDIO_MODULE_PREFIX); | 979 | alias += sprintf(alias, MDIO_MODULE_PREFIX); |
927 | 980 | ||
928 | for (i = 0; i < 32; i++) { | 981 | for (i = 0; i < 32; i++) { |
929 | if (!((id->phy_id_mask >> (31-i)) & 1)) | 982 | if (!((phy_id_mask >> (31-i)) & 1)) |
930 | *(alias++) = '?'; | 983 | *(alias++) = '?'; |
931 | else if ((id->phy_id >> (31-i)) & 1) | 984 | else if ((phy_id >> (31-i)) & 1) |
932 | *(alias++) = '1'; | 985 | *(alias++) = '1'; |
933 | else | 986 | else |
934 | *(alias++) = '0'; | 987 | *(alias++) = '0'; |
@@ -939,47 +992,50 @@ static int do_mdio_entry(const char *filename, | |||
939 | 992 | ||
940 | return 1; | 993 | return 1; |
941 | } | 994 | } |
942 | ADD_TO_DEVTABLE("mdio", struct mdio_device_id, do_mdio_entry); | 995 | ADD_TO_DEVTABLE("mdio", mdio_device_id, do_mdio_entry); |
943 | 996 | ||
944 | /* Looks like: zorro:iN. */ | 997 | /* Looks like: zorro:iN. */ |
945 | static int do_zorro_entry(const char *filename, struct zorro_device_id *id, | 998 | static int do_zorro_entry(const char *filename, void *symval, |
946 | char *alias) | 999 | char *alias) |
947 | { | 1000 | { |
948 | id->id = TO_NATIVE(id->id); | 1001 | DEF_FIELD(symval, zorro_device_id, id); |
949 | strcpy(alias, "zorro:"); | 1002 | strcpy(alias, "zorro:"); |
950 | ADD(alias, "i", id->id != ZORRO_WILDCARD, id->id); | 1003 | ADD(alias, "i", id != ZORRO_WILDCARD, id); |
951 | return 1; | 1004 | return 1; |
952 | } | 1005 | } |
953 | ADD_TO_DEVTABLE("zorro", struct zorro_device_id, do_zorro_entry); | 1006 | ADD_TO_DEVTABLE("zorro", zorro_device_id, do_zorro_entry); |
954 | 1007 | ||
955 | /* looks like: "pnp:dD" */ | 1008 | /* looks like: "pnp:dD" */ |
956 | static int do_isapnp_entry(const char *filename, | 1009 | static int do_isapnp_entry(const char *filename, |
957 | struct isapnp_device_id *id, char *alias) | 1010 | void *symval, char *alias) |
958 | { | 1011 | { |
1012 | DEF_FIELD(symval, isapnp_device_id, vendor); | ||
1013 | DEF_FIELD(symval, isapnp_device_id, function); | ||
959 | sprintf(alias, "pnp:d%c%c%c%x%x%x%x*", | 1014 | sprintf(alias, "pnp:d%c%c%c%x%x%x%x*", |
960 | 'A' + ((id->vendor >> 2) & 0x3f) - 1, | 1015 | 'A' + ((vendor >> 2) & 0x3f) - 1, |
961 | 'A' + (((id->vendor & 3) << 3) | ((id->vendor >> 13) & 7)) - 1, | 1016 | 'A' + (((vendor & 3) << 3) | ((vendor >> 13) & 7)) - 1, |
962 | 'A' + ((id->vendor >> 8) & 0x1f) - 1, | 1017 | 'A' + ((vendor >> 8) & 0x1f) - 1, |
963 | (id->function >> 4) & 0x0f, id->function & 0x0f, | 1018 | (function >> 4) & 0x0f, function & 0x0f, |
964 | (id->function >> 12) & 0x0f, (id->function >> 8) & 0x0f); | 1019 | (function >> 12) & 0x0f, (function >> 8) & 0x0f); |
965 | return 1; | 1020 | return 1; |
966 | } | 1021 | } |
967 | ADD_TO_DEVTABLE("isapnp", struct isapnp_device_id, do_isapnp_entry); | 1022 | ADD_TO_DEVTABLE("isapnp", isapnp_device_id, do_isapnp_entry); |
968 | 1023 | ||
969 | /* Looks like: "ipack:fNvNdN". */ | 1024 | /* Looks like: "ipack:fNvNdN". */ |
970 | static int do_ipack_entry(const char *filename, | 1025 | static int do_ipack_entry(const char *filename, |
971 | struct ipack_device_id *id, char *alias) | 1026 | void *symval, char *alias) |
972 | { | 1027 | { |
973 | id->vendor = TO_NATIVE(id->vendor); | 1028 | DEF_FIELD(symval, ipack_device_id, format); |
974 | id->device = TO_NATIVE(id->device); | 1029 | DEF_FIELD(symval, ipack_device_id, vendor); |
1030 | DEF_FIELD(symval, ipack_device_id, device); | ||
975 | strcpy(alias, "ipack:"); | 1031 | strcpy(alias, "ipack:"); |
976 | ADD(alias, "f", id->format != IPACK_ANY_FORMAT, id->format); | 1032 | ADD(alias, "f", format != IPACK_ANY_FORMAT, format); |
977 | ADD(alias, "v", id->vendor != IPACK_ANY_ID, id->vendor); | 1033 | ADD(alias, "v", vendor != IPACK_ANY_ID, vendor); |
978 | ADD(alias, "d", id->device != IPACK_ANY_ID, id->device); | 1034 | ADD(alias, "d", device != IPACK_ANY_ID, device); |
979 | add_wildcard(alias); | 1035 | add_wildcard(alias); |
980 | return 1; | 1036 | return 1; |
981 | } | 1037 | } |
982 | ADD_TO_DEVTABLE("ipack", struct ipack_device_id, do_ipack_entry); | 1038 | ADD_TO_DEVTABLE("ipack", ipack_device_id, do_ipack_entry); |
983 | 1039 | ||
984 | /* | 1040 | /* |
985 | * Append a match expression for a single masked hex digit. | 1041 | * Append a match expression for a single masked hex digit. |
@@ -1030,25 +1086,27 @@ static void append_nibble_mask(char **outp, | |||
1030 | * a ? or [] pattern matching exactly one digit. | 1086 | * a ? or [] pattern matching exactly one digit. |
1031 | */ | 1087 | */ |
1032 | static int do_amba_entry(const char *filename, | 1088 | static int do_amba_entry(const char *filename, |
1033 | struct amba_id *id, char *alias) | 1089 | void *symval, char *alias) |
1034 | { | 1090 | { |
1035 | unsigned int digit; | 1091 | unsigned int digit; |
1036 | char *p = alias; | 1092 | char *p = alias; |
1093 | DEF_FIELD(symval, amba_id, id); | ||
1094 | DEF_FIELD(symval, amba_id, mask); | ||
1037 | 1095 | ||
1038 | if ((id->id & id->mask) != id->id) | 1096 | if ((id & mask) != id) |
1039 | fatal("%s: Masked-off bit(s) of AMBA device ID are non-zero: " | 1097 | fatal("%s: Masked-off bit(s) of AMBA device ID are non-zero: " |
1040 | "id=0x%08X, mask=0x%08X. Please fix this driver.\n", | 1098 | "id=0x%08X, mask=0x%08X. Please fix this driver.\n", |
1041 | filename, id->id, id->mask); | 1099 | filename, id, mask); |
1042 | 1100 | ||
1043 | p += sprintf(alias, "amba:d"); | 1101 | p += sprintf(alias, "amba:d"); |
1044 | for (digit = 0; digit < 8; digit++) | 1102 | for (digit = 0; digit < 8; digit++) |
1045 | append_nibble_mask(&p, | 1103 | append_nibble_mask(&p, |
1046 | (id->id >> (4 * (7 - digit))) & 0xf, | 1104 | (id >> (4 * (7 - digit))) & 0xf, |
1047 | (id->mask >> (4 * (7 - digit))) & 0xf); | 1105 | (mask >> (4 * (7 - digit))) & 0xf); |
1048 | 1106 | ||
1049 | return 1; | 1107 | return 1; |
1050 | } | 1108 | } |
1051 | ADD_TO_DEVTABLE("amba", struct amba_id, do_amba_entry); | 1109 | ADD_TO_DEVTABLE("amba", amba_id, do_amba_entry); |
1052 | 1110 | ||
1053 | /* LOOKS like x86cpu:vendor:VVVV:family:FFFF:model:MMMM:feature:*,FEAT,* | 1111 | /* LOOKS like x86cpu:vendor:VVVV:family:FFFF:model:MMMM:feature:*,FEAT,* |
1054 | * All fields are numbers. It would be nicer to use strings for vendor | 1112 | * All fields are numbers. It would be nicer to use strings for vendor |
@@ -1056,24 +1114,24 @@ ADD_TO_DEVTABLE("amba", struct amba_id, do_amba_entry); | |||
1056 | * complicated. | 1114 | * complicated. |
1057 | */ | 1115 | */ |
1058 | 1116 | ||
1059 | static int do_x86cpu_entry(const char *filename, struct x86_cpu_id *id, | 1117 | static int do_x86cpu_entry(const char *filename, void *symval, |
1060 | char *alias) | 1118 | char *alias) |
1061 | { | 1119 | { |
1062 | id->feature = TO_NATIVE(id->feature); | 1120 | DEF_FIELD(symval, x86_cpu_id, feature); |
1063 | id->family = TO_NATIVE(id->family); | 1121 | DEF_FIELD(symval, x86_cpu_id, family); |
1064 | id->model = TO_NATIVE(id->model); | 1122 | DEF_FIELD(symval, x86_cpu_id, model); |
1065 | id->vendor = TO_NATIVE(id->vendor); | 1123 | DEF_FIELD(symval, x86_cpu_id, vendor); |
1066 | 1124 | ||
1067 | strcpy(alias, "x86cpu:"); | 1125 | strcpy(alias, "x86cpu:"); |
1068 | ADD(alias, "vendor:", id->vendor != X86_VENDOR_ANY, id->vendor); | 1126 | ADD(alias, "vendor:", vendor != X86_VENDOR_ANY, vendor); |
1069 | ADD(alias, ":family:", id->family != X86_FAMILY_ANY, id->family); | 1127 | ADD(alias, ":family:", family != X86_FAMILY_ANY, family); |
1070 | ADD(alias, ":model:", id->model != X86_MODEL_ANY, id->model); | 1128 | ADD(alias, ":model:", model != X86_MODEL_ANY, model); |
1071 | strcat(alias, ":feature:*"); | 1129 | strcat(alias, ":feature:*"); |
1072 | if (id->feature != X86_FEATURE_ANY) | 1130 | if (feature != X86_FEATURE_ANY) |
1073 | sprintf(alias + strlen(alias), "%04X*", id->feature); | 1131 | sprintf(alias + strlen(alias), "%04X*", feature); |
1074 | return 1; | 1132 | return 1; |
1075 | } | 1133 | } |
1076 | ADD_TO_DEVTABLE("x86cpu", struct x86_cpu_id, do_x86cpu_entry); | 1134 | ADD_TO_DEVTABLE("x86cpu", x86_cpu_id, do_x86cpu_entry); |
1077 | 1135 | ||
1078 | /* Does namelen bytes of name exactly match the symbol? */ | 1136 | /* Does namelen bytes of name exactly match the symbol? */ |
1079 | static bool sym_is(const char *name, unsigned namelen, const char *symbol) | 1137 | static bool sym_is(const char *name, unsigned namelen, const char *symbol) |
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 1c6fbb1a4f8e..78b30c1548e9 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c | |||
@@ -2128,7 +2128,7 @@ int main(int argc, char **argv) | |||
2128 | struct ext_sym_list *extsym_iter; | 2128 | struct ext_sym_list *extsym_iter; |
2129 | struct ext_sym_list *extsym_start = NULL; | 2129 | struct ext_sym_list *extsym_start = NULL; |
2130 | 2130 | ||
2131 | while ((opt = getopt(argc, argv, "i:I:e:cmsSo:awM:K:")) != -1) { | 2131 | while ((opt = getopt(argc, argv, "i:I:e:msSo:awM:K:")) != -1) { |
2132 | switch (opt) { | 2132 | switch (opt) { |
2133 | case 'i': | 2133 | case 'i': |
2134 | kernel_read = optarg; | 2134 | kernel_read = optarg; |
@@ -2137,9 +2137,6 @@ int main(int argc, char **argv) | |||
2137 | module_read = optarg; | 2137 | module_read = optarg; |
2138 | external_module = 1; | 2138 | external_module = 1; |
2139 | break; | 2139 | break; |
2140 | case 'c': | ||
2141 | cross_build = 1; | ||
2142 | break; | ||
2143 | case 'e': | 2140 | case 'e': |
2144 | external_module = 1; | 2141 | external_module = 1; |
2145 | extsym_iter = | 2142 | extsym_iter = |
diff --git a/scripts/setlocalversion b/scripts/setlocalversion index bd6dca8a0ab2..84b88f109b80 100755 --- a/scripts/setlocalversion +++ b/scripts/setlocalversion | |||
@@ -108,7 +108,7 @@ scm_version() | |||
108 | fi | 108 | fi |
109 | 109 | ||
110 | # Check for svn and a svn repo. | 110 | # Check for svn and a svn repo. |
111 | if rev=`svn info 2>/dev/null | grep '^Last Changed Rev'`; then | 111 | if rev=`LANG= LC_ALL= LC_MESSAGES=C svn info 2>/dev/null | grep '^Last Changed Rev'`; then |
112 | rev=`echo $rev | awk '{print $NF}'` | 112 | rev=`echo $rev | awk '{print $NF}'` |
113 | printf -- '-svn%s' "$rev" | 113 | printf -- '-svn%s' "$rev" |
114 | 114 | ||