lkml.org 
[lkml]   [2010]   [Aug]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject#3 (Re: More modaliases + patchtool)
Rusty Russell пишет:

> Finally, I suggest that your script should only fix files when passed --fix,
> and create a config option to run it (without --fix) under in
> lib/Kconfig.debug.

This is fixed script and patch for lib/Kconfig.debug & Makefile.
I am unsure in patch (mostly Makefile inclusions) - FIXME.
For example, I unsure in "PHONY += check_modaliases" requirement (and sense).

Also may be suggested negative exitcode to strict check. (?)

--
WBR, Dzianis Kahanovich AKA Denis Kaganovich, http://mahatma.bspu.unibel.by/

#!/bin/bash
## (c) Denis Kaganovich
## v5
## grep-pcre required

#BUS="pci"
BUS="\w+"

STR="^(?:static\s+)?(?:const\s+)?struct\s+"

fnd(){
local msg="Fixing:"
$fix || msg="Need to fix:"
grep -Prhl "${STR}${BUS}_device_id\s+" $1 --include="*.c" | while read i ; do
local bus=`grep -Prho "${STR}${BUS}_device_id.*\s+" $i`
bus="${bus#*struct }"
local n="${bus%%[*}"
n="${n%%=*}"
n="${n##*device_id }"
n="${n// }"
bus="${bus%%_device_id*}"
grep -Pq "^module_init\s*\(" $i || continue
grep -q "MODULE_DEVICE_TABLE" $i && continue
local ii="${i#$1}"
ii="${ii#/}"

# case $ii in
# */mdio-gpio.c)
# echo "BROKEN: $bus: $ii"
# continue
# ;;
# esac

bus="${bus%%_*}"
local BU
case "$bus" in
sdio)BU=MMC;;
*)BU="${bus^^}";;
esac
if grep -Prq "^\s*(?:menu)?config\s+$BU(?:\s.*)?$" $1 --include="Kconfig*"; then
echo "$msg $BU: ($n) $ii"
$fix && sed -i -e 's/^\(module_init.*\)$/\n#ifdef CONFIG_'"$BU"'\nMODULE_DEVICE_TABLE('"$bus, $n"');\n#endif\n\n\1/' $i
else
echo "$msg $bus: ($n) $ii"
$fix && sed -i -e 's/^\(module_init.*\)$/\nMODULE_DEVICE_TABLE('"$bus, $n"');\n\n\1/' $i
fi
done
}

p=""
fix=false
while [[ -n "$*" ]]; do
case "$1" in
--fix)fix=true;;
*)p="$p $1";;
esac
shift
done
[[ -z "$p" ]] && echo "$0 [--fix] <path_to_kernel>
(grep+pcre required)" && exit 1

fnd $p
Run "scripts/modulesfix" if CONFIG_CHECK_MODULE_DEVICE_TABLE.

Signed-off-by: Dzianis Kahanovich <mahatma@eu.by>

diff -pruN b/lib/Kconfig.debug c/lib/Kconfig.debug
--- b/lib/Kconfig.debug 2010-08-19 15:20:58.000000000 +0300
+++ c/lib/Kconfig.debug 2010-08-19 17:33:12.594764954 +0300
@@ -1147,6 +1147,13 @@ config ATOMIC64_SELFTEST

If unsure, say N.

+config CHECK_MODULE_DEVICE_TABLE
+ bool "Perform check MODULE_DEVICE_TABLE in modules"
+ help
+ Enable this option to check MODULE_DEVICE_TABLE in modules.
+ Some of new modules sometimes have no MODULE_DEVICE_TABLE declaration
+ and do not export hardware module alias. Say Y to find this modules.
+
source "samples/Kconfig"

source "lib/Kconfig.kgdb"
diff -pruN b/Makefile c/Makefile
--- b/Makefile 2010-08-19 15:20:58.000000000 +0300
+++ c/Makefile 2010-08-19 17:43:05.044764987 +0300
@@ -874,6 +874,13 @@ ifdef CONFIG_KALLSYMS
.tmp_vmlinux1: vmlinux.o
endif

+ifdef CONFIG_CHECK_MODULE_DEVICE_TABLE
+check_modaliases:
+ $(srctree)/scripts/modulesfix $(srctree)
+else
+check_modaliases:
+endif
+
modpost-init := $(filter-out init/built-in.o, $(vmlinux-init))
vmlinux.o: $(modpost-init) $(vmlinux-main) FORCE
$(call if_changed_rule,vmlinux-modpost)
@@ -1034,7 +1041,7 @@ all: modules
# using awk while concatenating to the final file.

PHONY += modules
-modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) modules.builtin
+modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) modules.builtin check_modaliases
$(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order
@$(kecho) ' Building modules, stage 2.';
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
\
 
 \ /
  Last update: 2010-08-19 17:23    [W:0.221 / U:0.212 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site