RTAI-fusion patch to support udev
Frederic Villeneuve
frederic.villeneuve@laposte.net
Sat, 17 Sep 2005 21:08:23 -0400
This is a multi-part message in MIME format.
--------------030403060202000402090100
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Hello,
Here is a patch that solves the issue where udev wipes out /dev/rtpX
device nodes after reboot.
This patch creates a class "rtpipe" in /sys/class that let udev knows
that it needs to create device nodes in /dev when rtai_nucleus.ko is loaded.
udev also needs a rules file copied to /etc/udev/rules.d in order to
create the device nodes.
Thanks to Philippe for taking care of the autoconf wizardry needed to
install the rules file.
Frederic
--------------030403060202000402090100
Content-Type: text/plain;
name="rtpipe.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="rtpipe.patch"
Index: nucleus/pipe.c
===================================================================
RCS file: /cvs/rtai/fusion/nucleus/pipe.c,v
retrieving revision 1.22
diff -u -r1.22 pipe.c
--- nucleus/pipe.c 26 Aug 2005 16:15:46 -0000 1.22
+++ nucleus/pipe.c 17 Sep 2005 02:02:32 -0000
@@ -28,6 +28,7 @@
#include <linux/termios.h>
#include <linux/proc_fs.h>
#include <linux/spinlock.h>
+#include <linux/device.h>
#include <asm/io.h>
#include <asm/uaccess.h>
#include <asm/system.h>
@@ -40,6 +41,17 @@
static xnpipe_session_handler *xnpipe_open_handler,
*xnpipe_close_handler;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13)
+ static struct class *xnpipe_class;
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
+ static struct class_simple *xnpipe_class;
+ #define class_create class_simple_create
+ #define class_device_create class_simple_device_add
+ #define class_device_destroy(a,b) class_simple_device_remove(b)
+ #define class_destroy class_simple_destroy
+#endif
+
+
xnpipe_state_t xnpipe_states[XNPIPE_NDEVS];
xnqueue_t xnpipe_sleepq, xnpipe_asyncq;
@@ -935,6 +947,7 @@
{
xnpipe_state_t *state;
+ int i;
for (state = &xnpipe_states[0];
state < &xnpipe_states[XNPIPE_NDEVS]; state++)
@@ -953,6 +966,26 @@
initq(&xnpipe_sleepq);
initq(&xnpipe_asyncq);
+ xnpipe_class = class_create(THIS_MODULE, "rtpipe");
+ if(IS_ERR(xnpipe_class))
+ {
+ xnlogerr("Error Creating rtpipe class.\n");
+ return PTR_ERR(xnpipe_class);
+ }
+
+ for (i = 0; i < XNPIPE_NDEVS; i++)
+ {
+ struct class_device* cldev;
+ cldev = class_device_create(xnpipe_class, MKDEV(XNPIPE_DEV_MAJOR, i),
+ NULL, "rtp%d", i);
+ if(IS_ERR(cldev))
+ {
+ xnlogerr("Can't add device class, major=%d, minor=%d\n", XNPIPE_DEV_MAJOR, i);
+ class_destroy(xnpipe_class);
+ return PTR_ERR(cldev);
+ }
+ }
+
if (register_chrdev(XNPIPE_DEV_MAJOR,"rtpipe",&xnpipe_fops))
{
xnlogerr("Unable to reserve major #%d for message pipe support.\n",
@@ -968,8 +1001,15 @@
void xnpipe_umount (void)
{
+ int i;
+
rthal_apc_free(xnpipe_wakeup_apc);
unregister_chrdev(XNPIPE_DEV_MAJOR,"rtpipe");
+ for (i = 0; i < XNPIPE_NDEVS; i ++)
+ {
+ class_device_destroy(xnpipe_class, MKDEV(XNPIPE_DEV_MAJOR, i));
+ }
+ class_destroy(xnpipe_class);
}
EXPORT_SYMBOL(xnpipe_connect);
--------------030403060202000402090100
Content-Type: text/plain;
name="fusion.rules"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="fusion.rules"
KERNEL="rtp[0-9]*", NAME="%k", MODE="0666"
--------------030403060202000402090100--