Release of pcmciautils-011 (2005-12-06)

Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
diff --git a/Makefile b/Makefile
index 1dd5a5c..705ada7 100644
--- a/Makefile
+++ b/Makefile
@@ -31,7 +31,7 @@
 
 # Set this to true if you want to use 'udev' instead of 'hotplug'
 # to invoke the necessary pcmciautils commands.
-UDEV = false
+UDEV = true
 
 # Set the following to `true' to log the debug
 # and make a unstripped, unoptimized  binary.
@@ -44,7 +44,7 @@
 CBDUMP =			cbdump
 CISDUMP =			dump_cis
 
-VERSION =	010
+VERSION =	011
 #INSTALL_DIR =	/usr/local/sbin
 RELEASE_NAME =	pcmciautils-$(VERSION)
 
@@ -57,6 +57,7 @@
 exec_prefix =	${prefix}
 etcdir =	${prefix}/etc
 sbindir =	${exec_prefix}/sbin
+mandir =	${prefix}/usr/share/man
 srcdir = .
 
 INSTALL = /usr/bin/install -c
@@ -169,12 +170,12 @@
 	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 =
 else
-	UDEV_RULES = udev/60-pcmcia.rules
 	PCMCIA_SOCKET_STARTUP_BUILD = $(PCMCIA_SOCKET_STARTUP)
 	INSTALL_TARGETS += install-config install-socket-tools
 	UNINSTALL_TARGETS += uninstall-socket-tools
@@ -184,8 +185,15 @@
 	endif
 endif
 
+#udev rules collection
+UDEV_RULES_FILE = udev/60-pcmcia.rules
+UDEV_RULES = udev/rules-start udev/rules-modprobe udev/rules-base
+ifneq ($(strip $(STARTUP)),false)
+	UDEV_RULES += udev/rules-nonstaticsocket
+endif
 
-all: ccdv $(PCCARDCTL) $(PCMCIA_CHECK_BROKEN_CIS) $(PCMCIA_SOCKET_STARTUP_BUILD)
+
+all: ccdv $(PCCARDCTL) $(PCMCIA_CHECK_BROKEN_CIS) $(PCMCIA_SOCKET_STARTUP_BUILD) udevrules
 
 ccdv:
 	@echo "Building ccdv"
@@ -199,7 +207,6 @@
 	mv y.tab.c $*.c
 	mv y.tab.h $*.h
 
-	
 $(PCCARDCTL): $(LIBC) src/$(PCCARDCTL).o $(OBJS) $(HEADERS)
 	$(QUIET) $(LD) $(LDFLAGS) -o $@ $(CRT0) src/$(PCCARDCTL).o $(LIB_OBJS) $(ARCH_LIB_OBJS)
 	$(QUIET) $(STRIPCMD) $@
@@ -214,7 +221,7 @@
 
 yacc_config.o lex_config.o: %.o: %.c
 	$(CC) -c -MD -O -pipe $(CPPFLAGS) $<
-	
+
 debugtools: ccdv $(CBDUMP) $(CISDUMP)
 
 $(CBDUMP): $(LIBC) debug/cbdump.o
@@ -225,12 +232,16 @@
 	$(QUIET) $(LD) $(LDFLAGS) -o $@ $(CRT0) debug/$(CISDUMP).o src/read-cis.o debug/parse_cis.o $(LIB_OBJS) $(ARCH_LIB_OBJS)
 	$(QUIET) $(STRIPCMD) $@
 
+udevrules:
+	cat $(UDEV_RULES) > $(UDEV_RULES_FILE)
+
 clean:
 	-find . \( -not -type d \) -and \( -name '*~' -o -name '*.[oas]' \) -type f -print \
 	 | xargs rm -f 
 	-rm -f $(PCCARDCTL) $(PCMCIA_CHECK_BROKEN_CIS) $(PCMCIA_SOCKET_STARTUP)
 	-rm -f $(CBDUMP) $(CISDUMP)
 	-rm -f src/yacc_config.c src/yacc_config.d src/lex_config.c src/lex_config.d src/yacc_config.h
+	-rm -f udev/60-pcmcia.rules
 	-rm -f build/ccdv
 
 install-hotplug:
