summaryrefslogtreecommitdiffstats
path: root/drivers/staging/comedi/comedi_fops.c
diff options
context:
space:
mode:
authorIan Abbott2010-05-19 15:10:00 +0200
committerGreg Kroah-Hartman2010-06-17 22:28:56 +0200
commit3c17ba0743d75f9888d905ddf9f8551c7dd36493 (patch)
treec473b48f9b5bbf9010c4d4479cebcc7cc21b03eb /drivers/staging/comedi/comedi_fops.c
parentStaging: comedi: ni_tio: fixed brace coding style issues and a few errors (diff)
downloadkernel-qcow2-linux-3c17ba0743d75f9888d905ddf9f8551c7dd36493.tar.gz
kernel-qcow2-linux-3c17ba0743d75f9888d905ddf9f8551c7dd36493.tar.xz
kernel-qcow2-linux-3c17ba0743d75f9888d905ddf9f8551c7dd36493.zip
Staging: comedi: Allow 'open' driver method to fail
Some comedi drivers should return an error from their 'open' method when something goes wrong. Change the prototype of the 'open' method in 'struct comedi_device' to allow this, and change the drivers that use it. Propagate any error to the 'open' file operation. The corresponding 'close' method won't be called when the 'open' method fails, so drivers failing the 'open' need to clean up any mess they created. The dt9812 and serial2002 drivers can now return an error on 'open'. The jr3_pci driver also uses the 'open' method but doesn't fail it. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/comedi/comedi_fops.c')
-rw-r--r--drivers/staging/comedi/comedi_fops.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c
index aeb2c00875cd..14091313cebb 100644
--- a/drivers/staging/comedi/comedi_fops.c
+++ b/drivers/staging/comedi/comedi_fops.c
@@ -1845,8 +1845,15 @@ ok:
}
}
- if (dev->attached && dev->use_count == 0 && dev->open)
- dev->open(dev);
+ if (dev->attached && dev->use_count == 0 && dev->open) {
+ int rc = dev->open(dev);
+ if (rc < 0) {
+ module_put(dev->driver->module);
+ module_put(THIS_MODULE);
+ mutex_unlock(&dev->mutex);
+ return rc;
+ }
+ }
dev->use_count++;