• Home
  • Raw
  • Download

Lines Matching refs:cpd

96 usb_loc_fill(struct usb_fs_privdata* pd, struct usb_cdev_privdata *cpd)  in usb_loc_fill()  argument
98 cpd->bus_index = pd->bus_index; in usb_loc_fill()
99 cpd->dev_index = pd->dev_index; in usb_loc_fill()
100 cpd->ep_addr = pd->ep_addr; in usb_loc_fill()
101 cpd->fifo_index = pd->fifo_index; in usb_loc_fill()
116 usb_ref_device(struct usb_cdev_privdata *cpd, in usb_ref_device() argument
122 DPRINTFN(2, "cpd=%p need uref=%d\n", cpd, need_uref); in usb_ref_device()
128 cpd->bus = devclass_get_softc(usb_devclass_ptr, cpd->bus_index); in usb_ref_device()
129 if (cpd->bus == NULL) { in usb_ref_device()
130 DPRINTFN(2, "no bus at %u\n", cpd->bus_index); in usb_ref_device()
133 cpd->udev = cpd->bus->devices[cpd->dev_index]; in usb_ref_device()
134 if (cpd->udev == NULL) { in usb_ref_device()
135 DPRINTFN(2, "no device at %u\n", cpd->dev_index); in usb_ref_device()
139 if (cpd->udev->state == USB_STATE_DETACHED && in usb_ref_device()
147 if (cpd->udev->refcount == USB_DEV_REF_MAX) { in usb_ref_device()
151 cpd->udev->refcount++; in usb_ref_device()
159 crd->do_unlock = usbd_enum_lock(cpd->udev); in usb_ref_device()
176 if (cpd->fflags == 0) { in usb_ref_device()
180 if ((unsigned int)cpd->fflags & FWRITE) { in usb_ref_device()
181 ppf = cpd->udev->fifo; in usb_ref_device()
182 f = ppf[cpd->fifo_index + USB_FIFO_TX]; in usb_ref_device()
187 if (f->curr_cpd != cpd) in usb_ref_device()
197 if ((unsigned int)cpd->fflags & FREAD) { in usb_ref_device()
198 ppf = cpd->udev->fifo; in usb_ref_device()
199 f = ppf[cpd->fifo_index + USB_FIFO_RX]; in usb_ref_device()
204 if (f->curr_cpd != cpd) in usb_ref_device()
229 usbd_enum_unlock(cpd->udev); in usb_ref_device()
232 if (cpd->udev && --(cpd->udev->refcount) == 0) in usb_ref_device()
233 cv_broadcast(&cpd->udev->ref_cv); in usb_ref_device()
255 usb_usb_ref_device(struct usb_cdev_privdata *cpd, in usb_usb_ref_device() argument
268 usb_unref_device(cpd, crd); in usb_usb_ref_device()
270 return (usb_ref_device(cpd, crd, 1 /* need uref */)); in usb_usb_ref_device()
280 usb_unref_device(struct usb_cdev_privdata *cpd, in usb_unref_device() argument
284 DPRINTFN(2, "cpd=%p is_uref=%d\n", cpd, crd->is_uref); in usb_unref_device()
287 usbd_enum_unlock(cpd->udev); in usb_unref_device()
304 if (--(cpd->udev->refcount) == 0) in usb_unref_device()
305 cv_broadcast(&cpd->udev->ref_cv); in usb_unref_device()
330 usb_fifo_create(struct usb_cdev_privdata *cpd, in usb_fifo_create() argument
333 struct usb_device *udev = cpd->udev; in usb_fifo_create()
341 int e = cpd->ep_addr; in usb_fifo_create()
343 is_tx = ((unsigned int)cpd->fflags & FWRITE) ? 1 : 0; in usb_fifo_create()
344 is_rx = ((unsigned int)cpd->fflags & FREAD) ? 1 : 0; in usb_fifo_create()
352 f = udev->fifo[cpd->fifo_index + USB_FIFO_TX]; in usb_fifo_create()
358 f = udev->fifo[cpd->fifo_index + USB_FIFO_RX]; in usb_fifo_create()
495 cpd->fifo_index = n; in usb_fifo_create()
610 usb_fifo_open(struct usb_cdev_privdata *cpd, in usb_fifo_open() argument
667 f->curr_cpd = cpd; in usb_fifo_open()
790 struct usb_cdev_privdata *cpd = NULL; in usb_open() local
804 cpd = bsd_malloc(sizeof(*cpd), M_USBDEV, M_WAITOK | M_ZERO); in usb_open()
805 if (cpd == NULL) { in usb_open()
809 usb_loc_fill(pd, cpd); in usb_open()
810 err = usb_ref_device(cpd, &refs, 1); in usb_open()
813 bsd_free(cpd, M_USBDEV); in usb_open()
816 cpd->fflags = fflags; /* access mode for open lifetime */ in usb_open()
819 err = usb_fifo_create(cpd, &refs); in usb_open()
823 usb_unref_device(cpd, &refs); in usb_open()
824 bsd_free(cpd, M_USBDEV); in usb_open()
828 err = usb_fifo_open(cpd, refs.rxfifo, fflags); in usb_open()
831 usb_unref_device(cpd, &refs); in usb_open()
832 bsd_free(cpd, M_USBDEV); in usb_open()
837 err = usb_fifo_open(cpd, refs.txfifo, fflags); in usb_open()
843 usb_unref_device(cpd, &refs); in usb_open()
844 bsd_free(cpd, M_USBDEV); in usb_open()
849 usb_unref_device(cpd, &refs); in usb_open()
850 filep->f_priv = cpd; in usb_open()
862 struct usb_cdev_privdata *cpd = (struct usb_cdev_privdata *)filep->f_priv; in usb_close() local
865 DPRINTFN(2, "cpd=%p\n", cpd); in usb_close()
867 err = usb_ref_device(cpd, &refs, in usb_close()
874 if ((unsigned int)cpd->fflags & FREAD) { in usb_close()
875 usb_fifo_close(refs.rxfifo, cpd->fflags); in usb_close()
877 if ((unsigned int)cpd->fflags & FWRITE) { in usb_close()
878 usb_fifo_close(refs.txfifo, cpd->fflags); in usb_close()
880 usb_unref_device(cpd, &refs); in usb_close()
882 bsd_free(cpd, M_USBDEV); in usb_close()
967 struct usb_cdev_privdata *cpd = (struct usb_cdev_privdata *)filep->f_priv; in usb_ioctl() local
980 err = usb_ref_device(cpd, &refs, 0 /* no uref */ ); in usb_ioctl()
984 fflags = cpd->fflags; in usb_ioctl()
1008 if (usb_usb_ref_device(cpd, &refs)) { in usb_ioctl()
1027 usb_unref_device(cpd, &refs); in usb_ioctl()
1031 while (usb_ref_device(cpd, &refs, 1 /* need uref */)) { in usb_ioctl()
1032 if (usb_ref_device(cpd, &refs, 0)) { in usb_ioctl()
1036 usb_unref_device(cpd, &refs); in usb_ioctl()
1042 usb_unref_device(cpd, &refs); in usb_ioctl()
1051 struct usb_cdev_privdata *cpd = (struct usb_cdev_privdata *)filep->f_priv; in usb_poll() local
1057 if (usb_ref_device(cpd, &refs, 0) != 0) in usb_poll()
1061 fflags = cpd->fflags; in usb_poll()
1148 usb_unref_device(cpd, &refs); in usb_poll()
1157 struct usb_cdev_privdata *cpd = (struct usb_cdev_privdata *)filep->f_priv; in usb_read() local
1164 err = usb_ref_device(cpd, &refs, 0 /* no uref */ ); in usb_read()
1171 usb_unref_device(cpd, &refs); in usb_read()
1258 usb_unref_device(cpd, &refs); in usb_read()
1267 struct usb_cdev_privdata *cpd = (struct usb_cdev_privdata *)filep->f_priv; in usb_write() local
1277 err = usb_ref_device(cpd, &refs, 0 /* no uref */ ); in usb_write()
1284 usb_unref_device(cpd, &refs); in usb_write()
1382 usb_unref_device(cpd, &refs); in usb_write()