@@ -239,19 +250,19 @@
 	$(INSTALL_PROGRAM) -D hotplug/pcmcia.rc $(DESTDIR)$(hotplugdir)/pcmcia.rc
 
 uninstall-hotplug:
-	- rm -f $(hotplugdir)/pcmcia.agent $(hotplugdir)/pcmcia.rc
+	- rm -f $(DESTDIR)$(hotplugdir)/pcmcia.agent $(DESTDIR)$(hotplugdir)/pcmcia.rc
 
 install-socket-hotplug:
 	$(INSTALL_PROGRAM) -D hotplug/pcmcia_socket.agent $(DESTDIR)$(hotplugdir)/pcmcia_socket.agent
 	$(INSTALL_PROGRAM) -D hotplug/pcmcia_socket.rc $(DESTDIR)$(hotplugdir)/pcmcia_socket.rc
 
 uninstall-socket-hotplug:
-	- rm -f $(hotplugdir)/pcmcia_socket.agent $(hotplugdir)/pcmcia_socket.rc
+	- rm -f $(DESTDIR)$(hotplugdir)/pcmcia_socket.agent $(DESTDIR)$(hotplugdir)/pcmcia_socket.rc
 install-socket-tools:
 	$(INSTALL_PROGRAM) -D $(PCMCIA_SOCKET_STARTUP) $(DESTDIR)$(sbindir)/$(PCMCIA_SOCKET_STARTUP)
 
 uninstall-socket-tools:
-	- rm -f $(sbindir)/$(PCMCIA_SOCKET_STARTUP)
+	- rm -f $(DESTDIR)$(sbindir)/$(PCMCIA_SOCKET_STARTUP)
 
 install-tools:
 	$(INSTALL) -d $(DESTDIR)$(sbindir)
@@ -260,22 +271,29 @@
 
 
 uninstall-tools:
-	- rm -f $(sbindir)/$(PCCARDCTL)
-	- rm -f $(sbindir)/$(PCMCIA_CHECK_BROKEN_CIS)
+	- rm -f $(DESTDIR)$(sbindir)/$(PCCARDCTL)
+	- rm -f $(DESTDIR)$(sbindir)/$(PCMCIA_CHECK_BROKEN_CIS)
 
 install-config:
 	$(INSTALL) -d $(DESTDIR)$(pcmciaconfdir)
 	$(INSTALL_DATA)  -D config/config.opts $(DESTDIR)$(pcmciaconfdir)/config.opts
 
 uninstall-config:
-#	- rm -f $(pcmciaconfdir)/config.opts
+#	- rm -f $(DESTDIR)$(pcmciaconfdir)/config.opts
 
 install-udev:
-	$(INSTALL_DATA) -D $(UDEV_RULES) $(DESTDIR)$(udevrulesdir)/60-pcmcia.rules
-	
+	$(INSTALL_DATA) -D $(UDEV_RULES_FILE) $(DESTDIR)$(udevrulesdir)/60-pcmcia.rules
+
 uninstall-udev:
-	- rm -f $(udevrulesdir)/60-pcmcia.rules
+	- rm -f $(DESTDIR)$(udevrulesdir)/60-pcmcia.rules
 
-install: install-tools $(INSTALL_TARGETS)
+install-man:
+	$(INSTALL_DATA) -D man/man8/pccardctl.8 $(DESTDIR)$(mandir)/man8/pccardctl.8
 
-uninstall: uninstall-tools $(UNINSTALL_TARGETS)
+uninstall-man:
+	- rm $(DESTDIR)$(mandir)/man8/pccardctl.8
+
+
+install: install-tools install-man $(INSTALL_TARGETS)
+
+uninstall: uninstall-tools uninstall-man $(UNINSTALL_TARGETS)
diff --git a/debug/dump_cis.c b/debug/dump_cis.c
index c5cdc51..05ad314 100644
--- a/debug/dump_cis.c
+++ b/debug/dump_cis.c
@@ -942,15 +942,13 @@
 			print_tuple(&tuple);
 
 		ret = pccard_parse_tuple(&tuple, &parse);
