From 28a40cf3176dc0f5e18086694861e15d6a665e53 Mon Sep 17 00:00:00 2001 From: Frank Mori Hess Date: Thu, 26 Apr 2007 14:54:10 +0000 Subject: [PATCH] Added support for a cmd_cleanup() callback on subdevices, which is called when a command is finished. Will be used to release mite DMA channels when no longer in use. --- comedi/comedi_fops.c | 11 ++++++++--- comedi/kcomedilib/kcomedilib_main.c | 4 +++- include/linux/comedidev.h | 1 + 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/comedi/comedi_fops.c b/comedi/comedi_fops.c index d7eea148..f9aceb0b 100644 --- a/comedi/comedi_fops.c +++ b/comedi/comedi_fops.c @@ -1550,16 +1550,21 @@ static ssize_t comedi_read(struct file * file,char *buf,size_t nbytes,loff_t *of void do_become_nonbusy(comedi_device *dev,comedi_subdevice *s) { comedi_async *async = s->async; - /* we do this because it's useful for the non-standard cases */ - s->subdev_flags &= ~SDF_RUNNING; + s->subdev_flags &= ~SDF_RUNNING; #ifdef CONFIG_COMEDI_RT if(s->runflags&SRF_RT){ comedi_switch_to_non_rt(dev); s->runflags &= ~SRF_RT; } #endif - + if(s->busy) + { + if(s->cmd_cleanup) + { + (*s->cmd_cleanup)(dev, s); + } + } if(async){ comedi_reset_async_buf( async ); }else{ diff --git a/comedi/kcomedilib/kcomedilib_main.c b/comedi/kcomedilib/kcomedilib_main.c index 195ebe7f..2902ed89 100644 --- a/comedi/kcomedilib/kcomedilib_main.c +++ b/comedi/kcomedilib/kcomedilib_main.c @@ -424,7 +424,9 @@ int comedi_cancel(comedi_t *d,unsigned int subdevice) s->runflags &= ~SRF_RT; comedi_switch_to_non_rt(dev); } - + // XXX cmd_cleanup() doesn't really belong here, but comedi_cancel() is the closest thing to + // do_become_nonbusy() in kcomedilib. + if(s->cmd_cleanup) s->cmd_cleanup(dev, s); s->busy=NULL; return 0; diff --git a/include/linux/comedidev.h b/include/linux/comedidev.h index 6e33a42d..8ad1e99e 100644 --- a/include/linux/comedidev.h +++ b/include/linux/comedidev.h @@ -132,6 +132,7 @@ struct comedi_subdevice_struct{ int (*do_cmd)(comedi_device *,comedi_subdevice *); int (*do_cmdtest)(comedi_device *,comedi_subdevice *,comedi_cmd *); + void (*cmd_cleanup)(comedi_device *, comedi_subdevice *); int (*poll)(comedi_device *,comedi_subdevice *); int (*cancel)(comedi_device *,comedi_subdevice *); //int (*do_lock)(comedi_device *,comedi_subdevice *); -- 2.26.2