| .. | .. |
|---|
| 159 | 159 | int i; |
|---|
| 160 | 160 | struct comedi_subdevice *s; |
|---|
| 161 | 161 | |
|---|
| 162 | + lockdep_assert_held(&dev->attach_lock); |
|---|
| 163 | + lockdep_assert_held(&dev->mutex); |
|---|
| 162 | 164 | if (dev->subdevices) { |
|---|
| 163 | 165 | for (i = 0; i < dev->n_subdevices; i++) { |
|---|
| 164 | 166 | s = &dev->subdevices[i]; |
|---|
| .. | .. |
|---|
| 196 | 198 | |
|---|
| 197 | 199 | void comedi_device_detach(struct comedi_device *dev) |
|---|
| 198 | 200 | { |
|---|
| 201 | + lockdep_assert_held(&dev->mutex); |
|---|
| 199 | 202 | comedi_device_cancel_all(dev); |
|---|
| 200 | 203 | down_write(&dev->attach_lock); |
|---|
| 201 | 204 | dev->attached = false; |
|---|
| .. | .. |
|---|
| 209 | 212 | static int poll_invalid(struct comedi_device *dev, struct comedi_subdevice *s) |
|---|
| 210 | 213 | { |
|---|
| 211 | 214 | return -EINVAL; |
|---|
| 215 | +} |
|---|
| 216 | + |
|---|
| 217 | +static int insn_device_inval(struct comedi_device *dev, |
|---|
| 218 | + struct comedi_insn *insn, unsigned int *data) |
|---|
| 219 | +{ |
|---|
| 220 | + return -EINVAL; |
|---|
| 221 | +} |
|---|
| 222 | + |
|---|
| 223 | +static unsigned int get_zero_valid_routes(struct comedi_device *dev, |
|---|
| 224 | + unsigned int n_pairs, |
|---|
| 225 | + unsigned int *pair_data) |
|---|
| 226 | +{ |
|---|
| 227 | + return 0; |
|---|
| 212 | 228 | } |
|---|
| 213 | 229 | |
|---|
| 214 | 230 | int insn_inval(struct comedi_device *dev, struct comedi_subdevice *s, |
|---|
| .. | .. |
|---|
| 630 | 646 | unsigned int buf_size; |
|---|
| 631 | 647 | int ret; |
|---|
| 632 | 648 | |
|---|
| 649 | + lockdep_assert_held(&dev->mutex); |
|---|
| 633 | 650 | if ((s->subdev_flags & (SDF_CMD_READ | SDF_CMD_WRITE)) == 0) { |
|---|
| 634 | 651 | dev_warn(dev->class_dev, |
|---|
| 635 | 652 | "async subdevices must support SDF_CMD_READ or SDF_CMD_WRITE\n"); |
|---|
| .. | .. |
|---|
| 676 | 693 | struct comedi_subdevice *s; |
|---|
| 677 | 694 | int ret; |
|---|
| 678 | 695 | int i; |
|---|
| 696 | + |
|---|
| 697 | + lockdep_assert_held(&dev->mutex); |
|---|
| 698 | + if (!dev->insn_device_config) |
|---|
| 699 | + dev->insn_device_config = insn_device_inval; |
|---|
| 700 | + |
|---|
| 701 | + if (!dev->get_valid_routes) |
|---|
| 702 | + dev->get_valid_routes = get_zero_valid_routes; |
|---|
| 679 | 703 | |
|---|
| 680 | 704 | for (i = 0; i < dev->n_subdevices; i++) { |
|---|
| 681 | 705 | s = &dev->subdevices[i]; |
|---|
| .. | .. |
|---|
| 728 | 752 | { |
|---|
| 729 | 753 | int ret; |
|---|
| 730 | 754 | |
|---|
| 755 | + lockdep_assert_held(&dev->mutex); |
|---|
| 731 | 756 | ret = __comedi_device_postconfig(dev); |
|---|
| 732 | 757 | if (ret < 0) |
|---|
| 733 | 758 | return ret; |
|---|
| .. | .. |
|---|
| 927 | 952 | struct comedi_driver *driv; |
|---|
| 928 | 953 | int ret; |
|---|
| 929 | 954 | |
|---|
| 955 | + lockdep_assert_held(&dev->mutex); |
|---|
| 930 | 956 | if (dev->attached) |
|---|
| 931 | 957 | return -EBUSY; |
|---|
| 932 | 958 | |
|---|
| .. | .. |
|---|
| 1034 | 1060 | return PTR_ERR(dev); |
|---|
| 1035 | 1061 | } |
|---|
| 1036 | 1062 | /* Note: comedi_alloc_board_minor() locked dev->mutex. */ |
|---|
| 1063 | + lockdep_assert_held(&dev->mutex); |
|---|
| 1037 | 1064 | |
|---|
| 1038 | 1065 | dev->driver = driver; |
|---|
| 1039 | 1066 | dev->board_name = dev->driver->driver_name; |
|---|
| 1040 | 1067 | ret = driver->auto_attach(dev, context); |
|---|
| 1041 | 1068 | if (ret >= 0) |
|---|
| 1042 | 1069 | ret = comedi_device_postconfig(dev); |
|---|
| 1043 | | - mutex_unlock(&dev->mutex); |
|---|
| 1044 | 1070 | |
|---|
| 1045 | 1071 | if (ret < 0) { |
|---|
| 1046 | 1072 | dev_warn(hardware_device, |
|---|
| 1047 | 1073 | "driver '%s' failed to auto-configure device.\n", |
|---|
| 1048 | 1074 | driver->driver_name); |
|---|
| 1075 | + mutex_unlock(&dev->mutex); |
|---|
| 1049 | 1076 | comedi_release_hardware_device(hardware_device); |
|---|
| 1050 | 1077 | } else { |
|---|
| 1051 | 1078 | /* |
|---|
| .. | .. |
|---|
| 1055 | 1082 | dev_info(dev->class_dev, |
|---|
| 1056 | 1083 | "driver '%s' has successfully auto-configured '%s'.\n", |
|---|
| 1057 | 1084 | driver->driver_name, dev->board_name); |
|---|
| 1085 | + mutex_unlock(&dev->mutex); |
|---|
| 1058 | 1086 | } |
|---|
| 1059 | 1087 | return ret; |
|---|
| 1060 | 1088 | } |
|---|