Package: sl-modem-daemon
Version: 2.9.9a-1
Tags: patch
The enclosed patch makes the following improvements to the
/etc/init.d/sl-modem-daemon script:
1. On "stop", unload the kernel module. This is the most important
change, as unloading the kernel module powers down the device hardware,
which I'm hoping extends the battery life on my laptop.
To do this, I removed the "config" call from the "stop" action. The
"config" function loads the kernel module to figure out the device to
pass to "start". This is counterproductive if we are stopping and want
to be unloading the module.
The stop command also now instructs start-stop-daemon to wait for the
daemon to quit before trying to unload its module.
2. Fix the timing on "start." If the daemon is started too fast after
loading the ALSA kernel module, the snd_pcm_open() call in the daemon
will fail because the needed devices haven't appeared in /dev yet. I
added a wait loop after the modprobe and before starting the daemon.
(Or this wait could be moved into modem/modem_main.c instead so that the
daemon sleeps and retries the open a few times before quitting on
failure.)
Another minor fix to the module loading in "start" is the check for the
module already existing. The check was looking for "snd-intel8x0m" in
/proc/modules, but on my system it appears as "snd_intel8x0m". I
changed the check to grep for "snd.intel8x0m" so that either name will
be found.
3. Add a "status" option.
< Stephen
--- sl-modem-2.9.9a/debian/sl-modem-daemon.init 2005-06-08 13:51:05
+++ debian/sl-modem-daemon.init 2005-06-08 17:00:20
@@ -96,13 +96,19 @@
start() {
if [ "$ALSA" ] ; then
- test -e /proc/asound/Modem || grep -q 'snd-intel8x0m' /proc/modules ||
{
+ test -e /proc/asound/Modem || grep -q 'snd.intel8x0m' /proc/modules ||
{
echo -n "Loading ALSA modem driver into kernel ... "
$modprobe snd-intel8x0m && echo "done." || {
echo "failed."
exit -1
}
}
+ DEV_SND_FILE=/dev/snd/controlC${SLMODEMD_DEVICE##*:}
+ for start_reps in `seq 100` ; do
+ test -r "$DEV_SND_FILE" && break
+ : wait $start_reps for the kernel module to make the device
$DEV_SND_FILE appear
+ sleep 0.1
+ done
echo -n "Starting SmartLink Modem driver for: $SLMODEMD_DEVICE"
start-stop-daemon --start --pidfile $PIDFILE --exec $DAEMON
--make-pidfile --background --quiet -- --alsa $OPTS
else
@@ -129,18 +135,49 @@
stop() {
echo -n "Shutting down SmartLink Modem driver normally"
+ RETVAL=0
if [ "`pidof $NAME`" ] ; then
- if start-stop-daemon --stop --quiet --pidfile $PIDFILE --exec $DAEMON ;
then
+ if start-stop-daemon --stop --quiet --pidfile $PIDFILE --exec $DAEMON
--retry 1 ; then
echo .
else
echo " probably failed."
echo "Trying it the hard way (send SIGKILL all $NAME processes): "
- killall -KILL $NAME || return 1
+ killall -KILL $NAME || RETVAL=1
fi
else
echo " ... no $NAME daemon running."
fi
- return 0
+ test "$RETVAL" -ne 0 || rm -f "$PIDFILE"
+ ! grep -q 'snd.intel8x0m' /proc/modules || {
+ echo -n "Unloading ALSA modem driver from kernel ... "
+ "$modprobe" -r snd-intel8x0m && echo "done." || {
+ echo "failed."
+ RETVAL=1
+ }
+ }
+ ! grep -q 'slamr' /proc/modules || {
+ echo -n "Unloading SmartLink Modem driver from kernel ... "
+ "$modprobe" -r slamr && echo "done." || {
+ echo "failed."
+ RETVAL=1
+ }
+ }
+ return "$RETVAL"
+}
+
+status() {
+ echo -n "Status of $DESC: "
+ if [ ! -r "$PIDFILE" ]; then
+ echo "$NAME is not running."
+ exit 3
+ fi
+ if read pid < "$PIDFILE" && ps -p "$pid" > /dev/null 2>&1; then
+ echo "$NAME is running."
+ exit 0
+ else
+ echo "$NAME is not running but $PIDFILE exists."
+ exit 1
+ fi
}
# See how we were called.
@@ -163,14 +200,16 @@
start
;;
stop)
- config
- stop && rm -f $PIDFILE
+ stop
;;
restart|reload)
+ stop
config
- stop && rm -f $PIDFILE
start
;;
+ status)
+ status
+ ;;
*)
echo "Usage: /etc/init.d/$NAME {start|stop|restart}"
exit 1
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]