Lines Matching defs:cpd

169 usb_loc_fill(struct usb_fs_privdata* pd, struct usb_cdev_privdata *cpd)
171 cpd->bus_index = pd->bus_index;
172 cpd->dev_index = pd->dev_index;
173 cpd->ep_addr = pd->ep_addr;
174 cpd->fifo_index = pd->fifo_index;
189 usb_ref_device(struct usb_cdev_privdata *cpd,
195 DPRINTFN(2, "cpd=%p need uref=%d\n", cpd, need_uref);
201 cpd->bus = devclass_get_softc(usb_devclass_ptr, cpd->bus_index);
202 if (cpd->bus == NULL) {
203 DPRINTFN(2, "no bus at %u\n", cpd->bus_index);
206 cpd->udev = cpd->bus->devices[cpd->dev_index];
207 if (cpd->udev == NULL) {
208 DPRINTFN(2, "no device at %u\n", cpd->dev_index);
211 if (cpd->udev->state == USB_STATE_DETACHED &&
219 if (cpd->udev->refcount == USB_DEV_REF_MAX) {
223 cpd->udev->refcount++;
231 crd->do_unlock = usbd_enum_lock_sig(cpd->udev);
248 if (cpd->fflags == 0) {
252 if (cpd->fflags & FWRITE) {
253 ppf = cpd->udev->fifo;
254 f = ppf[cpd->fifo_index + USB_FIFO_TX];
259 if (f->curr_cpd != cpd)
268 if (cpd->fflags & FREAD) {
269 ppf = cpd->udev->fifo;
270 f = ppf[cpd->fifo_index + USB_FIFO_RX];
275 if (f->curr_cpd != cpd)
299 usbd_enum_unlock(cpd->udev);
302 if (--(cpd->udev->refcount) == 0)
303 cv_broadcast(&cpd->udev->ref_cv);
325 usb_usb_ref_device(struct usb_cdev_privdata *cpd,
338 usb_unref_device(cpd, crd);
340 return (usb_ref_device(cpd, crd, 1 /* need uref */));
350 usb_unref_device(struct usb_cdev_privdata *cpd,
354 DPRINTFN(2, "cpd=%p is_uref=%d\n", cpd, crd->is_uref);
357 usbd_enum_unlock(cpd->udev);
374 if (--(cpd->udev->refcount) == 0)
375 cv_broadcast(&cpd->udev->ref_cv);
399 usb_fifo_create(struct usb_cdev_privdata *cpd,
402 struct usb_device *udev = cpd->udev;
410 int e = cpd->ep_addr;
412 is_tx = (cpd->fflags & FWRITE) ? 1 : 0;
413 is_rx = (cpd->fflags & FREAD) ? 1 : 0;
421 f = udev->fifo[cpd->fifo_index + USB_FIFO_TX];
427 f = udev->fifo[cpd->fifo_index + USB_FIFO_RX];
562 cpd->fifo_index = n;
682 usb_fifo_open(struct usb_cdev_privdata *cpd,
739 f->curr_cpd = cpd;
874 struct usb_cdev_privdata *cpd;
886 cpd = malloc(sizeof(*cpd), M_USBDEV, M_WAITOK | M_ZERO);
888 usb_loc_fill(pd, cpd);
889 err = usb_ref_device(cpd, &refs, 1);
892 free(cpd, M_USBDEV);
895 cpd->fflags = fflags; /* access mode for open lifetime */
898 err = usb_fifo_create(cpd, &refs);
902 usb_unref_device(cpd, &refs);
903 free(cpd, M_USBDEV);
907 err = usb_fifo_open(cpd, refs.rxfifo, fflags);
910 usb_unref_device(cpd, &refs);
911 free(cpd, M_USBDEV);
916 err = usb_fifo_open(cpd, refs.txfifo, fflags);
922 usb_unref_device(cpd, &refs);
923 free(cpd, M_USBDEV);
927 usb_unref_device(cpd, &refs);
928 devfs_set_cdevpriv(cpd, usb_close);
940 struct usb_cdev_privdata *cpd = arg;
943 DPRINTFN(2, "cpd=%p\n", cpd);
945 err = usb_ref_device(cpd, &refs,
952 if (cpd->fflags & FREAD) {
953 usb_fifo_close(refs.rxfifo, cpd->fflags);
955 if (cpd->fflags & FWRITE) {
956 usb_fifo_close(refs.txfifo, cpd->fflags);
958 usb_unref_device(cpd, &refs);
960 free(cpd, M_USBDEV);
1057 struct usb_cdev_privdata* cpd;
1064 err = devfs_get_cdevpriv((void **)&cpd);
1073 err = usb_ref_device(cpd, &refs, 0 /* no uref */ );
1077 fflags = cpd->fflags;
1101 if (usb_usb_ref_device(cpd, &refs)) {
1119 usb_unref_device(cpd, &refs);
1123 while (usb_ref_device(cpd, &refs, 1 /* need uref */)) {
1124 if (usb_ref_device(cpd, &refs, 0)) {
1128 usb_unref_device(cpd, &refs);
1134 usb_unref_device(cpd, &refs);
1148 struct usb_cdev_privdata* cpd;
1158 cpd = f->curr_cpd;
1159 if (cpd == NULL) {
1189 struct usb_cdev_privdata* cpd;
1199 cpd = f->curr_cpd;
1200 if (cpd == NULL) {
1248 struct usb_cdev_privdata* cpd;
1255 if (devfs_get_cdevpriv((void **)&cpd) != 0 ||
1256 usb_ref_device(cpd, &refs, 0) != 0)
1259 fflags = cpd->fflags;
1289 usb_unref_device(cpd, &refs);
1298 struct usb_cdev_privdata* cpd;
1303 if (devfs_get_cdevpriv((void **)&cpd) != 0 ||
1304 usb_ref_device(cpd, &refs, 0) != 0)
1308 fflags = cpd->fflags;
1393 usb_unref_device(cpd, &refs);
1401 struct usb_cdev_privdata* cpd;
1408 err = devfs_get_cdevpriv((void **)&cpd);
1412 err = usb_ref_device(cpd, &refs, 0 /* no uref */ );
1419 usb_unref_device(cpd, &refs);
1506 usb_unref_device(cpd, &refs);
1515 struct usb_cdev_privdata* cpd;
1525 err = devfs_get_cdevpriv((void **)&cpd);
1529 err = usb_ref_device(cpd, &refs, 0 /* no uref */ );
1536 usb_unref_device(cpd, &refs);
1641 usb_unref_device(cpd, &refs);