Release of pcmciautils-010 (2005-09-17)

Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
diff --git a/Makefile b/Makefile
index ea93a75..1dd5a5c 100644
--- a/Makefile
+++ b/Makefile
@@ -29,6 +29,10 @@
 # bus (e.g. on PPC)
 STARTUP = true
 
+# Set this to true if you want to use 'udev' instead of 'hotplug'
+# to invoke the necessary pcmciautils commands.
+UDEV = false
+
 # Set the following to `true' to log the debug
 # and make a unstripped, unoptimized  binary.
 # Leave this set to `false' for production use.
@@ -40,7 +44,7 @@
 CBDUMP =			cbdump
 CISDUMP =			dump_cis
 
-VERSION =	009
+VERSION =	010
 #INSTALL_DIR =	/usr/local/sbin
 RELEASE_NAME =	pcmciautils-$(VERSION)
 
@@ -63,6 +67,9 @@
 # place to put our hotplug scripts nodes
 hotplugdir =	${prefix}/etc/hotplug
 
+# place to put our udev rules to
+udevrulesdir = ${prefix}/etc/udev/rules.d
+
 # place where PCMICIA config is put to
 pcmciaconfdir =	${prefix}${etcdir}/pcmcia
 
@@ -107,7 +114,7 @@
 WARNINGS += $(call cc-supports,-Wdeclaration-after-statement)
 WARNINGS += -Wshadow
 
-CFLAGS := -pipe -DVERSION=\"$(VERSION)\"
+CFLAGS := -pipe -DPCMCIAUTILS_VERSION=\"$(VERSION)\"
 YFLAGS := -d
 
 HEADERS = \
@@ -153,15 +160,28 @@
 	STRIPCMD = $(STRIP) -s --remove-section=.note --remove-section=.comment
 endif
 
+# HOTPLUG or UDEV?
+ifeq ($(strip $(UDEV)),false)
+	INSTALL_TARGETS = install-hotplug
+	UNINSTALL_TARGETS = uninstall-hotplug
+else
+	INSTALL_TARGETS = install-udev
+	UNINSTALL_TARGETS = uninstall-udev
+endif
+
 # if STARTUP is disabled, we can skip a few things
 ifeq ($(strip $(STARTUP)),false)
+	UDEV_RULES = udev/60-pcmcia.rules.static
 	PCMCIA_SOCKET_STARTUP_BUILD =
-	INSTALL_TARGETS = 
-	UNINSTALL_TARGETS =
 else
+	UDEV_RULES = udev/60-pcmcia.rules
 	PCMCIA_SOCKET_STARTUP_BUILD = $(PCMCIA_SOCKET_STARTUP)
-	INSTALL_TARGETS = install-config install-socket-hotplug install-socket-tools
-	UNINSTALL_TARGETS = uninstall-socket-hotplug uninstall-socket-tools
+	INSTALL_TARGETS += install-config install-socket-tools
+	UNINSTALL_TARGETS += uninstall-socket-tools
+	ifeq ($(strip $(UDEV)),false)
+		INSTALL_TARGETS += install-socket-hotplug
+		UNINSTALL_TARGETS += uninstall-socket-hotplug
+	endif
 endif
 
 
@@ -250,7 +270,12 @@
 uninstall-config:
 #	- rm -f $(pcmciaconfdir)/config.opts
 
+install-udev:
+	$(INSTALL_DATA) -D $(UDEV_RULES) $(DESTDIR)$(udevrulesdir)/60-pcmcia.rules
+	
+uninstall-udev:
+	- rm -f $(udevrulesdir)/60-pcmcia.rules
 
-install: install-tools install-hotplug $(INSTALL_TARGETS)
+install: install-tools $(INSTALL_TARGETS)
 
-uninstall: uninstall-tools uninstall-hotplug $(UNINSTALL_TARGETS)
+uninstall: uninstall-tools $(UNINSTALL_TARGETS)
diff --git a/hotplug/pcmcia.agent b/hotplug/pcmcia.agent
index e071e92..8f89925 100755
--- a/hotplug/pcmcia.agent
+++ b/hotplug/pcmcia.agent
@@ -28,10 +28,8 @@
 		CISFILE=$(pcmcia-check-broken-cis $SOCKET_NO)
 		debug_mesg $CISFILE;
 		if [ ! -z $CISFILE ]; then