-		if (ret) {
+		if (ret)
 			printf("invalid tuple\n");
-			continue;
+		else {
+			print_parse(&tuple, &parse);
+			printf("\n");
 		}
 
-		print_parse(&tuple, &parse);
-
-		printf("\n");
-
 		ret = pcmcia_get_next_tuple(BIND_FN_ALL, &tuple);
 		if (ret)
 			break;
diff --git a/doc/cardmgr-to-pcmciautils.txt b/doc/cardmgr-to-pcmciautils.txt
new file mode 100644
index 0000000..8ff970a
--- /dev/null
+++ b/doc/cardmgr-to-pcmciautils.txt
@@ -0,0 +1,158 @@
+PCMCIA: cardmgr to pcmciautils HowTo
+====================================
+
+written by Daniel Ritz <daniel.ritz@gmx.ch>
+
+This howto describes in short how to change your system to work with the new
+pcmciautils instead of the old cardmgr.
+
+Prerequisites
+-------------
+
+- kernel 2.6.13-rc1 and newer
+- pcmciautils, preferably 010 or newer
+- you read the mini-howto.txt
+
+
+Introduction
+------------
+
+Kernels since 2.6.13-rc1 do not require the cardmgr daemon anymore. In those
+newer kernel the pcmcia bus acts almost as any other bus with full /sbin/hotplug
+support. Old style cardmgr setups should still work if the kernel is configured
+correctly. But be aware that the ioctl for PCMCIA will be removed in the near
+future.
+
+The change to be /sbin/hotplug capable means that the normal /etc/init.d/pcmcia
+script is not required any more and in fact only hurts as it starts cardmgr. To
+use the new pcmciautils it is a requirement that cardmgr is not started.
+
+
+The STARTUP option
+------------------
+
+When reading the pcmciautils howto you see that STARTUP option mentioned. What
+does it do again? It controls the setup of a dynamic resource database needed
+for some sockets. The resource database tells the PCMCIA layer what IO port and
+what IO memory are usable for PCMCIA cards. In case the database is dynamic, it
+needs to be setup before any cards can be used. The /etc/pcmcia/config.opts
+file contains the neccessary configuration.
+In old setups it is cardmgr that parses that file and tells the kernel what
+resources to use. In case of pcmciautils it's the pcmcia-socket-startup tool
+which is built and installed when the STARTUP option is set. The tool itself
+is run from the hotplug script pcmcia_socket.agent whenever a new socket is
+registered with the pcmcia module. This means that pcmcia-socket-startup does
+not need to be run manually.
+
+
+Compiling and installing pcmciautils
+------------------------------------
+
+You should have read the pcmciautils howto already. Again in short:
+- make a backup copy of your /etc/pcmcia/config.opts
+- determine whether you need UDEV set or not. if unsure: don't set it
+- determine whether you need STARTUP set or not
+- make
+- make install (as root)
+- put your original /etc/pcmcia/config.opts back to where it was
+
+
+Stop cardmgr from starting
+--------------------------
+
+We don't want cardmgr. For setups with a PCI PCMCIA/Cardbus controller the
+easiest thing to do is to make sure /etc/init.d/pcmcia does nothing.
+Either make sure it does not start up, or (if you want to use older kernels
+as well) add the following snippet to the beginning of /etc/init.d/pcmcia
+(after the #!/bin/sh line of course):
+
+
+	KVERREL=`uname -r`
+	KVER=${KVERREL%-*}
+	KVER_MAJOR=${KVER%.*}
+	KVER_MINOR=${KVER##*.}
+
+	if [ "$KVER_MAJOR" == "2.6" ]; then
+		# kernel 2.6.13-rc1 and higher have pcmcia via /sbin/hotplug
+		if [ $KVER_MINOR -ge 13 ]; then
+			# uncomment the following line if the driver for your
+			# controller is not auto-loaded. or if you want to be
+			# able to say /etc/init.d/pcmcia stop
+			#/etc/init.d/pcmcia-new $1
+			exit 0
+		fi
+	fi
+
+this will make sure the init script does nothing for newer kernel and works
+normally on older kernels.
+
+if you have a socket controller where the module cannot be loaded automatically
+by hotplug, uncomment the line in the above code snipped and make sure you have
+the /etc/init.d/pcmcia-new script around which should look like this:
+
+	#!/bin/sh
+
+	# set this to the driver to use, one of:
+	# yenta_socket, i82365, i82092, pd6792, tcic, etc.
+	DRIVER=yenta_socket
+	DRIVER_OPTS=
+
+	case "$1" in
+		start)
+			modprobe $DRIVER $DRIVER_OPTS > /dev/null 2>&1
+			modprobe pcmcia > /dev/null 2>&1 # just in case it's not auto-loaded
+			;;
+
+		stop)
+			pccardctl eject
+			MODULES=`lsmod | grep "pcmcia " | awk '{print $4}' | tr , ' '`
+			for i in $MODULES ; do
+				rmmod $i > /dev/null 2>&1
+			done
+			rmmod pcmcia > /dev/null 2>&1
+			rmmod $DRIVER > /dev/null 2>&1
+			rmmod rsrc_nonstatic > /dev/null 2>&1
+			rmmod pcmcia_core > /dev/null 2>&1
+			;;
+	esac
+
+( you can find this script in doc/pcmcia-new.sh )
+
+make sure you set the DRIVER (and maybe DRIVER_OPTS) variable to the right
+socket driver. If yenta_socket doesn't work look up the config file from your
+distro. look at the PCIC variable and PCIC_OPTS.
+	- Red Hat (and Conectiva, Mandriva, etc.) have it in /etc/sysconfig/pcmcia
+	- Debian (and probably Ubuntu) has it in /etc/pcmcia.conf
+	- Others: sorry, don't know
+If you don't know where to find it, you should look at the init script. Maybe it's
+even in there directly.
+
+The file system right for the script should be right as well:
+	chmod 755 /etc/init.d/pcmcia-new
+
+
+Auto-load pcmcia module
+-----------------------
+
+To have support for 16-bit cards you need the pcmcia module loaded. Since the
+other modules do not depend on this one it is not loaded automatically. To
+make sure the pcmcia module is loaded right after pcmcia_core, add the following
+line to /etc/modprobe.conf
+	install pcmcia_core /sbin/modprobe --ignore-install pcmcia_core; /sbin/modprobe pcmcia
+
+
+Hotplug
+-------
+
+Make sure hotplug works correctly. Most distros have a /etc/init.d/hotplug script
+which should be loaded at boot time. For most laptops the the socket driver is
+yenta_socket. If it is not loaded after boot it means that hotplug is not working
+correctly. Reasons for the driver not loaded include the /etc/hotplub/blacklist
+file or some other list that prevents the driver being loaded.
+eg. Conectiva Linux 10 does not load PCI modules per default, but only modules
+that are listed in /etc/hotplug/pci.whitelist.
+
+If your socket driver can be loaded via hotplug (PCI socket or detected by PnP or
+whatever) and everything is ok, yenta_socket (or another socket driver), pcmcia,
+pcmcia_core and rsrc_nonstatic (not for all socket drivers)  should be loaded after
+booting. Modules for inserted pcmcia cards should be loaded as well.
diff --git a/doc/mini-howto.txt b/doc/mini-howto.txt
new file mode 100644
index 0000000..78d8d2b
--- /dev/null
+++ b/doc/mini-howto.txt
@@ -0,0 +1,205 @@
+Linux Kernel 2.6 PCMCIA - mini-HOWTO
+====================================
+
+   Last update: 08 November 2005.
+
+Table of contents:
+
+     * [1]Introduction
+     * [2]Setup
+          + [3]Determine the socket driver to use
+          + [4]Resource database
+          + [5]Dependencies
+          + [6]Install pcmciautils
+          + [7]The difficult cases: CIS overrides
+     * [8]Usage
+
+
+1. Introduction
+---------------
+
+   So, you'd like to get PCMCIA working on Linux kernel 2.6.13-rc1 or
+   later? This short document intends to help you doing so; for
+   additional questions please search the web, especially the help forums
+   of your distribution, or ask on the [9]Linux-PCMCIA mailinglist. Also,
+   the help texts in the Linux kernel configuration for the PCMCIA
+   subsystem might point you into the correct direction -- so please read
+   them.
+
+
+2. Setup
+--------
+
+   Fortunately, several distributions have already included up-to-date
+   pcmciautils and PCMCIA support into their products. Therefore, you may
+   be able to rely on your distribution to set up the system correctly.
+
+  2.1. Determine the socket driver to use
+  ---------------------------------------
+
+   At first, you need to determine which PCMCIA socket driver you need to
+   use. On most modern notebooks, this is yenta-socket. Else, check the
+   kernel configuration menu for the appropriate driver.
+
+   Then, make sure it is either built into the kernel, or it is loaded
+   during bootup. Previously, this was oftern handled by the pcmcia-cs
+   startup script. As you won't use this package any longer, you can't
+   rely on it any more to load the socket driver!
+
+  2.2. Resource database?
+  -----------------------
+
+   Then, you need to find out whether you need a resource database. This
+   contains the ioport and iomem region which PCMCIA cards may use.
+   Fortunately, less and less systems require setting such a database up.
+
+   2.2.1. The lucky ones
+   ---------------------
+
+     Sockets which are governed by these drivers do not need a resource
+     database:
+       * hd64465
+       * Au1x00
+       * SA1100
+       * SA1111
+       * PXA2xx
+       * M32R_PCC
+       * M32R_CFC
+       * VRC4171
+       * VRC4173
+
+   2.2.2. The unlucky ones
+   -----------------------
+
+     These sockets always need a resource database:
+       * i82365
+       * tcic
+
+   2.2.3. The complicated ones
+   ---------------------------
+
+     For the remaining socket drivers,
+       * yenta-socket
+       * pd6729
+       * i82092
+
+     you need to investigate a bit further. However, if you think that this
+     is too complicated for you, just try it out without a resource
+     database. If it doesn't work, you can still add the resource database
+     later on.
+
+     First you need to know if the system is of the x86 or x86_64
+     architecture. If you don't know what this means, check wheter you have
+     an apple printed on the backside of your notebook -- then the answer
+     is no, else it is most probably yes.
+
+
+     2.2.3.1. x86 and x86_64 architectures
+     -------------------------------------
+
+       Now you need to determine the PCI bus the device is on: search for the
+       device using the lspci command. Then you'll see a number like
+       0000:02:03.0 in front of the device. If the second "block" (which is
+       02 in this example), is zero, you need a resource database, if it is
+       not zero, you do not need it.
+
+     2.2.3.2. other architectures
+     ----------------------------
+
+       On other architectures (including ppc and ppc64) you do not need a
+       resource database for such sockets.
+
+  2.3. Dependencies
+  -----------------
+
+   To use any of the PCMCIAutils tools, you need sysfsutils 1.3.0 or
+   newer. However, if you do not need a resource database, you do not run
+   a modular kernel and you are lucky, you might not need any userspace
+   tools at all.
+
+   If you use a modular kernel, you also need module-init-tools 3.2-pre4
+   or later.
+
+   In addition, you either need the basic hotplug scripts installed, or a
+   working udev environment.
+
+
+  2.4. Installing pcmciautils
+  ---------------------------
+
+   Get the latest revision of pcmciautils. Then, you need to configure
+   it. Therefore, open the file "Makefile" with an editor of your choice,
+   and modify it accordingly:
+
+   If you do not need a resource database, modify the line which starts
+   with STARTUP to read
+
+	STARTUP = false
+
+   If you want to use udev instead of hotplug to manage the activation of
+   pcmciautils, modify the line which starts with UDEV to read
+
+	UDEV = true
+
+   Issue the famous make command next. Then, if you already had PCMCIA
+   running well, make a backup copy of /etc/pcmcia/config.opts. Then
+   issue make install.
+
+   If you need a resource database, you should use the version of
+   /etc/pcmcia/config.opts you had up and running before (so restore the
+   backup copy you just made). Else you can try to use the version which
+   is distributed within pcmciautils and installed by default; however
+   you might need to modify it for the specific needs of the
+   architecture, socket and system you are using.
+
+
+  2.5. The difficult cases: CIS overrides
+  ---------------------------------------
+
+   If the PCMCIA card you use needs a "CIS" override (sort of a
+   "firmware" override) to work correctly, get the proper file out of
+   [10]pcmcia-cs or from other sources, rename it from ".dat" to ".cis"
+   and store it into /lib/firmware/.
+
+
+3. Usage
+--------
+
+  3.1. devices
+  ------------
+
+   Plug the cards in, watch them appear in /sys/bus/pcmcia/devices/, use
+   them. Don't forget to unmount block devices before ejecting a PCMCIA
+   card!
+
+   If you relied on the startup scripts in /etc/pcmcia/*, you should
+   switch to the generic hotplug scripts in one of its variants (hotplug,
+   hotplug-ng, and so on) or to udev rules. Most distributions already
+   include this capability; if not, you might need to adapt them slightly
+   depending on your distribution and configuration. Also check the udev
+   documentation, for example if you want to name interfaces differently
+   from the kernel's default setting.
+
+  3.2. pccardctl (replaces cardctl)
+  ---------------------------------
+
+   And what about the command cardctl you might be used to? It is
+   replaced by several new ways to achieve the same aims; if you want to
+   update pccardctl to handle them all, please send patches to the
+   [11]Linux-PCMCIA mailinglist.
+
+	cardctl info            pccardctl info
+	cardctl ident           pccardctl ident
+	cardctl insert          pccardctl insert
+	cardctl eject           pccardctl eject
+	cardctl suspend         pccardctl suspend [>=2.6.15]
+	cardctl resume          pccardctl resume  [>=2.6.15]
+	cardctl suspend         echo -n "3" > /sys/class/pcmcia_socket/pcmcia_socket*/d
+	evice/power/state
+	cardctl resume          echo -n "0" > /sys/class/pcmcia_socket/pcmcia_socket*/d
+	evice/power/state
+	cardctl status          cat /sys/class/pcmcia/pcmcia_socket/*/*
+	cardctl config          cat /sys/bus/pcmcia/devices/*/*
+	cardctl scheme          -- not implemented, as incompatible to cardbus. Use
+	                           other utilities (udev, nameif, ...) to achieve
+        	                   the same aims --
diff --git a/doc/pcmcia-new.sh b/doc/pcmcia-new.sh
new file mode 100644
index 0000000..5195989
--- /dev/null
+++ b/doc/pcmcia-new.sh
@@ -0,0 +1,36 @@
+#!/bin/sh
+#
+# this is an examle of the /etc/init.d/pcmcia-new init script as described in
+# cardmgr-to-pcmciautils.txt
+#
+
+#
+# set this to the driver to use, one of:
+# yenta_socket, i82365, i82092, pd6792, tcic, etc.
+#
+DRIVER=yenta_socket
+DRIVER_OPTS=
+
+# in case modprobe and rmmod are not in PATH: set MODUTILS_PATH to the right
+# path an uncomment the following two lines:
+#MODUTILS_PATH=
+#export PATH=$MODUTILS_PATH:$PATH
+
+case "$1" in
+	start)
+		modprobe $DRIVER $DRIVER_OPTS > /dev/null 2>&1
+		modprobe pcmcia > /dev/null 2>&1 # just in case it's not auto-loaded
+		;;
+
+	stop)
+		pccardctl eject
+		MODULES=`lsmod | grep "pcmcia " | awk '{print $4}' | tr , ' '`
+		for i in $MODULES ; do
+			rmmod $i > /dev/null 2>&1
+		done
+		rmmod pcmcia > /dev/null 2>&1
+		rmmod $DRIVER > /dev/null 2>&1
+		rmmod rsrc_nonstatic > /dev/null 2>&1
+		rmmod pcmcia_core > /dev/null 2>&1
+		;;
+esac
diff --git a/hotplug/pcmcia.rc b/hotplug/pcmcia.rc
index 19f15fe..6b240ab 100755
--- a/hotplug/pcmcia.rc
+++ b/hotplug/pcmcia.rc
@@ -22,7 +22,7 @@
 		continue;
 	    fi;
 	    MODALIAS=$(cat $PCMCIA_DEVICE/modalias)
