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++;
        return 0;
}


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

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.