diff options
Diffstat (limited to 'scripts')
28 files changed, 1165 insertions, 453 deletions
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.lib b/scripts/Makefile.lib index bdf42fdf64c9..07125e697d7a 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -156,6 +156,11 @@ cpp_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ ld_flags = $(LDFLAGS) $(ldflags-y) +dtc_cpp_flags = -Wp,-MD,$(depfile) -nostdinc \ + -I$(srctree)/arch/$(SRCARCH)/boot/dts \ + -I$(srctree)/arch/$(SRCARCH)/include/dts \ + -undef -D__DTS__ + # Finds the multi-part object the current object will be linked into modname-multi = $(sort $(foreach m,$(multi-used),\ $(if $(filter $(subst $(obj)/,,$*.o), $($(m:.o=-objs)) $($(m:.o=-y))),$(m:.o=)))) @@ -269,6 +274,15 @@ cmd_dtc = $(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 $(DTC_FLAGS) -d $(depfile $(obj)/%.dtb: $(src)/%.dts FORCE $(call if_changed_dep,dtc) +dtc-tmp = $(subst $(comma),_,$(dot-target).dts) + +quiet_cmd_dtc_cpp = DTC+CPP $@ +cmd_dtc_cpp = $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \ + $(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 $(DTC_FLAGS) $(dtc-tmp) + +$(obj)/%.dtb: $(src)/%.dtsp FORCE + $(call if_changed_dep,dtc_cpp) + # Bzip2 # --------------------------------------------------------------------------- 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/basic/fixdep.c b/scripts/basic/fixdep.c index cb1f50cf12e3..7f6425e24ce3 100644 --- a/scripts/basic/fixdep.c +++ b/scripts/basic/fixdep.c @@ -409,7 +409,7 @@ static void traps(void) int *p = (int *)test; if (*p != INT_CONF) { - fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianess? %#x\n", + fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianness? %#x\n", *p); exit(2); } diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 4d2c7dfdaabd..b28cc384a5bc 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -230,12 +230,12 @@ our $Inline = qr{inline|__always_inline|noinline}; our $Member = qr{->$Ident|\.$Ident|\[[^]]*\]}; our $Lval = qr{$Ident(?:$Member)*}; -our $Float_hex = qr{(?i:0x[0-9a-f]+p-?[0-9]+[fl]?)}; -our $Float_dec = qr{(?i:((?:[0-9]+\.[0-9]*|[0-9]*\.[0-9]+)(?:e-?[0-9]+)?[fl]?))}; -our $Float_int = qr{(?i:[0-9]+e-?[0-9]+[fl]?)}; +our $Float_hex = qr{(?i)0x[0-9a-f]+p-?[0-9]+[fl]?}; +our $Float_dec = qr{(?i)(?:[0-9]+\.[0-9]*|[0-9]*\.[0-9]+)(?:e-?[0-9]+)?[fl]?}; +our $Float_int = qr{(?i)[0-9]+e-?[0-9]+[fl]?}; our $Float = qr{$Float_hex|$Float_dec|$Float_int}; -our $Constant = qr{(?:$Float|(?i:(?:0x[0-9a-f]+|[0-9]+)[ul]*))}; -our $Assignment = qr{(?:\*\=|/=|%=|\+=|-=|<<=|>>=|&=|\^=|\|=|=)}; +our $Constant = qr{$Float|(?i)(?:0x[0-9a-f]+|[0-9]+)[ul]*}; +our $Assignment = qr{\*\=|/=|%=|\+=|-=|<<=|>>=|&=|\^=|\|=|=}; our $Compare = qr{<=|>=|==|!=|<|>}; our $Operators = qr{ <=|>=|==|!=| @@ -1931,6 +1931,12 @@ sub process { "use the SSYNC() macro in asm/blackfin.h\n" . $herevet); } +# check for old HOTPLUG __dev<foo> section markings + if ($line =~ /\b(__dev(init|exit)(data|const|))\b/) { + WARN("HOTPLUG_SECTION", + "Using $1 is unnecessary\n" . $herecurr); + } + # Check for potential 'bare' types my ($stat, $cond, $line_nr_next, $remain_next, $off_next, $realline_next); @@ -2430,6 +2436,15 @@ sub process { "Prefer pr_warn(... to pr_warning(...\n" . $herecurr); } + if ($line =~ /\bdev_printk\s*\(\s*KERN_([A-Z]+)/) { + my $orig = $1; + my $level = lc($orig); + $level = "warn" if ($level eq "warning"); + $level = "dbg" if ($level eq "debug"); + WARN("PREFER_DEV_LEVEL", + "Prefer dev_$level(... to dev_printk(KERN_$orig, ...\n" . $herecurr); + } + # function brace can't be on same line, except for #defines of do while, # or if closed on same line if (($line=~/$Type\s*$Ident\(.*\).*\s{/) and @@ -2915,6 +2930,7 @@ sub process { my $var = $1; if ($var !~ /$Constant/ && $var =~ /[A-Z]\w*[a-z]|[a-z]\w*[A-Z]/ && + $var !~ /"^(?:Clear|Set|TestClear|TestSet|)Page[A-Z]/ && !defined $camelcase{$var}) { $camelcase{$var} = 1; WARN("CAMELCASE", @@ -3237,9 +3253,9 @@ sub process { } # prefer usleep_range over udelay - if ($line =~ /\budelay\s*\(\s*(\w+)\s*\)/) { + if ($line =~ /\budelay\s*\(\s*(\d+)\s*\)/) { # ignore udelay's < 10, however - if (! (($1 =~ /(\d+)/) && ($1 < 10)) ) { + if (! ($1 < 10) ) { CHK("USLEEP_RANGE", "usleep_range is preferred over udelay; see Documentation/timers/timers-howto.txt\n" . $line); } @@ -3460,6 +3476,12 @@ sub process { "unnecessary cast may hide bugs, see http://c-faq.com/malloc/mallocnocast.html\n" . $herecurr); } +# check for alloc argument mismatch + if ($line =~ /\b(kcalloc|kmalloc_array)\s*\(\s*sizeof\b/) { + WARN("ALLOC_ARRAY_ARGS", + "$1 uses number as first arg, sizeof is generally wrong\n" . $herecurr); + } + # check for multiple semicolons if ($line =~ /;\s*;\s*$/) { WARN("ONE_SEMICOLON", diff --git a/scripts/checkstack.pl b/scripts/checkstack.pl index 17e384396705..544aa56b6200 100755 --- a/scripts/checkstack.pl +++ b/scripts/checkstack.pl @@ -34,7 +34,7 @@ use strict; # $1 (first bracket) matches the dynamic amount of the stack growth # # use anything else and feel the pain ;) -my (@stack, $re, $dre, $x, $xs); +my (@stack, $re, $dre, $x, $xs, $funcre); { my $arch = shift; if ($arch eq "") { @@ -44,6 +44,7 @@ my (@stack, $re, $dre, $x, $xs); $x = "[0-9a-f]"; # hex character $xs = "[0-9a-f ]"; # hex character or space + $funcre = qr/^$x* <(.*)>:$/; if ($arch eq 'arm') { #c0008ffc: e24dd064 sub sp, sp, #100 ; 0x64 $re = qr/.*sub.*sp, sp, #(([0-9]{2}|[3-9])[0-9]{2})/o; @@ -66,6 +67,10 @@ my (@stack, $re, $dre, $x, $xs); # 2b6c: 4e56 fb70 linkw %fp,#-1168 # 1df770: defc ffe4 addaw #-28,%sp $re = qr/.*(?:linkw %fp,|addaw )#-([0-9]{1,4})(?:,%sp)?$/o; + } elsif ($arch eq 'metag') { + #400026fc: 40 00 00 82 ADD A0StP,A0StP,#0x8 + $re = qr/.*ADD.*A0StP,A0StP,\#(0x$x{1,8})/o; + $funcre = qr/^$x* <[^\$](.*)>:$/; } elsif ($arch eq 'mips64') { #8800402c: 67bdfff0 daddiu sp,sp,-16 $re = qr/.*daddiu.*sp,sp,-(([0-9]{2}|[3-9])[0-9]{2})/o; @@ -109,7 +114,6 @@ my (@stack, $re, $dre, $x, $xs); # # main() # -my $funcre = qr/^$x* <(.*)>:$/; my ($func, $file, $lastslash); while (my $line = <STDIN>) { diff --git a/scripts/coccicheck b/scripts/coccicheck index 1a49d1c7ecfe..85d31899ad98 100755 --- a/scripts/coccicheck +++ b/scripts/coccicheck @@ -2,6 +2,15 @@ SPATCH="`which ${SPATCH:=spatch}`" +# The verbosity may be set by the environmental parameter V= +# as for example with 'make V=1 coccicheck' + +if [ -n "$V" -a "$V" != "0" ]; then + VERBOSE=1 +else + VERBOSE=0 +fi + if [ "$C" = "1" -o "$C" = "2" ]; then ONLINE=1 @@ -46,6 +55,14 @@ if [ "$ONLINE" = "0" ] ; then echo '' fi +run_cmd() { + if [ $VERBOSE -ne 0 ] ; then + echo "Running: $@" + fi + eval $@ +} + + coccinelle () { COCCI="$1" @@ -55,7 +72,7 @@ coccinelle () { # # $SPATCH -D $MODE $FLAGS -parse_cocci $COCCI $OPT > /dev/null - if [ "$ONLINE" = "0" ] ; then + if [ $VERBOSE -ne 0 ] ; then FILE=`echo $COCCI | sed "s|$srctree/||"` @@ -91,15 +108,21 @@ coccinelle () { fi if [ "$MODE" = "chain" ] ; then - $SPATCH -D patch $FLAGS -sp_file $COCCI $OPT $OPTIONS || \ - $SPATCH -D report $FLAGS -sp_file $COCCI $OPT $OPTIONS -no_show_diff || \ - $SPATCH -D context $FLAGS -sp_file $COCCI $OPT $OPTIONS || \ - $SPATCH -D org $FLAGS -sp_file $COCCI $OPT $OPTIONS -no_show_diff || exit 1 + run_cmd $SPATCH -D patch \ + $FLAGS -sp_file $COCCI $OPT $OPTIONS || \ + run_cmd $SPATCH -D report \ + $FLAGS -sp_file $COCCI $OPT $OPTIONS -no_show_diff || \ + run_cmd $SPATCH -D context \ + $FLAGS -sp_file $COCCI $OPT $OPTIONS || \ + run_cmd $SPATCH -D org \ + $FLAGS -sp_file $COCCI $OPT $OPTIONS -no_show_diff || exit 1 elif [ "$MODE" = "rep+ctxt" ] ; then - $SPATCH -D report $FLAGS -sp_file $COCCI $OPT $OPTIONS -no_show_diff && \ - $SPATCH -D context $FLAGS -sp_file $COCCI $OPT $OPTIONS || exit 1 + run_cmd $SPATCH -D report \ + $FLAGS -sp_file $COCCI $OPT $OPTIONS -no_show_diff && \ + run_cmd $SPATCH -D context \ + $FLAGS -sp_file $COCCI $OPT $OPTIONS || exit 1 else - $SPATCH -D $MODE $FLAGS -sp_file $COCCI $OPT $OPTIONS || exit 1 + run_cmd $SPATCH -D $MODE $FLAGS -sp_file $COCCI $OPT $OPTIONS || exit 1 fi } diff --git a/scripts/coccinelle/api/devm_ioremap_resource.cocci b/scripts/coccinelle/api/devm_ioremap_resource.cocci new file mode 100644 index 000000000000..495daa3dbf77 --- /dev/null +++ b/scripts/coccinelle/api/devm_ioremap_resource.cocci @@ -0,0 +1,90 @@ +virtual patch +virtual report + +@depends on patch@ +expression base, dev, res; +@@ + +-base = devm_request_and_ioremap(dev, res); ++base = devm_ioremap_resource(dev, res); + ... + if ( +-base == NULL ++IS_ERR(base) + || ...) { +<... +- return ...; ++ return PTR_ERR(base); +...> + } + +@depends on patch@ +expression e, E, ret; +identifier l; +@@ + + e = devm_ioremap_resource(...); + ... + if (IS_ERR(e) || ...) { + ... when any +- ret = E; ++ ret = PTR_ERR(e); + ... +( + return ret; +| + goto l; +) + } + +@depends on patch@ +expression e; +@@ + + e = devm_ioremap_resource(...); + ... + if (IS_ERR(e) || ...) { + ... +- \(dev_dbg\|dev_err\|pr_debug\|pr_err\|DRM_ERROR\)(...); + ... + } + +@depends on patch@ +expression e; +identifier l; +@@ + + e = devm_ioremap_resource(...); + ... + if (IS_ERR(e) || ...) +-{ +( + return ...; +| + goto l; +) +-} + +@r depends on report@ +expression e; +identifier l; +position p1; +@@ + +*e = devm_request_and_ioremap@p1(...); + ... + if (e == NULL || ...) { + ... +( + return ...; +| + goto l; +) + } + +@script:python depends on r@ +p1 << r.p1; +@@ + +msg = "ERROR: deprecated devm_request_and_ioremap() API used on line %s" % (p1[0].line) +coccilib.report.print_report(p1[0], msg) diff --git a/scripts/coccinelle/misc/memcpy-assign.cocci b/scripts/coccinelle/misc/memcpy-assign.cocci new file mode 100644 index 000000000000..afd058be497f --- /dev/null +++ b/scripts/coccinelle/misc/memcpy-assign.cocci @@ -0,0 +1,103 @@ +// +// Replace memcpy with struct assignment. +// +// Confidence: High +// Copyright: (C) 2012 Peter Senna Tschudin, INRIA/LIP6. GPLv2. +// URL: http://coccinelle.lip6.fr/ +// Comments: +// Options: --no-includes --include-headers + +virtual patch +virtual report +virtual context +virtual org + +@r1 depends on !patch@ +identifier struct_name; +struct struct_name to; +struct struct_name from; +struct struct_name *top; +struct struct_name *fromp; +position p; +@@ +memcpy@p(\(&(to)\|top\), \(&(from)\|fromp\), \(sizeof(to)\|sizeof(from)\|sizeof(struct struct_name)\|sizeof(*top)\|sizeof(*fromp)\)) + +@script:python depends on report@ +p << r1.p; +@@ +coccilib.report.print_report(p[0],"Replace memcpy with struct assignment") + +@depends on context@ +position r1.p; +@@ +*memcpy@p(...); + +@script:python depends on org@ +p << r1.p; +@@ +cocci.print_main("Replace memcpy with struct assignment",p) + +@depends on patch@ +identifier struct_name; +struct struct_name to; +struct struct_name from; +@@ +( +-memcpy(&(to), &(from), sizeof(to)); ++to = from; +| +-memcpy(&(to), &(from), sizeof(from)); ++to = from; +| +-memcpy(&(to), &(from), sizeof(struct struct_name)); ++to = from; +) + +@depends on patch@ +identifier struct_name; +struct struct_name to; +struct struct_name *from; +@@ +( +-memcpy(&(to), from, sizeof(to)); ++to = *from; +| +-memcpy(&(to), from, sizeof(*from)); ++to = *from; +| +-memcpy(&(to), from, sizeof(struct struct_name)); ++to = *from; +) + +@depends on patch@ +identifier struct_name; +struct struct_name *to; +struct struct_name from; +@@ +( +-memcpy(to, &(from), sizeof(*to)); ++ *to = from; +| +-memcpy(to, &(from), sizeof(from)); ++ *to = from; +| +-memcpy(to, &(from), sizeof(struct struct_name)); ++ *to = from; +) + +@depends on patch@ +identifier struct_name; +struct struct_name *to; +struct struct_name *from; +@@ +( +-memcpy(to, from, sizeof(*to)); ++ *to = *from; +| +-memcpy(to, from, sizeof(*from)); ++ *to = *from; +| +-memcpy(to, from, sizeof(struct struct_name)); ++ *to = *from; +) + diff --git a/scripts/coccinelle/misc/orplus.cocci b/scripts/coccinelle/misc/orplus.cocci new file mode 100644 index 000000000000..4a28cef1484e --- /dev/null +++ b/scripts/coccinelle/misc/orplus.cocci @@ -0,0 +1,55 @@ +/// Check for constants that are added but are used elsewhere as bitmasks +/// The results should be checked manually to ensure that the nonzero +/// bits in the two constants are actually disjoint. +/// +// Confidence: Moderate +// Copyright: (C) 2013 Julia Lawall, INRIA/LIP6. GPLv2. +// Copyright: (C) 2013 Gilles Muller, INRIA/LIP6. GPLv2. +// URL: http://coccinelle.lip6.fr/ +// Comments: +// Options: -no_includes -include_headers + +virtual org +virtual report +virtual context + +@r@ +constant c; +identifier i; +expression e; +@@ + +( +e | c@i +| +e & c@i +| +e |= c@i +| +e &= c@i +) + +@s@ +constant r.c,c1; +identifier i1; +position p; +@@ + +( + c1 + c - 1 +| +*c1@i1 +@p c +) + +@script:python depends on org@ +p << s.p; +@@ + +cocci.print_main("sum of probable bitmasks, consider |",p) + +@script:python depends on report@ +p << s.p; +@@ + +msg = "WARNING: sum of probable bitmasks, consider |" +coccilib.report.print_report(p[0],msg) diff --git a/scripts/coccinelle/misc/semicolon.cocci b/scripts/coccinelle/misc/semicolon.cocci new file mode 100644 index 000000000000..a47eba2edc9e --- /dev/null +++ b/scripts/coccinelle/misc/semicolon.cocci @@ -0,0 +1,83 @@ +/// +/// Removes unneeded semicolon. +/// +// Confidence: Moderate +// Copyright: (C) 2012 Peter Senna Tschudin, INRIA/LIP6. GPLv2. +// URL: http://coccinelle.lip6.fr/ +// Comments: Some false positives on empty default cases in switch statements. +// Options: --no-includes --include-headers + +virtual patch +virtual report +virtual context +virtual org + +@r_default@ +position p; +@@ +switch (...) +{ +default: ...;@p +} + +@r_case@ +position p; +@@ +( +switch (...) +{ +case ...:;@p +} +| +switch (...) +{ +case ...:... +case ...:;@p +} +| +switch (...) +{ +case ...:... +case ...: +case ...:;@p +} +) + +@r1@ +statement S; +position p1; +position p != {r_default.p, r_case.p}; +identifier label; +@@ +( +label:; +| +S@p1;@p +) + +@script:python@ +p << r1.p; +p1 << r1.p1; +@@ +if p[0].line != p1[0].line_end: + cocci.include_match(False) + +@depends on patch@ +position r1.p; +@@ +-;@p + +@script:python depends on report@ +p << r1.p; +@@ +coccilib.report.print_report(p[0],"Unneeded semicolon") + +@depends on context@ +position r1.p; +@@ +*;@p + +@script:python depends on org@ +p << r1.p; +@@ +cocci.print_main("Unneeded semicolon",p) 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/genksyms/genksyms.c b/scripts/genksyms/genksyms.c index 8a106499ec4f..d25e4a118d37 100644 --- a/scripts/genksyms/genksyms.c +++ b/scripts/genksyms/genksyms.c @@ -826,7 +826,8 @@ int main(int argc, char **argv) genksyms_usage(); return 1; } - if ((strcmp(arch, "h8300") == 0) || (strcmp(arch, "blackfin") == 0)) + if ((strcmp(arch, "h8300") == 0) || (strcmp(arch, "blackfin") == 0) || + (strcmp(arch, "metag") == 0)) mod_prefix = "_"; { extern int yydebug; diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl index 8b673dd4627f..ce4cc837b748 100755 --- a/scripts/get_maintainer.pl +++ b/scripts/get_maintainer.pl @@ -433,7 +433,7 @@ foreach my $file (@ARGV) { while (<$patch>) { my $patch_line = $_; - if (m/^\+\+\+\s+(\S+)/) { + if (m/^\+\+\+\s+(\S+)/ or m/^---\s+(\S+)/) { my $filename = $1; $filename =~ s@^[^/]*/@@; $filename =~ s@\n@@; @@ -611,6 +611,10 @@ sub get_maintainers { $hash{$tvi} = $value_pd; } } + } elsif ($type eq 'K') { + if ($file =~ m/$value/x) { + $hash{$tvi} = 0; + } } } } diff --git a/scripts/headers_install.pl b/scripts/headers_install.pl index 6c353ae8a451..581ca99c96f2 100644 --- a/scripts/headers_install.pl +++ b/scripts/headers_install.pl @@ -42,9 +42,9 @@ foreach my $filename (@files) { $line =~ s/(^|\s)(inline)\b/$1__$2__/g; $line =~ s/(^|\s)(asm)\b(\s|[(]|$)/$1__$2__$3/g; $line =~ s/(^|\s|[(])(volatile)\b(\s|[(]|$)/$1__$2__$3/g; - $line =~ s/#ifndef _UAPI/#ifndef /; - $line =~ s/#define _UAPI/#define /; - $line =~ s!#endif /[*] _UAPI!#endif /* !; + $line =~ s/#ifndef\s+_UAPI/#ifndef /; + $line =~ s/#define\s+_UAPI/#define /; + $line =~ s!#endif\s+/[*]\s*_UAPI!#endif /* !; printf {$out} "%s", $line; } close $out; diff --git a/scripts/kernel-doc b/scripts/kernel-doc index 28b761567815..4305b2f2ec5e 100755 --- a/scripts/kernel-doc +++ b/scripts/kernel-doc @@ -1750,7 +1750,7 @@ sub dump_struct($$) { # strip kmemcheck_bitfield_{begin,end}.*; $members =~ s/kmemcheck_bitfield_.*?;//gos; # strip attributes - $members =~ s/__aligned\s*\(\d+\)//gos; + $members =~ s/__aligned\s*\(.+\)//gos; create_parameterlist($members, ';', $file); check_sections($file, $declaration_name, "struct", $sectcheck, $struct_actual, $nested); @@ -2079,7 +2079,6 @@ sub dump_function($$) { $prototype =~ s/^__inline +//; $prototype =~ s/^__always_inline +//; $prototype =~ s/^noinline +//; - $prototype =~ s/__devinit +//; $prototype =~ s/__init +//; $prototype =~ s/__init_or_module +//; $prototype =~ s/__must_check +//; 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 ff36c508a10e..78b30c1548e9 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -830,6 +830,8 @@ static const char *section_white_list[] = ".toc*", ".xt.prop", /* xtensa */ ".xt.lit", /* xtensa */ + ".arcextmap*", /* arc */ + ".gnu.linkonce.arcext*", /* arc : modules */ NULL }; @@ -2126,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; @@ -2135,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/package/mkspec b/scripts/package/mkspec index 4bf17ddf7c7f..fbbfd08853d3 100755 --- a/scripts/package/mkspec +++ b/scripts/package/mkspec @@ -95,7 +95,7 @@ echo 'cp $KBUILD_IMAGE $RPM_BUILD_ROOT'"/boot/vmlinuz-$KERNELRELEASE" echo "%endif" echo "%endif" -echo 'make %{?_smp_mflags} INSTALL_HDR_PATH=$RPM_BUILD_ROOT/usr headers_install' +echo 'make %{?_smp_mflags} INSTALL_HDR_PATH=$RPM_BUILD_ROOT/usr KBUILD_SRC= headers_install' echo 'cp System.map $RPM_BUILD_ROOT'"/boot/System.map-$KERNELRELEASE" echo 'cp .config $RPM_BUILD_ROOT'"/boot/config-$KERNELRELEASE" diff --git a/scripts/recordmcount.c b/scripts/recordmcount.c index ee52cb8e17ad..9c22317778eb 100644 --- a/scripts/recordmcount.c +++ b/scripts/recordmcount.c @@ -33,6 +33,13 @@ #include <string.h> #include <unistd.h> +#ifndef EM_METAG +/* Remove this when these make it to the standard system elf.h. */ +#define EM_METAG 174 +#define R_METAG_ADDR32 2 +#define R_METAG_NONE 3 +#endif + static int fd_map; /* File descriptor for file being modified. */ static int mmap_failed; /* Boolean flag. */ static void *ehdr_curr; /* current ElfXX_Ehdr * for resource cleanup */ @@ -341,6 +348,12 @@ do_file(char const *const fname) altmcount = "__gnu_mcount_nc"; break; case EM_IA_64: reltype = R_IA64_IMM64; gpfx = '_'; break; + case EM_METAG: reltype = R_METAG_ADDR32; + altmcount = "_mcount_wrapper"; + rel_type_nop = R_METAG_NONE; + /* We happen to have the same requirement as MIPS */ + is_fake_mcount32 = MIPS32_is_fake_mcount; + break; case EM_MIPS: /* reltype: e_class */ gpfx = '_'; break; case EM_PPC: reltype = R_PPC_ADDR32; gpfx = '_'; break; case EM_PPC64: reltype = R_PPC64_ADDR64; gpfx = '_'; break; 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" diff --git a/scripts/sign-file b/scripts/sign-file index 974a20b661b7..2b7c4484d46c 100755 --- a/scripts/sign-file +++ b/scripts/sign-file @@ -2,51 +2,45 @@ # # Sign a module file using the given key. # -# Format: -# -# ./scripts/sign-file [-v] <key> <x509> <module> [<dest>] -# -# + +my $USAGE = +"Usage: scripts/sign-file [-v] <hash algo> <key> <x509> <module> [<dest>]\n" . +" scripts/sign-file [-v] -s <raw sig> <hash algo> <x509> <module> [<dest>]\n"; + use strict; use FileHandle; use IPC::Open2; +use Getopt::Std; -my $verbose = 0; -if ($#ARGV >= 0 && $ARGV[0] eq "-v") { - $verbose = 1; - shift; -} +my %opts; +getopts('vs:', \%opts) or die $USAGE; +my $verbose = $opts{'v'}; +my $signature_file = $opts{'s'}; -die "Format: ./scripts/sign-file [-v] <key> <x509> <module> [<dest>]\n" - if ($#ARGV != 2 && $#ARGV != 3); +die $USAGE if ($#ARGV > 4); +die $USAGE if (!$signature_file && $#ARGV < 3 || $signature_file && $#ARGV < 2); -my $private_key = $ARGV[0]; -my $x509 = $ARGV[1]; -my $module = $ARGV[2]; -my $dest = ($#ARGV == 3) ? $ARGV[3] : $ARGV[2] . "~"; +my $dgst = shift @ARGV; +my $private_key; +if (!$signature_file) { + $private_key = shift @ARGV; +} +my $x509 = shift @ARGV; +my $module = shift @ARGV; +my ($dest, $keep_orig); +if (@ARGV) { + $dest = $ARGV[0]; + $keep_orig = 1; +} else { + $dest = $module . "~"; +} -die "Can't read private key\n" unless (-r $private_key); +die "Can't read private key\n" if (!$signature_file && !-r $private_key); +die "Can't read signature file\n" if ($signature_file && !-r $signature_file); die "Can't read X.509 certificate\n" unless (-r $x509); die "Can't read module\n" unless (-r $module); # -# Read the kernel configuration -# -my %config = ( - CONFIG_MODULE_SIG_SHA512 => 1 - ); - -if (-r ".config") { - open(FD, "<.config") || die ".config"; - while (<FD>) { - if ($_ =~ /^(CONFIG_.*)=[ym]/) { - $config{$1} = 1; - } - } - close(FD); -} - -# # Function to read the contents of a file into a variable. # sub read_file($) @@ -321,73 +315,71 @@ my $id_type = 1; # Identifier type: X.509 # # Digest the data # -my ($dgst, $prologue) = (); -if (exists $config{"CONFIG_MODULE_SIG_SHA1"}) { +my $prologue; +if ($dgst eq "sha1") { $prologue = pack("C*", 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x0E, 0x03, 0x02, 0x1A, 0x05, 0x00, 0x04, 0x14); - $dgst = "-sha1"; $hash = 2; -} elsif (exists $config{"CONFIG_MODULE_SIG_SHA224"}) { +} elsif ($dgst eq "sha224") { $prologue = pack("C*", 0x30, 0x2d, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x04, 0x05, 0x00, 0x04, 0x1C); - $dgst = "-sha224"; $hash = 7; -} elsif (exists $config{"CONFIG_MODULE_SIG_SHA256"}) { +} elsif ($dgst eq "sha256") { $prologue = pack("C*", 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05, 0x00, 0x04, 0x20); - $dgst = "-sha256"; $hash = 4; -} elsif (exists $config{"CONFIG_MODULE_SIG_SHA384"}) { +} elsif ($dgst eq "sha384") { $prologue = pack("C*", 0x30, 0x41, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02, 0x05, 0x00, 0x04, 0x30); - $dgst = "-sha384"; $hash = 5; -} elsif (exists $config{"CONFIG_MODULE_SIG_SHA512"}) { +} elsif ($dgst eq "sha512") { $prologue = pack("C*", 0x30, 0x51, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03, 0x05, 0x00, 0x04, 0x40); - $dgst = "-sha512"; $hash = 6; } else { - die "Can't determine hash algorithm"; + die "Unknown hash algorithm: $dgst\n"; } -# -# Generate the digest and read from openssl's stdout -# -my $digest; -$digest = readpipe("openssl dgst $dgst -binary $module") || die "openssl dgst"; - -# -# Generate the binary signature, which will be just the integer that comprises -# the signature with no metadata attached. -# -my $pid; -$pid = open2(*read_from, *write_to, - "openssl rsautl -sign -inkey $private_key -keyform PEM") || - die "openssl rsautl"; -binmode write_to; -print write_to $prologue . $digest || die "pipe to openssl rsautl"; -close(write_to) || die "pipe to openssl rsautl"; - -binmode read_from; my $signature; -read(read_from, $signature, 4096) || die "pipe from openssl rsautl"; -close(read_from) || die "pipe from openssl rsautl"; +if ($signature_file) { + $signature = read_file($signature_file); +} else { + # + # Generate the digest and read from openssl's stdout + # + my $digest; + $digest = readpipe("openssl dgst -$dgst -binary $module") || die "openssl dgst"; + + # + # Generate the binary signature, which will be just the integer that + # comprises the signature with no metadata attached. + # + my $pid; + $pid = open2(*read_from, *write_to, + "openssl rsautl -sign -inkey $private_key -keyform PEM") || + die "openssl rsautl"; + binmode write_to; + print write_to $prologue . $digest || die "pipe to openssl rsautl"; + close(write_to) || die "pipe to openssl rsautl"; + + binmode read_from; + read(read_from, $signature, 4096) || die "pipe from openssl rsautl"; + close(read_from) || die "pipe from openssl rsautl"; + waitpid($pid, 0) || die; + die "openssl rsautl died: $?" if ($? >> 8); +} $signature = pack("n", length($signature)) . $signature, -waitpid($pid, 0) || die; -die "openssl rsautl died: $?" if ($? >> 8); - # # Build the signed binary # @@ -424,6 +416,6 @@ print FD ; close FD || die $dest; -if ($#ARGV != 3) { +if (!$keep_orig) { rename($dest, $module) || die $module; } diff --git a/scripts/sortextable.h b/scripts/sortextable.h index e4fd45b7e456..f5eb43d42926 100644 --- a/scripts/sortextable.h +++ b/scripts/sortextable.h @@ -182,7 +182,7 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort) _r(&sort_needed_sym->st_value) - _r(&sort_needed_sec->sh_addr); -#if 1 +#if 0 printf("sort done marker at %lx\n", (unsigned long)((char *)sort_done_location - (char *)ehdr)); #endif diff --git a/scripts/tags.sh b/scripts/tags.sh index 08f06c00745e..26a87e68afed 100755 --- a/scripts/tags.sh +++ b/scripts/tags.sh @@ -149,12 +149,17 @@ dogtags() exuberant() { all_target_sources | xargs $1 -a \ - -I __initdata,__exitdata,__acquires,__releases \ - -I __read_mostly,____cacheline_aligned \ + -I __initdata,__exitdata,__initconst,__devinitdata \ + -I __devinitconst,__cpuinitdata,__initdata_memblock \ + -I __refdata,__attribute \ + -I __acquires,__releases,__deprecated \ + -I __read_mostly,__aligned,____cacheline_aligned \ -I ____cacheline_aligned_in_smp \ -I ____cacheline_internodealigned_in_smp \ + -I __used,__packed,__packed2__,__must_check,__must_hold \ -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL \ -I DEFINE_TRACE,EXPORT_TRACEPOINT_SYMBOL,EXPORT_TRACEPOINT_SYMBOL_GPL \ + -I static,const \ --extra=+f --c-kinds=+px \ --regex-asm='/^(ENTRY|_GLOBAL)\(([^)]*)\).*/\2/' \ --regex-c='/^SYSCALL_DEFINE[[:digit:]]?\(([^,)]*).*/sys_\1/' \ @@ -182,8 +187,19 @@ exuberant() --regex-c++='/TESTCLEARFLAG_FALSE\(([^,)]*).*/TestClearPage\1/' \ --regex-c++='/__TESTCLEARFLAG_FALSE\(([^,)]*).*/__TestClearPage\1/' \ --regex-c++='/_PE\(([^,)]*).*/PEVENT_ERRNO__\1/' \ - --regex-c='/PCI_OP_READ\(([a-z]*[a-z]).*[1-4]\)/pci_bus_read_config_\1/' \ - --regex-c='/PCI_OP_WRITE\(([a-z]*[a-z]).*[1-4]\)/pci_bus_write_config_\1/' + --regex-c='/PCI_OP_READ\((\w*).*[1-4]\)/pci_bus_read_config_\1/' \ + --regex-c='/PCI_OP_WRITE\((\w*).*[1-4]\)/pci_bus_write_config_\1/' \ + --regex-c='/DEFINE_(MUTEX|SEMAPHORE|SPINLOCK)\((\w*)/\2/v/' \ + --regex-c='/DEFINE_(RAW_SPINLOCK|RWLOCK|SEQLOCK)\((\w*)/\2/v/' \ + --regex-c='/DECLARE_(RWSEM|COMPLETION)\((\w*)/\2/v/' \ + --regex-c='/DECLARE_BITMAP\((\w*)/\1/v/' \ + --regex-c='/(^|\s)(|L|H)LIST_HEAD\((\w*)/\3/v/' \ + --regex-c='/(^|\s)RADIX_TREE\((\w*)/\2/v/' \ + --regex-c='/DEFINE_PER_CPU\(([^,]*,\s*)(\w*).*\)/\2/v/' \ + --regex-c='/DEFINE_PER_CPU_SHARED_ALIGNED\(([^,]*,\s*)(\w*).*\)/\2/v/' \ + --regex-c='/DECLARE_WAIT_QUEUE_HEAD\((\w*)/\1/v/' \ + --regex-c='/DECLARE_(TASKLET|WORK|DELAYED_WORK)\((\w*)/\2/v/' \ + --regex-c='/DEFINE_PCI_DEVICE_TABLE\((\w*)/\1/v/' all_kconfigs | xargs $1 -a \ --langdef=kconfig --language-force=kconfig \ @@ -201,34 +217,34 @@ exuberant() emacs() { all_target_sources | xargs $1 -a \ - --regex='/^(ENTRY|_GLOBAL)(\([^)]*\)).*/\2/' \ + --regex='/^\(ENTRY\|_GLOBAL\)(\([^)]*\)).*/\2/' \ --regex='/^SYSCALL_DEFINE[0-9]?(\([^,)]*\).*/sys_\1/' \ --regex='/^TRACE_EVENT(\([^,)]*\).*/trace_\1/' \ --regex='/^DEFINE_EVENT([^,)]*, *\([^,)]*\).*/trace_\1/' \ - --regex='/PAGEFLAG\(([^,)]*).*/Page\1/' \ - --regex='/PAGEFLAG\(([^,)]*).*/SetPage\1/' \ - --regex='/PAGEFLAG\(([^,)]*).*/ClearPage\1/' \ - --regex='/TESTSETFLAG\(([^,)]*).*/TestSetPage\1/' \ - --regex='/TESTPAGEFLAG\(([^,)]*).*/Page\1/' \ - --regex='/SETPAGEFLAG\(([^,)]*).*/SetPage\1/' \ - --regex='/__SETPAGEFLAG\(([^,)]*).*/__SetPage\1/' \ - --regex='/TESTCLEARFLAG\(([^,)]*).*/TestClearPage\1/' \ - --regex='/__TESTCLEARFLAG\(([^,)]*).*/TestClearPage\1/' \ - --regex='/CLEARPAGEFLAG\(([^,)]*).*/ClearPage\1/' \ - --regex='/__CLEARPAGEFLAG\(([^,)]*).*/__ClearPage\1/' \ - --regex='/__PAGEFLAG\(([^,)]*).*/__SetPage\1/' \ - --regex='/__PAGEFLAG\(([^,)]*).*/__ClearPage\1/' \ - --regex='/PAGEFLAG_FALSE\(([^,)]*).*/Page\1/' \ - --regex='/TESTSCFLAG\(([^,)]*).*/TestSetPage\1/' \ - --regex='/TESTSCFLAG\(([^,)]*).*/TestClearPage\1/' \ - --regex='/SETPAGEFLAG_NOOP\(([^,)]*).*/SetPage\1/' \ - --regex='/CLEARPAGEFLAG_NOOP\(([^,)]*).*/ClearPage\1/' \ - --regex='/__CLEARPAGEFLAG_NOOP\(([^,)]*).*/__ClearPage\1/' \ - --regex='/TESTCLEARFLAG_FALSE\(([^,)]*).*/TestClearPage\1/' \ - --regex='/__TESTCLEARFLAG_FALSE\(([^,)]*).*/__TestClearPage\1/' \ - --regex='/_PE\(([^,)]*).*/PEVENT_ERRNO__\1/' \ - --regex='/PCI_OP_READ\(([a-z]*[a-z]).*[1-4]\)/pci_bus_read_config_\1/' \ - --regex='/PCI_OP_WRITE\(([a-z]*[a-z]).*[1-4]\)/pci_bus_write_config_\1/' + --regex='/PAGEFLAG(\([^,)]*\).*/Page\1/' \ + --regex='/PAGEFLAG(\([^,)]*\).*/SetPage\1/' \ + --regex='/PAGEFLAG(\([^,)]*\).*/ClearPage\1/' \ + --regex='/TESTSETFLAG(\([^,)]*\).*/TestSetPage\1/' \ + --regex='/TESTPAGEFLAG(\([^,)]*\).*/Page\1/' \ + --regex='/SETPAGEFLAG(\([^,)]*\).*/SetPage\1/' \ + --regex='/__SETPAGEFLAG(\([^,)]*\).*/__SetPage\1/' \ + --regex='/TESTCLEARFLAG(\([^,)]*\).*/TestClearPage\1/' \ + --regex='/__TESTCLEARFLAG(\([^,)]*\).*/TestClearPage\1/' \ + --regex='/CLEARPAGEFLAG(\([^,)]*\).*/ClearPage\1/' \ + --regex='/__CLEARPAGEFLAG(\([^,)]*\).*/__ClearPage\1/' \ + --regex='/__PAGEFLAG(\([^,)]*\).*/__SetPage\1/' \ + --regex='/__PAGEFLAG(\([^,)]*\).*/__ClearPage\1/' \ + --regex='/PAGEFLAG_FALSE(\([^,)]*\).*/Page\1/' \ + --regex='/TESTSCFLAG(\([^,)]*\).*/TestSetPage\1/' \ + --regex='/TESTSCFLAG(\([^,)]*\).*/TestClearPage\1/' \ + --regex='/SETPAGEFLAG_NOOP(\([^,)]*\).*/SetPage\1/' \ + --regex='/CLEARPAGEFLAG_NOOP(\([^,)]*\).*/ClearPage\1/' \ + --regex='/__CLEARPAGEFLAG_NOOP(\([^,)]*\).*/__ClearPage\1/' \ + --regex='/TESTCLEARFLAG_FALSE(\([^,)]*\).*/TestClearPage\1/' \ + --regex='/__TESTCLEARFLAG_FALSE(\([^,)]*\).*/__TestClearPage\1/' \ + --regex='/_PE(\([^,)]*\).*/PEVENT_ERRNO__\1/' \ + --regex='/PCI_OP_READ(\([a-z]*[a-z]\).*[1-4])/pci_bus_read_config_\1/' \ + --regex='/PCI_OP_WRITE(\([a-z]*[a-z]\).*[1-4])/pci_bus_write_config_\1/' all_kconfigs | xargs $1 -a \ --regex='/^[ \t]*\(\(menu\)*config\)[ \t]+\([a-zA-Z0-9_]+\)/\3/' |