diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-27 12:25:47 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-27 12:25:47 -0800 |
commit | 0ca7ffb356063c5ece847687da457dfe748612a2 (patch) | |
tree | f7858236ba482814c8cacf45447a3f96548a1688 | |
parent | 30acd906b02470e7eb346401de966a33864d9af4 (diff) | |
parent | 423a8155facf23719078ff63911c1e85ba40970b (diff) | |
download | lwn-0ca7ffb356063c5ece847687da457dfe748612a2.tar.gz lwn-0ca7ffb356063c5ece847687da457dfe748612a2.zip |
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/ \ # "make" in the configured kernel build directory always uses that. # Default value for CROSS_COMPILE is not to prefix executables # Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile -export KBUILD_BUILDHOST := $(SUBARCH) ARCH ?= $(SUBARCH) CROSS_COMPILE ?= $(CONFIG_CROSS_COMPILE:"%"=%) @@ -620,7 +619,8 @@ KBUILD_AFLAGS += -gdwarf-2 endif ifdef CONFIG_DEBUG_INFO_REDUCED -KBUILD_CFLAGS += $(call cc-option, -femit-struct-debug-baseonly) +KBUILD_CFLAGS += $(call cc-option, -femit-struct-debug-baseonly) \ + $(call cc-option,-fno-var-tracking) endif ifdef CONFIG_FUNCTION_TRACER @@ -1398,7 +1398,7 @@ quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files)) # Run depmod only if we have System.map and depmod is executable quiet_cmd_depmod = DEPMOD $(KERNELRELEASE) cmd_depmod = $(CONFIG_SHELL) $(srctree)/scripts/depmod.sh $(DEPMOD) \ - $(KERNELRELEASE) + $(KERNELRELEASE) "$(patsubst "%",%,$(CONFIG_SYMBOL_PREFIX))" # Create temporary dir for module support files # 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 { __u32 model_id; __u32 specifier_id; __u32 version; - kernel_ulong_t driver_data - __attribute__((aligned(sizeof(kernel_ulong_t)))); + kernel_ulong_t driver_data; }; @@ -148,8 +147,7 @@ struct hid_device_id { __u16 group; __u32 vendor; __u32 product; - kernel_ulong_t driver_data - __attribute__((aligned(sizeof(kernel_ulong_t)))); + kernel_ulong_t driver_data; }; /* s390 CCW devices */ @@ -173,8 +171,6 @@ struct ccw_device_id { struct ap_device_id { __u16 match_flags; /* which fields to match against */ __u8 dev_type; /* device type */ - __u8 pad1; - __u32 pad2; kernel_ulong_t driver_info; }; @@ -184,13 +180,10 @@ struct ap_device_id { struct css_device_id { __u8 match_flags; __u8 type; /* subchannel type */ - __u16 pad2; - __u32 pad3; kernel_ulong_t driver_data; }; -#define ACPI_ID_LEN 16 /* only 9 bytes needed here, 16 bytes are used */ - /* to workaround crosscompile issues */ +#define ACPI_ID_LEN 9 struct acpi_device_id { __u8 id[ACPI_ID_LEN]; @@ -231,11 +224,7 @@ struct of_device_id char name[32]; char type[32]; char compatible[128]; -#ifdef __KERNEL__ const void *data; -#else - kernel_ulong_t data; -#endif }; /* VIO */ @@ -260,24 +249,14 @@ struct pcmcia_device_id { /* for pseudo multi-function devices */ __u8 device_no; - __u32 prod_id_hash[4] - __attribute__((aligned(sizeof(__u32)))); + __u32 prod_id_hash[4]; /* not matched against in kernelspace*/ -#ifdef __KERNEL__ const char * prod_id[4]; -#else - kernel_ulong_t prod_id[4] - __attribute__((aligned(sizeof(kernel_ulong_t)))); -#endif /* not matched against */ kernel_ulong_t driver_info; -#ifdef __KERNEL__ char * cisfile; -#else - kernel_ulong_t cisfile; -#endif }; #define PCMCIA_DEV_ID_MATCH_MANF_ID 0x0001 @@ -373,8 +352,7 @@ struct sdio_device_id { __u8 class; /* Standard interface or SDIO_ANY_ID */ __u16 vendor; /* Vendor or SDIO_ANY_ID */ __u16 device; /* Device ID or SDIO_ANY_ID */ - kernel_ulong_t driver_data /* Data private to the driver */ - __attribute__((aligned(sizeof(kernel_ulong_t)))); + kernel_ulong_t driver_data; /* Data private to the driver */ }; /* SSB core, see drivers/ssb/ */ @@ -420,8 +398,7 @@ struct virtio_device_id { */ struct hv_vmbus_device_id { __u8 guid[16]; - kernel_ulong_t driver_data /* Data private to the driver */ - __attribute__((aligned(sizeof(kernel_ulong_t)))); + kernel_ulong_t driver_data; /* Data private to the driver */ }; /* rpmsg */ @@ -440,8 +417,7 @@ struct rpmsg_device_id { struct i2c_device_id { char name[I2C_NAME_SIZE]; - kernel_ulong_t driver_data /* Data private to the driver */ - __attribute__((aligned(sizeof(kernel_ulong_t)))); + kernel_ulong_t driver_data; /* Data private to the driver */ }; /* spi */ @@ -451,8 +427,7 @@ struct i2c_device_id { struct spi_device_id { char name[SPI_NAME_SIZE]; - kernel_ulong_t driver_data /* Data private to the driver */ - __attribute__((aligned(sizeof(kernel_ulong_t)))); + kernel_ulong_t driver_data; /* Data private to the driver */ }; /* dmi */ @@ -484,15 +459,6 @@ struct dmi_strmatch { char substr[79]; }; -#ifndef __KERNEL__ -struct dmi_system_id { - kernel_ulong_t callback; - kernel_ulong_t ident; - struct dmi_strmatch matches[4]; - kernel_ulong_t driver_data - __attribute__((aligned(sizeof(kernel_ulong_t)))); -}; -#else struct dmi_system_id { int (*callback)(const struct dmi_system_id *); const char *ident; @@ -506,7 +472,6 @@ struct dmi_system_id { * error: storage size of '__mod_dmi_device_table' isn't known */ #define dmi_device_id dmi_system_id -#endif #define DMI_MATCH(a, b) { a, b } @@ -515,8 +480,7 @@ struct dmi_system_id { struct platform_device_id { char name[PLATFORM_NAME_SIZE]; - kernel_ulong_t driver_data - __attribute__((aligned(sizeof(kernel_ulong_t)))); + kernel_ulong_t driver_data; }; #define MDIO_MODULE_PREFIX "mdio:" @@ -572,11 +536,7 @@ struct isapnp_device_id { struct amba_id { unsigned int id; unsigned int mask; -#ifndef __KERNEL__ - kernel_ulong_t data; -#else void *data; -#endif }; /* 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 $(obj)/time.o: $(obj)/timeconst.h -quiet_cmd_timeconst = TIMEC $@ - cmd_timeconst = $(PERL) $< $(CONFIG_HZ) > $@ +quiet_cmd_hzfile = HZFILE $@ + cmd_hzfile = echo "hz=$(CONFIG_HZ)" > $@ + +targets += hz.bc +$(obj)/hz.bc: $(objtree)/include/config/hz.h FORCE + $(call if_changed,hzfile) + +quiet_cmd_bc = BC $@ + cmd_bc = bc -q $(filter-out FORCE,$^) > $@ + targets += timeconst.h -$(obj)/timeconst.h: $(src)/timeconst.pl FORCE - $(call if_changed,timeconst) +$(obj)/timeconst.h: $(obj)/hz.bc $(src)/timeconst.bc FORCE + $(call if_changed,bc) ifeq ($(CONFIG_MODULE_SIG),y) # 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 @@ +scale=0 + +define gcd(a,b) { + auto t; + while (b) { + t = b; + b = a % b; + a = t; + } + return a; +} + +/* Division by reciprocal multiplication. */ +define fmul(b,n,d) { + return (2^b*n+d-1)/d; +} + +/* Adjustment factor when a ceiling value is used. Use as: + (imul * n) + (fmulxx * n + fadjxx) >> xx) */ +define fadj(b,n,d) { + auto v; + d = d/gcd(n,d); + v = 2^b*(d-1)/d; + return v; +} + +/* Compute the appropriate mul/adj values as well as a shift count, + which brings the mul value into the range 2^b-1 <= x < 2^b. Such + a shift value will be correct in the signed integer range and off + by at most one in the upper half of the unsigned range. */ +define fmuls(b,n,d) { + auto s, m; + for (s = 0; 1; s++) { + m = fmul(s,n,d); + if (m >= 2^(b-1)) + return s; + } + return 0; +} + +define timeconst(hz) { + print "/* Automatically generated by kernel/timeconst.bc */\n" + print "/* Time conversion constants for HZ == ", hz, " */\n" + print "\n" + + print "#ifndef KERNEL_TIMECONST_H\n" + print "#define KERNEL_TIMECONST_H\n\n" + + print "#include <linux/param.h>\n" + print "#include <linux/types.h>\n\n" + + print "#if HZ != ", hz, "\n" + print "#error \qkernel/timeconst.h has the wrong HZ value!\q\n" + print "#endif\n\n" + + if (hz < 2) { + print "#error Totally bogus HZ value!\n" + } else { + s=fmuls(32,1000,hz) + obase=16 + print "#define HZ_TO_MSEC_MUL32\tU64_C(0x", fmul(s,1000,hz), ")\n" + print "#define HZ_TO_MSEC_ADJ32\tU64_C(0x", fadj(s,1000,hz), ")\n" + obase=10 + print "#define HZ_TO_MSEC_SHR32\t", s, "\n" + + s=fmuls(32,hz,1000) + obase=16 + print "#define MSEC_TO_HZ_MUL32\tU64_C(0x", fmul(s,hz,1000), ")\n" + print "#define MSEC_TO_HZ_ADJ32\tU64_C(0x", fadj(s,hz,1000), ")\n" + obase=10 + print "#define MSEC_TO_HZ_SHR32\t", s, "\n" + + obase=10 + cd=gcd(hz,1000) + print "#define HZ_TO_MSEC_NUM\t\t", 1000/cd, "\n" + print "#define HZ_TO_MSEC_DEN\t\t", hz/cd, "\n" + print "#define MSEC_TO_HZ_NUM\t\t", hz/cd, "\n" + print "#define MSEC_TO_HZ_DEN\t\t", 1000/cd, "\n" + print "\n" + + s=fmuls(32,1000000,hz) + obase=16 + print "#define HZ_TO_USEC_MUL32\tU64_C(0x", fmul(s,1000000,hz), ")\n" + print "#define HZ_TO_USEC_ADJ32\tU64_C(0x", fadj(s,1000000,hz), ")\n" + obase=10 + print "#define HZ_TO_USEC_SHR32\t", s, "\n" + + s=fmuls(32,hz,1000000) + obase=16 + print "#define USEC_TO_HZ_MUL32\tU64_C(0x", fmul(s,hz,1000000), ")\n" + print "#define USEC_TO_HZ_ADJ32\tU64_C(0x", fadj(s,hz,1000000), ")\n" + obase=10 + print "#define USEC_TO_HZ_SHR32\t", s, "\n" + + obase=10 + cd=gcd(hz,1000000) + print "#define HZ_TO_USEC_NUM\t\t", 1000000/cd, "\n" + print "#define HZ_TO_USEC_DEN\t\t", hz/cd, "\n" + print "#define USEC_TO_HZ_NUM\t\t", hz/cd, "\n" + print "#define USEC_TO_HZ_DEN\t\t", 1000000/cd, "\n" + print "\n" + + print "#endif /* KERNEL_TIMECONST_H */\n" + } + halt +} + +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 @@ -#!/usr/bin/perl -# ----------------------------------------------------------------------- -# -# Copyright 2007-2008 rPath, Inc. - All Rights Reserved -# -# This file is part of the Linux kernel, and is made available under -# the terms of the GNU General Public License version 2 or (at your -# option) any later version; incorporated herein by reference. -# -# ----------------------------------------------------------------------- -# - -# -# Usage: timeconst.pl HZ > timeconst.h -# - -# Precomputed values for systems without Math::BigInt -# Generated by: -# timeconst.pl --can 24 32 48 64 100 122 128 200 250 256 300 512 1000 1024 1200 -%canned_values = ( - 24 => [ - '0xa6aaaaab','0x2aaaaaa',26, - 125,3, - '0xc49ba5e4','0x1fbe76c8b4',37, - 3,125, - '0xa2c2aaab','0xaaaa',16, - 125000,3, - '0xc9539b89','0x7fffbce4217d',47, - 3,125000, - ], 32 => [ - '0xfa000000','0x6000000',27, - 125,4, - '0x83126e98','0xfdf3b645a',36, - 4,125, - '0xf4240000','0x0',17, - 31250,1, - '0x8637bd06','0x3fff79c842fa',46, - 1,31250, - ], 48 => [ - '0xa6aaaaab','0x6aaaaaa',27, - 125,6, - '0xc49ba5e4','0xfdf3b645a',36, - 6,125, - '0xa2c2aaab','0x15555',17, - 62500,3, - '0xc9539b89','0x3fffbce4217d',46, - 3,62500, - ], 64 => [ - '0xfa000000','0xe000000',28, - 125,8, - '0x83126e98','0x7ef9db22d',35, - 8,125, - '0xf4240000','0x0',18, - 15625,1, - '0x8637bd06','0x1fff79c842fa',45, - 1,15625, - ], 100 => [ - '0xa0000000','0x0',28, - 10,1, - '0xcccccccd','0x733333333',35, - 1,10, - '0x9c400000','0x0',18, - 10000,1, - '0xd1b71759','0x1fff2e48e8a7',45, - 1,10000, - ], 122 => [ - '0x8325c53f','0xfbcda3a',28, - 500,61, - '0xf9db22d1','0x7fbe76c8b',35, - 61,500, - '0x8012e2a0','0x3ef36',18, - 500000,61, - '0xffda4053','0x1ffffbce4217',45, - 61,500000, - ], 128 => [ - '0xfa000000','0x1e000000',29, - 125,16, - '0x83126e98','0x3f7ced916',34, - 16,125, - '0xf4240000','0x40000',19, - 15625,2, - '0x8637bd06','0xfffbce4217d',44, - 2,15625, - ], 200 => [ - '0xa0000000','0x0',29, - 5,1, - '0xcccccccd','0x333333333',34, - 1,5, - '0x9c400000','0x0',19, - 5000,1, - '0xd1b71759','0xfff2e48e8a7',44, - 1,5000, - ], 250 => [ - '0x80000000','0x0',29, - 4,1, - '0x80000000','0x180000000',33, - 1,4, - '0xfa000000','0x0',20, - 4000,1, - '0x83126e98','0x7ff7ced9168',43, - 1,4000, - ], 256 => [ - '0xfa000000','0x3e000000',30, - 125,32, - '0x83126e98','0x1fbe76c8b',33, - 32,125, - '0xf4240000','0xc0000',20, - 15625,4, - '0x8637bd06','0x7ffde7210be',43, - 4,15625, - ], 300 => [ - '0xd5555556','0x2aaaaaaa',30, - 10,3, - '0x9999999a','0x1cccccccc',33, - 3,10, - '0xd0555556','0xaaaaa',20, - 10000,3, - '0x9d495183','0x7ffcb923a29',43, - 3,10000, - ], 512 => [ - '0xfa000000','0x7e000000',31, - 125,64, - '0x83126e98','0xfdf3b645',32, - 64,125, - '0xf4240000','0x1c0000',21, - 15625,8, - '0x8637bd06','0x3ffef39085f',42, - 8,15625, - ], 1000 => [ - '0x80000000','0x0',31, - 1,1, - '0x80000000','0x0',31, - 1,1, - '0xfa000000','0x0',22, - 1000,1, - '0x83126e98','0x1ff7ced9168',41, - 1,1000, - ], 1024 => [ - '0xfa000000','0xfe000000',32, - 125,128, - '0x83126e98','0x7ef9db22',31, - 128,125, - '0xf4240000','0x3c0000',22, - 15625,16, - '0x8637bd06','0x1fff79c842f',41, - 16,15625, - ], 1200 => [ - '0xd5555556','0xd5555555',32, - 5,6, - '0x9999999a','0x66666666',31, - 6,5, - '0xd0555556','0x2aaaaa',22, - 2500,3, - '0x9d495183','0x1ffcb923a29',41, - 3,2500, - ] -); - -$has_bigint = eval 'use Math::BigInt qw(bgcd); 1;'; - -sub bint($) -{ - my($x) = @_; - return Math::BigInt->new($x); -} - -# -# Constants for division by reciprocal multiplication. -# (bits, numerator, denominator) -# -sub fmul($$$) -{ - my ($b,$n,$d) = @_; - - $n = bint($n); - $d = bint($d); - - return scalar (($n << $b)+$d-bint(1))/$d; -} - -sub fadj($$$) -{ - my($b,$n,$d) = @_; - - $n = bint($n); - $d = bint($d); - - $d = $d/bgcd($n, $d); - return scalar (($d-bint(1)) << $b)/$d; -} - -sub fmuls($$$) { - my($b,$n,$d) = @_; - my($s,$m); - my($thres) = bint(1) << ($b-1); - - $n = bint($n); - $d = bint($d); - - for ($s = 0; 1; $s++) { - $m = fmul($s,$n,$d); - return $s if ($m >= $thres); - } - return 0; -} - -# Generate a hex value if the result fits in 64 bits; -# otherwise skip. -sub bignum_hex($) { - my($x) = @_; - my $s = $x->as_hex(); - - return (length($s) > 18) ? undef : $s; -} - -# Provides mul, adj, and shr factors for a specific -# (bit, time, hz) combination -sub muladj($$$) { - my($b, $t, $hz) = @_; - my $s = fmuls($b, $t, $hz); - my $m = fmul($s, $t, $hz); - my $a = fadj($s, $t, $hz); - return (bignum_hex($m), bignum_hex($a), $s); -} - -# Provides numerator, denominator values -sub numden($$) { - my($n, $d) = @_; - my $g = bgcd($n, $d); - return ($n/$g, $d/$g); -} - -# All values for a specific (time, hz) combo -sub conversions($$) { - my ($t, $hz) = @_; - my @val = (); - - # HZ_TO_xx - push(@val, muladj(32, $t, $hz)); - push(@val, numden($t, $hz)); - - # xx_TO_HZ - push(@val, muladj(32, $hz, $t)); - push(@val, numden($hz, $t)); - - return @val; -} - -sub compute_values($) { - my($hz) = @_; - my @val = (); - my $s, $m, $a, $g; - - if (!$has_bigint) { - die "$0: HZ == $hz not canned and ". - "Math::BigInt not available\n"; - } - - # MSEC conversions - push(@val, conversions(1000, $hz)); - - # USEC conversions - push(@val, conversions(1000000, $hz)); - - return @val; -} - -sub outputval($$) -{ - my($name, $val) = @_; - my $csuf; - - if (defined($val)) { - if ($name !~ /SHR/) { - $val = "U64_C($val)"; - } - printf "#define %-23s %s\n", $name.$csuf, $val.$csuf; - } -} - -sub output($@) -{ - my($hz, @val) = @_; - my $pfx, $bit, $suf, $s, $m, $a; - - print "/* Automatically generated by kernel/timeconst.pl */\n"; - print "/* Conversion constants for HZ == $hz */\n"; - print "\n"; - print "#ifndef KERNEL_TIMECONST_H\n"; - print "#define KERNEL_TIMECONST_H\n"; - print "\n"; - - print "#include <linux/param.h>\n"; - print "#include <linux/types.h>\n"; - - print "\n"; - print "#if HZ != $hz\n"; - print "#error \"kernel/timeconst.h has the wrong HZ value!\"\n"; - print "#endif\n"; - print "\n"; - - foreach $pfx ('HZ_TO_MSEC','MSEC_TO_HZ', - 'HZ_TO_USEC','USEC_TO_HZ') { - foreach $bit (32) { - foreach $suf ('MUL', 'ADJ', 'SHR') { - outputval("${pfx}_$suf$bit", shift(@val)); - } - } - foreach $suf ('NUM', 'DEN') { - outputval("${pfx}_$suf", shift(@val)); - } - } - - print "\n"; - print "#endif /* KERNEL_TIMECONST_H */\n"; -} - -# Pretty-print Perl values -sub perlvals(@) { - my $v; - my @l = (); - - foreach $v (@_) { - if (!defined($v)) { - push(@l, 'undef'); - } elsif ($v =~ /^0x/) { - push(@l, "\'".$v."\'"); - } else { - push(@l, $v.''); - } - } - return join(',', @l); -} - -($hz) = @ARGV; - -# Use this to generate the %canned_values structure -if ($hz eq '--can') { - shift(@ARGV); - @hzlist = sort {$a <=> $b} (@ARGV); - - print "# Precomputed values for systems without Math::BigInt\n"; - print "# Generated by:\n"; - print "# timeconst.pl --can ", join(' ', @hzlist), "\n"; - print "\%canned_values = (\n"; - my $pf = "\t"; - foreach $hz (@hzlist) { - my @values = compute_values($hz); - print "$pf$hz => [\n"; - while (scalar(@values)) { - my $bit; - foreach $bit (32) { - my $m = shift(@values); - my $a = shift(@values); - my $s = shift(@values); - print "\t\t", perlvals($m,$a,$s), ",\n"; - } - my $n = shift(@values); - my $d = shift(@values); - print "\t\t", perlvals($n,$d), ",\n"; - } - print "\t]"; - $pf = ', '; - } - print "\n);\n"; -} else { - $hz += 0; # Force to number - if ($hz < 1) { - die "Usage: $0 HZ\n"; - } - - $cv = $canned_values{$hz}; - @val = defined($cv) ? @$cv : compute_values($hz); - output($hz, @val); -} -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 @@ # # ========================================================================== -# called may set destination dir (when installing to asm/) -_dst := $(or $(destination-y),$(dst),$(obj)) - # generated header directory gen := $(if $(gen),$(gen),$(subst include/,include/generated/,$(obj))) kbuild-file := $(srctree)/$(obj)/Kbuild include $(kbuild-file) +# called may set destination dir (when installing to asm/) +_dst := $(or $(destination-y),$(dst),$(obj)) + old-kbuild-file := $(srctree)/$(subst uapi/,,$(obj))/Kbuild ifneq ($(wildcard $(old-kbuild-file)),) 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))) # Stop after building .o files if NOFINAL is set. Makes compile tests quicker _modpost: $(if $(KBUILD_MODPOST_NOFINAL), $(modules:.ko:.o),$(modules)) -ifneq ($(KBUILD_BUILDHOST),$(ARCH)) - cross_build := 1 -endif - # Step 2), invoke modpost # Includes step 3,4 modpost = scripts/mod/modpost \ @@ -80,8 +76,7 @@ modpost = scripts/mod/modpost \ $(if $(KBUILD_EXTRA_SYMBOLS), $(patsubst %, -e %,$(KBUILD_EXTRA_SYMBOLS))) \ $(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \ $(if $(CONFIG_DEBUG_SECTION_MISMATCH),,-S) \ - $(if $(KBUILD_EXTMOD)$(KBUILD_MODPOST_WARN),-w) \ - $(if $(cross_build),-c) + $(if $(KBUILD_EXTMOD)$(KBUILD_MODPOST_WARN),-w) quiet_cmd_modpost = MODPOST $(words $(filter-out vmlinux FORCE, $^)) modules 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 @@ # # A depmod wrapper used by the toplevel Makefile -if test $# -ne 2; then - echo "Usage: $0 /sbin/depmod <kernelrelease>" >&2 +if test $# -ne 3; then + echo "Usage: $0 /sbin/depmod <kernelrelease> <symbolprefix>" >&2 exit 1 fi DEPMOD=$1 KERNELRELEASE=$2 +SYMBOL_PREFIX=$3 if ! test -r System.map -a -x "$DEPMOD"; then exit 0 fi + +# older versions of depmod don't support -P <symbol-prefix> +# support was added in module-init-tools 3.13 +if test -n "$SYMBOL_PREFIX"; then + release=$("$DEPMOD" --version) + package=$(echo "$release" | cut -d' ' -f 1) + if test "$package" = "module-init-tools"; then + version=$(echo "$release" | cut -d' ' -f 2) + later=$(printf '%s\n' "$version" "3.13" | sort -V | tail -n 1) + if test "$later" != "$version"; then + # module-init-tools < 3.13, drop the symbol prefix + SYMBOL_PREFIX="" + fi + fi + if test -n "$SYMBOL_PREFIX"; then + SYMBOL_PREFIX="-P $SYMBOL_PREFIX" + fi +fi + # older versions of depmod require the version string to start with three # numbers, so we cheat with a symlink here depmod_hack_needed=true @@ -34,7 +54,7 @@ set -- -ae -F System.map if test -n "$INSTALL_MOD_PATH"; then set -- "$@" -b "$INSTALL_MOD_PATH" fi -"$DEPMOD" "$@" "$KERNELRELEASE" +"$DEPMOD" "$@" "$KERNELRELEASE" $SYMBOL_PREFIX ret=$? 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 fi # We need access to CONFIG_ symbols -. ./.config +case "${KCONFIG_CONFIG}" in +*/*) + . "${KCONFIG_CONFIG}" + ;; +*) + # Force using a file from the current directory + . "./${KCONFIG_CONFIG}" +esac #link vmlinux.o 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 @@ elfconfig.h mk_elfconfig modpost +devicetable-offsets.h 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 modpost-objs := modpost.o file2alias.o sumversion.o +devicetable-offsets-file := devicetable-offsets.h + +define sed-y + "/^->/{s:->#\(.*\):/* \1 */:; \ + s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \ + s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \ + s:->::; p;}" +endef + +quiet_cmd_offsets = GEN $@ +define cmd_offsets + (set -e; \ + echo "#ifndef __DEVICEVTABLE_OFFSETS_H__"; \ + echo "#define __DEVICEVTABLE_OFFSETS_H__"; \ + echo "/*"; \ + echo " * DO NOT MODIFY."; \ + echo " *"; \ + echo " * This file was generated by Kbuild"; \ + echo " *"; \ + echo " */"; \ + echo ""; \ + sed -ne $(sed-y) $<; \ + echo ""; \ + echo "#endif" ) > $@ +endef + +# We use internal kbuild rules to avoid the "is up to date" message from make +scripts/mod/devicetable-offsets.s: scripts/mod/devicetable-offsets.c FORCE + $(Q)mkdir -p $(dir $@) + $(call if_changed_dep,cc_s_c) + +$(obj)/$(devicetable-offsets-file): scripts/mod/devicetable-offsets.s + $(call cmd,offsets) + # dependencies on generated files need to be listed explicitly $(obj)/modpost.o $(obj)/file2alias.o $(obj)/sumversion.o: $(obj)/elfconfig.h +$(obj)/file2alias.o: $(obj)/$(devicetable-offsets-file) quiet_cmd_elfconfig = MKELF $@ 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 @@ +#include <linux/kbuild.h> +#include <linux/mod_devicetable.h> + +#define DEVID(devid) DEFINE(SIZE_##devid, sizeof(struct devid)) +#define DEVID_FIELD(devid, field) \ + DEFINE(OFF_##devid##_##field, offsetof(struct devid, field)) + +int main(void) +{ + DEVID(usb_device_id); + DEVID_FIELD(usb_device_id, match_flags); + DEVID_FIELD(usb_device_id, idVendor); + DEVID_FIELD(usb_device_id, idProduct); + DEVID_FIELD(usb_device_id, bcdDevice_lo); + DEVID_FIELD(usb_device_id, bcdDevice_hi); + DEVID_FIELD(usb_device_id, bDeviceClass); + DEVID_FIELD(usb_device_id, bDeviceSubClass); + DEVID_FIELD(usb_device_id, bDeviceProtocol); + DEVID_FIELD(usb_device_id, bInterfaceClass); + DEVID_FIELD(usb_device_id, bInterfaceSubClass); + DEVID_FIELD(usb_device_id, bInterfaceProtocol); + DEVID_FIELD(usb_device_id, bInterfaceNumber); + + DEVID(hid_device_id); + DEVID_FIELD(hid_device_id, bus); + DEVID_FIELD(hid_device_id, group); + DEVID_FIELD(hid_device_id, vendor); + DEVID_FIELD(hid_device_id, product); + + DEVID(ieee1394_device_id); + DEVID_FIELD(ieee1394_device_id, match_flags); + DEVID_FIELD(ieee1394_device_id, vendor_id); + DEVID_FIELD(ieee1394_device_id, model_id); + DEVID_FIELD(ieee1394_device_id, specifier_id); + DEVID_FIELD(ieee1394_device_id, version); + + DEVID(pci_device_id); + DEVID_FIELD(pci_device_id, vendor); + DEVID_FIELD(pci_device_id, device); + DEVID_FIELD(pci_device_id, subvendor); + DEVID_FIELD(pci_device_id, subdevice); + DEVID_FIELD(pci_device_id, class); + DEVID_FIELD(pci_device_id, class_mask); + + DEVID(ccw_device_id); + DEVID_FIELD(ccw_device_id, match_flags); + DEVID_FIELD(ccw_device_id, cu_type); + DEVID_FIELD(ccw_device_id, cu_model); + DEVID_FIELD(ccw_device_id, dev_type); + DEVID_FIELD(ccw_device_id, dev_model); + + DEVID(ap_device_id); + DEVID_FIELD(ap_device_id, dev_type); + + DEVID(css_device_id); + DEVID_FIELD(css_device_id, type); + + DEVID(serio_device_id); + DEVID_FIELD(serio_device_id, type); + DEVID_FIELD(serio_device_id, proto); + DEVID_FIELD(serio_device_id, id); + DEVID_FIELD(serio_device_id, extra); + + DEVID(acpi_device_id); + DEVID_FIELD(acpi_device_id, id); + + DEVID(pnp_device_id); + DEVID_FIELD(pnp_device_id, id); + + DEVID(pnp_card_device_id); + DEVID_FIELD(pnp_card_device_id, devs); + + DEVID(pcmcia_device_id); + DEVID_FIELD(pcmcia_device_id, match_flags); + DEVID_FIELD(pcmcia_device_id, manf_id); + DEVID_FIELD(pcmcia_device_id, card_id); + DEVID_FIELD(pcmcia_device_id, func_id); + DEVID_FIELD(pcmcia_device_id, function); + DEVID_FIELD(pcmcia_device_id, device_no); + DEVID_FIELD(pcmcia_device_id, prod_id_hash); + + DEVID(of_device_id); + DEVID_FIELD(of_device_id, name); + DEVID_FIELD(of_device_id, type); + DEVID_FIELD(of_device_id, compatible); + + DEVID(vio_device_id); + DEVID_FIELD(vio_device_id, type); + DEVID_FIELD(vio_device_id, compat); + + DEVID(input_device_id); + DEVID_FIELD(input_device_id, flags); + DEVID_FIELD(input_device_id, bustype); + DEVID_FIELD(input_device_id, vendor); + DEVID_FIELD(input_device_id, product); + DEVID_FIELD(input_device_id, version); + DEVID_FIELD(input_device_id, evbit); + DEVID_FIELD(input_device_id, keybit); + DEVID_FIELD(input_device_id, relbit); + DEVID_FIELD(input_device_id, absbit); + DEVID_FIELD(input_device_id, mscbit); + DEVID_FIELD(input_device_id, ledbit); + DEVID_FIELD(input_device_id, sndbit); + DEVID_FIELD(input_device_id, ffbit); + DEVID_FIELD(input_device_id, swbit); + + DEVID(eisa_device_id); + DEVID_FIELD(eisa_device_id, sig); + + DEVID(parisc_device_id); + DEVID_FIELD(parisc_device_id, hw_type); + DEVID_FIELD(parisc_device_id, hversion); + DEVID_FIELD(parisc_device_id, hversion_rev); + DEVID_FIELD(parisc_device_id, sversion); + + DEVID(sdio_device_id); + DEVID_FIELD(sdio_device_id, class); + DEVID_FIELD(sdio_device_id, vendor); + DEVID_FIELD(sdio_device_id, device); + + DEVID(ssb_device_id); + DEVID_FIELD(ssb_device_id, vendor); + DEVID_FIELD(ssb_device_id, coreid); + DEVID_FIELD(ssb_device_id, revision); + + DEVID(bcma_device_id); + DEVID_FIELD(bcma_device_id, manuf); + DEVID_FIELD(bcma_device_id, id); + DEVID_FIELD(bcma_device_id, rev); + DEVID_FIELD(bcma_device_id, class); + + DEVID(virtio_device_id); + DEVID_FIELD(virtio_device_id, device); + DEVID_FIELD(virtio_device_id, vendor); + + DEVID(hv_vmbus_device_id); + DEVID_FIELD(hv_vmbus_device_id, guid); + + DEVID(i2c_device_id); + DEVID_FIELD(i2c_device_id, name); + + DEVID(spi_device_id); + DEVID_FIELD(spi_device_id, name); + + DEVID(dmi_system_id); + DEVID_FIELD(dmi_system_id, matches); + + DEVID(platform_device_id); + DEVID_FIELD(platform_device_id, name); + + DEVID(mdio_device_id); + DEVID_FIELD(mdio_device_id, phy_id); + DEVID_FIELD(mdio_device_id, phy_id_mask); + + DEVID(zorro_device_id); + DEVID_FIELD(zorro_device_id, id); + + DEVID(isapnp_device_id); + DEVID_FIELD(isapnp_device_id, vendor); + DEVID_FIELD(isapnp_device_id, function); + + DEVID(ipack_device_id); + DEVID_FIELD(ipack_device_id, format); + DEVID_FIELD(ipack_device_id, vendor); + DEVID_FIELD(ipack_device_id, device); + + DEVID(amba_id); + DEVID_FIELD(amba_id, id); + DEVID_FIELD(amba_id, mask); + + DEVID(x86_cpu_id); + DEVID_FIELD(x86_cpu_id, feature); + DEVID_FIELD(x86_cpu_id, family); + DEVID_FIELD(x86_cpu_id, model); + DEVID_FIELD(x86_cpu_id, vendor); + + return 0; +} 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 @@ */ #include "modpost.h" +#include "devicetable-offsets.h" /* We use the ELF typedefs for kernel_ulong_t but bite the bullet and * use either stdint.h or inttypes.h for the rest. */ @@ -84,13 +85,25 @@ extern struct devtable *__start___devtable[], *__stop___devtable[]; # define __used __attribute__((__used__)) #endif +/* Define a variable f that holds the value of field f of struct devid + * based at address m. + */ +#define DEF_FIELD(m, devid, f) \ + typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f)) +/* Define a variable f that holds the address of field f of struct devid + * based at address m. Due to the way typeof works, for a field of type + * T[N] the variable has type T(*)[N], _not_ T*. + */ +#define DEF_FIELD_ADDR(m, devid, f) \ + typeof(((struct devid *)0)->f) *f = ((m) + OFF_##devid##_##f) + /* Add a table entry. We test function type matches while we're here. */ #define ADD_TO_DEVTABLE(device_id, type, function) \ static struct devtable __cat(devtable,__LINE__) = { \ device_id + 0*sizeof((function)((const char *)NULL, \ - (type *)NULL, \ + (void *)NULL, \ (char *)NULL)), \ - sizeof(type), (function) }; \ + SIZE_##type, (function) }; \ static struct devtable *SECTION(__devtable) __used \ __cat(devtable_ptr,__LINE__) = &__cat(devtable,__LINE__) @@ -116,7 +129,6 @@ static inline void add_wildcard(char *str) strcat(str + len, "*"); } -unsigned int cross_build = 0; /** * Check that sizeof(device_id type) are consistent with size of section * 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, int i; if (size % id_size || size < id_size) { - if (cross_build != 0) - return; fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo " "of the size of section __mod_%s_device_table=%lu.\n" "Fix definition of struct %s_device_id " @@ -157,17 +167,29 @@ static void device_id_check(const char *modname, const char *device_id, /* USB is special because the bcdDevice can be matched against a numeric range */ /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipNinN" */ -static void do_usb_entry(struct usb_device_id *id, +static void do_usb_entry(void *symval, unsigned int bcdDevice_initial, int bcdDevice_initial_digits, unsigned char range_lo, unsigned char range_hi, unsigned char max, struct module *mod) { char alias[500]; + DEF_FIELD(symval, usb_device_id, match_flags); + DEF_FIELD(symval, usb_device_id, idVendor); + DEF_FIELD(symval, usb_device_id, idProduct); + DEF_FIELD(symval, usb_device_id, bcdDevice_lo); + DEF_FIELD(symval, usb_device_id, bDeviceClass); + DEF_FIELD(symval, usb_device_id, bDeviceSubClass); + DEF_FIELD(symval, usb_device_id, bDeviceProtocol); + DEF_FIELD(symval, usb_device_id, bInterfaceClass); + DEF_FIELD(symval, usb_device_id, bInterfaceSubClass); + DEF_FIELD(symval, usb_device_id, bInterfaceProtocol); + DEF_FIELD(symval, usb_device_id, bInterfaceNumber); + strcpy(alias, "usb:"); - ADD(alias, "v", id->match_flags&USB_DEVICE_ID_MATCH_VENDOR, - id->idVendor); - ADD(alias, "p", id->match_flags&USB_DEVICE_ID_MATCH_PRODUCT, - id->idProduct); + ADD(alias, "v", match_flags&USB_DEVICE_ID_MATCH_VENDOR, + idVendor); + ADD(alias, "p", match_flags&USB_DEVICE_ID_MATCH_PRODUCT, + idProduct); strcat(alias, "d"); if (bcdDevice_initial_digits) @@ -190,29 +212,23 @@ static void do_usb_entry(struct usb_device_id *id, range_lo); } } - if (bcdDevice_initial_digits < (sizeof(id->bcdDevice_lo) * 2 - 1)) + if (bcdDevice_initial_digits < (sizeof(bcdDevice_lo) * 2 - 1)) strcat(alias, "*"); - ADD(alias, "dc", id->match_flags&USB_DEVICE_ID_MATCH_DEV_CLASS, - id->bDeviceClass); - ADD(alias, "dsc", - id->match_flags&USB_DEVICE_ID_MATCH_DEV_SUBCLASS, - id->bDeviceSubClass); - ADD(alias, "dp", - id->match_flags&USB_DEVICE_ID_MATCH_DEV_PROTOCOL, - id->bDeviceProtocol); - ADD(alias, "ic", - id->match_flags&USB_DEVICE_ID_MATCH_INT_CLASS, - id->bInterfaceClass); - ADD(alias, "isc", - id->match_flags&USB_DEVICE_ID_MATCH_INT_SUBCLASS, - id->bInterfaceSubClass); - ADD(alias, "ip", - id->match_flags&USB_DEVICE_ID_MATCH_INT_PROTOCOL, - id->bInterfaceProtocol); - ADD(alias, "in", - id->match_flags&USB_DEVICE_ID_MATCH_INT_NUMBER, - id->bInterfaceNumber); + ADD(alias, "dc", match_flags&USB_DEVICE_ID_MATCH_DEV_CLASS, + bDeviceClass); + ADD(alias, "dsc", match_flags&USB_DEVICE_ID_MATCH_DEV_SUBCLASS, + bDeviceSubClass); + ADD(alias, "dp", match_flags&USB_DEVICE_ID_MATCH_DEV_PROTOCOL, + bDeviceProtocol); + ADD(alias, "ic", match_flags&USB_DEVICE_ID_MATCH_INT_CLASS, + bInterfaceClass); + ADD(alias, "isc", match_flags&USB_DEVICE_ID_MATCH_INT_SUBCLASS, + bInterfaceSubClass); + ADD(alias, "ip", match_flags&USB_DEVICE_ID_MATCH_INT_PROTOCOL, + bInterfaceProtocol); + ADD(alias, "in", match_flags&USB_DEVICE_ID_MATCH_INT_NUMBER, + bInterfaceNumber); add_wildcard(alias); buf_printf(&mod->dev_table_buf, @@ -258,24 +274,28 @@ static unsigned int incbcd(unsigned int *bcd, return init; } -static void do_usb_entry_multi(struct usb_device_id *id, struct module *mod) +static void do_usb_entry_multi(void *symval, struct module *mod) { unsigned int devlo, devhi; unsigned char chi, clo, max; int ndigits; - id->match_flags = TO_NATIVE(id->match_flags); - id->idVendor = TO_NATIVE(id->idVendor); - id->idProduct = TO_NATIVE(id->idProduct); + DEF_FIELD(symval, usb_device_id, match_flags); + DEF_FIELD(symval, usb_device_id, idVendor); + DEF_FIELD(symval, usb_device_id, idProduct); + DEF_FIELD(symval, usb_device_id, bcdDevice_lo); + DEF_FIELD(symval, usb_device_id, bcdDevice_hi); + DEF_FIELD(symval, usb_device_id, bDeviceClass); + DEF_FIELD(symval, usb_device_id, bInterfaceClass); - devlo = id->match_flags & USB_DEVICE_ID_MATCH_DEV_LO ? - TO_NATIVE(id->bcdDevice_lo) : 0x0U; - devhi = id->match_flags & USB_DEVICE_ID_MATCH_DEV_HI ? - TO_NATIVE(id->bcdDevice_hi) : ~0x0U; + devlo = match_flags & USB_DEVICE_ID_MATCH_DEV_LO ? + bcdDevice_lo : 0x0U; + devhi = match_flags & USB_DEVICE_ID_MATCH_DEV_HI ? + bcdDevice_hi : ~0x0U; /* Figure out if this entry is in bcd or hex format */ max = 0x9; /* Default to decimal format */ - for (ndigits = 0 ; ndigits < sizeof(id->bcdDevice_lo) * 2 ; ndigits++) { + for (ndigits = 0 ; ndigits < sizeof(bcdDevice_lo) * 2 ; ndigits++) { clo = (devlo >> (ndigits << 2)) & 0xf; chi = ((devhi > 0x9999 ? 0x9999 : devhi) >> (ndigits << 2)) & 0xf; if (clo > max || chi > max) { @@ -288,11 +308,11 @@ static void do_usb_entry_multi(struct usb_device_id *id, struct module *mod) * Some modules (visor) have empty slots as placeholder for * run-time specification that results in catch-all alias */ - if (!(id->idVendor | id->idProduct | id->bDeviceClass | id->bInterfaceClass)) + if (!(idVendor | idProduct | bDeviceClass | bInterfaceClass)) return; /* Convert numeric bcdDevice range into fnmatch-able pattern(s) */ - for (ndigits = sizeof(id->bcdDevice_lo) * 2 - 1; devlo <= devhi; ndigits--) { + for (ndigits = sizeof(bcdDevice_lo) * 2 - 1; devlo <= devhi; ndigits--) { clo = devlo & 0xf; chi = devhi & 0xf; 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) devhi >>= 4; if (devlo == devhi || !ndigits) { - do_usb_entry(id, devlo, ndigits, clo, chi, max, mod); + do_usb_entry(symval, devlo, ndigits, clo, chi, max, mod); break; } if (clo > 0x0) - do_usb_entry(id, + do_usb_entry(symval, incbcd(&devlo, 1, max, - sizeof(id->bcdDevice_lo) * 2), + sizeof(bcdDevice_lo) * 2), ndigits, clo, max, max, mod); if (chi < max) - do_usb_entry(id, + do_usb_entry(symval, incbcd(&devhi, -1, max, - sizeof(id->bcdDevice_lo) * 2), + sizeof(bcdDevice_lo) * 2), ndigits, 0x0, chi, max, mod); } } @@ -323,7 +343,7 @@ static void do_usb_table(void *symval, unsigned long size, struct module *mod) { unsigned int i; - const unsigned long id_size = sizeof(struct usb_device_id); + const unsigned long id_size = SIZE_usb_device_id; device_id_check(mod->name, "usb", size, id_size, symval); @@ -336,81 +356,81 @@ static void do_usb_table(void *symval, unsigned long size, /* Looks like: hid:bNvNpN */ static int do_hid_entry(const char *filename, - struct hid_device_id *id, char *alias) + void *symval, char *alias) { - id->bus = TO_NATIVE(id->bus); - id->group = TO_NATIVE(id->group); - id->vendor = TO_NATIVE(id->vendor); - id->product = TO_NATIVE(id->product); + DEF_FIELD(symval, hid_device_id, bus); + DEF_FIELD(symval, hid_device_id, group); + DEF_FIELD(symval, hid_device_id, vendor); + DEF_FIELD(symval, hid_device_id, product); sprintf(alias, "hid:"); - ADD(alias, "b", id->bus != HID_BUS_ANY, id->bus); - ADD(alias, "g", id->group != HID_GROUP_ANY, id->group); - ADD(alias, "v", id->vendor != HID_ANY_ID, id->vendor); - ADD(alias, "p", id->product != HID_ANY_ID, id->product); + ADD(alias, "b", bus != HID_BUS_ANY, bus); + ADD(alias, "g", group != HID_GROUP_ANY, group); + ADD(alias, "v", vendor != HID_ANY_ID, vendor); + ADD(alias, "p", product != HID_ANY_ID, product); return 1; } -ADD_TO_DEVTABLE("hid", struct hid_device_id, do_hid_entry); +ADD_TO_DEVTABLE("hid", hid_device_id, do_hid_entry); /* Looks like: ieee1394:venNmoNspNverN */ static int do_ieee1394_entry(const char *filename, - struct ieee1394_device_id *id, char *alias) + void *symval, char *alias) { - id->match_flags = TO_NATIVE(id->match_flags); - id->vendor_id = TO_NATIVE(id->vendor_id); - id->model_id = TO_NATIVE(id->model_id); - id->specifier_id = TO_NATIVE(id->specifier_id); - id->version = TO_NATIVE(id->version); + DEF_FIELD(symval, ieee1394_device_id, match_flags); + DEF_FIELD(symval, ieee1394_device_id, vendor_id); + DEF_FIELD(symval, ieee1394_device_id, model_id); + DEF_FIELD(symval, ieee1394_device_id, specifier_id); + DEF_FIELD(symval, ieee1394_device_id, version); strcpy(alias, "ieee1394:"); - ADD(alias, "ven", id->match_flags & IEEE1394_MATCH_VENDOR_ID, - id->vendor_id); - ADD(alias, "mo", id->match_flags & IEEE1394_MATCH_MODEL_ID, - id->model_id); - ADD(alias, "sp", id->match_flags & IEEE1394_MATCH_SPECIFIER_ID, - id->specifier_id); - ADD(alias, "ver", id->match_flags & IEEE1394_MATCH_VERSION, - id->version); + ADD(alias, "ven", match_flags & IEEE1394_MATCH_VENDOR_ID, + vendor_id); + ADD(alias, "mo", match_flags & IEEE1394_MATCH_MODEL_ID, + model_id); + ADD(alias, "sp", match_flags & IEEE1394_MATCH_SPECIFIER_ID, + specifier_id); + ADD(alias, "ver", match_flags & IEEE1394_MATCH_VERSION, + version); add_wildcard(alias); return 1; } -ADD_TO_DEVTABLE("ieee1394", struct ieee1394_device_id, do_ieee1394_entry); +ADD_TO_DEVTABLE("ieee1394", ieee1394_device_id, do_ieee1394_entry); /* Looks like: pci:vNdNsvNsdNbcNscNiN. */ static int do_pci_entry(const char *filename, - struct pci_device_id *id, char *alias) + void *symval, char *alias) { /* Class field can be divided into these three. */ unsigned char baseclass, subclass, interface, baseclass_mask, subclass_mask, interface_mask; - id->vendor = TO_NATIVE(id->vendor); - id->device = TO_NATIVE(id->device); - id->subvendor = TO_NATIVE(id->subvendor); - id->subdevice = TO_NATIVE(id->subdevice); - id->class = TO_NATIVE(id->class); - id->class_mask = TO_NATIVE(id->class_mask); + DEF_FIELD(symval, pci_device_id, vendor); + DEF_FIELD(symval, pci_device_id, device); + DEF_FIELD(symval, pci_device_id, subvendor); + DEF_FIELD(symval, pci_device_id, subdevice); + DEF_FIELD(symval, pci_device_id, class); + DEF_FIELD(symval, pci_device_id, class_mask); strcpy(alias, "pci:"); - ADD(alias, "v", id->vendor != PCI_ANY_ID, id->vendor); - ADD(alias, "d", id->device != PCI_ANY_ID, id->device); - ADD(alias, "sv", id->subvendor != PCI_ANY_ID, id->subvendor); - ADD(alias, "sd", id->subdevice != PCI_ANY_ID, id->subdevice); - - baseclass = (id->class) >> 16; - baseclass_mask = (id->class_mask) >> 16; - subclass = (id->class) >> 8; - subclass_mask = (id->class_mask) >> 8; - interface = id->class; - interface_mask = id->class_mask; + ADD(alias, "v", vendor != PCI_ANY_ID, vendor); + ADD(alias, "d", device != PCI_ANY_ID, device); + ADD(alias, "sv", subvendor != PCI_ANY_ID, subvendor); + ADD(alias, "sd", subdevice != PCI_ANY_ID, subdevice); + + baseclass = (class) >> 16; + baseclass_mask = (class_mask) >> 16; + subclass = (class) >> 8; + subclass_mask = (class_mask) >> 8; + interface = class; + interface_mask = class_mask; if ((baseclass_mask != 0 && baseclass_mask != 0xFF) || (subclass_mask != 0 && subclass_mask != 0xFF) || (interface_mask != 0 && interface_mask != 0xFF)) { warn("Can't handle masks in %s:%04X\n", - filename, id->class_mask); + filename, class_mask); return 0; } @@ -420,101 +440,105 @@ static int do_pci_entry(const char *filename, add_wildcard(alias); return 1; } -ADD_TO_DEVTABLE("pci", struct pci_device_id, do_pci_entry); +ADD_TO_DEVTABLE("pci", pci_device_id, do_pci_entry); /* looks like: "ccw:tNmNdtNdmN" */ static int do_ccw_entry(const char *filename, - struct ccw_device_id *id, char *alias) + void *symval, char *alias) { - id->match_flags = TO_NATIVE(id->match_flags); - id->cu_type = TO_NATIVE(id->cu_type); - id->cu_model = TO_NATIVE(id->cu_model); - id->dev_type = TO_NATIVE(id->dev_type); - id->dev_model = TO_NATIVE(id->dev_model); + DEF_FIELD(symval, ccw_device_id, match_flags); + DEF_FIELD(symval, ccw_device_id, cu_type); + DEF_FIELD(symval, ccw_device_id, cu_model); + DEF_FIELD(symval, ccw_device_id, dev_type); + DEF_FIELD(symval, ccw_device_id, dev_model); strcpy(alias, "ccw:"); - ADD(alias, "t", id->match_flags&CCW_DEVICE_ID_MATCH_CU_TYPE, - id->cu_type); - ADD(alias, "m", id->match_flags&CCW_DEVICE_ID_MATCH_CU_MODEL, - id->cu_model); - ADD(alias, "dt", id->match_flags&CCW_DEVICE_ID_MATCH_DEVICE_TYPE, - id->dev_type); - ADD(alias, "dm", id->match_flags&CCW_DEVICE_ID_MATCH_DEVICE_MODEL, - id->dev_model); + ADD(alias, "t", match_flags&CCW_DEVICE_ID_MATCH_CU_TYPE, + cu_type); + ADD(alias, "m", match_flags&CCW_DEVICE_ID_MATCH_CU_MODEL, + cu_model); + ADD(alias, "dt", match_flags&CCW_DEVICE_ID_MATCH_DEVICE_TYPE, + dev_type); + ADD(alias, "dm", match_flags&CCW_DEVICE_ID_MATCH_DEVICE_MODEL, + dev_model); add_wildcard(alias); return 1; } -ADD_TO_DEVTABLE("ccw", struct ccw_device_id, do_ccw_entry); +ADD_TO_DEVTABLE("ccw", ccw_device_id, do_ccw_entry); /* looks like: "ap:tN" */ static int do_ap_entry(const char *filename, - struct ap_device_id *id, char *alias) + void *symval, char *alias) { - sprintf(alias, "ap:t%02X*", id->dev_type); + DEF_FIELD(symval, ap_device_id, dev_type); + + sprintf(alias, "ap:t%02X*", dev_type); return 1; } -ADD_TO_DEVTABLE("ap", struct ap_device_id, do_ap_entry); +ADD_TO_DEVTABLE("ap", ap_device_id, do_ap_entry); /* looks like: "css:tN" */ static int do_css_entry(const char *filename, - struct css_device_id *id, char *alias) + void *symval, char *alias) { - sprintf(alias, "css:t%01X", id->type); + DEF_FIELD(symval, css_device_id, type); + + sprintf(alias, "css:t%01X", type); return 1; } -ADD_TO_DEVTABLE("css", struct css_device_id, do_css_entry); +ADD_TO_DEVTABLE("css", css_device_id, do_css_entry); /* Looks like: "serio:tyNprNidNexN" */ static int do_serio_entry(const char *filename, - struct serio_device_id *id, char *alias) + void *symval, char *alias) { - id->type = TO_NATIVE(id->type); - id->proto = TO_NATIVE(id->proto); - id->id = TO_NATIVE(id->id); - id->extra = TO_NATIVE(id->extra); + DEF_FIELD(symval, serio_device_id, type); + DEF_FIELD(symval, serio_device_id, proto); + DEF_FIELD(symval, serio_device_id, id); + DEF_FIELD(symval, serio_device_id, extra); strcpy(alias, "serio:"); - ADD(alias, "ty", id->type != SERIO_ANY, id->type); - ADD(alias, "pr", id->proto != SERIO_ANY, id->proto); - ADD(alias, "id", id->id != SERIO_ANY, id->id); - ADD(alias, "ex", id->extra != SERIO_ANY, id->extra); + ADD(alias, "ty", type != SERIO_ANY, type); + ADD(alias, "pr", proto != SERIO_ANY, proto); + ADD(alias, "id", id != SERIO_ANY, id); + ADD(alias, "ex", extra != SERIO_ANY, extra); add_wildcard(alias); return 1; } -ADD_TO_DEVTABLE("serio", struct serio_device_id, do_serio_entry); +ADD_TO_DEVTABLE("serio", serio_device_id, do_serio_entry); /* looks like: "acpi:ACPI0003 or acpi:PNP0C0B" or "acpi:LNXVIDEO" */ static int do_acpi_entry(const char *filename, - struct acpi_device_id *id, char *alias) + void *symval, char *alias) { - sprintf(alias, "acpi*:%s:*", id->id); + DEF_FIELD_ADDR(symval, acpi_device_id, id); + sprintf(alias, "acpi*:%s:*", *id); return 1; } -ADD_TO_DEVTABLE("acpi", struct acpi_device_id, do_acpi_entry); +ADD_TO_DEVTABLE("acpi", acpi_device_id, do_acpi_entry); /* looks like: "pnp:dD" */ static void do_pnp_device_entry(void *symval, unsigned long size, struct module *mod) { - const unsigned long id_size = sizeof(struct pnp_device_id); + const unsigned long id_size = SIZE_pnp_device_id; const unsigned int count = (size / id_size)-1; - const struct pnp_device_id *devs = symval; unsigned int i; device_id_check(mod->name, "pnp", size, id_size, symval); for (i = 0; i < count; i++) { - const char *id = (char *)devs[i].id; - char acpi_id[sizeof(devs[0].id)]; + DEF_FIELD_ADDR(symval + i*id_size, pnp_device_id, id); + char acpi_id[sizeof(*id)]; int j; buf_printf(&mod->dev_table_buf, - "MODULE_ALIAS(\"pnp:d%s*\");\n", id); + "MODULE_ALIAS(\"pnp:d%s*\");\n", *id); /* fix broken pnp bus lowercasing */ for (j = 0; j < sizeof(acpi_id); j++) - acpi_id[j] = toupper(id[j]); + acpi_id[j] = toupper((*id)[j]); buf_printf(&mod->dev_table_buf, "MODULE_ALIAS(\"acpi*:%s:*\");\n", acpi_id); } @@ -524,19 +548,18 @@ static void do_pnp_device_entry(void *symval, unsigned long size, static void do_pnp_card_entries(void *symval, unsigned long size, struct module *mod) { - const unsigned long id_size = sizeof(struct pnp_card_device_id); + const unsigned long id_size = SIZE_pnp_card_device_id; const unsigned int count = (size / id_size)-1; - const struct pnp_card_device_id *cards = symval; unsigned int i; device_id_check(mod->name, "pnp", size, id_size, symval); for (i = 0; i < count; i++) { unsigned int j; - const struct pnp_card_device_id *card = &cards[i]; + DEF_FIELD_ADDR(symval + i*id_size, pnp_card_device_id, devs); for (j = 0; j < PNP_MAX_DEVICES; j++) { - const char *id = (char *)card->devs[j].id; + const char *id = (char *)(*devs)[j].id; int i2, j2; int dup = 0; @@ -545,10 +568,10 @@ static void do_pnp_card_entries(void *symval, unsigned long size, /* find duplicate, already added value */ for (i2 = 0; i2 < i && !dup; i2++) { - const struct pnp_card_device_id *card2 = &cards[i2]; + DEF_FIELD_ADDR(symval + i2*id_size, pnp_card_device_id, devs); for (j2 = 0; j2 < PNP_MAX_DEVICES; j2++) { - const char *id2 = (char *)card2->devs[j2].id; + const char *id2 = (char *)(*devs)[j2].id; if (!id2[0]) break; @@ -562,7 +585,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size, /* add an individual alias for every device entry */ if (!dup) { - char acpi_id[sizeof(card->devs[0].id)]; + char acpi_id[PNP_ID_LEN]; int k; buf_printf(&mod->dev_table_buf, @@ -580,54 +603,58 @@ static void do_pnp_card_entries(void *symval, unsigned long size, /* Looks like: pcmcia:mNcNfNfnNpfnNvaNvbNvcNvdN. */ static int do_pcmcia_entry(const char *filename, - struct pcmcia_device_id *id, char *alias) + void *symval, char *alias) { unsigned int i; - - id->match_flags = TO_NATIVE(id->match_flags); - id->manf_id = TO_NATIVE(id->manf_id); - id->card_id = TO_NATIVE(id->card_id); - id->func_id = TO_NATIVE(id->func_id); - id->function = TO_NATIVE(id->function); - id->device_no = TO_NATIVE(id->device_no); + DEF_FIELD(symval, pcmcia_device_id, match_flags); + DEF_FIELD(symval, pcmcia_device_id, manf_id); + DEF_FIELD(symval, pcmcia_device_id, card_id); + DEF_FIELD(symval, pcmcia_device_id, func_id); + DEF_FIELD(symval, pcmcia_device_id, function); + DEF_FIELD(symval, pcmcia_device_id, device_no); + DEF_FIELD_ADDR(symval, pcmcia_device_id, prod_id_hash); for (i=0; i<4; i++) { - id->prod_id_hash[i] = TO_NATIVE(id->prod_id_hash[i]); - } - - strcpy(alias, "pcmcia:"); - ADD(alias, "m", id->match_flags & PCMCIA_DEV_ID_MATCH_MANF_ID, - id->manf_id); - ADD(alias, "c", id->match_flags & PCMCIA_DEV_ID_MATCH_CARD_ID, - id->card_id); - ADD(alias, "f", id->match_flags & PCMCIA_DEV_ID_MATCH_FUNC_ID, - id->func_id); - ADD(alias, "fn", id->match_flags & PCMCIA_DEV_ID_MATCH_FUNCTION, - id->function); - ADD(alias, "pfn", id->match_flags & PCMCIA_DEV_ID_MATCH_DEVICE_NO, - id->device_no); - ADD(alias, "pa", id->match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID1, id->prod_id_hash[0]); - ADD(alias, "pb", id->match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID2, id->prod_id_hash[1]); - ADD(alias, "pc", id->match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID3, id->prod_id_hash[2]); - ADD(alias, "pd", id->match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID4, id->prod_id_hash[3]); + (*prod_id_hash)[i] = TO_NATIVE((*prod_id_hash)[i]); + } + + strcpy(alias, "pcmcia:"); + ADD(alias, "m", match_flags & PCMCIA_DEV_ID_MATCH_MANF_ID, + manf_id); + ADD(alias, "c", match_flags & PCMCIA_DEV_ID_MATCH_CARD_ID, + card_id); + ADD(alias, "f", match_flags & PCMCIA_DEV_ID_MATCH_FUNC_ID, + func_id); + ADD(alias, "fn", match_flags & PCMCIA_DEV_ID_MATCH_FUNCTION, + function); + ADD(alias, "pfn", match_flags & PCMCIA_DEV_ID_MATCH_DEVICE_NO, + device_no); + ADD(alias, "pa", match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID1, (*prod_id_hash)[0]); + ADD(alias, "pb", match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID2, (*prod_id_hash)[1]); + ADD(alias, "pc", match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID3, (*prod_id_hash)[2]); + ADD(alias, "pd", match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID4, (*prod_id_hash)[3]); add_wildcard(alias); - return 1; + return 1; } -ADD_TO_DEVTABLE("pcmcia", struct pcmcia_device_id, do_pcmcia_entry); +ADD_TO_DEVTABLE("pcmcia", pcmcia_device_id, do_pcmcia_entry); -static int do_of_entry (const char *filename, struct of_device_id *of, char *alias) +static int do_of_entry (const char *filename, void *symval, char *alias) { int len; char *tmp; + DEF_FIELD_ADDR(symval, of_device_id, name); + DEF_FIELD_ADDR(symval, of_device_id, type); + DEF_FIELD_ADDR(symval, of_device_id, compatible); + len = sprintf (alias, "of:N%sT%s", - of->name[0] ? of->name : "*", - of->type[0] ? of->type : "*"); + (*name)[0] ? *name : "*", + (*type)[0] ? *type : "*"); - if (of->compatible[0]) + if (compatible[0]) sprintf (&alias[len], "%sC%s", - of->type[0] ? "*" : "", - of->compatible); + (*type)[0] ? "*" : "", + *compatible); /* Replace all whitespace with underscores */ 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 add_wildcard(alias); return 1; } -ADD_TO_DEVTABLE("of", struct of_device_id, do_of_entry); +ADD_TO_DEVTABLE("of", of_device_id, do_of_entry); -static int do_vio_entry(const char *filename, struct vio_device_id *vio, +static int do_vio_entry(const char *filename, void *symval, char *alias) { char *tmp; + DEF_FIELD_ADDR(symval, vio_device_id, type); + DEF_FIELD_ADDR(symval, vio_device_id, compat); - sprintf(alias, "vio:T%sS%s", vio->type[0] ? vio->type : "*", - vio->compat[0] ? vio->compat : "*"); + sprintf(alias, "vio:T%sS%s", (*type)[0] ? *type : "*", + (*compat)[0] ? *compat : "*"); /* Replace all whitespace with underscores */ for (tmp = alias; tmp && *tmp; tmp++) @@ -655,7 +684,7 @@ static int do_vio_entry(const char *filename, struct vio_device_id *vio, add_wildcard(alias); return 1; } -ADD_TO_DEVTABLE("vio", struct vio_device_id, do_vio_entry); +ADD_TO_DEVTABLE("vio", vio_device_id, do_vio_entry); #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) @@ -664,154 +693,172 @@ static void do_input(char *alias, { unsigned int i; + for (i = min / BITS_PER_LONG; i < max / BITS_PER_LONG + 1; i++) + arr[i] = TO_NATIVE(arr[i]); for (i = min; i < max; i++) if (arr[i / BITS_PER_LONG] & (1L << (i%BITS_PER_LONG))) sprintf(alias + strlen(alias), "%X,*", i); } /* input:b0v0p0e0-eXkXrXaXmXlXsXfXwX where X is comma-separated %02X. */ -static int do_input_entry(const char *filename, struct input_device_id *id, +static int do_input_entry(const char *filename, void *symval, char *alias) { + DEF_FIELD(symval, input_device_id, flags); + DEF_FIELD(symval, input_device_id, bustype); + DEF_FIELD(symval, input_device_id, vendor); + DEF_FIELD(symval, input_device_id, product); + DEF_FIELD(symval, input_device_id, version); + DEF_FIELD_ADDR(symval, input_device_id, evbit); + DEF_FIELD_ADDR(symval, input_device_id, keybit); + DEF_FIELD_ADDR(symval, input_device_id, relbit); + DEF_FIELD_ADDR(symval, input_device_id, absbit); + DEF_FIELD_ADDR(symval, input_device_id, mscbit); + DEF_FIELD_ADDR(symval, input_device_id, ledbit); + DEF_FIELD_ADDR(symval, input_device_id, sndbit); + DEF_FIELD_ADDR(symval, input_device_id, ffbit); + DEF_FIELD_ADDR(symval, input_device_id, swbit); + sprintf(alias, "input:"); - ADD(alias, "b", id->flags & INPUT_DEVICE_ID_MATCH_BUS, id->bustype); - ADD(alias, "v", id->flags & INPUT_DEVICE_ID_MATCH_VENDOR, id->vendor); - ADD(alias, "p", id->flags & INPUT_DEVICE_ID_MATCH_PRODUCT, id->product); - ADD(alias, "e", id->flags & INPUT_DEVICE_ID_MATCH_VERSION, id->version); + ADD(alias, "b", flags & INPUT_DEVICE_ID_MATCH_BUS, bustype); + ADD(alias, "v", flags & INPUT_DEVICE_ID_MATCH_VENDOR, vendor); + ADD(alias, "p", flags & INPUT_DEVICE_ID_MATCH_PRODUCT, product); + ADD(alias, "e", flags & INPUT_DEVICE_ID_MATCH_VERSION, version); sprintf(alias + strlen(alias), "-e*"); - if (id->flags & INPUT_DEVICE_ID_MATCH_EVBIT) - do_input(alias, id->evbit, 0, INPUT_DEVICE_ID_EV_MAX); + if (flags & INPUT_DEVICE_ID_MATCH_EVBIT) + do_input(alias, *evbit, 0, INPUT_DEVICE_ID_EV_MAX); sprintf(alias + strlen(alias), "k*"); - if (id->flags & INPUT_DEVICE_ID_MATCH_KEYBIT) - do_input(alias, id->keybit, + if (flags & INPUT_DEVICE_ID_MATCH_KEYBIT) + do_input(alias, *keybit, INPUT_DEVICE_ID_KEY_MIN_INTERESTING, INPUT_DEVICE_ID_KEY_MAX); sprintf(alias + strlen(alias), "r*"); - if (id->flags & INPUT_DEVICE_ID_MATCH_RELBIT) - do_input(alias, id->relbit, 0, INPUT_DEVICE_ID_REL_MAX); + if (flags & INPUT_DEVICE_ID_MATCH_RELBIT) + do_input(alias, *relbit, 0, INPUT_DEVICE_ID_REL_MAX); sprintf(alias + strlen(alias), "a*"); - if (id->flags & INPUT_DEVICE_ID_MATCH_ABSBIT) - do_input(alias, id->absbit, 0, INPUT_DEVICE_ID_ABS_MAX); + if (flags & INPUT_DEVICE_ID_MATCH_ABSBIT) + do_input(alias, *absbit, 0, INPUT_DEVICE_ID_ABS_MAX); sprintf(alias + strlen(alias), "m*"); - if (id->flags & INPUT_DEVICE_ID_MATCH_MSCIT) - do_input(alias, id->mscbit, 0, INPUT_DEVICE_ID_MSC_MAX); + if (flags & INPUT_DEVICE_ID_MATCH_MSCIT) + do_input(alias, *mscbit, 0, INPUT_DEVICE_ID_MSC_MAX); sprintf(alias + strlen(alias), "l*"); - if (id->flags & INPUT_DEVICE_ID_MATCH_LEDBIT) - do_input(alias, id->ledbit, 0, INPUT_DEVICE_ID_LED_MAX); + if (flags & INPUT_DEVICE_ID_MATCH_LEDBIT) + do_input(alias, *ledbit, 0, INPUT_DEVICE_ID_LED_MAX); sprintf(alias + strlen(alias), "s*"); - if (id->flags & INPUT_DEVICE_ID_MATCH_SNDBIT) - do_input(alias, id->sndbit, 0, INPUT_DEVICE_ID_SND_MAX); + if (flags & INPUT_DEVICE_ID_MATCH_SNDBIT) + do_input(alias, *sndbit, 0, INPUT_DEVICE_ID_SND_MAX); sprintf(alias + strlen(alias), "f*"); - if (id->flags & INPUT_DEVICE_ID_MATCH_FFBIT) - do_input(alias, id->ffbit, 0, INPUT_DEVICE_ID_FF_MAX); + if (flags & INPUT_DEVICE_ID_MATCH_FFBIT) + do_input(alias, *ffbit, 0, INPUT_DEVICE_ID_FF_MAX); sprintf(alias + strlen(alias), "w*"); - if (id->flags & INPUT_DEVICE_ID_MATCH_SWBIT) - do_input(alias, id->swbit, 0, INPUT_DEVICE_ID_SW_MAX); + if (flags & INPUT_DEVICE_ID_MATCH_SWBIT) + do_input(alias, *swbit, 0, INPUT_DEVICE_ID_SW_MAX); return 1; } -ADD_TO_DEVTABLE("input", struct input_device_id, do_input_entry); +ADD_TO_DEVTABLE("input", input_device_id, do_input_entry); -static int do_eisa_entry(const char *filename, struct eisa_device_id *eisa, +static int do_eisa_entry(const char *filename, void *symval, char *alias) { - if (eisa->sig[0]) - sprintf(alias, EISA_DEVICE_MODALIAS_FMT "*", eisa->sig); + DEF_FIELD_ADDR(symval, eisa_device_id, sig); + if (sig[0]) + sprintf(alias, EISA_DEVICE_MODALIAS_FMT "*", *sig); else strcat(alias, "*"); return 1; } -ADD_TO_DEVTABLE("eisa", struct eisa_device_id, do_eisa_entry); +ADD_TO_DEVTABLE("eisa", eisa_device_id, do_eisa_entry); /* Looks like: parisc:tNhvNrevNsvN */ -static int do_parisc_entry(const char *filename, struct parisc_device_id *id, +static int do_parisc_entry(const char *filename, void *symval, char *alias) { - id->hw_type = TO_NATIVE(id->hw_type); - id->hversion = TO_NATIVE(id->hversion); - id->hversion_rev = TO_NATIVE(id->hversion_rev); - id->sversion = TO_NATIVE(id->sversion); + DEF_FIELD(symval, parisc_device_id, hw_type); + DEF_FIELD(symval, parisc_device_id, hversion); + DEF_FIELD(symval, parisc_device_id, hversion_rev); + DEF_FIELD(symval, parisc_device_id, sversion); strcpy(alias, "parisc:"); - ADD(alias, "t", id->hw_type != PA_HWTYPE_ANY_ID, id->hw_type); - ADD(alias, "hv", id->hversion != PA_HVERSION_ANY_ID, id->hversion); - ADD(alias, "rev", id->hversion_rev != PA_HVERSION_REV_ANY_ID, id->hversion_rev); - ADD(alias, "sv", id->sversion != PA_SVERSION_ANY_ID, id->sversion); + ADD(alias, "t", hw_type != PA_HWTYPE_ANY_ID, hw_type); + ADD(alias, "hv", hversion != PA_HVERSION_ANY_ID, hversion); + ADD(alias, "rev", hversion_rev != PA_HVERSION_REV_ANY_ID, hversion_rev); + ADD(alias, "sv", sversion != PA_SVERSION_ANY_ID, sversion); add_wildcard(alias); return 1; } -ADD_TO_DEVTABLE("parisc", struct parisc_device_id, do_parisc_entry); +ADD_TO_DEVTABLE("parisc", parisc_device_id, do_parisc_entry); /* Looks like: sdio:cNvNdN. */ static int do_sdio_entry(const char *filename, - struct sdio_device_id *id, char *alias) + void *symval, char *alias) { - id->class = TO_NATIVE(id->class); - id->vendor = TO_NATIVE(id->vendor); - id->device = TO_NATIVE(id->device); + DEF_FIELD(symval, sdio_device_id, class); + DEF_FIELD(symval, sdio_device_id, vendor); + DEF_FIELD(symval, sdio_device_id, device); strcpy(alias, "sdio:"); - ADD(alias, "c", id->class != (__u8)SDIO_ANY_ID, id->class); - ADD(alias, "v", id->vendor != (__u16)SDIO_ANY_ID, id->vendor); - ADD(alias, "d", id->device != (__u16)SDIO_ANY_ID, id->device); + ADD(alias, "c", class != (__u8)SDIO_ANY_ID, class); + ADD(alias, "v", vendor != (__u16)SDIO_ANY_ID, vendor); + ADD(alias, "d", device != (__u16)SDIO_ANY_ID, device); add_wildcard(alias); return 1; } -ADD_TO_DEVTABLE("sdio", struct sdio_device_id, do_sdio_entry); +ADD_TO_DEVTABLE("sdio", sdio_device_id, do_sdio_entry); /* Looks like: ssb:vNidNrevN. */ static int do_ssb_entry(const char *filename, - struct ssb_device_id *id, char *alias) + void *symval, char *alias) { - id->vendor = TO_NATIVE(id->vendor); - id->coreid = TO_NATIVE(id->coreid); - id->revision = TO_NATIVE(id->revision); + DEF_FIELD(symval, ssb_device_id, vendor); + DEF_FIELD(symval, ssb_device_id, coreid); + DEF_FIELD(symval, ssb_device_id, revision); strcpy(alias, "ssb:"); - ADD(alias, "v", id->vendor != SSB_ANY_VENDOR, id->vendor); - ADD(alias, "id", id->coreid != SSB_ANY_ID, id->coreid); - ADD(alias, "rev", id->revision != SSB_ANY_REV, id->revision); + ADD(alias, "v", vendor != SSB_ANY_VENDOR, vendor); + ADD(alias, "id", coreid != SSB_ANY_ID, coreid); + ADD(alias, "rev", revision != SSB_ANY_REV, revision); add_wildcard(alias); return 1; } -ADD_TO_DEVTABLE("ssb", struct ssb_device_id, do_ssb_entry); +ADD_TO_DEVTABLE("ssb", ssb_device_id, do_ssb_entry); /* Looks like: bcma:mNidNrevNclN. */ static int do_bcma_entry(const char *filename, - struct bcma_device_id *id, char *alias) + void *symval, char *alias) { - id->manuf = TO_NATIVE(id->manuf); - id->id = TO_NATIVE(id->id); - id->rev = TO_NATIVE(id->rev); - id->class = TO_NATIVE(id->class); + DEF_FIELD(symval, bcma_device_id, manuf); + DEF_FIELD(symval, bcma_device_id, id); + DEF_FIELD(symval, bcma_device_id, rev); + DEF_FIELD(symval, bcma_device_id, class); strcpy(alias, "bcma:"); - ADD(alias, "m", id->manuf != BCMA_ANY_MANUF, id->manuf); - ADD(alias, "id", id->id != BCMA_ANY_ID, id->id); - ADD(alias, "rev", id->rev != BCMA_ANY_REV, id->rev); - ADD(alias, "cl", id->class != BCMA_ANY_CLASS, id->class); + ADD(alias, "m", manuf != BCMA_ANY_MANUF, manuf); + ADD(alias, "id", id != BCMA_ANY_ID, id); + ADD(alias, "rev", rev != BCMA_ANY_REV, rev); + ADD(alias, "cl", class != BCMA_ANY_CLASS, class); add_wildcard(alias); return 1; } -ADD_TO_DEVTABLE("bcma", struct bcma_device_id, do_bcma_entry); +ADD_TO_DEVTABLE("bcma", bcma_device_id, do_bcma_entry); /* Looks like: virtio:dNvN */ -static int do_virtio_entry(const char *filename, struct virtio_device_id *id, +static int do_virtio_entry(const char *filename, void *symval, char *alias) { - id->device = TO_NATIVE(id->device); - id->vendor = TO_NATIVE(id->vendor); + DEF_FIELD(symval, virtio_device_id, device); + DEF_FIELD(symval, virtio_device_id, vendor); strcpy(alias, "virtio:"); - ADD(alias, "d", id->device != VIRTIO_DEV_ANY_ID, id->device); - ADD(alias, "v", id->vendor != VIRTIO_DEV_ANY_ID, id->vendor); + ADD(alias, "d", device != VIRTIO_DEV_ANY_ID, device); + ADD(alias, "v", vendor != VIRTIO_DEV_ANY_ID, vendor); add_wildcard(alias); return 1; } -ADD_TO_DEVTABLE("virtio", struct virtio_device_id, do_virtio_entry); +ADD_TO_DEVTABLE("virtio", virtio_device_id, do_virtio_entry); /* * Looks like: vmbus:guid @@ -819,41 +866,44 @@ ADD_TO_DEVTABLE("virtio", struct virtio_device_id, do_virtio_entry); * in the name. */ -static int do_vmbus_entry(const char *filename, struct hv_vmbus_device_id *id, +static int do_vmbus_entry(const char *filename, void *symval, char *alias) { int i; - char guid_name[((sizeof(id->guid) + 1)) * 2]; + DEF_FIELD_ADDR(symval, hv_vmbus_device_id, guid); + char guid_name[(sizeof(*guid) + 1) * 2]; - for (i = 0; i < (sizeof(id->guid) * 2); i += 2) - sprintf(&guid_name[i], "%02x", id->guid[i/2]); + for (i = 0; i < (sizeof(*guid) * 2); i += 2) + sprintf(&guid_name[i], "%02x", TO_NATIVE((*guid)[i/2])); strcpy(alias, "vmbus:"); strcat(alias, guid_name); return 1; } -ADD_TO_DEVTABLE("vmbus", struct hv_vmbus_device_id, do_vmbus_entry); +ADD_TO_DEVTABLE("vmbus", hv_vmbus_device_id, do_vmbus_entry); /* Looks like: i2c:S */ -static int do_i2c_entry(const char *filename, struct i2c_device_id *id, +static int do_i2c_entry(const char *filename, void *symval, char *alias) { - sprintf(alias, I2C_MODULE_PREFIX "%s", id->name); + DEF_FIELD_ADDR(symval, i2c_device_id, name); + sprintf(alias, I2C_MODULE_PREFIX "%s", *name); return 1; } -ADD_TO_DEVTABLE("i2c", struct i2c_device_id, do_i2c_entry); +ADD_TO_DEVTABLE("i2c", i2c_device_id, do_i2c_entry); /* Looks like: spi:S */ -static int do_spi_entry(const char *filename, struct spi_device_id *id, +static int do_spi_entry(const char *filename, void *symval, char *alias) { - sprintf(alias, SPI_MODULE_PREFIX "%s", id->name); + DEF_FIELD_ADDR(symval, spi_device_id, name); + sprintf(alias, SPI_MODULE_PREFIX "%s", *name); return 1; } -ADD_TO_DEVTABLE("spi", struct spi_device_id, do_spi_entry); +ADD_TO_DEVTABLE("spi", spi_device_id, do_spi_entry); static const struct dmifield { const char *prefix; @@ -885,21 +935,21 @@ static void dmi_ascii_filter(char *d, const char *s) } -static int do_dmi_entry(const char *filename, struct dmi_system_id *id, +static int do_dmi_entry(const char *filename, void *symval, char *alias) { int i, j; - + DEF_FIELD_ADDR(symval, dmi_system_id, matches); sprintf(alias, "dmi*"); for (i = 0; i < ARRAY_SIZE(dmi_fields); i++) { for (j = 0; j < 4; j++) { - if (id->matches[j].slot && - id->matches[j].slot == dmi_fields[i].field) { + if ((*matches)[j].slot && + (*matches)[j].slot == dmi_fields[i].field) { sprintf(alias + strlen(alias), ":%s*", dmi_fields[i].prefix); dmi_ascii_filter(alias + strlen(alias), - id->matches[j].substr); + (*matches)[j].substr); strcat(alias, "*"); } } @@ -908,27 +958,30 @@ static int do_dmi_entry(const char *filename, struct dmi_system_id *id, strcat(alias, ":"); return 1; } -ADD_TO_DEVTABLE("dmi", struct dmi_system_id, do_dmi_entry); +ADD_TO_DEVTABLE("dmi", dmi_system_id, do_dmi_entry); static int do_platform_entry(const char *filename, - struct platform_device_id *id, char *alias) + void *symval, char *alias) { - sprintf(alias, PLATFORM_MODULE_PREFIX "%s", id->name); + DEF_FIELD_ADDR(symval, platform_device_id, name); + sprintf(alias, PLATFORM_MODULE_PREFIX "%s", *name); return 1; } -ADD_TO_DEVTABLE("platform", struct platform_device_id, do_platform_entry); +ADD_TO_DEVTABLE("platform", platform_device_id, do_platform_entry); static int do_mdio_entry(const char *filename, - struct mdio_device_id *id, char *alias) + void *symval, char *alias) { int i; + DEF_FIELD(symval, mdio_device_id, phy_id); + DEF_FIELD(symval, mdio_device_id, phy_id_mask); alias += sprintf(alias, MDIO_MODULE_PREFIX); for (i = 0; i < 32; i++) { - if (!((id->phy_id_mask >> (31-i)) & 1)) + if (!((phy_id_mask >> (31-i)) & 1)) *(alias++) = '?'; - else if ((id->phy_id >> (31-i)) & 1) + else if ((phy_id >> (31-i)) & 1) *(alias++) = '1'; else *(alias++) = '0'; @@ -939,47 +992,50 @@ static int do_mdio_entry(const char *filename, return 1; } -ADD_TO_DEVTABLE("mdio", struct mdio_device_id, do_mdio_entry); +ADD_TO_DEVTABLE("mdio", mdio_device_id, do_mdio_entry); /* Looks like: zorro:iN. */ -static int do_zorro_entry(const char *filename, struct zorro_device_id *id, +static int do_zorro_entry(const char *filename, void *symval, char *alias) { - id->id = TO_NATIVE(id->id); + DEF_FIELD(symval, zorro_device_id, id); strcpy(alias, "zorro:"); - ADD(alias, "i", id->id != ZORRO_WILDCARD, id->id); + ADD(alias, "i", id != ZORRO_WILDCARD, id); return 1; } -ADD_TO_DEVTABLE("zorro", struct zorro_device_id, do_zorro_entry); +ADD_TO_DEVTABLE("zorro", zorro_device_id, do_zorro_entry); /* looks like: "pnp:dD" */ static int do_isapnp_entry(const char *filename, - struct isapnp_device_id *id, char *alias) + void *symval, char *alias) { + DEF_FIELD(symval, isapnp_device_id, vendor); + DEF_FIELD(symval, isapnp_device_id, function); sprintf(alias, "pnp:d%c%c%c%x%x%x%x*", - 'A' + ((id->vendor >> 2) & 0x3f) - 1, - 'A' + (((id->vendor & 3) << 3) | ((id->vendor >> 13) & 7)) - 1, - 'A' + ((id->vendor >> 8) & 0x1f) - 1, - (id->function >> 4) & 0x0f, id->function & 0x0f, - (id->function >> 12) & 0x0f, (id->function >> 8) & 0x0f); + 'A' + ((vendor >> 2) & 0x3f) - 1, + 'A' + (((vendor & 3) << 3) | ((vendor >> 13) & 7)) - 1, + 'A' + ((vendor >> 8) & 0x1f) - 1, + (function >> 4) & 0x0f, function & 0x0f, + (function >> 12) & 0x0f, (function >> 8) & 0x0f); return 1; } -ADD_TO_DEVTABLE("isapnp", struct isapnp_device_id, do_isapnp_entry); +ADD_TO_DEVTABLE("isapnp", isapnp_device_id, do_isapnp_entry); /* Looks like: "ipack:fNvNdN". */ static int do_ipack_entry(const char *filename, - struct ipack_device_id *id, char *alias) + void *symval, char *alias) { - id->vendor = TO_NATIVE(id->vendor); - id->device = TO_NATIVE(id->device); + DEF_FIELD(symval, ipack_device_id, format); + DEF_FIELD(symval, ipack_device_id, vendor); + DEF_FIELD(symval, ipack_device_id, device); strcpy(alias, "ipack:"); - ADD(alias, "f", id->format != IPACK_ANY_FORMAT, id->format); - ADD(alias, "v", id->vendor != IPACK_ANY_ID, id->vendor); - ADD(alias, "d", id->device != IPACK_ANY_ID, id->device); + ADD(alias, "f", format != IPACK_ANY_FORMAT, format); + ADD(alias, "v", vendor != IPACK_ANY_ID, vendor); + ADD(alias, "d", device != IPACK_ANY_ID, device); add_wildcard(alias); return 1; } -ADD_TO_DEVTABLE("ipack", struct ipack_device_id, do_ipack_entry); +ADD_TO_DEVTABLE("ipack", ipack_device_id, do_ipack_entry); /* * Append a match expression for a single masked hex digit. @@ -1030,25 +1086,27 @@ static void append_nibble_mask(char **outp, * a ? or [] pattern matching exactly one digit. */ static int do_amba_entry(const char *filename, - struct amba_id *id, char *alias) + void *symval, char *alias) { unsigned int digit; char *p = alias; + DEF_FIELD(symval, amba_id, id); + DEF_FIELD(symval, amba_id, mask); - if ((id->id & id->mask) != id->id) + if ((id & mask) != id) fatal("%s: Masked-off bit(s) of AMBA device ID are non-zero: " "id=0x%08X, mask=0x%08X. Please fix this driver.\n", - filename, id->id, id->mask); + filename, id, mask); p += sprintf(alias, "amba:d"); for (digit = 0; digit < 8; digit++) append_nibble_mask(&p, - (id->id >> (4 * (7 - digit))) & 0xf, - (id->mask >> (4 * (7 - digit))) & 0xf); + (id >> (4 * (7 - digit))) & 0xf, + (mask >> (4 * (7 - digit))) & 0xf); return 1; } -ADD_TO_DEVTABLE("amba", struct amba_id, do_amba_entry); +ADD_TO_DEVTABLE("amba", amba_id, do_amba_entry); /* LOOKS like x86cpu:vendor:VVVV:family:FFFF:model:MMMM:feature:*,FEAT,* * 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); * complicated. */ -static int do_x86cpu_entry(const char *filename, struct x86_cpu_id *id, +static int do_x86cpu_entry(const char *filename, void *symval, char *alias) { - id->feature = TO_NATIVE(id->feature); - id->family = TO_NATIVE(id->family); - id->model = TO_NATIVE(id->model); - id->vendor = TO_NATIVE(id->vendor); + DEF_FIELD(symval, x86_cpu_id, feature); + DEF_FIELD(symval, x86_cpu_id, family); + DEF_FIELD(symval, x86_cpu_id, model); + DEF_FIELD(symval, x86_cpu_id, vendor); strcpy(alias, "x86cpu:"); - ADD(alias, "vendor:", id->vendor != X86_VENDOR_ANY, id->vendor); - ADD(alias, ":family:", id->family != X86_FAMILY_ANY, id->family); - ADD(alias, ":model:", id->model != X86_MODEL_ANY, id->model); + ADD(alias, "vendor:", vendor != X86_VENDOR_ANY, vendor); + ADD(alias, ":family:", family != X86_FAMILY_ANY, family); + ADD(alias, ":model:", model != X86_MODEL_ANY, model); strcat(alias, ":feature:*"); - if (id->feature != X86_FEATURE_ANY) - sprintf(alias + strlen(alias), "%04X*", id->feature); + if (feature != X86_FEATURE_ANY) + sprintf(alias + strlen(alias), "%04X*", feature); return 1; } -ADD_TO_DEVTABLE("x86cpu", struct x86_cpu_id, do_x86cpu_entry); +ADD_TO_DEVTABLE("x86cpu", x86_cpu_id, do_x86cpu_entry); /* Does namelen bytes of name exactly match the symbol? */ 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) struct ext_sym_list *extsym_iter; struct ext_sym_list *extsym_start = NULL; - while ((opt = getopt(argc, argv, "i:I:e:cmsSo:awM:K:")) != -1) { + while ((opt = getopt(argc, argv, "i:I:e:msSo:awM:K:")) != -1) { switch (opt) { case 'i': kernel_read = optarg; @@ -2137,9 +2137,6 @@ int main(int argc, char **argv) module_read = optarg; external_module = 1; break; - case 'c': - cross_build = 1; - break; case 'e': external_module = 1; 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() fi # Check for svn and a svn repo. - if rev=`svn info 2>/dev/null | grep '^Last Changed Rev'`; then + if rev=`LANG= LC_ALL= LC_MESSAGES=C svn info 2>/dev/null | grep '^Last Changed Rev'`; then rev=`echo $rev | awk '{print $NF}'` printf -- '-svn%s' "$rev" |