unsigned int i = dev->minor;
        bool cleared = false;
 
+       lockdep_assert_held(&dev->mutex);
        mutex_lock(&comedi_board_minor_table_lock);
        if (dev == comedi_board_minor_table[i]) {
                comedi_board_minor_table[i] = NULL;
 {
        struct comedi_subdevice *s;
 
+       lockdep_assert_held(&dev->mutex);
        if (minor >= COMEDI_NUM_BOARD_MINORS) {
                s = comedi_subdevice_from_minor(dev, minor);
                if (!s || (s->subdev_flags & SDF_CMD_READ))
 {
        struct comedi_subdevice *s;
 
+       lockdep_assert_held(&dev->mutex);
        if (minor >= COMEDI_NUM_BOARD_MINORS) {
                s = comedi_subdevice_from_minor(dev, minor);
                if (!s || (s->subdev_flags & SDF_CMD_WRITE))
        struct comedi_async *async = s->async;
        int retval;
 
+       lockdep_assert_held(&dev->mutex);
+
        if (new_size > async->max_bufsize)
                return -EPERM;
 
 {
        struct comedi_async *async = s->async;
 
+       lockdep_assert_held(&dev->mutex);
        comedi_update_subdevice_runflags(s, COMEDI_SRF_RUNNING, 0);
        if (async) {
                comedi_buf_reset(s);
 {
        int ret = 0;
 
+       lockdep_assert_held(&dev->mutex);
        if (comedi_is_subdevice_running(s) && s->cancel)
                ret = s->cancel(dev, s);
 
        struct comedi_subdevice *s;
        int i;
 
+       lockdep_assert_held(&dev->mutex);
        if (!dev->attached)
                return;
 
        struct comedi_subdevice *s;
        int i;
 
+       lockdep_assert_held(&dev->mutex);
        if (!dev->attached)
                return 0;
 
 {
        struct comedi_devconfig it;
 
+       lockdep_assert_held(&dev->mutex);
        if (!capable(CAP_SYS_ADMIN))
                return -EPERM;
 
        struct comedi_subdevice *s;
        int retval = 0;
 
+       lockdep_assert_held(&dev->mutex);
        if (copy_from_user(&bc, arg, sizeof(bc)))
                return -EFAULT;
 
        struct comedi_subdevice *s;
        struct comedi_devinfo devinfo;
 
+       lockdep_assert_held(&dev->mutex);
        memset(&devinfo, 0, sizeof(devinfo));
 
        /* fill devinfo structure */
        struct comedi_subdinfo *tmp, *us;
        struct comedi_subdevice *s;
 
+       lockdep_assert_held(&dev->mutex);
        tmp = kcalloc(dev->n_subdevices, sizeof(*tmp), GFP_KERNEL);
        if (!tmp)
                return -ENOMEM;
        struct comedi_subdevice *s;
        struct comedi_chaninfo it;
 
+       lockdep_assert_held(&dev->mutex);
        if (copy_from_user(&it, arg, sizeof(it)))
                return -EFAULT;
 
        int retval = 0;
        bool become_nonbusy = false;
 
+       lockdep_assert_held(&dev->mutex);
        if (copy_from_user(&bi, arg, sizeof(bi)))
                return -EFAULT;
 
  */
 static int get_valid_routes(struct comedi_device *dev, unsigned int *data)
 {
+       lockdep_assert_held(&dev->mutex);
        data[1] = dev->get_valid_routes(dev, data[1], data + 2);
        return 0;
 }
        int ret = 0;
        int i;
 
+       lockdep_assert_held(&dev->mutex);
        if (insn->insn & INSN_MASK_SPECIAL) {
                /* a non-subdevice instruction */
 
        int i = 0;
        int ret = 0;
 
+       lockdep_assert_held(&dev->mutex);
        if (copy_from_user(&insnlist, arg, sizeof(insnlist)))
                return -EFAULT;
 
        unsigned int n_data = MIN_SAMPLES;
        int ret = 0;
 
+       lockdep_assert_held(&dev->mutex);
        if (copy_from_user(&insn, arg, sizeof(insn)))
                return -EFAULT;
 
 {
        struct comedi_subdevice *s;
 
+       lockdep_assert_held(&dev->mutex);
        if (copy_from_user(cmd, arg, sizeof(*cmd))) {
                dev_dbg(dev->class_dev, "bad cmd address\n");
                return -EFAULT;
        unsigned int *chanlist;
        int ret;
 
+       lockdep_assert_held(&dev->mutex);
        cmd->chanlist = NULL;
        chanlist = memdup_user(user_chanlist,
                               cmd->chanlist_len * sizeof(unsigned int));
        unsigned int __user *user_chanlist;
        int ret;
 
+       lockdep_assert_held(&dev->mutex);
+
        /* get the user's cmd and do some simple validation */
        ret = __comedi_get_user_cmd(dev, arg, &cmd);
        if (ret)
        unsigned int __user *user_chanlist;
        int ret;
 
+       lockdep_assert_held(&dev->mutex);
+
        /* get the user's cmd and do some simple validation */
        ret = __comedi_get_user_cmd(dev, arg, &cmd);
        if (ret)
        unsigned long flags;
        struct comedi_subdevice *s;
 
+       lockdep_assert_held(&dev->mutex);
        if (arg >= dev->n_subdevices)
                return -EINVAL;
        s = &dev->subdevices[arg];
 {
        struct comedi_subdevice *s;
 
+       lockdep_assert_held(&dev->mutex);
        if (arg >= dev->n_subdevices)
                return -EINVAL;
        s = &dev->subdevices[arg];
 {
        struct comedi_subdevice *s;
 
+       lockdep_assert_held(&dev->mutex);
        if (arg >= dev->n_subdevices)
                return -EINVAL;
        s = &dev->subdevices[arg];
 {
        struct comedi_subdevice *s;
 
+       lockdep_assert_held(&dev->mutex);
        if (arg >= dev->n_subdevices)
                return -EINVAL;
        s = &dev->subdevices[arg];
        struct comedi_file *cfp = file->private_data;
        struct comedi_subdevice *s_old, *s_new;
 
+       lockdep_assert_held(&dev->mutex);
        if (arg >= dev->n_subdevices)
                return -EINVAL;
 
        struct comedi_file *cfp = file->private_data;
        struct comedi_subdevice *s_old, *s_new;
 
+       lockdep_assert_held(&dev->mutex);
        if (arg >= dev->n_subdevices)
                return -EINVAL;
 
                        goto out_cleanup_board_minors;
                }
                /* comedi_alloc_board_minor() locked the mutex */
+               lockdep_assert_held(&dev->mutex);
                mutex_unlock(&dev->mutex);
        }