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

Pekka J Enberg
2005-07-07T06:10:44Z

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