From: Frank Mori Hess Date: Thu, 26 Apr 2007 14:58:03 +0000 (+0000) Subject: Got rid of call to subdevice's buf_change callback which occurred after X-Git-Tag: r0_7_74~100 X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=2eabb0ba9596e03123ae18aba6446f2a13b854de;p=comedi.git Got rid of call to subdevice's buf_change callback which occurred after device was detached. Small cleanup of duplicated code. --- diff --git a/comedi/drivers.c b/comedi/drivers.c index 9fa40f60..08d17089 100644 --- a/comedi/drivers.c +++ b/comedi/drivers.c @@ -80,7 +80,6 @@ static void cleanup_device(comedi_device *dev) if(s->async) { comedi_buf_alloc(dev, s, 0); - if(s->buf_change) s->buf_change(dev, s, 0); kfree(s->async); } } @@ -104,26 +103,26 @@ static void cleanup_device(comedi_device *dev) dev->close = NULL; } -int comedi_device_detach(comedi_device *dev) +static int __comedi_device_detach(comedi_device *dev) { - if(!dev->attached) - return 0; - - /* this is not correct for the kmod case? */ - module_put(dev->driver->module); - - dev->attached=0; - + dev->attached = 0; if(dev->driver){ dev->driver->detach(dev); }else{ printk("BUG: dev->driver=NULL in comedi_device_detach()\n"); } - + module_put(dev->driver->module); cleanup_device(dev); return 0; } +int comedi_device_detach(comedi_device *dev) +{ + if(!dev->attached) + return 0; + return __comedi_device_detach(dev); +} + int comedi_device_attach(comedi_device *dev,comedi_devconfig *it) { comedi_driver *driv; @@ -154,13 +153,10 @@ int comedi_device_attach(comedi_device *dev,comedi_devconfig *it) dev->driver=driv; ret=driv->attach(dev,it); if(ret<0){ - driv->detach(dev); - cleanup_device(dev); - module_put(driv->module); + __comedi_device_detach(dev); return ret; } goto attached; - module_put( driv->module ); } // recognize has failed if we get here @@ -181,9 +177,7 @@ attached: ret = postconfig(dev); if(ret < 0) { - driv->detach(dev); - cleanup_device(dev); - module_put(driv->module); + __comedi_device_detach(dev); return ret; }