diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2012-03-19 20:02:01 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2012-03-19 20:02:01 -0400 |
commit | 10ce3cc919f50c2043b41ca968b43c26a3672600 (patch) | |
tree | ea409366a5208aced495bc0516a08b81fd43222e /drivers/usb/core | |
parent | 24e3e5ae1e4c2a3a32f5b1f96b4e3fd721806acd (diff) | |
parent | 5c6a7a62c130afef3d61c1dee153012231ff5cd9 (diff) |
Merge branch 'next' into for-linus
Diffstat (limited to 'drivers/usb/core')
-rw-r--r-- | drivers/usb/core/devio.c | 191 | ||||
-rw-r--r-- | drivers/usb/core/driver.c | 36 | ||||
-rw-r--r-- | drivers/usb/core/file.c | 2 | ||||
-rw-r--r-- | drivers/usb/core/hcd-pci.c | 9 | ||||
-rw-r--r-- | drivers/usb/core/hcd.c | 37 | ||||
-rw-r--r-- | drivers/usb/core/hub.c | 127 | ||||
-rw-r--r-- | drivers/usb/core/inode.c | 31 | ||||
-rw-r--r-- | drivers/usb/core/quirks.c | 5 | ||||
-rw-r--r-- | drivers/usb/core/sysfs.c | 4 | ||||
-rw-r--r-- | drivers/usb/core/usb.c | 4 | ||||
-rw-r--r-- | drivers/usb/core/usb.h | 14 |
11 files changed, 242 insertions, 218 deletions
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c index e3beaf229ee3..8df4b76465ac 100644 --- a/drivers/usb/core/devio.c +++ b/drivers/usb/core/devio.c | |||
@@ -86,13 +86,14 @@ struct async { | |||
86 | void __user *userbuffer; | 86 | void __user *userbuffer; |
87 | void __user *userurb; | 87 | void __user *userurb; |
88 | struct urb *urb; | 88 | struct urb *urb; |
89 | unsigned int mem_usage; | ||
89 | int status; | 90 | int status; |
90 | u32 secid; | 91 | u32 secid; |
91 | u8 bulk_addr; | 92 | u8 bulk_addr; |
92 | u8 bulk_status; | 93 | u8 bulk_status; |
93 | }; | 94 | }; |
94 | 95 | ||
95 | static int usbfs_snoop; | 96 | static bool usbfs_snoop; |
96 | module_param(usbfs_snoop, bool, S_IRUGO | S_IWUSR); | 97 | module_param(usbfs_snoop, bool, S_IRUGO | S_IWUSR); |
97 | MODULE_PARM_DESC(usbfs_snoop, "true to log all usbfs traffic"); | 98 | MODULE_PARM_DESC(usbfs_snoop, "true to log all usbfs traffic"); |
98 | 99 | ||
@@ -108,8 +109,44 @@ enum snoop_when { | |||
108 | 109 | ||
109 | #define USB_DEVICE_DEV MKDEV(USB_DEVICE_MAJOR, 0) | 110 | #define USB_DEVICE_DEV MKDEV(USB_DEVICE_MAJOR, 0) |
110 | 111 | ||
111 | #define MAX_USBFS_BUFFER_SIZE 16384 | 112 | /* Limit on the total amount of memory we can allocate for transfers */ |
113 | static unsigned usbfs_memory_mb = 16; | ||
114 | module_param(usbfs_memory_mb, uint, 0644); | ||
115 | MODULE_PARM_DESC(usbfs_memory_mb, | ||
116 | "maximum MB allowed for usbfs buffers (0 = no limit)"); | ||
112 | 117 | ||
118 | /* Hard limit, necessary to avoid aithmetic overflow */ | ||
119 | #define USBFS_XFER_MAX (UINT_MAX / 2 - 1000000) | ||
120 | |||
121 | static atomic_t usbfs_memory_usage; /* Total memory currently allocated */ | ||
122 | |||
123 | /* Check whether it's okay to allocate more memory for a transfer */ | ||
124 | static int usbfs_increase_memory_usage(unsigned amount) | ||
125 | { | ||
126 | unsigned lim; | ||
127 | |||
128 | /* | ||
129 | * Convert usbfs_memory_mb to bytes, avoiding overflows. | ||
130 | * 0 means use the hard limit (effectively unlimited). | ||
131 | */ | ||
132 | lim = ACCESS_ONCE(usbfs_memory_mb); | ||
133 | if (lim == 0 || lim > (USBFS_XFER_MAX >> 20)) | ||
134 | lim = USBFS_XFER_MAX; | ||
135 | else | ||
136 | lim <<= 20; | ||
137 | |||
138 | atomic_add(amount, &usbfs_memory_usage); | ||
139 | if (atomic_read(&usbfs_memory_usage) <= lim) | ||
140 | return 0; | ||
141 | atomic_sub(amount, &usbfs_memory_usage); | ||
142 | return -ENOMEM; | ||
143 | } | ||
144 | |||
145 | /* Memory for a transfer is being deallocated */ | ||
146 | static void usbfs_decrease_memory_usage(unsigned amount) | ||
147 | { | ||
148 | atomic_sub(amount, &usbfs_memory_usage); | ||
149 | } | ||
113 | 150 | ||
114 | static int connected(struct dev_state *ps) | 151 | static int connected(struct dev_state *ps) |
115 | { | 152 | { |
@@ -249,10 +286,12 @@ static struct async *alloc_async(unsigned int numisoframes) | |||
249 | static void free_async(struct async *as) | 286 | static void free_async(struct async *as) |
250 | { | 287 | { |
251 | put_pid(as->pid); | 288 | put_pid(as->pid); |
252 | put_cred(as->cred); | 289 | if (as->cred) |
290 | put_cred(as->cred); | ||
253 | kfree(as->urb->transfer_buffer); | 291 | kfree(as->urb->transfer_buffer); |
254 | kfree(as->urb->setup_packet); | 292 | kfree(as->urb->setup_packet); |
255 | usb_free_urb(as->urb); | 293 | usb_free_urb(as->urb); |
294 | usbfs_decrease_memory_usage(as->mem_usage); | ||
256 | kfree(as); | 295 | kfree(as); |
257 | } | 296 | } |
258 | 297 | ||
@@ -792,9 +831,15 @@ static int proc_control(struct dev_state *ps, void __user *arg) | |||
792 | wLength = ctrl.wLength; /* To suppress 64k PAGE_SIZE warning */ | 831 | wLength = ctrl.wLength; /* To suppress 64k PAGE_SIZE warning */ |
793 | if (wLength > PAGE_SIZE) | 832 | if (wLength > PAGE_SIZE) |
794 | return -EINVAL; | 833 | return -EINVAL; |
834 | ret = usbfs_increase_memory_usage(PAGE_SIZE + sizeof(struct urb) + | ||
835 | sizeof(struct usb_ctrlrequest)); | ||
836 | if (ret) | ||
837 | return ret; | ||
795 | tbuf = (unsigned char *)__get_free_page(GFP_KERNEL); | 838 | tbuf = (unsigned char *)__get_free_page(GFP_KERNEL); |
796 | if (!tbuf) | 839 | if (!tbuf) { |
797 | return -ENOMEM; | 840 | ret = -ENOMEM; |
841 | goto done; | ||
842 | } | ||
798 | tmo = ctrl.timeout; | 843 | tmo = ctrl.timeout; |
799 | snoop(&dev->dev, "control urb: bRequestType=%02x " | 844 | snoop(&dev->dev, "control urb: bRequestType=%02x " |
800 | "bRequest=%02x wValue=%04x " | 845 | "bRequest=%02x wValue=%04x " |
@@ -806,8 +851,8 @@ static int proc_control(struct dev_state *ps, void __user *arg) | |||
806 | if (ctrl.bRequestType & 0x80) { | 851 | if (ctrl.bRequestType & 0x80) { |
807 | if (ctrl.wLength && !access_ok(VERIFY_WRITE, ctrl.data, | 852 | if (ctrl.wLength && !access_ok(VERIFY_WRITE, ctrl.data, |
808 | ctrl.wLength)) { | 853 | ctrl.wLength)) { |
809 | free_page((unsigned long)tbuf); | 854 | ret = -EINVAL; |
810 | return -EINVAL; | 855 | goto done; |
811 | } | 856 | } |
812 | pipe = usb_rcvctrlpipe(dev, 0); | 857 | pipe = usb_rcvctrlpipe(dev, 0); |
813 | snoop_urb(dev, NULL, pipe, ctrl.wLength, tmo, SUBMIT, NULL, 0); | 858 | snoop_urb(dev, NULL, pipe, ctrl.wLength, tmo, SUBMIT, NULL, 0); |
@@ -821,15 +866,15 @@ static int proc_control(struct dev_state *ps, void __user *arg) | |||
821 | tbuf, max(i, 0)); | 866 | tbuf, max(i, 0)); |
822 | if ((i > 0) && ctrl.wLength) { | 867 | if ((i > 0) && ctrl.wLength) { |
823 | if (copy_to_user(ctrl.data, tbuf, i)) { | 868 | if (copy_to_user(ctrl.data, tbuf, i)) { |
824 | free_page((unsigned long)tbuf); | 869 | ret = -EFAULT; |
825 | return -EFAULT; | 870 | goto done; |
826 | } | 871 | } |
827 | } | 872 | } |
828 | } else { | 873 | } else { |
829 | if (ctrl.wLength) { | 874 | if (ctrl.wLength) { |
830 | if (copy_from_user(tbuf, ctrl.data, ctrl.wLength)) { | 875 | if (copy_from_user(tbuf, ctrl.data, ctrl.wLength)) { |
831 | free_page((unsigned long)tbuf); | 876 | ret = -EFAULT; |
832 | return -EFAULT; | 877 | goto done; |
833 | } | 878 | } |
834 | } | 879 | } |
835 | pipe = usb_sndctrlpipe(dev, 0); | 880 | pipe = usb_sndctrlpipe(dev, 0); |
@@ -843,14 +888,18 @@ static int proc_control(struct dev_state *ps, void __user *arg) | |||
843 | usb_lock_device(dev); | 888 | usb_lock_device(dev); |
844 | snoop_urb(dev, NULL, pipe, max(i, 0), min(i, 0), COMPLETE, NULL, 0); | 889 | snoop_urb(dev, NULL, pipe, max(i, 0), min(i, 0), COMPLETE, NULL, 0); |
845 | } | 890 | } |
846 | free_page((unsigned long)tbuf); | ||
847 | if (i < 0 && i != -EPIPE) { | 891 | if (i < 0 && i != -EPIPE) { |
848 | dev_printk(KERN_DEBUG, &dev->dev, "usbfs: USBDEVFS_CONTROL " | 892 | dev_printk(KERN_DEBUG, &dev->dev, "usbfs: USBDEVFS_CONTROL " |
849 | "failed cmd %s rqt %u rq %u len %u ret %d\n", | 893 | "failed cmd %s rqt %u rq %u len %u ret %d\n", |
850 | current->comm, ctrl.bRequestType, ctrl.bRequest, | 894 | current->comm, ctrl.bRequestType, ctrl.bRequest, |
851 | ctrl.wLength, i); | 895 | ctrl.wLength, i); |
852 | } | 896 | } |
853 | return i; | 897 | ret = i; |
898 | done: | ||
899 | free_page((unsigned long) tbuf); | ||
900 | usbfs_decrease_memory_usage(PAGE_SIZE + sizeof(struct urb) + | ||
901 | sizeof(struct usb_ctrlrequest)); | ||
902 | return ret; | ||
854 | } | 903 | } |
855 | 904 | ||
856 | static int proc_bulk(struct dev_state *ps, void __user *arg) | 905 | static int proc_bulk(struct dev_state *ps, void __user *arg) |
@@ -877,15 +926,20 @@ static int proc_bulk(struct dev_state *ps, void __user *arg) | |||
877 | if (!usb_maxpacket(dev, pipe, !(bulk.ep & USB_DIR_IN))) | 926 | if (!usb_maxpacket(dev, pipe, !(bulk.ep & USB_DIR_IN))) |
878 | return -EINVAL; | 927 | return -EINVAL; |
879 | len1 = bulk.len; | 928 | len1 = bulk.len; |
880 | if (len1 > MAX_USBFS_BUFFER_SIZE) | 929 | if (len1 >= USBFS_XFER_MAX) |
881 | return -EINVAL; | 930 | return -EINVAL; |
882 | if (!(tbuf = kmalloc(len1, GFP_KERNEL))) | 931 | ret = usbfs_increase_memory_usage(len1 + sizeof(struct urb)); |
883 | return -ENOMEM; | 932 | if (ret) |
933 | return ret; | ||
934 | if (!(tbuf = kmalloc(len1, GFP_KERNEL))) { | ||
935 | ret = -ENOMEM; | ||
936 | goto done; | ||
937 | } | ||
884 | tmo = bulk.timeout; | 938 | tmo = bulk.timeout; |
885 | if (bulk.ep & 0x80) { | 939 | if (bulk.ep & 0x80) { |
886 | if (len1 && !access_ok(VERIFY_WRITE, bulk.data, len1)) { | 940 | if (len1 && !access_ok(VERIFY_WRITE, bulk.data, len1)) { |
887 | kfree(tbuf); | 941 | ret = -EINVAL; |
888 | return -EINVAL; | 942 | goto done; |
889 | } | 943 | } |
890 | snoop_urb(dev, NULL, pipe, len1, tmo, SUBMIT, NULL, 0); | 944 | snoop_urb(dev, NULL, pipe, len1, tmo, SUBMIT, NULL, 0); |
891 | 945 | ||
@@ -896,15 +950,15 @@ static int proc_bulk(struct dev_state *ps, void __user *arg) | |||
896 | 950 | ||
897 | if (!i && len2) { | 951 | if (!i && len2) { |
898 | if (copy_to_user(bulk.data, tbuf, len2)) { | 952 | if (copy_to_user(bulk.data, tbuf, len2)) { |
899 | kfree(tbuf); | 953 | ret = -EFAULT; |
900 | return -EFAULT; | 954 | goto done; |
901 | } | 955 | } |
902 | } | 956 | } |
903 | } else { | 957 | } else { |
904 | if (len1) { | 958 | if (len1) { |
905 | if (copy_from_user(tbuf, bulk.data, len1)) { | 959 | if (copy_from_user(tbuf, bulk.data, len1)) { |
906 | kfree(tbuf); | 960 | ret = -EFAULT; |
907 | return -EFAULT; | 961 | goto done; |
908 | } | 962 | } |
909 | } | 963 | } |
910 | snoop_urb(dev, NULL, pipe, len1, tmo, SUBMIT, tbuf, len1); | 964 | snoop_urb(dev, NULL, pipe, len1, tmo, SUBMIT, tbuf, len1); |
@@ -914,10 +968,11 @@ static int proc_bulk(struct dev_state *ps, void __user *arg) | |||
914 | usb_lock_device(dev); | 968 | usb_lock_device(dev); |
915 | snoop_urb(dev, NULL, pipe, len2, i, COMPLETE, NULL, 0); | 969 | snoop_urb(dev, NULL, pipe, len2, i, COMPLETE, NULL, 0); |
916 | } | 970 | } |
971 | ret = (i < 0 ? i : len2); | ||
972 | done: | ||
917 | kfree(tbuf); | 973 | kfree(tbuf); |
918 | if (i < 0) | 974 | usbfs_decrease_memory_usage(len1 + sizeof(struct urb)); |
919 | return i; | 975 | return ret; |
920 | return len2; | ||
921 | } | 976 | } |
922 | 977 | ||
923 | static int proc_resetep(struct dev_state *ps, void __user *arg) | 978 | static int proc_resetep(struct dev_state *ps, void __user *arg) |
@@ -1062,7 +1117,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, | |||
1062 | { | 1117 | { |
1063 | struct usbdevfs_iso_packet_desc *isopkt = NULL; | 1118 | struct usbdevfs_iso_packet_desc *isopkt = NULL; |
1064 | struct usb_host_endpoint *ep; | 1119 | struct usb_host_endpoint *ep; |
1065 | struct async *as; | 1120 | struct async *as = NULL; |
1066 | struct usb_ctrlrequest *dr = NULL; | 1121 | struct usb_ctrlrequest *dr = NULL; |
1067 | unsigned int u, totlen, isofrmlen; | 1122 | unsigned int u, totlen, isofrmlen; |
1068 | int ret, ifnum = -1; | 1123 | int ret, ifnum = -1; |
@@ -1095,32 +1150,30 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, | |||
1095 | } | 1150 | } |
1096 | if (!ep) | 1151 | if (!ep) |
1097 | return -ENOENT; | 1152 | return -ENOENT; |
1153 | |||
1154 | u = 0; | ||
1098 | switch(uurb->type) { | 1155 | switch(uurb->type) { |
1099 | case USBDEVFS_URB_TYPE_CONTROL: | 1156 | case USBDEVFS_URB_TYPE_CONTROL: |
1100 | if (!usb_endpoint_xfer_control(&ep->desc)) | 1157 | if (!usb_endpoint_xfer_control(&ep->desc)) |
1101 | return -EINVAL; | 1158 | return -EINVAL; |
1102 | /* min 8 byte setup packet, | 1159 | /* min 8 byte setup packet */ |
1103 | * max 8 byte setup plus an arbitrary data stage */ | 1160 | if (uurb->buffer_length < 8) |
1104 | if (uurb->buffer_length < 8 || | ||
1105 | uurb->buffer_length > (8 + MAX_USBFS_BUFFER_SIZE)) | ||
1106 | return -EINVAL; | 1161 | return -EINVAL; |
1107 | dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_KERNEL); | 1162 | dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_KERNEL); |
1108 | if (!dr) | 1163 | if (!dr) |
1109 | return -ENOMEM; | 1164 | return -ENOMEM; |
1110 | if (copy_from_user(dr, uurb->buffer, 8)) { | 1165 | if (copy_from_user(dr, uurb->buffer, 8)) { |
1111 | kfree(dr); | 1166 | ret = -EFAULT; |
1112 | return -EFAULT; | 1167 | goto error; |
1113 | } | 1168 | } |
1114 | if (uurb->buffer_length < (le16_to_cpup(&dr->wLength) + 8)) { | 1169 | if (uurb->buffer_length < (le16_to_cpup(&dr->wLength) + 8)) { |
1115 | kfree(dr); | 1170 | ret = -EINVAL; |
1116 | return -EINVAL; | 1171 | goto error; |
1117 | } | 1172 | } |
1118 | ret = check_ctrlrecip(ps, dr->bRequestType, dr->bRequest, | 1173 | ret = check_ctrlrecip(ps, dr->bRequestType, dr->bRequest, |
1119 | le16_to_cpup(&dr->wIndex)); | 1174 | le16_to_cpup(&dr->wIndex)); |
1120 | if (ret) { | 1175 | if (ret) |
1121 | kfree(dr); | 1176 | goto error; |
1122 | return ret; | ||
1123 | } | ||
1124 | uurb->number_of_packets = 0; | 1177 | uurb->number_of_packets = 0; |
1125 | uurb->buffer_length = le16_to_cpup(&dr->wLength); | 1178 | uurb->buffer_length = le16_to_cpup(&dr->wLength); |
1126 | uurb->buffer += 8; | 1179 | uurb->buffer += 8; |
@@ -1138,6 +1191,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, | |||
1138 | __le16_to_cpup(&dr->wValue), | 1191 | __le16_to_cpup(&dr->wValue), |
1139 | __le16_to_cpup(&dr->wIndex), | 1192 | __le16_to_cpup(&dr->wIndex), |
1140 | __le16_to_cpup(&dr->wLength)); | 1193 | __le16_to_cpup(&dr->wLength)); |
1194 | u = sizeof(struct usb_ctrlrequest); | ||
1141 | break; | 1195 | break; |
1142 | 1196 | ||
1143 | case USBDEVFS_URB_TYPE_BULK: | 1197 | case USBDEVFS_URB_TYPE_BULK: |
@@ -1151,8 +1205,6 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, | |||
1151 | goto interrupt_urb; | 1205 | goto interrupt_urb; |
1152 | } | 1206 | } |
1153 | uurb->number_of_packets = 0; | 1207 | uurb->number_of_packets = 0; |
1154 | if (uurb->buffer_length > MAX_USBFS_BUFFER_SIZE) | ||
1155 | return -EINVAL; | ||
1156 | break; | 1208 | break; |
1157 | 1209 | ||
1158 | case USBDEVFS_URB_TYPE_INTERRUPT: | 1210 | case USBDEVFS_URB_TYPE_INTERRUPT: |
@@ -1160,8 +1212,6 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, | |||
1160 | return -EINVAL; | 1212 | return -EINVAL; |
1161 | interrupt_urb: | 1213 | interrupt_urb: |
1162 | uurb->number_of_packets = 0; | 1214 | uurb->number_of_packets = 0; |
1163 | if (uurb->buffer_length > MAX_USBFS_BUFFER_SIZE) | ||
1164 | return -EINVAL; | ||
1165 | break; | 1215 | break; |
1166 | 1216 | ||
1167 | case USBDEVFS_URB_TYPE_ISO: | 1217 | case USBDEVFS_URB_TYPE_ISO: |
@@ -1176,50 +1226,53 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, | |||
1176 | if (!(isopkt = kmalloc(isofrmlen, GFP_KERNEL))) | 1226 | if (!(isopkt = kmalloc(isofrmlen, GFP_KERNEL))) |
1177 | return -ENOMEM; | 1227 | return -ENOMEM; |
1178 | if (copy_from_user(isopkt, iso_frame_desc, isofrmlen)) { | 1228 | if (copy_from_user(isopkt, iso_frame_desc, isofrmlen)) { |
1179 | kfree(isopkt); | 1229 | ret = -EFAULT; |
1180 | return -EFAULT; | 1230 | goto error; |
1181 | } | 1231 | } |
1182 | for (totlen = u = 0; u < uurb->number_of_packets; u++) { | 1232 | for (totlen = u = 0; u < uurb->number_of_packets; u++) { |
1183 | /* arbitrary limit, | 1233 | /* arbitrary limit, |
1184 | * sufficient for USB 2.0 high-bandwidth iso */ | 1234 | * sufficient for USB 2.0 high-bandwidth iso */ |
1185 | if (isopkt[u].length > 8192) { | 1235 | if (isopkt[u].length > 8192) { |
1186 | kfree(isopkt); | 1236 | ret = -EINVAL; |
1187 | return -EINVAL; | 1237 | goto error; |
1188 | } | 1238 | } |
1189 | totlen += isopkt[u].length; | 1239 | totlen += isopkt[u].length; |
1190 | } | 1240 | } |
1191 | /* 3072 * 64 microframes */ | 1241 | u *= sizeof(struct usb_iso_packet_descriptor); |
1192 | if (totlen > 196608) { | ||
1193 | kfree(isopkt); | ||
1194 | return -EINVAL; | ||
1195 | } | ||
1196 | uurb->buffer_length = totlen; | 1242 | uurb->buffer_length = totlen; |
1197 | break; | 1243 | break; |
1198 | 1244 | ||
1199 | default: | 1245 | default: |
1200 | return -EINVAL; | 1246 | return -EINVAL; |
1201 | } | 1247 | } |
1248 | |||
1249 | if (uurb->buffer_length >= USBFS_XFER_MAX) { | ||
1250 | ret = -EINVAL; | ||
1251 | goto error; | ||
1252 | } | ||
1202 | if (uurb->buffer_length > 0 && | 1253 | if (uurb->buffer_length > 0 && |
1203 | !access_ok(is_in ? VERIFY_WRITE : VERIFY_READ, | 1254 | !access_ok(is_in ? VERIFY_WRITE : VERIFY_READ, |
1204 | uurb->buffer, uurb->buffer_length)) { | 1255 | uurb->buffer, uurb->buffer_length)) { |
1205 | kfree(isopkt); | 1256 | ret = -EFAULT; |
1206 | kfree(dr); | 1257 | goto error; |
1207 | return -EFAULT; | ||
1208 | } | 1258 | } |
1209 | as = alloc_async(uurb->number_of_packets); | 1259 | as = alloc_async(uurb->number_of_packets); |
1210 | if (!as) { | 1260 | if (!as) { |
1211 | kfree(isopkt); | 1261 | ret = -ENOMEM; |
1212 | kfree(dr); | 1262 | goto error; |
1213 | return -ENOMEM; | ||
1214 | } | 1263 | } |
1264 | u += sizeof(struct async) + sizeof(struct urb) + uurb->buffer_length; | ||
1265 | ret = usbfs_increase_memory_usage(u); | ||
1266 | if (ret) | ||
1267 | goto error; | ||
1268 | as->mem_usage = u; | ||
1269 | |||
1215 | if (uurb->buffer_length > 0) { | 1270 | if (uurb->buffer_length > 0) { |
1216 | as->urb->transfer_buffer = kmalloc(uurb->buffer_length, | 1271 | as->urb->transfer_buffer = kmalloc(uurb->buffer_length, |
1217 | GFP_KERNEL); | 1272 | GFP_KERNEL); |
1218 | if (!as->urb->transfer_buffer) { | 1273 | if (!as->urb->transfer_buffer) { |
1219 | kfree(isopkt); | 1274 | ret = -ENOMEM; |
1220 | kfree(dr); | 1275 | goto error; |
1221 | free_async(as); | ||
1222 | return -ENOMEM; | ||
1223 | } | 1276 | } |
1224 | /* Isochronous input data may end up being discontiguous | 1277 | /* Isochronous input data may end up being discontiguous |
1225 | * if some of the packets are short. Clear the buffer so | 1278 | * if some of the packets are short. Clear the buffer so |
@@ -1253,6 +1306,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, | |||
1253 | 1306 | ||
1254 | as->urb->transfer_buffer_length = uurb->buffer_length; | 1307 | as->urb->transfer_buffer_length = uurb->buffer_length; |
1255 | as->urb->setup_packet = (unsigned char *)dr; | 1308 | as->urb->setup_packet = (unsigned char *)dr; |
1309 | dr = NULL; | ||
1256 | as->urb->start_frame = uurb->start_frame; | 1310 | as->urb->start_frame = uurb->start_frame; |
1257 | as->urb->number_of_packets = uurb->number_of_packets; | 1311 | as->urb->number_of_packets = uurb->number_of_packets; |
1258 | if (uurb->type == USBDEVFS_URB_TYPE_ISO || | 1312 | if (uurb->type == USBDEVFS_URB_TYPE_ISO || |
@@ -1268,6 +1322,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, | |||
1268 | totlen += isopkt[u].length; | 1322 | totlen += isopkt[u].length; |
1269 | } | 1323 | } |
1270 | kfree(isopkt); | 1324 | kfree(isopkt); |
1325 | isopkt = NULL; | ||
1271 | as->ps = ps; | 1326 | as->ps = ps; |
1272 | as->userurb = arg; | 1327 | as->userurb = arg; |
1273 | if (is_in && uurb->buffer_length > 0) | 1328 | if (is_in && uurb->buffer_length > 0) |
@@ -1282,8 +1337,8 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, | |||
1282 | if (!is_in && uurb->buffer_length > 0) { | 1337 | if (!is_in && uurb->buffer_length > 0) { |
1283 | if (copy_from_user(as->urb->transfer_buffer, uurb->buffer, | 1338 | if (copy_from_user(as->urb->transfer_buffer, uurb->buffer, |
1284 | uurb->buffer_length)) { | 1339 | uurb->buffer_length)) { |
1285 | free_async(as); | 1340 | ret = -EFAULT; |
1286 | return -EFAULT; | 1341 | goto error; |
1287 | } | 1342 | } |
1288 | } | 1343 | } |
1289 | snoop_urb(ps->dev, as->userurb, as->urb->pipe, | 1344 | snoop_urb(ps->dev, as->userurb, as->urb->pipe, |
@@ -1329,10 +1384,16 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, | |||
1329 | snoop_urb(ps->dev, as->userurb, as->urb->pipe, | 1384 | snoop_urb(ps->dev, as->userurb, as->urb->pipe, |
1330 | 0, ret, COMPLETE, NULL, 0); | 1385 | 0, ret, COMPLETE, NULL, 0); |
1331 | async_removepending(as); | 1386 | async_removepending(as); |
1332 | free_async(as); | 1387 | goto error; |
1333 | return ret; | ||
1334 | } | 1388 | } |
1335 | return 0; | 1389 | return 0; |
1390 | |||
1391 | error: | ||
1392 | kfree(isopkt); | ||
1393 | kfree(dr); | ||
1394 | if (as) | ||
1395 | free_async(as); | ||
1396 | return ret; | ||
1336 | } | 1397 | } |
1337 | 1398 | ||
1338 | static int proc_submiturb(struct dev_state *ps, void __user *arg) | 1399 | static int proc_submiturb(struct dev_state *ps, void __user *arg) |
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c index 45887a0ff873..d40ff9568813 100644 --- a/drivers/usb/core/driver.c +++ b/drivers/usb/core/driver.c | |||
@@ -45,10 +45,12 @@ ssize_t usb_store_new_id(struct usb_dynids *dynids, | |||
45 | struct usb_dynid *dynid; | 45 | struct usb_dynid *dynid; |
46 | u32 idVendor = 0; | 46 | u32 idVendor = 0; |
47 | u32 idProduct = 0; | 47 | u32 idProduct = 0; |
48 | unsigned int bInterfaceClass = 0; | ||
48 | int fields = 0; | 49 | int fields = 0; |
49 | int retval = 0; | 50 | int retval = 0; |
50 | 51 | ||
51 | fields = sscanf(buf, "%x %x", &idVendor, &idProduct); | 52 | fields = sscanf(buf, "%x %x %x", &idVendor, &idProduct, |
53 | &bInterfaceClass); | ||
52 | if (fields < 2) | 54 | if (fields < 2) |
53 | return -EINVAL; | 55 | return -EINVAL; |
54 | 56 | ||
@@ -60,6 +62,10 @@ ssize_t usb_store_new_id(struct usb_dynids *dynids, | |||
60 | dynid->id.idVendor = idVendor; | 62 | dynid->id.idVendor = idVendor; |
61 | dynid->id.idProduct = idProduct; | 63 | dynid->id.idProduct = idProduct; |
62 | dynid->id.match_flags = USB_DEVICE_ID_MATCH_DEVICE; | 64 | dynid->id.match_flags = USB_DEVICE_ID_MATCH_DEVICE; |
65 | if (fields == 3) { | ||
66 | dynid->id.bInterfaceClass = (u8)bInterfaceClass; | ||
67 | dynid->id.match_flags |= USB_DEVICE_ID_MATCH_INT_CLASS; | ||
68 | } | ||
63 | 69 | ||
64 | spin_lock(&dynids->lock); | 70 | spin_lock(&dynids->lock); |
65 | list_add_tail(&dynid->node, &dynids->list); | 71 | list_add_tail(&dynid->node, &dynids->list); |
@@ -1073,17 +1079,10 @@ static int usb_suspend_interface(struct usb_device *udev, | |||
1073 | goto done; | 1079 | goto done; |
1074 | driver = to_usb_driver(intf->dev.driver); | 1080 | driver = to_usb_driver(intf->dev.driver); |
1075 | 1081 | ||
1076 | if (driver->suspend) { | 1082 | /* at this time we know the driver supports suspend */ |
1077 | status = driver->suspend(intf, msg); | 1083 | status = driver->suspend(intf, msg); |
1078 | if (status && !PMSG_IS_AUTO(msg)) | 1084 | if (status && !PMSG_IS_AUTO(msg)) |
1079 | dev_err(&intf->dev, "%s error %d\n", | 1085 | dev_err(&intf->dev, "suspend error %d\n", status); |
1080 | "suspend", status); | ||
1081 | } else { | ||
1082 | /* Later we will unbind the driver and reprobe */ | ||
1083 | intf->needs_binding = 1; | ||
1084 | dev_warn(&intf->dev, "no %s for driver %s?\n", | ||
1085 | "suspend", driver->name); | ||
1086 | } | ||
1087 | 1086 | ||
1088 | done: | 1087 | done: |
1089 | dev_vdbg(&intf->dev, "%s: status %d\n", __func__, status); | 1088 | dev_vdbg(&intf->dev, "%s: status %d\n", __func__, status); |
@@ -1132,16 +1131,9 @@ static int usb_resume_interface(struct usb_device *udev, | |||
1132 | "reset_resume", driver->name); | 1131 | "reset_resume", driver->name); |
1133 | } | 1132 | } |
1134 | } else { | 1133 | } else { |
1135 | if (driver->resume) { | 1134 | status = driver->resume(intf); |
1136 | status = driver->resume(intf); | 1135 | if (status) |
1137 | if (status) | 1136 | dev_err(&intf->dev, "resume error %d\n", status); |
1138 | dev_err(&intf->dev, "%s error %d\n", | ||
1139 | "resume", status); | ||
1140 | } else { | ||
1141 | intf->needs_binding = 1; | ||
1142 | dev_warn(&intf->dev, "no %s for driver %s?\n", | ||
1143 | "resume", driver->name); | ||
1144 | } | ||
1145 | } | 1137 | } |
1146 | 1138 | ||
1147 | done: | 1139 | done: |
diff --git a/drivers/usb/core/file.c b/drivers/usb/core/file.c index 99458c843d60..d95760de9e8b 100644 --- a/drivers/usb/core/file.c +++ b/drivers/usb/core/file.c | |||
@@ -66,7 +66,7 @@ static struct usb_class { | |||
66 | struct class *class; | 66 | struct class *class; |
67 | } *usb_class; | 67 | } *usb_class; |
68 | 68 | ||
69 | static char *usb_devnode(struct device *dev, mode_t *mode) | 69 | static char *usb_devnode(struct device *dev, umode_t *mode) |
70 | { | 70 | { |
71 | struct usb_class_driver *drv; | 71 | struct usb_class_driver *drv; |
72 | 72 | ||
diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c index a004db35f6d0..81e2c0d9c17d 100644 --- a/drivers/usb/core/hcd-pci.c +++ b/drivers/usb/core/hcd-pci.c | |||
@@ -187,7 +187,10 @@ int usb_hcd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) | |||
187 | return -ENODEV; | 187 | return -ENODEV; |
188 | dev->current_state = PCI_D0; | 188 | dev->current_state = PCI_D0; |
189 | 189 | ||
190 | if (!dev->irq) { | 190 | /* The xHCI driver supports MSI and MSI-X, |
191 | * so don't fail if the BIOS doesn't provide a legacy IRQ. | ||
192 | */ | ||
193 | if (!dev->irq && (driver->flags & HCD_MASK) != HCD_USB3) { | ||
191 | dev_err(&dev->dev, | 194 | dev_err(&dev->dev, |
192 | "Found HC with no IRQ. Check BIOS/PCI %s setup!\n", | 195 | "Found HC with no IRQ. Check BIOS/PCI %s setup!\n", |
193 | pci_name(dev)); | 196 | pci_name(dev)); |
@@ -453,10 +456,6 @@ static int resume_common(struct device *dev, int event) | |||
453 | 456 | ||
454 | pci_set_master(pci_dev); | 457 | pci_set_master(pci_dev); |
455 | 458 | ||
456 | clear_bit(HCD_FLAG_SAW_IRQ, &hcd->flags); | ||
457 | if (hcd->shared_hcd) | ||
458 | clear_bit(HCD_FLAG_SAW_IRQ, &hcd->shared_hcd->flags); | ||
459 | |||
460 | if (hcd->driver->pci_resume && !HCD_DEAD(hcd)) { | 459 | if (hcd->driver->pci_resume && !HCD_DEAD(hcd)) { |
461 | if (event != PM_EVENT_AUTO_RESUME) | 460 | if (event != PM_EVENT_AUTO_RESUME) |
462 | wait_for_companions(pci_dev, hcd); | 461 | wait_for_companions(pci_dev, hcd); |
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index 13222d352a61..e1282328fc27 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c | |||
@@ -658,7 +658,7 @@ error: | |||
658 | len > offsetof(struct usb_device_descriptor, | 658 | len > offsetof(struct usb_device_descriptor, |
659 | bDeviceProtocol)) | 659 | bDeviceProtocol)) |
660 | ((struct usb_device_descriptor *) ubuf)-> | 660 | ((struct usb_device_descriptor *) ubuf)-> |
661 | bDeviceProtocol = 1; | 661 | bDeviceProtocol = USB_HUB_PR_HS_SINGLE_TT; |
662 | } | 662 | } |
663 | 663 | ||
664 | /* any errors get returned through the urb completion */ | 664 | /* any errors get returned through the urb completion */ |
@@ -1168,20 +1168,6 @@ int usb_hcd_check_unlink_urb(struct usb_hcd *hcd, struct urb *urb, | |||
1168 | if (urb->unlinked) | 1168 | if (urb->unlinked) |
1169 | return -EBUSY; | 1169 | return -EBUSY; |
1170 | urb->unlinked = status; | 1170 | urb->unlinked = status; |
1171 | |||
1172 | /* IRQ setup can easily be broken so that USB controllers | ||
1173 | * never get completion IRQs ... maybe even the ones we need to | ||
1174 | * finish unlinking the initial failed usb_set_address() | ||
1175 | * or device descriptor fetch. | ||
1176 | */ | ||
1177 | if (!HCD_SAW_IRQ(hcd) && !is_root_hub(urb->dev)) { | ||
1178 | dev_warn(hcd->self.controller, "Unlink after no-IRQ? " | ||
1179 | "Controller is probably using the wrong IRQ.\n"); | ||
1180 | set_bit(HCD_FLAG_SAW_IRQ, &hcd->flags); | ||
1181 | if (hcd->shared_hcd) | ||
1182 | set_bit(HCD_FLAG_SAW_IRQ, &hcd->shared_hcd->flags); | ||
1183 | } | ||
1184 | |||
1185 | return 0; | 1171 | return 0; |
1186 | } | 1172 | } |
1187 | EXPORT_SYMBOL_GPL(usb_hcd_check_unlink_urb); | 1173 | EXPORT_SYMBOL_GPL(usb_hcd_check_unlink_urb); |
@@ -1412,11 +1398,10 @@ int usb_hcd_map_urb_for_dma(struct usb_hcd *hcd, struct urb *urb, | |||
1412 | ret = -EAGAIN; | 1398 | ret = -EAGAIN; |
1413 | else | 1399 | else |
1414 | urb->transfer_flags |= URB_DMA_MAP_SG; | 1400 | urb->transfer_flags |= URB_DMA_MAP_SG; |
1415 | if (n != urb->num_sgs) { | 1401 | urb->num_mapped_sgs = n; |
1416 | urb->num_sgs = n; | 1402 | if (n != urb->num_sgs) |
1417 | urb->transfer_flags |= | 1403 | urb->transfer_flags |= |
1418 | URB_DMA_SG_COMBINED; | 1404 | URB_DMA_SG_COMBINED; |
1419 | } | ||
1420 | } else if (urb->sg) { | 1405 | } else if (urb->sg) { |
1421 | struct scatterlist *sg = urb->sg; | 1406 | struct scatterlist *sg = urb->sg; |
1422 | urb->transfer_dma = dma_map_page( | 1407 | urb->transfer_dma = dma_map_page( |
@@ -2148,16 +2133,12 @@ irqreturn_t usb_hcd_irq (int irq, void *__hcd) | |||
2148 | */ | 2133 | */ |
2149 | local_irq_save(flags); | 2134 | local_irq_save(flags); |
2150 | 2135 | ||
2151 | if (unlikely(HCD_DEAD(hcd) || !HCD_HW_ACCESSIBLE(hcd))) { | 2136 | if (unlikely(HCD_DEAD(hcd) || !HCD_HW_ACCESSIBLE(hcd))) |
2152 | rc = IRQ_NONE; | 2137 | rc = IRQ_NONE; |
2153 | } else if (hcd->driver->irq(hcd) == IRQ_NONE) { | 2138 | else if (hcd->driver->irq(hcd) == IRQ_NONE) |
2154 | rc = IRQ_NONE; | 2139 | rc = IRQ_NONE; |
2155 | } else { | 2140 | else |
2156 | set_bit(HCD_FLAG_SAW_IRQ, &hcd->flags); | ||
2157 | if (hcd->shared_hcd) | ||
2158 | set_bit(HCD_FLAG_SAW_IRQ, &hcd->shared_hcd->flags); | ||
2159 | rc = IRQ_HANDLED; | 2141 | rc = IRQ_HANDLED; |
2160 | } | ||
2161 | 2142 | ||
2162 | local_irq_restore(flags); | 2143 | local_irq_restore(flags); |
2163 | return rc; | 2144 | return rc; |
@@ -2466,8 +2447,10 @@ int usb_add_hcd(struct usb_hcd *hcd, | |||
2466 | && device_can_wakeup(&hcd->self.root_hub->dev)) | 2447 | && device_can_wakeup(&hcd->self.root_hub->dev)) |
2467 | dev_dbg(hcd->self.controller, "supports USB remote wakeup\n"); | 2448 | dev_dbg(hcd->self.controller, "supports USB remote wakeup\n"); |
2468 | 2449 | ||
2469 | /* enable irqs just before we start the controller */ | 2450 | /* enable irqs just before we start the controller, |
2470 | if (usb_hcd_is_primary_hcd(hcd)) { | 2451 | * if the BIOS provides legacy PCI irqs. |
2452 | */ | ||
2453 | if (usb_hcd_is_primary_hcd(hcd) && irqnum) { | ||
2471 | retval = usb_hcd_request_irqs(hcd, irqnum, irqflags); | 2454 | retval = usb_hcd_request_irqs(hcd, irqnum, irqflags); |
2472 | if (retval) | 2455 | if (retval) |
2473 | goto err_request_irq; | 2456 | goto err_request_irq; |
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 79781461eec9..265c2f675d04 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c | |||
@@ -84,7 +84,7 @@ struct usb_hub { | |||
84 | 84 | ||
85 | static inline int hub_is_superspeed(struct usb_device *hdev) | 85 | static inline int hub_is_superspeed(struct usb_device *hdev) |
86 | { | 86 | { |
87 | return (hdev->descriptor.bDeviceProtocol == 3); | 87 | return (hdev->descriptor.bDeviceProtocol == USB_HUB_PR_SS); |
88 | } | 88 | } |
89 | 89 | ||
90 | /* Protect struct usb_device->state and ->children members | 90 | /* Protect struct usb_device->state and ->children members |
@@ -102,7 +102,7 @@ static DECLARE_WAIT_QUEUE_HEAD(khubd_wait); | |||
102 | static struct task_struct *khubd_task; | 102 | static struct task_struct *khubd_task; |
103 | 103 | ||
104 | /* cycle leds on hubs that aren't blinking for attention */ | 104 | /* cycle leds on hubs that aren't blinking for attention */ |
105 | static int blinkenlights = 0; | 105 | static bool blinkenlights = 0; |
106 | module_param (blinkenlights, bool, S_IRUGO); | 106 | module_param (blinkenlights, bool, S_IRUGO); |
107 | MODULE_PARM_DESC (blinkenlights, "true to cycle leds on hubs"); | 107 | MODULE_PARM_DESC (blinkenlights, "true to cycle leds on hubs"); |
108 | 108 | ||
@@ -131,12 +131,12 @@ MODULE_PARM_DESC(initial_descriptor_timeout, | |||
131 | * otherwise the new scheme is used. If that fails and "use_both_schemes" | 131 | * otherwise the new scheme is used. If that fails and "use_both_schemes" |
132 | * is set, then the driver will make another attempt, using the other scheme. | 132 | * is set, then the driver will make another attempt, using the other scheme. |
133 | */ | 133 | */ |
134 | static int old_scheme_first = 0; | 134 | static bool old_scheme_first = 0; |
135 | module_param(old_scheme_first, bool, S_IRUGO | S_IWUSR); | 135 | module_param(old_scheme_first, bool, S_IRUGO | S_IWUSR); |
136 | MODULE_PARM_DESC(old_scheme_first, | 136 | MODULE_PARM_DESC(old_scheme_first, |
137 | "start with the old device initialization scheme"); | 137 | "start with the old device initialization scheme"); |
138 | 138 | ||
139 | static int use_both_schemes = 1; | 139 | static bool use_both_schemes = 1; |
140 | module_param(use_both_schemes, bool, S_IRUGO | S_IWUSR); | 140 | module_param(use_both_schemes, bool, S_IRUGO | S_IWUSR); |
141 | MODULE_PARM_DESC(use_both_schemes, | 141 | MODULE_PARM_DESC(use_both_schemes, |
142 | "try the other device initialization scheme if the " | 142 | "try the other device initialization scheme if the " |
@@ -705,10 +705,26 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type) | |||
705 | if (type == HUB_INIT3) | 705 | if (type == HUB_INIT3) |
706 | goto init3; | 706 | goto init3; |
707 | 707 | ||
708 | /* After a resume, port power should still be on. | 708 | /* The superspeed hub except for root hub has to use Hub Depth |
709 | * value as an offset into the route string to locate the bits | ||
710 | * it uses to determine the downstream port number. So hub driver | ||
711 | * should send a set hub depth request to superspeed hub after | ||
712 | * the superspeed hub is set configuration in initialization or | ||
713 | * reset procedure. | ||
714 | * | ||
715 | * After a resume, port power should still be on. | ||
709 | * For any other type of activation, turn it on. | 716 | * For any other type of activation, turn it on. |
710 | */ | 717 | */ |
711 | if (type != HUB_RESUME) { | 718 | if (type != HUB_RESUME) { |
719 | if (hdev->parent && hub_is_superspeed(hdev)) { | ||
720 | ret = usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0), | ||
721 | HUB_SET_DEPTH, USB_RT_HUB, | ||
722 | hdev->level - 1, 0, NULL, 0, | ||
723 | USB_CTRL_SET_TIMEOUT); | ||
724 | if (ret < 0) | ||
725 | dev_err(hub->intfdev, | ||
726 | "set hub depth failed\n"); | ||
727 | } | ||
712 | 728 | ||
713 | /* Speed up system boot by using a delayed_work for the | 729 | /* Speed up system boot by using a delayed_work for the |
714 | * hub's initial power-up delays. This is pretty awkward | 730 | * hub's initial power-up delays. This is pretty awkward |
@@ -987,18 +1003,6 @@ static int hub_configure(struct usb_hub *hub, | |||
987 | goto fail; | 1003 | goto fail; |
988 | } | 1004 | } |
989 | 1005 | ||
990 | if (hub_is_superspeed(hdev) && (hdev->parent != NULL)) { | ||
991 | ret = usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0), | ||
992 | HUB_SET_DEPTH, USB_RT_HUB, | ||
993 | hdev->level - 1, 0, NULL, 0, | ||
994 | USB_CTRL_SET_TIMEOUT); | ||
995 | |||
996 | if (ret < 0) { | ||
997 | message = "can't set hub depth"; | ||
998 | goto fail; | ||
999 | } | ||
1000 | } | ||
1001 | |||
1002 | /* Request the entire hub descriptor. | 1006 | /* Request the entire hub descriptor. |
1003 | * hub->descriptor can handle USB_MAXCHILDREN ports, | 1007 | * hub->descriptor can handle USB_MAXCHILDREN ports, |
1004 | * but the hub can/will return fewer bytes here. | 1008 | * but the hub can/will return fewer bytes here. |
@@ -1041,58 +1045,58 @@ static int hub_configure(struct usb_hub *hub, | |||
1041 | dev_dbg(hub_dev, "standalone hub\n"); | 1045 | dev_dbg(hub_dev, "standalone hub\n"); |
1042 | 1046 | ||
1043 | switch (wHubCharacteristics & HUB_CHAR_LPSM) { | 1047 | switch (wHubCharacteristics & HUB_CHAR_LPSM) { |
1044 | case 0x00: | 1048 | case HUB_CHAR_COMMON_LPSM: |
1045 | dev_dbg(hub_dev, "ganged power switching\n"); | 1049 | dev_dbg(hub_dev, "ganged power switching\n"); |
1046 | break; | 1050 | break; |
1047 | case 0x01: | 1051 | case HUB_CHAR_INDV_PORT_LPSM: |
1048 | dev_dbg(hub_dev, "individual port power switching\n"); | 1052 | dev_dbg(hub_dev, "individual port power switching\n"); |
1049 | break; | 1053 | break; |
1050 | case 0x02: | 1054 | case HUB_CHAR_NO_LPSM: |
1051 | case 0x03: | 1055 | case HUB_CHAR_LPSM: |
1052 | dev_dbg(hub_dev, "no power switching (usb 1.0)\n"); | 1056 | dev_dbg(hub_dev, "no power switching (usb 1.0)\n"); |
1053 | break; | 1057 | break; |
1054 | } | 1058 | } |
1055 | 1059 | ||
1056 | switch (wHubCharacteristics & HUB_CHAR_OCPM) { | 1060 | switch (wHubCharacteristics & HUB_CHAR_OCPM) { |
1057 | case 0x00: | 1061 | case HUB_CHAR_COMMON_OCPM: |
1058 | dev_dbg(hub_dev, "global over-current protection\n"); | 1062 | dev_dbg(hub_dev, "global over-current protection\n"); |
1059 | break; | 1063 | break; |
1060 | case 0x08: | 1064 | case HUB_CHAR_INDV_PORT_OCPM: |
1061 | dev_dbg(hub_dev, "individual port over-current protection\n"); | 1065 | dev_dbg(hub_dev, "individual port over-current protection\n"); |
1062 | break; | 1066 | break; |
1063 | case 0x10: | 1067 | case HUB_CHAR_NO_OCPM: |
1064 | case 0x18: | 1068 | case HUB_CHAR_OCPM: |
1065 | dev_dbg(hub_dev, "no over-current protection\n"); | 1069 | dev_dbg(hub_dev, "no over-current protection\n"); |
1066 | break; | 1070 | break; |
1067 | } | 1071 | } |
1068 | 1072 | ||
1069 | spin_lock_init (&hub->tt.lock); | 1073 | spin_lock_init (&hub->tt.lock); |
1070 | INIT_LIST_HEAD (&hub->tt.clear_list); | 1074 | INIT_LIST_HEAD (&hub->tt.clear_list); |
1071 | INIT_WORK(&hub->tt.clear_work, hub_tt_work); | 1075 | INIT_WORK(&hub->tt.clear_work, hub_tt_work); |
1072 | switch (hdev->descriptor.bDeviceProtocol) { | 1076 | switch (hdev->descriptor.bDeviceProtocol) { |
1073 | case 0: | 1077 | case USB_HUB_PR_FS: |
1074 | break; | 1078 | break; |
1075 | case 1: | 1079 | case USB_HUB_PR_HS_SINGLE_TT: |
1076 | dev_dbg(hub_dev, "Single TT\n"); | 1080 | dev_dbg(hub_dev, "Single TT\n"); |
1077 | hub->tt.hub = hdev; | 1081 | hub->tt.hub = hdev; |
1078 | break; | 1082 | break; |
1079 | case 2: | 1083 | case USB_HUB_PR_HS_MULTI_TT: |
1080 | ret = usb_set_interface(hdev, 0, 1); | 1084 | ret = usb_set_interface(hdev, 0, 1); |
1081 | if (ret == 0) { | 1085 | if (ret == 0) { |
1082 | dev_dbg(hub_dev, "TT per port\n"); | 1086 | dev_dbg(hub_dev, "TT per port\n"); |
1083 | hub->tt.multi = 1; | 1087 | hub->tt.multi = 1; |
1084 | } else | 1088 | } else |
1085 | dev_err(hub_dev, "Using single TT (err %d)\n", | 1089 | dev_err(hub_dev, "Using single TT (err %d)\n", |
1086 | ret); | 1090 | ret); |
1087 | hub->tt.hub = hdev; | 1091 | hub->tt.hub = hdev; |
1088 | break; | 1092 | break; |
1089 | case 3: | 1093 | case USB_HUB_PR_SS: |
1090 | /* USB 3.0 hubs don't have a TT */ | 1094 | /* USB 3.0 hubs don't have a TT */ |
1091 | break; | 1095 | break; |
1092 | default: | 1096 | default: |
1093 | dev_dbg(hub_dev, "Unrecognized hub protocol %d\n", | 1097 | dev_dbg(hub_dev, "Unrecognized hub protocol %d\n", |
1094 | hdev->descriptor.bDeviceProtocol); | 1098 | hdev->descriptor.bDeviceProtocol); |
1095 | break; | 1099 | break; |
1096 | } | 1100 | } |
1097 | 1101 | ||
1098 | /* Note 8 FS bit times == (8 bits / 12000000 bps) ~= 666ns */ | 1102 | /* Note 8 FS bit times == (8 bits / 12000000 bps) ~= 666ns */ |
@@ -1360,7 +1364,6 @@ descriptor_error: | |||
1360 | return -ENODEV; | 1364 | return -ENODEV; |
1361 | } | 1365 | } |
1362 | 1366 | ||
1363 | /* No BKL needed */ | ||
1364 | static int | 1367 | static int |
1365 | hub_ioctl(struct usb_interface *intf, unsigned int code, void *user_data) | 1368 | hub_ioctl(struct usb_interface *intf, unsigned int code, void *user_data) |
1366 | { | 1369 | { |
@@ -2027,7 +2030,7 @@ static unsigned hub_is_wusb(struct usb_hub *hub) | |||
2027 | #define SET_ADDRESS_TRIES 2 | 2030 | #define SET_ADDRESS_TRIES 2 |
2028 | #define GET_DESCRIPTOR_TRIES 2 | 2031 | #define GET_DESCRIPTOR_TRIES 2 |
2029 | #define SET_CONFIG_TRIES (2 * (use_both_schemes + 1)) | 2032 | #define SET_CONFIG_TRIES (2 * (use_both_schemes + 1)) |
2030 | #define USE_NEW_SCHEME(i) ((i) / 2 == old_scheme_first) | 2033 | #define USE_NEW_SCHEME(i) ((i) / 2 == (int)old_scheme_first) |
2031 | 2034 | ||
2032 | #define HUB_ROOT_RESET_TIME 50 /* times are in msec */ | 2035 | #define HUB_ROOT_RESET_TIME 50 /* times are in msec */ |
2033 | #define HUB_SHORT_RESET_TIME 10 | 2036 | #define HUB_SHORT_RESET_TIME 10 |
diff --git a/drivers/usb/core/inode.c b/drivers/usb/core/inode.c index 2278dad886e2..9e186f3da839 100644 --- a/drivers/usb/core/inode.c +++ b/drivers/usb/core/inode.c | |||
@@ -65,7 +65,7 @@ static umode_t devmode = USBFS_DEFAULT_DEVMODE; | |||
65 | static umode_t busmode = USBFS_DEFAULT_BUSMODE; | 65 | static umode_t busmode = USBFS_DEFAULT_BUSMODE; |
66 | static umode_t listmode = USBFS_DEFAULT_LISTMODE; | 66 | static umode_t listmode = USBFS_DEFAULT_LISTMODE; |
67 | 67 | ||
68 | static int usbfs_show_options(struct seq_file *seq, struct vfsmount *mnt) | 68 | static int usbfs_show_options(struct seq_file *seq, struct dentry *root) |
69 | { | 69 | { |
70 | if (devuid != 0) | 70 | if (devuid != 0) |
71 | seq_printf(seq, ",devuid=%u", devuid); | 71 | seq_printf(seq, ",devuid=%u", devuid); |
@@ -264,21 +264,19 @@ static int remount(struct super_block *sb, int *flags, char *data) | |||
264 | return -EINVAL; | 264 | return -EINVAL; |
265 | } | 265 | } |
266 | 266 | ||
267 | if (usbfs_mount && usbfs_mount->mnt_sb) | 267 | if (usbfs_mount) |
268 | update_sb(usbfs_mount->mnt_sb); | 268 | update_sb(usbfs_mount->mnt_sb); |
269 | 269 | ||
270 | return 0; | 270 | return 0; |
271 | } | 271 | } |
272 | 272 | ||
273 | static struct inode *usbfs_get_inode (struct super_block *sb, int mode, dev_t dev) | 273 | static struct inode *usbfs_get_inode (struct super_block *sb, umode_t mode, dev_t dev) |
274 | { | 274 | { |
275 | struct inode *inode = new_inode(sb); | 275 | struct inode *inode = new_inode(sb); |
276 | 276 | ||
277 | if (inode) { | 277 | if (inode) { |
278 | inode->i_ino = get_next_ino(); | 278 | inode->i_ino = get_next_ino(); |
279 | inode->i_mode = mode; | 279 | inode_init_owner(inode, NULL, mode); |
280 | inode->i_uid = current_fsuid(); | ||
281 | inode->i_gid = current_fsgid(); | ||
282 | inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; | 280 | inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; |
283 | switch (mode & S_IFMT) { | 281 | switch (mode & S_IFMT) { |
284 | default: | 282 | default: |
@@ -300,7 +298,7 @@ static struct inode *usbfs_get_inode (struct super_block *sb, int mode, dev_t de | |||
300 | } | 298 | } |
301 | 299 | ||
302 | /* SMP-safe */ | 300 | /* SMP-safe */ |
303 | static int usbfs_mknod (struct inode *dir, struct dentry *dentry, int mode, | 301 | static int usbfs_mknod (struct inode *dir, struct dentry *dentry, umode_t mode, |
304 | dev_t dev) | 302 | dev_t dev) |
305 | { | 303 | { |
306 | struct inode *inode = usbfs_get_inode(dir->i_sb, mode, dev); | 304 | struct inode *inode = usbfs_get_inode(dir->i_sb, mode, dev); |
@@ -317,7 +315,7 @@ static int usbfs_mknod (struct inode *dir, struct dentry *dentry, int mode, | |||
317 | return error; | 315 | return error; |
318 | } | 316 | } |
319 | 317 | ||
320 | static int usbfs_mkdir (struct inode *dir, struct dentry *dentry, int mode) | 318 | static int usbfs_mkdir (struct inode *dir, struct dentry *dentry, umode_t mode) |
321 | { | 319 | { |
322 | int res; | 320 | int res; |
323 | 321 | ||
@@ -328,7 +326,7 @@ static int usbfs_mkdir (struct inode *dir, struct dentry *dentry, int mode) | |||
328 | return res; | 326 | return res; |
329 | } | 327 | } |
330 | 328 | ||
331 | static int usbfs_create (struct inode *dir, struct dentry *dentry, int mode) | 329 | static int usbfs_create (struct inode *dir, struct dentry *dentry, umode_t mode) |
332 | { | 330 | { |
333 | mode = (mode & S_IALLUGO) | S_IFREG; | 331 | mode = (mode & S_IALLUGO) | S_IFREG; |
334 | return usbfs_mknod (dir, dentry, mode, 0); | 332 | return usbfs_mknod (dir, dentry, mode, 0); |
@@ -489,7 +487,7 @@ static int usbfs_fill_super(struct super_block *sb, void *data, int silent) | |||
489 | * | 487 | * |
490 | * This function handles both regular files and directories. | 488 | * This function handles both regular files and directories. |
491 | */ | 489 | */ |
492 | static int fs_create_by_name (const char *name, mode_t mode, | 490 | static int fs_create_by_name (const char *name, umode_t mode, |
493 | struct dentry *parent, struct dentry **dentry) | 491 | struct dentry *parent, struct dentry **dentry) |
494 | { | 492 | { |
495 | int error = 0; | 493 | int error = 0; |
@@ -500,9 +498,8 @@ static int fs_create_by_name (const char *name, mode_t mode, | |||
500 | * have around. | 498 | * have around. |
501 | */ | 499 | */ |
502 | if (!parent ) { | 500 | if (!parent ) { |
503 | if (usbfs_mount && usbfs_mount->mnt_sb) { | 501 | if (usbfs_mount) |
504 | parent = usbfs_mount->mnt_sb->s_root; | 502 | parent = usbfs_mount->mnt_root; |
505 | } | ||
506 | } | 503 | } |
507 | 504 | ||
508 | if (!parent) { | 505 | if (!parent) { |
@@ -514,7 +511,7 @@ static int fs_create_by_name (const char *name, mode_t mode, | |||
514 | mutex_lock(&parent->d_inode->i_mutex); | 511 | mutex_lock(&parent->d_inode->i_mutex); |
515 | *dentry = lookup_one_len(name, parent, strlen(name)); | 512 | *dentry = lookup_one_len(name, parent, strlen(name)); |
516 | if (!IS_ERR(*dentry)) { | 513 | if (!IS_ERR(*dentry)) { |
517 | if ((mode & S_IFMT) == S_IFDIR) | 514 | if (S_ISDIR(mode)) |
518 | error = usbfs_mkdir (parent->d_inode, *dentry, mode); | 515 | error = usbfs_mkdir (parent->d_inode, *dentry, mode); |
519 | else | 516 | else |
520 | error = usbfs_create (parent->d_inode, *dentry, mode); | 517 | error = usbfs_create (parent->d_inode, *dentry, mode); |
@@ -525,7 +522,7 @@ static int fs_create_by_name (const char *name, mode_t mode, | |||
525 | return error; | 522 | return error; |
526 | } | 523 | } |
527 | 524 | ||
528 | static struct dentry *fs_create_file (const char *name, mode_t mode, | 525 | static struct dentry *fs_create_file (const char *name, umode_t mode, |
529 | struct dentry *parent, void *data, | 526 | struct dentry *parent, void *data, |
530 | const struct file_operations *fops, | 527 | const struct file_operations *fops, |
531 | uid_t uid, gid_t gid) | 528 | uid_t uid, gid_t gid) |
@@ -608,7 +605,7 @@ static int create_special_files (void) | |||
608 | 605 | ||
609 | ignore_mount = 0; | 606 | ignore_mount = 0; |
610 | 607 | ||
611 | parent = usbfs_mount->mnt_sb->s_root; | 608 | parent = usbfs_mount->mnt_root; |
612 | devices_usbfs_dentry = fs_create_file ("devices", | 609 | devices_usbfs_dentry = fs_create_file ("devices", |
613 | listmode | S_IFREG, parent, | 610 | listmode | S_IFREG, parent, |
614 | NULL, &usbfs_devices_fops, | 611 | NULL, &usbfs_devices_fops, |
@@ -662,7 +659,7 @@ static void usbfs_add_bus(struct usb_bus *bus) | |||
662 | 659 | ||
663 | sprintf (name, "%03d", bus->busnum); | 660 | sprintf (name, "%03d", bus->busnum); |
664 | 661 | ||
665 | parent = usbfs_mount->mnt_sb->s_root; | 662 | parent = usbfs_mount->mnt_root; |
666 | bus->usbfs_dentry = fs_create_file (name, busmode | S_IFDIR, parent, | 663 | bus->usbfs_dentry = fs_create_file (name, busmode | S_IFDIR, parent, |
667 | bus, NULL, busuid, busgid); | 664 | bus, NULL, busuid, busgid); |
668 | if (bus->usbfs_dentry == NULL) { | 665 | if (bus->usbfs_dentry == NULL) { |
diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c index ecf12e15a7ef..4c65eb6a867a 100644 --- a/drivers/usb/core/quirks.c +++ b/drivers/usb/core/quirks.c | |||
@@ -117,9 +117,12 @@ static const struct usb_device_id usb_quirk_list[] = { | |||
117 | { USB_DEVICE(0x06a3, 0x0006), .driver_info = | 117 | { USB_DEVICE(0x06a3, 0x0006), .driver_info = |
118 | USB_QUIRK_CONFIG_INTF_STRINGS }, | 118 | USB_QUIRK_CONFIG_INTF_STRINGS }, |
119 | 119 | ||
120 | /* Guillemot Webcam Hercules Dualpix Exchange*/ | 120 | /* Guillemot Webcam Hercules Dualpix Exchange (2nd ID) */ |
121 | { USB_DEVICE(0x06f8, 0x0804), .driver_info = USB_QUIRK_RESET_RESUME }, | 121 | { USB_DEVICE(0x06f8, 0x0804), .driver_info = USB_QUIRK_RESET_RESUME }, |
122 | 122 | ||
123 | /* Guillemot Webcam Hercules Dualpix Exchange*/ | ||
124 | { USB_DEVICE(0x06f8, 0x3005), .driver_info = USB_QUIRK_RESET_RESUME }, | ||
125 | |||
123 | /* M-Systems Flash Disk Pioneers */ | 126 | /* M-Systems Flash Disk Pioneers */ |
124 | { USB_DEVICE(0x08ec, 0x1000), .driver_info = USB_QUIRK_RESET_RESUME }, | 127 | { USB_DEVICE(0x08ec, 0x1000), .driver_info = USB_QUIRK_RESET_RESUME }, |
125 | 128 | ||
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c index 662c0cf3a3e1..9e491ca2e5c4 100644 --- a/drivers/usb/core/sysfs.c +++ b/drivers/usb/core/sysfs.c | |||
@@ -642,7 +642,7 @@ static struct attribute *dev_string_attrs[] = { | |||
642 | NULL | 642 | NULL |
643 | }; | 643 | }; |
644 | 644 | ||
645 | static mode_t dev_string_attrs_are_visible(struct kobject *kobj, | 645 | static umode_t dev_string_attrs_are_visible(struct kobject *kobj, |
646 | struct attribute *a, int n) | 646 | struct attribute *a, int n) |
647 | { | 647 | { |
648 | struct device *dev = container_of(kobj, struct device, kobj); | 648 | struct device *dev = container_of(kobj, struct device, kobj); |
@@ -877,7 +877,7 @@ static struct attribute *intf_assoc_attrs[] = { | |||
877 | NULL, | 877 | NULL, |
878 | }; | 878 | }; |
879 | 879 | ||
880 | static mode_t intf_assoc_attrs_are_visible(struct kobject *kobj, | 880 | static umode_t intf_assoc_attrs_are_visible(struct kobject *kobj, |
881 | struct attribute *a, int n) | 881 | struct attribute *a, int n) |
882 | { | 882 | { |
883 | struct device *dev = container_of(kobj, struct device, kobj); | 883 | struct device *dev = container_of(kobj, struct device, kobj); |
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index 73cd90012ec5..8ca9f994a280 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c | |||
@@ -47,7 +47,7 @@ | |||
47 | 47 | ||
48 | const char *usbcore_name = "usbcore"; | 48 | const char *usbcore_name = "usbcore"; |
49 | 49 | ||
50 | static int nousb; /* Disable USB when built into kernel image */ | 50 | static bool nousb; /* Disable USB when built into kernel image */ |
51 | 51 | ||
52 | #ifdef CONFIG_USB_SUSPEND | 52 | #ifdef CONFIG_USB_SUSPEND |
53 | static int usb_autosuspend_delay = 2; /* Default delay value, | 53 | static int usb_autosuspend_delay = 2; /* Default delay value, |
@@ -326,7 +326,7 @@ static const struct dev_pm_ops usb_device_pm_ops = { | |||
326 | #endif /* CONFIG_PM */ | 326 | #endif /* CONFIG_PM */ |
327 | 327 | ||
328 | 328 | ||
329 | static char *usb_devnode(struct device *dev, mode_t *mode) | 329 | static char *usb_devnode(struct device *dev, umode_t *mode) |
330 | { | 330 | { |
331 | struct usb_device *usb_dev; | 331 | struct usb_device *usb_dev; |
332 | 332 | ||
diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h index 3888778582c4..45e8479c377d 100644 --- a/drivers/usb/core/usb.h +++ b/drivers/usb/core/usb.h | |||
@@ -132,20 +132,6 @@ static inline int is_usb_device_driver(struct device_driver *drv) | |||
132 | for_devices; | 132 | for_devices; |
133 | } | 133 | } |
134 | 134 | ||
135 | /* translate USB error codes to codes user space understands */ | ||
136 | static inline int usb_translate_errors(int error_code) | ||
137 | { | ||
138 | switch (error_code) { | ||
139 | case 0: | ||
140 | case -ENOMEM: | ||
141 | case -ENODEV: | ||
142 | return error_code; | ||
143 | default: | ||
144 | return -EIO; | ||
145 | } | ||
146 | } | ||
147 | |||
148 | |||
149 | /* for labeling diagnostics */ | 135 | /* for labeling diagnostics */ |
150 | extern const char *usbcore_name; | 136 | extern const char *usbcore_name; |
151 | 137 | ||