RFC: add udev support to parport_pc



Here is a patch to parport_pc.c that adds udev support. Without it sysfs does not have enough information to give to udev so the lp and parport nodes can be created. The only problem I have is the kernel_oops when I do the following: insmod parport, insmod parport_pc, rmmod parport_pc, rmmod parport, insmod parport, insmod parport_pc, rmmod parport_pc, kernel oops.
From the part of the traceback I can read the problem is in parport_pc_exit.
Any help in tracking down the problem would be appreciated. If this is acceptable how can I get this added to the mainline? This is my first patch so please be gentle.

Thanks,
Jason Dravet

Signed-off-by: Jason Dravet <dravet@xxxxxxxxxxx>
--- /usr/src/linux-2.6.14/drivers/parport/parport_pc.c.orig 2005-12-30 13:52:48.000000000 -0600
+++ /usr/src/linux-2.6.14/drivers/parport/parport_pc.c 2005-12-30 19:56:20.000000000 -0600
@@ -55,6 +55,7 @@
#include <linux/pci.h>
#include <linux/pnp.h>
#include <linux/sysctl.h>
+#include <linux/sysfs.h>


#include <asm/io.h>
#include <asm/dma.h>
@@ -99,6 +100,8 @@ static struct superio_struct {	/* For Su
	int dma;
} superios[NR_SUPERIOS] __devinitdata = { {0,},};

+static struct class *parallel_class;
+
static int user_specified;
#if defined(CONFIG_PARPORT_PC_SUPERIO) || \
       (defined(CONFIG_PARPORT_1284) && defined(CONFIG_PARPORT_PC_FIFO))
@@ -2232,6 +2235,25 @@ struct parport *parport_pc_probe_port (u
                                           is mandatory (see above) */
		p->dma = PARPORT_DMA_NONE;

+ parallel_class = class_create(THIS_MODULE, "lp");
+ if (p->base == 888) /* 888 is dec for 378h */
+ {
+ class_device_create(parallel_class, NULL, MKDEV(6, 0), NULL, "lp0");
+ class_device_create(parallel_class, NULL, MKDEV(99, 0), NULL, "parport0");
+ }
+
+ if (p->base == 632) /* 632 is dec for 278h */
+ {
+ class_device_create(parallel_class, NULL, MKDEV(6, 1), NULL, "lp1");
+ class_device_create(parallel_class, NULL, MKDEV(99, 1), NULL, "parport1");
+ }
+
+ if (p->base == 956) /* 956 is dec for 3BCh */
+ {
+ class_device_create(parallel_class, NULL, MKDEV(6, 2), NULL, "lp2");
+ class_device_create(parallel_class, NULL, MKDEV(99, 2), NULL, "parport2");
+ }
+
#ifdef CONFIG_PARPORT_PC_FIFO
if (parport_ECP_supported(p) &&
p->dma != PARPORT_DMA_NOFIFO &&
@@ -3406,6 +3428,13 @@ static void __exit parport_pc_exit(void)
if (pnp_registered_parport)
pnp_unregister_driver (&parport_pc_pnp_driver);


+	class_device_destroy(parallel_class, MKDEV(99, 2));
+	class_device_destroy(parallel_class, MKDEV(6, 2));
+	class_device_destroy(parallel_class, MKDEV(99, 1));
+	class_device_destroy(parallel_class, MKDEV(6, 1));
+	class_device_destroy(parallel_class, MKDEV(99, 0));
+	class_device_destroy(parallel_class, MKDEV(6, 0));
+
	spin_lock(&ports_lock);
	while (!list_empty(&ports_list)) {
		struct parport_pc_private *priv;


- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/



Relevant Pages

  • Re: RFC: add udev support to parport_pc
    ... > Here is a patch to parport_pc.c that adds udev support. ... > parport nodes can be created. ... > rmmod parport_pc, rmmod parport, insmod parport, insmod parport_pc, ...
    (Linux-Kernel)
  • Re: [patch/rfc 2.6.20-git] parport reports physical devices
    ... underlying parport. ... This patch resolves that issue for non-legacy configurations: ... I'm using for my daily work has such a legacy parallel port, ... This would make the driver smaller.) ...
    (Linux-Kernel)
  • Re: [patch 2.6.21-rc5 1/3] parport->dev driver model support
    ... of sysfs child nodes, which can affect things like power management. ... This patch adds a field to "struct parport" pointing to that device node, ... NOTE this depends on an earlier patch to make pnp devices set up DMA, ... parport is the primary user of legacy i8237 dma infrastructure. ...
    (Linux-Kernel)
  • Re: [patch 2.6.21-rc5 1/3] parport->dev driver model support
    ... of sysfs child nodes, which can affect things like power management. ... This patch adds a field to "struct parport" pointing to that device node, ... NOTE this depends on an earlier patch to make pnp devices set up DMA, ... parport is the primary user of legacy i8237 dma infrastructure. ...
    (Linux-Kernel)
  • Re: [PATCH] Prevent legacy io access on pmac
    ... Follow up to the previous patch: ... Update the return values in i8402 and parport to -ENODEV. ... Please read the FAQ at http://www.tux.org/lkml/ ...
    (Linux-Kernel)