Re: Patch of a new driver for kernel 2.4.x that need review

From: Pekka J Enberg
Date: Thu Jul 07 2005 - 01:11:42 EST


Mark Gross writes:
+static int
+tlclk_open(struct inode *inode, struct file *filp)
+{
+ int result;
+#ifdef MODULE
+ if (!MOD_IN_USE) {
+ MOD_INC_USE_COUNT;
+#endif
+ /* Make sure there is no interrupt pending will + * initialising interrupt handler */
+ inb(TLCLK_REG6);
+
+ result = request_irq(telclk_interrupt, &tlclk_interrupt,
+ SA_SHIRQ, "telclock", tlclk_interrupt);

Instead of playing the MOD_IN_USE games, please either (1) grab the irq in module init (it's a shared IRQ after all) or (2) do the following:

static int tlclk_used;

static int tlclk_open(struct inode *inode, struct file *filp) {
if (tlclk_used++)
return 0;

// request_irq goes here.
}

For an example, see the file drivers/input/mouse/amimouse.c (appears in 2.6.12 at least).

Pekka

-
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/