Lines Matching refs:ps
50 struct dev_state *ps; member
80 struct dev_state *ps = (struct dev_state *)file->private_data; in usbdev_read() local
87 down_read(&ps->devsem); in usbdev_read()
88 if (!ps->dev) { in usbdev_read()
100 if (copy_to_user(buf, ((char *)&ps->dev->descriptor) + pos, len)) { in usbdev_read()
112 for (i = 0; nbytes && i < ps->dev->descriptor.bNumConfigurations; i++) { in usbdev_read()
114 (struct usb_config_descriptor *)ps->dev->rawdescriptors[i]; in usbdev_read()
123 ps->dev->rawdescriptors[i] + (pos - last), len)) { in usbdev_read()
139 up_read(&ps->devsem); in usbdev_read()
195 struct dev_state *ps = as->ps; in async_newpending() local
198 spin_lock_irqsave(&ps->lock, flags); in async_newpending()
199 list_add_tail(&as->asynclist, &ps->async_pending); in async_newpending()
200 spin_unlock_irqrestore(&ps->lock, flags); in async_newpending()
205 struct dev_state *ps = as->ps; in async_removepending() local
208 spin_lock_irqsave(&ps->lock, flags); in async_removepending()
210 spin_unlock_irqrestore(&ps->lock, flags); in async_removepending()
213 static inline struct async *async_getcompleted(struct dev_state *ps) in async_getcompleted() argument
218 spin_lock_irqsave(&ps->lock, flags); in async_getcompleted()
219 if (!list_empty(&ps->async_completed)) { in async_getcompleted()
220 as = list_entry(ps->async_completed.next, struct async, asynclist); in async_getcompleted()
223 spin_unlock_irqrestore(&ps->lock, flags); in async_getcompleted()
227 static inline struct async *async_getpending(struct dev_state *ps, void *userurb) in async_getpending() argument
232 spin_lock_irqsave(&ps->lock, flags); in async_getpending()
233 list_for_each_entry(as, &ps->async_pending, asynclist) in async_getpending()
236 spin_unlock_irqrestore(&ps->lock, flags); in async_getpending()
239 spin_unlock_irqrestore(&ps->lock, flags); in async_getpending()
246 struct dev_state *ps = as->ps; in async_completed() local
249 spin_lock(&ps->lock); in async_completed()
250 list_move_tail(&as->asynclist, &ps->async_completed); in async_completed()
251 spin_unlock(&ps->lock); in async_completed()
252 wake_up(&ps->wait); in async_completed()
262 static void destroy_async (struct dev_state *ps, struct list_head *list) in destroy_async() argument
267 spin_lock_irqsave(&ps->lock, flags); in destroy_async()
271 spin_unlock_irqrestore(&ps->lock, flags); in destroy_async()
274 spin_lock_irqsave(&ps->lock, flags); in destroy_async()
276 spin_unlock_irqrestore(&ps->lock, flags); in destroy_async()
277 while ((as = async_getcompleted(ps))) in destroy_async()
281 static void destroy_async_on_interface (struct dev_state *ps, unsigned int intf) in destroy_async_on_interface() argument
287 spin_lock_irqsave(&ps->lock, flags); in destroy_async_on_interface()
288 list_for_each_safe(p, q, &ps->async_pending) in destroy_async_on_interface()
291 spin_unlock_irqrestore(&ps->lock, flags); in destroy_async_on_interface()
292 destroy_async(ps, &hitlist); in destroy_async_on_interface()
295 static inline void destroy_all_async(struct dev_state *ps) in destroy_all_async() argument
297 destroy_async(ps, &ps->async_pending); in destroy_all_async()
314 struct dev_state *ps = (struct dev_state *)context; in driver_disconnect() local
316 if (!ps) in driver_disconnect()
320 down_write (&ps->devsem); in driver_disconnect()
323 ps->dev = 0; in driver_disconnect()
324 ps->ifclaimed = 0; in driver_disconnect()
327 destroy_all_async (ps); in driver_disconnect()
329 up_write (&ps->devsem); in driver_disconnect()
338 static int claimintf(struct dev_state *ps, unsigned int intf) in claimintf() argument
340 struct usb_device *dev = ps->dev; in claimintf()
344 if (intf >= 8*sizeof(ps->ifclaimed) || !dev || intf >= dev->actconfig->bNumInterfaces) in claimintf()
347 if (test_bit(intf, &ps->ifclaimed)) in claimintf()
353 usb_driver_claim_interface(&usbdevfs_driver, iface, ps); in claimintf()
354 set_bit(intf, &ps->ifclaimed); in claimintf()
361 static int releaseintf(struct dev_state *ps, unsigned int intf) in releaseintf() argument
367 if (intf >= 8*sizeof(ps->ifclaimed)) in releaseintf()
371 dev = ps->dev; in releaseintf()
372 if (dev && test_and_clear_bit(intf, &ps->ifclaimed)) { in releaseintf()
381 static int checkintf(struct dev_state *ps, unsigned int intf) in checkintf() argument
383 if (intf >= 8*sizeof(ps->ifclaimed)) in checkintf()
385 if (test_bit(intf, &ps->ifclaimed)) in checkintf()
390 return claimintf(ps, intf); in checkintf()
459 static int check_ctrlrecip(struct dev_state *ps, unsigned int requesttype, unsigned int index) in check_ctrlrecip() argument
468 if ((ret = findintfep(ps->dev, index & 0xff)) < 0) in check_ctrlrecip()
470 if ((ret = checkintf(ps, ret))) in check_ctrlrecip()
475 if ((ret = findintfif(ps->dev, index & 0xff)) < 0) in check_ctrlrecip()
477 if ((ret = checkintf(ps, ret))) in check_ctrlrecip()
490 struct dev_state *ps; in usbdev_open() local
506 if (!(ps = kmalloc(sizeof(struct dev_state), GFP_KERNEL))) in usbdev_open()
509 ps->dev = dev; in usbdev_open()
510 ps->file = file; in usbdev_open()
511 spin_lock_init(&ps->lock); in usbdev_open()
512 INIT_LIST_HEAD(&ps->async_pending); in usbdev_open()
513 INIT_LIST_HEAD(&ps->async_completed); in usbdev_open()
514 init_waitqueue_head(&ps->wait); in usbdev_open()
515 init_rwsem(&ps->devsem); in usbdev_open()
516 ps->discsignr = 0; in usbdev_open()
517 ps->disctask = current; in usbdev_open()
518 ps->disccontext = NULL; in usbdev_open()
519 ps->ifclaimed = 0; in usbdev_open()
521 list_add_tail(&ps->list, &dev->filelist); in usbdev_open()
522 file->private_data = ps; in usbdev_open()
530 struct dev_state *ps = (struct dev_state *)file->private_data; in usbdev_release() local
534 list_del_init(&ps->list); in usbdev_release()
535 if (ps->dev) { in usbdev_release()
536 for (i = 0; ps->ifclaimed && i < 8*sizeof(ps->ifclaimed); i++) in usbdev_release()
537 if (test_bit(i, &ps->ifclaimed)) in usbdev_release()
538 releaseintf(ps, i); in usbdev_release()
541 destroy_all_async(ps); in usbdev_release()
542 kfree(ps); in usbdev_release()
546 static int proc_control(struct dev_state *ps, void *arg) in proc_control() argument
548 struct usb_device *dev = ps->dev; in proc_control()
556 if ((ret = check_ctrlrecip(ps, ctrl.requesttype, ctrl.index))) in proc_control()
594 static int proc_bulk(struct dev_state *ps, void *arg) in proc_bulk() argument
596 struct usb_device *dev = ps->dev; in proc_bulk()
605 if ((ret = findintfep(ps->dev, bulk.ep)) < 0) in proc_bulk()
607 if ((ret = checkintf(ps, ret))) in proc_bulk()
661 static int proc_resetep(struct dev_state *ps, void *arg) in proc_resetep() argument
668 if ((ret = findintfep(ps->dev, ep)) < 0) in proc_resetep()
670 if ((ret = checkintf(ps, ret))) in proc_resetep()
672 usb_settoggle(ps->dev, ep & 0xf, !(ep & USB_DIR_IN), 0); in proc_resetep()
676 static int proc_clearhalt(struct dev_state *ps, void *arg) in proc_clearhalt() argument
684 if ((ret = findintfep(ps->dev, ep)) < 0) in proc_clearhalt()
686 if ((ret = checkintf(ps, ret))) in proc_clearhalt()
689 pipe = usb_rcvbulkpipe(ps->dev, ep & 0x7f); in proc_clearhalt()
691 pipe = usb_sndbulkpipe(ps->dev, ep & 0x7f); in proc_clearhalt()
693 return usb_clear_halt(ps->dev, pipe); in proc_clearhalt()
697 static int proc_getdriver(struct dev_state *ps, void *arg) in proc_getdriver() argument
705 if ((ret = findintfif(ps->dev, gd.interface)) < 0) in proc_getdriver()
707 interface = usb_ifnum_to_if(ps->dev, gd.interface); in proc_getdriver()
718 static int proc_connectinfo(struct dev_state *ps, void *arg) in proc_connectinfo() argument
722 ci.devnum = ps->dev->devnum; in proc_connectinfo()
723 ci.slow = ps->dev->speed == USB_SPEED_LOW; in proc_connectinfo()
729 static int proc_resetdevice(struct dev_state *ps) in proc_resetdevice() argument
733 ret = usb_reset_device(ps->dev); in proc_resetdevice()
737 for (i = 0; i < ps->dev->actconfig->bNumInterfaces; i++) { in proc_resetdevice()
738 struct usb_interface *intf = &ps->dev->actconfig->interface[i]; in proc_resetdevice()
741 if (test_bit(i, &ps->ifclaimed)) in proc_resetdevice()
747 intf->driver->disconnect(ps->dev, intf->private_data); in proc_resetdevice()
748 id = usb_match_id(ps->dev,intf,intf->driver->id_table); in proc_resetdevice()
749 intf->driver->probe(ps->dev, i, id); in proc_resetdevice()
757 static int proc_setintf(struct dev_state *ps, void *arg) in proc_setintf() argument
765 if ((ret = findintfif(ps->dev, setintf.interface)) < 0) in proc_setintf()
767 interface = usb_ifnum_to_if(ps->dev, setintf.interface); in proc_setintf()
771 if ((ret = checkintf(ps, ret))) in proc_setintf()
774 if (usb_set_interface(ps->dev, setintf.interface, setintf.altsetting)) in proc_setintf()
779 static int proc_setconfig(struct dev_state *ps, void *arg) in proc_setconfig() argument
785 if (usb_set_configuration(ps->dev, u) < 0) in proc_setconfig()
790 static int proc_submiturb(struct dev_state *ps, void *arg) in proc_submiturb() argument
811 if ((intf = findintfep(ps->dev, uurb.endpoint)) < 0) in proc_submiturb()
813 if ((ret = checkintf(ps, intf))) in proc_submiturb()
819 if (!(ep_desc = usb_epnum_to_ep_desc(ps->dev, uurb.endpoint))) in proc_submiturb()
837 if ((ret = check_ctrlrecip(ps, dr->bRequestType, le16_to_cpup(&dr->wIndex)))) { in proc_submiturb()
911 as->urb.dev = ps->dev; in proc_submiturb()
912 …as->urb.pipe = (uurb.type << 30) | __create_pipe(ps->dev, uurb.endpoint & 0xf) | (uurb.endpoint & … in proc_submiturb()
927 as->ps = ps; in proc_submiturb()
952 static int proc_unlinkurb(struct dev_state *ps, void *arg) in proc_unlinkurb() argument
956 as = async_getpending(ps, arg); in proc_unlinkurb()
993 static int proc_reapurb(struct dev_state *ps, void *arg) in proc_reapurb() argument
1000 add_wait_queue(&ps->wait, &wait); in proc_reapurb()
1001 while (ps->dev) { in proc_reapurb()
1003 if ((as = async_getcompleted(ps))) in proc_reapurb()
1007 up_read(&ps->devsem); in proc_reapurb()
1009 down_read(&ps->devsem); in proc_reapurb()
1011 remove_wait_queue(&ps->wait, &wait); in proc_reapurb()
1028 static int proc_reapurbnonblock(struct dev_state *ps, void *arg) in proc_reapurbnonblock() argument
1034 if (!(as = async_getcompleted(ps))) in proc_reapurbnonblock()
1046 static int proc_disconnectsignal(struct dev_state *ps, void *arg) in proc_disconnectsignal() argument
1054 ps->discsignr = ds.signr; in proc_disconnectsignal()
1055 ps->disccontext = ds.context; in proc_disconnectsignal()
1059 static int proc_claiminterface(struct dev_state *ps, void *arg) in proc_claiminterface() argument
1066 if ((ret = findintfif(ps->dev, intf)) < 0) in proc_claiminterface()
1068 return claimintf(ps, ret); in proc_claiminterface()
1071 static int proc_releaseinterface(struct dev_state *ps, void *arg) in proc_releaseinterface() argument
1078 if ((ret = findintfif(ps->dev, intf)) < 0) in proc_releaseinterface()
1080 if ((ret = releaseintf(ps, intf)) < 0) in proc_releaseinterface()
1082 destroy_async_on_interface (ps, intf); in proc_releaseinterface()
1086 static int proc_ioctl (struct dev_state *ps, void *arg) in proc_ioctl() argument
1111 if (!ps->dev) in proc_ioctl()
1113 else if (!(ifp = usb_ifnum_to_if (ps->dev, ctrl.ifno))) in proc_ioctl()
1123 driver->name, ps->dev->devnum, ctrl.ifno); in proc_ioctl()
1124 driver->disconnect (ps->dev, ifp->private_data); in proc_ioctl()
1133 usb_find_interface_driver_for_ifnum (ps->dev, ctrl.ifno); in proc_ioctl()
1143 retval = driver->ioctl (ps->dev, ctrl.ioctl_code, buf); in proc_ioctl()
1161 static int usbdev_ioctl_exclusive(struct dev_state *ps, struct inode *inode, in usbdev_ioctl_exclusive() argument
1168 ret = proc_control(ps, (void *)arg); in usbdev_ioctl_exclusive()
1174 ret = proc_resetep(ps, (void *)arg); in usbdev_ioctl_exclusive()
1180 ret = proc_resetdevice(ps); in usbdev_ioctl_exclusive()
1184 ret = proc_clearhalt(ps, (void *)arg); in usbdev_ioctl_exclusive()
1190 ret = proc_setintf(ps, (void *)arg); in usbdev_ioctl_exclusive()
1194 ret = proc_setconfig(ps, (void *)arg); in usbdev_ioctl_exclusive()
1198 ret = proc_submiturb(ps, (void *)arg); in usbdev_ioctl_exclusive()
1204 ret = proc_unlinkurb(ps, (void *)arg); in usbdev_ioctl_exclusive()
1208 ret = proc_claiminterface(ps, (void *)arg); in usbdev_ioctl_exclusive()
1212 ret = proc_releaseinterface(ps, (void *)arg); in usbdev_ioctl_exclusive()
1216 ret = proc_ioctl(ps, (void *) arg); in usbdev_ioctl_exclusive()
1228 struct dev_state *ps = file->private_data; in usbdev_ioctl() local
1233 down_read(&ps->devsem); in usbdev_ioctl()
1234 if (!ps->dev) { in usbdev_ioctl()
1235 up_read(&ps->devsem); in usbdev_ioctl()
1247 ret = proc_getdriver(ps, (void *)arg); in usbdev_ioctl()
1251 ret = proc_connectinfo(ps, (void *)arg); in usbdev_ioctl()
1255 ret = proc_reapurb(ps, (void *)arg); in usbdev_ioctl()
1259 ret = proc_reapurbnonblock(ps, (void *)arg); in usbdev_ioctl()
1263 ret = proc_disconnectsignal(ps, (void *)arg); in usbdev_ioctl()
1267 ret = proc_bulk(ps, (void *)arg); in usbdev_ioctl()
1284 if (usb_excl_lock(ps->dev, 3, 1) == 0) { in usbdev_ioctl()
1285 ret = usbdev_ioctl_exclusive(ps, inode, cmd, arg); in usbdev_ioctl()
1286 usb_excl_unlock(ps->dev, 3); in usbdev_ioctl()
1293 up_read(&ps->devsem); in usbdev_ioctl()
1302 struct dev_state *ps = (struct dev_state *)file->private_data; in usbdev_poll() local
1305 poll_wait(file, &ps->wait, wait); in usbdev_poll()
1306 if (file->f_mode & FMODE_WRITE && !list_empty(&ps->async_completed)) in usbdev_poll()
1308 if (!ps->dev) in usbdev_poll()