mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dzianis Kahanovich <mahatma@bspu.unibel.by>
To: Rusty Russell <rusty@rustcorp.com.au>
Cc: linux-kernel@vger.kernel.org
Subject: #3 (Re: More modaliases + patchtool)
Date: Thu, 19 Aug 2010 17:58:39 +0300	[thread overview]
Message-ID: <4C6D469F.2080900@bspu.unibel.by> (raw)
In-Reply-To: <201008191020.52861.rusty@rustcorp.com.au>

[-- Attachment #1: Type: text/plain, Size: 539 bytes --]

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/


[-- Attachment #2: modulesfix --]
[-- Type: text/plain, Size: 1302 bytes --]

#!/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

[-- Attachment #3: modulesfix_config.patch --]
[-- Type: text/plain, Size: 1693 bytes --]

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

  reply	other threads:[~2010-08-19 15:19 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <4C6BE292.3060307@bspu.unibel.by>
2010-08-19  0:50 ` More modaliases + patchtool Rusty Russell
2010-08-19 14:58   ` Dzianis Kahanovich [this message]
     [not found]   ` <4C6D26BC.9040805@bspu.unibel.by>
2010-09-11  2:14     ` #2 (Re: More modaliases + patchtool) Rusty Russell
2010-09-11  3:36       ` Jeremy Fitzhardinge
2010-09-13  3:03         ` Rusty Russell
2010-09-11 17:51       ` Dmitry Torokhov
2010-09-13  3:24         ` Rusty Russell
2010-09-17 10:55       ` pci: Re: #2 (Re: More modaliases + patchtool)) Dzianis Kahanovich
2010-09-17 13:11       ` Dzianis Kahanovich
2010-09-17 13:26       ` xenbus: " Dzianis Kahanovich
2010-09-17 18:09         ` Jeremy Fitzhardinge
2010-09-17 13:27       ` usb: " Dzianis Kahanovich
2010-09-17 13:29       ` serio: " Dzianis Kahanovich
2010-09-17 13:29       ` pnp: " Dzianis Kahanovich
2010-09-17 13:32       ` of: " Dzianis Kahanovich
2010-09-17 13:35       ` i2c: " Dzianis Kahanovich
2010-09-17 14:06         ` Mark Brown
2010-09-17 15:47           ` Dzianis Kahanovich
2010-09-17 15:54             ` Mark Brown
2010-09-17 13:36       ` hid: " Dzianis Kahanovich
2010-09-17 13:36       ` dio: " Dzianis Kahanovich
2010-09-17 13:37       ` ccw: " Dzianis Kahanovich
2010-09-17 13:38       ` acpi: " Dzianis Kahanovich
2010-09-17 13:38       ` spi " Dzianis Kahanovich
2010-09-17 13:39       ` RapidIO: " Dzianis Kahanovich
2010-09-17 13:42       ` platform: " Dzianis Kahanovich
2010-09-17 13:54         ` Mark Brown
2010-09-17 15:55       ` acpi (signed): " Dzianis Kahanovich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4C6D469F.2080900@bspu.unibel.by \
    --to=mahatma@bspu.unibel.by \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mahatma@eu.by \
    --cc=rusty@rustcorp.com.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®