}
if (dev->attached && dev->use_count == 0 && dev->open) {
- dev->open(dev);
+ 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++;
* Comedi functions
*/
-static void dt9812_comedi_open(comedi_device * dev)
+static int dt9812_comedi_open(comedi_device * dev)
{
+ int result = -ENODEV;
+
down(&devpriv->slot->mutex);
if (devpriv->slot->usb) {
// We have an attached device, fill in current range info
}
break;
}
+ result = 0;
}
up(&devpriv->slot->mutex);
+ return result;
}
static int dt9812_di_rinsn(comedi_device * dev, comedi_subdevice * s,
return result;
}
-static void jr3_pci_open(comedi_device * dev)
+static int jr3_pci_open(comedi_device * dev)
{
int i;
jr3_pci_dev_private *devpriv = dev->private;
p->channel_no);
}
}
+ return 0;
}
int read_idm_word(const u8 * data, size_t size, int *pos, unsigned int *val)
}
}
-static void serial_2002_open(comedi_device * dev)
+static int serial_2002_open(comedi_device * dev)
{
+ int result;
char port[20];
sprintf(port, "/dev/ttyS%d", devpriv->port);
devpriv->tty = filp_open(port, 0, O_RDWR);
if (IS_ERR(devpriv->tty)) {
- printk("serial_2002: file open error = %ld\n",
- PTR_ERR(devpriv->tty));
+ result = (int)PTR_ERR(devpriv->tty);
+ printk("serial_2002: file open error = %d\n", result);
} else {
typedef struct {
short int kind;
}
}
}
+ result = 0;
}
+ return result;
}
static void serial_2002_close(comedi_device * dev)
struct fasync_struct *async_queue;
- void (*open) (comedi_device * dev);
+ int (*open) (comedi_device * dev);
void (*close) (comedi_device * dev);
};