Re: #2 (Re: More modaliases + patchtool)

From: Denis Kaganovich
Date: Thu Sep 16 2010 - 16:23:38 EST


--- rusty@xxxxxxxxxxxxxxx wrote:

This one, too, seems to make sense.

[ Remaining 2/3 of patch cut here ].

I think the best way to split this patch is by bus type. Drop the
#ifdef's
if you think it's a good idea, do some compile testing, then forward to
the
specific maintainers for each type. I'm happy to do that for you if you
want (though these kind of patches are Morton-worthy IMHO).

Cheers,
Rusty.
===

I just seen your messages, sorry, may be not forwarded to work...
OK, I will make hand-checks and splitting, etc. About "#ifdef" ;) I add
it only after one (NOW not remember) driver from OF bus and think that
for AUTO-mode good to be always "#ifdef". I will remove ifdef's for
drivers, hardly related from its buses (this is dummy for scripting, but
easy for human).

PS Preview (or solution?), sorry attachment disabled here - this version of script with "--diff" flag will generate (in current dir) patches for BUS.patch (upcase - ifdef) and bus.patch (lowcase - no ifdef). On first look (just compile test) only OF need ifdef. Say me if there are solution, else I will post hand-verifyed results a bit later.

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

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

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

_sed(){
local n="$1"
shift
$diff && sed "${@}" <$i |diff -pruN $i - >>$n.patch
$fix && $first && {
first=false
sed -i "${@}" $i
}
}

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
local first=true
if grep -Prq "^\s*(?:menu)?config\s+$BU(?:\s.*)?$" $1 --include="Kconfig*"; then
echo "$msg $BU: ($n) $ii"
_sed $BU -e 's/^\(module_init.*\)$/\n#ifdef CONFIG_'"$BU"'\nMODULE_DEVICE_TABLE('"$bus, $n"');\n#endif\n\n\1/'
$diff || continue
fi
echo "$msg $bus: ($n) $ii"
_sed $bus -e 's/^\(module_init.*\)$/\nMODULE_DEVICE_TABLE('"$bus, $n"');\n\n\1/'
done
}

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

fnd $p

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/