403 if (copy_from_user(buf, buffer, count)) {
404 dev_err(&dev->dev, "%s: can't copy_from_user\n", __func__);
405 retval = -EFAULT;
406 goto exit;
407 }
408
409 usb_anchor_urb(urb, &vstdev->submitted);
410 retval = vstusb_fill_and_send_urb(urb, dev, pipe, buf, count, &done);
411 mutex_unlock(&vstdev->lock);
412 if (retval) {
413 usb_unanchor_urb(urb);
414 dev_err(&dev->dev, "%s: error %d filling and sending urb %d\n",
415 __func__, retval, pipe);
416 goto exit;
417 }
418
419 retval = vstusb_complete_urb(urb, &done, timeout, &cnt);
420 if (retval) {
421 dev_err(&dev->dev, "%s: error %d completing urb %d\n",
422 __func__, retval, pipe);
423 goto exit;
424 } else {
425 retval = cnt;
426 dev_dbg(&dev->dev, "%s: sent %d bytes to pipe %d\n",
427 __func__, cnt, pipe);
428 }
429
430exit:
431 usb_free_urb(urb);
432 kfree(buf);
433 return retval;
434}
435
436static long vstusb_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
437{
438 int retval = 0;
439 int cnt = -1;
440 void __user *data = (void __user *)arg;
441 struct vstusb_args usb_data;
442
443 struct vstusb_device *vstdev;