summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'net-dialup/capi4k-utils/files/capi.hotplug')
-rw-r--r--net-dialup/capi4k-utils/files/capi.hotplug65
1 files changed, 51 insertions, 14 deletions
diff --git a/net-dialup/capi4k-utils/files/capi.hotplug b/net-dialup/capi4k-utils/files/capi.hotplug
index 9ed7517069ff..00be239e424c 100644
--- a/net-dialup/capi4k-utils/files/capi.hotplug
+++ b/net-dialup/capi4k-utils/files/capi.hotplug
@@ -1,20 +1,41 @@
#!/bin/bash
-# Copyright 1999-2004 Gentoo Foundation
+# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/net-dialup/capi4k-utils/files/capi.hotplug,v 1.1 2005/03/29 06:43:28 mrness Exp $
+# $Header: /var/cvsroot/gentoo-x86/net-dialup/capi4k-utils/files/capi.hotplug,v 1.2 2005/03/29 22:16:07 genstef Exp $
. /etc/conf.d/capi
[ "$CAPI_HOTPLUG_USB" = "0" ] && exit 0
+# syslog output
+syslog() { # <msg>
+ /usr/bin/logger -t "capi-usb" "$1"
+}
+
+beep_ok() {
+ [ "$CAPI_HOTPLUG_BEEP" = "0" ] || echo -en "\033[10;1200]\a\033[10;262]" > /dev/console
+}
+
+beep_error() {
+ [ "$CAPI_HOTPLUG_BEEP" = "0" ] || echo -en "\033[10;300]\a\033[10;262]" > /dev/console
+}
+
# driver lookup
cardinfo() { # <driver>
- /bin/sed 2>/dev/null -n "s:^\([1-9][0-9]*\) \+${1} \+\([^ ]\+\) \+\([^ ]\+\).*:\1 \3 \2:p" /proc/capi/controller
+ # /proc/capi/controller: <controller> <drivername> <state> <cardname> <controllerinfo>
+ /bin/sed 2>/dev/null -n "s:^\([1-9][0-9]*\) \+${1} \+\([^ ]\+\) \+\([^ ]\+\) \+\([^ ]\+\):\1 \3 \2 \4:p" /proc/capi/controller
}
# AVM firmware loader
-avmusb() { # <card> <firmware>
- /usr/sbin/avmcapictrl load "/lib/firmware/${2}" "${1}"
+avmusb() { # <driver> <usbdev> <firmware>
+ local CARD NAME STATUS TYPE VER DEV FIRMWARE
+ while read CARD NAME STATUS TYPE VER DEV; do # AVM cardinfo
+ if [ "${STATUS}" = "detected" -a ${DEV} -eq ${2} ]; then
+ syslog "loading firmware ${3} into controller ${CARD} (${NAME})"
+ /usr/sbin/avmcapictrl load "/lib/firmware/${3}" "${CARD}"
+ break
+ fi
+ done < <(cardinfo "${1}")
}
# normalize and split product code
@@ -66,30 +87,46 @@ case "${VENDID}" in
FIRMWARE="fdlubase.frm"
;;
*) # unknown card
- echo "unknown USB product: $VENDID"
+ syslog "unknown USB product: ${VENDID}"
exit 1
esac
case "$ACTION" in
add)
/bin/ln 2>/dev/null -s "$$" "$LOCK" || exit 0
- for MODULE in kernelcapi capi capidrv $DRIVER; do
- /sbin/modprobe -s $MODULE || exit 1
- done
+
+ # loading capi + capidrv
+ ( [ -f /proc/capi/capi20 ] || /sbin/modprobe -sq capi ) && \
+ ( [ -f /proc/capi/capidrv -o "$CAPI_LOAD_CAPIDRV" = "0" ] || /sbin/modprobe -sq capidrv )
+ if [ $? -ne 0 ]; then
+ syslog "could not load CAPI!"
+ beep_error; /bin/rm -f "$LOCK"; exit 1
+ fi
+
+ # loading driver
+ if ! /sbin/modprobe -sq $DRIVER; then
+ syslog "could not load driver ${DRIVER}!"
+ beep_error; /bin/rm -f "$LOCK"; exit 1
+ fi
+
+ # loading firmware
if [ -n "$LOADER" -a -n "$FIRMWARE" ]; then
CNT=0 # wait for udev
while [ ! -e /dev/capi20 -a $CNT -lt 10 ]; do
sleep 1; : $((CNT++))
done
- read CARD NAME STATUS < <(cardinfo $DRIVER)
- [ "$STATUS" = "detected" ] && $LOADER $CARD $FIRMWARE
+ if [ -f "/lib/firmware/${FIRMWARE}" ]; then
+ $LOADER $DRIVER $USBDEV $FIRMWARE
+ else
+ syslog "firmware ${FIRMWARE} not found!"
+ beep_error; /bin/rm -f "$LOCK"; exit 1
+ fi
fi
- [ "$CAPI_HOTPLUG_BEEP" = "0" ] || echo -en "\033[10;1200]\a\033[10;262]" > /dev/console
- /bin/rm -f "$LOCK"
+
+ beep_ok; /bin/rm -f "$LOCK"
;;
remove)
/sbin/modprobe -sqr $DRIVER
- [ "$CAPI_HOTPLUG_BEEP" = "0" ] || echo -en "\033[10;300]\a\033[10;262]" > /dev/console
;;
esac
exit 0