[mythtv] loading lirc kernel modules

D. Hugh Redelmeier hugh at mimosa.com
Sat Oct 7 07:04:38 UTC 2006


I wonder what is the best way to load the lirc kernel module.
I'm using Fedora Core 5 and following Jarod's guide.

In a fairly recent change to Jarod's guide, he recommends adding 
lirc.modules to /etc/sysconfig/modules/:

    #!/bin/sh

    for module in `/sbin/modprobe -c | awk '/^alias[[:space:]]+char-major-61+[[:space:]]/ { print $3 }'`; do
	    /sbin/modprobe $module
    done

I would have expected that the following command would do the same
thing more simply and reliably:
	/sbin/modprobe char-major-61

Actually, I suspect that the awk regular expression has a bug.  The
segment "char-major-61+" matches char-major-61, char-major-611,
char-major-6111, etc.  I don't think that this was intended.  I think
that the plus should be removed.



Anyway, this way of loading the module seems like a bit of a kludge.
I wonder what the best way is.

It seems to me that opening any character device with major number 61
should provoke the effect of /sbin/modprobe char-major-61.  On my
system,
	ls -lR /dev | grep 61,
yields
    crw------- 1 root   root    61,   0 Oct  6 20:52 lirc0
    crw------- 1 root   root    61,   1 Oct  6 20:52 lirc1
    crw------- 1 root   root    61,   2 Oct  6 20:52 lirc2
    crw------- 1 root   root    61,   3 Oct  6 20:52 lirc3
(and /dev/lirc is a symlink to /dev/lirc0)
So why doesn't starting up lircd cause the module to be loaded?

Ah! The brave new world of dynamic /dev.  There is no /dev entry with
char-major-61 until the module is loaded!  So how can the alias
char-major-61 ever get used?  Is this just a hold-over from the days
of a static /dev?


So, as far as I can tell, nothing seems to provoke a modprobe of the
right module.  When should it happen?

The logic of lircd is that it only tries to open the device once it
has a client.  Hard to hook into that.  Maybe it is OK for the the
/etc/rc.d/init.d/lircd "start" action to include the modprobe.  This
seems a little better than Jarod's approach: at least the modprobe is
delayed until the "user" of the module is initialized.


Here are my proposed changes to /etc/rc.d/init.d/lircd (relative to
the atrpms version for Fedora Core 5).  I've explained the changes
that remove "daemon" in a message to the atrpms list (summary: they
are redundant).

Have I got this right?  Is there a better way?

===================================================================
RCS file: RCS/lircd,v
retrieving revision 1.1
diff -u -r1.1 lircd
--- lircd	2006/10/07 00:36:33	1.1
+++ lircd	2006/10/07 06:51:40
@@ -20,21 +20,27 @@
 RETVAL=0
 
 start(){
+	if [ ! -f /dev/lirc ] ; then
+		echo -n $"Installing lirc kernel modules: "
+		modprobe char-major-61
+		RETVAL=$?
+		echo
+	fi
 	if [ -f /etc/lircd.conf ]; then
 		echo -n $"Starting infrared remote control daemon: "
-		daemon lircd $LIRCD_OPTIONS
+		lircd $LIRCD_OPTIONS
 		RETVAL=$?
 		echo
 	fi
 	if [ -f /etc/lircmd.conf ]; then
 		echo -n $"Starting infrared remote control mouse daemon: "
-		daemon lircmd
+		lircmd
 		RETVAL=$?
 		echo
 	fi
 	if [ -f /etc/irexec.conf ]; then
 		echo -n $"Starting infrared command execution daemon: "
-		daemon irexec --daemon /etc/irexec.conf
+		irexec --daemon /etc/irexec.conf
 		RETVAL=$?
 		echo
 	fi

================ end of diff ================


More information about the mythtv-dev mailing list