-	    debug_mesg $MODALIAS $PCMICA_DEVICE
+	    debug_mesg $MODALIAS $PCMCIA_DEVICE
 	    if [ -z $MODALIAS ]; then
 		continue;
 	    fi;
diff --git a/man/man8/pccardctl.8 b/man/man8/pccardctl.8
new file mode 100644
index 0000000..6c1ff4a
--- /dev/null
+++ b/man/man8/pccardctl.8
@@ -0,0 +1,66 @@
+.\" Copyright (C) 1998 David A. Hinds -- dahinds@users.sourceforge.net
+.\" Copyright (C) 2005 by Daniel Ritz <daniel.ritz@gmx.ch>
+.\"
+.TH PCCARDCTL 8 "2005/10/22" "pcmciautils"
+.SH NAME
+pccardctl \- PCMCIA card control utility
+
+.SH SYNOPSIS
+\fBpccardctl\fR [\fB-V\fR] \fIcommand\fR [\fIsocket\fR]
+.br
+
+.SH DESCRIPTION
+\fBpccardctl\fR is used to monitor and control the state of PCMCIA
+sockets.  If a socket number is specified, the command will be applied
+to just one socket; otherwise, all sockets will be affected.
+.PP
+If \fBpccardctl\fR is executed by root, all commands are available.  If
+it is executed by an unpriviledged user, only the informational
+commands are accessible.
+.PP
+
+.SH COMMANDS
+.TP \w'abcd'u
+.B status
+Display the current socket status flags. \-\-not yet implemented
+.TP
+.B config
+Display the socket configuration, including power settings, interrupt
+and I/O window settings, and configuration registers.
+\-\-not yet implemented
+.TP
+.B ident
+Display card identification information, including product
+identification strings, manufacturer ID codes, and function ID codes.
+Not yet implemented for cardbus cards. Use lspci instead.
+.TP
+.B info
+Much like the \fBident\fR command, but its output is formatted as a
+series of Bourne-stype shell variable definitions for use in scripts.
+Not yet implemented for cardbus cards.
+.TP
+.B suspend
+Shut down and then disable power for a socket.
+.TP
+.B resume
+Restore power to a socket, and re-configure for use.
+.TP
+.TP
+.B eject
+Notify all client drivers that this card will be ejected, then cut
+power to the socket.
+.TP
+.B insert
+Notify all client drivers that this card has just been inserted.
+
+.SH OPTIONS
+.TP
+.B \-V
+Show version information and exit.
+
+.SH AUTHOR
+Daniel Ritz \- daniel.ritz@gmx.ch
+.br
+based upon the original cardctl man page by
+.br
+David Hinds \- dahinds@users.sourceforge.net
diff --git a/src/pccardctl.c b/src/pccardctl.c
index 5bef5d2..6f4e06a 100644
--- a/src/pccardctl.c
+++ b/src/pccardctl.c
@@ -41,7 +41,7 @@
         if (!attr)
                 return -ENODEV;
 
