3.3. Opening And Closing The Capture Device


static int users = 0;

static int camera_open(stuct video_device *dev, int flags)
{
        if(users)
                return -EBUSY;
        if(request_irq(irq, camera_irq, 0, "camera", dev)<0)
                return -EBUSY;
        users++;
        MOD_INC_USE_COUNT;
        return 0;
}


static int camera_close(struct video_device *dev)
{
        users--;
        free_irq(irq, dev);
        MOD_DEC_USE_COUNT;
}
  

The open and close routines are also quite similar. The only real change is that we now request an interrupt for the camera device interrupt line. If we cannot get the interrupt we report EBUSY to the application and give up.