diff options
| author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-03-23 16:49:37 -0400 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-03-23 16:49:37 -0400 |
| commit | cd0e075784f4bce97b4ed47d4b354f045e895546 (patch) | |
| tree | 2354d4c2f5185c59dc21c537841b55c694cc53ec /drivers/usb/gadget/function | |
| parent | 32fc9eb5b2dcebefb7fb4c8288c739c320362524 (diff) | |
| parent | bc465aa9d045feb0e13b4a8f32cc33c1943f62d6 (diff) | |
Merge 4.0-rc5 into usb-next
We want the USB fixes in here as well to resolve merge conflicts.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/gadget/function')
| -rw-r--r-- | drivers/usb/gadget/function/f_fs.c | 204 | ||||
| -rw-r--r-- | drivers/usb/gadget/function/f_loopback.c | 3 | ||||
| -rw-r--r-- | drivers/usb/gadget/function/f_sourcesink.c | 511 | ||||
| -rw-r--r-- | drivers/usb/gadget/function/g_zero.h | 13 |
4 files changed, 101 insertions, 630 deletions
diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c index af98b096af2f..175c9956cbe3 100644 --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c | |||
| @@ -144,10 +144,9 @@ struct ffs_io_data { | |||
| 144 | bool read; | 144 | bool read; |
| 145 | 145 | ||
| 146 | struct kiocb *kiocb; | 146 | struct kiocb *kiocb; |
| 147 | const struct iovec *iovec; | 147 | struct iov_iter data; |
| 148 | unsigned long nr_segs; | 148 | const void *to_free; |
| 149 | char __user *buf; | 149 | char *buf; |
| 150 | size_t len; | ||
| 151 | 150 | ||
| 152 | struct mm_struct *mm; | 151 | struct mm_struct *mm; |
| 153 | struct work_struct work; | 152 | struct work_struct work; |
| @@ -649,29 +648,10 @@ static void ffs_user_copy_worker(struct work_struct *work) | |||
| 649 | io_data->req->actual; | 648 | io_data->req->actual; |
| 650 | 649 | ||
| 651 | if (io_data->read && ret > 0) { | 650 | if (io_data->read && ret > 0) { |
| 652 | int i; | ||
| 653 | size_t pos = 0; | ||
| 654 | |||
| 655 | /* | ||
| 656 | * Since req->length may be bigger than io_data->len (after | ||
| 657 | * being rounded up to maxpacketsize), we may end up with more | ||
| 658 | * data then user space has space for. | ||
| 659 | */ | ||
| 660 | ret = min_t(int, ret, io_data->len); | ||
| 661 | |||
| 662 | use_mm(io_data->mm); | 651 | use_mm(io_data->mm); |
| 663 | for (i = 0; i < io_data->nr_segs; i++) { | 652 | ret = copy_to_iter(io_data->buf, ret, &io_data->data); |
| 664 | size_t len = min_t(size_t, ret - pos, | 653 | if (iov_iter_count(&io_data->data)) |
| 665 | io_data->iovec[i].iov_len); | 654 | ret = -EFAULT; |
| 666 | if (!len) | ||
| 667 | break; | ||
| 668 | if (unlikely(copy_to_user(io_data->iovec[i].iov_base, | ||
| 669 | &io_data->buf[pos], len))) { | ||
| 670 | ret = -EFAULT; | ||
| 671 | break; | ||
| 672 | } | ||
| 673 | pos += len; | ||
| 674 | } | ||
| 675 | unuse_mm(io_data->mm); | 655 | unuse_mm(io_data->mm); |
| 676 | } | 656 | } |
| 677 | 657 | ||
| @@ -684,7 +664,7 @@ static void ffs_user_copy_worker(struct work_struct *work) | |||
| 684 | 664 | ||
| 685 | io_data->kiocb->private = NULL; | 665 | io_data->kiocb->private = NULL; |
| 686 | if (io_data->read) | 666 | if (io_data->read) |
| 687 | kfree(io_data->iovec); | 667 | kfree(io_data->to_free); |
| 688 | kfree(io_data->buf); | 668 | kfree(io_data->buf); |
| 689 | kfree(io_data); | 669 | kfree(io_data); |
| 690 | } | 670 | } |
| @@ -743,6 +723,7 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data) | |||
| 743 | * before the waiting completes, so do not assign to 'gadget' earlier | 723 | * before the waiting completes, so do not assign to 'gadget' earlier |
| 744 | */ | 724 | */ |
| 745 | struct usb_gadget *gadget = epfile->ffs->gadget; | 725 | struct usb_gadget *gadget = epfile->ffs->gadget; |
| 726 | size_t copied; | ||
| 746 | 727 | ||
| 747 | spin_lock_irq(&epfile->ffs->eps_lock); | 728 | spin_lock_irq(&epfile->ffs->eps_lock); |
| 748 | /* In the meantime, endpoint got disabled or changed. */ | 729 | /* In the meantime, endpoint got disabled or changed. */ |
| @@ -750,34 +731,21 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data) | |||
| 750 | spin_unlock_irq(&epfile->ffs->eps_lock); | 731 | spin_unlock_irq(&epfile->ffs->eps_lock); |
| 751 | return -ESHUTDOWN; | 732 | return -ESHUTDOWN; |
| 752 | } | 733 | } |
| 734 | data_len = iov_iter_count(&io_data->data); | ||
| 753 | /* | 735 | /* |
| 754 | * Controller may require buffer size to be aligned to | 736 | * Controller may require buffer size to be aligned to |
| 755 | * maxpacketsize of an out endpoint. | 737 | * maxpacketsize of an out endpoint. |
| 756 | */ | 738 | */ |
| 757 | data_len = io_data->read ? | 739 | if (io_data->read) |
| 758 | usb_ep_align_maybe(gadget, ep->ep, io_data->len) : | 740 | data_len = usb_ep_align_maybe(gadget, ep->ep, data_len); |
| 759 | io_data->len; | ||
| 760 | spin_unlock_irq(&epfile->ffs->eps_lock); | 741 | spin_unlock_irq(&epfile->ffs->eps_lock); |
| 761 | 742 | ||
| 762 | data = kmalloc(data_len, GFP_KERNEL); | 743 | data = kmalloc(data_len, GFP_KERNEL); |
| 763 | if (unlikely(!data)) | 744 | if (unlikely(!data)) |
| 764 | return -ENOMEM; | 745 | return -ENOMEM; |
| 765 | if (io_data->aio && !io_data->read) { | 746 | if (!io_data->read) { |
| 766 | int i; | 747 | copied = copy_from_iter(data, data_len, &io_data->data); |
| 767 | size_t pos = 0; | 748 | if (copied != data_len) { |
| 768 | for (i = 0; i < io_data->nr_segs; i++) { | ||
| 769 | if (unlikely(copy_from_user(&data[pos], | ||
| 770 | io_data->iovec[i].iov_base, | ||
| 771 | io_data->iovec[i].iov_len))) { | ||
| 772 | ret = -EFAULT; | ||
| 773 | goto error; | ||
| 774 | } | ||
| 775 | pos += io_data->iovec[i].iov_len; | ||
| 776 | } | ||
| 777 | } else { | ||
| 778 | if (!io_data->read && | ||
| 779 | unlikely(__copy_from_user(data, io_data->buf, | ||
| 780 | io_data->len))) { | ||
| 781 | ret = -EFAULT; | 749 | ret = -EFAULT; |
| 782 | goto error; | 750 | goto error; |
| 783 | } | 751 | } |
| @@ -876,10 +844,8 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data) | |||
| 876 | */ | 844 | */ |
| 877 | ret = ep->status; | 845 | ret = ep->status; |
| 878 | if (io_data->read && ret > 0) { | 846 | if (io_data->read && ret > 0) { |
| 879 | ret = min_t(size_t, ret, io_data->len); | 847 | ret = copy_to_iter(data, ret, &io_data->data); |
| 880 | 848 | if (unlikely(iov_iter_count(&io_data->data))) | |
| 881 | if (unlikely(copy_to_user(io_data->buf, | ||
| 882 | data, ret))) | ||
| 883 | ret = -EFAULT; | 849 | ret = -EFAULT; |
| 884 | } | 850 | } |
| 885 | } | 851 | } |
| @@ -898,37 +864,6 @@ error: | |||
| 898 | return ret; | 864 | return ret; |
| 899 | } | 865 | } |
| 900 | 866 | ||
| 901 | static ssize_t | ||
| 902 | ffs_epfile_write(struct file *file, const char __user *buf, size_t len, | ||
| 903 | loff_t *ptr) | ||
| 904 | { | ||
| 905 | struct ffs_io_data io_data; | ||
| 906 | |||
| 907 | ENTER(); | ||
| 908 | |||
| 909 | io_data.aio = false; | ||
| 910 | io_data.read = false; | ||
| 911 | io_data.buf = (char * __user)buf; | ||
| 912 | io_data.len = len; | ||
| 913 | |||
| 914 | return ffs_epfile_io(file, &io_data); | ||
| 915 | } | ||
| 916 | |||
| 917 | static ssize_t | ||
| 918 | ffs_epfile_read(struct file *file, char __user *buf, size_t len, loff_t *ptr) | ||
| 919 | { | ||
| 920 | struct ffs_io_data io_data; | ||
| 921 | |||
| 922 | ENTER(); | ||
| 923 | |||
| 924 | io_data.aio = false; | ||
| 925 | io_data.read = true; | ||
| 926 | io_data.buf = buf; | ||
| 927 | io_data.len = len; | ||
| 928 | |||
| 929 | return ffs_epfile_io(file, &io_data); | ||
| 930 | } | ||
| 931 | |||
| 932 | static int | 867 | static int |
| 933 | ffs_epfile_open(struct inode *inode, struct file *file) | 868 | ffs_epfile_open(struct inode *inode, struct file *file) |
| 934 | { | 869 | { |
| @@ -965,67 +900,86 @@ static int ffs_aio_cancel(struct kiocb *kiocb) | |||
| 965 | return value; | 900 | return value; |
| 966 | } | 901 | } |
| 967 | 902 | ||
| 968 | static ssize_t ffs_epfile_aio_write(struct kiocb *kiocb, | 903 | static ssize_t ffs_epfile_write_iter(struct kiocb *kiocb, struct iov_iter *from) |
| 969 | const struct iovec *iovec, | ||
| 970 | unsigned long nr_segs, loff_t loff) | ||
| 971 | { | 904 | { |
| 972 | struct ffs_io_data *io_data; | 905 | struct ffs_io_data io_data, *p = &io_data; |
| 906 | ssize_t res; | ||
| 973 | 907 | ||
| 974 | ENTER(); | 908 | ENTER(); |
| 975 | 909 | ||
| 976 | io_data = kmalloc(sizeof(*io_data), GFP_KERNEL); | 910 | if (!is_sync_kiocb(kiocb)) { |
| 977 | if (unlikely(!io_data)) | 911 | p = kmalloc(sizeof(io_data), GFP_KERNEL); |
| 978 | return -ENOMEM; | 912 | if (unlikely(!p)) |
| 913 | return -ENOMEM; | ||
| 914 | p->aio = true; | ||
| 915 | } else { | ||
| 916 | p->aio = false; | ||
| 917 | } | ||
| 979 | 918 | ||
| 980 | io_data->aio = true; | 919 | p->read = false; |
| 981 | io_data->read = false; | 920 | p->kiocb = kiocb; |
| 982 | io_data->kiocb = kiocb; | 921 | p->data = *from; |
| 983 | io_data->iovec = iovec; | 922 | p->mm = current->mm; |
| 984 | io_data->nr_segs = nr_segs; | ||
| 985 | io_data->len = kiocb->ki_nbytes; | ||
| 986 | io_data->mm = current->mm; | ||
| 987 | 923 | ||
| 988 | kiocb->private = io_data; | 924 | kiocb->private = p; |
| 989 | 925 | ||
| 990 | kiocb_set_cancel_fn(kiocb, ffs_aio_cancel); | 926 | kiocb_set_cancel_fn(kiocb, ffs_aio_cancel); |
| 991 | 927 | ||
| 992 | return ffs_epfile_io(kiocb->ki_filp, io_data); | 928 | res = ffs_epfile_io(kiocb->ki_filp, p); |
| 929 | if (res == -EIOCBQUEUED) | ||
| 930 | return res; | ||
| 931 | if (p->aio) | ||
| 932 | kfree(p); | ||
| 933 | else | ||
| 934 | *from = p->data; | ||
| 935 | return res; | ||
| 993 | } | 936 | } |
| 994 | 937 | ||
| 995 | static ssize_t ffs_epfile_aio_read(struct kiocb *kiocb, | 938 | static ssize_t ffs_epfile_read_iter(struct kiocb *kiocb, struct iov_iter *to) |
| 996 | const struct iovec *iovec, | ||
| 997 | unsigned long nr_segs, loff_t loff) | ||
| 998 | { | 939 | { |
| 999 | struct ffs_io_data *io_data; | 940 | struct ffs_io_data io_data, *p = &io_data; |
| 1000 | struct iovec *iovec_copy; | 941 | ssize_t res; |
| 1001 | 942 | ||
| 1002 | ENTER(); | 943 | ENTER(); |
| 1003 | 944 | ||
| 1004 | iovec_copy = kmalloc_array(nr_segs, sizeof(*iovec_copy), GFP_KERNEL); | 945 | if (!is_sync_kiocb(kiocb)) { |
| 1005 | if (unlikely(!iovec_copy)) | 946 | p = kmalloc(sizeof(io_data), GFP_KERNEL); |
| 1006 | return -ENOMEM; | 947 | if (unlikely(!p)) |
| 1007 | 948 | return -ENOMEM; | |
| 1008 | memcpy(iovec_copy, iovec, sizeof(struct iovec)*nr_segs); | 949 | p->aio = true; |
| 1009 | 950 | } else { | |
| 1010 | io_data = kmalloc(sizeof(*io_data), GFP_KERNEL); | 951 | p->aio = false; |
| 1011 | if (unlikely(!io_data)) { | ||
| 1012 | kfree(iovec_copy); | ||
| 1013 | return -ENOMEM; | ||
| 1014 | } | 952 | } |
| 1015 | 953 | ||
| 1016 | io_data->aio = true; | 954 | p->read = true; |
| 1017 | io_data->read = true; | 955 | p->kiocb = kiocb; |
| 1018 | io_data->kiocb = kiocb; | 956 | if (p->aio) { |
| 1019 | io_data->iovec = iovec_copy; | 957 | p->to_free = dup_iter(&p->data, to, GFP_KERNEL); |
| 1020 | io_data->nr_segs = nr_segs; | 958 | if (!p->to_free) { |
| 1021 | io_data->len = kiocb->ki_nbytes; | 959 | kfree(p); |
| 1022 | io_data->mm = current->mm; | 960 | return -ENOMEM; |
| 961 | } | ||
| 962 | } else { | ||
| 963 | p->data = *to; | ||
| 964 | p->to_free = NULL; | ||
| 965 | } | ||
| 966 | p->mm = current->mm; | ||
| 1023 | 967 | ||
| 1024 | kiocb->private = io_data; | 968 | kiocb->private = p; |
| 1025 | 969 | ||
| 1026 | kiocb_set_cancel_fn(kiocb, ffs_aio_cancel); | 970 | kiocb_set_cancel_fn(kiocb, ffs_aio_cancel); |
| 1027 | 971 | ||
| 1028 | return ffs_epfile_io(kiocb->ki_filp, io_data); | 972 | res = ffs_epfile_io(kiocb->ki_filp, p); |
| 973 | if (res == -EIOCBQUEUED) | ||
| 974 | return res; | ||
| 975 | |||
| 976 | if (p->aio) { | ||
| 977 | kfree(p->to_free); | ||
| 978 | kfree(p); | ||
| 979 | } else { | ||
| 980 | *to = p->data; | ||
| 981 | } | ||
| 982 | return res; | ||
| 1029 | } | 983 | } |
| 1030 | 984 | ||
| 1031 | static int | 985 | static int |
| @@ -1105,10 +1059,10 @@ static const struct file_operations ffs_epfile_operations = { | |||
| 1105 | .llseek = no_llseek, | 1059 | .llseek = no_llseek, |
| 1106 | 1060 | ||
| 1107 | .open = ffs_epfile_open, | 1061 | .open = ffs_epfile_open, |
| 1108 | .write = ffs_epfile_write, | 1062 | .write = new_sync_write, |
| 1109 | .read = ffs_epfile_read, | 1063 | .read = new_sync_read, |
| 1110 | .aio_write = ffs_epfile_aio_write, | 1064 | .write_iter = ffs_epfile_write_iter, |
| 1111 | .aio_read = ffs_epfile_aio_read, | 1065 | .read_iter = ffs_epfile_read_iter, |
| 1112 | .release = ffs_epfile_release, | 1066 | .release = ffs_epfile_release, |
| 1113 | .unlocked_ioctl = ffs_epfile_ioctl, | 1067 | .unlocked_ioctl = ffs_epfile_ioctl, |
| 1114 | }; | 1068 | }; |
diff --git a/drivers/usb/gadget/function/f_loopback.c b/drivers/usb/gadget/function/f_loopback.c index 298b46112b1a..39f49f1ad22f 100644 --- a/drivers/usb/gadget/function/f_loopback.c +++ b/drivers/usb/gadget/function/f_loopback.c | |||
| @@ -289,8 +289,7 @@ static void disable_loopback(struct f_loopback *loop) | |||
| 289 | struct usb_composite_dev *cdev; | 289 | struct usb_composite_dev *cdev; |
| 290 | 290 | ||
| 291 | cdev = loop->function.config->cdev; | 291 | cdev = loop->function.config->cdev; |
| 292 | disable_endpoints(cdev, loop->in_ep, loop->out_ep, NULL, NULL, NULL, | 292 | disable_endpoints(cdev, loop->in_ep, loop->out_ep, NULL, NULL); |
| 293 | NULL); | ||
| 294 | VDBG(cdev, "%s disabled\n", loop->function.name); | 293 | VDBG(cdev, "%s disabled\n", loop->function.name); |
| 295 | } | 294 | } |
| 296 | 295 | ||
diff --git a/drivers/usb/gadget/function/f_sourcesink.c b/drivers/usb/gadget/function/f_sourcesink.c index e3dae47baef3..3a5ae9900b1e 100644 --- a/drivers/usb/gadget/function/f_sourcesink.c +++ b/drivers/usb/gadget/function/f_sourcesink.c | |||
| @@ -23,15 +23,6 @@ | |||
| 23 | #include "gadget_chips.h" | 23 | #include "gadget_chips.h" |
| 24 | #include "u_f.h" | 24 | #include "u_f.h" |
| 25 | 25 | ||
| 26 | #define USB_MS_TO_SS_INTERVAL(x) USB_MS_TO_HS_INTERVAL(x) | ||
| 27 | |||
| 28 | enum eptype { | ||
| 29 | EP_CONTROL = 0, | ||
| 30 | EP_BULK, | ||
| 31 | EP_ISOC, | ||
| 32 | EP_INTERRUPT, | ||
| 33 | }; | ||
| 34 | |||
| 35 | /* | 26 | /* |
| 36 | * SOURCE/SINK FUNCTION ... a primary testing vehicle for USB peripheral | 27 | * SOURCE/SINK FUNCTION ... a primary testing vehicle for USB peripheral |
| 37 | * controller drivers. | 28 | * controller drivers. |
| @@ -64,8 +55,6 @@ struct f_sourcesink { | |||
| 64 | struct usb_ep *out_ep; | 55 | struct usb_ep *out_ep; |
| 65 | struct usb_ep *iso_in_ep; | 56 | struct usb_ep *iso_in_ep; |
| 66 | struct usb_ep *iso_out_ep; | 57 | struct usb_ep *iso_out_ep; |
| 67 | struct usb_ep *int_in_ep; | ||
| 68 | struct usb_ep *int_out_ep; | ||
| 69 | int cur_alt; | 58 | int cur_alt; |
| 70 | }; | 59 | }; |
| 71 | 60 | ||
| @@ -79,10 +68,6 @@ static unsigned isoc_interval; | |||
| 79 | static unsigned isoc_maxpacket; | 68 | static unsigned isoc_maxpacket; |
| 80 | static unsigned isoc_mult; | 69 | static unsigned isoc_mult; |
| 81 | static unsigned isoc_maxburst; | 70 | static unsigned isoc_maxburst; |
| 82 | static unsigned int_interval; /* In ms */ | ||
| 83 | static unsigned int_maxpacket; | ||
| 84 | static unsigned int_mult; | ||
| 85 | static unsigned int_maxburst; | ||
| 86 | static unsigned buflen; | 71 | static unsigned buflen; |
| 87 | 72 | ||
| 88 | /*-------------------------------------------------------------------------*/ | 73 | /*-------------------------------------------------------------------------*/ |
| @@ -107,16 +92,6 @@ static struct usb_interface_descriptor source_sink_intf_alt1 = { | |||
| 107 | /* .iInterface = DYNAMIC */ | 92 | /* .iInterface = DYNAMIC */ |
| 108 | }; | 93 | }; |
| 109 | 94 | ||
| 110 | static struct usb_interface_descriptor source_sink_intf_alt2 = { | ||
| 111 | .bLength = USB_DT_INTERFACE_SIZE, | ||
| 112 | .bDescriptorType = USB_DT_INTERFACE, | ||
| 113 | |||
| 114 | .bAlternateSetting = 2, | ||
| 115 | .bNumEndpoints = 2, | ||
| 116 | .bInterfaceClass = USB_CLASS_VENDOR_SPEC, | ||
| 117 | /* .iInterface = DYNAMIC */ | ||
| 118 | }; | ||
| 119 | |||
| 120 | /* full speed support: */ | 95 | /* full speed support: */ |
| 121 | 96 | ||
| 122 | static struct usb_endpoint_descriptor fs_source_desc = { | 97 | static struct usb_endpoint_descriptor fs_source_desc = { |
| @@ -155,26 +130,6 @@ static struct usb_endpoint_descriptor fs_iso_sink_desc = { | |||
| 155 | .bInterval = 4, | 130 | .bInterval = 4, |
| 156 | }; | 131 | }; |
| 157 | 132 | ||
| 158 | static struct usb_endpoint_descriptor fs_int_source_desc = { | ||
| 159 | .bLength = USB_DT_ENDPOINT_SIZE, | ||
| 160 | .bDescriptorType = USB_DT_ENDPOINT, | ||
| 161 | |||
| 162 | .bEndpointAddress = USB_DIR_IN, | ||
| 163 | .bmAttributes = USB_ENDPOINT_XFER_INT, | ||
| 164 | .wMaxPacketSize = cpu_to_le16(64), | ||
| 165 | .bInterval = GZERO_INT_INTERVAL, | ||
| 166 | }; | ||
| 167 | |||
| 168 | static struct usb_endpoint_descriptor fs_int_sink_desc = { | ||
| 169 | .bLength = USB_DT_ENDPOINT_SIZE, | ||
| 170 | .bDescriptorType = USB_DT_ENDPOINT, | ||
| 171 | |||
| 172 | .bEndpointAddress = USB_DIR_OUT, | ||
| 173 | .bmAttributes = USB_ENDPOINT_XFER_INT, | ||
| 174 | .wMaxPacketSize = cpu_to_le16(64), | ||
| 175 | .bInterval = GZERO_INT_INTERVAL, | ||
| 176 | }; | ||
| 177 | |||
| 178 | static struct usb_descriptor_header *fs_source_sink_descs[] = { | 133 | static struct usb_descriptor_header *fs_source_sink_descs[] = { |
| 179 | (struct usb_descriptor_header *) &source_sink_intf_alt0, | 134 | (struct usb_descriptor_header *) &source_sink_intf_alt0, |
| 180 | (struct usb_descriptor_header *) &fs_sink_desc, | 135 | (struct usb_descriptor_header *) &fs_sink_desc, |
| @@ -185,10 +140,6 @@ static struct usb_descriptor_header *fs_source_sink_descs[] = { | |||
| 185 | (struct usb_descriptor_header *) &fs_source_desc, | 140 | (struct usb_descriptor_header *) &fs_source_desc, |
| 186 | (struct usb_descriptor_header *) &fs_iso_sink_desc, | 141 | (struct usb_descriptor_header *) &fs_iso_sink_desc, |
| 187 | (struct usb_descriptor_header *) &fs_iso_source_desc, | 142 | (struct usb_descriptor_header *) &fs_iso_source_desc, |
| 188 | (struct usb_descriptor_header *) &source_sink_intf_alt2, | ||
| 189 | #define FS_ALT_IFC_2_OFFSET 8 | ||
| 190 | (struct usb_descriptor_header *) &fs_int_sink_desc, | ||
| 191 | (struct usb_descriptor_header *) &fs_int_source_desc, | ||
| 192 | NULL, | 143 | NULL, |
| 193 | }; | 144 | }; |
| 194 | 145 | ||
| @@ -228,24 +179,6 @@ static struct usb_endpoint_descriptor hs_iso_sink_desc = { | |||
| 228 | .bInterval = 4, | 179 | .bInterval = 4, |
| 229 | }; | 180 | }; |
| 230 | 181 | ||
| 231 | static struct usb_endpoint_descriptor hs_int_source_desc = { | ||
| 232 | .bLength = USB_DT_ENDPOINT_SIZE, | ||
| 233 | .bDescriptorType = USB_DT_ENDPOINT, | ||
| 234 | |||
| 235 | .bmAttributes = USB_ENDPOINT_XFER_INT, | ||
| 236 | .wMaxPacketSize = cpu_to_le16(1024), | ||
| 237 | .bInterval = USB_MS_TO_HS_INTERVAL(GZERO_INT_INTERVAL), | ||
| 238 | }; | ||
| 239 | |||
| 240 | static struct usb_endpoint_descriptor hs_int_sink_desc = { | ||
| 241 | .bLength = USB_DT_ENDPOINT_SIZE, | ||
| 242 | .bDescriptorType = USB_DT_ENDPOINT, | ||
| 243 | |||
| 244 | .bmAttributes = USB_ENDPOINT_XFER_INT, | ||
| 245 | .wMaxPacketSize = cpu_to_le16(1024), | ||
| 246 | .bInterval = USB_MS_TO_HS_INTERVAL(GZERO_INT_INTERVAL), | ||
| 247 | }; | ||
| 248 | |||
| 249 | static struct usb_descriptor_header *hs_source_sink_descs[] = { | 182 | static struct usb_descriptor_header *hs_source_sink_descs[] = { |
| 250 | (struct usb_descriptor_header *) &source_sink_intf_alt0, | 183 | (struct usb_descriptor_header *) &source_sink_intf_alt0, |
| 251 | (struct usb_descriptor_header *) &hs_source_desc, | 184 | (struct usb_descriptor_header *) &hs_source_desc, |
| @@ -256,10 +189,6 @@ static struct usb_descriptor_header *hs_source_sink_descs[] = { | |||
| 256 | (struct usb_descriptor_header *) &hs_sink_desc, | 189 | (struct usb_descriptor_header *) &hs_sink_desc, |
| 257 | (struct usb_descriptor_header *) &hs_iso_source_desc, | 190 | (struct usb_descriptor_header *) &hs_iso_source_desc, |
| 258 | (struct usb_descriptor_header *) &hs_iso_sink_desc, | 191 | (struct usb_descriptor_header *) &hs_iso_sink_desc, |
| 259 | (struct usb_descriptor_header *) &source_sink_intf_alt2, | ||
| 260 | #define HS_ALT_IFC_2_OFFSET 8 | ||
| 261 | (struct usb_descriptor_header *) &hs_int_source_desc, | ||
| 262 | (struct usb_descriptor_header *) &hs_int_sink_desc, | ||
| 263 | NULL, | 192 | NULL, |
| 264 | }; | 193 | }; |
| 265 | 194 | ||
| @@ -335,42 +264,6 @@ static struct usb_ss_ep_comp_descriptor ss_iso_sink_comp_desc = { | |||
| 335 | .wBytesPerInterval = cpu_to_le16(1024), | 264 | .wBytesPerInterval = cpu_to_le16(1024), |
| 336 | }; | 265 | }; |
| 337 | 266 | ||
| 338 | static struct usb_endpoint_descriptor ss_int_source_desc = { | ||
| 339 | .bLength = USB_DT_ENDPOINT_SIZE, | ||
| 340 | .bDescriptorType = USB_DT_ENDPOINT, | ||
| 341 | |||
| 342 | .bmAttributes = USB_ENDPOINT_XFER_INT, | ||
| 343 | .wMaxPacketSize = cpu_to_le16(1024), | ||
| 344 | .bInterval = USB_MS_TO_SS_INTERVAL(GZERO_INT_INTERVAL), | ||
| 345 | }; | ||
| 346 | |||
| 347 | static struct usb_ss_ep_comp_descriptor ss_int_source_comp_desc = { | ||
| 348 | .bLength = USB_DT_SS_EP_COMP_SIZE, | ||
| 349 | .bDescriptorType = USB_DT_SS_ENDPOINT_COMP, | ||
| 350 | |||
| 351 | .bMaxBurst = 0, | ||
| 352 | .bmAttributes = 0, | ||
| 353 | .wBytesPerInterval = cpu_to_le16(1024), | ||
| 354 | }; | ||
| 355 | |||
| 356 | static struct usb_endpoint_descriptor ss_int_sink_desc = { | ||
| 357 | .bLength = USB_DT_ENDPOINT_SIZE, | ||
| 358 | .bDescriptorType = USB_DT_ENDPOINT, | ||
| 359 | |||
| 360 | .bmAttributes = USB_ENDPOINT_XFER_INT, | ||
| 361 | .wMaxPacketSize = cpu_to_le16(1024), | ||
| 362 | .bInterval = USB_MS_TO_SS_INTERVAL(GZERO_INT_INTERVAL), | ||
| 363 | }; | ||
| 364 | |||
| 365 | static struct usb_ss_ep_comp_descriptor ss_int_sink_comp_desc = { | ||
| 366 | .bLength = USB_DT_SS_EP_COMP_SIZE, | ||
| 367 | .bDescriptorType = USB_DT_SS_ENDPOINT_COMP, | ||
| 368 | |||
| 369 | .bMaxBurst = 0, | ||
| 370 | .bmAttributes = 0, | ||
| 371 | .wBytesPerInterval = cpu_to_le16(1024), | ||
| 372 | }; | ||
| 373 | |||
| 374 | static struct usb_descriptor_header *ss_source_sink_descs[] = { | 267 | static struct usb_descriptor_header *ss_source_sink_descs[] = { |
| 375 | (struct usb_descriptor_header *) &source_sink_intf_alt0, | 268 | (struct usb_descriptor_header *) &source_sink_intf_alt0, |
| 376 | (struct usb_descriptor_header *) &ss_source_desc, | 269 | (struct usb_descriptor_header *) &ss_source_desc, |
| @@ -387,12 +280,6 @@ static struct usb_descriptor_header *ss_source_sink_descs[] = { | |||
| 387 | (struct usb_descriptor_header *) &ss_iso_source_comp_desc, | 280 | (struct usb_descriptor_header *) &ss_iso_source_comp_desc, |
| 388 | (struct usb_descriptor_header *) &ss_iso_sink_desc, | 281 | (struct usb_descriptor_header *) &ss_iso_sink_desc, |
| 389 | (struct usb_descriptor_header *) &ss_iso_sink_comp_desc, | 282 | (struct usb_descriptor_header *) &ss_iso_sink_comp_desc, |
| 390 | (struct usb_descriptor_header *) &source_sink_intf_alt2, | ||
| 391 | #define SS_ALT_IFC_2_OFFSET 14 | ||
| 392 | (struct usb_descriptor_header *) &ss_int_source_desc, | ||
| 393 | (struct usb_descriptor_header *) &ss_int_source_comp_desc, | ||
| 394 | (struct usb_descriptor_header *) &ss_int_sink_desc, | ||
| 395 | (struct usb_descriptor_header *) &ss_int_sink_comp_desc, | ||
| 396 | NULL, | 283 | NULL, |
| 397 | }; | 284 | }; |
| 398 | 285 | ||
| @@ -414,21 +301,6 @@ static struct usb_gadget_strings *sourcesink_strings[] = { | |||
| 414 | }; | 301 | }; |
| 415 | 302 | ||
| 416 | /*-------------------------------------------------------------------------*/ | 303 | /*-------------------------------------------------------------------------*/ |
| 417 | static const char *get_ep_string(enum eptype ep_type) | ||
| 418 | { | ||
| 419 | switch (ep_type) { | ||
| 420 | case EP_ISOC: | ||
| 421 | return "ISOC-"; | ||
| 422 | case EP_INTERRUPT: | ||
| 423 | return "INTERRUPT-"; | ||
| 424 | case EP_CONTROL: | ||
| 425 | return "CTRL-"; | ||
| 426 | case EP_BULK: | ||
| 427 | return "BULK-"; | ||
| 428 | default: | ||
| 429 | return "UNKNOWN-"; | ||
| 430 | } | ||
| 431 | } | ||
| 432 | 304 | ||
| 433 | static inline struct usb_request *ss_alloc_ep_req(struct usb_ep *ep, int len) | 305 | static inline struct usb_request *ss_alloc_ep_req(struct usb_ep *ep, int len) |
| 434 | { | 306 | { |
| @@ -456,8 +328,7 @@ static void disable_ep(struct usb_composite_dev *cdev, struct usb_ep *ep) | |||
| 456 | 328 | ||
| 457 | void disable_endpoints(struct usb_composite_dev *cdev, | 329 | void disable_endpoints(struct usb_composite_dev *cdev, |
| 458 | struct usb_ep *in, struct usb_ep *out, | 330 | struct usb_ep *in, struct usb_ep *out, |
| 459 | struct usb_ep *iso_in, struct usb_ep *iso_out, | 331 | struct usb_ep *iso_in, struct usb_ep *iso_out) |
| 460 | struct usb_ep *int_in, struct usb_ep *int_out) | ||
| 461 | { | 332 | { |
| 462 | disable_ep(cdev, in); | 333 | disable_ep(cdev, in); |
| 463 | disable_ep(cdev, out); | 334 | disable_ep(cdev, out); |
| @@ -465,10 +336,6 @@ void disable_endpoints(struct usb_composite_dev *cdev, | |||
| 465 | disable_ep(cdev, iso_in); | 336 | disable_ep(cdev, iso_in); |
| 466 | if (iso_out) | 337 | if (iso_out) |
| 467 | disable_ep(cdev, iso_out); | 338 | disable_ep(cdev, iso_out); |
| 468 | if (int_in) | ||
| 469 | disable_ep(cdev, int_in); | ||
| 470 | if (int_out) | ||
| 471 | disable_ep(cdev, int_out); | ||
| 472 | } | 339 | } |
| 473 | 340 | ||
| 474 | static int | 341 | static int |
| @@ -485,7 +352,6 @@ sourcesink_bind(struct usb_configuration *c, struct usb_function *f) | |||
| 485 | return id; | 352 | return id; |
| 486 | source_sink_intf_alt0.bInterfaceNumber = id; | 353 | source_sink_intf_alt0.bInterfaceNumber = id; |
| 487 | source_sink_intf_alt1.bInterfaceNumber = id; | 354 | source_sink_intf_alt1.bInterfaceNumber = id; |
| 488 | source_sink_intf_alt2.bInterfaceNumber = id; | ||
| 489 | 355 | ||
| 490 | /* allocate bulk endpoints */ | 356 | /* allocate bulk endpoints */ |
| 491 | ss->in_ep = usb_ep_autoconfig(cdev->gadget, &fs_source_desc); | 357 | ss->in_ep = usb_ep_autoconfig(cdev->gadget, &fs_source_desc); |
| @@ -546,55 +412,14 @@ no_iso: | |||
| 546 | if (isoc_maxpacket > 1024) | 412 | if (isoc_maxpacket > 1024) |
| 547 | isoc_maxpacket = 1024; | 413 | isoc_maxpacket = 1024; |
| 548 | 414 | ||
| 549 | /* sanity check the interrupt module parameters */ | ||
| 550 | if (int_interval < 1) | ||
| 551 | int_interval = 1; | ||
| 552 | if (int_interval > 4096) | ||
| 553 | int_interval = 4096; | ||
| 554 | if (int_mult > 2) | ||
| 555 | int_mult = 2; | ||
| 556 | if (int_maxburst > 15) | ||
| 557 | int_maxburst = 15; | ||
| 558 | |||
| 559 | /* fill in the FS interrupt descriptors from the module parameters */ | ||
| 560 | fs_int_source_desc.wMaxPacketSize = int_maxpacket > 64 ? | ||
| 561 | 64 : int_maxpacket; | ||
| 562 | fs_int_source_desc.bInterval = int_interval > 255 ? | ||
| 563 | 255 : int_interval; | ||
| 564 | fs_int_sink_desc.wMaxPacketSize = int_maxpacket > 64 ? | ||
| 565 | 64 : int_maxpacket; | ||
| 566 | fs_int_sink_desc.bInterval = int_interval > 255 ? | ||
| 567 | 255 : int_interval; | ||
| 568 | |||
| 569 | /* allocate int endpoints */ | ||
| 570 | ss->int_in_ep = usb_ep_autoconfig(cdev->gadget, &fs_int_source_desc); | ||
| 571 | if (!ss->int_in_ep) | ||
| 572 | goto no_int; | ||
| 573 | ss->int_in_ep->driver_data = cdev; /* claim */ | ||
| 574 | |||
| 575 | ss->int_out_ep = usb_ep_autoconfig(cdev->gadget, &fs_int_sink_desc); | ||
| 576 | if (ss->int_out_ep) { | ||
| 577 | ss->int_out_ep->driver_data = cdev; /* claim */ | ||
| 578 | } else { | ||
| 579 | ss->int_in_ep->driver_data = NULL; | ||
| 580 | ss->int_in_ep = NULL; | ||
| 581 | no_int: | ||
| 582 | fs_source_sink_descs[FS_ALT_IFC_2_OFFSET] = NULL; | ||
| 583 | hs_source_sink_descs[HS_ALT_IFC_2_OFFSET] = NULL; | ||
| 584 | ss_source_sink_descs[SS_ALT_IFC_2_OFFSET] = NULL; | ||
| 585 | } | ||
| 586 | |||
| 587 | if (int_maxpacket > 1024) | ||
| 588 | int_maxpacket = 1024; | ||
| 589 | |||
| 590 | /* support high speed hardware */ | 415 | /* support high speed hardware */ |
| 591 | hs_source_desc.bEndpointAddress = fs_source_desc.bEndpointAddress; | 416 | hs_source_desc.bEndpointAddress = fs_source_desc.bEndpointAddress; |
| 592 | hs_sink_desc.bEndpointAddress = fs_sink_desc.bEndpointAddress; | 417 | hs_sink_desc.bEndpointAddress = fs_sink_desc.bEndpointAddress; |
| 593 | 418 | ||
| 594 | /* | 419 | /* |
| 595 | * Fill in the HS isoc and interrupt descriptors from the module | 420 | * Fill in the HS isoc descriptors from the module parameters. |
| 596 | * parameters. We assume that the user knows what they are doing and | 421 | * We assume that the user knows what they are doing and won't |
| 597 | * won't give parameters that their UDC doesn't support. | 422 | * give parameters that their UDC doesn't support. |
| 598 | */ | 423 | */ |
| 599 | hs_iso_source_desc.wMaxPacketSize = isoc_maxpacket; | 424 | hs_iso_source_desc.wMaxPacketSize = isoc_maxpacket; |
| 600 | hs_iso_source_desc.wMaxPacketSize |= isoc_mult << 11; | 425 | hs_iso_source_desc.wMaxPacketSize |= isoc_mult << 11; |
| @@ -607,17 +432,6 @@ no_int: | |||
| 607 | hs_iso_sink_desc.bInterval = isoc_interval; | 432 | hs_iso_sink_desc.bInterval = isoc_interval; |
| 608 | hs_iso_sink_desc.bEndpointAddress = fs_iso_sink_desc.bEndpointAddress; | 433 | hs_iso_sink_desc.bEndpointAddress = fs_iso_sink_desc.bEndpointAddress; |
| 609 | 434 | ||
| 610 | hs_int_source_desc.wMaxPacketSize = int_maxpacket; | ||
| 611 | hs_int_source_desc.wMaxPacketSize |= int_mult << 11; | ||
| 612 | hs_int_source_desc.bInterval = USB_MS_TO_HS_INTERVAL(int_interval); | ||
| 613 | hs_int_source_desc.bEndpointAddress = | ||
| 614 | fs_int_source_desc.bEndpointAddress; | ||
| 615 | |||
| 616 | hs_int_sink_desc.wMaxPacketSize = int_maxpacket; | ||
| 617 | hs_int_sink_desc.wMaxPacketSize |= int_mult << 11; | ||
| 618 | hs_int_sink_desc.bInterval = USB_MS_TO_HS_INTERVAL(int_interval); | ||
| 619 | hs_int_sink_desc.bEndpointAddress = fs_int_sink_desc.bEndpointAddress; | ||
| 620 | |||
| 621 | /* support super speed hardware */ | 435 | /* support super speed hardware */ |
| 622 | ss_source_desc.bEndpointAddress = | 436 | ss_source_desc.bEndpointAddress = |
| 623 | fs_source_desc.bEndpointAddress; | 437 | fs_source_desc.bEndpointAddress; |
| @@ -625,9 +439,9 @@ no_int: | |||
| 625 | fs_sink_desc.bEndpointAddress; | 439 | fs_sink_desc.bEndpointAddress; |
| 626 | 440 | ||
| 627 | /* | 441 | /* |
| 628 | * Fill in the SS isoc and interrupt descriptors from the module | 442 | * Fill in the SS isoc descriptors from the module parameters. |
| 629 | * parameters. We assume that the user knows what they are doing and | 443 | * We assume that the user knows what they are doing and won't |
| 630 | * won't give parameters that their UDC doesn't support. | 444 | * give parameters that their UDC doesn't support. |
| 631 | */ | 445 | */ |
| 632 | ss_iso_source_desc.wMaxPacketSize = isoc_maxpacket; | 446 | ss_iso_source_desc.wMaxPacketSize = isoc_maxpacket; |
| 633 | ss_iso_source_desc.bInterval = isoc_interval; | 447 | ss_iso_source_desc.bInterval = isoc_interval; |
| @@ -646,37 +460,17 @@ no_int: | |||
| 646 | isoc_maxpacket * (isoc_mult + 1) * (isoc_maxburst + 1); | 460 | isoc_maxpacket * (isoc_mult + 1) * (isoc_maxburst + 1); |
| 647 | ss_iso_sink_desc.bEndpointAddress = fs_iso_sink_desc.bEndpointAddress; | 461 | ss_iso_sink_desc.bEndpointAddress = fs_iso_sink_desc.bEndpointAddress; |
| 648 | 462 | ||
| 649 | ss_int_source_desc.wMaxPacketSize = int_maxpacket; | ||
| 650 | ss_int_source_desc.bInterval = USB_MS_TO_SS_INTERVAL(int_interval); | ||
| 651 | ss_int_source_comp_desc.bmAttributes = int_mult; | ||
| 652 | ss_int_source_comp_desc.bMaxBurst = int_maxburst; | ||
| 653 | ss_int_source_comp_desc.wBytesPerInterval = | ||
| 654 | int_maxpacket * (int_mult + 1) * (int_maxburst + 1); | ||
| 655 | ss_int_source_desc.bEndpointAddress = | ||
| 656 | fs_int_source_desc.bEndpointAddress; | ||
| 657 | |||
| 658 | ss_int_sink_desc.wMaxPacketSize = int_maxpacket; | ||
| 659 | ss_int_sink_desc.bInterval = USB_MS_TO_SS_INTERVAL(int_interval); | ||
| 660 | ss_int_sink_comp_desc.bmAttributes = int_mult; | ||
| 661 | ss_int_sink_comp_desc.bMaxBurst = int_maxburst; | ||
| 662 | ss_int_sink_comp_desc.wBytesPerInterval = | ||
| 663 | int_maxpacket * (int_mult + 1) * (int_maxburst + 1); | ||
| 664 | ss_int_sink_desc.bEndpointAddress = fs_int_sink_desc.bEndpointAddress; | ||
| 665 | |||
| 666 | ret = usb_assign_descriptors(f, fs_source_sink_descs, | 463 | ret = usb_assign_descriptors(f, fs_source_sink_descs, |
| 667 | hs_source_sink_descs, ss_source_sink_descs); | 464 | hs_source_sink_descs, ss_source_sink_descs); |
| 668 | if (ret) | 465 | if (ret) |
| 669 | return ret; | 466 | return ret; |
| 670 | 467 | ||
| 671 | DBG(cdev, "%s speed %s: IN/%s, OUT/%s, ISO-IN/%s, ISO-OUT/%s, " | 468 | DBG(cdev, "%s speed %s: IN/%s, OUT/%s, ISO-IN/%s, ISO-OUT/%s\n", |
| 672 | "INT-IN/%s, INT-OUT/%s\n", | ||
| 673 | (gadget_is_superspeed(c->cdev->gadget) ? "super" : | 469 | (gadget_is_superspeed(c->cdev->gadget) ? "super" : |
| 674 | (gadget_is_dualspeed(c->cdev->gadget) ? "dual" : "full")), | 470 | (gadget_is_dualspeed(c->cdev->gadget) ? "dual" : "full")), |
| 675 | f->name, ss->in_ep->name, ss->out_ep->name, | 471 | f->name, ss->in_ep->name, ss->out_ep->name, |
| 676 | ss->iso_in_ep ? ss->iso_in_ep->name : "<none>", | 472 | ss->iso_in_ep ? ss->iso_in_ep->name : "<none>", |
| 677 | ss->iso_out_ep ? ss->iso_out_ep->name : "<none>", | 473 | ss->iso_out_ep ? ss->iso_out_ep->name : "<none>"); |
| 678 | ss->int_in_ep ? ss->int_in_ep->name : "<none>", | ||
| 679 | ss->int_out_ep ? ss->int_out_ep->name : "<none>"); | ||
| 680 | return 0; | 474 | return 0; |
| 681 | } | 475 | } |
| 682 | 476 | ||
| @@ -807,15 +601,14 @@ static void source_sink_complete(struct usb_ep *ep, struct usb_request *req) | |||
| 807 | } | 601 | } |
| 808 | 602 | ||
| 809 | static int source_sink_start_ep(struct f_sourcesink *ss, bool is_in, | 603 | static int source_sink_start_ep(struct f_sourcesink *ss, bool is_in, |
| 810 | enum eptype ep_type, int speed) | 604 | bool is_iso, int speed) |
| 811 | { | 605 | { |
| 812 | struct usb_ep *ep; | 606 | struct usb_ep *ep; |
| 813 | struct usb_request *req; | 607 | struct usb_request *req; |
| 814 | int i, size, status; | 608 | int i, size, status; |
| 815 | 609 | ||
| 816 | for (i = 0; i < 8; i++) { | 610 | for (i = 0; i < 8; i++) { |
| 817 | switch (ep_type) { | 611 | if (is_iso) { |
| 818 | case EP_ISOC: | ||
| 819 | switch (speed) { | 612 | switch (speed) { |
| 820 | case USB_SPEED_SUPER: | 613 | case USB_SPEED_SUPER: |
| 821 | size = isoc_maxpacket * (isoc_mult + 1) * | 614 | size = isoc_maxpacket * (isoc_mult + 1) * |
| @@ -831,28 +624,9 @@ static int source_sink_start_ep(struct f_sourcesink *ss, bool is_in, | |||
| 831 | } | 624 | } |
| 832 | ep = is_in ? ss->iso_in_ep : ss->iso_out_ep; | 625 | ep = is_in ? ss->iso_in_ep : ss->iso_out_ep; |
| 833 | req = ss_alloc_ep_req(ep, size); | 626 | req = ss_alloc_ep_req(ep, size); |
| 834 | break; | 627 | } else { |
| 835 | case EP_INTERRUPT: | ||
| 836 | switch (speed) { | ||
| 837 | case USB_SPEED_SUPER: | ||
| 838 | size = int_maxpacket * (int_mult + 1) * | ||
| 839 | (int_maxburst + 1); | ||
| 840 | break; | ||
| 841 | case USB_SPEED_HIGH: | ||
| 842 | size = int_maxpacket * (int_mult + 1); | ||
| 843 | break; | ||
| 844 | default: | ||
| 845 | size = int_maxpacket > 1023 ? | ||
| 846 | 1023 : int_maxpacket; | ||
| 847 | break; | ||
| 848 | } | ||
| 849 | ep = is_in ? ss->int_in_ep : ss->int_out_ep; | ||
| 850 | req = ss_alloc_ep_req(ep, size); | ||
| 851 | break; | ||
| 852 | default: | ||
| 853 | ep = is_in ? ss->in_ep : ss->out_ep; | 628 | ep = is_in ? ss->in_ep : ss->out_ep; |
| 854 | req = ss_alloc_ep_req(ep, 0); | 629 | req = ss_alloc_ep_req(ep, 0); |
| 855 | break; | ||
| 856 | } | 630 | } |
| 857 | 631 | ||
| 858 | if (!req) | 632 | if (!req) |
| @@ -870,12 +644,12 @@ static int source_sink_start_ep(struct f_sourcesink *ss, bool is_in, | |||
| 870 | 644 | ||
| 871 | cdev = ss->function.config->cdev; | 645 | cdev = ss->function.config->cdev; |
| 872 | ERROR(cdev, "start %s%s %s --> %d\n", | 646 | ERROR(cdev, "start %s%s %s --> %d\n", |
| 873 | get_ep_string(ep_type), is_in ? "IN" : "OUT", | 647 | is_iso ? "ISO-" : "", is_in ? "IN" : "OUT", |
| 874 | ep->name, status); | 648 | ep->name, status); |
| 875 | free_ep_req(ep, req); | 649 | free_ep_req(ep, req); |
| 876 | } | 650 | } |
| 877 | 651 | ||
| 878 | if (!(ep_type == EP_ISOC)) | 652 | if (!is_iso) |
| 879 | break; | 653 | break; |
| 880 | } | 654 | } |
| 881 | 655 | ||
| @@ -888,7 +662,7 @@ static void disable_source_sink(struct f_sourcesink *ss) | |||
| 888 | 662 | ||
| 889 | cdev = ss->function.config->cdev; | 663 | cdev = ss->function.config->cdev; |
| 890 | disable_endpoints(cdev, ss->in_ep, ss->out_ep, ss->iso_in_ep, | 664 | disable_endpoints(cdev, ss->in_ep, ss->out_ep, ss->iso_in_ep, |
| 891 | ss->iso_out_ep, ss->int_in_ep, ss->int_out_ep); | 665 | ss->iso_out_ep); |
| 892 | VDBG(cdev, "%s disabled\n", ss->function.name); | 666 | VDBG(cdev, "%s disabled\n", ss->function.name); |
| 893 | } | 667 | } |
| 894 | 668 | ||
| @@ -900,62 +674,6 @@ enable_source_sink(struct usb_composite_dev *cdev, struct f_sourcesink *ss, | |||
| 900 | int speed = cdev->gadget->speed; | 674 | int speed = cdev->gadget->speed; |
| 901 | struct usb_ep *ep; | 675 | struct usb_ep *ep; |
| 902 | 676 | ||
| 903 | if (alt == 2) { | ||
| 904 | /* Configure for periodic interrupt endpoint */ | ||
| 905 | ep = ss->int_in_ep; | ||
| 906 | if (ep) { | ||
| 907 | result = config_ep_by_speed(cdev->gadget, | ||
| 908 | &(ss->function), ep); | ||
| 909 | if (result) | ||
| 910 | return result; | ||
| 911 | |||
| 912 | result = usb_ep_enable(ep); | ||
| 913 | if (result < 0) | ||
| 914 | return result; | ||
| 915 | |||
| 916 | ep->driver_data = ss; | ||
| 917 | result = source_sink_start_ep(ss, true, EP_INTERRUPT, | ||
| 918 | speed); | ||
| 919 | if (result < 0) { | ||
| 920 | fail1: | ||
| 921 | ep = ss->int_in_ep; | ||
| 922 | if (ep) { | ||
| 923 | usb_ep_disable(ep); | ||
| 924 | ep->driver_data = NULL; | ||
| 925 | } | ||
| 926 | return result; | ||
| 927 | } | ||
| 928 | } | ||
| 929 | |||
| 930 | /* | ||
| 931 | * one interrupt endpoint reads (sinks) anything OUT (from the | ||
| 932 | * host) | ||
| 933 | */ | ||
| 934 | ep = ss->int_out_ep; | ||
| 935 | if (ep) { | ||
| 936 | result = config_ep_by_speed(cdev->gadget, | ||
| 937 | &(ss->function), ep); | ||
| 938 | if (result) | ||
| 939 | goto fail1; | ||
| 940 | |||
| 941 | result = usb_ep_enable(ep); | ||
| 942 | if (result < 0) | ||
| 943 | goto fail1; | ||
| 944 | |||
| 945 | ep->driver_data = ss; | ||
| 946 | result = source_sink_start_ep(ss, false, EP_INTERRUPT, | ||
| 947 | speed); | ||
| 948 | if (result < 0) { | ||
| 949 | ep = ss->int_out_ep; | ||
| 950 | usb_ep_disable(ep); | ||
| 951 | ep->driver_data = NULL; | ||
| 952 | goto fail1; | ||
| 953 | } | ||
| 954 | } | ||
| 955 | |||
| 956 | goto out; | ||
| 957 | } | ||
| 958 | |||
| 959 | /* one bulk endpoint writes (sources) zeroes IN (to the host) */ | 677 | /* one bulk endpoint writes (sources) zeroes IN (to the host) */ |
| 960 | ep = ss->in_ep; | 678 | ep = ss->in_ep; |
| 961 | result = config_ep_by_speed(cdev->gadget, &(ss->function), ep); | 679 | result = config_ep_by_speed(cdev->gadget, &(ss->function), ep); |
| @@ -966,7 +684,7 @@ fail1: | |||
| 966 | return result; | 684 | return result; |
| 967 | ep->driver_data = ss; | 685 | ep->driver_data = ss; |
| 968 | 686 | ||
| 969 | result = source_sink_start_ep(ss, true, EP_BULK, speed); | 687 | result = source_sink_start_ep(ss, true, false, speed); |
| 970 | if (result < 0) { | 688 | if (result < 0) { |
| 971 | fail: | 689 | fail: |
| 972 | ep = ss->in_ep; | 690 | ep = ss->in_ep; |
| @@ -985,7 +703,7 @@ fail: | |||
| 985 | goto fail; | 703 | goto fail; |
| 986 | ep->driver_data = ss; | 704 | ep->driver_data = ss; |
| 987 | 705 | ||
| 988 | result = source_sink_start_ep(ss, false, EP_BULK, speed); | 706 | result = source_sink_start_ep(ss, false, false, speed); |
| 989 | if (result < 0) { | 707 | if (result < 0) { |
| 990 | fail2: | 708 | fail2: |
| 991 | ep = ss->out_ep; | 709 | ep = ss->out_ep; |
| @@ -1008,7 +726,7 @@ fail2: | |||
| 1008 | goto fail2; | 726 | goto fail2; |
| 1009 | ep->driver_data = ss; | 727 | ep->driver_data = ss; |
| 1010 | 728 | ||
| 1011 | result = source_sink_start_ep(ss, true, EP_ISOC, speed); | 729 | result = source_sink_start_ep(ss, true, true, speed); |
| 1012 | if (result < 0) { | 730 | if (result < 0) { |
| 1013 | fail3: | 731 | fail3: |
| 1014 | ep = ss->iso_in_ep; | 732 | ep = ss->iso_in_ep; |
| @@ -1031,14 +749,13 @@ fail3: | |||
| 1031 | goto fail3; | 749 | goto fail3; |
| 1032 | ep->driver_data = ss; | 750 | ep->driver_data = ss; |
| 1033 | 751 | ||
| 1034 | result = source_sink_start_ep(ss, false, EP_ISOC, speed); | 752 | result = source_sink_start_ep(ss, false, true, speed); |
| 1035 | if (result < 0) { | 753 | if (result < 0) { |
| 1036 | usb_ep_disable(ep); | 754 | usb_ep_disable(ep); |
| 1037 | ep->driver_data = NULL; | 755 | ep->driver_data = NULL; |
| 1038 | goto fail3; | 756 | goto fail3; |
| 1039 | } | 757 | } |
| 1040 | } | 758 | } |
| 1041 | |||
| 1042 | out: | 759 | out: |
| 1043 | ss->cur_alt = alt; | 760 | ss->cur_alt = alt; |
| 1044 | 761 | ||
| @@ -1054,8 +771,6 @@ static int sourcesink_set_alt(struct usb_function *f, | |||
| 1054 | 771 | ||
| 1055 | if (ss->in_ep->driver_data) | 772 | if (ss->in_ep->driver_data) |
| 1056 | disable_source_sink(ss); | 773 | disable_source_sink(ss); |
| 1057 | else if (alt == 2 && ss->int_in_ep->driver_data) | ||
| 1058 | disable_source_sink(ss); | ||
| 1059 | return enable_source_sink(cdev, ss, alt); | 774 | return enable_source_sink(cdev, ss, alt); |
| 1060 | } | 775 | } |
| 1061 | 776 | ||
| @@ -1168,10 +883,6 @@ static struct usb_function *source_sink_alloc_func( | |||
| 1168 | isoc_maxpacket = ss_opts->isoc_maxpacket; | 883 | isoc_maxpacket = ss_opts->isoc_maxpacket; |
| 1169 | isoc_mult = ss_opts->isoc_mult; | 884 | isoc_mult = ss_opts->isoc_mult; |
| 1170 | isoc_maxburst = ss_opts->isoc_maxburst; | 885 | isoc_maxburst = ss_opts->isoc_maxburst; |
| 1171 | int_interval = ss_opts->int_interval; | ||
| 1172 | int_maxpacket = ss_opts->int_maxpacket; | ||
| 1173 | int_mult = ss_opts->int_mult; | ||
| 1174 | int_maxburst = ss_opts->int_maxburst; | ||
| 1175 | buflen = ss_opts->bulk_buflen; | 886 | buflen = ss_opts->bulk_buflen; |
| 1176 | 887 | ||
| 1177 | ss->function.name = "source/sink"; | 888 | ss->function.name = "source/sink"; |
| @@ -1468,182 +1179,6 @@ static struct f_ss_opts_attribute f_ss_opts_bulk_buflen = | |||
| 1468 | f_ss_opts_bulk_buflen_show, | 1179 | f_ss_opts_bulk_buflen_show, |
| 1469 | f_ss_opts_bulk_buflen_store); | 1180 | f_ss_opts_bulk_buflen_store); |
| 1470 | 1181 | ||
| 1471 | static ssize_t f_ss_opts_int_interval_show(struct f_ss_opts *opts, char *page) | ||
| 1472 | { | ||
| 1473 | int result; | ||
| 1474 | |||
| 1475 | mutex_lock(&opts->lock); | ||
| 1476 | result = sprintf(page, "%u", opts->int_interval); | ||
| 1477 | mutex_unlock(&opts->lock); | ||
| 1478 | |||
| 1479 | return result; | ||
| 1480 | } | ||
| 1481 | |||
| 1482 | static ssize_t f_ss_opts_int_interval_store(struct f_ss_opts *opts, | ||
| 1483 | const char *page, size_t len) | ||
| 1484 | { | ||
| 1485 | int ret; | ||
| 1486 | u32 num; | ||
| 1487 | |||
| 1488 | mutex_lock(&opts->lock); | ||
| 1489 | if (opts->refcnt) { | ||
| 1490 | ret = -EBUSY; | ||
| 1491 | goto end; | ||
| 1492 | } | ||
| 1493 | |||
| 1494 | ret = kstrtou32(page, 0, &num); | ||
| 1495 | if (ret) | ||
| 1496 | goto end; | ||
| 1497 | |||
| 1498 | if (num > 4096) { | ||
| 1499 | ret = -EINVAL; | ||
| 1500 | goto end; | ||
| 1501 | } | ||
| 1502 | |||
| 1503 | opts->int_interval = num; | ||
| 1504 | ret = len; | ||
| 1505 | end: | ||
| 1506 | mutex_unlock(&opts->lock); | ||
| 1507 | return ret; | ||
| 1508 | } | ||
| 1509 | |||
| 1510 | static struct f_ss_opts_attribute f_ss_opts_int_interval = | ||
| 1511 | __CONFIGFS_ATTR(int_interval, S_IRUGO | S_IWUSR, | ||
| 1512 | f_ss_opts_int_interval_show, | ||
| 1513 | f_ss_opts_int_interval_store); | ||
| 1514 | |||
| 1515 | static ssize_t f_ss_opts_int_maxpacket_show(struct f_ss_opts *opts, char *page) | ||
| 1516 | { | ||
| 1517 | int result; | ||
| 1518 | |||
| 1519 | mutex_lock(&opts->lock); | ||
| 1520 | result = sprintf(page, "%u", opts->int_maxpacket); | ||
| 1521 | mutex_unlock(&opts->lock); | ||
| 1522 | |||
| 1523 | return result; | ||
| 1524 | } | ||
| 1525 | |||
| 1526 | static ssize_t f_ss_opts_int_maxpacket_store(struct f_ss_opts *opts, | ||
| 1527 | const char *page, size_t len) | ||
| 1528 | { | ||
| 1529 | int ret; | ||
| 1530 | u16 num; | ||
| 1531 | |||
| 1532 | mutex_lock(&opts->lock); | ||
| 1533 | if (opts->refcnt) { | ||
| 1534 | ret = -EBUSY; | ||
| 1535 | goto end; | ||
| 1536 | } | ||
| 1537 | |||
| 1538 | ret = kstrtou16(page, 0, &num); | ||
| 1539 | if (ret) | ||
| 1540 | goto end; | ||
| 1541 | |||
| 1542 | if (num > 1024) { | ||
| 1543 | ret = -EINVAL; | ||
| 1544 | goto end; | ||
| 1545 | } | ||
| 1546 | |||
| 1547 | opts->int_maxpacket = num; | ||
| 1548 | ret = len; | ||
| 1549 | end: | ||
| 1550 | mutex_unlock(&opts->lock); | ||
| 1551 | return ret; | ||
| 1552 | } | ||
| 1553 | |||
| 1554 | static struct f_ss_opts_attribute f_ss_opts_int_maxpacket = | ||
| 1555 | __CONFIGFS_ATTR(int_maxpacket, S_IRUGO | S_IWUSR, | ||
| 1556 | f_ss_opts_int_maxpacket_show, | ||
| 1557 | f_ss_opts_int_maxpacket_store); | ||
| 1558 | |||
| 1559 | static ssize_t f_ss_opts_int_mult_show(struct f_ss_opts *opts, char *page) | ||
| 1560 | { | ||
| 1561 | int result; | ||
| 1562 | |||
| 1563 | mutex_lock(&opts->lock); | ||
| 1564 | result = sprintf(page, "%u", opts->int_mult); | ||
| 1565 | mutex_unlock(&opts->lock); | ||
| 1566 | |||
| 1567 | return result; | ||
| 1568 | } | ||
| 1569 | |||
| 1570 | static ssize_t f_ss_opts_int_mult_store(struct f_ss_opts *opts, | ||
| 1571 | const char *page, size_t len) | ||
| 1572 | { | ||
| 1573 | int ret; | ||
| 1574 | u8 num; | ||
| 1575 | |||
| 1576 | mutex_lock(&opts->lock); | ||
| 1577 | if (opts->refcnt) { | ||
| 1578 | ret = -EBUSY; | ||
| 1579 | goto end; | ||
| 1580 | } | ||
| 1581 | |||
| 1582 | ret = kstrtou8(page, 0, &num); | ||
| 1583 | if (ret) | ||
| 1584 | goto end; | ||
| 1585 | |||
| 1586 | if (num > 2) { | ||
| 1587 | ret = -EINVAL; | ||
| 1588 | goto end; | ||
| 1589 | } | ||
| 1590 | |||
| 1591 | opts->int_mult = num; | ||
| 1592 | ret = len; | ||
| 1593 | end: | ||
| 1594 | mutex_unlock(&opts->lock); | ||
| 1595 | return ret; | ||
| 1596 | } | ||
| 1597 | |||
| 1598 | static struct f_ss_opts_attribute f_ss_opts_int_mult = | ||
| 1599 | __CONFIGFS_ATTR(int_mult, S_IRUGO | S_IWUSR, | ||
| 1600 | f_ss_opts_int_mult_show, | ||
| 1601 | f_ss_opts_int_mult_store); | ||
| 1602 | |||
| 1603 | static ssize_t f_ss_opts_int_maxburst_show(struct f_ss_opts *opts, char *page) | ||
| 1604 | { | ||
| 1605 | int result; | ||
| 1606 | |||
| 1607 | mutex_lock(&opts->lock); | ||
| 1608 | result = sprintf(page, "%u", opts->int_maxburst); | ||
| 1609 | mutex_unlock(&opts->lock); | ||
| 1610 | |||
| 1611 | return result; | ||
| 1612 | } | ||
| 1613 | |||
| 1614 | static ssize_t f_ss_opts_int_maxburst_store(struct f_ss_opts *opts, | ||
| 1615 | const char *page, size_t len) | ||
| 1616 | { | ||
| 1617 | int ret; | ||
| 1618 | u8 num; | ||
| 1619 | |||
| 1620 | mutex_lock(&opts->lock); | ||
| 1621 | if (opts->refcnt) { | ||
| 1622 | ret = -EBUSY; | ||
| 1623 | goto end; | ||
| 1624 | } | ||
| 1625 | |||
| 1626 | ret = kstrtou8(page, 0, &num); | ||
| 1627 | if (ret) | ||
| 1628 | goto end; | ||
| 1629 | |||
| 1630 | if (num > 15) { | ||
| 1631 | ret = -EINVAL; | ||
| 1632 | goto end; | ||
| 1633 | } | ||
| 1634 | |||
| 1635 | opts->int_maxburst = num; | ||
| 1636 | ret = len; | ||
| 1637 | end: | ||
| 1638 | mutex_unlock(&opts->lock); | ||
| 1639 | return ret; | ||
| 1640 | } | ||
| 1641 | |||
| 1642 | static struct f_ss_opts_attribute f_ss_opts_int_maxburst = | ||
| 1643 | __CONFIGFS_ATTR(int_maxburst, S_IRUGO | S_IWUSR, | ||
| 1644 | f_ss_opts_int_maxburst_show, | ||
| 1645 | f_ss_opts_int_maxburst_store); | ||
| 1646 | |||
| 1647 | static struct configfs_attribute *ss_attrs[] = { | 1182 | static struct configfs_attribute *ss_attrs[] = { |
| 1648 | &f_ss_opts_pattern.attr, | 1183 | &f_ss_opts_pattern.attr, |
| 1649 | &f_ss_opts_isoc_interval.attr, | 1184 | &f_ss_opts_isoc_interval.attr, |
| @@ -1651,10 +1186,6 @@ static struct configfs_attribute *ss_attrs[] = { | |||
| 1651 | &f_ss_opts_isoc_mult.attr, | 1186 | &f_ss_opts_isoc_mult.attr, |
| 1652 | &f_ss_opts_isoc_maxburst.attr, | 1187 | &f_ss_opts_isoc_maxburst.attr, |
| 1653 | &f_ss_opts_bulk_buflen.attr, | 1188 | &f_ss_opts_bulk_buflen.attr, |
| 1654 | &f_ss_opts_int_interval.attr, | ||
| 1655 | &f_ss_opts_int_maxpacket.attr, | ||
| 1656 | &f_ss_opts_int_mult.attr, | ||
| 1657 | &f_ss_opts_int_maxburst.attr, | ||
| 1658 | NULL, | 1189 | NULL, |
| 1659 | }; | 1190 | }; |
| 1660 | 1191 | ||
| @@ -1684,8 +1215,6 @@ static struct usb_function_instance *source_sink_alloc_inst(void) | |||
| 1684 | ss_opts->isoc_interval = GZERO_ISOC_INTERVAL; | 1215 | ss_opts->isoc_interval = GZERO_ISOC_INTERVAL; |
| 1685 | ss_opts->isoc_maxpacket = GZERO_ISOC_MAXPACKET; | 1216 | ss_opts->isoc_maxpacket = GZERO_ISOC_MAXPACKET; |
| 1686 | ss_opts->bulk_buflen = GZERO_BULK_BUFLEN; | 1217 | ss_opts->bulk_buflen = GZERO_BULK_BUFLEN; |
| 1687 | ss_opts->int_interval = GZERO_INT_INTERVAL; | ||
| 1688 | ss_opts->int_maxpacket = GZERO_INT_MAXPACKET; | ||
| 1689 | 1218 | ||
| 1690 | config_group_init_type_name(&ss_opts->func_inst.group, "", | 1219 | config_group_init_type_name(&ss_opts->func_inst.group, "", |
| 1691 | &ss_func_type); | 1220 | &ss_func_type); |
diff --git a/drivers/usb/gadget/function/g_zero.h b/drivers/usb/gadget/function/g_zero.h index 2ce28b9d97cc..15f180904f8a 100644 --- a/drivers/usb/gadget/function/g_zero.h +++ b/drivers/usb/gadget/function/g_zero.h | |||
| @@ -10,8 +10,6 @@ | |||
| 10 | #define GZERO_QLEN 32 | 10 | #define GZERO_QLEN 32 |
| 11 | #define GZERO_ISOC_INTERVAL 4 | 11 | #define GZERO_ISOC_INTERVAL 4 |
| 12 | #define GZERO_ISOC_MAXPACKET 1024 | 12 | #define GZERO_ISOC_MAXPACKET 1024 |
| 13 | #define GZERO_INT_INTERVAL 1 /* Default interrupt interval = 1 ms */ | ||
| 14 | #define GZERO_INT_MAXPACKET 1024 | ||
| 15 | 13 | ||
| 16 | struct usb_zero_options { | 14 | struct usb_zero_options { |
| 17 | unsigned pattern; | 15 | unsigned pattern; |
| @@ -19,10 +17,6 @@ struct usb_zero_options { | |||
| 19 | unsigned isoc_maxpacket; | 17 | unsigned isoc_maxpacket; |
| 20 | unsigned isoc_mult; | 18 | unsigned isoc_mult; |
| 21 | unsigned isoc_maxburst; | 19 | unsigned isoc_maxburst; |
| 22 | unsigned int_interval; /* In ms */ | ||
| 23 | unsigned int_maxpacket; | ||
| 24 | unsigned int_mult; | ||
| 25 | unsigned int_maxburst; | ||
| 26 | unsigned bulk_buflen; | 20 | unsigned bulk_buflen; |
| 27 | unsigned qlen; | 21 | unsigned qlen; |
| 28 | }; | 22 | }; |
| @@ -34,10 +28,6 @@ struct f_ss_opts { | |||
| 34 | unsigned isoc_maxpacket; | 28 | unsigned isoc_maxpacket; |
| 35 | unsigned isoc_mult; | 29 | unsigned isoc_mult; |
| 36 | unsigned isoc_maxburst; | 30 | unsigned isoc_maxburst; |
| 37 | unsigned int_interval; /* In ms */ | ||
| 38 | unsigned int_maxpacket; | ||
| 39 | unsigned int_mult; | ||
| 40 | unsigned int_maxburst; | ||
| 41 | unsigned bulk_buflen; | 31 | unsigned bulk_buflen; |
| 42 | 32 | ||
| 43 | /* | 33 | /* |
| @@ -72,7 +62,6 @@ int lb_modinit(void); | |||
| 72 | void free_ep_req(struct usb_ep *ep, struct usb_request *req); | 62 | void free_ep_req(struct usb_ep *ep, struct usb_request *req); |
| 73 | void disable_endpoints(struct usb_composite_dev *cdev, | 63 | void disable_endpoints(struct usb_composite_dev *cdev, |
| 74 | struct usb_ep *in, struct usb_ep *out, | 64 | struct usb_ep *in, struct usb_ep *out, |
| 75 | struct usb_ep *iso_in, struct usb_ep *iso_out, | 65 | struct usb_ep *iso_in, struct usb_ep *iso_out); |
| 76 | struct usb_ep *int_in, struct usb_ep *int_out); | ||
| 77 | 66 | ||
| 78 | #endif /* __G_ZERO_H */ | 67 | #endif /* __G_ZERO_H */ |
