Added open/close hooks to device structure
authorDavid Schleef <ds@schleef.org>
Wed, 15 May 2002 19:08:53 +0000 (19:08 +0000)
committerDavid Schleef <ds@schleef.org>
Wed, 15 May 2002 19:08:53 +0000 (19:08 +0000)
comedi/comedi_fops.c
include/linux/comedidev.h

index 2e23fe79d9fe591e6a967565c984bb38ec7289ea..66e1a342b78df97ee8e3e7cd0fd07984b44ced8f 100644 (file)
@@ -1618,6 +1618,11 @@ ok:
        if(dev->attached && dev->driver->module){
                __MOD_INC_USE_COUNT(dev->driver->module);
        }
+
+       if(dev->attached && dev->use_count==0 && dev->open){
+               dev->open(dev);
+       }
+
        dev->use_count++;
 
        return 0;
@@ -1640,6 +1645,10 @@ static int comedi_close_v22(struct inode *inode,struct file *file)
                }
        }
 
+       if(dev->attached && dev->use_count==1 && dev->close){
+               dev->close(dev);
+       }
+
        MOD_DEC_USE_COUNT;
        if(dev->attached && dev->driver->module){
                __MOD_DEC_USE_COUNT(dev->driver->module);
index c468d5d5176c691b628c7e12ea502605c04d801d..715db3271e07ce82d175d6a5b80e27f28f573dd8 100644 (file)
@@ -206,6 +206,9 @@ struct comedi_device_struct{
        wait_queue_head_t write_wait;
 
        struct fasync_struct *async_queue;
+
+       void (*open)(comedi_device *dev);
+       void (*close)(comedi_device *dev);
 };