-			if [ -f /etc/pcmcia/cis/$CISFILE ]; then
-				cat /etc/pcmcia/cis/$CISFILE > /sys/class/pcmcia_socket/pcmcia_socket$(SOCKET_NO)/cis
-			elif [ -f /lib/firmware/cis/$CISFILE ]; then
-				cat /lib/firmware/cis/$CISFILE > /sys/class/pcmcia_socket/pcmcia_socket$(SOCKET_NO)/cis
+			if [ -f /lib/firmware/$CISFILE ]; then
+				cat /lib/firmware/$CISFILE > $SYSFS/class/pcmcia_socket/pcmcia_socket$(SOCKET_NO)/cis
 			fi;
 		fi;
 	fi;
diff --git a/src/lex_config.l b/src/lex_config.l
index 2d99966..746edc1 100644
--- a/src/lex_config.l
+++ b/src/lex_config.l
@@ -15,7 +15,6 @@
  */
 
 #undef src
-#undef VERSION
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/src/pccardctl.c b/src/pccardctl.c
index 02ad3ee..5bef5d2 100644
--- a/src/pccardctl.c
+++ b/src/pccardctl.c
@@ -218,7 +218,7 @@
 }
 
 static void print_header(void) {
-	printf("pcmciautils %s\n", VERSION);
+	printf("pcmciautils %s\n", PCMCIAUTILS_VERSION);
 	printf("Copyright (C) 2004-2005 Dominik Brodowski, (C) 1999 David A. Hinds\n");
 	printf("Report errors and bugs to <linux-pcmcia@lists.infradead.org>, please.\n");
 }
diff --git a/src/yacc_config.y b/src/yacc_config.y
index 23fc054..f6df721 100644
--- a/src/yacc_config.y
+++ b/src/yacc_config.y
@@ -19,7 +19,6 @@
 #include <sys/types.h>
 
 #include "startup.h"
-#undef VERSION
 
 /* If bison: generate nicer error messages */ 
 #define YYERROR_VERBOSE 1
diff --git a/udev/60-pcmcia.rules b/udev/60-pcmcia.rules
new file mode 100644
index 0000000..79909ed
--- /dev/null
+++ b/udev/60-pcmcia.rules
@@ -0,0 +1,27 @@
+# PCMCIA devices:
+#
+# modprobe $modalias loads all possibly appropriate modules
+ACTION=="add", SUBSYSTEM=="pcmcia", MODALIAS=="*", \
+		RUN+="/sbin/modprobe $modalias"
+
+# Very few CIS firmware entries (which we use for matching)
+# 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", MODALIAS=="*", \
+		RUN+="/sbin/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", MODALIAS=="*", \
+		RUN+="/bin/sh -c 'echo 1 > /sys/$DEVPATH/allow_func_id_match'"
+
+
+# PCMCIA sockets:
+#
+# modprobe the pcmcia bus module so that 16-bit PCMCIA devices work
+SUBSYSTEM="pcmcia_socket"       RUN+="/sbin/modprobe pcmcia"
+
+# if this is a PCMCIA socket which needs a resource database,
+# pcmcia-socket-startup sets it up
+SUBSYSTEM="pcmcia_socket"       RUN+="/sbin/pcmcia-socket-startup"
diff --git a/udev/60-pcmcia.rules.static b/udev/60-pcmcia.rules.static
new file mode 100644
index 0000000..23ef3e3
--- /dev/null
+++ b/udev/60-pcmcia.rules.static
@@ -0,0 +1,27 @@
+# PCMCIA devices:
+#
+# modprobe $modalias loads all possibly appropriate modules
+ACTION=="add", SUBSYSTEM=="pcmcia", MODALIAS=="*", \
+		RUN+="/sbin/modprobe $modalias"
+
+# Very few CIS firmware entries (which we use for matching)
+# 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", MODALIAS=="*", \
+		RUN+="/sbin/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", MODALIAS=="*", \
+		RUN+="/bin/sh -c 'echo 1 > /sys/$DEVPATH/allow_func_id_match'"
+
+
+# PCMCIA sockets:
+#
+# modprobe the pcmcia bus module so that 16-bit PCMCIA devices work
+SUBSYSTEM="pcmcia_socket"       RUN+="/sbin/modprobe pcmcia"
+
+# if this is a PCMCIA socket which needs a resource database,
+# pcmcia-socket-startup sets it up
+#SUBSYSTEM="pcmcia_socket"       RUN+="/sbin/pcmcia-socket-startup"