[PATCH] use label to make udev rules more concise

Colin Watson cjwatson at debian.org
Fri Jul 11 11:19:06 EDT 2008


Rather than checking ACTION=="add" over and over again in the udev
rules, it would be simpler and more efficient to check once at the top
and jump past the add-only rules if ACTION!="add".

Signed-off-by: Colin Watson <cjwatson at debian.org>

diff --git a/Makefile b/Makefile
index c46d339..d275af0 100644
--- a/Makefile
+++ b/Makefile
@@ -203,6 +203,7 @@ UDEV_RULES = udev/rules-start udev/rules-modprobe udev/rules-base
 ifneq ($(strip $(STARTUP)),false)
 	UDEV_RULES += udev/rules-nonstaticsocket
 endif
+UDEV_RULES += udev/rules-end
 
 
 all: ccdv $(PCCARDCTL) $(PCMCIA_CHECK_BROKEN_CIS) $(PCMCIA_SOCKET_STARTUP_BUILD) udevrules
diff --git a/udev/rules-base b/udev/rules-base
index 9bad261..0227cef 100644
--- a/udev/rules-base
+++ b/udev/rules-base
@@ -3,15 +3,15 @@
 # are so broken that we need to read out random bytes of it
 # instead of the manufactor, card or product ID. Then the
 # matching is done in userspace.
-ACTION=="add", SUBSYSTEM=="pcmcia", ENV{MODALIAS}=="?*", \
-		RUN+="/sbin/pcmcia-check-broken-cis"
+SUBSYSTEM=="pcmcia", ENV{MODALIAS}=="?*", \
+		RUN+="/lib/udev/pcmcia-check-broken-cis"
 
 # However, the "weak" matching by func_id is only allowed _after_ modprobe
 # returns, so that "strong" matches have a higher priority.
-ACTION=="add", SUBSYSTEM=="pcmcia", ENV{MODALIAS}=="?*", ATTR{allow_func_id_match}="1"
+SUBSYSTEM=="pcmcia", ENV{MODALIAS}=="?*", ATTR{allow_func_id_match}="1"
 
 # PCMCIA sockets:
 #
 # modprobe the pcmcia bus module so that 16-bit PCMCIA devices work
-ACTION=="add", SUBSYSTEM=="pcmcia_socket", \
-		RUN+="/sbin/modprobe pcmcia"
+SUBSYSTEM=="pcmcia_socket", \
+		RUN+="/sbin/modprobe -b pcmcia"
diff --git a/udev/rules-end b/udev/rules-end
new file mode 100644
index 0000000..2b5ae20
--- /dev/null
+++ b/udev/rules-end
@@ -0,0 +1,2 @@
+
+LABEL="pcmciautils_end"
diff --git a/udev/rules-modprobe b/udev/rules-modprobe
index a13b2ad..7fb03f4 100644
--- a/udev/rules-modprobe
+++ b/udev/rules-modprobe
@@ -1,3 +1,3 @@
 # modprobe $env{MODALIAS} loads all possibly appropriate modules
-ACTION=="add", SUBSYSTEM=="pcmcia", ENV{MODALIAS}=="?*", \
+SUBSYSTEM=="pcmcia", ENV{MODALIAS}=="?*", \
 		RUN+="/sbin/modprobe $env{MODALIAS}"
diff --git a/udev/rules-nonstaticsocket b/udev/rules-nonstaticsocket
index 23b599e..8b8e1c2 100644
--- a/udev/rules-nonstaticsocket
+++ b/udev/rules-nonstaticsocket
@@ -1,5 +1,5 @@
 
 # if this is a PCMCIA socket which needs a resource database,
 # pcmcia-socket-startup sets it up
-ACTION=="add", SUBSYSTEM=="pcmcia_socket", \
-		RUN+="/sbin/pcmcia-socket-startup"
+SUBSYSTEM=="pcmcia_socket", \
+		RUN+="/lib/udev/pcmcia-socket-startup"
diff --git a/udev/rules-start b/udev/rules-start
index 790902b..b67d35d 100644
--- a/udev/rules-start
+++ b/udev/rules-start
@@ -1,2 +1,3 @@
 # PCMCIA devices:
 #
+ACTION!="add", GOTO="pcmciautils_end"

-- 
Colin Watson                                       [cjwatson at debian.org]



More information about the linux-pcmcia mailing list