-        ret = sysfs_write_attribute(attr, power ? "3" : "0", 1);
+        ret = sysfs_write_attribute(attr, power ? "2" : "0", 1);
 
         sysfs_close_attribute(attr);
 
diff --git a/udev/60-pcmcia.rules b/udev/60-pcmcia.rules
deleted file mode 100644
index 79909ed..0000000
--- a/udev/60-pcmcia.rules
+++ /dev/null
@@ -1,27 +0,0 @@
-# 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
deleted file mode 100644
index 23ef3e3..0000000
--- a/udev/60-pcmcia.rules.static
+++ /dev/null
@@ -1,27 +0,0 @@
-# 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/rules-base b/udev/rules-base
new file mode 100644
index 0000000..c6d14de
--- /dev/null
+++ b/udev/rules-base
@@ -0,0 +1,18 @@
+
+# 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
+ACTION=="add", SUBSYSTEM=="pcmcia_socket", \
+		RUN+="/sbin/modprobe pcmcia"
diff --git a/udev/rules-modprobe b/udev/rules-modprobe
new file mode 100644
index 0000000..ea1f44a
--- /dev/null
+++ b/udev/rules-modprobe
@@ -0,0 +1,3 @@
+# modprobe $modalias loads all possibly appropriate modules
+ACTION=="add", SUBSYSTEM=="pcmcia", MODALIAS=="?*", \
+		RUN+="/sbin/modprobe $modalias"
diff --git a/udev/rules-nonstaticsocket b/udev/rules-nonstaticsocket
new file mode 100644
index 0000000..23b599e
--- /dev/null
+++ b/udev/rules-nonstaticsocket
@@ -0,0 +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"
diff --git a/udev/rules-start b/udev/rules-start
new file mode 100644
index 0000000..790902b
--- /dev/null
+++ b/udev/rules-start
@@ -0,0 +1,2 @@
+# PCMCIA devices:
+#