Merge with Greg's USB tree at kernel.org:/pub/scm/linux/kernel/git/gregkh/usb-2.6.git/

Yah, it does work to merge. Knock wood.

+467 -423
+2 -2
drivers/net/irda/stir4200.c
··· 1128 } 1129 1130 #ifdef CONFIG_PM 1131 - /* Power management suspend, so power off the transmitter/receiver */ 1132 - static int stir_suspend(struct usb_interface *intf, u32 state) 1133 { 1134 struct stir_cb *stir = usb_get_intfdata(intf); 1135
··· 1128 } 1129 1130 #ifdef CONFIG_PM 1131 + /* USB suspend, so power off the transmitter/receiver */ 1132 + static int stir_suspend(struct usb_interface *intf, pm_message_t message) 1133 { 1134 struct stir_cb *stir = usb_get_intfdata(intf); 1135
+16 -32
drivers/usb/class/audio.c
··· 649 } 650 } 651 set_current_state(TASK_RUNNING); 652 - if (u->durb[0].urb->transfer_buffer) 653 - kfree(u->durb[0].urb->transfer_buffer); 654 - if (u->durb[1].urb->transfer_buffer) 655 - kfree(u->durb[1].urb->transfer_buffer); 656 - if (u->surb[0].urb->transfer_buffer) 657 - kfree(u->surb[0].urb->transfer_buffer); 658 - if (u->surb[1].urb->transfer_buffer) 659 - kfree(u->surb[1].urb->transfer_buffer); 660 u->durb[0].urb->transfer_buffer = u->durb[1].urb->transfer_buffer = 661 u->surb[0].urb->transfer_buffer = u->surb[1].urb->transfer_buffer = NULL; 662 } ··· 1005 u->phase = 0; 1006 maxsze = (u->freqmax + 0x3fff) >> (14 - AFMT_BYTESSHIFT(u->format)); 1007 bufsz = DESCFRAMES * maxsze; 1008 - if (u->durb[0].urb->transfer_buffer) 1009 - kfree(u->durb[0].urb->transfer_buffer); 1010 u->durb[0].urb->transfer_buffer = kmalloc(bufsz, GFP_KERNEL); 1011 u->durb[0].urb->transfer_buffer_length = bufsz; 1012 - if (u->durb[1].urb->transfer_buffer) 1013 - kfree(u->durb[1].urb->transfer_buffer); 1014 u->durb[1].urb->transfer_buffer = kmalloc(bufsz, GFP_KERNEL); 1015 u->durb[1].urb->transfer_buffer_length = bufsz; 1016 if (u->syncpipe) { 1017 - if (u->surb[0].urb->transfer_buffer) 1018 - kfree(u->surb[0].urb->transfer_buffer); 1019 u->surb[0].urb->transfer_buffer = kmalloc(3*SYNCFRAMES, GFP_KERNEL); 1020 u->surb[0].urb->transfer_buffer_length = 3*SYNCFRAMES; 1021 - if (u->surb[1].urb->transfer_buffer) 1022 - kfree(u->surb[1].urb->transfer_buffer); 1023 u->surb[1].urb->transfer_buffer = kmalloc(3*SYNCFRAMES, GFP_KERNEL); 1024 u->surb[1].urb->transfer_buffer_length = 3*SYNCFRAMES; 1025 } ··· 1120 } 1121 } 1122 set_current_state(TASK_RUNNING); 1123 - if (u->durb[0].urb->transfer_buffer) 1124 - kfree(u->durb[0].urb->transfer_buffer); 1125 - if (u->durb[1].urb->transfer_buffer) 1126 - kfree(u->durb[1].urb->transfer_buffer); 1127 - if (u->surb[0].urb->transfer_buffer) 1128 - kfree(u->surb[0].urb->transfer_buffer); 1129 - if (u->surb[1].urb->transfer_buffer) 1130 - kfree(u->surb[1].urb->transfer_buffer); 1131 u->durb[0].urb->transfer_buffer = u->durb[1].urb->transfer_buffer = 1132 u->surb[0].urb->transfer_buffer = u->surb[1].urb->transfer_buffer = NULL; 1133 } ··· 1364 u->phase = 0; 1365 maxsze = (u->freqmax + 0x3fff) >> (14 - AFMT_BYTESSHIFT(u->format)); 1366 bufsz = DESCFRAMES * maxsze; 1367 - if (u->durb[0].urb->transfer_buffer) 1368 - kfree(u->durb[0].urb->transfer_buffer); 1369 u->durb[0].urb->transfer_buffer = kmalloc(bufsz, GFP_KERNEL); 1370 u->durb[0].urb->transfer_buffer_length = bufsz; 1371 - if (u->durb[1].urb->transfer_buffer) 1372 - kfree(u->durb[1].urb->transfer_buffer); 1373 u->durb[1].urb->transfer_buffer = kmalloc(bufsz, GFP_KERNEL); 1374 u->durb[1].urb->transfer_buffer_length = bufsz; 1375 if (u->syncpipe) { 1376 - if (u->surb[0].urb->transfer_buffer) 1377 - kfree(u->surb[0].urb->transfer_buffer); 1378 u->surb[0].urb->transfer_buffer = kmalloc(3*SYNCFRAMES, GFP_KERNEL); 1379 u->surb[0].urb->transfer_buffer_length = 3*SYNCFRAMES; 1380 - if (u->surb[1].urb->transfer_buffer) 1381 - kfree(u->surb[1].urb->transfer_buffer); 1382 u->surb[1].urb->transfer_buffer = kmalloc(3*SYNCFRAMES, GFP_KERNEL); 1383 u->surb[1].urb->transfer_buffer_length = 3*SYNCFRAMES; 1384 }
··· 649 } 650 } 651 set_current_state(TASK_RUNNING); 652 + kfree(u->durb[0].urb->transfer_buffer); 653 + kfree(u->durb[1].urb->transfer_buffer); 654 + kfree(u->surb[0].urb->transfer_buffer); 655 + kfree(u->surb[1].urb->transfer_buffer); 656 u->durb[0].urb->transfer_buffer = u->durb[1].urb->transfer_buffer = 657 u->surb[0].urb->transfer_buffer = u->surb[1].urb->transfer_buffer = NULL; 658 } ··· 1009 u->phase = 0; 1010 maxsze = (u->freqmax + 0x3fff) >> (14 - AFMT_BYTESSHIFT(u->format)); 1011 bufsz = DESCFRAMES * maxsze; 1012 + kfree(u->durb[0].urb->transfer_buffer); 1013 u->durb[0].urb->transfer_buffer = kmalloc(bufsz, GFP_KERNEL); 1014 u->durb[0].urb->transfer_buffer_length = bufsz; 1015 + kfree(u->durb[1].urb->transfer_buffer); 1016 u->durb[1].urb->transfer_buffer = kmalloc(bufsz, GFP_KERNEL); 1017 u->durb[1].urb->transfer_buffer_length = bufsz; 1018 if (u->syncpipe) { 1019 + kfree(u->surb[0].urb->transfer_buffer); 1020 u->surb[0].urb->transfer_buffer = kmalloc(3*SYNCFRAMES, GFP_KERNEL); 1021 u->surb[0].urb->transfer_buffer_length = 3*SYNCFRAMES; 1022 + kfree(u->surb[1].urb->transfer_buffer); 1023 u->surb[1].urb->transfer_buffer = kmalloc(3*SYNCFRAMES, GFP_KERNEL); 1024 u->surb[1].urb->transfer_buffer_length = 3*SYNCFRAMES; 1025 } ··· 1128 } 1129 } 1130 set_current_state(TASK_RUNNING); 1131 + kfree(u->durb[0].urb->transfer_buffer); 1132 + kfree(u->durb[1].urb->transfer_buffer); 1133 + kfree(u->surb[0].urb->transfer_buffer); 1134 + kfree(u->surb[1].urb->transfer_buffer); 1135 u->durb[0].urb->transfer_buffer = u->durb[1].urb->transfer_buffer = 1136 u->surb[0].urb->transfer_buffer = u->surb[1].urb->transfer_buffer = NULL; 1137 } ··· 1376 u->phase = 0; 1377 maxsze = (u->freqmax + 0x3fff) >> (14 - AFMT_BYTESSHIFT(u->format)); 1378 bufsz = DESCFRAMES * maxsze; 1379 + kfree(u->durb[0].urb->transfer_buffer); 1380 u->durb[0].urb->transfer_buffer = kmalloc(bufsz, GFP_KERNEL); 1381 u->durb[0].urb->transfer_buffer_length = bufsz; 1382 + kfree(u->durb[1].urb->transfer_buffer); 1383 u->durb[1].urb->transfer_buffer = kmalloc(bufsz, GFP_KERNEL); 1384 u->durb[1].urb->transfer_buffer_length = bufsz; 1385 if (u->syncpipe) { 1386 + kfree(u->surb[0].urb->transfer_buffer); 1387 u->surb[0].urb->transfer_buffer = kmalloc(3*SYNCFRAMES, GFP_KERNEL); 1388 u->surb[0].urb->transfer_buffer_length = 3*SYNCFRAMES; 1389 + kfree(u->surb[1].urb->transfer_buffer); 1390 u->surb[1].urb->transfer_buffer = kmalloc(3*SYNCFRAMES, GFP_KERNEL); 1391 u->surb[1].urb->transfer_buffer_length = 3*SYNCFRAMES; 1392 }
+2 -2
drivers/usb/class/bluetty.c
··· 309 } 310 } 311 if (urb->transfer_buffer_length < len) { 312 - kfree (urb->transfer_buffer); 313 urb->transfer_buffer = kmalloc (len, GFP_KERNEL); 314 if (urb->transfer_buffer == NULL) { 315 err ("%s - out of memory", __FUNCTION__); ··· 535 } 536 537 exit: 538 - kfree (temp_buffer); 539 540 return retval; 541 }
··· 309 } 310 } 311 if (urb->transfer_buffer_length < len) { 312 + kfree(urb->transfer_buffer); 313 urb->transfer_buffer = kmalloc (len, GFP_KERNEL); 314 if (urb->transfer_buffer == NULL) { 315 err ("%s - out of memory", __FUNCTION__); ··· 535 } 536 537 exit: 538 + kfree(temp_buffer); 539 540 return retval; 541 }
+2 -1
drivers/usb/core/config.c
··· 10 #include <linux/slab.h> 11 #include <linux/device.h> 12 #include <asm/byteorder.h> 13 - 14 15 #define USB_MAXALTSETTING 128 /* Hard limit */ 16 #define USB_MAXENDPOINTS 30 /* Hard limit */
··· 10 #include <linux/slab.h> 11 #include <linux/device.h> 12 #include <asm/byteorder.h> 13 + #include "usb.h" 14 + #include "hcd.h" 15 16 #define USB_MAXALTSETTING 128 /* Hard limit */ 17 #define USB_MAXENDPOINTS 30 /* Hard limit */
+3 -5
drivers/usb/core/devices.c
··· 59 #include <linux/usbdevice_fs.h> 60 #include <asm/uaccess.h> 61 62 #include "hcd.h" 63 64 #define MAX_TOPO_LEVEL 6 ··· 637 638 static int usb_device_release(struct inode *inode, struct file *file) 639 { 640 - if (file->private_data) { 641 - kfree(file->private_data); 642 - file->private_data = NULL; 643 - } 644 - 645 return 0; 646 } 647
··· 59 #include <linux/usbdevice_fs.h> 60 #include <asm/uaccess.h> 61 62 + #include "usb.h" 63 #include "hcd.h" 64 65 #define MAX_TOPO_LEVEL 6 ··· 636 637 static int usb_device_release(struct inode *inode, struct file *file) 638 { 639 + kfree(file->private_data); 640 + file->private_data = NULL; 641 return 0; 642 } 643
+31 -41
drivers/usb/core/devio.c
··· 213 214 static void free_async(struct async *as) 215 { 216 - if (as->urb->transfer_buffer) 217 - kfree(as->urb->transfer_buffer); 218 - if (as->urb->setup_packet) 219 - kfree(as->urb->setup_packet); 220 usb_free_urb(as->urb); 221 - kfree(as); 222 } 223 224 static inline void async_newpending(struct async *as) ··· 936 return -EINVAL; 937 } 938 if (!(as = alloc_async(uurb->number_of_packets))) { 939 - if (isopkt) 940 - kfree(isopkt); 941 - if (dr) 942 - kfree(dr); 943 return -ENOMEM; 944 } 945 if (!(as->urb->transfer_buffer = kmalloc(uurb->buffer_length, GFP_KERNEL))) { 946 - if (isopkt) 947 - kfree(isopkt); 948 - if (dr) 949 - kfree(dr); 950 free_async(as); 951 return -ENOMEM; 952 } ··· 961 as->urb->iso_frame_desc[u].length = isopkt[u].length; 962 totlen += isopkt[u].length; 963 } 964 - if (isopkt) 965 - kfree(isopkt); 966 as->ps = ps; 967 as->userurb = arg; 968 if (uurb->endpoint & USB_DIR_IN) ··· 1025 if (put_user(urb->error_count, &userurb->error_count)) 1026 return -EFAULT; 1027 1028 - if (!(usb_pipeisoc(urb->pipe))) 1029 - return 0; 1030 - for (i = 0; i < urb->number_of_packets; i++) { 1031 - if (put_user(urb->iso_frame_desc[i].actual_length, 1032 - &userurb->iso_frame_desc[i].actual_length)) 1033 - return -EFAULT; 1034 - if (put_user(urb->iso_frame_desc[i].status, 1035 - &userurb->iso_frame_desc[i].status)) 1036 - return -EFAULT; 1037 } 1038 1039 free_async(as); ··· 1119 if (get_urb32(&uurb,(struct usbdevfs_urb32 *)arg)) 1120 return -EFAULT; 1121 1122 - return proc_do_submiturb(ps, &uurb, ((struct usbdevfs_urb __user *)arg)->iso_frame_desc, arg); 1123 } 1124 1125 static int processcompl_compat(struct async *as, void __user * __user *arg) ··· 1139 if (put_user(urb->error_count, &userurb->error_count)) 1140 return -EFAULT; 1141 1142 - if (!(usb_pipeisoc(urb->pipe))) 1143 - return 0; 1144 - for (i = 0; i < urb->number_of_packets; i++) { 1145 - if (put_user(urb->iso_frame_desc[i].actual_length, 1146 - &userurb->iso_frame_desc[i].actual_length)) 1147 - return -EFAULT; 1148 - if (put_user(urb->iso_frame_desc[i].status, 1149 - &userurb->iso_frame_desc[i].status)) 1150 - return -EFAULT; 1151 } 1152 1153 free_async(as); ··· 1170 { 1171 struct async *as; 1172 1173 - printk("reapurbnblock\n"); 1174 if (!(as = async_getcompleted(ps))) 1175 return -EAGAIN; 1176 - printk("reap got as %p\n", as); 1177 return processcompl_compat(as, (void __user * __user *)arg); 1178 } 1179 ··· 1230 return -ENOMEM; 1231 if ((_IOC_DIR(ctrl.ioctl_code) & _IOC_WRITE)) { 1232 if (copy_from_user (buf, ctrl.data, size)) { 1233 - kfree (buf); 1234 return -EFAULT; 1235 } 1236 } else { ··· 1239 } 1240 1241 if (!connected(ps->dev)) { 1242 - if (buf) 1243 - kfree(buf); 1244 return -ENODEV; 1245 } 1246 ··· 1301 && size > 0 1302 && copy_to_user (ctrl.data, buf, size) != 0) 1303 retval = -EFAULT; 1304 - if (buf != NULL) 1305 - kfree (buf); 1306 return retval; 1307 } 1308
··· 213 214 static void free_async(struct async *as) 215 { 216 + kfree(as->urb->transfer_buffer); 217 + kfree(as->urb->setup_packet); 218 usb_free_urb(as->urb); 219 + kfree(as); 220 } 221 222 static inline void async_newpending(struct async *as) ··· 938 return -EINVAL; 939 } 940 if (!(as = alloc_async(uurb->number_of_packets))) { 941 + kfree(isopkt); 942 + kfree(dr); 943 return -ENOMEM; 944 } 945 if (!(as->urb->transfer_buffer = kmalloc(uurb->buffer_length, GFP_KERNEL))) { 946 + kfree(isopkt); 947 + kfree(dr); 948 free_async(as); 949 return -ENOMEM; 950 } ··· 967 as->urb->iso_frame_desc[u].length = isopkt[u].length; 968 totlen += isopkt[u].length; 969 } 970 + kfree(isopkt); 971 as->ps = ps; 972 as->userurb = arg; 973 if (uurb->endpoint & USB_DIR_IN) ··· 1032 if (put_user(urb->error_count, &userurb->error_count)) 1033 return -EFAULT; 1034 1035 + if (usb_pipeisoc(urb->pipe)) { 1036 + for (i = 0; i < urb->number_of_packets; i++) { 1037 + if (put_user(urb->iso_frame_desc[i].actual_length, 1038 + &userurb->iso_frame_desc[i].actual_length)) 1039 + return -EFAULT; 1040 + if (put_user(urb->iso_frame_desc[i].status, 1041 + &userurb->iso_frame_desc[i].status)) 1042 + return -EFAULT; 1043 + } 1044 } 1045 1046 free_async(as); ··· 1126 if (get_urb32(&uurb,(struct usbdevfs_urb32 *)arg)) 1127 return -EFAULT; 1128 1129 + return proc_do_submiturb(ps, &uurb, ((struct usbdevfs_urb32 __user *)arg)->iso_frame_desc, arg); 1130 } 1131 1132 static int processcompl_compat(struct async *as, void __user * __user *arg) ··· 1146 if (put_user(urb->error_count, &userurb->error_count)) 1147 return -EFAULT; 1148 1149 + if (usb_pipeisoc(urb->pipe)) { 1150 + for (i = 0; i < urb->number_of_packets; i++) { 1151 + if (put_user(urb->iso_frame_desc[i].actual_length, 1152 + &userurb->iso_frame_desc[i].actual_length)) 1153 + return -EFAULT; 1154 + if (put_user(urb->iso_frame_desc[i].status, 1155 + &userurb->iso_frame_desc[i].status)) 1156 + return -EFAULT; 1157 + } 1158 } 1159 1160 free_async(as); ··· 1177 { 1178 struct async *as; 1179 1180 if (!(as = async_getcompleted(ps))) 1181 return -EAGAIN; 1182 return processcompl_compat(as, (void __user * __user *)arg); 1183 } 1184 ··· 1239 return -ENOMEM; 1240 if ((_IOC_DIR(ctrl.ioctl_code) & _IOC_WRITE)) { 1241 if (copy_from_user (buf, ctrl.data, size)) { 1242 + kfree(buf); 1243 return -EFAULT; 1244 } 1245 } else { ··· 1248 } 1249 1250 if (!connected(ps->dev)) { 1251 + kfree(buf); 1252 return -ENODEV; 1253 } 1254 ··· 1311 && size > 0 1312 && copy_to_user (ctrl.data, buf, size) != 0) 1313 retval = -EFAULT; 1314 + 1315 + kfree(buf); 1316 return retval; 1317 } 1318
+2
drivers/usb/core/file.c
··· 28 #endif 29 #include <linux/usb.h> 30 31 #define MAX_USB_MINORS 256 32 static struct file_operations *usb_minors[MAX_USB_MINORS]; 33 static DEFINE_SPINLOCK(minor_lock);
··· 28 #endif 29 #include <linux/usb.h> 30 31 + #include "usb.h" 32 + 33 #define MAX_USB_MINORS 256 34 static struct file_operations *usb_minors[MAX_USB_MINORS]; 35 static DEFINE_SPINLOCK(minor_lock);
+91 -60
drivers/usb/core/hcd-pci.c
··· 33 #include "hcd.h" 34 35 36 - /* PCI-based HCs are normal, but custom bus glue should be ok */ 37 38 39 /*-------------------------------------------------------------------------*/ ··· 67 68 if (pci_enable_device (dev) < 0) 69 return -ENODEV; 70 - dev->current_state = 0; 71 - dev->dev.power.power_state = 0; 72 73 if (!dev->irq) { 74 dev_err (&dev->dev, ··· 186 187 #ifdef CONFIG_PM 188 189 - static char __attribute_used__ *pci_state(u32 state) 190 - { 191 - switch (state) { 192 - case 0: return "D0"; 193 - case 1: return "D1"; 194 - case 2: return "D2"; 195 - case 3: return "D3hot"; 196 - case 4: return "D3cold"; 197 - } 198 - return NULL; 199 - } 200 - 201 /** 202 * usb_hcd_pci_suspend - power management suspend of a PCI-based HCD 203 * @dev: USB Host Controller being suspended 204 - * @state: state that the controller is going into 205 * 206 * Store this function in the HCD's struct pci_driver as suspend(). 207 */ 208 - int usb_hcd_pci_suspend (struct pci_dev *dev, u32 state) 209 { 210 struct usb_hcd *hcd; 211 int retval = 0; ··· 201 202 hcd = pci_get_drvdata(dev); 203 204 /* even when the PCI layer rejects some of the PCI calls 205 * below, HCs can try global suspend and reduce DMA traffic. 206 * PM-sensitive HCDs may already have done this. 207 */ 208 has_pci_pm = pci_find_capability(dev, PCI_CAP_ID_PM); 209 - if (state > 4) 210 - state = 4; 211 212 switch (hcd->state) { 213 ··· 226 */ 227 case HC_STATE_RUNNING: 228 hcd->state = HC_STATE_QUIESCING; 229 - retval = hcd->driver->suspend (hcd, state); 230 if (retval) { 231 dev_dbg (hcd->self.controller, 232 "suspend fail, retval %d\n", ··· 244 * have been called, otherwise root hub timers still run ... 245 */ 246 case HC_STATE_SUSPENDED: 247 - if (state <= dev->current_state) 248 - break; 249 - 250 - /* no DMA or IRQs except in D0 */ 251 - if (!dev->current_state) { 252 pci_save_state (dev); 253 pci_disable_device (dev); 254 - free_irq (hcd->irq, hcd); 255 } 256 257 if (!has_pci_pm) { ··· 256 break; 257 } 258 259 - /* POLICY: ignore D1/D2/D3hot differences; 260 - * we know D3hot will always work. 261 */ 262 - retval = pci_set_power_state (dev, state); 263 - if (retval < 0 && state < 3) { 264 - retval = pci_set_power_state (dev, 3); 265 - if (retval == 0) 266 - state = 3; 267 - } 268 if (retval == 0) { 269 - dev_dbg (hcd->self.controller, "--> PCI %s\n", 270 - pci_state(dev->current_state)); 271 - #ifdef CONFIG_USB_SUSPEND 272 - pci_enable_wake (dev, state, hcd->remote_wakeup); 273 - pci_enable_wake (dev, 4, hcd->remote_wakeup); 274 - #endif 275 } else if (retval < 0) { 276 - dev_dbg (&dev->dev, "PCI %s suspend fail, %d\n", 277 - pci_state(state), retval); 278 (void) usb_hcd_pci_resume (dev); 279 break; 280 } ··· 276 default: 277 dev_dbg (hcd->self.controller, "hcd state %d; not suspended\n", 278 hcd->state); 279 retval = -EINVAL; 280 break; 281 } 282 283 /* update power_state **ONLY** to make sysfs happier */ 284 if (retval == 0) 285 - dev->dev.power.power_state = state; 286 return retval; 287 } 288 EXPORT_SYMBOL (usb_hcd_pci_suspend); ··· 298 { 299 struct usb_hcd *hcd; 300 int retval; 301 - int has_pci_pm; 302 303 hcd = pci_get_drvdata(dev); 304 if (hcd->state != HC_STATE_SUSPENDED) { ··· 305 "can't resume, not suspended!\n"); 306 return 0; 307 } 308 - has_pci_pm = pci_find_capability(dev, PCI_CAP_ID_PM); 309 310 - /* D3cold resume isn't usually reported this way... */ 311 - dev_dbg(hcd->self.controller, "resume from PCI %s%s\n", 312 - pci_state(dev->current_state), 313 - has_pci_pm ? "" : " (legacy)"); 314 315 hcd->state = HC_STATE_RESUMING; 316 - 317 - if (has_pci_pm) 318 - pci_set_power_state (dev, 0); 319 - dev->dev.power.power_state = 0; 320 retval = request_irq (dev->irq, usb_hcd_irq, SA_SHIRQ, 321 - hcd->driver->description, hcd); 322 if (retval < 0) { 323 dev_err (hcd->self.controller, 324 "can't restore IRQ after resume!\n"); 325 return retval; 326 } 327 - hcd->saw_irq = 0; 328 - pci_restore_state (dev); 329 - #ifdef CONFIG_USB_SUSPEND 330 - pci_enable_wake (dev, dev->current_state, 0); 331 - pci_enable_wake (dev, 4, 0); 332 - #endif 333 334 retval = hcd->driver->resume (hcd); 335 if (!HC_IS_RUNNING (hcd->state)) {
··· 33 #include "hcd.h" 34 35 36 + /* PCI-based HCs are common, but plenty of non-PCI HCs are used too */ 37 38 39 /*-------------------------------------------------------------------------*/ ··· 67 68 if (pci_enable_device (dev) < 0) 69 return -ENODEV; 70 + dev->current_state = PCI_D0; 71 + dev->dev.power.power_state = PMSG_ON; 72 73 if (!dev->irq) { 74 dev_err (&dev->dev, ··· 186 187 #ifdef CONFIG_PM 188 189 /** 190 * usb_hcd_pci_suspend - power management suspend of a PCI-based HCD 191 * @dev: USB Host Controller being suspended 192 + * @message: semantics in flux 193 * 194 * Store this function in the HCD's struct pci_driver as suspend(). 195 */ 196 + int usb_hcd_pci_suspend (struct pci_dev *dev, pm_message_t message) 197 { 198 struct usb_hcd *hcd; 199 int retval = 0; ··· 213 214 hcd = pci_get_drvdata(dev); 215 216 + /* FIXME until the generic PM interfaces change a lot more, this 217 + * can't use PCI D1 and D2 states. For example, the confusion 218 + * between messages and states will need to vanish, and messages 219 + * will need to provide a target system state again. 220 + * 221 + * It'll be important to learn characteristics of the target state, 222 + * especially on embedded hardware where the HCD will often be in 223 + * charge of an external VBUS power supply and one or more clocks. 224 + * Some target system states will leave them active; others won't. 225 + * (With PCI, that's often handled by platform BIOS code.) 226 + */ 227 + 228 /* even when the PCI layer rejects some of the PCI calls 229 * below, HCs can try global suspend and reduce DMA traffic. 230 * PM-sensitive HCDs may already have done this. 231 */ 232 has_pci_pm = pci_find_capability(dev, PCI_CAP_ID_PM); 233 234 switch (hcd->state) { 235 ··· 228 */ 229 case HC_STATE_RUNNING: 230 hcd->state = HC_STATE_QUIESCING; 231 + retval = hcd->driver->suspend (hcd, message); 232 if (retval) { 233 dev_dbg (hcd->self.controller, 234 "suspend fail, retval %d\n", ··· 246 * have been called, otherwise root hub timers still run ... 247 */ 248 case HC_STATE_SUSPENDED: 249 + /* no DMA or IRQs except when HC is active */ 250 + if (dev->current_state == PCI_D0) { 251 + free_irq (hcd->irq, hcd); 252 pci_save_state (dev); 253 pci_disable_device (dev); 254 } 255 256 if (!has_pci_pm) { ··· 261 break; 262 } 263 264 + /* NOTE: dev->current_state becomes nonzero only here, and 265 + * only for devices that support PCI PM. Also, exiting 266 + * PCI_D3 (but not PCI_D1 or PCI_D2) is allowed to reset 267 + * some device state (e.g. as part of clock reinit). 268 */ 269 + retval = pci_set_power_state (dev, PCI_D3hot); 270 if (retval == 0) { 271 + dev_dbg (hcd->self.controller, "--> PCI D3\n"); 272 + pci_enable_wake (dev, PCI_D3hot, hcd->remote_wakeup); 273 + pci_enable_wake (dev, PCI_D3cold, hcd->remote_wakeup); 274 } else if (retval < 0) { 275 + dev_dbg (&dev->dev, "PCI D3 suspend fail, %d\n", 276 + retval); 277 (void) usb_hcd_pci_resume (dev); 278 break; 279 } ··· 287 default: 288 dev_dbg (hcd->self.controller, "hcd state %d; not suspended\n", 289 hcd->state); 290 + WARN_ON(1); 291 retval = -EINVAL; 292 break; 293 } 294 295 /* update power_state **ONLY** to make sysfs happier */ 296 if (retval == 0) 297 + dev->dev.power.power_state = message; 298 return retval; 299 } 300 EXPORT_SYMBOL (usb_hcd_pci_suspend); ··· 308 { 309 struct usb_hcd *hcd; 310 int retval; 311 312 hcd = pci_get_drvdata(dev); 313 if (hcd->state != HC_STATE_SUSPENDED) { ··· 316 "can't resume, not suspended!\n"); 317 return 0; 318 } 319 320 + /* NOTE: chip docs cover clean "real suspend" cases (what Linux 321 + * calls "standby", "suspend to RAM", and so on). There are also 322 + * dirty cases when swsusp fakes a suspend in "shutdown" mode. 323 + */ 324 + if (dev->current_state != PCI_D0) { 325 + #ifdef DEBUG 326 + int pci_pm; 327 + u16 pmcr; 328 + 329 + pci_pm = pci_find_capability(dev, PCI_CAP_ID_PM); 330 + pci_read_config_word(dev, pci_pm + PCI_PM_CTRL, &pmcr); 331 + pmcr &= PCI_PM_CTRL_STATE_MASK; 332 + if (pmcr) { 333 + /* Clean case: power to USB and to HC registers was 334 + * maintained; remote wakeup is easy. 335 + */ 336 + dev_dbg(hcd->self.controller, "resume from PCI D%d\n", 337 + pmcr); 338 + } else { 339 + /* Clean: HC lost Vcc power, D0 uninitialized 340 + * + Vaux may have preserved port and transceiver 341 + * state ... for remote wakeup from D3cold 342 + * + or not; HCD must reinit + re-enumerate 343 + * 344 + * Dirty: D0 semi-initialized cases with swsusp 345 + * + after BIOS init 346 + * + after Linux init (HCD statically linked) 347 + */ 348 + dev_dbg(hcd->self.controller, 349 + "PCI D0, from previous PCI D%d\n", 350 + dev->current_state); 351 + } 352 + #endif 353 + pci_enable_wake (dev, dev->current_state, 0); 354 + pci_enable_wake (dev, PCI_D3cold, 0); 355 + } else { 356 + /* Same basic cases: clean (powered/not), dirty */ 357 + dev_dbg(hcd->self.controller, "PCI legacy resume\n"); 358 + } 359 + 360 + /* NOTE: the PCI API itself is asymmetric here. We don't need to 361 + * pci_set_power_state(PCI_D0) since that's part of re-enabling; 362 + * but that won't re-enable bus mastering. Yet pci_disable_device() 363 + * explicitly disables bus mastering... 364 + */ 365 + retval = pci_enable_device (dev); 366 + if (retval < 0) { 367 + dev_err (hcd->self.controller, 368 + "can't re-enable after resume, %d!\n", retval); 369 + return retval; 370 + } 371 + pci_set_master (dev); 372 + pci_restore_state (dev); 373 + 374 + dev->dev.power.power_state = PMSG_ON; 375 376 hcd->state = HC_STATE_RESUMING; 377 + hcd->saw_irq = 0; 378 retval = request_irq (dev->irq, usb_hcd_irq, SA_SHIRQ, 379 + hcd->irq_descr, hcd); 380 if (retval < 0) { 381 dev_err (hcd->self.controller, 382 "can't restore IRQ after resume!\n"); 383 + usb_hc_died (hcd); 384 return retval; 385 } 386 387 retval = hcd->driver->resume (hcd); 388 if (!HC_IS_RUNNING (hcd->state)) {
+2 -2
drivers/usb/core/hcd.h
··· 177 * a whole, not just the root hub; they're for bus glue. 178 */ 179 /* called after all devices were suspended */ 180 - int (*suspend) (struct usb_hcd *hcd, u32 state); 181 182 /* called before any devices get resumed */ 183 int (*resume) (struct usb_hcd *hcd); ··· 226 extern void usb_hcd_pci_remove (struct pci_dev *dev); 227 228 #ifdef CONFIG_PM 229 - extern int usb_hcd_pci_suspend (struct pci_dev *dev, u32 state); 230 extern int usb_hcd_pci_resume (struct pci_dev *dev); 231 #endif /* CONFIG_PM */ 232
··· 177 * a whole, not just the root hub; they're for bus glue. 178 */ 179 /* called after all devices were suspended */ 180 + int (*suspend) (struct usb_hcd *hcd, pm_message_t message); 181 182 /* called before any devices get resumed */ 183 int (*resume) (struct usb_hcd *hcd); ··· 226 extern void usb_hcd_pci_remove (struct pci_dev *dev); 227 228 #ifdef CONFIG_PM 229 + extern int usb_hcd_pci_suspend (struct pci_dev *dev, pm_message_t state); 230 extern int usb_hcd_pci_resume (struct pci_dev *dev); 231 #endif /* CONFIG_PM */ 232
+10 -14
drivers/usb/core/hub.c
··· 381 dev_err (&hdev->dev, 382 "clear tt %d (%04x) error %d\n", 383 clear->tt, clear->devinfo, status); 384 - kfree (clear); 385 } 386 spin_unlock_irqrestore (&hub->tt.lock, flags); 387 } ··· 728 list_del_init(&hub->event_list); 729 spin_unlock_irq(&hub_event_lock); 730 731 - if (hub->descriptor) { 732 - kfree(hub->descriptor); 733 - hub->descriptor = NULL; 734 - } 735 736 - if (hub->status) { 737 - kfree(hub->status); 738 - hub->status = NULL; 739 - } 740 741 if (hub->buffer) { 742 usb_buffer_free(hdev, sizeof(*hub->buffer), hub->buffer, ··· 1452 /* FIXME let caller ask to power down the port: 1453 * - some devices won't enumerate without a VBUS power cycle 1454 * - SRP saves power that way 1455 - * - usb_suspend_device(dev,PM_SUSPEND_DISK) 1456 * That's easy if this hub can switch power per-port, and 1457 * khubd reactivates the port later (timer, SRP, etc). 1458 * Powerdown must be optional, because of reset/DFU. ··· 1527 1528 /* 1529 * Devices on USB hub ports have only one "suspend" state, corresponding 1530 - * to ACPI D2 (PM_SUSPEND_MEM), "may cause the device to lose some context". 1531 * State transitions include: 1532 * 1533 * - suspend, resume ... when the VBUS power link stays live ··· 1727 struct usb_driver *driver; 1728 1729 intf = udev->actconfig->interface[i]; 1730 - if (intf->dev.power.power_state == PM_SUSPEND_ON) 1731 continue; 1732 if (!intf->dev.driver) { 1733 /* FIXME maybe force to alt 0 */ ··· 1741 1742 /* can we do better than just logging errors? */ 1743 status = driver->resume(intf); 1744 - if (intf->dev.power.power_state != PM_SUSPEND_ON 1745 || status) 1746 dev_dbg(&intf->dev, 1747 "resume fail, state %d code %d\n", ··· 2350 schedule_work (&hub->leds); 2351 } 2352 } 2353 - kfree (qual); 2354 } 2355 2356 static unsigned
··· 381 dev_err (&hdev->dev, 382 "clear tt %d (%04x) error %d\n", 383 clear->tt, clear->devinfo, status); 384 + kfree(clear); 385 } 386 spin_unlock_irqrestore (&hub->tt.lock, flags); 387 } ··· 728 list_del_init(&hub->event_list); 729 spin_unlock_irq(&hub_event_lock); 730 731 + kfree(hub->descriptor); 732 + hub->descriptor = NULL; 733 734 + kfree(hub->status); 735 + hub->status = NULL; 736 737 if (hub->buffer) { 738 usb_buffer_free(hdev, sizeof(*hub->buffer), hub->buffer, ··· 1456 /* FIXME let caller ask to power down the port: 1457 * - some devices won't enumerate without a VBUS power cycle 1458 * - SRP saves power that way 1459 + * - usb_suspend_device(dev, PMSG_SUSPEND) 1460 * That's easy if this hub can switch power per-port, and 1461 * khubd reactivates the port later (timer, SRP, etc). 1462 * Powerdown must be optional, because of reset/DFU. ··· 1531 1532 /* 1533 * Devices on USB hub ports have only one "suspend" state, corresponding 1534 + * to ACPI D2, "may cause the device to lose some context". 1535 * State transitions include: 1536 * 1537 * - suspend, resume ... when the VBUS power link stays live ··· 1731 struct usb_driver *driver; 1732 1733 intf = udev->actconfig->interface[i]; 1734 + if (intf->dev.power.power_state == PMSG_SUSPEND) 1735 continue; 1736 if (!intf->dev.driver) { 1737 /* FIXME maybe force to alt 0 */ ··· 1745 1746 /* can we do better than just logging errors? */ 1747 status = driver->resume(intf); 1748 + if (intf->dev.power.power_state != PMSG_ON 1749 || status) 1750 dev_dbg(&intf->dev, 1751 "resume fail, state %d code %d\n", ··· 2354 schedule_work (&hub->leds); 2355 } 2356 } 2357 + kfree(qual); 2358 } 2359 2360 static unsigned
+1
drivers/usb/core/inode.c
··· 41 #include <linux/parser.h> 42 #include <asm/byteorder.h> 43 #include "usb.h" 44 45 static struct super_operations usbfs_ops; 46 static struct file_operations default_file_operations;
··· 41 #include <linux/parser.h> 42 #include <asm/byteorder.h> 43 #include "usb.h" 44 + #include "hcd.h" 45 46 static struct super_operations usbfs_ops; 47 static struct file_operations default_file_operations;
+4 -21
drivers/usb/core/message.c
··· 1133 /* prevent submissions using previous endpoint settings */ 1134 usb_disable_interface(dev, iface); 1135 1136 - /* 9.1.1.5 says: 1137 - * 1138 - * Configuring a device or changing an alternate setting 1139 - * causes all of the status and configuration values 1140 - * associated with endpoints in the affected interfaces to 1141 - * be set to their default values. This includes setting 1142 - * the data toggle of any endpoint using data toggles to 1143 - * the value DATA0. 1144 - * 1145 - * Some devices take this too literally and don't reset the data 1146 - * toggles if the new altsetting is the same as the old one (the 1147 - * command isn't "changing" an alternate setting). We will manually 1148 - * reset the toggles when the new and old altsettings are the same. 1149 - * Most devices won't need this, but fortunately it doesn't happen 1150 - * often. 1151 - */ 1152 - if (iface->cur_altsetting == alt) 1153 - manual = 1; 1154 iface->cur_altsetting = alt; 1155 1156 /* If the interface only has one altsetting and the device didn't 1157 - * accept the request (or whenever the old altsetting is the same 1158 - * as the new one), we attempt to carry out the equivalent action 1159 * by manually clearing the HALT feature for each endpoint in the 1160 * new altsetting. 1161 */ ··· 1183 * 1184 * Because this affects multiple interfaces, avoid using this with composite 1185 * (multi-interface) devices. Instead, the driver for each interface may 1186 - * use usb_set_interface() on the interfaces it claims. Resetting the whole 1187 * configuration would affect other drivers' interfaces. 1188 * 1189 * The caller must own the device lock.
··· 1133 /* prevent submissions using previous endpoint settings */ 1134 usb_disable_interface(dev, iface); 1135 1136 iface->cur_altsetting = alt; 1137 1138 /* If the interface only has one altsetting and the device didn't 1139 + * accept the request, we attempt to carry out the equivalent action 1140 * by manually clearing the HALT feature for each endpoint in the 1141 * new altsetting. 1142 */ ··· 1202 * 1203 * Because this affects multiple interfaces, avoid using this with composite 1204 * (multi-interface) devices. Instead, the driver for each interface may 1205 + * use usb_set_interface() on the interfaces it claims. Be careful though; 1206 + * some devices don't support the SET_INTERFACE request, and others won't 1207 + * reset all the interface state (notably data toggles). Resetting the whole 1208 * configuration would affect other drivers' interfaces. 1209 * 1210 * The caller must own the device lock.
+10 -6
drivers/usb/core/urb.c
··· 420 * 421 * Host Controller Drivers (HCDs) place all the URBs for a particular 422 * endpoint in a queue. Normally the queue advances as the controller 423 - * hardware processes each request. But when an URB terminates with any 424 - * fault (such as an error, or being unlinked) its queue stops, at least 425 - * until that URB's completion routine returns. It is guaranteed that 426 - * the queue will not restart until all its unlinked URBs have been fully 427 - * retired, with their completion routines run, even if that's not until 428 - * some time after the original completion handler returns. 429 * 430 * This means that USB device drivers can safely build deep queues for 431 * large or complex transfers, and clean them up reliably after any sort
··· 420 * 421 * Host Controller Drivers (HCDs) place all the URBs for a particular 422 * endpoint in a queue. Normally the queue advances as the controller 423 + * hardware processes each request. But when an URB terminates with an 424 + * error its queue stops, at least until that URB's completion routine 425 + * returns. It is guaranteed that the queue will not restart until all 426 + * its unlinked URBs have been fully retired, with their completion 427 + * routines run, even if that's not until some time after the original 428 + * completion handler returns. Normally the same behavior and guarantees 429 + * apply when an URB terminates because it was unlinked; however if an 430 + * URB is unlinked before the hardware has started to execute it, then 431 + * its queue is not guaranteed to stop until all the preceding URBs have 432 + * completed. 433 * 434 * This means that USB device drivers can safely build deep queues for 435 * large or complex transfers, and clean them up reliably after any sort
+3 -10
drivers/usb/core/usb.c
··· 50 #include "hcd.h" 51 #include "usb.h" 52 53 - extern int usb_hub_init(void); 54 - extern void usb_hub_cleanup(void); 55 - extern int usb_major_init(void); 56 - extern void usb_major_cleanup(void); 57 - extern int usb_host_init(void); 58 - extern void usb_host_cleanup(void); 59 - 60 61 const char *usbcore_name = "usbcore"; 62 ··· 1375 usb_pipein (pipe) ? DMA_FROM_DEVICE : DMA_TO_DEVICE); 1376 } 1377 1378 - static int usb_generic_suspend(struct device *dev, u32 state) 1379 { 1380 struct usb_interface *intf; 1381 struct usb_driver *driver; 1382 1383 if (dev->driver == &usb_generic_driver) 1384 - return usb_suspend_device (to_usb_device(dev), state); 1385 1386 if ((dev->driver == NULL) || 1387 (dev->driver_data == &usb_generic_driver_data)) ··· 1395 return 0; 1396 1397 if (driver->suspend) 1398 - return driver->suspend(intf, state); 1399 return 0; 1400 } 1401
··· 50 #include "hcd.h" 51 #include "usb.h" 52 53 54 const char *usbcore_name = "usbcore"; 55 ··· 1382 usb_pipein (pipe) ? DMA_FROM_DEVICE : DMA_TO_DEVICE); 1383 } 1384 1385 + static int usb_generic_suspend(struct device *dev, pm_message_t message) 1386 { 1387 struct usb_interface *intf; 1388 struct usb_driver *driver; 1389 1390 if (dev->driver == &usb_generic_driver) 1391 + return usb_suspend_device (to_usb_device(dev), message); 1392 1393 if ((dev->driver == NULL) || 1394 (dev->driver_data == &usb_generic_driver_data)) ··· 1402 return 0; 1403 1404 if (driver->suspend) 1405 + return driver->suspend(intf, message); 1406 return 0; 1407 } 1408
+8
drivers/usb/core/usb.h
··· 21 extern void usb_kick_khubd(struct usb_device *dev); 22 extern void usb_resume_root_hub(struct usb_device *dev); 23 24 /* for labeling diagnostics */ 25 extern const char *usbcore_name; 26 ··· 36 extern struct file_operations usbfs_devices_fops; 37 extern struct file_operations usbfs_device_file_operations; 38 extern void usbfs_conn_disc_event(void); 39 40 struct dev_state { 41 struct list_head list; /* state list */
··· 21 extern void usb_kick_khubd(struct usb_device *dev); 22 extern void usb_resume_root_hub(struct usb_device *dev); 23 24 + extern int usb_hub_init(void); 25 + extern void usb_hub_cleanup(void); 26 + extern int usb_major_init(void); 27 + extern void usb_major_cleanup(void); 28 + extern int usb_host_init(void); 29 + extern void usb_host_cleanup(void); 30 + 31 /* for labeling diagnostics */ 32 extern const char *usbcore_name; 33 ··· 29 extern struct file_operations usbfs_devices_fops; 30 extern struct file_operations usbfs_device_file_operations; 31 extern void usbfs_conn_disc_event(void); 32 + 33 34 struct dev_state { 35 struct list_head list; /* state list */
+24 -32
drivers/usb/gadget/ether.c
··· 100 101 /* CDC and RNDIS support the same host-chosen outgoing packet filters. */ 102 #define DEFAULT_FILTER (USB_CDC_PACKET_TYPE_BROADCAST \ 103 |USB_CDC_PACKET_TYPE_DIRECTED) 104 105 ··· 324 /* also defer IRQs on highspeed TX */ 325 #define TX_DELAY qmult 326 327 - #define BITRATE(g) (((g)->speed == USB_SPEED_HIGH) ? HS_BPS : FS_BPS) 328 329 #else /* full speed (low speed doesn't do bulk) */ 330 #define qlen(gadget) DEFAULT_QLEN 331 332 - #define BITRATE(g) FS_BPS 333 #endif 334 335 ··· 1175 eth_reset_config (dev); 1176 1177 /* default: pass all packets, no multicast filtering */ 1178 - dev->cdc_filter = 0x000f; 1179 1180 switch (number) { 1181 case DEV_CONFIG_VALUE: ··· 1351 struct eth_dev *dev = get_gadget_data (gadget); 1352 struct usb_request *req = dev->req; 1353 int value = -EOPNOTSUPP; 1354 - u16 wIndex = ctrl->wIndex; 1355 - u16 wValue = ctrl->wValue; 1356 - u16 wLength = ctrl->wLength; 1357 1358 /* descriptors just go into the pre-allocated ep0 buffer, 1359 * while config change events may enable network traffic. ··· 1701 1702 /* Some platforms perform better when IP packets are aligned, 1703 * but on at least one, checksumming fails otherwise. Note: 1704 - * this doesn't account for variable-sized RNDIS headers. 1705 */ 1706 skb_reserve(skb, NET_IP_ALIGN); 1707 ··· 1738 #ifdef CONFIG_USB_ETH_RNDIS 1739 /* we know MaxPacketsPerTransfer == 1 here */ 1740 if (dev->rndis) 1741 - rndis_rm_hdr (req->buf, &(skb->len)); 1742 #endif 1743 - if (ETH_HLEN > skb->len || skb->len > ETH_FRAME_LEN) { 1744 dev->stats.rx_errors++; 1745 dev->stats.rx_length_errors++; 1746 DEBUG (dev, "rx length %d\n", skb->len); ··· 2057 DEBUG ((struct eth_dev *) ep->driver_data, 2058 "rndis control ack complete --> %d, %d/%d\n", 2059 req->status, req->actual, req->length); 2060 - 2061 - usb_ep_free_buffer(ep, req->buf, req->dma, 8); 2062 - usb_ep_free_request(ep, req); 2063 } 2064 2065 static int rndis_control_ack (struct net_device *net) 2066 { 2067 struct eth_dev *dev = netdev_priv(net); 2068 u32 length; 2069 - struct usb_request *resp; 2070 2071 /* in case RNDIS calls this after disconnect */ 2072 - if (!dev->status_ep) { 2073 DEBUG (dev, "status ENODEV\n"); 2074 return -ENODEV; 2075 } 2076 2077 - /* Allocate memory for notification ie. ACK */ 2078 - resp = usb_ep_alloc_request (dev->status_ep, GFP_ATOMIC); 2079 - if (!resp) { 2080 - DEBUG (dev, "status ENOMEM\n"); 2081 - return -ENOMEM; 2082 - } 2083 - 2084 - resp->buf = usb_ep_alloc_buffer (dev->status_ep, 8, 2085 - &resp->dma, GFP_ATOMIC); 2086 - if (!resp->buf) { 2087 - DEBUG (dev, "status buf ENOMEM\n"); 2088 - usb_ep_free_request (dev->status_ep, resp); 2089 - return -ENOMEM; 2090 - } 2091 - 2092 /* Send RNDIS RESPONSE_AVAILABLE notification; 2093 * USB_CDC_NOTIFY_RESPONSE_AVAILABLE should work too 2094 */ ··· 2105 if (dev->rndis) { 2106 rndis_set_param_medium (dev->rndis_config, 2107 NDIS_MEDIUM_802_3, 2108 - BITRATE(dev->gadget)); 2109 rndis_send_media_state (dev, 1); 2110 } 2111 #endif ··· 2299 device_desc.bcdDevice = __constant_cpu_to_le16 (0x0210); 2300 } else if (gadget_is_pxa27x(gadget)) { 2301 device_desc.bcdDevice = __constant_cpu_to_le16 (0x0211); 2302 - } else if (gadget_is_s3c2410(gadget)) { 2303 - device_desc.bcdDevice = __constant_cpu_to_le16 (0x0212); 2304 } else if (gadget_is_at91(gadget)) { 2305 device_desc.bcdDevice = __constant_cpu_to_le16 (0x0213); 2306 } else {
··· 100 101 /* CDC and RNDIS support the same host-chosen outgoing packet filters. */ 102 #define DEFAULT_FILTER (USB_CDC_PACKET_TYPE_BROADCAST \ 103 + |USB_CDC_PACKET_TYPE_ALL_MULTICAST \ 104 + |USB_CDC_PACKET_TYPE_PROMISCUOUS \ 105 |USB_CDC_PACKET_TYPE_DIRECTED) 106 107 ··· 322 /* also defer IRQs on highspeed TX */ 323 #define TX_DELAY qmult 324 325 + static inline int BITRATE(struct usb_gadget *g) 326 + { 327 + return (g->speed == USB_SPEED_HIGH) ? HS_BPS : FS_BPS; 328 + } 329 330 #else /* full speed (low speed doesn't do bulk) */ 331 #define qlen(gadget) DEFAULT_QLEN 332 333 + static inline int BITRATE(struct usb_gadget *g) 334 + { 335 + return FS_BPS; 336 + } 337 #endif 338 339 ··· 1167 eth_reset_config (dev); 1168 1169 /* default: pass all packets, no multicast filtering */ 1170 + dev->cdc_filter = DEFAULT_FILTER; 1171 1172 switch (number) { 1173 case DEV_CONFIG_VALUE: ··· 1343 struct eth_dev *dev = get_gadget_data (gadget); 1344 struct usb_request *req = dev->req; 1345 int value = -EOPNOTSUPP; 1346 + u16 wIndex = (__force u16) ctrl->wIndex; 1347 + u16 wValue = (__force u16) ctrl->wValue; 1348 + u16 wLength = (__force u16) ctrl->wLength; 1349 1350 /* descriptors just go into the pre-allocated ep0 buffer, 1351 * while config change events may enable network traffic. ··· 1693 1694 /* Some platforms perform better when IP packets are aligned, 1695 * but on at least one, checksumming fails otherwise. Note: 1696 + * RNDIS headers involve variable numbers of LE32 values. 1697 */ 1698 skb_reserve(skb, NET_IP_ALIGN); 1699 ··· 1730 #ifdef CONFIG_USB_ETH_RNDIS 1731 /* we know MaxPacketsPerTransfer == 1 here */ 1732 if (dev->rndis) 1733 + status = rndis_rm_hdr (skb); 1734 #endif 1735 + if (status < 0 1736 + || ETH_HLEN > skb->len 1737 + || skb->len > ETH_FRAME_LEN) { 1738 dev->stats.rx_errors++; 1739 dev->stats.rx_length_errors++; 1740 DEBUG (dev, "rx length %d\n", skb->len); ··· 2047 DEBUG ((struct eth_dev *) ep->driver_data, 2048 "rndis control ack complete --> %d, %d/%d\n", 2049 req->status, req->actual, req->length); 2050 } 2051 2052 static int rndis_control_ack (struct net_device *net) 2053 { 2054 struct eth_dev *dev = netdev_priv(net); 2055 u32 length; 2056 + struct usb_request *resp = dev->stat_req; 2057 2058 /* in case RNDIS calls this after disconnect */ 2059 + if (!dev->status) { 2060 DEBUG (dev, "status ENODEV\n"); 2061 return -ENODEV; 2062 } 2063 2064 /* Send RNDIS RESPONSE_AVAILABLE notification; 2065 * USB_CDC_NOTIFY_RESPONSE_AVAILABLE should work too 2066 */ ··· 2113 if (dev->rndis) { 2114 rndis_set_param_medium (dev->rndis_config, 2115 NDIS_MEDIUM_802_3, 2116 + BITRATE(dev->gadget)/100); 2117 rndis_send_media_state (dev, 1); 2118 } 2119 #endif ··· 2307 device_desc.bcdDevice = __constant_cpu_to_le16 (0x0210); 2308 } else if (gadget_is_pxa27x(gadget)) { 2309 device_desc.bcdDevice = __constant_cpu_to_le16 (0x0211); 2310 + } else if (gadget_is_s3c2410(gadget)) { 2311 + device_desc.bcdDevice = __constant_cpu_to_le16 (0x0212); 2312 } else if (gadget_is_at91(gadget)) { 2313 device_desc.bcdDevice = __constant_cpu_to_le16 (0x0213); 2314 } else {
+5 -7
drivers/usb/gadget/omap_udc.c
··· 2809 return 0; 2810 } 2811 2812 - /* suspend/resume/wakeup from sysfs (echo > power/state) */ 2813 - 2814 - static int omap_udc_suspend(struct device *dev, u32 state, u32 level) 2815 { 2816 if (level != 0) 2817 return 0; 2818 2819 DBG("suspend, state %d\n", state); 2820 omap_pullup(&udc->gadget, 0); 2821 - udc->gadget.dev.power.power_state = 3; 2822 - udc->gadget.dev.parent->power.power_state = 3; 2823 return 0; 2824 } 2825 ··· 2827 return 0; 2828 2829 DBG("resume + wakeup/SRP\n"); 2830 - udc->gadget.dev.parent->power.power_state = 0; 2831 - udc->gadget.dev.power.power_state = 0; 2832 omap_pullup(&udc->gadget, 1); 2833 2834 /* maybe the host would enumerate us if we nudged it */
··· 2809 return 0; 2810 } 2811 2812 + static int omap_udc_suspend(struct device *dev, pm_message_t state, u32 level) 2813 { 2814 if (level != 0) 2815 return 0; 2816 2817 DBG("suspend, state %d\n", state); 2818 omap_pullup(&udc->gadget, 0); 2819 + udc->gadget.dev.power.power_state = PMSG_SUSPEND; 2820 + udc->gadget.dev.parent->power.power_state = PMSG_SUSPEND; 2821 return 0; 2822 } 2823 ··· 2829 return 0; 2830 2831 DBG("resume + wakeup/SRP\n"); 2832 + udc->gadget.dev.parent->power.power_state = PMSG_ON; 2833 + udc->gadget.dev.power.power_state = PMSG_ON; 2834 omap_pullup(&udc->gadget, 1); 2835 2836 /* maybe the host would enumerate us if we nudged it */
+19 -21
drivers/usb/gadget/rndis.c
··· 37 #include <asm/io.h> 38 #include <asm/byteorder.h> 39 #include <asm/system.h> 40 41 42 #undef RNDIS_PM ··· 166 167 /* mandatory */ 168 case OID_GEN_LINK_SPEED: 169 - DEBUG("%s: OID_GEN_LINK_SPEED\n", __FUNCTION__); 170 length = 4; 171 if (rndis_per_dev_params [configNr].media_state 172 == NDIS_MEDIA_STATE_DISCONNECTED) ··· 730 retval = 0; 731 732 /* FIXME use these NDIS_PACKET_TYPE_* bitflags to 733 - * filter packets in hard_start_xmit() 734 * NDIS_PACKET_TYPE_x == USB_CDC_PACKET_TYPE_x for x in: 735 * PROMISCUOUS, DIRECTED, 736 * MULTICAST, ALL_MULTICAST, BROADCAST ··· 1195 return; 1196 header = (void *) skb_push (skb, sizeof *header); 1197 memset (header, 0, sizeof *header); 1198 - header->MessageType = __constant_cpu_to_le32 (1); 1199 header->MessageLength = cpu_to_le32(skb->len); 1200 header->DataOffset = __constant_cpu_to_le32 (36); 1201 - header->OOBDataOffset = cpu_to_le32(skb->len - 44); 1202 } 1203 1204 void rndis_free_response (int configNr, u8 *buf) ··· 1254 return r; 1255 } 1256 1257 - int rndis_rm_hdr (u8 *buf, u32 *length) 1258 { 1259 - u32 i, messageLen, dataOffset; 1260 - __le32 *tmp; 1261 - 1262 - tmp = (__le32 *) buf; 1263 1264 - if (!buf || !length) return -1; 1265 - if (le32_to_cpup(tmp++) != 1) return -1; 1266 - 1267 - messageLen = le32_to_cpup(tmp++); 1268 - dataOffset = le32_to_cpup(tmp++) + 8; 1269 1270 - if (messageLen < dataOffset || messageLen > *length) return -1; 1271 - 1272 - for (i = dataOffset; i < messageLen; i++) 1273 - buf [i - dataOffset] = buf [i]; 1274 - 1275 - *length = messageLen - dataOffset; 1276 - 1277 return 0; 1278 } 1279
··· 37 #include <asm/io.h> 38 #include <asm/byteorder.h> 39 #include <asm/system.h> 40 + #include <asm/unaligned.h> 41 42 43 #undef RNDIS_PM ··· 165 166 /* mandatory */ 167 case OID_GEN_LINK_SPEED: 168 + // DEBUG("%s: OID_GEN_LINK_SPEED\n", __FUNCTION__); 169 length = 4; 170 if (rndis_per_dev_params [configNr].media_state 171 == NDIS_MEDIA_STATE_DISCONNECTED) ··· 729 retval = 0; 730 731 /* FIXME use these NDIS_PACKET_TYPE_* bitflags to 732 + * set the cdc_filter; it's not RNDIS-specific 733 * NDIS_PACKET_TYPE_x == USB_CDC_PACKET_TYPE_x for x in: 734 * PROMISCUOUS, DIRECTED, 735 * MULTICAST, ALL_MULTICAST, BROADCAST ··· 1194 return; 1195 header = (void *) skb_push (skb, sizeof *header); 1196 memset (header, 0, sizeof *header); 1197 + header->MessageType = __constant_cpu_to_le32(REMOTE_NDIS_PACKET_MSG); 1198 header->MessageLength = cpu_to_le32(skb->len); 1199 header->DataOffset = __constant_cpu_to_le32 (36); 1200 + header->DataLength = cpu_to_le32(skb->len - sizeof *header); 1201 } 1202 1203 void rndis_free_response (int configNr, u8 *buf) ··· 1253 return r; 1254 } 1255 1256 + int rndis_rm_hdr(struct sk_buff *skb) 1257 { 1258 + /* tmp points to a struct rndis_packet_msg_type */ 1259 + __le32 *tmp = (void *) skb->data; 1260 1261 + /* MessageType, MessageLength */ 1262 + if (__constant_cpu_to_le32(REMOTE_NDIS_PACKET_MSG) 1263 + != get_unaligned(tmp++)) 1264 + return -EINVAL; 1265 + tmp++; 1266 1267 + /* DataOffset, DataLength */ 1268 + if (!skb_pull(skb, le32_to_cpu(get_unaligned(tmp++)) 1269 + + 8 /* offset of DataOffset */)) 1270 + return -EOVERFLOW; 1271 + skb_trim(skb, le32_to_cpu(get_unaligned(tmp++))); 1272 + 1273 return 0; 1274 } 1275
+2 -1
drivers/usb/gadget/rndis.h
··· 38 */ 39 40 /* Message Set for Connectionless (802.3) Devices */ 41 #define REMOTE_NDIS_INITIALIZE_MSG 0x00000002U /* Initialize device */ 42 #define REMOTE_NDIS_HALT_MSG 0x00000003U 43 #define REMOTE_NDIS_QUERY_MSG 0x00000004U ··· 334 const char *vendorDescr); 335 int rndis_set_param_medium (u8 configNr, u32 medium, u32 speed); 336 void rndis_add_hdr (struct sk_buff *skb); 337 - int rndis_rm_hdr (u8 *buf, u32 *length); 338 u8 *rndis_get_next_response (int configNr, u32 *length); 339 void rndis_free_response (int configNr, u8 *buf); 340
··· 38 */ 39 40 /* Message Set for Connectionless (802.3) Devices */ 41 + #define REMOTE_NDIS_PACKET_MSG 0x00000001U 42 #define REMOTE_NDIS_INITIALIZE_MSG 0x00000002U /* Initialize device */ 43 #define REMOTE_NDIS_HALT_MSG 0x00000003U 44 #define REMOTE_NDIS_QUERY_MSG 0x00000004U ··· 333 const char *vendorDescr); 334 int rndis_set_param_medium (u8 configNr, u32 medium, u32 speed); 335 void rndis_add_hdr (struct sk_buff *skb); 336 + int rndis_rm_hdr (struct sk_buff *skb); 337 u8 *rndis_get_next_response (int configNr, u32 *length); 338 void rndis_free_response (int configNr, u8 *buf); 339
+2 -3
drivers/usb/gadget/serial.c
··· 2312 */ 2313 void gs_buf_free(struct gs_buf *gb) 2314 { 2315 - if (gb != NULL) { 2316 - if (gb->buf_buf != NULL) 2317 - kfree(gb->buf_buf); 2318 kfree(gb); 2319 } 2320 }
··· 2312 */ 2313 void gs_buf_free(struct gs_buf *gb) 2314 { 2315 + if (gb) { 2316 + kfree(gb->buf_buf); 2317 kfree(gb); 2318 } 2319 }
+1 -1
drivers/usb/host/ehci-dbg.c
··· 394 mark = ' '; 395 if (hw_curr == td->qtd_dma) 396 mark = '*'; 397 - else if (qh->hw_qtd_next == td->qtd_dma) 398 mark = '+'; 399 else if (QTD_LENGTH (scratch)) { 400 if (td->hw_alt_next == ehci->async->hw_alt_next)
··· 394 mark = ' '; 395 if (hw_curr == td->qtd_dma) 396 mark = '*'; 397 + else if (qh->hw_qtd_next == cpu_to_le32(td->qtd_dma)) 398 mark = '+'; 399 else if (QTD_LENGTH (scratch)) { 400 if (td->hw_alt_next == ehci->async->hw_alt_next)
+2 -2
drivers/usb/host/ehci-hcd.c
··· 721 * the right sort of wakeup. 722 */ 723 724 - static int ehci_suspend (struct usb_hcd *hcd, u32 state) 725 { 726 struct ehci_hcd *ehci = hcd_to_ehci (hcd); 727 ··· 729 msleep (100); 730 731 #ifdef CONFIG_USB_SUSPEND 732 - (void) usb_suspend_device (hcd->self.root_hub, state); 733 #else 734 usb_lock_device (hcd->self.root_hub); 735 (void) ehci_hub_suspend (hcd);
··· 721 * the right sort of wakeup. 722 */ 723 724 + static int ehci_suspend (struct usb_hcd *hcd, pm_message_t message) 725 { 726 struct ehci_hcd *ehci = hcd_to_ehci (hcd); 727 ··· 729 msleep (100); 730 731 #ifdef CONFIG_USB_SUSPEND 732 + (void) usb_suspend_device (hcd->self.root_hub, message); 733 #else 734 usb_lock_device (hcd->self.root_hub); 735 (void) ehci_hub_suspend (hcd);
+1 -2
drivers/usb/host/ehci-mem.c
··· 156 ehci->periodic = NULL; 157 158 /* shadow periodic table */ 159 - if (ehci->pshadow) 160 - kfree (ehci->pshadow); 161 ehci->pshadow = NULL; 162 } 163
··· 156 ehci->periodic = NULL; 157 158 /* shadow periodic table */ 159 + kfree(ehci->pshadow); 160 ehci->pshadow = NULL; 161 } 162
+2 -2
drivers/usb/host/ehci-sched.c
··· 310 311 for (i = qh->start; i < ehci->periodic_size; i += period) { 312 union ehci_shadow *prev = &ehci->pshadow [i]; 313 - u32 *hw_p = &ehci->periodic [i]; 314 union ehci_shadow here = *prev; 315 - u32 type = 0; 316 317 /* skip the iso nodes at list head */ 318 while (here.ptr) {
··· 310 311 for (i = qh->start; i < ehci->periodic_size; i += period) { 312 union ehci_shadow *prev = &ehci->pshadow [i]; 313 + __le32 *hw_p = &ehci->periodic [i]; 314 union ehci_shadow here = *prev; 315 + __le32 type = 0; 316 317 /* skip the iso nodes at list head */ 318 while (here.ptr) {
+1 -1
drivers/usb/host/ehci.h
··· 364 struct ehci_itd *itd; /* Q_TYPE_ITD */ 365 struct ehci_sitd *sitd; /* Q_TYPE_SITD */ 366 struct ehci_fstn *fstn; /* Q_TYPE_FSTN */ 367 - u32 *hw_next; /* (all types) */ 368 void *ptr; 369 }; 370
··· 364 struct ehci_itd *itd; /* Q_TYPE_ITD */ 365 struct ehci_sitd *sitd; /* Q_TYPE_SITD */ 366 struct ehci_fstn *fstn; /* Q_TYPE_FSTN */ 367 + __le32 *hw_next; /* (all types) */ 368 void *ptr; 369 }; 370
+3 -1
drivers/usb/host/ohci-omap.c
··· 458 459 /* states match PCI usage, always suspending the root hub except that 460 * 4 ~= D3cold (ACPI D3) with clock off (resume sees reset). 461 */ 462 463 - static int ohci_omap_suspend(struct device *dev, u32 state, u32 level) 464 { 465 struct ohci_hcd *ohci = hcd_to_ohci(dev_get_drvdata(dev)); 466 int status = -EINVAL;
··· 458 459 /* states match PCI usage, always suspending the root hub except that 460 * 4 ~= D3cold (ACPI D3) with clock off (resume sees reset). 461 + * 462 + * FIXME: above comment is not right, and code is wrong, too :-(. 463 */ 464 465 + static int ohci_omap_suspend(struct device *dev, pm_message_t state, u32 level) 466 { 467 struct ohci_hcd *ohci = hcd_to_ohci(dev_get_drvdata(dev)); 468 int status = -EINVAL;
+16 -5
drivers/usb/host/ohci-pci.c
··· 54 if (pdev->vendor == PCI_VENDOR_ID_AMD 55 && pdev->device == 0x740c) { 56 ohci->flags = OHCI_QUIRK_AMD756; 57 - ohci_info (ohci, "AMD756 erratum 4 workaround\n"); 58 // also somewhat erratum 10 (suspend/resume issues) 59 } 60 ··· 68 */ 69 else if (pdev->vendor == PCI_VENDOR_ID_OPTI 70 && pdev->device == 0xc861) { 71 - ohci_info (ohci, 72 "WARNING: OPTi workarounds unavailable\n"); 73 } 74 ··· 84 if (b && b->device == PCI_DEVICE_ID_NS_87560_LIO 85 && b->vendor == PCI_VENDOR_ID_NS) { 86 ohci->flags |= OHCI_QUIRK_SUPERIO; 87 - ohci_info (ohci, "Using NSC SuperIO setup\n"); 88 } 89 } 90 } 91 ··· 113 114 #ifdef CONFIG_PM 115 116 - static int ohci_pci_suspend (struct usb_hcd *hcd, u32 state) 117 { 118 struct ohci_hcd *ohci = hcd_to_ohci (hcd); 119 ··· 122 msleep (100); 123 124 #ifdef CONFIG_USB_SUSPEND 125 - (void) usb_suspend_device (hcd->self.root_hub, state); 126 #else 127 usb_lock_device (hcd->self.root_hub); 128 (void) ohci_hub_suspend (hcd);
··· 54 if (pdev->vendor == PCI_VENDOR_ID_AMD 55 && pdev->device == 0x740c) { 56 ohci->flags = OHCI_QUIRK_AMD756; 57 + ohci_dbg (ohci, "AMD756 erratum 4 workaround\n"); 58 // also somewhat erratum 10 (suspend/resume issues) 59 } 60 ··· 68 */ 69 else if (pdev->vendor == PCI_VENDOR_ID_OPTI 70 && pdev->device == 0xc861) { 71 + ohci_dbg (ohci, 72 "WARNING: OPTi workarounds unavailable\n"); 73 } 74 ··· 84 if (b && b->device == PCI_DEVICE_ID_NS_87560_LIO 85 && b->vendor == PCI_VENDOR_ID_NS) { 86 ohci->flags |= OHCI_QUIRK_SUPERIO; 87 + ohci_dbg (ohci, "Using NSC SuperIO setup\n"); 88 } 89 + } 90 + 91 + /* Check for Compaq's ZFMicro chipset, which needs short 92 + * delays before control or bulk queues get re-activated 93 + * in finish_unlinks() 94 + */ 95 + else if (pdev->vendor == PCI_VENDOR_ID_COMPAQ 96 + && pdev->device == 0xa0f8) { 97 + ohci->flags |= OHCI_QUIRK_ZFMICRO; 98 + ohci_dbg (ohci, 99 + "enabled Compaq ZFMicro chipset quirk\n"); 100 } 101 } 102 ··· 102 103 #ifdef CONFIG_PM 104 105 + static int ohci_pci_suspend (struct usb_hcd *hcd, pm_message_t message) 106 { 107 struct ohci_hcd *ohci = hcd_to_ohci (hcd); 108 ··· 111 msleep (100); 112 113 #ifdef CONFIG_USB_SUSPEND 114 + (void) usb_suspend_device (hcd->self.root_hub, message); 115 #else 116 usb_lock_device (hcd->self.root_hub); 117 (void) ohci_hub_suspend (hcd);
+2 -2
drivers/usb/host/ohci-pxa27x.c
··· 337 return 0; 338 } 339 340 - static int ohci_hcd_pxa27x_drv_suspend(struct device *dev, u32 state, u32 level) 341 { 342 // struct platform_device *pdev = to_platform_device(dev); 343 // struct usb_hcd *hcd = dev_get_drvdata(dev); ··· 346 return 0; 347 } 348 349 - static int ohci_hcd_pxa27x_drv_resume(struct device *dev, u32 state) 350 { 351 // struct platform_device *pdev = to_platform_device(dev); 352 // struct usb_hcd *hcd = dev_get_drvdata(dev);
··· 337 return 0; 338 } 339 340 + static int ohci_hcd_pxa27x_drv_suspend(struct device *dev, pm_message_t state, u32 level) 341 { 342 // struct platform_device *pdev = to_platform_device(dev); 343 // struct usb_hcd *hcd = dev_get_drvdata(dev); ··· 346 return 0; 347 } 348 349 + static int ohci_hcd_pxa27x_drv_resume(struct device *dev, u32 level) 350 { 351 // struct platform_device *pdev = to_platform_device(dev); 352 // struct usb_hcd *hcd = dev_get_drvdata(dev);
+11 -2
drivers/usb/host/ohci-q.c
··· 1021 1022 if (ohci->ed_controltail) { 1023 command |= OHCI_CLF; 1024 if (!(ohci->hc_control & OHCI_CTRL_CLE)) { 1025 control |= OHCI_CTRL_CLE; 1026 ohci_writel (ohci, 0, ··· 1031 } 1032 if (ohci->ed_bulktail) { 1033 command |= OHCI_BLF; 1034 if (!(ohci->hc_control & OHCI_CTRL_BLE)) { 1035 control |= OHCI_CTRL_BLE; 1036 ohci_writel (ohci, 0, ··· 1043 /* CLE/BLE to enable, CLF/BLF to (maybe) kickstart */ 1044 if (control) { 1045 ohci->hc_control |= control; 1046 ohci_writel (ohci, ohci->hc_control, 1047 &ohci->regs->control); 1048 } 1049 - if (command) 1050 ohci_writel (ohci, command, &ohci->regs->cmdstatus); 1051 - } 1052 } 1053 1054
··· 1021 1022 if (ohci->ed_controltail) { 1023 command |= OHCI_CLF; 1024 + if (ohci->flags & OHCI_QUIRK_ZFMICRO) 1025 + mdelay(1); 1026 if (!(ohci->hc_control & OHCI_CTRL_CLE)) { 1027 control |= OHCI_CTRL_CLE; 1028 ohci_writel (ohci, 0, ··· 1029 } 1030 if (ohci->ed_bulktail) { 1031 command |= OHCI_BLF; 1032 + if (ohci->flags & OHCI_QUIRK_ZFMICRO) 1033 + mdelay(1); 1034 if (!(ohci->hc_control & OHCI_CTRL_BLE)) { 1035 control |= OHCI_CTRL_BLE; 1036 ohci_writel (ohci, 0, ··· 1039 /* CLE/BLE to enable, CLF/BLF to (maybe) kickstart */ 1040 if (control) { 1041 ohci->hc_control |= control; 1042 + if (ohci->flags & OHCI_QUIRK_ZFMICRO) 1043 + mdelay(1); 1044 ohci_writel (ohci, ohci->hc_control, 1045 &ohci->regs->control); 1046 } 1047 + if (command) { 1048 + if (ohci->flags & OHCI_QUIRK_ZFMICRO) 1049 + mdelay(1); 1050 ohci_writel (ohci, command, &ohci->regs->cmdstatus); 1051 + } 1052 + } 1053 } 1054 1055
+1
drivers/usb/host/ohci.h
··· 396 #define OHCI_QUIRK_SUPERIO 0x02 /* natsemi */ 397 #define OHCI_QUIRK_INITRESET 0x04 /* SiS, OPTi, ... */ 398 #define OHCI_BIG_ENDIAN 0x08 /* big endian HC */ 399 // there are also chip quirks/bugs in init logic 400 401 };
··· 396 #define OHCI_QUIRK_SUPERIO 0x02 /* natsemi */ 397 #define OHCI_QUIRK_INITRESET 0x04 /* SiS, OPTi, ... */ 398 #define OHCI_BIG_ENDIAN 0x08 /* big endian HC */ 399 + #define OHCI_QUIRK_ZFMICRO 0x10 /* Compaq ZFMicro chipset*/ 400 // there are also chip quirks/bugs in init logic 401 402 };
+3 -6
drivers/usb/host/uhci-hcd.c
··· 716 } 717 718 #ifdef CONFIG_PM 719 - static int uhci_suspend(struct usb_hcd *hcd, u32 state) 720 { 721 struct uhci_hcd *uhci = hcd_to_uhci(hcd); 722 ··· 890 debugfs_remove(uhci_debugfs_root); 891 892 debug_failed: 893 - if (errbuf) 894 - kfree(errbuf); 895 896 errbuf_failed: 897 ··· 905 warn("not all urb_priv's were freed!"); 906 907 debugfs_remove(uhci_debugfs_root); 908 - 909 - if (errbuf) 910 - kfree(errbuf); 911 } 912 913 module_init(uhci_hcd_init);
··· 716 } 717 718 #ifdef CONFIG_PM 719 + static int uhci_suspend(struct usb_hcd *hcd, pm_message_t message) 720 { 721 struct uhci_hcd *uhci = hcd_to_uhci(hcd); 722 ··· 890 debugfs_remove(uhci_debugfs_root); 891 892 debug_failed: 893 + kfree(errbuf); 894 895 errbuf_failed: 896 ··· 906 warn("not all urb_priv's were freed!"); 907 908 debugfs_remove(uhci_debugfs_root); 909 + kfree(errbuf); 910 } 911 912 module_init(uhci_hcd_init);
+1
drivers/usb/input/aiptek.c
··· 2138 aiptek->inputdev.id.vendor = le16_to_cpu(usbdev->descriptor.idVendor); 2139 aiptek->inputdev.id.product = le16_to_cpu(usbdev->descriptor.idProduct); 2140 aiptek->inputdev.id.version = le16_to_cpu(usbdev->descriptor.bcdDevice); 2141 2142 aiptek->usbdev = usbdev; 2143 aiptek->ifnum = intf->altsetting[0].desc.bInterfaceNumber;
··· 2138 aiptek->inputdev.id.vendor = le16_to_cpu(usbdev->descriptor.idVendor); 2139 aiptek->inputdev.id.product = le16_to_cpu(usbdev->descriptor.idProduct); 2140 aiptek->inputdev.id.version = le16_to_cpu(usbdev->descriptor.bcdDevice); 2141 + aiptek->inputdev.dev = &intf->dev; 2142 2143 aiptek->usbdev = usbdev; 2144 aiptek->ifnum = intf->altsetting[0].desc.bInterfaceNumber;
+4 -5
drivers/usb/input/hid-core.c
··· 558 } 559 } 560 561 - if (device->rdesc) 562 - kfree(device->rdesc); 563 kfree(device); 564 } 565 ··· 1789 return 0; 1790 } 1791 1792 - static int hid_suspend(struct usb_interface *intf, u32 state) 1793 { 1794 struct hid_device *hid = usb_get_intfdata (intf); 1795 1796 usb_kill_urb(hid->urbin); 1797 - intf->dev.power.power_state = state; 1798 dev_dbg(&intf->dev, "suspend\n"); 1799 return 0; 1800 } ··· 1804 struct hid_device *hid = usb_get_intfdata (intf); 1805 int status; 1806 1807 - intf->dev.power.power_state = PM_SUSPEND_ON; 1808 if (hid->open) 1809 status = usb_submit_urb(hid->urbin, GFP_NOIO); 1810 else
··· 558 } 559 } 560 561 + kfree(device->rdesc); 562 kfree(device); 563 } 564 ··· 1790 return 0; 1791 } 1792 1793 + static int hid_suspend(struct usb_interface *intf, pm_message_t message) 1794 { 1795 struct hid_device *hid = usb_get_intfdata (intf); 1796 1797 usb_kill_urb(hid->urbin); 1798 + intf->dev.power.power_state = PMSG_SUSPEND; 1799 dev_dbg(&intf->dev, "suspend\n"); 1800 return 0; 1801 } ··· 1805 struct hid_device *hid = usb_get_intfdata (intf); 1806 int status; 1807 1808 + intf->dev.power.power_state = PMSG_ON; 1809 if (hid->open) 1810 status = usb_submit_urb(hid->urbin, GFP_NOIO); 1811 else
+1 -2
drivers/usb/media/dabusb.c
··· 138 #ifdef DEBUG 139 dump_urb(b->purb); 140 #endif 141 - if (b->purb->transfer_buffer) 142 - kfree (b->purb->transfer_buffer); 143 usb_free_urb(b->purb); 144 tmp = p->next; 145 list_del (p);
··· 138 #ifdef DEBUG 139 dump_urb(b->purb); 140 #endif 141 + kfree(b->purb->transfer_buffer); 142 usb_free_urb(b->purb); 143 tmp = p->next; 144 list_del (p);
+4 -8
drivers/usb/media/ov511.c
··· 3915 ov->tempfbuf = NULL; 3916 3917 for (i = 0; i < OV511_NUMSBUF; i++) { 3918 - if (ov->sbuf[i].data) { 3919 - kfree(ov->sbuf[i].data); 3920 - ov->sbuf[i].data = NULL; 3921 - } 3922 } 3923 3924 for (i = 0; i < OV511_NUMFRAMES; i++) { ··· 5952 up(&ov->cbuf_lock); 5953 } 5954 5955 - if (ov) { 5956 - kfree(ov); 5957 - ov = NULL; 5958 - } 5959 5960 error_out: 5961 err("Camera initialization failed");
··· 3915 ov->tempfbuf = NULL; 3916 3917 for (i = 0; i < OV511_NUMSBUF; i++) { 3918 + kfree(ov->sbuf[i].data); 3919 + ov->sbuf[i].data = NULL; 3920 } 3921 3922 for (i = 0; i < OV511_NUMFRAMES; i++) { ··· 5954 up(&ov->cbuf_lock); 5955 } 5956 5957 + kfree(ov); 5958 + ov = NULL; 5959 5960 error_out: 5961 err("Camera initialization failed");
+8 -7
drivers/usb/media/se401.c
··· 868 869 se401->dev = NULL; 870 871 - for (i=0; i<SE401_NUMSBUF; i++) if (se401->urb[i]) { 872 - usb_kill_urb(se401->urb[i]); 873 - usb_free_urb(se401->urb[i]); 874 - se401->urb[i] = NULL; 875 - kfree(se401->sbuf[i].data); 876 - } 877 - for (i=0; i<SE401_NUMSCRATCH; i++) if (se401->scratch[i].data) { 878 kfree(se401->scratch[i].data); 879 } 880 if (se401->inturb) {
··· 868 869 se401->dev = NULL; 870 871 + for (i=0; i<SE401_NUMSBUF; i++) 872 + if (se401->urb[i]) { 873 + usb_kill_urb(se401->urb[i]); 874 + usb_free_urb(se401->urb[i]); 875 + se401->urb[i] = NULL; 876 + kfree(se401->sbuf[i].data); 877 + } 878 + for (i=0; i<SE401_NUMSCRATCH; i++) { 879 kfree(se401->scratch[i].data); 880 } 881 if (se401->inturb) {
+2 -4
drivers/usb/media/usbvideo.c
··· 1169 } 1170 RingQueue_Free(&uvd->dp); 1171 for (i=0; i < USBVIDEO_NUMSBUF; i++) { 1172 - if (uvd->sbuf[i].data != NULL) { 1173 - kfree (uvd->sbuf[i].data); 1174 - uvd->sbuf[i].data = NULL; 1175 - } 1176 } 1177 } 1178 }
··· 1169 } 1170 RingQueue_Free(&uvd->dp); 1171 for (i=0; i < USBVIDEO_NUMSBUF; i++) { 1172 + kfree(uvd->sbuf[i].data); 1173 + uvd->sbuf[i].data = NULL; 1174 } 1175 } 1176 }
+2 -4
drivers/usb/media/w9968cf.c
··· 3624 return 0; 3625 3626 fail: /* Free unused memory */ 3627 - if (cam->control_buffer) 3628 - kfree(cam->control_buffer); 3629 - if (cam->data_buffer) 3630 - kfree(cam->data_buffer); 3631 if (cam->v4ldev) 3632 video_device_release(cam->v4ldev); 3633 up(&cam->dev_sem);
··· 3624 return 0; 3625 3626 fail: /* Free unused memory */ 3627 + kfree(cam->control_buffer); 3628 + kfree(cam->data_buffer); 3629 if (cam->v4ldev) 3630 video_device_release(cam->v4ldev); 3631 up(&cam->dev_sem);
+10 -16
drivers/usb/misc/auerswald.c
··· 705 /* free a single auerbuf */ 706 static void auerbuf_free (pauerbuf_t bp) 707 { 708 - if (bp->bufp) { 709 - kfree (bp->bufp); 710 - } 711 - if (bp->dr) { 712 - kfree (bp->dr); 713 - } 714 if (bp->urbp) { 715 - usb_free_urb (bp->urbp); 716 } 717 - kfree (bp); 718 } 719 720 /* free the buffers from an auerbuf list */ ··· 1089 */ 1090 static void auerswald_int_free (pauerswald_t cp) 1091 { 1092 - if (cp->inturbp) { 1093 - usb_free_urb (cp->inturbp); 1094 - cp->inturbp = NULL; 1095 - } 1096 - if (cp->intbufp) { 1097 - kfree (cp->intbufp); 1098 - cp->intbufp = NULL; 1099 - } 1100 } 1101 1102 /* This function is called to activate the interrupt
··· 705 /* free a single auerbuf */ 706 static void auerbuf_free (pauerbuf_t bp) 707 { 708 + kfree(bp->bufp); 709 + kfree(bp->dr); 710 if (bp->urbp) { 711 + usb_free_urb(bp->urbp); 712 } 713 + kfree(bp); 714 } 715 716 /* free the buffers from an auerbuf list */ ··· 1093 */ 1094 static void auerswald_int_free (pauerswald_t cp) 1095 { 1096 + if (cp->inturbp) { 1097 + usb_free_urb(cp->inturbp); 1098 + cp->inturbp = NULL; 1099 + } 1100 + kfree(cp->intbufp); 1101 + cp->intbufp = NULL; 1102 } 1103 1104 /* This function is called to activate the interrupt
+2 -1
drivers/usb/misc/sisusbvga/sisusb.c
··· 3104 3105 static struct usb_device_id sisusb_table [] = { 3106 { USB_DEVICE(0x0711, 0x0900) }, 3107 { } 3108 }; 3109 ··· 3115 .name = "sisusb", 3116 .probe = sisusb_probe, 3117 .disconnect = sisusb_disconnect, 3118 - .id_table = sisusb_table 3119 }; 3120 3121 static int __init usb_sisusb_init(void)
··· 3104 3105 static struct usb_device_id sisusb_table [] = { 3106 { USB_DEVICE(0x0711, 0x0900) }, 3107 + { USB_DEVICE(0x182d, 0x021c) }, 3108 { } 3109 }; 3110 ··· 3114 .name = "sisusb", 3115 .probe = sisusb_probe, 3116 .disconnect = sisusb_disconnect, 3117 + .id_table = sisusb_table, 3118 }; 3119 3120 static int __init usb_sisusb_init(void)
+21 -1
drivers/usb/net/pegasus.c
··· 1364 free_netdev(pegasus->net); 1365 } 1366 1367 - static int pegasus_suspend (struct usb_interface *intf, pm_message_t state) 1368 { 1369 struct pegasus *pegasus = usb_get_intfdata(intf); 1370 1371 netif_device_detach (pegasus->net); 1372 return 0; 1373 } 1374 ··· 1383 { 1384 struct pegasus *pegasus = usb_get_intfdata(intf); 1385 1386 netif_device_attach (pegasus->net); 1387 return 0; 1388 } 1389
··· 1364 free_netdev(pegasus->net); 1365 } 1366 1367 + static int pegasus_suspend (struct usb_interface *intf, pm_message_t message) 1368 { 1369 struct pegasus *pegasus = usb_get_intfdata(intf); 1370 1371 netif_device_detach (pegasus->net); 1372 + if (netif_running(pegasus->net)) { 1373 + cancel_delayed_work(&pegasus->carrier_check); 1374 + 1375 + usb_kill_urb(pegasus->rx_urb); 1376 + usb_kill_urb(pegasus->intr_urb); 1377 + } 1378 + intf->dev.power.power_state = PMSG_SUSPEND; 1379 return 0; 1380 } 1381 ··· 1376 { 1377 struct pegasus *pegasus = usb_get_intfdata(intf); 1378 1379 + intf->dev.power.power_state = PMSG_ON; 1380 netif_device_attach (pegasus->net); 1381 + if (netif_running(pegasus->net)) { 1382 + pegasus->rx_urb->status = 0; 1383 + pegasus->rx_urb->actual_length = 0; 1384 + read_bulk_callback(pegasus->rx_urb, 0); 1385 + 1386 + pegasus->intr_urb->status = 0; 1387 + pegasus->intr_urb->actual_length = 0; 1388 + intr_callback(pegasus->intr_urb, 0); 1389 + 1390 + queue_delayed_work(pegasus_workqueue, &pegasus->carrier_check, 1391 + CARRIER_CHECK_DELAY); 1392 + } 1393 return 0; 1394 } 1395
+26 -5
drivers/usb/net/usbnet.c
··· 426 dev->stats.rx_bytes += skb->len; 427 428 if (netif_msg_rx_status (dev)) 429 - devdbg (dev, "< rx, len %d, type 0x%x", 430 skb->len + sizeof (struct ethhdr), skb->protocol); 431 memset (skb->cb, 0, sizeof (struct skb_data)); 432 status = netif_rx (skb); ··· 3732 3733 #ifdef CONFIG_PM 3734 3735 - static int usbnet_suspend (struct usb_interface *intf, u32 state) 3736 { 3737 struct usbnet *dev = usb_get_intfdata(intf); 3738 3739 netif_device_detach (dev->net); 3740 return 0; 3741 } 3742 ··· 3750 { 3751 struct usbnet *dev = usb_get_intfdata(intf); 3752 3753 netif_device_attach (dev->net); 3754 return 0; 3755 } 3756 ··· 4017 .idProduct = 0x9050, /* C-860 */ 4018 ZAURUS_MASTER_INTERFACE, 4019 .driver_info = ZAURUS_PXA_INFO, 4020 #ifdef CONFIG_USB_ZAURUS 4021 - /* at least some (reports vary) C-860 units have very different 4022 - * lies about their standards support. 4023 */ 4024 }, { 4025 .match_flags = USB_DEVICE_ID_MATCH_INT_INFO 4026 | USB_DEVICE_ID_MATCH_DEVICE, ··· 4044 .bInterfaceSubClass = USB_CDC_SUBCLASS_MDLM, 4045 .bInterfaceProtocol = USB_CDC_PROTO_NONE, 4046 .driver_info = (unsigned long) &zaurus_pxa_mdlm_info, 4047 - #endif 4048 }, 4049 4050 /* Olympus has some models with a Zaurus-compatible option. 4051 * R-1000 uses a FreeScale i.MXL cpu (ARMv4T)
··· 426 dev->stats.rx_bytes += skb->len; 427 428 if (netif_msg_rx_status (dev)) 429 + devdbg (dev, "< rx, len %zd, type 0x%x", 430 skb->len + sizeof (struct ethhdr), skb->protocol); 431 memset (skb->cb, 0, sizeof (struct skb_data)); 432 status = netif_rx (skb); ··· 3732 3733 #ifdef CONFIG_PM 3734 3735 + static int usbnet_suspend (struct usb_interface *intf, pm_message_t message) 3736 { 3737 struct usbnet *dev = usb_get_intfdata(intf); 3738 3739 + /* accelerate emptying of the rx and queues, to avoid 3740 + * having everything error out. 3741 + */ 3742 netif_device_detach (dev->net); 3743 + (void) unlink_urbs (dev, &dev->rxq); 3744 + (void) unlink_urbs (dev, &dev->txq); 3745 + intf->dev.power.power_state = PMSG_SUSPEND; 3746 return 0; 3747 } 3748 ··· 3744 { 3745 struct usbnet *dev = usb_get_intfdata(intf); 3746 3747 + intf->dev.power.power_state = PMSG_ON; 3748 netif_device_attach (dev->net); 3749 + tasklet_schedule (&dev->bh); 3750 return 0; 3751 } 3752 ··· 4009 .idProduct = 0x9050, /* C-860 */ 4010 ZAURUS_MASTER_INTERFACE, 4011 .driver_info = ZAURUS_PXA_INFO, 4012 + }, 4013 + 4014 #ifdef CONFIG_USB_ZAURUS 4015 + /* at least some (reports vary) PXA units have very different 4016 + * lies about their standards support: they claim to be cell 4017 + * phones giving direct radio access (which they aren't). 4018 */ 4019 + { 4020 + .match_flags = USB_DEVICE_ID_MATCH_INT_INFO 4021 + | USB_DEVICE_ID_MATCH_DEVICE, 4022 + .idVendor = 0x04DD, 4023 + /* Sharp ROM v1.32 */ 4024 + .idProduct = 0x8006, /* SL-5600 */ 4025 + .bInterfaceClass = USB_CLASS_COMM, 4026 + .bInterfaceSubClass = USB_CDC_SUBCLASS_MDLM, 4027 + .bInterfaceProtocol = USB_CDC_PROTO_NONE, 4028 + .driver_info = (unsigned long) &zaurus_pxa_mdlm_info, 4029 }, { 4030 .match_flags = USB_DEVICE_ID_MATCH_INT_INFO 4031 | USB_DEVICE_ID_MATCH_DEVICE, ··· 4023 .bInterfaceSubClass = USB_CDC_SUBCLASS_MDLM, 4024 .bInterfaceProtocol = USB_CDC_PROTO_NONE, 4025 .driver_info = (unsigned long) &zaurus_pxa_mdlm_info, 4026 }, 4027 + #endif 4028 4029 /* Olympus has some models with a Zaurus-compatible option. 4030 * R-1000 uses a FreeScale i.MXL cpu (ARMv4T)
+1 -2
drivers/usb/net/zd1201.c
··· 106 107 err = 0; 108 exit: 109 - if (buf) 110 - kfree(buf); 111 release_firmware(fw_entry); 112 return err; 113 }
··· 106 107 err = 0; 108 exit: 109 + kfree(buf); 110 release_firmware(fw_entry); 111 return err; 112 }
+1 -2
drivers/usb/serial/belkin_sa.c
··· 202 for (i=0; i < serial->num_ports; ++i) { 203 /* My special items, the standard routines free my urbs */ 204 priv = usb_get_serial_port_data(serial->port[i]); 205 - if (priv) 206 - kfree(priv); 207 } 208 } 209
··· 202 for (i=0; i < serial->num_ports; ++i) { 203 /* My special items, the standard routines free my urbs */ 204 priv = usb_get_serial_port_data(serial->port[i]); 205 + kfree(priv); 206 } 207 } 208
+2 -3
drivers/usb/serial/cypress_m8.c
··· 1340 1341 static void cypress_buf_free(struct cypress_buf *cb) 1342 { 1343 - if (cb != NULL) { 1344 - if (cb->buf_buf != NULL) 1345 - kfree(cb->buf_buf); 1346 kfree(cb); 1347 } 1348 }
··· 1340 1341 static void cypress_buf_free(struct cypress_buf *cb) 1342 { 1343 + if (cb) { 1344 + kfree(cb->buf_buf); 1345 kfree(cb); 1346 } 1347 }
+6 -4
drivers/usb/serial/digi_acceleport.c
··· 568 * and the sleep. In other words, spin_unlock_irqrestore and 569 * interruptible_sleep_on_timeout are "atomic" with respect to 570 * wake ups. This is used to implement condition variables. 571 */ 572 573 static inline long cond_wait_interruptible_timeout_irqrestore( ··· 579 { 580 DEFINE_WAIT(wait); 581 582 - prepare_to_wait(q, &wait, TASK_UNINTERRUPTIBLE); 583 spin_unlock_irqrestore(lock, flags); 584 timeout = schedule_timeout(timeout); 585 finish_wait(q, &wait); 586 587 return timeout; 588 - 589 } 590 591 ··· 1598 dbg( "digi_close: write oob failed, ret=%d", ret ); 1599 1600 /* wait for final commands on oob port to complete */ 1601 - prepare_to_wait(&priv->dp_flush_wait, &wait, TASK_UNINTERRUPTIBLE); 1602 schedule_timeout(DIGI_CLOSE_TIMEOUT); 1603 finish_wait(&priv->dp_flush_wait, &wait); 1604 ··· 1997 1998 } else if( opcode == DIGI_CMD_IFLUSH_FIFO ) { 1999 2000 - wake_up( &priv->dp_flush_wait ); 2001 2002 } 2003
··· 568 * and the sleep. In other words, spin_unlock_irqrestore and 569 * interruptible_sleep_on_timeout are "atomic" with respect to 570 * wake ups. This is used to implement condition variables. 571 + * 572 + * interruptible_sleep_on_timeout is deprecated and has been replaced 573 + * with the equivalent code. 574 */ 575 576 static inline long cond_wait_interruptible_timeout_irqrestore( ··· 576 { 577 DEFINE_WAIT(wait); 578 579 + prepare_to_wait(q, &wait, TASK_INTERRUPTIBLE); 580 spin_unlock_irqrestore(lock, flags); 581 timeout = schedule_timeout(timeout); 582 finish_wait(q, &wait); 583 584 return timeout; 585 } 586 587 ··· 1596 dbg( "digi_close: write oob failed, ret=%d", ret ); 1597 1598 /* wait for final commands on oob port to complete */ 1599 + prepare_to_wait(&priv->dp_flush_wait, &wait, TASK_INTERRUPTIBLE); 1600 schedule_timeout(DIGI_CLOSE_TIMEOUT); 1601 finish_wait(&priv->dp_flush_wait, &wait); 1602 ··· 1995 1996 } else if( opcode == DIGI_CMD_IFLUSH_FIFO ) { 1997 1998 + wake_up_interruptible( &priv->dp_flush_wait ); 1999 2000 } 2001
+2 -4
drivers/usb/serial/empeg.c
··· 550 failed_usb_serial_register: 551 for (i = 0; i < NUM_URBS; ++i) { 552 if (write_urb_pool[i]) { 553 - if (write_urb_pool[i]->transfer_buffer) 554 - kfree(write_urb_pool[i]->transfer_buffer); 555 usb_free_urb(write_urb_pool[i]); 556 } 557 } ··· 574 * the host controllers get fixed to set urb->dev = NULL after 575 * the urb is finished. Otherwise this call oopses. */ 576 /* usb_kill_urb(write_urb_pool[i]); */ 577 - if (write_urb_pool[i]->transfer_buffer) 578 - kfree(write_urb_pool[i]->transfer_buffer); 579 usb_free_urb (write_urb_pool[i]); 580 } 581 }
··· 550 failed_usb_serial_register: 551 for (i = 0; i < NUM_URBS; ++i) { 552 if (write_urb_pool[i]) { 553 + kfree(write_urb_pool[i]->transfer_buffer); 554 usb_free_urb(write_urb_pool[i]); 555 } 556 } ··· 575 * the host controllers get fixed to set urb->dev = NULL after 576 * the urb is finished. Otherwise this call oopses. */ 577 /* usb_kill_urb(write_urb_pool[i]); */ 578 + kfree(write_urb_pool[i]->transfer_buffer); 579 usb_free_urb (write_urb_pool[i]); 580 } 581 }
+3 -7
drivers/usb/serial/ftdi_sio.c
··· 1347 priv->flags = ASYNC_LOW_LATENCY; 1348 1349 /* Increase the size of read buffers */ 1350 - if (port->bulk_in_buffer) { 1351 - kfree (port->bulk_in_buffer); 1352 - } 1353 port->bulk_in_buffer = kmalloc (BUFSZ, GFP_KERNEL); 1354 if (!port->bulk_in_buffer) { 1355 kfree (priv); ··· 1363 usb_free_urb (port->write_urb); 1364 port->write_urb = NULL; 1365 } 1366 - if (port->bulk_out_buffer) { 1367 - kfree (port->bulk_out_buffer); 1368 - port->bulk_out_buffer = NULL; 1369 - } 1370 1371 usb_set_serial_port_data(serial->port[0], priv); 1372
··· 1347 priv->flags = ASYNC_LOW_LATENCY; 1348 1349 /* Increase the size of read buffers */ 1350 + kfree(port->bulk_in_buffer); 1351 port->bulk_in_buffer = kmalloc (BUFSZ, GFP_KERNEL); 1352 if (!port->bulk_in_buffer) { 1353 kfree (priv); ··· 1365 usb_free_urb (port->write_urb); 1366 port->write_urb = NULL; 1367 } 1368 + kfree(port->bulk_out_buffer); 1369 + port->bulk_out_buffer = NULL; 1370 1371 usb_set_serial_port_data(serial->port[0], priv); 1372
+8 -16
drivers/usb/serial/io_edgeport.c
··· 951 952 953 /* clean up the transfer buffer */ 954 - if (urb->transfer_buffer != NULL) { 955 - kfree(urb->transfer_buffer); 956 - } 957 958 /* Free the command urb */ 959 usb_free_urb (urb); ··· 1264 1265 if (edge_port->write_urb) { 1266 /* if this urb had a transfer buffer already (old transfer) free it */ 1267 - if (edge_port->write_urb->transfer_buffer != NULL) { 1268 - kfree(edge_port->write_urb->transfer_buffer); 1269 - } 1270 - usb_free_urb (edge_port->write_urb); 1271 edge_port->write_urb = NULL; 1272 } 1273 - if (edge_port->txfifo.fifo) { 1274 - kfree(edge_port->txfifo.fifo); 1275 - edge_port->txfifo.fifo = NULL; 1276 - } 1277 1278 dbg("%s exited", __FUNCTION__); 1279 } ··· 1413 // get a pointer to the write_urb 1414 urb = edge_port->write_urb; 1415 1416 - /* if this urb had a transfer buffer already (old transfer) free it */ 1417 - if (urb->transfer_buffer != NULL) { 1418 - kfree(urb->transfer_buffer); 1419 - urb->transfer_buffer = NULL; 1420 - } 1421 1422 /* build the data header for the buffer and port that we are about to send out */ 1423 count = fifo->count;
··· 951 952 953 /* clean up the transfer buffer */ 954 + kfree(urb->transfer_buffer); 955 956 /* Free the command urb */ 957 usb_free_urb (urb); ··· 1266 1267 if (edge_port->write_urb) { 1268 /* if this urb had a transfer buffer already (old transfer) free it */ 1269 + kfree(edge_port->write_urb->transfer_buffer); 1270 + usb_free_urb(edge_port->write_urb); 1271 edge_port->write_urb = NULL; 1272 } 1273 + kfree(edge_port->txfifo.fifo); 1274 + edge_port->txfifo.fifo = NULL; 1275 1276 dbg("%s exited", __FUNCTION__); 1277 } ··· 1419 // get a pointer to the write_urb 1420 urb = edge_port->write_urb; 1421 1422 + /* make sure transfer buffer is freed */ 1423 + kfree(urb->transfer_buffer); 1424 + urb->transfer_buffer = NULL; 1425 1426 /* build the data header for the buffer and port that we are about to send out */ 1427 count = fifo->count;
+2 -3
drivers/usb/serial/io_ti.c
··· 2845 2846 void edge_buf_free(struct edge_buf *eb) 2847 { 2848 - if (eb != NULL) { 2849 - if (eb->buf_buf != NULL) 2850 - kfree(eb->buf_buf); 2851 kfree(eb); 2852 } 2853 }
··· 2845 2846 void edge_buf_free(struct edge_buf *eb) 2847 { 2848 + if (eb) { 2849 + kfree(eb->buf_buf); 2850 kfree(eb); 2851 } 2852 }
+1 -2
drivers/usb/serial/kl5kusb105.c
··· 341 * finished. Otherwise this call 342 * oopses. */ 343 /* usb_kill_urb(write_urbs[j]); */ 344 - if (write_urbs[j]->transfer_buffer) 345 - kfree(write_urbs[j]->transfer_buffer); 346 usb_free_urb (write_urbs[j]); 347 } 348 }
··· 341 * finished. Otherwise this call 342 * oopses. */ 343 /* usb_kill_urb(write_urbs[j]); */ 344 + kfree(write_urbs[j]->transfer_buffer); 345 usb_free_urb (write_urbs[j]); 346 } 347 }
+1 -4
drivers/usb/serial/omninet.c
··· 178 { 179 struct usb_serial *serial = port->serial; 180 struct usb_serial_port *wport; 181 - struct omninet_data *od; 182 183 dbg("%s - port %d", __FUNCTION__, port->number); 184 ··· 185 usb_kill_urb(wport->write_urb); 186 usb_kill_urb(port->read_urb); 187 188 - od = usb_get_serial_port_data(port); 189 - if (od) 190 - kfree(od); 191 } 192 193
··· 178 { 179 struct usb_serial *serial = port->serial; 180 struct usb_serial_port *wport; 181 182 dbg("%s - port %d", __FUNCTION__, port->number); 183 ··· 186 usb_kill_urb(wport->write_urb); 187 usb_kill_urb(port->read_urb); 188 189 + kfree(usb_get_serial_port_data(port)); 190 } 191 192
+38 -17
drivers/usb/serial/pl2303.c
··· 94 { USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_ID) }, 95 { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_PRODUCT_ID) }, 96 { USB_DEVICE(SIEMENS_VENDOR_ID, SIEMENS_PRODUCT_ID_X65) }, 97 { } /* Terminating entry */ 98 }; 99 ··· 678 unsigned long flags; 679 u8 control; 680 681 spin_lock_irqsave (&priv->lock, flags); 682 if (set & TIOCM_RTS) 683 priv->line_control |= CONTROL_RTS; ··· 705 unsigned int result; 706 707 dbg("%s (%d)", __FUNCTION__, port->number); 708 709 spin_lock_irqsave (&priv->lock, flags); 710 mcr = priv->line_control; ··· 818 } 819 } 820 821 822 static void pl2303_read_int_callback (struct urb *urb, struct pt_regs *regs) 823 { 824 struct usb_serial_port *port = (struct usb_serial_port *) urb->context; 825 - struct pl2303_private *priv = usb_get_serial_port_data(port); 826 unsigned char *data = urb->transfer_buffer; 827 - unsigned long flags; 828 int status; 829 - u8 uart_state; 830 831 dbg("%s (%d)", __FUNCTION__, port->number); 832 ··· 870 goto exit; 871 } 872 873 - 874 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, urb->actual_length, urb->transfer_buffer); 875 876 - if (urb->actual_length < UART_STATE) 877 - goto exit; 878 - 879 - /* Save off the uart status for others to look at */ 880 - uart_state = data[UART_STATE]; 881 - spin_lock_irqsave(&priv->lock, flags); 882 - uart_state |= (priv->line_status & UART_STATE_TRANSIENT_MASK); 883 - priv->line_status = uart_state; 884 - spin_unlock_irqrestore(&priv->lock, flags); 885 - 886 exit: 887 status = usb_submit_urb (urb, GFP_ATOMIC); 888 if (status) ··· 1044 1045 static void pl2303_buf_free(struct pl2303_buf *pb) 1046 { 1047 - if (pb != NULL) { 1048 - if (pb->buf_buf != NULL) 1049 - kfree(pb->buf_buf); 1050 kfree(pb); 1051 } 1052 }
··· 94 { USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_ID) }, 95 { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_PRODUCT_ID) }, 96 { USB_DEVICE(SIEMENS_VENDOR_ID, SIEMENS_PRODUCT_ID_X65) }, 97 + { USB_DEVICE(SYNTECH_VENDOR_ID, SYNTECH_PRODUCT_ID) }, 98 { } /* Terminating entry */ 99 }; 100 ··· 677 unsigned long flags; 678 u8 control; 679 680 + if (!usb_get_intfdata(port->serial->interface)) 681 + return -ENODEV; 682 + 683 spin_lock_irqsave (&priv->lock, flags); 684 if (set & TIOCM_RTS) 685 priv->line_control |= CONTROL_RTS; ··· 701 unsigned int result; 702 703 dbg("%s (%d)", __FUNCTION__, port->number); 704 + 705 + if (!usb_get_intfdata(port->serial->interface)) 706 + return -ENODEV; 707 708 spin_lock_irqsave (&priv->lock, flags); 709 mcr = priv->line_control; ··· 811 } 812 } 813 814 + static void pl2303_update_line_status(struct usb_serial_port *port, 815 + unsigned char *data, 816 + unsigned int actual_length) 817 + { 818 + 819 + struct pl2303_private *priv = usb_get_serial_port_data(port); 820 + unsigned long flags; 821 + u8 status_idx = UART_STATE; 822 + u8 length = UART_STATE; 823 + 824 + if ((le16_to_cpu(port->serial->dev->descriptor.idVendor) == SIEMENS_VENDOR_ID) && 825 + (le16_to_cpu(port->serial->dev->descriptor.idProduct) == SIEMENS_PRODUCT_ID_X65)) { 826 + length = 1; 827 + status_idx = 0; 828 + } 829 + 830 + if (actual_length < length) 831 + goto exit; 832 + 833 + /* Save off the uart status for others to look at */ 834 + spin_lock_irqsave(&priv->lock, flags); 835 + priv->line_status = data[status_idx]; 836 + spin_unlock_irqrestore(&priv->lock, flags); 837 + 838 + exit: 839 + return; 840 + } 841 842 static void pl2303_read_int_callback (struct urb *urb, struct pt_regs *regs) 843 { 844 struct usb_serial_port *port = (struct usb_serial_port *) urb->context; 845 unsigned char *data = urb->transfer_buffer; 846 + unsigned int actual_length = urb->actual_length; 847 int status; 848 849 dbg("%s (%d)", __FUNCTION__, port->number); 850 ··· 838 goto exit; 839 } 840 841 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, urb->actual_length, urb->transfer_buffer); 842 + pl2303_update_line_status(port, data, actual_length); 843 844 exit: 845 status = usb_submit_urb (urb, GFP_ATOMIC); 846 if (status) ··· 1022 1023 static void pl2303_buf_free(struct pl2303_buf *pb) 1024 { 1025 + if (pb) { 1026 + kfree(pb->buf_buf); 1027 kfree(pb); 1028 } 1029 }
+3
drivers/usb/serial/pl2303.h
··· 55 56 #define SIEMENS_VENDOR_ID 0x11f5 57 #define SIEMENS_PRODUCT_ID_X65 0x0003
··· 55 56 #define SIEMENS_VENDOR_ID 0x11f5 57 #define SIEMENS_PRODUCT_ID_X65 0x0003 58 + 59 + #define SYNTECH_VENDOR_ID 0x0745 60 + #define SYNTECH_PRODUCT_ID 0x0001
+1 -2
drivers/usb/serial/ti_usb_3410_5052.c
··· 517 } 518 } 519 520 - if (tdev) 521 - kfree(tdev); 522 usb_set_serial_data(serial, NULL); 523 } 524
··· 517 } 518 } 519 520 + kfree(tdev); 521 usb_set_serial_data(serial, NULL); 522 } 523
+6
drivers/usb/serial/visor.c
··· 215 .driver_info = (kernel_ulong_t)&palm_os_4_probe }, 216 { USB_DEVICE(PALM_VENDOR_ID, PALM_TUNGSTEN_T_ID), 217 .driver_info = (kernel_ulong_t)&palm_os_4_probe }, 218 { USB_DEVICE(PALM_VENDOR_ID, PALM_TUNGSTEN_Z_ID), 219 .driver_info = (kernel_ulong_t)&palm_os_4_probe }, 220 { USB_DEVICE(PALM_VENDOR_ID, PALM_ZIRE31_ID), ··· 238 { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_SCH_I330_ID), 239 .driver_info = (kernel_ulong_t)&palm_os_4_probe }, 240 { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_SPH_I500_ID), 241 .driver_info = (kernel_ulong_t)&palm_os_4_probe }, 242 { USB_DEVICE(GARMIN_VENDOR_ID, GARMIN_IQUE_3600_ID), 243 .driver_info = (kernel_ulong_t)&palm_os_4_probe }, ··· 277 { USB_DEVICE(PALM_VENDOR_ID, PALM_M125_ID) }, 278 { USB_DEVICE(PALM_VENDOR_ID, PALM_M130_ID) }, 279 { USB_DEVICE(PALM_VENDOR_ID, PALM_TUNGSTEN_T_ID) }, 280 { USB_DEVICE(PALM_VENDOR_ID, PALM_TUNGSTEN_Z_ID) }, 281 { USB_DEVICE(PALM_VENDOR_ID, PALM_ZIRE31_ID) }, 282 { USB_DEVICE(PALM_VENDOR_ID, PALM_ZIRE_ID) }, ··· 291 { USB_DEVICE(SONY_VENDOR_ID, SONY_CLIE_TJ25_ID) }, 292 { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_SCH_I330_ID) }, 293 { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_SPH_I500_ID) }, 294 { USB_DEVICE(GARMIN_VENDOR_ID, GARMIN_IQUE_3600_ID) }, 295 { USB_DEVICE(ACEECA_VENDOR_ID, ACEECA_MEZ1000_ID) }, 296 { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_7135_ID) },
··· 215 .driver_info = (kernel_ulong_t)&palm_os_4_probe }, 216 { USB_DEVICE(PALM_VENDOR_ID, PALM_TUNGSTEN_T_ID), 217 .driver_info = (kernel_ulong_t)&palm_os_4_probe }, 218 + { USB_DEVICE(PALM_VENDOR_ID, PALM_TREO_650), 219 + .driver_info = (kernel_ulong_t)&palm_os_4_probe }, 220 { USB_DEVICE(PALM_VENDOR_ID, PALM_TUNGSTEN_Z_ID), 221 .driver_info = (kernel_ulong_t)&palm_os_4_probe }, 222 { USB_DEVICE(PALM_VENDOR_ID, PALM_ZIRE31_ID), ··· 236 { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_SCH_I330_ID), 237 .driver_info = (kernel_ulong_t)&palm_os_4_probe }, 238 { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_SPH_I500_ID), 239 + .driver_info = (kernel_ulong_t)&palm_os_4_probe }, 240 + { USB_DEVICE(TAPWAVE_VENDOR_ID, TAPWAVE_ZODIAC_ID), 241 .driver_info = (kernel_ulong_t)&palm_os_4_probe }, 242 { USB_DEVICE(GARMIN_VENDOR_ID, GARMIN_IQUE_3600_ID), 243 .driver_info = (kernel_ulong_t)&palm_os_4_probe }, ··· 273 { USB_DEVICE(PALM_VENDOR_ID, PALM_M125_ID) }, 274 { USB_DEVICE(PALM_VENDOR_ID, PALM_M130_ID) }, 275 { USB_DEVICE(PALM_VENDOR_ID, PALM_TUNGSTEN_T_ID) }, 276 + { USB_DEVICE(PALM_VENDOR_ID, PALM_TREO_650) }, 277 { USB_DEVICE(PALM_VENDOR_ID, PALM_TUNGSTEN_Z_ID) }, 278 { USB_DEVICE(PALM_VENDOR_ID, PALM_ZIRE31_ID) }, 279 { USB_DEVICE(PALM_VENDOR_ID, PALM_ZIRE_ID) }, ··· 286 { USB_DEVICE(SONY_VENDOR_ID, SONY_CLIE_TJ25_ID) }, 287 { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_SCH_I330_ID) }, 288 { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_SPH_I500_ID) }, 289 + { USB_DEVICE(TAPWAVE_VENDOR_ID, TAPWAVE_ZODIAC_ID) }, 290 { USB_DEVICE(GARMIN_VENDOR_ID, GARMIN_IQUE_3600_ID) }, 291 { USB_DEVICE(ACEECA_VENDOR_ID, ACEECA_MEZ1000_ID) }, 292 { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_7135_ID) },
+4
drivers/usb/serial/visor.h
··· 30 #define PALM_M125_ID 0x0040 31 #define PALM_M130_ID 0x0050 32 #define PALM_TUNGSTEN_T_ID 0x0060 33 #define PALM_TUNGSTEN_Z_ID 0x0031 34 #define PALM_ZIRE31_ID 0x0061 35 #define PALM_ZIRE_ID 0x0070 ··· 49 #define SAMSUNG_VENDOR_ID 0x04E8 50 #define SAMSUNG_SCH_I330_ID 0x8001 51 #define SAMSUNG_SPH_I500_ID 0x6601 52 53 #define GARMIN_VENDOR_ID 0x091E 54 #define GARMIN_IQUE_3600_ID 0x0004
··· 30 #define PALM_M125_ID 0x0040 31 #define PALM_M130_ID 0x0050 32 #define PALM_TUNGSTEN_T_ID 0x0060 33 + #define PALM_TREO_650 0x0061 34 #define PALM_TUNGSTEN_Z_ID 0x0031 35 #define PALM_ZIRE31_ID 0x0061 36 #define PALM_ZIRE_ID 0x0070 ··· 48 #define SAMSUNG_VENDOR_ID 0x04E8 49 #define SAMSUNG_SCH_I330_ID 0x8001 50 #define SAMSUNG_SPH_I500_ID 0x6601 51 + 52 + #define TAPWAVE_VENDOR_ID 0x12EF 53 + #define TAPWAVE_ZODIAC_ID 0x0100 54 55 #define GARMIN_VENDOR_ID 0x091E 56 #define GARMIN_IQUE_3600_ID 0x0004
+8 -16
drivers/usb/storage/sddr55.c
··· 119 /* expect to get short transfer if no card fitted */ 120 if (result == USB_STOR_XFER_SHORT || result == USB_STOR_XFER_STALLED) { 121 /* had a short transfer, no card inserted, free map memory */ 122 - if (info->lba_to_pba) 123 - kfree(info->lba_to_pba); 124 - if (info->pba_to_lba) 125 - kfree(info->pba_to_lba); 126 info->lba_to_pba = NULL; 127 info->pba_to_lba = NULL; 128 ··· 647 return -1; 648 } 649 650 - if (info->lba_to_pba) 651 - kfree(info->lba_to_pba); 652 - if (info->pba_to_lba) 653 - kfree(info->pba_to_lba); 654 info->lba_to_pba = kmalloc(numblocks*sizeof(int), GFP_NOIO); 655 info->pba_to_lba = kmalloc(numblocks*sizeof(int), GFP_NOIO); 656 657 if (info->lba_to_pba == NULL || info->pba_to_lba == NULL) { 658 - if (info->lba_to_pba != NULL) 659 - kfree(info->lba_to_pba); 660 - if (info->pba_to_lba != NULL) 661 - kfree(info->pba_to_lba); 662 info->lba_to_pba = NULL; 663 info->pba_to_lba = NULL; 664 kfree(buffer); ··· 722 if (!extra) 723 return; 724 725 - if (info->lba_to_pba) 726 - kfree(info->lba_to_pba); 727 - if (info->pba_to_lba) 728 - kfree(info->pba_to_lba); 729 } 730 731
··· 119 /* expect to get short transfer if no card fitted */ 120 if (result == USB_STOR_XFER_SHORT || result == USB_STOR_XFER_STALLED) { 121 /* had a short transfer, no card inserted, free map memory */ 122 + kfree(info->lba_to_pba); 123 + kfree(info->pba_to_lba); 124 info->lba_to_pba = NULL; 125 info->pba_to_lba = NULL; 126 ··· 649 return -1; 650 } 651 652 + kfree(info->lba_to_pba); 653 + kfree(info->pba_to_lba); 654 info->lba_to_pba = kmalloc(numblocks*sizeof(int), GFP_NOIO); 655 info->pba_to_lba = kmalloc(numblocks*sizeof(int), GFP_NOIO); 656 657 if (info->lba_to_pba == NULL || info->pba_to_lba == NULL) { 658 + kfree(info->lba_to_pba); 659 + kfree(info->pba_to_lba); 660 info->lba_to_pba = NULL; 661 info->pba_to_lba = NULL; 662 kfree(buffer); ··· 728 if (!extra) 729 return; 730 731 + kfree(info->lba_to_pba); 732 + kfree(info->pba_to_lba); 733 } 734 735
+1 -1
drivers/usb/storage/transport.c
··· 996 * command phase and the data phase. Some devices need a little 997 * more than that, probably because of clock rate inaccuracies. */ 998 if (unlikely(us->flags & US_FL_GO_SLOW)) 999 - udelay(110); 1000 1001 if (transfer_length) { 1002 unsigned int pipe = srb->sc_data_direction == DMA_FROM_DEVICE ?
··· 996 * command phase and the data phase. Some devices need a little 997 * more than that, probably because of clock rate inaccuracies. */ 998 if (unlikely(us->flags & US_FL_GO_SLOW)) 999 + udelay(125); 1000 1001 if (transfer_length) { 1002 unsigned int pipe = srb->sc_data_direction == DMA_FROM_DEVICE ?
+13
drivers/usb/storage/unusual_devs.h
··· 763 US_FL_SINGLE_LUN ), 764 #endif 765 766 /* Datafab KECF-USB / Sagatek DCS-CF / Simpletech Flashlink UCF-100 767 * Only revision 1.13 tested (same for all of the above devices, 768 * based on the Datafab DF-UG-07 chip). Needed for US_FL_FIX_INQUIRY.
··· 763 US_FL_SINGLE_LUN ), 764 #endif 765 766 + #ifdef CONFIG_USB_STORAGE_DATAFAB 767 + /* Reported by Felix Moeller <felix@derklecks.de> 768 + * in Germany this is sold by Hama with the productnumber 46952 769 + * as "DualSlot CompactFlash(TM) & MStick Drive USB" 770 + */ 771 + UNUSUAL_DEV( 0x07c4, 0xa10b, 0x0000, 0xffff, 772 + "DataFab Systems Inc.", 773 + "USB CF+MS", 774 + US_SC_SCSI, US_PR_DATAFAB, NULL, 775 + 0 ), 776 + 777 + #endif 778 + 779 /* Datafab KECF-USB / Sagatek DCS-CF / Simpletech Flashlink UCF-100 780 * Only revision 1.13 tested (same for all of the above devices, 781 * based on the Datafab DF-UG-07 chip). Needed for US_FL_FIX_INQUIRY.
+2 -2
include/linux/usb.h
··· 558 559 int (*ioctl) (struct usb_interface *intf, unsigned int code, void *buf); 560 561 - int (*suspend) (struct usb_interface *intf, u32 state); 562 int (*resume) (struct usb_interface *intf); 563 564 const struct usb_device_id *id_table; ··· 977 int timeout); 978 979 /* selective suspend/resume */ 980 - extern int usb_suspend_device(struct usb_device *dev, u32 state); 981 extern int usb_resume_device(struct usb_device *dev); 982 983
··· 558 559 int (*ioctl) (struct usb_interface *intf, unsigned int code, void *buf); 560 561 + int (*suspend) (struct usb_interface *intf, pm_message_t message); 562 int (*resume) (struct usb_interface *intf); 563 564 const struct usb_device_id *id_table; ··· 977 int timeout); 978 979 /* selective suspend/resume */ 980 + extern int usb_suspend_device(struct usb_device *dev, pm_message_t message); 981 extern int usb_resume_device(struct usb_device *dev); 982 983
+1 -1
include/linux/usb_cdc.h
··· 114 115 /* type is associated with mdlm_desc.bGUID */ 116 __u8 bGuidDescriptorType; 117 - __u8 bDetailData[]; 118 } __attribute__ ((packed)); 119 120 /*-------------------------------------------------------------------------*/
··· 114 115 /* type is associated with mdlm_desc.bGUID */ 116 __u8 bGuidDescriptorType; 117 + __u8 bDetailData[0]; 118 } __attribute__ ((packed)); 119 120 /*-------------------------------------------------------------------------*/