From: David Schleef Date: Wed, 15 May 2002 19:08:53 +0000 (+0000) Subject: Added open/close hooks to device structure X-Git-Tag: r0_7_65~45 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=9d8d0f236255459fd5738f651c5bae8789588ab6;p=comedi.git Added open/close hooks to device structure --- diff --git a/comedi/comedi_fops.c b/comedi/comedi_fops.c index 2e23fe79..66e1a342 100644 --- a/comedi/comedi_fops.c +++ b/comedi/comedi_fops.c @@ -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); diff --git a/include/linux/comedidev.h b/include/linux/comedidev.h index c468d5d5..715db327 100644 --- a/include/linux/comedidev.h +++ b/include/linux/comedidev.h @@ -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); };