Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6

* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6: (220 commits)
USB: backlight, appledisplay: fix incomplete registration failure handling
USB: pl2303: remove unnecessary reset of usb_device in urbs
USB: ftdi_sio: remove obsolete check in unthrottle
USB: ftdi_sio: remove unused tx_bytes counter
USB: qcaux: driver for auxiliary serial ports on Qualcomm devices
USB: pl2303: initial TIOCGSERIAL support
USB: option: add Longcheer/Longsung vendor ID
USB: fix I2C API usage in ohci-pnx4008.
USB: usbmon: mask seconds properly in text API
USB: sisusbvga: no unnecessary GFP_ATOMIC
USB: storage: onetouch: unnecessary GFP_ATOMIC
USB: serial: ftdi: add CONTEC vendor and product id
USB: remove references to port->port.count from the serial drivers
USB: tty: Prune uses of tty_request_room in the USB layer
USB: tty: Add a function to insert a string of characters with the same flag
USB: don't read past config->interface[] if usb_control_msg() fails in usb_reset_configuration()
USB: tty: kill request_room for USB ACM class
USB: tty: sort out the request_room handling for whiteheat
USB: storage: fix misplaced parenthesis
USB: vstusb.c: removal of driver for Vernier Software & Technology, Inc., devices and spectrometers
...

+7447 -3688
+11
Documentation/ABI/testing/sysfs-bus-usb
··· 159 device. This is useful to ensure auto probing won't 160 match the driver to the device. For example: 161 # echo "046d c315" > /sys/bus/usb/drivers/foo/remove_id
··· 159 device. This is useful to ensure auto probing won't 160 match the driver to the device. For example: 161 # echo "046d c315" > /sys/bus/usb/drivers/foo/remove_id 162 + 163 + What: /sys/bus/usb/device/.../avoid_reset 164 + Date: December 2009 165 + Contact: Oliver Neukum <oliver@neukum.org> 166 + Description: 167 + Writing 1 to this file tells the kernel that this 168 + device will morph into another mode when it is reset. 169 + Drivers will not use reset for error handling for 170 + such devices. 171 + Users: 172 + usb_modeswitch
-1
Documentation/ioctl/ioctl-number.txt
··· 139 'K' all linux/kd.h 140 'L' 00-1F linux/loop.h conflict! 141 'L' 10-1F drivers/scsi/mpt2sas/mpt2sas_ctl.h conflict! 142 - 'L' 20-2F linux/usb/vstusb.h 143 'L' E0-FF linux/ppdd.h encrypted disk device driver 144 <http://linux01.gwdg.de/~alatham/ppdd.html> 145 'M' all linux/soundcard.h conflict!
··· 139 'K' all linux/kd.h 140 'L' 00-1F linux/loop.h conflict! 141 'L' 10-1F drivers/scsi/mpt2sas/mpt2sas_ctl.h conflict! 142 'L' E0-FF linux/ppdd.h encrypted disk device driver 143 <http://linux01.gwdg.de/~alatham/ppdd.html> 144 'M' all linux/soundcard.h conflict!
+2
Documentation/networking/00-INDEX
··· 32 - the Crystal LAN (CS8900/20-based) Ethernet ISA adapter driver 33 cxacru.txt 34 - Conexant AccessRunner USB ADSL Modem 35 de4x5.txt 36 - the Digital EtherWORKS DE4?? and DE5?? PCI Ethernet driver 37 decnet.txt
··· 32 - the Crystal LAN (CS8900/20-based) Ethernet ISA adapter driver 33 cxacru.txt 34 - Conexant AccessRunner USB ADSL Modem 35 + cxacru-cf.py 36 + - Conexant AccessRunner USB ADSL Modem configuration file parser 37 de4x5.txt 38 - the Digital EtherWORKS DE4?? and DE5?? PCI Ethernet driver 39 decnet.txt
+48
Documentation/networking/cxacru-cf.py
···
··· 1 + #!/usr/bin/env python 2 + # Copyright 2009 Simon Arlott 3 + # 4 + # This program is free software; you can redistribute it and/or modify it 5 + # under the terms of the GNU General Public License as published by the Free 6 + # Software Foundation; either version 2 of the License, or (at your option) 7 + # any later version. 8 + # 9 + # This program is distributed in the hope that it will be useful, but WITHOUT 10 + # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 + # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 + # more details. 13 + # 14 + # You should have received a copy of the GNU General Public License along with 15 + # this program; if not, write to the Free Software Foundation, Inc., 59 16 + # Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 + # 18 + # Usage: cxacru-cf.py < cxacru-cf.bin 19 + # Output: values string suitable for the sysfs adsl_config attribute 20 + # 21 + # Warning: cxacru-cf.bin with MD5 hash cdbac2689969d5ed5d4850f117702110 22 + # contains mis-aligned values which will stop the modem from being able 23 + # to make a connection. If the first and last two bytes are removed then 24 + # the values become valid, but the modulation will be forced to ANSI 25 + # T1.413 only which may not be appropriate. 26 + # 27 + # The original binary format is a packed list of le32 values. 28 + 29 + import sys 30 + import struct 31 + 32 + i = 0 33 + while True: 34 + buf = sys.stdin.read(4) 35 + 36 + if len(buf) == 0: 37 + break 38 + elif len(buf) != 4: 39 + sys.stdout.write("\n") 40 + sys.stderr.write("Error: read {0} not 4 bytes\n".format(len(buf))) 41 + sys.exit(1) 42 + 43 + if i > 0: 44 + sys.stdout.write(" ") 45 + sys.stdout.write("{0:x}={1}".format(i, struct.unpack("<I", buf)[0])) 46 + i += 1 47 + 48 + sys.stdout.write("\n")
+16
Documentation/networking/cxacru.txt
··· 4 module loaded, the device will sometimes stop responding after unloading the 5 driver and it is necessary to unplug/remove power to the device to fix this. 6 7 Detected devices will appear as ATM devices named "cxacru". In /sys/class/atm/ 8 these are directories named cxacruN where N is the device number. A symlink 9 named device points to the USB interface device's directory which contains ··· 20 * adsl_headend 21 * adsl_headend_environment 22 Information about the remote headend. 23 24 * downstream_attenuation (dB) 25 * downstream_bits_per_frame ··· 76 * mac_address 77 78 * modulation 79 "ANSI T1.413" 80 "ITU-T G.992.1 (G.DMT)" 81 "ITU-T G.992.2 (G.LITE)"
··· 4 module loaded, the device will sometimes stop responding after unloading the 5 driver and it is necessary to unplug/remove power to the device to fix this. 6 7 + Note: support for cxacru-cf.bin has been removed. It was not loaded correctly 8 + so it had no effect on the device configuration. Fixing it could have stopped 9 + existing devices working when an invalid configuration is supplied. 10 + 11 + There is a script cxacru-cf.py to convert an existing file to the sysfs form. 12 + 13 Detected devices will appear as ATM devices named "cxacru". In /sys/class/atm/ 14 these are directories named cxacruN where N is the device number. A symlink 15 named device points to the USB interface device's directory which contains ··· 14 * adsl_headend 15 * adsl_headend_environment 16 Information about the remote headend. 17 + 18 + * adsl_config 19 + Configuration writing interface. 20 + Write parameters in hexadecimal format <index>=<value>, 21 + separated by whitespace, e.g.: 22 + "1=0 a=5" 23 + Up to 7 parameters at a time will be sent and the modem will restart 24 + the ADSL connection when any value is set. These are logged for future 25 + reference. 26 27 * downstream_attenuation (dB) 28 * downstream_bits_per_frame ··· 61 * mac_address 62 63 * modulation 64 + "" (when not connected) 65 "ANSI T1.413" 66 "ITU-T G.992.1 (G.DMT)" 67 "ITU-T G.992.2 (G.LITE)"
+4 -2
Documentation/usb/error-codes.txt
··· 41 42 -EFBIG Host controller driver can't schedule that many ISO frames. 43 44 - -EPIPE Specified endpoint is stalled. For non-control endpoints, 45 - reset this status with usb_clear_halt(). 46 47 -EMSGSIZE (a) endpoint maxpacket size is zero; it is not usable 48 in the current interface altsetting. ··· 59 -EPERM Submission failed because urb->reject was set. 60 61 -EHOSTUNREACH URB was rejected because the device is suspended. 62 63 64 **************************************************************************
··· 41 42 -EFBIG Host controller driver can't schedule that many ISO frames. 43 44 + -EPIPE The pipe type specified in the URB doesn't match the 45 + endpoint's actual type. 46 47 -EMSGSIZE (a) endpoint maxpacket size is zero; it is not usable 48 in the current interface altsetting. ··· 59 -EPERM Submission failed because urb->reject was set. 60 61 -EHOSTUNREACH URB was rejected because the device is suspended. 62 + 63 + -ENOEXEC A control URB doesn't contain a Setup packet. 64 65 66 **************************************************************************
+91 -136
Documentation/usb/power-management.txt
··· 2 3 Alan Stern <stern@rowland.harvard.edu> 4 5 - November 10, 2009 6 7 8 ··· 29 information about system PM). 30 31 Note: Dynamic PM support for USB is present only if the kernel was 32 - built with CONFIG_USB_SUSPEND enabled. System PM support is present 33 - only if the kernel was built with CONFIG_SUSPEND or CONFIG_HIBERNATION 34 - enabled. 35 36 37 What is Remote Wakeup? ··· 229 also change the idle-delay time; 2 seconds is not the best choice for 230 every device. 231 232 Sometimes it turns out that even when a device does work okay with 233 autosuspend there are still problems. For example, there are 234 experimental patches adding autosuspend support to the usbhid driver, ··· 326 void usb_autopm_get_interface_no_resume(struct usb_interface *intf); 327 void usb_autopm_put_interface_no_suspend(struct usb_interface *intf); 328 329 - The functions work by maintaining a counter in the usb_interface 330 - structure. When intf->pm_usage_count is > 0 then the interface is 331 - deemed to be busy, and the kernel will not autosuspend the interface's 332 - device. When intf->pm_usage_count is <= 0 then the interface is 333 - considered to be idle, and the kernel may autosuspend the device. 334 335 - (There is a similar pm_usage_count field in struct usb_device, 336 associated with the device itself rather than any of its interfaces. 337 - This field is used only by the USB core.) 338 339 - Drivers must not modify intf->pm_usage_count directly; its value 340 - should be changed only be using the functions listed above. Drivers 341 - are responsible for insuring that the overall change to pm_usage_count 342 - during their lifetime balances out to 0 (it may be necessary for the 343 - disconnect method to call usb_autopm_put_interface() one or more times 344 - to fulfill this requirement). The first two routines use the PM mutex 345 - in struct usb_device for mutual exclusion; drivers using the async 346 - routines are responsible for their own synchronization and mutual 347 - exclusion. 348 349 - usb_autopm_get_interface() increments pm_usage_count and 350 - attempts an autoresume if the new value is > 0 and the 351 - device is suspended. 352 353 - usb_autopm_put_interface() decrements pm_usage_count and 354 - attempts an autosuspend if the new value is <= 0 and the 355 - device isn't suspended. 356 357 usb_autopm_get_interface_async() and 358 usb_autopm_put_interface_async() do almost the same things as 359 - their non-async counterparts. The differences are: they do 360 - not acquire the PM mutex, and they use a workqueue to do their 361 jobs. As a result they can be called in an atomic context, 362 such as an URB's completion handler, but when they return the 363 - device will not generally not yet be in the desired state. 364 365 usb_autopm_get_interface_no_resume() and 366 usb_autopm_put_interface_no_suspend() merely increment or 367 - decrement the pm_usage_count value; they do not attempt to 368 - carry out an autoresume or an autosuspend. Hence they can be 369 - called in an atomic context. 370 371 - The conventional usage pattern is that a driver calls 372 usb_autopm_get_interface() in its open routine and 373 - usb_autopm_put_interface() in its close or release routine. But 374 - other patterns are possible. 375 376 The autosuspend attempts mentioned above will often fail for one 377 reason or another. For example, the power/level attribute might be 378 set to "on", or another interface in the same device might not be 379 idle. This is perfectly normal. If the reason for failure was that 380 - the device hasn't been idle for long enough, a delayed workqueue 381 - routine is automatically set up to carry out the operation when the 382 - autosuspend idle-delay has expired. 383 384 Autoresume attempts also can fail, although failure would mean that 385 the device is no longer present or operating properly. Unlike 386 - autosuspend, there's no delay for an autoresume. 387 388 389 Other parts of the driver interface 390 ----------------------------------- 391 392 Sometimes a driver needs to make sure that remote wakeup is enabled 393 during autosuspend. For example, there's not much point ··· 412 Normally a driver would set this flag in its probe method, at which 413 time the device is guaranteed not to be autosuspended.) 414 415 - The synchronous usb_autopm_* routines have to run in a sleepable 416 - process context; they must not be called from an interrupt handler or 417 - while holding a spinlock. In fact, the entire autosuspend mechanism 418 - is not well geared toward interrupt-driven operation. However there 419 - is one thing a driver can do in an interrupt handler: 420 421 usb_mark_last_busy(struct usb_device *udev); 422 423 - This sets udev->last_busy to the current time. udev->last_busy is the 424 - field used for idle-delay calculations; updating it will cause any 425 - pending autosuspend to be moved back. The usb_autopm_* routines will 426 - also set the last_busy field to the current time. 427 428 - Calling urb_mark_last_busy() from within an URB completion handler is 429 - subject to races: The kernel may have just finished deciding the 430 - device has been idle for long enough but not yet gotten around to 431 - calling the driver's suspend method. The driver would have to be 432 - responsible for synchronizing its suspend method with its URB 433 - completion handler and causing the autosuspend to fail with -EBUSY if 434 - an URB had completed too recently. 435 436 External suspend calls should never be allowed to fail in this way, 437 only autosuspend calls. The driver can tell them apart by checking ··· 440 method; this bit will be set for internal PM events (autosuspend) and 441 clear for external PM events. 442 443 - Many of the ingredients in the autosuspend framework are oriented 444 - towards interfaces: The usb_interface structure contains the 445 - pm_usage_cnt field, and the usb_autopm_* routines take an interface 446 - pointer as their argument. But somewhat confusingly, a few of the 447 - pieces (i.e., usb_mark_last_busy()) use the usb_device structure 448 - instead. Drivers need to keep this straight; they can call 449 - interface_to_usbdev() to find the device structure for a given 450 - interface. 451 452 453 - Locking requirements 454 - -------------------- 455 - 456 - All three suspend/resume methods are always called while holding the 457 - usb_device's PM mutex. For external events -- but not necessarily for 458 - autosuspend or autoresume -- the device semaphore (udev->dev.sem) will 459 - also be held. This implies that external suspend/resume events are 460 - mutually exclusive with calls to probe, disconnect, pre_reset, and 461 - post_reset; the USB core guarantees that this is true of internal 462 - suspend/resume events as well. 463 464 If a driver wants to block all suspend/resume calls during some 465 - critical section, it can simply acquire udev->pm_mutex. Note that 466 - calls to resume may be triggered indirectly. Block IO due to memory 467 - allocations can make the vm subsystem resume a device. Thus while 468 - holding this lock you must not allocate memory with GFP_KERNEL or 469 - GFP_NOFS. 470 - 471 - Alternatively, if the critical section might call some of the 472 - usb_autopm_* routines, the driver can avoid deadlock by doing: 473 - 474 - down(&udev->dev.sem); 475 - rc = usb_autopm_get_interface(intf); 476 - 477 - and at the end of the critical section: 478 - 479 - if (!rc) 480 - usb_autopm_put_interface(intf); 481 - up(&udev->dev.sem); 482 - 483 - Holding the device semaphore will block all external PM calls, and the 484 - usb_autopm_get_interface() will prevent any internal PM calls, even if 485 - it fails. (Exercise: Why?) 486 - 487 - The rules for locking order are: 488 - 489 - Never acquire any device semaphore while holding any PM mutex. 490 - 491 - Never acquire udev->pm_mutex while holding the PM mutex for 492 - a device that isn't a descendant of udev. 493 - 494 - In other words, PM mutexes should only be acquired going up the device 495 - tree, and they should be acquired only after locking all the device 496 - semaphores you need to hold. These rules don't matter to drivers very 497 - much; they usually affect just the USB core. 498 - 499 - Still, drivers do need to be careful. For example, many drivers use a 500 - private mutex to synchronize their normal I/O activities with their 501 - disconnect method. Now if the driver supports autosuspend then it 502 - must call usb_autopm_put_interface() from somewhere -- maybe from its 503 - close method. It should make the call while holding the private mutex, 504 - since a driver shouldn't call any of the usb_autopm_* functions for an 505 - interface from which it has been unbound. 506 - 507 - But the usb_autpm_* routines always acquire the device's PM mutex, and 508 - consequently the locking order has to be: private mutex first, PM 509 - mutex second. Since the suspend method is always called with the PM 510 - mutex held, it mustn't try to acquire the private mutex. It has to 511 - synchronize with the driver's I/O activities in some other way. 512 513 514 Interaction between dynamic PM and system PM ··· 465 Dynamic power management and system power management can interact in 466 a couple of ways. 467 468 - Firstly, a device may already be manually suspended or autosuspended 469 - when a system suspend occurs. Since system suspends are supposed to 470 - be as transparent as possible, the device should remain suspended 471 - following the system resume. The 2.6.23 kernel obeys this principle 472 - for manually suspended devices but not for autosuspended devices; they 473 - do get resumed when the system wakes up. (Presumably they will be 474 - autosuspended again after their idle-delay time expires.) In later 475 - kernels this behavior will be fixed. 476 - 477 - (There is an exception. If a device would undergo a reset-resume 478 - instead of a normal resume, and the device is enabled for remote 479 - wakeup, then the reset-resume takes place even if the device was 480 - already suspended when the system suspend began. The justification is 481 - that a reset-resume is a kind of remote-wakeup event. Or to put it 482 - another way, a device which needs a reset won't be able to generate 483 - normal remote-wakeup signals, so it ought to be resumed immediately.) 484 485 Secondly, a dynamic power-management event may occur as a system 486 suspend is underway. The window for this is short, since system
··· 2 3 Alan Stern <stern@rowland.harvard.edu> 4 5 + December 11, 2009 6 7 8 ··· 29 information about system PM). 30 31 Note: Dynamic PM support for USB is present only if the kernel was 32 + built with CONFIG_USB_SUSPEND enabled (which depends on 33 + CONFIG_PM_RUNTIME). System PM support is present only if the kernel 34 + was built with CONFIG_SUSPEND or CONFIG_HIBERNATION enabled. 35 36 37 What is Remote Wakeup? ··· 229 also change the idle-delay time; 2 seconds is not the best choice for 230 every device. 231 232 + If a driver knows that its device has proper suspend/resume support, 233 + it can enable autosuspend all by itself. For example, the video 234 + driver for a laptop's webcam might do this, since these devices are 235 + rarely used and so should normally be autosuspended. 236 + 237 Sometimes it turns out that even when a device does work okay with 238 autosuspend there are still problems. For example, there are 239 experimental patches adding autosuspend support to the usbhid driver, ··· 321 void usb_autopm_get_interface_no_resume(struct usb_interface *intf); 322 void usb_autopm_put_interface_no_suspend(struct usb_interface *intf); 323 324 + The functions work by maintaining a usage counter in the 325 + usb_interface's embedded device structure. When the counter is > 0 326 + then the interface is deemed to be busy, and the kernel will not 327 + autosuspend the interface's device. When the usage counter is = 0 328 + then the interface is considered to be idle, and the kernel may 329 + autosuspend the device. 330 331 + (There is a similar usage counter field in struct usb_device, 332 associated with the device itself rather than any of its interfaces. 333 + This counter is used only by the USB core.) 334 335 + Drivers need not be concerned about balancing changes to the usage 336 + counter; the USB core will undo any remaining "get"s when a driver 337 + is unbound from its interface. As a corollary, drivers must not call 338 + any of the usb_autopm_* functions after their diconnect() routine has 339 + returned. 340 341 + Drivers using the async routines are responsible for their own 342 + synchronization and mutual exclusion. 343 344 + usb_autopm_get_interface() increments the usage counter and 345 + does an autoresume if the device is suspended. If the 346 + autoresume fails, the counter is decremented back. 347 + 348 + usb_autopm_put_interface() decrements the usage counter and 349 + attempts an autosuspend if the new value is = 0. 350 351 usb_autopm_get_interface_async() and 352 usb_autopm_put_interface_async() do almost the same things as 353 + their non-async counterparts. The big difference is that they 354 + use a workqueue to do the resume or suspend part of their 355 jobs. As a result they can be called in an atomic context, 356 such as an URB's completion handler, but when they return the 357 + device will generally not yet be in the desired state. 358 359 usb_autopm_get_interface_no_resume() and 360 usb_autopm_put_interface_no_suspend() merely increment or 361 + decrement the usage counter; they do not attempt to carry out 362 + an autoresume or an autosuspend. Hence they can be called in 363 + an atomic context. 364 365 + The simplest usage pattern is that a driver calls 366 usb_autopm_get_interface() in its open routine and 367 + usb_autopm_put_interface() in its close or release routine. But other 368 + patterns are possible. 369 370 The autosuspend attempts mentioned above will often fail for one 371 reason or another. For example, the power/level attribute might be 372 set to "on", or another interface in the same device might not be 373 idle. This is perfectly normal. If the reason for failure was that 374 + the device hasn't been idle for long enough, a timer is scheduled to 375 + carry out the operation automatically when the autosuspend idle-delay 376 + has expired. 377 378 Autoresume attempts also can fail, although failure would mean that 379 the device is no longer present or operating properly. Unlike 380 + autosuspend, there's no idle-delay for an autoresume. 381 382 383 Other parts of the driver interface 384 ----------------------------------- 385 + 386 + Drivers can enable autosuspend for their devices by calling 387 + 388 + usb_enable_autosuspend(struct usb_device *udev); 389 + 390 + in their probe() routine, if they know that the device is capable of 391 + suspending and resuming correctly. This is exactly equivalent to 392 + writing "auto" to the device's power/level attribute. Likewise, 393 + drivers can disable autosuspend by calling 394 + 395 + usb_disable_autosuspend(struct usb_device *udev); 396 + 397 + This is exactly the same as writing "on" to the power/level attribute. 398 399 Sometimes a driver needs to make sure that remote wakeup is enabled 400 during autosuspend. For example, there's not much point ··· 395 Normally a driver would set this flag in its probe method, at which 396 time the device is guaranteed not to be autosuspended.) 397 398 + If a driver does its I/O asynchronously in interrupt context, it 399 + should call usb_autopm_get_interface_async() before starting output and 400 + usb_autopm_put_interface_async() when the output queue drains. When 401 + it receives an input event, it should call 402 403 usb_mark_last_busy(struct usb_device *udev); 404 405 + in the event handler. This sets udev->last_busy to the current time. 406 + udev->last_busy is the field used for idle-delay calculations; 407 + updating it will cause any pending autosuspend to be moved back. Most 408 + of the usb_autopm_* routines will also set the last_busy field to the 409 + current time. 410 411 + Asynchronous operation is always subject to races. For example, a 412 + driver may call one of the usb_autopm_*_interface_async() routines at 413 + a time when the core has just finished deciding the device has been 414 + idle for long enough but not yet gotten around to calling the driver's 415 + suspend method. The suspend method must be responsible for 416 + synchronizing with the output request routine and the URB completion 417 + handler; it should cause autosuspends to fail with -EBUSY if the 418 + driver needs to use the device. 419 420 External suspend calls should never be allowed to fail in this way, 421 only autosuspend calls. The driver can tell them apart by checking ··· 422 method; this bit will be set for internal PM events (autosuspend) and 423 clear for external PM events. 424 425 426 + Mutual exclusion 427 + ---------------- 428 429 + For external events -- but not necessarily for autosuspend or 430 + autoresume -- the device semaphore (udev->dev.sem) will be held when a 431 + suspend or resume method is called. This implies that external 432 + suspend/resume events are mutually exclusive with calls to probe, 433 + disconnect, pre_reset, and post_reset; the USB core guarantees that 434 + this is true of autosuspend/autoresume events as well. 435 436 If a driver wants to block all suspend/resume calls during some 437 + critical section, the best way is to lock the device and call 438 + usb_autopm_get_interface() (and do the reverse at the end of the 439 + critical section). Holding the device semaphore will block all 440 + external PM calls, and the usb_autopm_get_interface() will prevent any 441 + internal PM calls, even if it fails. (Exercise: Why?) 442 443 444 Interaction between dynamic PM and system PM ··· 499 Dynamic power management and system power management can interact in 500 a couple of ways. 501 502 + Firstly, a device may already be autosuspended when a system suspend 503 + occurs. Since system suspends are supposed to be as transparent as 504 + possible, the device should remain suspended following the system 505 + resume. But this theory may not work out well in practice; over time 506 + the kernel's behavior in this regard has changed. 507 508 Secondly, a dynamic power-management event may occur as a system 509 suspend is underway. The window for this is short, since system
+10 -1
arch/arm/configs/rx51_defconfig
··· 445 # CONFIG_LAPB is not set 446 # CONFIG_ECONET is not set 447 # CONFIG_WAN_ROUTER is not set 448 # CONFIG_NET_SCHED is not set 449 # CONFIG_DCB is not set 450 ··· 1327 # CONFIG_USB_GADGET_LH7A40X is not set 1328 # CONFIG_USB_GADGET_OMAP is not set 1329 # CONFIG_USB_GADGET_PXA25X is not set 1330 # CONFIG_USB_GADGET_PXA27X is not set 1331 - # CONFIG_USB_GADGET_S3C2410 is not set 1332 # CONFIG_USB_GADGET_IMX is not set 1333 # CONFIG_USB_GADGET_M66592 is not set 1334 # CONFIG_USB_GADGET_AMD5536UDC is not set 1335 # CONFIG_USB_GADGET_FSL_QE is not set 1336 # CONFIG_USB_GADGET_CI13XXX is not set 1337 # CONFIG_USB_GADGET_NET2280 is not set 1338 # CONFIG_USB_GADGET_GOKU is not set 1339 # CONFIG_USB_GADGET_DUMMY_HCD is not set 1340 CONFIG_USB_GADGET_DUALSPEED=y 1341 CONFIG_USB_ZERO=m 1342 # CONFIG_USB_ZERO_HNPTEST is not set 1343 # CONFIG_USB_ETH is not set 1344 # CONFIG_USB_GADGETFS is not set 1345 CONFIG_USB_FILE_STORAGE=m 1346 # CONFIG_USB_FILE_STORAGE_TEST is not set 1347 # CONFIG_USB_G_SERIAL is not set 1348 # CONFIG_USB_MIDI_GADGET is not set 1349 # CONFIG_USB_G_PRINTER is not set 1350 # CONFIG_USB_CDC_COMPOSITE is not set 1351 1352 # 1353 # OTG and related infrastructure
··· 445 # CONFIG_LAPB is not set 446 # CONFIG_ECONET is not set 447 # CONFIG_WAN_ROUTER is not set 448 + CONFIG_PHONET=y 449 + # CONFIG_IEEE802154 is not set 450 # CONFIG_NET_SCHED is not set 451 # CONFIG_DCB is not set 452 ··· 1325 # CONFIG_USB_GADGET_LH7A40X is not set 1326 # CONFIG_USB_GADGET_OMAP is not set 1327 # CONFIG_USB_GADGET_PXA25X is not set 1328 + # CONFIG_USB_GADGET_R8A66597 is not set 1329 # CONFIG_USB_GADGET_PXA27X is not set 1330 + # CONFIG_USB_GADGET_S3C_HSOTG is not set 1331 # CONFIG_USB_GADGET_IMX is not set 1332 + # CONFIG_USB_GADGET_S3C2410 is not set 1333 # CONFIG_USB_GADGET_M66592 is not set 1334 # CONFIG_USB_GADGET_AMD5536UDC is not set 1335 # CONFIG_USB_GADGET_FSL_QE is not set 1336 # CONFIG_USB_GADGET_CI13XXX is not set 1337 # CONFIG_USB_GADGET_NET2280 is not set 1338 # CONFIG_USB_GADGET_GOKU is not set 1339 + # CONFIG_USB_GADGET_LANGWELL is not set 1340 # CONFIG_USB_GADGET_DUMMY_HCD is not set 1341 CONFIG_USB_GADGET_DUALSPEED=y 1342 CONFIG_USB_ZERO=m 1343 # CONFIG_USB_ZERO_HNPTEST is not set 1344 + # CONFIG_USB_AUDIO is not set 1345 # CONFIG_USB_ETH is not set 1346 # CONFIG_USB_GADGETFS is not set 1347 CONFIG_USB_FILE_STORAGE=m 1348 # CONFIG_USB_FILE_STORAGE_TEST is not set 1349 + # CONFIG_USB_MASS_STORAGE is not set 1350 # CONFIG_USB_G_SERIAL is not set 1351 # CONFIG_USB_MIDI_GADGET is not set 1352 # CONFIG_USB_G_PRINTER is not set 1353 # CONFIG_USB_CDC_COMPOSITE is not set 1354 + CONFIG_USB_G_NOKIA=m 1355 + # CONFIG_USB_G_MULTI is not set 1356 1357 # 1358 # OTG and related infrastructure
+54 -26
arch/arm/mach-mx2/devices.c
··· 31 #include <linux/init.h> 32 #include <linux/platform_device.h> 33 #include <linux/gpio.h> 34 35 #include <mach/irqs.h> 36 #include <mach/hardware.h> ··· 293 .num_resources = ARRAY_SIZE(mxc_fb), 294 .resource = mxc_fb, 295 .dev = { 296 - .coherent_dma_mask = 0xFFFFFFFF, 297 }, 298 }; 299 ··· 396 }, 397 }; 398 399 - static u64 mxc_sdhc1_dmamask = 0xffffffffUL; 400 401 struct platform_device mxc_sdhc_device0 = { 402 - .name = "mxc-mmc", 403 - .id = 0, 404 - .dev = { 405 - .dma_mask = &mxc_sdhc1_dmamask, 406 - .coherent_dma_mask = 0xffffffff, 407 - }, 408 - .num_resources = ARRAY_SIZE(mxc_sdhc1_resources), 409 - .resource = mxc_sdhc1_resources, 410 }; 411 412 static struct resource mxc_sdhc2_resources[] = { ··· 425 }, 426 }; 427 428 - static u64 mxc_sdhc2_dmamask = 0xffffffffUL; 429 430 struct platform_device mxc_sdhc_device1 = { 431 - .name = "mxc-mmc", 432 - .id = 1, 433 - .dev = { 434 - .dma_mask = &mxc_sdhc2_dmamask, 435 - .coherent_dma_mask = 0xffffffff, 436 - }, 437 - .num_resources = ARRAY_SIZE(mxc_sdhc2_resources), 438 - .resource = mxc_sdhc2_resources, 439 }; 440 441 #ifdef CONFIG_MACH_MX27 ··· 451 }, 452 }; 453 454 - static u64 otg_dmamask = 0xffffffffUL; 455 456 /* OTG gadget device */ 457 struct platform_device mxc_otg_udc_device = { ··· 459 .id = -1, 460 .dev = { 461 .dma_mask = &otg_dmamask, 462 - .coherent_dma_mask = 0xffffffffUL, 463 }, 464 .resource = otg_resources, 465 .num_resources = ARRAY_SIZE(otg_resources), ··· 470 .name = "mxc-ehci", 471 .id = 0, 472 .dev = { 473 - .coherent_dma_mask = 0xffffffff, 474 .dma_mask = &otg_dmamask, 475 }, 476 .resource = otg_resources, ··· 479 480 /* USB host 1 */ 481 482 - static u64 usbh1_dmamask = 0xffffffffUL; 483 484 static struct resource mxc_usbh1_resources[] = { 485 { ··· 497 .name = "mxc-ehci", 498 .id = 1, 499 .dev = { 500 - .coherent_dma_mask = 0xffffffff, 501 .dma_mask = &usbh1_dmamask, 502 }, 503 .resource = mxc_usbh1_resources, ··· 505 }; 506 507 /* USB host 2 */ 508 - static u64 usbh2_dmamask = 0xffffffffUL; 509 510 static struct resource mxc_usbh2_resources[] = { 511 { ··· 523 .name = "mxc-ehci", 524 .id = 2, 525 .dev = { 526 - .coherent_dma_mask = 0xffffffff, 527 .dma_mask = &usbh2_dmamask, 528 }, 529 .resource = mxc_usbh2_resources, ··· 643 { 644 return mxc_gpio_init(imx_gpio_ports, ARRAY_SIZE(imx_gpio_ports)); 645 }
··· 31 #include <linux/init.h> 32 #include <linux/platform_device.h> 33 #include <linux/gpio.h> 34 + #include <linux/dma-mapping.h> 35 36 #include <mach/irqs.h> 37 #include <mach/hardware.h> ··· 292 .num_resources = ARRAY_SIZE(mxc_fb), 293 .resource = mxc_fb, 294 .dev = { 295 + .coherent_dma_mask = DMA_BIT_MASK(32), 296 }, 297 }; 298 ··· 395 }, 396 }; 397 398 + static u64 mxc_sdhc1_dmamask = DMA_BIT_MASK(32); 399 400 struct platform_device mxc_sdhc_device0 = { 401 + .name = "mxc-mmc", 402 + .id = 0, 403 + .dev = { 404 + .dma_mask = &mxc_sdhc1_dmamask, 405 + .coherent_dma_mask = DMA_BIT_MASK(32), 406 + }, 407 + .num_resources = ARRAY_SIZE(mxc_sdhc1_resources), 408 + .resource = mxc_sdhc1_resources, 409 }; 410 411 static struct resource mxc_sdhc2_resources[] = { ··· 424 }, 425 }; 426 427 + static u64 mxc_sdhc2_dmamask = DMA_BIT_MASK(32); 428 429 struct platform_device mxc_sdhc_device1 = { 430 + .name = "mxc-mmc", 431 + .id = 1, 432 + .dev = { 433 + .dma_mask = &mxc_sdhc2_dmamask, 434 + .coherent_dma_mask = DMA_BIT_MASK(32), 435 + }, 436 + .num_resources = ARRAY_SIZE(mxc_sdhc2_resources), 437 + .resource = mxc_sdhc2_resources, 438 }; 439 440 #ifdef CONFIG_MACH_MX27 ··· 450 }, 451 }; 452 453 + static u64 otg_dmamask = DMA_BIT_MASK(32); 454 455 /* OTG gadget device */ 456 struct platform_device mxc_otg_udc_device = { ··· 458 .id = -1, 459 .dev = { 460 .dma_mask = &otg_dmamask, 461 + .coherent_dma_mask = DMA_BIT_MASK(32), 462 }, 463 .resource = otg_resources, 464 .num_resources = ARRAY_SIZE(otg_resources), ··· 469 .name = "mxc-ehci", 470 .id = 0, 471 .dev = { 472 + .coherent_dma_mask = DMA_BIT_MASK(32), 473 .dma_mask = &otg_dmamask, 474 }, 475 .resource = otg_resources, ··· 478 479 /* USB host 1 */ 480 481 + static u64 usbh1_dmamask = DMA_BIT_MASK(32); 482 483 static struct resource mxc_usbh1_resources[] = { 484 { ··· 496 .name = "mxc-ehci", 497 .id = 1, 498 .dev = { 499 + .coherent_dma_mask = DMA_BIT_MASK(32), 500 .dma_mask = &usbh1_dmamask, 501 }, 502 .resource = mxc_usbh1_resources, ··· 504 }; 505 506 /* USB host 2 */ 507 + static u64 usbh2_dmamask = DMA_BIT_MASK(32); 508 509 static struct resource mxc_usbh2_resources[] = { 510 { ··· 522 .name = "mxc-ehci", 523 .id = 2, 524 .dev = { 525 + .coherent_dma_mask = DMA_BIT_MASK(32), 526 .dma_mask = &usbh2_dmamask, 527 }, 528 .resource = mxc_usbh2_resources, ··· 642 { 643 return mxc_gpio_init(imx_gpio_ports, ARRAY_SIZE(imx_gpio_ports)); 644 } 645 + 646 + #ifdef CONFIG_MACH_MX21 647 + static struct resource mx21_usbhc_resources[] = { 648 + { 649 + .start = USBOTG_BASE_ADDR, 650 + .end = USBOTG_BASE_ADDR + 0x1FFF, 651 + .flags = IORESOURCE_MEM, 652 + }, 653 + { 654 + .start = MXC_INT_USBHOST, 655 + .end = MXC_INT_USBHOST, 656 + .flags = IORESOURCE_IRQ, 657 + }, 658 + }; 659 + 660 + struct platform_device mx21_usbhc_device = { 661 + .name = "imx21-hcd", 662 + .id = 0, 663 + .dev = { 664 + .dma_mask = &mx21_usbhc_device.dev.coherent_dma_mask, 665 + .coherent_dma_mask = DMA_BIT_MASK(32), 666 + }, 667 + .num_resources = ARRAY_SIZE(mx21_usbhc_resources), 668 + .resource = mx21_usbhc_resources, 669 + }; 670 + #endif 671 +
+1
arch/arm/mach-mx2/devices.h
··· 26 extern struct platform_device mxc_spi_device0; 27 extern struct platform_device mxc_spi_device1; 28 extern struct platform_device mxc_spi_device2; 29 extern struct platform_device imx_ssi_device0; 30 extern struct platform_device imx_ssi_device1;
··· 26 extern struct platform_device mxc_spi_device0; 27 extern struct platform_device mxc_spi_device1; 28 extern struct platform_device mxc_spi_device2; 29 + extern struct platform_device mx21_usbhc_device; 30 extern struct platform_device imx_ssi_device0; 31 extern struct platform_device imx_ssi_device1;
+38
arch/arm/plat-mxc/include/mach/mx21-usbhost.h
···
··· 1 + /* 2 + * Copyright (C) 2009 Martin Fuzzey <mfuzzey@gmail.com> 3 + * 4 + * This program is free software; you can redistribute it and/or modify 5 + * it under the terms of the GNU General Public License as published by 6 + * the Free Software Foundation; either version 2 of the License, or 7 + * (at your option) any later version. 8 + * 9 + * This program is distributed in the hope that it will be useful, 10 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 + * GNU General Public License for more details. 13 + */ 14 + 15 + #ifndef __ASM_ARCH_MX21_USBH 16 + #define __ASM_ARCH_MX21_USBH 17 + 18 + enum mx21_usbh_xcvr { 19 + /* Values below as used by hardware (HWMODE register) */ 20 + MX21_USBXCVR_TXDIF_RXDIF = 0, 21 + MX21_USBXCVR_TXDIF_RXSE = 1, 22 + MX21_USBXCVR_TXSE_RXDIF = 2, 23 + MX21_USBXCVR_TXSE_RXSE = 3, 24 + }; 25 + 26 + struct mx21_usbh_platform_data { 27 + enum mx21_usbh_xcvr host_xcvr; /* tranceiver mode host 1,2 ports */ 28 + enum mx21_usbh_xcvr otg_xcvr; /* tranceiver mode otg (as host) port */ 29 + u16 enable_host1:1, 30 + enable_host2:1, 31 + enable_otg_host:1, /* enable "OTG" port (as host) */ 32 + host1_xcverless:1, /* traceiverless host1 port */ 33 + host1_txenoe:1, /* output enable host1 transmit enable */ 34 + otg_ext_xcvr:1, /* external tranceiver for OTG port */ 35 + unused:10; 36 + }; 37 + 38 + #endif /* __ASM_ARCH_MX21_USBH */
+5 -2
arch/avr32/mach-at32ap/at32ap700x.c
··· 1770 ARRAY_SIZE(usba0_resource))) 1771 goto out_free_pdev; 1772 1773 - if (data) 1774 usba_data.pdata.vbus_pin = data->vbus_pin; 1775 - else 1776 usba_data.pdata.vbus_pin = -EINVAL; 1777 1778 data = &usba_data.pdata; 1779 data->num_ep = ARRAY_SIZE(at32_usba_ep);
··· 1770 ARRAY_SIZE(usba0_resource))) 1771 goto out_free_pdev; 1772 1773 + if (data) { 1774 usba_data.pdata.vbus_pin = data->vbus_pin; 1775 + usba_data.pdata.vbus_pin_inverted = data->vbus_pin_inverted; 1776 + } else { 1777 usba_data.pdata.vbus_pin = -EINVAL; 1778 + usba_data.pdata.vbus_pin_inverted = -EINVAL; 1779 + } 1780 1781 data = &usba_data.pdata; 1782 data->num_ep = ARRAY_SIZE(at32_usba_ep);
+6 -5
drivers/char/tty_buffer.c
··· 231 EXPORT_SYMBOL_GPL(tty_buffer_request_room); 232 233 /** 234 - * tty_insert_flip_string - Add characters to the tty buffer 235 * @tty: tty structure 236 * @chars: characters 237 * @size: size 238 * 239 * Queue a series of bytes to the tty buffering. All the characters ··· 243 * Locking: Called functions may take tty->buf.lock 244 */ 245 246 - int tty_insert_flip_string(struct tty_struct *tty, const unsigned char *chars, 247 - size_t size) 248 { 249 int copied = 0; 250 do { ··· 255 if (unlikely(space == 0)) 256 break; 257 memcpy(tb->char_buf_ptr + tb->used, chars, space); 258 - memset(tb->flag_buf_ptr + tb->used, TTY_NORMAL, space); 259 tb->used += space; 260 copied += space; 261 chars += space; ··· 264 } while (unlikely(size > copied)); 265 return copied; 266 } 267 - EXPORT_SYMBOL(tty_insert_flip_string); 268 269 /** 270 * tty_insert_flip_string_flags - Add characters to the tty buffer
··· 231 EXPORT_SYMBOL_GPL(tty_buffer_request_room); 232 233 /** 234 + * tty_insert_flip_string_fixed_flag - Add characters to the tty buffer 235 * @tty: tty structure 236 * @chars: characters 237 + * @flag: flag value for each character 238 * @size: size 239 * 240 * Queue a series of bytes to the tty buffering. All the characters ··· 242 * Locking: Called functions may take tty->buf.lock 243 */ 244 245 + int tty_insert_flip_string_fixed_flag(struct tty_struct *tty, 246 + const unsigned char *chars, char flag, size_t size) 247 { 248 int copied = 0; 249 do { ··· 254 if (unlikely(space == 0)) 255 break; 256 memcpy(tb->char_buf_ptr + tb->used, chars, space); 257 + memset(tb->flag_buf_ptr + tb->used, flag, space); 258 tb->used += space; 259 copied += space; 260 chars += space; ··· 263 } while (unlikely(size > copied)); 264 return copied; 265 } 266 + EXPORT_SYMBOL(tty_insert_flip_string_fixed_flag); 267 268 /** 269 * tty_insert_flip_string_flags - Add characters to the tty buffer
+5 -2
drivers/hid/usbhid/hiddev.c
··· 265 static int hiddev_open(struct inode *inode, struct file *file) 266 { 267 struct hiddev_list *list; 268 - int res; 269 270 - int i = iminor(inode) - HIDDEV_MINOR_BASE; 271 272 if (i >= HIDDEV_MINORS || i < 0 || !hiddev_table[i]) 273 return -ENODEV; ··· 314 usbhid_open(hid); 315 } 316 317 return 0; 318 bail: 319 file->private_data = NULL; 320 kfree(list); 321 return res; 322 } 323
··· 265 static int hiddev_open(struct inode *inode, struct file *file) 266 { 267 struct hiddev_list *list; 268 + int res, i; 269 270 + lock_kernel(); 271 + i = iminor(inode) - HIDDEV_MINOR_BASE; 272 273 if (i >= HIDDEV_MINORS || i < 0 || !hiddev_table[i]) 274 return -ENODEV; ··· 313 usbhid_open(hid); 314 } 315 316 + unlock_kernel(); 317 return 0; 318 bail: 319 file->private_data = NULL; 320 kfree(list); 321 + unlock_kernel(); 322 return res; 323 } 324
+7 -1
drivers/media/video/dabusb.c
··· 616 { 617 int devnum = iminor(inode); 618 pdabusb_t s; 619 620 if (devnum < DABUSB_MINOR || devnum >= (DABUSB_MINOR + NRDABUSB)) 621 return -EIO; 622 623 s = &dabusb[devnum - DABUSB_MINOR]; 624 625 dbg("dabusb_open"); ··· 636 msleep_interruptible(500); 637 638 if (signal_pending (current)) { 639 return -EAGAIN; 640 } 641 mutex_lock(&s->mutex); ··· 644 if (usb_set_interface (s->usbdev, _DABUSB_IF, 1) < 0) { 645 mutex_unlock(&s->mutex); 646 dev_err(&s->usbdev->dev, "set_interface failed\n"); 647 return -EINVAL; 648 } 649 s->opened = 1; ··· 653 file->f_pos = 0; 654 file->private_data = s; 655 656 - return nonseekable_open(inode, file); 657 } 658 659 static int dabusb_release (struct inode *inode, struct file *file)
··· 616 { 617 int devnum = iminor(inode); 618 pdabusb_t s; 619 + int r; 620 621 if (devnum < DABUSB_MINOR || devnum >= (DABUSB_MINOR + NRDABUSB)) 622 return -EIO; 623 624 + lock_kernel(); 625 s = &dabusb[devnum - DABUSB_MINOR]; 626 627 dbg("dabusb_open"); ··· 634 msleep_interruptible(500); 635 636 if (signal_pending (current)) { 637 + unlock_kernel(); 638 return -EAGAIN; 639 } 640 mutex_lock(&s->mutex); ··· 641 if (usb_set_interface (s->usbdev, _DABUSB_IF, 1) < 0) { 642 mutex_unlock(&s->mutex); 643 dev_err(&s->usbdev->dev, "set_interface failed\n"); 644 + unlock_kernel(); 645 return -EINVAL; 646 } 647 s->opened = 1; ··· 649 file->f_pos = 0; 650 file->private_data = s; 651 652 + r = nonseekable_open(inode, file); 653 + unlock_kernel(); 654 + return r; 655 } 656 657 static int dabusb_release (struct inode *inode, struct file *file)
+1 -1
drivers/staging/usbip/vhci_sysfs.c
··· 144 case USB_SPEED_LOW: 145 case USB_SPEED_FULL: 146 case USB_SPEED_HIGH: 147 - case USB_SPEED_VARIABLE: 148 break; 149 default: 150 usbip_uerr("speed %d\n", speed);
··· 144 case USB_SPEED_LOW: 145 case USB_SPEED_FULL: 146 case USB_SPEED_HIGH: 147 + case USB_SPEED_WIRELESS: 148 break; 149 default: 150 usbip_uerr("speed %d\n", speed);
+2
drivers/usb/Kconfig
··· 21 default y if USB_ARCH_HAS_EHCI 22 default y if PCMCIA && !M32R # sl811_cs 23 default y if ARM # SL-811 24 default y if SUPERH # r8a66597-hcd 25 default PCI 26 ··· 40 default y if ARCH_PNX4008 && I2C 41 default y if MFD_TC6393XB 42 default y if ARCH_W90X900 43 # PPC: 44 default y if STB03xxx 45 default y if PPC_MPC52xx
··· 21 default y if USB_ARCH_HAS_EHCI 22 default y if PCMCIA && !M32R # sl811_cs 23 default y if ARM # SL-811 24 + default y if BLACKFIN # SL-811 25 default y if SUPERH # r8a66597-hcd 26 default PCI 27 ··· 39 default y if ARCH_PNX4008 && I2C 40 default y if MFD_TC6393XB 41 default y if ARCH_W90X900 42 + default y if ARCH_DAVINCI_DA8XX 43 # PPC: 44 default y if STB03xxx 45 default y if PPC_MPC52xx
+1
drivers/usb/Makefile
··· 21 obj-$(CONFIG_USB_R8A66597_HCD) += host/ 22 obj-$(CONFIG_USB_HWA_HCD) += host/ 23 obj-$(CONFIG_USB_ISP1760_HCD) += host/ 24 25 obj-$(CONFIG_USB_C67X00_HCD) += c67x00/ 26
··· 21 obj-$(CONFIG_USB_R8A66597_HCD) += host/ 22 obj-$(CONFIG_USB_HWA_HCD) += host/ 23 obj-$(CONFIG_USB_ISP1760_HCD) += host/ 24 + obj-$(CONFIG_USB_IMX21_HCD) += host/ 25 26 obj-$(CONFIG_USB_C67X00_HCD) += c67x00/ 27
+137 -55
drivers/usb/atm/cxacru.c
··· 5 * Copyright (C) 2004 David Woodhouse, Duncan Sands, Roman Kagan 6 * Copyright (C) 2005 Duncan Sands, Roman Kagan (rkagan % mail ! ru) 7 * Copyright (C) 2007 Simon Arlott 8 * 9 * This program is free software; you can redistribute it and/or modify it 10 * under the terms of the GNU General Public License as published by the Free ··· 44 #include "usbatm.h" 45 46 #define DRIVER_AUTHOR "Roman Kagan, David Woodhouse, Duncan Sands, Simon Arlott" 47 - #define DRIVER_VERSION "0.3" 48 #define DRIVER_DESC "Conexant AccessRunner ADSL USB modem driver" 49 50 static const char cxacru_driver_name[] = "cxacru"; ··· 53 #define CXACRU_EP_DATA 0x02 /* Bulk in/out */ 54 55 #define CMD_PACKET_SIZE 64 /* Should be maxpacket(ep)? */ 56 57 /* Addresses */ 58 #define PLLFCLK_ADDR 0x00350068 ··· 105 CM_REQUEST_CARD_GET_MAC_ADDRESS, 106 CM_REQUEST_CARD_GET_DATA_LINK_STATUS, 107 CM_REQUEST_MAX, 108 }; 109 110 /* reply codes to the commands above */ ··· 218 static DEVICE_ATTR(_name, S_IWUSR | S_IRUGO, \ 219 cxacru_sysfs_show_##_name, cxacru_sysfs_store_##_name) 220 221 #define CXACRU_ATTR_INIT(_value, _type, _name) \ 222 static ssize_t cxacru_sysfs_show_##_name(struct device *dev, \ 223 struct device_attribute *attr, char *buf) \ 224 { \ 225 - struct usb_interface *intf = to_usb_interface(dev); \ 226 - struct usbatm_data *usbatm_instance = usb_get_intfdata(intf); \ 227 - struct cxacru_data *instance = usbatm_instance->driver_data; \ 228 return cxacru_sysfs_showattr_##_type(instance->card_info[_value], buf); \ 229 } \ 230 CXACRU__ATTR_INIT(_name) 231 232 #define CXACRU_ATTR_CREATE(_v, _t, _name) CXACRU_DEVICE_CREATE_FILE(_name) 233 #define CXACRU_CMD_CREATE(_name) CXACRU_DEVICE_CREATE_FILE(_name) 234 #define CXACRU__ATTR_CREATE(_name) CXACRU_DEVICE_CREATE_FILE(_name) 235 236 #define CXACRU_ATTR_REMOVE(_v, _t, _name) CXACRU_DEVICE_REMOVE_FILE(_name) 237 #define CXACRU_CMD_REMOVE(_name) CXACRU_DEVICE_REMOVE_FILE(_name) 238 #define CXACRU__ATTR_REMOVE(_name) CXACRU_DEVICE_REMOVE_FILE(_name) 239 240 static ssize_t cxacru_sysfs_showattr_u32(u32 value, char *buf) ··· 298 static ssize_t cxacru_sysfs_showattr_MODU(u32 value, char *buf) 299 { 300 static char *str[] = { 301 - NULL, 302 "ANSI T1.413", 303 "ITU-T G.992.1 (G.DMT)", 304 "ITU-T G.992.2 (G.LITE)" 305 }; 306 - if (unlikely(value >= ARRAY_SIZE(str) || str[value] == NULL)) 307 return snprintf(buf, PAGE_SIZE, "%u\n", value); 308 return snprintf(buf, PAGE_SIZE, "%s\n", str[value]); 309 } ··· 319 static ssize_t cxacru_sysfs_show_mac_address(struct device *dev, 320 struct device_attribute *attr, char *buf) 321 { 322 - struct usb_interface *intf = to_usb_interface(dev); 323 - struct usbatm_data *usbatm_instance = usb_get_intfdata(intf); 324 - struct atm_dev *atm_dev = usbatm_instance->atm_dev; 325 326 - return snprintf(buf, PAGE_SIZE, "%pM\n", atm_dev->esi); 327 } 328 329 static ssize_t cxacru_sysfs_show_adsl_state(struct device *dev, 330 struct device_attribute *attr, char *buf) 331 { 332 - struct usb_interface *intf = to_usb_interface(dev); 333 - struct usbatm_data *usbatm_instance = usb_get_intfdata(intf); 334 - struct cxacru_data *instance = usbatm_instance->driver_data; 335 - u32 value = instance->card_info[CXINF_LINE_STARTABLE]; 336 - 337 static char *str[] = { "running", "stopped" }; 338 if (unlikely(value >= ARRAY_SIZE(str))) 339 return snprintf(buf, PAGE_SIZE, "%u\n", value); 340 return snprintf(buf, PAGE_SIZE, "%s\n", str[value]); ··· 349 static ssize_t cxacru_sysfs_store_adsl_state(struct device *dev, 350 struct device_attribute *attr, const char *buf, size_t count) 351 { 352 - struct usb_interface *intf = to_usb_interface(dev); 353 - struct usbatm_data *usbatm_instance = usb_get_intfdata(intf); 354 - struct cxacru_data *instance = usbatm_instance->driver_data; 355 int ret; 356 int poll = -1; 357 char str_cmd[8]; ··· 364 return -EINVAL; 365 ret = 0; 366 367 if (mutex_lock_interruptible(&instance->adsl_state_serialize)) 368 return -ERESTARTSYS; 369 370 if (!strcmp(str_cmd, "stop") || !strcmp(str_cmd, "restart")) { 371 ret = cxacru_cm(instance, CM_REQUEST_CHIP_ADSL_LINE_STOP, NULL, 0, NULL, 0); 372 if (ret < 0) { 373 - atm_err(usbatm_instance, "change adsl state:" 374 " CHIP_ADSL_LINE_STOP returned %d\n", ret); 375 376 ret = -EIO; ··· 393 if (!strcmp(str_cmd, "start") || !strcmp(str_cmd, "restart")) { 394 ret = cxacru_cm(instance, CM_REQUEST_CHIP_ADSL_LINE_START, NULL, 0, NULL, 0); 395 if (ret < 0) { 396 - atm_err(usbatm_instance, "change adsl state:" 397 " CHIP_ADSL_LINE_START returned %d\n", ret); 398 399 ret = -EIO; ··· 446 return ret; 447 } 448 449 /* 450 * All device attributes are included in CXACRU_ALL_FILES 451 * so that the same list can be used multiple times: ··· 547 CXACRU_ATTR_##_action(CXINF_ADSL_HEADEND, u32, adsl_headend); \ 548 CXACRU_ATTR_##_action(CXINF_ADSL_HEADEND_ENVIRONMENT, u32, adsl_headend_environment); \ 549 CXACRU_ATTR_##_action(CXINF_CONTROLLER_VERSION, u32, adsl_controller_version); \ 550 - CXACRU_CMD_##_action( adsl_state); 551 552 CXACRU_ALL_FILES(INIT); 553 ··· 702 len = ret / 4; 703 for (offb = 0; offb < len; ) { 704 int l = le32_to_cpu(buf[offb++]); 705 - if (l > stride || l > (len - offb) / 2) { 706 if (printk_ratelimit()) 707 usb_err(instance->usbatm, "invalid data length from cm %#x: %d\n", 708 cm, l); ··· 755 { 756 struct cxacru_data *instance = usbatm_instance->driver_data; 757 struct usb_interface *intf = usbatm_instance->usb_intf; 758 - /* 759 - struct atm_dev *atm_dev = usbatm_instance->atm_dev; 760 - */ 761 int ret; 762 int start_polling = 1; 763 ··· 799 } 800 mutex_unlock(&instance->poll_state_serialize); 801 mutex_unlock(&instance->adsl_state_serialize); 802 803 if (start_polling) 804 cxacru_poll_status(&instance->poll_work.work); ··· 979 980 static void cxacru_upload_firmware(struct cxacru_data *instance, 981 const struct firmware *fw, 982 - const struct firmware *bp, 983 - const struct firmware *cf) 984 { 985 int ret; 986 - int off; 987 struct usbatm_data *usbatm = instance->usbatm; 988 struct usb_device *usb_dev = usbatm->usb_dev; 989 __le16 signature[] = { usb_dev->descriptor.idVendor, ··· 1015 } 1016 1017 /* Firmware */ 1018 ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, FW_ADDR, fw->data, fw->size); 1019 if (ret) { 1020 usb_err(usbatm, "Firmware upload failed: %d\n", ret); ··· 1024 1025 /* Boot ROM patch */ 1026 if (instance->modem_type->boot_rom_patch) { 1027 ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, BR_ADDR, bp->data, bp->size); 1028 if (ret) { 1029 usb_err(usbatm, "Boot ROM patching failed: %d\n", ret); ··· 1039 return; 1040 } 1041 1042 if (instance->modem_type->boot_rom_patch) { 1043 val = cpu_to_le32(BR_ADDR); 1044 ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, BR_STACK_ADDR, (u8 *) &val, 4); ··· 1065 usb_err(usbatm, "modem failed to initialize: %d\n", ret); 1066 return; 1067 } 1068 - 1069 - /* Load config data (le32), doing one packet at a time */ 1070 - if (cf) 1071 - for (off = 0; off < cf->size / 4; ) { 1072 - __le32 buf[CMD_PACKET_SIZE / 4 - 1]; 1073 - int i, len = min_t(int, cf->size / 4 - off, CMD_PACKET_SIZE / 4 / 2 - 1); 1074 - buf[0] = cpu_to_le32(len); 1075 - for (i = 0; i < len; i++, off++) { 1076 - buf[i * 2 + 1] = cpu_to_le32(off); 1077 - memcpy(buf + i * 2 + 2, cf->data + off * 4, 4); 1078 - } 1079 - ret = cxacru_cm(instance, CM_REQUEST_CARD_DATA_SET, 1080 - (u8 *) buf, len, NULL, 0); 1081 - if (ret < 0) { 1082 - usb_err(usbatm, "load config data failed: %d\n", ret); 1083 - return; 1084 - } 1085 - } 1086 - 1087 - msleep_interruptible(4000); 1088 } 1089 1090 static int cxacru_find_firmware(struct cxacru_data *instance, ··· 1090 static int cxacru_heavy_init(struct usbatm_data *usbatm_instance, 1091 struct usb_interface *usb_intf) 1092 { 1093 - const struct firmware *fw, *bp, *cf; 1094 struct cxacru_data *instance = usbatm_instance->driver_data; 1095 1096 int ret = cxacru_find_firmware(instance, "fw", &fw); ··· 1108 } 1109 } 1110 1111 - if (cxacru_find_firmware(instance, "cf", &cf)) /* optional */ 1112 - cf = NULL; 1113 1114 - cxacru_upload_firmware(instance, fw, bp, cf); 1115 - 1116 - if (cf) 1117 - release_firmware(cf); 1118 if (instance->modem_type->boot_rom_patch) 1119 release_firmware(bp); 1120 release_firmware(fw);
··· 5 * Copyright (C) 2004 David Woodhouse, Duncan Sands, Roman Kagan 6 * Copyright (C) 2005 Duncan Sands, Roman Kagan (rkagan % mail ! ru) 7 * Copyright (C) 2007 Simon Arlott 8 + * Copyright (C) 2009 Simon Arlott 9 * 10 * This program is free software; you can redistribute it and/or modify it 11 * under the terms of the GNU General Public License as published by the Free ··· 43 #include "usbatm.h" 44 45 #define DRIVER_AUTHOR "Roman Kagan, David Woodhouse, Duncan Sands, Simon Arlott" 46 + #define DRIVER_VERSION "0.4" 47 #define DRIVER_DESC "Conexant AccessRunner ADSL USB modem driver" 48 49 static const char cxacru_driver_name[] = "cxacru"; ··· 52 #define CXACRU_EP_DATA 0x02 /* Bulk in/out */ 53 54 #define CMD_PACKET_SIZE 64 /* Should be maxpacket(ep)? */ 55 + #define CMD_MAX_CONFIG ((CMD_PACKET_SIZE / 4 - 1) / 2) 56 57 /* Addresses */ 58 #define PLLFCLK_ADDR 0x00350068 ··· 103 CM_REQUEST_CARD_GET_MAC_ADDRESS, 104 CM_REQUEST_CARD_GET_DATA_LINK_STATUS, 105 CM_REQUEST_MAX, 106 + }; 107 + 108 + /* commands for interaction with the flash memory 109 + * 110 + * read: response is the contents of the first 60 bytes of flash memory 111 + * write: request contains the 60 bytes of data to write to flash memory 112 + * response is the contents of the first 60 bytes of flash memory 113 + * 114 + * layout: PP PP VV VV MM MM MM MM MM MM ?? ?? SS SS SS SS SS SS SS SS 115 + * SS SS SS SS SS SS SS SS 00 00 00 00 00 00 00 00 00 00 00 00 116 + * 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 117 + * 118 + * P: le16 USB Product ID 119 + * V: le16 USB Vendor ID 120 + * M: be48 MAC Address 121 + * S: le16 ASCII Serial Number 122 + */ 123 + enum cxacru_cm_flash { 124 + CM_FLASH_READ = 0xa1, 125 + CM_FLASH_WRITE = 0xa2 126 }; 127 128 /* reply codes to the commands above */ ··· 196 static DEVICE_ATTR(_name, S_IWUSR | S_IRUGO, \ 197 cxacru_sysfs_show_##_name, cxacru_sysfs_store_##_name) 198 199 + #define CXACRU_SET_INIT(_name) \ 200 + static DEVICE_ATTR(_name, S_IWUSR, \ 201 + NULL, cxacru_sysfs_store_##_name) 202 + 203 #define CXACRU_ATTR_INIT(_value, _type, _name) \ 204 static ssize_t cxacru_sysfs_show_##_name(struct device *dev, \ 205 struct device_attribute *attr, char *buf) \ 206 { \ 207 + struct cxacru_data *instance = to_usbatm_driver_data(\ 208 + to_usb_interface(dev)); \ 209 + \ 210 + if (instance == NULL) \ 211 + return -ENODEV; \ 212 + \ 213 return cxacru_sysfs_showattr_##_type(instance->card_info[_value], buf); \ 214 } \ 215 CXACRU__ATTR_INIT(_name) 216 217 #define CXACRU_ATTR_CREATE(_v, _t, _name) CXACRU_DEVICE_CREATE_FILE(_name) 218 #define CXACRU_CMD_CREATE(_name) CXACRU_DEVICE_CREATE_FILE(_name) 219 + #define CXACRU_SET_CREATE(_name) CXACRU_DEVICE_CREATE_FILE(_name) 220 #define CXACRU__ATTR_CREATE(_name) CXACRU_DEVICE_CREATE_FILE(_name) 221 222 #define CXACRU_ATTR_REMOVE(_v, _t, _name) CXACRU_DEVICE_REMOVE_FILE(_name) 223 #define CXACRU_CMD_REMOVE(_name) CXACRU_DEVICE_REMOVE_FILE(_name) 224 + #define CXACRU_SET_REMOVE(_name) CXACRU_DEVICE_REMOVE_FILE(_name) 225 #define CXACRU__ATTR_REMOVE(_name) CXACRU_DEVICE_REMOVE_FILE(_name) 226 227 static ssize_t cxacru_sysfs_showattr_u32(u32 value, char *buf) ··· 267 static ssize_t cxacru_sysfs_showattr_MODU(u32 value, char *buf) 268 { 269 static char *str[] = { 270 + "", 271 "ANSI T1.413", 272 "ITU-T G.992.1 (G.DMT)", 273 "ITU-T G.992.2 (G.LITE)" 274 }; 275 + if (unlikely(value >= ARRAY_SIZE(str))) 276 return snprintf(buf, PAGE_SIZE, "%u\n", value); 277 return snprintf(buf, PAGE_SIZE, "%s\n", str[value]); 278 } ··· 288 static ssize_t cxacru_sysfs_show_mac_address(struct device *dev, 289 struct device_attribute *attr, char *buf) 290 { 291 + struct cxacru_data *instance = to_usbatm_driver_data( 292 + to_usb_interface(dev)); 293 294 + if (instance == NULL || instance->usbatm->atm_dev == NULL) 295 + return -ENODEV; 296 + 297 + return snprintf(buf, PAGE_SIZE, "%pM\n", 298 + instance->usbatm->atm_dev->esi); 299 } 300 301 static ssize_t cxacru_sysfs_show_adsl_state(struct device *dev, 302 struct device_attribute *attr, char *buf) 303 { 304 static char *str[] = { "running", "stopped" }; 305 + struct cxacru_data *instance = to_usbatm_driver_data( 306 + to_usb_interface(dev)); 307 + u32 value; 308 + 309 + if (instance == NULL) 310 + return -ENODEV; 311 + 312 + value = instance->card_info[CXINF_LINE_STARTABLE]; 313 if (unlikely(value >= ARRAY_SIZE(str))) 314 return snprintf(buf, PAGE_SIZE, "%u\n", value); 315 return snprintf(buf, PAGE_SIZE, "%s\n", str[value]); ··· 312 static ssize_t cxacru_sysfs_store_adsl_state(struct device *dev, 313 struct device_attribute *attr, const char *buf, size_t count) 314 { 315 + struct cxacru_data *instance = to_usbatm_driver_data( 316 + to_usb_interface(dev)); 317 int ret; 318 int poll = -1; 319 char str_cmd[8]; ··· 328 return -EINVAL; 329 ret = 0; 330 331 + if (instance == NULL) 332 + return -ENODEV; 333 + 334 if (mutex_lock_interruptible(&instance->adsl_state_serialize)) 335 return -ERESTARTSYS; 336 337 if (!strcmp(str_cmd, "stop") || !strcmp(str_cmd, "restart")) { 338 ret = cxacru_cm(instance, CM_REQUEST_CHIP_ADSL_LINE_STOP, NULL, 0, NULL, 0); 339 if (ret < 0) { 340 + atm_err(instance->usbatm, "change adsl state:" 341 " CHIP_ADSL_LINE_STOP returned %d\n", ret); 342 343 ret = -EIO; ··· 354 if (!strcmp(str_cmd, "start") || !strcmp(str_cmd, "restart")) { 355 ret = cxacru_cm(instance, CM_REQUEST_CHIP_ADSL_LINE_START, NULL, 0, NULL, 0); 356 if (ret < 0) { 357 + atm_err(instance->usbatm, "change adsl state:" 358 " CHIP_ADSL_LINE_START returned %d\n", ret); 359 360 ret = -EIO; ··· 407 return ret; 408 } 409 410 + /* CM_REQUEST_CARD_DATA_GET times out, so no show attribute */ 411 + 412 + static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev, 413 + struct device_attribute *attr, const char *buf, size_t count) 414 + { 415 + struct cxacru_data *instance = to_usbatm_driver_data( 416 + to_usb_interface(dev)); 417 + int len = strlen(buf); 418 + int ret, pos, num; 419 + __le32 data[CMD_PACKET_SIZE / 4]; 420 + 421 + if (!capable(CAP_NET_ADMIN)) 422 + return -EACCES; 423 + 424 + if (instance == NULL) 425 + return -ENODEV; 426 + 427 + pos = 0; 428 + num = 0; 429 + while (pos < len) { 430 + int tmp; 431 + u32 index; 432 + u32 value; 433 + 434 + ret = sscanf(buf + pos, "%x=%x%n", &index, &value, &tmp); 435 + if (ret < 2) 436 + return -EINVAL; 437 + if (index < 0 || index > 0x7f) 438 + return -EINVAL; 439 + pos += tmp; 440 + 441 + /* skip trailing newline */ 442 + if (buf[pos] == '\n' && pos == len-1) 443 + pos++; 444 + 445 + data[num * 2 + 1] = cpu_to_le32(index); 446 + data[num * 2 + 2] = cpu_to_le32(value); 447 + num++; 448 + 449 + /* send config values when data buffer is full 450 + * or no more data 451 + */ 452 + if (pos >= len || num >= CMD_MAX_CONFIG) { 453 + char log[CMD_MAX_CONFIG * 12 + 1]; /* %02x=%08x */ 454 + 455 + data[0] = cpu_to_le32(num); 456 + ret = cxacru_cm(instance, CM_REQUEST_CARD_DATA_SET, 457 + (u8 *) data, 4 + num * 8, NULL, 0); 458 + if (ret < 0) { 459 + atm_err(instance->usbatm, 460 + "set card data returned %d\n", ret); 461 + return -EIO; 462 + } 463 + 464 + for (tmp = 0; tmp < num; tmp++) 465 + snprintf(log + tmp*12, 13, " %02x=%08x", 466 + le32_to_cpu(data[tmp * 2 + 1]), 467 + le32_to_cpu(data[tmp * 2 + 2])); 468 + atm_info(instance->usbatm, "config%s\n", log); 469 + num = 0; 470 + } 471 + } 472 + 473 + return len; 474 + } 475 + 476 /* 477 * All device attributes are included in CXACRU_ALL_FILES 478 * so that the same list can be used multiple times: ··· 442 CXACRU_ATTR_##_action(CXINF_ADSL_HEADEND, u32, adsl_headend); \ 443 CXACRU_ATTR_##_action(CXINF_ADSL_HEADEND_ENVIRONMENT, u32, adsl_headend_environment); \ 444 CXACRU_ATTR_##_action(CXINF_CONTROLLER_VERSION, u32, adsl_controller_version); \ 445 + CXACRU_CMD_##_action( adsl_state); \ 446 + CXACRU_SET_##_action( adsl_config); 447 448 CXACRU_ALL_FILES(INIT); 449 ··· 596 len = ret / 4; 597 for (offb = 0; offb < len; ) { 598 int l = le32_to_cpu(buf[offb++]); 599 + if (l < 0 || l > stride || l > (len - offb) / 2) { 600 if (printk_ratelimit()) 601 usb_err(instance->usbatm, "invalid data length from cm %#x: %d\n", 602 cm, l); ··· 649 { 650 struct cxacru_data *instance = usbatm_instance->driver_data; 651 struct usb_interface *intf = usbatm_instance->usb_intf; 652 int ret; 653 int start_polling = 1; 654 ··· 696 } 697 mutex_unlock(&instance->poll_state_serialize); 698 mutex_unlock(&instance->adsl_state_serialize); 699 + 700 + printk(KERN_INFO "%s%d: %s %pM\n", atm_dev->type, atm_dev->number, 701 + usbatm_instance->description, atm_dev->esi); 702 703 if (start_polling) 704 cxacru_poll_status(&instance->poll_work.work); ··· 873 874 static void cxacru_upload_firmware(struct cxacru_data *instance, 875 const struct firmware *fw, 876 + const struct firmware *bp) 877 { 878 int ret; 879 struct usbatm_data *usbatm = instance->usbatm; 880 struct usb_device *usb_dev = usbatm->usb_dev; 881 __le16 signature[] = { usb_dev->descriptor.idVendor, ··· 911 } 912 913 /* Firmware */ 914 + usb_info(usbatm, "loading firmware\n"); 915 ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, FW_ADDR, fw->data, fw->size); 916 if (ret) { 917 usb_err(usbatm, "Firmware upload failed: %d\n", ret); ··· 919 920 /* Boot ROM patch */ 921 if (instance->modem_type->boot_rom_patch) { 922 + usb_info(usbatm, "loading boot ROM patch\n"); 923 ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, BR_ADDR, bp->data, bp->size); 924 if (ret) { 925 usb_err(usbatm, "Boot ROM patching failed: %d\n", ret); ··· 933 return; 934 } 935 936 + usb_info(usbatm, "starting device\n"); 937 if (instance->modem_type->boot_rom_patch) { 938 val = cpu_to_le32(BR_ADDR); 939 ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, BR_STACK_ADDR, (u8 *) &val, 4); ··· 958 usb_err(usbatm, "modem failed to initialize: %d\n", ret); 959 return; 960 } 961 } 962 963 static int cxacru_find_firmware(struct cxacru_data *instance, ··· 1003 static int cxacru_heavy_init(struct usbatm_data *usbatm_instance, 1004 struct usb_interface *usb_intf) 1005 { 1006 + const struct firmware *fw, *bp; 1007 struct cxacru_data *instance = usbatm_instance->driver_data; 1008 1009 int ret = cxacru_find_firmware(instance, "fw", &fw); ··· 1021 } 1022 } 1023 1024 + cxacru_upload_firmware(instance, fw, bp); 1025 1026 if (instance->modem_type->boot_rom_patch) 1027 release_firmware(bp); 1028 release_firmware(fw);
+2 -1
drivers/usb/atm/usbatm.c
··· 1333 if (instance->atm_dev) { 1334 sysfs_remove_link(&instance->atm_dev->class_dev.kobj, "device"); 1335 atm_dev_deregister(instance->atm_dev); 1336 } 1337 1338 usbatm_put_instance(instance); /* taken in usbatm_usb_probe */ ··· 1349 { 1350 dbg("%s: driver version %s", __func__, DRIVER_VERSION); 1351 1352 - if (sizeof(struct usbatm_control) > sizeof(((struct sk_buff *) 0)->cb)) { 1353 printk(KERN_ERR "%s unusable with this kernel!\n", usbatm_driver_name); 1354 return -EIO; 1355 }
··· 1333 if (instance->atm_dev) { 1334 sysfs_remove_link(&instance->atm_dev->class_dev.kobj, "device"); 1335 atm_dev_deregister(instance->atm_dev); 1336 + instance->atm_dev = NULL; 1337 } 1338 1339 usbatm_put_instance(instance); /* taken in usbatm_usb_probe */ ··· 1348 { 1349 dbg("%s: driver version %s", __func__, DRIVER_VERSION); 1350 1351 + if (sizeof(struct usbatm_control) > FIELD_SIZEOF(struct sk_buff, cb)) { 1352 printk(KERN_ERR "%s unusable with this kernel!\n", usbatm_driver_name); 1353 return -EIO; 1354 }
+15
drivers/usb/atm/usbatm.h
··· 204 struct urb *urbs[0]; 205 }; 206 207 #endif /* _USBATM_H_ */
··· 204 struct urb *urbs[0]; 205 }; 206 207 + static inline void *to_usbatm_driver_data(struct usb_interface *intf) 208 + { 209 + struct usbatm_data *usbatm_instance; 210 + 211 + if (intf == NULL) 212 + return NULL; 213 + 214 + usbatm_instance = usb_get_intfdata(intf); 215 + 216 + if (usbatm_instance == NULL) /* set NULL before unbind() */ 217 + return NULL; 218 + 219 + return usbatm_instance->driver_data; /* set NULL after unbind() */ 220 + } 221 + 222 #endif /* _USBATM_H_ */
+4 -4
drivers/usb/c67x00/c67x00-drv.c
··· 137 if (!c67x00) 138 return -ENOMEM; 139 140 - if (!request_mem_region(res->start, res->end - res->start + 1, 141 pdev->name)) { 142 dev_err(&pdev->dev, "Memory region busy\n"); 143 ret = -EBUSY; 144 goto request_mem_failed; 145 } 146 - c67x00->hpi.base = ioremap(res->start, res->end - res->start + 1); 147 if (!c67x00->hpi.base) { 148 dev_err(&pdev->dev, "Unable to map HPI registers\n"); 149 ret = -EIO; ··· 182 request_irq_failed: 183 iounmap(c67x00->hpi.base); 184 map_failed: 185 - release_mem_region(res->start, res->end - res->start + 1); 186 request_mem_failed: 187 kfree(c67x00); 188 ··· 208 209 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 210 if (res) 211 - release_mem_region(res->start, res->end - res->start + 1); 212 213 kfree(c67x00); 214
··· 137 if (!c67x00) 138 return -ENOMEM; 139 140 + if (!request_mem_region(res->start, resource_size(res), 141 pdev->name)) { 142 dev_err(&pdev->dev, "Memory region busy\n"); 143 ret = -EBUSY; 144 goto request_mem_failed; 145 } 146 + c67x00->hpi.base = ioremap(res->start, resource_size(res)); 147 if (!c67x00->hpi.base) { 148 dev_err(&pdev->dev, "Unable to map HPI registers\n"); 149 ret = -EIO; ··· 182 request_irq_failed: 183 iounmap(c67x00->hpi.base); 184 map_failed: 185 + release_mem_region(res->start, resource_size(res)); 186 request_mem_failed: 187 kfree(c67x00); 188 ··· 208 209 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 210 if (res) 211 + release_mem_region(res->start, resource_size(res)); 212 213 kfree(c67x00); 214
+53 -29
drivers/usb/class/cdc-acm.c
··· 170 { 171 wb->use = 0; 172 acm->transmitting--; 173 } 174 175 /* ··· 212 } 213 214 dbg("%s susp_count: %d", __func__, acm->susp_count); 215 if (acm->susp_count) { 216 - acm->delayed_wb = wb; 217 - schedule_work(&acm->waker); 218 spin_unlock_irqrestore(&acm->write_lock, flags); 219 return 0; /* A white lie */ 220 } ··· 428 throttled = acm->throttle; 429 spin_unlock_irqrestore(&acm->throttle_lock, flags); 430 if (!throttled) { 431 - tty_buffer_request_room(tty, buf->size); 432 tty_insert_flip_string(tty, buf->base, buf->size); 433 tty_flip_buffer_push(tty); 434 } else { ··· 537 tty_kref_put(tty); 538 } 539 540 - static void acm_waker(struct work_struct *waker) 541 - { 542 - struct acm *acm = container_of(waker, struct acm, waker); 543 - int rv; 544 - 545 - rv = usb_autopm_get_interface(acm->control); 546 - if (rv < 0) { 547 - dev_err(&acm->dev->dev, "Autopm failure in %s\n", __func__); 548 - return; 549 - } 550 - if (acm->delayed_wb) { 551 - acm_start_wb(acm, acm->delayed_wb); 552 - acm->delayed_wb = NULL; 553 - } 554 - usb_autopm_put_interface(acm->control); 555 - } 556 - 557 /* 558 * TTY handlers 559 */ ··· 552 553 acm = acm_table[tty->index]; 554 if (!acm || !acm->dev) 555 - goto err_out; 556 else 557 rv = 0; 558 ··· 568 569 mutex_lock(&acm->mutex); 570 if (acm->port.count++) { 571 usb_autopm_put_interface(acm->control); 572 - goto done; 573 } 574 575 acm->ctrlurb->dev = acm->dev; ··· 599 set_bit(ASYNCB_INITIALIZED, &acm->port.flags); 600 rv = tty_port_block_til_ready(&acm->port, tty, filp); 601 tasklet_schedule(&acm->urb_task); 602 - done: 603 mutex_unlock(&acm->mutex); 604 - err_out: 605 mutex_unlock(&open_mutex); 606 return rv; 607 608 full_bailout: 609 usb_kill_urb(acm->ctrlurb); 610 bail_out: 611 - usb_autopm_put_interface(acm->control); 612 acm->port.count--; 613 mutex_unlock(&acm->mutex); 614 early_bail: 615 mutex_unlock(&open_mutex); 616 tty_port_tty_set(&acm->port, NULL); ··· 1010 case USB_CDC_CALL_MANAGEMENT_TYPE: 1011 call_management_function = buffer[3]; 1012 call_interface_num = buffer[4]; 1013 - if ((call_management_function & 3) != 3) 1014 dev_err(&intf->dev, "This device cannot do calls on its own. It is not a modem.\n"); 1015 break; 1016 default: ··· 1165 acm->urb_task.func = acm_rx_tasklet; 1166 acm->urb_task.data = (unsigned long) acm; 1167 INIT_WORK(&acm->work, acm_softint); 1168 - INIT_WORK(&acm->waker, acm_waker); 1169 init_waitqueue_head(&acm->drain_wait); 1170 spin_lock_init(&acm->throttle_lock); 1171 spin_lock_init(&acm->write_lock); ··· 1329 tasklet_enable(&acm->urb_task); 1330 1331 cancel_work_sync(&acm->work); 1332 - cancel_work_sync(&acm->waker); 1333 } 1334 1335 static void acm_disconnect(struct usb_interface *intf) ··· 1420 static int acm_resume(struct usb_interface *intf) 1421 { 1422 struct acm *acm = usb_get_intfdata(intf); 1423 int rv = 0; 1424 int cnt; 1425 ··· 1435 mutex_lock(&acm->mutex); 1436 if (acm->port.count) { 1437 rv = usb_submit_urb(acm->ctrlurb, GFP_NOIO); 1438 if (rv < 0) 1439 goto err_out; 1440 ··· 1459 err_out: 1460 mutex_unlock(&acm->mutex); 1461 return rv; 1462 } 1463 1464 #endif /* CONFIG_PM */ ··· 1489 * USB driver structure. 1490 */ 1491 1492 - static struct usb_device_id acm_ids[] = { 1493 /* quirky and broken devices */ 1494 { USB_DEVICE(0x0870, 0x0001), /* Metricom GS Modem */ 1495 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */ ··· 1594 1595 /* NOTE: non-Nokia COMM/ACM/0xff is likely MSFT RNDIS... NOT a modem! */ 1596 1597 /* control interfaces with various AT-command sets */ 1598 { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM, 1599 USB_CDC_ACM_PROTO_AT_V25TER) }, ··· 1625 #ifdef CONFIG_PM 1626 .suspend = acm_suspend, 1627 .resume = acm_resume, 1628 #endif 1629 .id_table = acm_ids, 1630 #ifdef CONFIG_PM
··· 170 { 171 wb->use = 0; 172 acm->transmitting--; 173 + usb_autopm_put_interface_async(acm->control); 174 } 175 176 /* ··· 211 } 212 213 dbg("%s susp_count: %d", __func__, acm->susp_count); 214 + usb_autopm_get_interface_async(acm->control); 215 if (acm->susp_count) { 216 + if (!acm->delayed_wb) 217 + acm->delayed_wb = wb; 218 + else 219 + usb_autopm_put_interface_async(acm->control); 220 spin_unlock_irqrestore(&acm->write_lock, flags); 221 return 0; /* A white lie */ 222 } ··· 424 throttled = acm->throttle; 425 spin_unlock_irqrestore(&acm->throttle_lock, flags); 426 if (!throttled) { 427 tty_insert_flip_string(tty, buf->base, buf->size); 428 tty_flip_buffer_push(tty); 429 } else { ··· 534 tty_kref_put(tty); 535 } 536 537 /* 538 * TTY handlers 539 */ ··· 566 567 acm = acm_table[tty->index]; 568 if (!acm || !acm->dev) 569 + goto out; 570 else 571 rv = 0; 572 ··· 582 583 mutex_lock(&acm->mutex); 584 if (acm->port.count++) { 585 + mutex_unlock(&acm->mutex); 586 usb_autopm_put_interface(acm->control); 587 + goto out; 588 } 589 590 acm->ctrlurb->dev = acm->dev; ··· 612 set_bit(ASYNCB_INITIALIZED, &acm->port.flags); 613 rv = tty_port_block_til_ready(&acm->port, tty, filp); 614 tasklet_schedule(&acm->urb_task); 615 + 616 mutex_unlock(&acm->mutex); 617 + out: 618 mutex_unlock(&open_mutex); 619 return rv; 620 621 full_bailout: 622 usb_kill_urb(acm->ctrlurb); 623 bail_out: 624 acm->port.count--; 625 mutex_unlock(&acm->mutex); 626 + usb_autopm_put_interface(acm->control); 627 early_bail: 628 mutex_unlock(&open_mutex); 629 tty_port_tty_set(&acm->port, NULL); ··· 1023 case USB_CDC_CALL_MANAGEMENT_TYPE: 1024 call_management_function = buffer[3]; 1025 call_interface_num = buffer[4]; 1026 + if ( (quirks & NOT_A_MODEM) == 0 && (call_management_function & 3) != 3) 1027 dev_err(&intf->dev, "This device cannot do calls on its own. It is not a modem.\n"); 1028 break; 1029 default: ··· 1178 acm->urb_task.func = acm_rx_tasklet; 1179 acm->urb_task.data = (unsigned long) acm; 1180 INIT_WORK(&acm->work, acm_softint); 1181 init_waitqueue_head(&acm->drain_wait); 1182 spin_lock_init(&acm->throttle_lock); 1183 spin_lock_init(&acm->write_lock); ··· 1343 tasklet_enable(&acm->urb_task); 1344 1345 cancel_work_sync(&acm->work); 1346 } 1347 1348 static void acm_disconnect(struct usb_interface *intf) ··· 1435 static int acm_resume(struct usb_interface *intf) 1436 { 1437 struct acm *acm = usb_get_intfdata(intf); 1438 + struct acm_wb *wb; 1439 int rv = 0; 1440 int cnt; 1441 ··· 1449 mutex_lock(&acm->mutex); 1450 if (acm->port.count) { 1451 rv = usb_submit_urb(acm->ctrlurb, GFP_NOIO); 1452 + 1453 + spin_lock_irq(&acm->write_lock); 1454 + if (acm->delayed_wb) { 1455 + wb = acm->delayed_wb; 1456 + acm->delayed_wb = NULL; 1457 + spin_unlock_irq(&acm->write_lock); 1458 + acm_start_wb(acm, acm->delayed_wb); 1459 + } else { 1460 + spin_unlock_irq(&acm->write_lock); 1461 + } 1462 + 1463 + /* 1464 + * delayed error checking because we must 1465 + * do the write path at all cost 1466 + */ 1467 if (rv < 0) 1468 goto err_out; 1469 ··· 1458 err_out: 1459 mutex_unlock(&acm->mutex); 1460 return rv; 1461 + } 1462 + 1463 + static int acm_reset_resume(struct usb_interface *intf) 1464 + { 1465 + struct acm *acm = usb_get_intfdata(intf); 1466 + struct tty_struct *tty; 1467 + 1468 + mutex_lock(&acm->mutex); 1469 + if (acm->port.count) { 1470 + tty = tty_port_tty_get(&acm->port); 1471 + if (tty) { 1472 + tty_hangup(tty); 1473 + tty_kref_put(tty); 1474 + } 1475 + } 1476 + mutex_unlock(&acm->mutex); 1477 + return acm_resume(intf); 1478 } 1479 1480 #endif /* CONFIG_PM */ ··· 1471 * USB driver structure. 1472 */ 1473 1474 + static const struct usb_device_id acm_ids[] = { 1475 /* quirky and broken devices */ 1476 { USB_DEVICE(0x0870, 0x0001), /* Metricom GS Modem */ 1477 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */ ··· 1576 1577 /* NOTE: non-Nokia COMM/ACM/0xff is likely MSFT RNDIS... NOT a modem! */ 1578 1579 + /* Support Lego NXT using pbLua firmware */ 1580 + { USB_DEVICE(0x0694, 0xff00), 1581 + .driver_info = NOT_A_MODEM, 1582 + }, 1583 + 1584 /* control interfaces with various AT-command sets */ 1585 { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM, 1586 USB_CDC_ACM_PROTO_AT_V25TER) }, ··· 1602 #ifdef CONFIG_PM 1603 .suspend = acm_suspend, 1604 .resume = acm_resume, 1605 + .reset_resume = acm_reset_resume, 1606 #endif 1607 .id_table = acm_ids, 1608 #ifdef CONFIG_PM
+1 -1
drivers/usb/class/cdc-acm.h
··· 112 struct mutex mutex; 113 struct usb_cdc_line_coding line; /* bits, stop, parity */ 114 struct work_struct work; /* work queue entry for line discipline waking up */ 115 - struct work_struct waker; 116 wait_queue_head_t drain_wait; /* close processing */ 117 struct tasklet_struct urb_task; /* rx processing */ 118 spinlock_t throttle_lock; /* synchronize throtteling and read callback */ ··· 136 #define NO_UNION_NORMAL 1 137 #define SINGLE_RX_URB 2 138 #define NO_CAP_LINE 4
··· 112 struct mutex mutex; 113 struct usb_cdc_line_coding line; /* bits, stop, parity */ 114 struct work_struct work; /* work queue entry for line discipline waking up */ 115 wait_queue_head_t drain_wait; /* close processing */ 116 struct tasklet_struct urb_task; /* rx processing */ 117 spinlock_t throttle_lock; /* synchronize throtteling and read callback */ ··· 137 #define NO_UNION_NORMAL 1 138 #define SINGLE_RX_URB 2 139 #define NO_CAP_LINE 4 140 + #define NOT_A_MODEM 8
+1 -1
drivers/usb/class/cdc-wdm.c
··· 31 #define DRIVER_AUTHOR "Oliver Neukum" 32 #define DRIVER_DESC "USB Abstract Control Model driver for USB WCM Device Management" 33 34 - static struct usb_device_id wdm_ids[] = { 35 { 36 .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS | 37 USB_DEVICE_ID_MATCH_INT_SUBCLASS,
··· 31 #define DRIVER_AUTHOR "Oliver Neukum" 32 #define DRIVER_DESC "USB Abstract Control Model driver for USB WCM Device Management" 33 34 + static const struct usb_device_id wdm_ids[] = { 35 { 36 .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS | 37 USB_DEVICE_ID_MATCH_INT_SUBCLASS,
+4 -18
drivers/usb/class/usblp.c
··· 163 unsigned char used; /* True if open */ 164 unsigned char present; /* True if not disconnected */ 165 unsigned char bidir; /* interface is bidirectional */ 166 - unsigned char sleeping; /* interface is suspended */ 167 unsigned char no_paper; /* Paper Out happened */ 168 unsigned char *device_id_string; /* IEEE 1284 DEVICE ID string (ptr) */ 169 /* first 2 bytes are (big-endian) length */ ··· 190 dbg("quirks=%d", usblp->quirks); 191 dbg("used=%d", usblp->used); 192 dbg("bidir=%d", usblp->bidir); 193 - dbg("sleeping=%d", usblp->sleeping); 194 dbg("device_id_string=\"%s\"", 195 usblp->device_id_string ? 196 usblp->device_id_string + 2 : ··· 374 375 static int handle_bidir (struct usblp *usblp) 376 { 377 - if (usblp->bidir && usblp->used && !usblp->sleeping) { 378 if (usblp_submit_read(usblp) < 0) 379 return -EIO; 380 } ··· 497 498 mutex_lock (&usblp->mut); 499 if (!usblp->present) { 500 - retval = -ENODEV; 501 - goto done; 502 - } 503 - 504 - if (usblp->sleeping) { 505 retval = -ENODEV; 506 goto done; 507 } ··· 907 return 0; 908 } 909 spin_unlock_irqrestore(&usblp->lock, flags); 910 - if (usblp->sleeping) 911 - return -ENODEV; 912 if (nonblock) 913 return -EAGAIN; 914 return 1; ··· 959 return 0; 960 } 961 spin_unlock_irqrestore(&usblp->lock, flags); 962 - if (usblp->sleeping) 963 - return -ENODEV; 964 if (nonblock) 965 return -EAGAIN; 966 return 1; ··· 1366 mutex_unlock (&usblp_mutex); 1367 } 1368 1369 - static int usblp_suspend (struct usb_interface *intf, pm_message_t message) 1370 { 1371 struct usblp *usblp = usb_get_intfdata (intf); 1372 1373 - /* we take no more IO */ 1374 - usblp->sleeping = 1; 1375 usblp_unlink_urbs(usblp); 1376 #if 0 /* XXX Do we want this? What if someone is reading, should we fail? */ 1377 /* not strictly necessary, but just in case */ ··· 1380 return 0; 1381 } 1382 1383 - static int usblp_resume (struct usb_interface *intf) 1384 { 1385 struct usblp *usblp = usb_get_intfdata (intf); 1386 int r; 1387 1388 - usblp->sleeping = 0; 1389 r = handle_bidir (usblp); 1390 1391 return r; 1392 } 1393 1394 - static struct usb_device_id usblp_ids [] = { 1395 { USB_DEVICE_INFO(7, 1, 1) }, 1396 { USB_DEVICE_INFO(7, 1, 2) }, 1397 { USB_DEVICE_INFO(7, 1, 3) },
··· 163 unsigned char used; /* True if open */ 164 unsigned char present; /* True if not disconnected */ 165 unsigned char bidir; /* interface is bidirectional */ 166 unsigned char no_paper; /* Paper Out happened */ 167 unsigned char *device_id_string; /* IEEE 1284 DEVICE ID string (ptr) */ 168 /* first 2 bytes are (big-endian) length */ ··· 191 dbg("quirks=%d", usblp->quirks); 192 dbg("used=%d", usblp->used); 193 dbg("bidir=%d", usblp->bidir); 194 dbg("device_id_string=\"%s\"", 195 usblp->device_id_string ? 196 usblp->device_id_string + 2 : ··· 376 377 static int handle_bidir (struct usblp *usblp) 378 { 379 + if (usblp->bidir && usblp->used) { 380 if (usblp_submit_read(usblp) < 0) 381 return -EIO; 382 } ··· 499 500 mutex_lock (&usblp->mut); 501 if (!usblp->present) { 502 retval = -ENODEV; 503 goto done; 504 } ··· 914 return 0; 915 } 916 spin_unlock_irqrestore(&usblp->lock, flags); 917 if (nonblock) 918 return -EAGAIN; 919 return 1; ··· 968 return 0; 969 } 970 spin_unlock_irqrestore(&usblp->lock, flags); 971 if (nonblock) 972 return -EAGAIN; 973 return 1; ··· 1377 mutex_unlock (&usblp_mutex); 1378 } 1379 1380 + static int usblp_suspend(struct usb_interface *intf, pm_message_t message) 1381 { 1382 struct usblp *usblp = usb_get_intfdata (intf); 1383 1384 usblp_unlink_urbs(usblp); 1385 #if 0 /* XXX Do we want this? What if someone is reading, should we fail? */ 1386 /* not strictly necessary, but just in case */ ··· 1393 return 0; 1394 } 1395 1396 + static int usblp_resume(struct usb_interface *intf) 1397 { 1398 struct usblp *usblp = usb_get_intfdata (intf); 1399 int r; 1400 1401 r = handle_bidir (usblp); 1402 1403 return r; 1404 } 1405 1406 + static const struct usb_device_id usblp_ids[] = { 1407 { USB_DEVICE_INFO(7, 1, 1) }, 1408 { USB_DEVICE_INFO(7, 1, 2) }, 1409 { USB_DEVICE_INFO(7, 1, 3) },
+1 -1
drivers/usb/class/usbtmc.c
··· 48 */ 49 #define USBTMC_MAX_READS_TO_CLEAR_BULK_IN 100 50 51 - static struct usb_device_id usbtmc_devices[] = { 52 { USB_INTERFACE_INFO(USB_CLASS_APP_SPEC, 3, 0), }, 53 { USB_INTERFACE_INFO(USB_CLASS_APP_SPEC, 3, 1), }, 54 { 0, } /* terminating entry */
··· 48 */ 49 #define USBTMC_MAX_READS_TO_CLEAR_BULK_IN 100 50 51 + static const struct usb_device_id usbtmc_devices[] = { 52 { USB_INTERFACE_INFO(USB_CLASS_APP_SPEC, 3, 0), }, 53 { USB_INTERFACE_INFO(USB_CLASS_APP_SPEC, 3, 1), }, 54 { 0, } /* terminating entry */
+2 -2
drivers/usb/core/Kconfig
··· 91 If you are unsure about this, say N here. 92 93 config USB_SUSPEND 94 - bool "USB selective suspend/resume and wakeup" 95 - depends on USB && PM 96 help 97 If you say Y here, you can use driver calls or the sysfs 98 "power/level" file to suspend or resume individual USB
··· 91 If you are unsure about this, say N here. 92 93 config USB_SUSPEND 94 + bool "USB runtime power management (suspend/resume and wakeup)" 95 + depends on USB && PM_RUNTIME 96 help 97 If you say Y here, you can use driver calls or the sysfs 98 "power/level" file to suspend or resume individual USB
+11 -21
drivers/usb/core/devices.c
··· 118 */ 119 120 static DECLARE_WAIT_QUEUE_HEAD(deviceconndiscwq); 121 static unsigned int conndiscevcnt; 122 123 /* this struct stores the poll state for <mountpoint>/devices pollers */ ··· 157 158 void usbfs_conn_disc_event(void) 159 { 160 conndiscevcnt++; 161 wake_up(&deviceconndiscwq); 162 } 163 ··· 632 static unsigned int usb_device_poll(struct file *file, 633 struct poll_table_struct *wait) 634 { 635 - struct usb_device_status *st = file->private_data; 636 unsigned int mask = 0; 637 638 - lock_kernel(); 639 if (!st) { 640 st = kmalloc(sizeof(struct usb_device_status), GFP_KERNEL); 641 - 642 - /* we may have dropped BKL - 643 - * need to check for having lost the race */ 644 - if (file->private_data) { 645 - kfree(st); 646 - st = file->private_data; 647 - goto lost_race; 648 - } 649 - /* we haven't lost - check for allocation failure now */ 650 if (!st) { 651 - unlock_kernel(); 652 return POLLIN; 653 } 654 655 - /* 656 - * need to prevent the module from being unloaded, since 657 - * proc_unregister does not call the release method and 658 - * we would have a memory leak 659 - */ 660 st->lastev = conndiscevcnt; 661 file->private_data = st; 662 mask = POLLIN; 663 } 664 - lost_race: 665 if (file->f_mode & FMODE_READ) 666 poll_wait(file, &deviceconndiscwq, wait); 667 if (st->lastev != conndiscevcnt) 668 mask |= POLLIN; 669 st->lastev = conndiscevcnt; 670 - unlock_kernel(); 671 return mask; 672 } 673 ··· 675 { 676 loff_t ret; 677 678 - lock_kernel(); 679 680 switch (orig) { 681 case 0: ··· 691 ret = -EINVAL; 692 } 693 694 - unlock_kernel(); 695 return ret; 696 } 697
··· 118 */ 119 120 static DECLARE_WAIT_QUEUE_HEAD(deviceconndiscwq); 121 + /* guarded by usbfs_mutex */ 122 static unsigned int conndiscevcnt; 123 124 /* this struct stores the poll state for <mountpoint>/devices pollers */ ··· 156 157 void usbfs_conn_disc_event(void) 158 { 159 + mutex_lock(&usbfs_mutex); 160 conndiscevcnt++; 161 + mutex_unlock(&usbfs_mutex); 162 wake_up(&deviceconndiscwq); 163 } 164 ··· 629 static unsigned int usb_device_poll(struct file *file, 630 struct poll_table_struct *wait) 631 { 632 + struct usb_device_status *st; 633 unsigned int mask = 0; 634 635 + mutex_lock(&usbfs_mutex); 636 + st = file->private_data; 637 if (!st) { 638 st = kmalloc(sizeof(struct usb_device_status), GFP_KERNEL); 639 if (!st) { 640 + mutex_unlock(&usbfs_mutex); 641 return POLLIN; 642 } 643 644 st->lastev = conndiscevcnt; 645 file->private_data = st; 646 mask = POLLIN; 647 } 648 + 649 if (file->f_mode & FMODE_READ) 650 poll_wait(file, &deviceconndiscwq, wait); 651 if (st->lastev != conndiscevcnt) 652 mask |= POLLIN; 653 st->lastev = conndiscevcnt; 654 + mutex_unlock(&usbfs_mutex); 655 return mask; 656 } 657 ··· 685 { 686 loff_t ret; 687 688 + mutex_lock(&file->f_dentry->d_inode->i_mutex); 689 690 switch (orig) { 691 case 0: ··· 701 ret = -EINVAL; 702 } 703 704 + mutex_unlock(&file->f_dentry->d_inode->i_mutex); 705 return ret; 706 } 707
+80 -47
drivers/usb/core/devio.c
··· 122 { 123 loff_t ret; 124 125 - lock_kernel(); 126 127 switch (orig) { 128 case 0: ··· 138 ret = -EINVAL; 139 } 140 141 - unlock_kernel(); 142 return ret; 143 } 144 ··· 310 311 static void snoop_urb(struct usb_device *udev, 312 void __user *userurb, int pipe, unsigned length, 313 - int timeout_or_status, enum snoop_when when) 314 { 315 static const char *types[] = {"isoc", "int", "ctrl", "bulk"}; 316 static const char *dirs[] = {"out", "in"}; ··· 344 dev_info(&udev->dev, "ep%d %s-%s, actual_length %u, " 345 "status %d\n", 346 ep, t, d, length, timeout_or_status); 347 } 348 } 349 ··· 416 } 417 snoop(&urb->dev->dev, "urb complete\n"); 418 snoop_urb(urb->dev, as->userurb, urb->pipe, urb->actual_length, 419 - as->status, COMPLETE); 420 if (as->status < 0 && as->bulk_addr && as->status != -ECONNRESET && 421 as->status != -ENOENT) 422 cancel_bulk_urbs(ps, as->bulk_addr); ··· 661 const struct cred *cred = current_cred(); 662 int ret; 663 664 - lock_kernel(); 665 - /* Protect against simultaneous removal or release */ 666 - mutex_lock(&usbfs_mutex); 667 - 668 ret = -ENOMEM; 669 ps = kmalloc(sizeof(struct dev_state), GFP_KERNEL); 670 if (!ps) 671 - goto out; 672 673 ret = -ENODEV; 674 675 /* usbdev device-node */ 676 if (imajor(inode) == USB_DEVICE_MAJOR) 677 dev = usbdev_lookup_by_devt(inode->i_rdev); 678 #ifdef CONFIG_USB_DEVICEFS 679 /* procfs file */ 680 if (!dev) { ··· 686 dev = NULL; 687 } 688 #endif 689 - if (!dev || dev->state == USB_STATE_NOTATTACHED) 690 - goto out; 691 ret = usb_autoresume_device(dev); 692 if (ret) 693 - goto out; 694 695 - ret = 0; 696 ps->dev = dev; 697 ps->file = file; 698 spin_lock_init(&ps->lock); ··· 716 smp_wmb(); 717 list_add_tail(&ps->list, &dev->filelist); 718 file->private_data = ps; 719 snoop(&dev->dev, "opened by process %d: %s\n", task_pid_nr(current), 720 current->comm); 721 - out: 722 - if (ret) { 723 - kfree(ps); 724 - usb_put_dev(dev); 725 - } 726 - mutex_unlock(&usbfs_mutex); 727 - unlock_kernel(); 728 return ret; 729 } 730 ··· 739 usb_lock_device(dev); 740 usb_hub_release_all_ports(dev, ps); 741 742 - /* Protect against simultaneous open */ 743 - mutex_lock(&usbfs_mutex); 744 list_del_init(&ps->list); 745 - mutex_unlock(&usbfs_mutex); 746 747 for (ifnum = 0; ps->ifclaimed && ifnum < 8*sizeof(ps->ifclaimed); 748 ifnum++) { ··· 782 if (!tbuf) 783 return -ENOMEM; 784 tmo = ctrl.timeout; 785 if (ctrl.bRequestType & 0x80) { 786 if (ctrl.wLength && !access_ok(VERIFY_WRITE, ctrl.data, 787 ctrl.wLength)) { ··· 796 return -EINVAL; 797 } 798 pipe = usb_rcvctrlpipe(dev, 0); 799 - snoop_urb(dev, NULL, pipe, ctrl.wLength, tmo, SUBMIT); 800 801 usb_unlock_device(dev); 802 i = usb_control_msg(dev, pipe, ctrl.bRequest, 803 ctrl.bRequestType, ctrl.wValue, ctrl.wIndex, 804 tbuf, ctrl.wLength, tmo); 805 usb_lock_device(dev); 806 - snoop_urb(dev, NULL, pipe, max(i, 0), min(i, 0), COMPLETE); 807 - 808 if ((i > 0) && ctrl.wLength) { 809 if (copy_to_user(ctrl.data, tbuf, i)) { 810 free_page((unsigned long)tbuf); ··· 819 } 820 } 821 pipe = usb_sndctrlpipe(dev, 0); 822 - snoop_urb(dev, NULL, pipe, ctrl.wLength, tmo, SUBMIT); 823 824 usb_unlock_device(dev); 825 i = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), ctrl.bRequest, 826 ctrl.bRequestType, ctrl.wValue, ctrl.wIndex, 827 tbuf, ctrl.wLength, tmo); 828 usb_lock_device(dev); 829 - snoop_urb(dev, NULL, pipe, max(i, 0), min(i, 0), COMPLETE); 830 } 831 free_page((unsigned long)tbuf); 832 if (i < 0 && i != -EPIPE) { ··· 873 kfree(tbuf); 874 return -EINVAL; 875 } 876 - snoop_urb(dev, NULL, pipe, len1, tmo, SUBMIT); 877 878 usb_unlock_device(dev); 879 i = usb_bulk_msg(dev, pipe, tbuf, len1, &len2, tmo); 880 usb_lock_device(dev); 881 - snoop_urb(dev, NULL, pipe, len2, i, COMPLETE); 882 883 if (!i && len2) { 884 if (copy_to_user(bulk.data, tbuf, len2)) { ··· 893 return -EFAULT; 894 } 895 } 896 - snoop_urb(dev, NULL, pipe, len1, tmo, SUBMIT); 897 898 usb_unlock_device(dev); 899 i = usb_bulk_msg(dev, pipe, tbuf, len1, &len2, tmo); 900 usb_lock_device(dev); 901 - snoop_urb(dev, NULL, pipe, len2, i, COMPLETE); 902 } 903 kfree(tbuf); 904 if (i < 0) ··· 1117 is_in = 0; 1118 uurb->endpoint &= ~USB_DIR_IN; 1119 } 1120 break; 1121 1122 case USBDEVFS_URB_TYPE_BULK: ··· 1131 case USB_ENDPOINT_XFER_CONTROL: 1132 case USB_ENDPOINT_XFER_ISOC: 1133 return -EINVAL; 1134 - /* allow single-shot interrupt transfers, at bogus rates */ 1135 } 1136 uurb->number_of_packets = 0; 1137 if (uurb->buffer_length > MAX_USBFS_BUFFER_SIZE) 1138 return -EINVAL; ··· 1180 return -EINVAL; 1181 } 1182 uurb->buffer_length = totlen; 1183 - break; 1184 - 1185 - case USBDEVFS_URB_TYPE_INTERRUPT: 1186 - uurb->number_of_packets = 0; 1187 - if (!usb_endpoint_xfer_int(&ep->desc)) 1188 - return -EINVAL; 1189 - if (uurb->buffer_length > MAX_USBFS_BUFFER_SIZE) 1190 - return -EINVAL; 1191 break; 1192 1193 default: ··· 1267 } 1268 } 1269 snoop_urb(ps->dev, as->userurb, as->urb->pipe, 1270 - as->urb->transfer_buffer_length, 0, SUBMIT); 1271 async_newpending(as); 1272 1273 if (usb_endpoint_xfer_bulk(&ep->desc)) { ··· 1307 dev_printk(KERN_DEBUG, &ps->dev->dev, 1308 "usbfs: usb_submit_urb returned %d\n", ret); 1309 snoop_urb(ps->dev, as->userurb, as->urb->pipe, 1310 - 0, ret, COMPLETE); 1311 async_removepending(as); 1312 free_async(as); 1313 return ret; ··· 1661 if (driver == NULL || driver->ioctl == NULL) { 1662 retval = -ENOTTY; 1663 } else { 1664 retval = driver->ioctl(intf, ctl->ioctl_code, buf); 1665 if (retval == -ENOIOCTLCMD) 1666 retval = -ENOTTY; 1667 } ··· 1747 1748 if (!(file->f_mode & FMODE_WRITE)) 1749 return -EPERM; 1750 usb_lock_device(dev); 1751 if (!connected(ps)) { 1752 usb_unlock_device(dev); ··· 1914 { 1915 int ret; 1916 1917 - lock_kernel(); 1918 ret = usbdev_do_ioctl(file, cmd, (void __user *)arg); 1919 - unlock_kernel(); 1920 1921 return ret; 1922 } ··· 1925 { 1926 int ret; 1927 1928 - lock_kernel(); 1929 ret = usbdev_do_ioctl(file, cmd, compat_ptr(arg)); 1930 - unlock_kernel(); 1931 1932 return ret; 1933 }
··· 122 { 123 loff_t ret; 124 125 + mutex_lock(&file->f_dentry->d_inode->i_mutex); 126 127 switch (orig) { 128 case 0: ··· 138 ret = -EINVAL; 139 } 140 141 + mutex_unlock(&file->f_dentry->d_inode->i_mutex); 142 return ret; 143 } 144 ··· 310 311 static void snoop_urb(struct usb_device *udev, 312 void __user *userurb, int pipe, unsigned length, 313 + int timeout_or_status, enum snoop_when when, 314 + unsigned char *data, unsigned data_len) 315 { 316 static const char *types[] = {"isoc", "int", "ctrl", "bulk"}; 317 static const char *dirs[] = {"out", "in"}; ··· 343 dev_info(&udev->dev, "ep%d %s-%s, actual_length %u, " 344 "status %d\n", 345 ep, t, d, length, timeout_or_status); 346 + } 347 + 348 + if (data && data_len > 0) { 349 + print_hex_dump(KERN_DEBUG, "data: ", DUMP_PREFIX_NONE, 32, 1, 350 + data, data_len, 1); 351 } 352 } 353 ··· 410 } 411 snoop(&urb->dev->dev, "urb complete\n"); 412 snoop_urb(urb->dev, as->userurb, urb->pipe, urb->actual_length, 413 + as->status, COMPLETE, 414 + ((urb->transfer_flags & URB_DIR_MASK) == USB_DIR_OUT) ? 415 + NULL : urb->transfer_buffer, urb->actual_length); 416 if (as->status < 0 && as->bulk_addr && as->status != -ECONNRESET && 417 as->status != -ENOENT) 418 cancel_bulk_urbs(ps, as->bulk_addr); ··· 653 const struct cred *cred = current_cred(); 654 int ret; 655 656 ret = -ENOMEM; 657 ps = kmalloc(sizeof(struct dev_state), GFP_KERNEL); 658 if (!ps) 659 + goto out_free_ps; 660 661 ret = -ENODEV; 662 + 663 + /* Protect against simultaneous removal or release */ 664 + mutex_lock(&usbfs_mutex); 665 666 /* usbdev device-node */ 667 if (imajor(inode) == USB_DEVICE_MAJOR) 668 dev = usbdev_lookup_by_devt(inode->i_rdev); 669 + 670 #ifdef CONFIG_USB_DEVICEFS 671 /* procfs file */ 672 if (!dev) { ··· 678 dev = NULL; 679 } 680 #endif 681 + mutex_unlock(&usbfs_mutex); 682 + 683 + if (!dev) 684 + goto out_free_ps; 685 + 686 + usb_lock_device(dev); 687 + if (dev->state == USB_STATE_NOTATTACHED) 688 + goto out_unlock_device; 689 + 690 ret = usb_autoresume_device(dev); 691 if (ret) 692 + goto out_unlock_device; 693 694 ps->dev = dev; 695 ps->file = file; 696 spin_lock_init(&ps->lock); ··· 702 smp_wmb(); 703 list_add_tail(&ps->list, &dev->filelist); 704 file->private_data = ps; 705 + usb_unlock_device(dev); 706 snoop(&dev->dev, "opened by process %d: %s\n", task_pid_nr(current), 707 current->comm); 708 + return ret; 709 + 710 + out_unlock_device: 711 + usb_unlock_device(dev); 712 + usb_put_dev(dev); 713 + out_free_ps: 714 + kfree(ps); 715 return ret; 716 } 717 ··· 724 usb_lock_device(dev); 725 usb_hub_release_all_ports(dev, ps); 726 727 list_del_init(&ps->list); 728 729 for (ifnum = 0; ps->ifclaimed && ifnum < 8*sizeof(ps->ifclaimed); 730 ifnum++) { ··· 770 if (!tbuf) 771 return -ENOMEM; 772 tmo = ctrl.timeout; 773 + snoop(&dev->dev, "control urb: bRequestType=%02x " 774 + "bRequest=%02x wValue=%04x " 775 + "wIndex=%04x wLength=%04x\n", 776 + ctrl.bRequestType, ctrl.bRequest, 777 + __le16_to_cpup(&ctrl.wValue), 778 + __le16_to_cpup(&ctrl.wIndex), 779 + __le16_to_cpup(&ctrl.wLength)); 780 if (ctrl.bRequestType & 0x80) { 781 if (ctrl.wLength && !access_ok(VERIFY_WRITE, ctrl.data, 782 ctrl.wLength)) { ··· 777 return -EINVAL; 778 } 779 pipe = usb_rcvctrlpipe(dev, 0); 780 + snoop_urb(dev, NULL, pipe, ctrl.wLength, tmo, SUBMIT, NULL, 0); 781 782 usb_unlock_device(dev); 783 i = usb_control_msg(dev, pipe, ctrl.bRequest, 784 ctrl.bRequestType, ctrl.wValue, ctrl.wIndex, 785 tbuf, ctrl.wLength, tmo); 786 usb_lock_device(dev); 787 + snoop_urb(dev, NULL, pipe, max(i, 0), min(i, 0), COMPLETE, 788 + tbuf, i); 789 if ((i > 0) && ctrl.wLength) { 790 if (copy_to_user(ctrl.data, tbuf, i)) { 791 free_page((unsigned long)tbuf); ··· 800 } 801 } 802 pipe = usb_sndctrlpipe(dev, 0); 803 + snoop_urb(dev, NULL, pipe, ctrl.wLength, tmo, SUBMIT, 804 + tbuf, ctrl.wLength); 805 806 usb_unlock_device(dev); 807 i = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), ctrl.bRequest, 808 ctrl.bRequestType, ctrl.wValue, ctrl.wIndex, 809 tbuf, ctrl.wLength, tmo); 810 usb_lock_device(dev); 811 + snoop_urb(dev, NULL, pipe, max(i, 0), min(i, 0), COMPLETE, NULL, 0); 812 } 813 free_page((unsigned long)tbuf); 814 if (i < 0 && i != -EPIPE) { ··· 853 kfree(tbuf); 854 return -EINVAL; 855 } 856 + snoop_urb(dev, NULL, pipe, len1, tmo, SUBMIT, NULL, 0); 857 858 usb_unlock_device(dev); 859 i = usb_bulk_msg(dev, pipe, tbuf, len1, &len2, tmo); 860 usb_lock_device(dev); 861 + snoop_urb(dev, NULL, pipe, len2, i, COMPLETE, tbuf, len2); 862 863 if (!i && len2) { 864 if (copy_to_user(bulk.data, tbuf, len2)) { ··· 873 return -EFAULT; 874 } 875 } 876 + snoop_urb(dev, NULL, pipe, len1, tmo, SUBMIT, tbuf, len1); 877 878 usb_unlock_device(dev); 879 i = usb_bulk_msg(dev, pipe, tbuf, len1, &len2, tmo); 880 usb_lock_device(dev); 881 + snoop_urb(dev, NULL, pipe, len2, i, COMPLETE, NULL, 0); 882 } 883 kfree(tbuf); 884 if (i < 0) ··· 1097 is_in = 0; 1098 uurb->endpoint &= ~USB_DIR_IN; 1099 } 1100 + snoop(&ps->dev->dev, "control urb: bRequestType=%02x " 1101 + "bRequest=%02x wValue=%04x " 1102 + "wIndex=%04x wLength=%04x\n", 1103 + dr->bRequestType, dr->bRequest, 1104 + __le16_to_cpup(&dr->wValue), 1105 + __le16_to_cpup(&dr->wIndex), 1106 + __le16_to_cpup(&dr->wLength)); 1107 break; 1108 1109 case USBDEVFS_URB_TYPE_BULK: ··· 1104 case USB_ENDPOINT_XFER_CONTROL: 1105 case USB_ENDPOINT_XFER_ISOC: 1106 return -EINVAL; 1107 + case USB_ENDPOINT_XFER_INT: 1108 + /* allow single-shot interrupt transfers */ 1109 + uurb->type = USBDEVFS_URB_TYPE_INTERRUPT; 1110 + goto interrupt_urb; 1111 } 1112 + uurb->number_of_packets = 0; 1113 + if (uurb->buffer_length > MAX_USBFS_BUFFER_SIZE) 1114 + return -EINVAL; 1115 + break; 1116 + 1117 + case USBDEVFS_URB_TYPE_INTERRUPT: 1118 + if (!usb_endpoint_xfer_int(&ep->desc)) 1119 + return -EINVAL; 1120 + interrupt_urb: 1121 uurb->number_of_packets = 0; 1122 if (uurb->buffer_length > MAX_USBFS_BUFFER_SIZE) 1123 return -EINVAL; ··· 1141 return -EINVAL; 1142 } 1143 uurb->buffer_length = totlen; 1144 break; 1145 1146 default: ··· 1236 } 1237 } 1238 snoop_urb(ps->dev, as->userurb, as->urb->pipe, 1239 + as->urb->transfer_buffer_length, 0, SUBMIT, 1240 + is_in ? NULL : as->urb->transfer_buffer, 1241 + uurb->buffer_length); 1242 async_newpending(as); 1243 1244 if (usb_endpoint_xfer_bulk(&ep->desc)) { ··· 1274 dev_printk(KERN_DEBUG, &ps->dev->dev, 1275 "usbfs: usb_submit_urb returned %d\n", ret); 1276 snoop_urb(ps->dev, as->userurb, as->urb->pipe, 1277 + 0, ret, COMPLETE, NULL, 0); 1278 async_removepending(as); 1279 free_async(as); 1280 return ret; ··· 1628 if (driver == NULL || driver->ioctl == NULL) { 1629 retval = -ENOTTY; 1630 } else { 1631 + /* keep API that guarantees BKL */ 1632 + lock_kernel(); 1633 retval = driver->ioctl(intf, ctl->ioctl_code, buf); 1634 + unlock_kernel(); 1635 if (retval == -ENOIOCTLCMD) 1636 retval = -ENOTTY; 1637 } ··· 1711 1712 if (!(file->f_mode & FMODE_WRITE)) 1713 return -EPERM; 1714 + 1715 usb_lock_device(dev); 1716 if (!connected(ps)) { 1717 usb_unlock_device(dev); ··· 1877 { 1878 int ret; 1879 1880 ret = usbdev_do_ioctl(file, cmd, (void __user *)arg); 1881 1882 return ret; 1883 } ··· 1890 { 1891 int ret; 1892 1893 ret = usbdev_do_ioctl(file, cmd, compat_ptr(arg)); 1894 1895 return ret; 1896 }
+428 -498
drivers/usb/core/driver.c
··· 25 #include <linux/device.h> 26 #include <linux/usb.h> 27 #include <linux/usb/quirks.h> 28 - #include <linux/workqueue.h> 29 #include "hcd.h" 30 #include "usb.h" 31 ··· 221 { 222 struct usb_device_driver *udriver = to_usb_device_driver(dev->driver); 223 struct usb_device *udev = to_usb_device(dev); 224 - int error = -ENODEV; 225 226 dev_dbg(dev, "%s\n", __func__); 227 ··· 230 /* The device should always appear to be in use 231 * unless the driver suports autosuspend. 232 */ 233 - udev->pm_usage_cnt = !(udriver->supports_autosuspend); 234 235 - error = udriver->probe(udev); 236 return error; 237 } 238 239 /* called from driver core with dev locked */ 240 static int usb_unbind_device(struct device *dev) 241 { 242 struct usb_device_driver *udriver = to_usb_device_driver(dev->driver); 243 244 - udriver->disconnect(to_usb_device(dev)); 245 return 0; 246 } 247 ··· 279 intf->needs_binding = 0; 280 281 if (usb_device_is_owned(udev)) 282 - return -ENODEV; 283 284 if (udev->authorized == 0) { 285 dev_err(&intf->dev, "Device is not authorized for usage\n"); 286 - return -ENODEV; 287 } 288 289 id = usb_match_id(intf, driver->id_table); 290 if (!id) 291 id = usb_match_dynamic_id(intf, driver); 292 - if (id) { 293 - dev_dbg(dev, "%s - got id\n", __func__); 294 295 - error = usb_autoresume_device(udev); 296 - if (error) 297 - return error; 298 299 - /* Interface "power state" doesn't correspond to any hardware 300 - * state whatsoever. We use it to record when it's bound to 301 - * a driver that may start I/0: it's not frozen/quiesced. 302 - */ 303 - mark_active(intf); 304 - intf->condition = USB_INTERFACE_BINDING; 305 306 - /* The interface should always appear to be in use 307 - * unless the driver suports autosuspend. 308 - */ 309 - atomic_set(&intf->pm_usage_cnt, !driver->supports_autosuspend); 310 311 - /* Carry out a deferred switch to altsetting 0 */ 312 - if (intf->needs_altsetting0) { 313 - error = usb_set_interface(udev, intf->altsetting[0]. 314 - desc.bInterfaceNumber, 0); 315 - if (error < 0) 316 - goto err; 317 318 - intf->needs_altsetting0 = 0; 319 - } 320 - 321 - error = driver->probe(intf, id); 322 - if (error) 323 goto err; 324 - 325 - intf->condition = USB_INTERFACE_BOUND; 326 - usb_autosuspend_device(udev); 327 } 328 329 return error; 330 331 - err: 332 - mark_quiesced(intf); 333 intf->needs_remote_wakeup = 0; 334 intf->condition = USB_INTERFACE_UNBOUND; 335 usb_cancel_queued_reset(intf); 336 usb_autosuspend_device(udev); 337 return error; 338 } ··· 384 usb_set_intfdata(intf, NULL); 385 386 intf->condition = USB_INTERFACE_UNBOUND; 387 - mark_quiesced(intf); 388 intf->needs_remote_wakeup = 0; 389 390 if (!error) 391 usb_autosuspend_device(udev); ··· 425 struct usb_interface *iface, void *priv) 426 { 427 struct device *dev = &iface->dev; 428 - struct usb_device *udev = interface_to_usbdev(iface); 429 int retval = 0; 430 431 if (dev->driver) ··· 434 usb_set_intfdata(iface, priv); 435 iface->needs_binding = 0; 436 437 - usb_pm_lock(udev); 438 iface->condition = USB_INTERFACE_BOUND; 439 - mark_active(iface); 440 - atomic_set(&iface->pm_usage_cnt, !driver->supports_autosuspend); 441 - usb_pm_unlock(udev); 442 443 /* if interface was already added, bind now; else let 444 * the future device_add() bind it, bypassing probe() ··· 710 { 711 struct usb_device *usb_dev; 712 713 - /* driver is often null here; dev_dbg() would oops */ 714 - pr_debug("usb %s: uevent\n", dev_name(dev)); 715 - 716 if (is_usb_device(dev)) { 717 usb_dev = to_usb_device(dev); 718 } else if (is_usb_interface(dev)) { ··· 721 } 722 723 if (usb_dev->devnum < 0) { 724 pr_debug("usb %s: already deleted?\n", dev_name(dev)); 725 return -ENODEV; 726 } ··· 1000 } 1001 } 1002 1003 - /* Caller has locked udev's pm_mutex */ 1004 static int usb_suspend_device(struct usb_device *udev, pm_message_t msg) 1005 { 1006 struct usb_device_driver *udriver; ··· 1023 return status; 1024 } 1025 1026 - /* Caller has locked udev's pm_mutex */ 1027 static int usb_resume_device(struct usb_device *udev, pm_message_t msg) 1028 { 1029 struct usb_device_driver *udriver; ··· 1056 return status; 1057 } 1058 1059 - /* Caller has locked intf's usb_device's pm mutex */ 1060 static int usb_suspend_interface(struct usb_device *udev, 1061 struct usb_interface *intf, pm_message_t msg) 1062 { 1063 struct usb_driver *driver; 1064 int status = 0; 1065 1066 - /* with no hardware, USB interfaces only use FREEZE and ON states */ 1067 - if (udev->state == USB_STATE_NOTATTACHED || !is_active(intf)) 1068 - goto done; 1069 - 1070 - /* This can happen; see usb_driver_release_interface() */ 1071 - if (intf->condition == USB_INTERFACE_UNBOUND) 1072 goto done; 1073 driver = to_usb_driver(intf->dev.driver); 1074 1075 if (driver->suspend) { 1076 status = driver->suspend(intf, msg); 1077 - if (status == 0) 1078 - mark_quiesced(intf); 1079 - else if (!(msg.event & PM_EVENT_AUTO)) 1080 dev_err(&intf->dev, "%s error %d\n", 1081 "suspend", status); 1082 } else { ··· 1077 intf->needs_binding = 1; 1078 dev_warn(&intf->dev, "no %s for driver %s?\n", 1079 "suspend", driver->name); 1080 - mark_quiesced(intf); 1081 } 1082 1083 done: ··· 1084 return status; 1085 } 1086 1087 - /* Caller has locked intf's usb_device's pm_mutex */ 1088 static int usb_resume_interface(struct usb_device *udev, 1089 struct usb_interface *intf, pm_message_t msg, int reset_resume) 1090 { 1091 struct usb_driver *driver; 1092 int status = 0; 1093 1094 - if (udev->state == USB_STATE_NOTATTACHED || is_active(intf)) 1095 goto done; 1096 1097 /* Don't let autoresume interfere with unbinding */ ··· 1141 1142 done: 1143 dev_vdbg(&intf->dev, "%s: status %d\n", __func__, status); 1144 - if (status == 0 && intf->condition == USB_INTERFACE_BOUND) 1145 - mark_active(intf); 1146 1147 /* Later we will unbind the driver and/or reprobe, if necessary */ 1148 return status; 1149 } 1150 - 1151 - #ifdef CONFIG_USB_SUSPEND 1152 - 1153 - /* Internal routine to check whether we may autosuspend a device. */ 1154 - static int autosuspend_check(struct usb_device *udev, int reschedule) 1155 - { 1156 - int i; 1157 - struct usb_interface *intf; 1158 - unsigned long suspend_time, j; 1159 - 1160 - /* For autosuspend, fail fast if anything is in use or autosuspend 1161 - * is disabled. Also fail if any interfaces require remote wakeup 1162 - * but it isn't available. 1163 - */ 1164 - if (udev->pm_usage_cnt > 0) 1165 - return -EBUSY; 1166 - if (udev->autosuspend_delay < 0 || udev->autosuspend_disabled) 1167 - return -EPERM; 1168 - 1169 - suspend_time = udev->last_busy + udev->autosuspend_delay; 1170 - if (udev->actconfig) { 1171 - for (i = 0; i < udev->actconfig->desc.bNumInterfaces; i++) { 1172 - intf = udev->actconfig->interface[i]; 1173 - if (!is_active(intf)) 1174 - continue; 1175 - if (atomic_read(&intf->pm_usage_cnt) > 0) 1176 - return -EBUSY; 1177 - if (intf->needs_remote_wakeup && 1178 - !udev->do_remote_wakeup) { 1179 - dev_dbg(&udev->dev, "remote wakeup needed " 1180 - "for autosuspend\n"); 1181 - return -EOPNOTSUPP; 1182 - } 1183 - 1184 - /* Don't allow autosuspend if the device will need 1185 - * a reset-resume and any of its interface drivers 1186 - * doesn't include support. 1187 - */ 1188 - if (udev->quirks & USB_QUIRK_RESET_RESUME) { 1189 - struct usb_driver *driver; 1190 - 1191 - driver = to_usb_driver(intf->dev.driver); 1192 - if (!driver->reset_resume || 1193 - intf->needs_remote_wakeup) 1194 - return -EOPNOTSUPP; 1195 - } 1196 - } 1197 - } 1198 - 1199 - /* If everything is okay but the device hasn't been idle for long 1200 - * enough, queue a delayed autosuspend request. If the device 1201 - * _has_ been idle for long enough and the reschedule flag is set, 1202 - * likewise queue a delayed (1 second) autosuspend request. 1203 - */ 1204 - j = jiffies; 1205 - if (time_before(j, suspend_time)) 1206 - reschedule = 1; 1207 - else 1208 - suspend_time = j + HZ; 1209 - if (reschedule) { 1210 - if (!timer_pending(&udev->autosuspend.timer)) { 1211 - queue_delayed_work(ksuspend_usb_wq, &udev->autosuspend, 1212 - round_jiffies_up_relative(suspend_time - j)); 1213 - } 1214 - return -EAGAIN; 1215 - } 1216 - return 0; 1217 - } 1218 - 1219 - #else 1220 - 1221 - static inline int autosuspend_check(struct usb_device *udev, int reschedule) 1222 - { 1223 - return 0; 1224 - } 1225 - 1226 - #endif /* CONFIG_USB_SUSPEND */ 1227 1228 /** 1229 * usb_suspend_both - suspend a USB device and its interfaces ··· 1157 * all the interfaces which were suspended are resumed so that they remain 1158 * in the same state as the device. 1159 * 1160 - * If an autosuspend is in progress the routine checks first to make sure 1161 - * that neither the device itself or any of its active interfaces is in use 1162 - * (pm_usage_cnt is greater than 0). If they are, the autosuspend fails. 1163 - * 1164 - * If the suspend succeeds, the routine recursively queues an autosuspend 1165 - * request for @udev's parent device, thereby propagating the change up 1166 - * the device tree. If all of the parent's children are now suspended, 1167 - * the parent will autosuspend in turn. 1168 - * 1169 - * The suspend method calls are subject to mutual exclusion under control 1170 - * of @udev's pm_mutex. Many of these calls are also under the protection 1171 - * of @udev's device lock (including all requests originating outside the 1172 - * USB subsystem), but autosuspend requests generated by a child device or 1173 - * interface driver may not be. Usbcore will insure that the method calls 1174 - * do not arrive during bind, unbind, or reset operations. However, drivers 1175 - * must be prepared to handle suspend calls arriving at unpredictable times. 1176 - * The only way to block such calls is to do an autoresume (preventing 1177 - * autosuspends) while holding @udev's device lock (preventing outside 1178 - * suspends). 1179 - * 1180 - * The caller must hold @udev->pm_mutex. 1181 * 1182 * This routine can run only in process context. 1183 */ ··· 1171 int status = 0; 1172 int i = 0; 1173 struct usb_interface *intf; 1174 - struct usb_device *parent = udev->parent; 1175 1176 if (udev->state == USB_STATE_NOTATTACHED || 1177 udev->state == USB_STATE_SUSPENDED) 1178 goto done; 1179 - 1180 - udev->do_remote_wakeup = device_may_wakeup(&udev->dev); 1181 - 1182 - if (msg.event & PM_EVENT_AUTO) { 1183 - status = autosuspend_check(udev, 0); 1184 - if (status < 0) 1185 - goto done; 1186 - } 1187 1188 /* Suspend all the interfaces and then udev itself */ 1189 if (udev->actconfig) { ··· 1190 1191 /* If the suspend failed, resume interfaces that did get suspended */ 1192 if (status != 0) { 1193 - pm_message_t msg2; 1194 - 1195 - msg2.event = msg.event ^ (PM_EVENT_SUSPEND | PM_EVENT_RESUME); 1196 while (--i >= 0) { 1197 intf = udev->actconfig->interface[i]; 1198 - usb_resume_interface(udev, intf, msg2, 0); 1199 } 1200 1201 - /* Try another autosuspend when the interfaces aren't busy */ 1202 - if (msg.event & PM_EVENT_AUTO) 1203 - autosuspend_check(udev, status == -EBUSY); 1204 - 1205 - /* If the suspend succeeded then prevent any more URB submissions, 1206 - * flush any outstanding URBs, and propagate the suspend up the tree. 1207 */ 1208 } else { 1209 - cancel_delayed_work(&udev->autosuspend); 1210 udev->can_submit = 0; 1211 for (i = 0; i < 16; ++i) { 1212 usb_hcd_flush_endpoint(udev, udev->ep_out[i]); 1213 usb_hcd_flush_endpoint(udev, udev->ep_in[i]); 1214 } 1215 - 1216 - /* If this is just a FREEZE or a PRETHAW, udev might 1217 - * not really be suspended. Only true suspends get 1218 - * propagated up the device tree. 1219 - */ 1220 - if (parent && udev->state == USB_STATE_SUSPENDED) 1221 - usb_autosuspend_device(parent); 1222 } 1223 1224 done: ··· 1221 * the resume method for @udev and then calls the resume methods for all 1222 * the interface drivers in @udev. 1223 * 1224 - * Before starting the resume, the routine calls itself recursively for 1225 - * the parent device of @udev, thereby propagating the change up the device 1226 - * tree and assuring that @udev will be able to resume. If the parent is 1227 - * unable to resume successfully, the routine fails. 1228 - * 1229 - * The resume method calls are subject to mutual exclusion under control 1230 - * of @udev's pm_mutex. Many of these calls are also under the protection 1231 - * of @udev's device lock (including all requests originating outside the 1232 - * USB subsystem), but autoresume requests generated by a child device or 1233 - * interface driver may not be. Usbcore will insure that the method calls 1234 - * do not arrive during bind, unbind, or reset operations. However, drivers 1235 - * must be prepared to handle resume calls arriving at unpredictable times. 1236 - * The only way to block such calls is to do an autoresume (preventing 1237 - * other autoresumes) while holding @udev's device lock (preventing outside 1238 - * resumes). 1239 - * 1240 - * The caller must hold @udev->pm_mutex. 1241 * 1242 * This routine can run only in process context. 1243 */ ··· 1235 int status = 0; 1236 int i; 1237 struct usb_interface *intf; 1238 - struct usb_device *parent = udev->parent; 1239 1240 - cancel_delayed_work(&udev->autosuspend); 1241 if (udev->state == USB_STATE_NOTATTACHED) { 1242 status = -ENODEV; 1243 goto done; 1244 } 1245 udev->can_submit = 1; 1246 1247 - /* Propagate the resume up the tree, if necessary */ 1248 - if (udev->state == USB_STATE_SUSPENDED) { 1249 - if (parent) { 1250 - status = usb_autoresume_device(parent); 1251 - if (status == 0) { 1252 - status = usb_resume_device(udev, msg); 1253 - if (status || udev->state == 1254 - USB_STATE_NOTATTACHED) { 1255 - usb_autosuspend_device(parent); 1256 - 1257 - /* It's possible usb_resume_device() 1258 - * failed after the port was 1259 - * unsuspended, causing udev to be 1260 - * logically disconnected. We don't 1261 - * want usb_disconnect() to autosuspend 1262 - * the parent again, so tell it that 1263 - * udev disconnected while still 1264 - * suspended. */ 1265 - if (udev->state == 1266 - USB_STATE_NOTATTACHED) 1267 - udev->discon_suspended = 1; 1268 - } 1269 - } 1270 - } else { 1271 - 1272 - /* We can't progagate beyond the USB subsystem, 1273 - * so if a root hub's controller is suspended 1274 - * then we're stuck. */ 1275 - status = usb_resume_device(udev, msg); 1276 - } 1277 - } else if (udev->reset_resume) 1278 status = usb_resume_device(udev, msg); 1279 1280 if (status == 0 && udev->actconfig) { 1281 for (i = 0; i < udev->actconfig->desc.bNumInterfaces; i++) { 1282 intf = udev->actconfig->interface[i]; ··· 1262 return status; 1263 } 1264 1265 - #ifdef CONFIG_USB_SUSPEND 1266 - 1267 - /* Internal routine to adjust a device's usage counter and change 1268 - * its autosuspend state. 1269 - */ 1270 - static int usb_autopm_do_device(struct usb_device *udev, int inc_usage_cnt) 1271 { 1272 - int status = 0; 1273 1274 - usb_pm_lock(udev); 1275 - udev->pm_usage_cnt += inc_usage_cnt; 1276 - WARN_ON(udev->pm_usage_cnt < 0); 1277 - if (inc_usage_cnt) 1278 - udev->last_busy = jiffies; 1279 - if (inc_usage_cnt >= 0 && udev->pm_usage_cnt > 0) { 1280 - if (udev->state == USB_STATE_SUSPENDED) 1281 - status = usb_resume_both(udev, PMSG_AUTO_RESUME); 1282 - if (status != 0) 1283 - udev->pm_usage_cnt -= inc_usage_cnt; 1284 - else if (inc_usage_cnt) 1285 udev->last_busy = jiffies; 1286 - } else if (inc_usage_cnt <= 0 && udev->pm_usage_cnt <= 0) { 1287 - status = usb_suspend_both(udev, PMSG_AUTO_SUSPEND); 1288 } 1289 - usb_pm_unlock(udev); 1290 return status; 1291 } 1292 1293 - /* usb_autosuspend_work - callback routine to autosuspend a USB device */ 1294 - void usb_autosuspend_work(struct work_struct *work) 1295 { 1296 - struct usb_device *udev = 1297 - container_of(work, struct usb_device, autosuspend.work); 1298 - 1299 - usb_autopm_do_device(udev, 0); 1300 } 1301 1302 - /* usb_autoresume_work - callback routine to autoresume a USB device */ 1303 - void usb_autoresume_work(struct work_struct *work) 1304 { 1305 - struct usb_device *udev = 1306 - container_of(work, struct usb_device, autoresume); 1307 1308 - /* Wake it up, let the drivers do their thing, and then put it 1309 - * back to sleep. 1310 - */ 1311 - if (usb_autopm_do_device(udev, 1) == 0) 1312 - usb_autopm_do_device(udev, -1); 1313 } 1314 1315 /** 1316 * usb_autosuspend_device - delayed autosuspend of a USB device and its interfaces ··· 1359 * @udev and wants to allow it to autosuspend. Examples would be when 1360 * @udev's device file in usbfs is closed or after a configuration change. 1361 * 1362 - * @udev's usage counter is decremented. If it or any of the usage counters 1363 - * for an active interface is greater than 0, no autosuspend request will be 1364 - * queued. (If an interface driver does not support autosuspend then its 1365 - * usage counter is permanently positive.) Furthermore, if an interface 1366 - * driver requires remote-wakeup capability during autosuspend but remote 1367 - * wakeup is disabled, the autosuspend will fail. 1368 * 1369 - * Often the caller will hold @udev's device lock, but this is not 1370 - * necessary. 1371 * 1372 * This routine can run only in process context. 1373 */ ··· 1371 { 1372 int status; 1373 1374 - status = usb_autopm_do_device(udev, -1); 1375 - dev_vdbg(&udev->dev, "%s: cnt %d\n", 1376 - __func__, udev->pm_usage_cnt); 1377 } 1378 1379 /** ··· 1385 * This routine should be called when a core subsystem thinks @udev may 1386 * be ready to autosuspend. 1387 * 1388 - * @udev's usage counter left unchanged. If it or any of the usage counters 1389 - * for an active interface is greater than 0, or autosuspend is not allowed 1390 - * for any other reason, no autosuspend request will be queued. 1391 * 1392 * This routine can run only in process context. 1393 */ 1394 void usb_try_autosuspend_device(struct usb_device *udev) 1395 { 1396 - usb_autopm_do_device(udev, 0); 1397 - dev_vdbg(&udev->dev, "%s: cnt %d\n", 1398 - __func__, udev->pm_usage_cnt); 1399 } 1400 1401 /** ··· 1409 * 1410 * This routine should be called when a core subsystem wants to use @udev 1411 * and needs to guarantee that it is not suspended. No autosuspend will 1412 - * occur until usb_autosuspend_device is called. (Note that this will not 1413 - * prevent suspend events originating in the PM core.) Examples would be 1414 - * when @udev's device file in usbfs is opened or when a remote-wakeup 1415 * request is received. 1416 * 1417 * @udev's usage counter is incremented to prevent subsequent autosuspends. 1418 * However if the autoresume fails then the usage counter is re-decremented. 1419 * 1420 - * Often the caller will hold @udev's device lock, but this is not 1421 - * necessary (and attempting it might cause deadlock). 1422 * 1423 * This routine can run only in process context. 1424 */ ··· 1425 { 1426 int status; 1427 1428 - status = usb_autopm_do_device(udev, 1); 1429 - dev_vdbg(&udev->dev, "%s: status %d cnt %d\n", 1430 - __func__, status, udev->pm_usage_cnt); 1431 - return status; 1432 - } 1433 - 1434 - /* Internal routine to adjust an interface's usage counter and change 1435 - * its device's autosuspend state. 1436 - */ 1437 - static int usb_autopm_do_interface(struct usb_interface *intf, 1438 - int inc_usage_cnt) 1439 - { 1440 - struct usb_device *udev = interface_to_usbdev(intf); 1441 - int status = 0; 1442 - 1443 - usb_pm_lock(udev); 1444 - if (intf->condition == USB_INTERFACE_UNBOUND) 1445 - status = -ENODEV; 1446 - else { 1447 - atomic_add(inc_usage_cnt, &intf->pm_usage_cnt); 1448 - udev->last_busy = jiffies; 1449 - if (inc_usage_cnt >= 0 && 1450 - atomic_read(&intf->pm_usage_cnt) > 0) { 1451 - if (udev->state == USB_STATE_SUSPENDED) 1452 - status = usb_resume_both(udev, 1453 - PMSG_AUTO_RESUME); 1454 - if (status != 0) 1455 - atomic_sub(inc_usage_cnt, &intf->pm_usage_cnt); 1456 - else 1457 - udev->last_busy = jiffies; 1458 - } else if (inc_usage_cnt <= 0 && 1459 - atomic_read(&intf->pm_usage_cnt) <= 0) { 1460 - status = usb_suspend_both(udev, PMSG_AUTO_SUSPEND); 1461 - } 1462 - } 1463 - usb_pm_unlock(udev); 1464 return status; 1465 } 1466 ··· 1446 * closed. 1447 * 1448 * The routine decrements @intf's usage counter. When the counter reaches 1449 - * 0, a delayed autosuspend request for @intf's device is queued. When 1450 - * the delay expires, if @intf->pm_usage_cnt is still <= 0 along with all 1451 - * the other usage counters for the sibling interfaces and @intf's 1452 - * usb_device, the device and all its interfaces will be autosuspended. 1453 - * 1454 - * Note that @intf->pm_usage_cnt is owned by the interface driver. The 1455 - * core will not change its value other than the increment and decrement 1456 - * in usb_autopm_get_interface and usb_autopm_put_interface. The driver 1457 - * may use this simple counter-oriented discipline or may set the value 1458 - * any way it likes. 1459 * 1460 * If the driver has set @intf->needs_remote_wakeup then autosuspend will 1461 * take place only if the device's remote-wakeup facility is enabled. 1462 - * 1463 - * Suspend method calls queued by this routine can arrive at any time 1464 - * while @intf is resumed and its usage counter is equal to 0. They are 1465 - * not protected by the usb_device's lock but only by its pm_mutex. 1466 - * Drivers must provide their own synchronization. 1467 * 1468 * This routine can run only in process context. 1469 */ 1470 void usb_autopm_put_interface(struct usb_interface *intf) 1471 { 1472 - int status; 1473 1474 - status = usb_autopm_do_interface(intf, -1); 1475 - dev_vdbg(&intf->dev, "%s: status %d cnt %d\n", 1476 - __func__, status, atomic_read(&intf->pm_usage_cnt)); 1477 } 1478 EXPORT_SYMBOL_GPL(usb_autopm_put_interface); 1479 ··· 1472 * usb_autopm_put_interface_async - decrement a USB interface's PM-usage counter 1473 * @intf: the usb_interface whose counter should be decremented 1474 * 1475 - * This routine does essentially the same thing as 1476 - * usb_autopm_put_interface(): it decrements @intf's usage counter and 1477 - * queues a delayed autosuspend request if the counter is <= 0. The 1478 - * difference is that it does not acquire the device's pm_mutex; 1479 - * callers must handle all synchronization issues themselves. 1480 * 1481 * Typically a driver would call this routine during an URB's completion 1482 * handler, if no more URBs were pending. ··· 1486 void usb_autopm_put_interface_async(struct usb_interface *intf) 1487 { 1488 struct usb_device *udev = interface_to_usbdev(intf); 1489 int status = 0; 1490 1491 - if (intf->condition == USB_INTERFACE_UNBOUND) { 1492 - status = -ENODEV; 1493 - } else { 1494 - udev->last_busy = jiffies; 1495 - atomic_dec(&intf->pm_usage_cnt); 1496 - if (udev->autosuspend_disabled || udev->autosuspend_delay < 0) 1497 - status = -EPERM; 1498 - else if (atomic_read(&intf->pm_usage_cnt) <= 0 && 1499 - !timer_pending(&udev->autosuspend.timer)) { 1500 - queue_delayed_work(ksuspend_usb_wq, &udev->autosuspend, 1501 round_jiffies_up_relative( 1502 - udev->autosuspend_delay)); 1503 } 1504 } 1505 - dev_vdbg(&intf->dev, "%s: status %d cnt %d\n", 1506 - __func__, status, atomic_read(&intf->pm_usage_cnt)); 1507 } 1508 EXPORT_SYMBOL_GPL(usb_autopm_put_interface_async); 1509 1510 /** 1511 * usb_autopm_get_interface - increment a USB interface's PM-usage counter ··· 1549 * or @intf is unbound. A typical example would be a character-device 1550 * driver when its device file is opened. 1551 * 1552 - * 1553 - * The routine increments @intf's usage counter. (However if the 1554 - * autoresume fails then the counter is re-decremented.) So long as the 1555 - * counter is greater than 0, autosuspend will not be allowed for @intf 1556 - * or its usb_device. When the driver is finished using @intf it should 1557 - * call usb_autopm_put_interface() to decrement the usage counter and 1558 - * queue a delayed autosuspend request (if the counter is <= 0). 1559 - * 1560 - * 1561 - * Note that @intf->pm_usage_cnt is owned by the interface driver. The 1562 - * core will not change its value other than the increment and decrement 1563 - * in usb_autopm_get_interface and usb_autopm_put_interface. The driver 1564 - * may use this simple counter-oriented discipline or may set the value 1565 - * any way it likes. 1566 - * 1567 - * Resume method calls generated by this routine can arrive at any time 1568 - * while @intf is suspended. They are not protected by the usb_device's 1569 - * lock but only by its pm_mutex. Drivers must provide their own 1570 - * synchronization. 1571 * 1572 * This routine can run only in process context. 1573 */ ··· 1558 { 1559 int status; 1560 1561 - status = usb_autopm_do_interface(intf, 1); 1562 - dev_vdbg(&intf->dev, "%s: status %d cnt %d\n", 1563 - __func__, status, atomic_read(&intf->pm_usage_cnt)); 1564 return status; 1565 } 1566 EXPORT_SYMBOL_GPL(usb_autopm_get_interface); ··· 1577 * @intf: the usb_interface whose counter should be incremented 1578 * 1579 * This routine does much the same thing as 1580 - * usb_autopm_get_interface(): it increments @intf's usage counter and 1581 - * queues an autoresume request if the result is > 0. The differences 1582 - * are that it does not acquire the device's pm_mutex (callers must 1583 - * handle all synchronization issues themselves), and it does not 1584 - * autoresume the device directly (it only queues a request). After a 1585 - * successful call, the device will generally not yet be resumed. 1586 * 1587 * This routine can run in atomic context. 1588 */ 1589 int usb_autopm_get_interface_async(struct usb_interface *intf) 1590 { 1591 - struct usb_device *udev = interface_to_usbdev(intf); 1592 - int status = 0; 1593 1594 - if (intf->condition == USB_INTERFACE_UNBOUND) 1595 - status = -ENODEV; 1596 - else { 1597 atomic_inc(&intf->pm_usage_cnt); 1598 - if (atomic_read(&intf->pm_usage_cnt) > 0 && 1599 - udev->state == USB_STATE_SUSPENDED) 1600 - queue_work(ksuspend_usb_wq, &udev->autoresume); 1601 - } 1602 - dev_vdbg(&intf->dev, "%s: status %d cnt %d\n", 1603 - __func__, status, atomic_read(&intf->pm_usage_cnt)); 1604 return status; 1605 } 1606 EXPORT_SYMBOL_GPL(usb_autopm_get_interface_async); 1607 1608 - #else 1609 - 1610 - void usb_autosuspend_work(struct work_struct *work) 1611 - {} 1612 - 1613 - void usb_autoresume_work(struct work_struct *work) 1614 - {} 1615 - 1616 - #endif /* CONFIG_USB_SUSPEND */ 1617 - 1618 /** 1619 - * usb_external_suspend_device - external suspend of a USB device and its interfaces 1620 - * @udev: the usb_device to suspend 1621 - * @msg: Power Management message describing this state transition 1622 * 1623 - * This routine handles external suspend requests: ones not generated 1624 - * internally by a USB driver (autosuspend) but rather coming from the user 1625 - * (via sysfs) or the PM core (system sleep). The suspend will be carried 1626 - * out regardless of @udev's usage counter or those of its interfaces, 1627 - * and regardless of whether or not remote wakeup is enabled. Of course, 1628 - * interface drivers still have the option of failing the suspend (if 1629 - * there are unsuspended children, for example). 1630 * 1631 - * The caller must hold @udev's device lock. 1632 */ 1633 - int usb_external_suspend_device(struct usb_device *udev, pm_message_t msg) 1634 { 1635 - int status; 1636 1637 - do_unbind_rebind(udev, DO_UNBIND); 1638 - usb_pm_lock(udev); 1639 - status = usb_suspend_both(udev, msg); 1640 - usb_pm_unlock(udev); 1641 - return status; 1642 - } 1643 - 1644 - /** 1645 - * usb_external_resume_device - external resume of a USB device and its interfaces 1646 - * @udev: the usb_device to resume 1647 - * @msg: Power Management message describing this state transition 1648 - * 1649 - * This routine handles external resume requests: ones not generated 1650 - * internally by a USB driver (autoresume) but rather coming from the user 1651 - * (via sysfs), the PM core (system resume), or the device itself (remote 1652 - * wakeup). @udev's usage counter is unaffected. 1653 - * 1654 - * The caller must hold @udev's device lock. 1655 - */ 1656 - int usb_external_resume_device(struct usb_device *udev, pm_message_t msg) 1657 - { 1658 - int status; 1659 - 1660 - usb_pm_lock(udev); 1661 - status = usb_resume_both(udev, msg); 1662 udev->last_busy = jiffies; 1663 - usb_pm_unlock(udev); 1664 - if (status == 0) 1665 - do_unbind_rebind(udev, DO_REBIND); 1666 - 1667 - /* Now that the device is awake, we can start trying to autosuspend 1668 - * it again. */ 1669 - if (status == 0) 1670 - usb_try_autosuspend_device(udev); 1671 - return status; 1672 } 1673 1674 - int usb_suspend(struct device *dev, pm_message_t msg) 1675 { 1676 - struct usb_device *udev; 1677 1678 - udev = to_usb_device(dev); 1679 - 1680 - /* If udev is already suspended, we can skip this suspend and 1681 - * we should also skip the upcoming system resume. High-speed 1682 - * root hubs are an exception; they need to resume whenever the 1683 - * system wakes up in order for USB-PERSIST port handover to work 1684 - * properly. 1685 */ 1686 - if (udev->state == USB_STATE_SUSPENDED) { 1687 - if (udev->parent || udev->speed != USB_SPEED_HIGH) 1688 - udev->skip_sys_resume = 1; 1689 - return 0; 1690 } 1691 1692 - udev->skip_sys_resume = 0; 1693 - return usb_external_suspend_device(udev, msg); 1694 } 1695 1696 - int usb_resume(struct device *dev, pm_message_t msg) 1697 { 1698 - struct usb_device *udev; 1699 - int status; 1700 1701 - udev = to_usb_device(dev); 1702 - 1703 - /* If udev->skip_sys_resume is set then udev was already suspended 1704 - * when the system sleep started, so we don't want to resume it 1705 - * during this system wakeup. 1706 */ 1707 - if (udev->skip_sys_resume) 1708 - return 0; 1709 - status = usb_external_resume_device(udev, msg); 1710 1711 - /* Avoid PM error messages for devices disconnected while suspended 1712 - * as we'll display regular disconnect messages just a bit later. 1713 - */ 1714 - if (status == -ENODEV) 1715 - return 0; 1716 return status; 1717 } 1718 1719 - #endif /* CONFIG_PM */ 1720 1721 struct bus_type usb_bus_type = { 1722 .name = "usb", 1723 .match = usb_device_match, 1724 .uevent = usb_uevent, 1725 };
··· 25 #include <linux/device.h> 26 #include <linux/usb.h> 27 #include <linux/usb/quirks.h> 28 + #include <linux/pm_runtime.h> 29 #include "hcd.h" 30 #include "usb.h" 31 ··· 221 { 222 struct usb_device_driver *udriver = to_usb_device_driver(dev->driver); 223 struct usb_device *udev = to_usb_device(dev); 224 + int error = 0; 225 226 dev_dbg(dev, "%s\n", __func__); 227 ··· 230 /* The device should always appear to be in use 231 * unless the driver suports autosuspend. 232 */ 233 + if (!udriver->supports_autosuspend) 234 + error = usb_autoresume_device(udev); 235 236 + if (!error) 237 + error = udriver->probe(udev); 238 return error; 239 } 240 241 /* called from driver core with dev locked */ 242 static int usb_unbind_device(struct device *dev) 243 { 244 + struct usb_device *udev = to_usb_device(dev); 245 struct usb_device_driver *udriver = to_usb_device_driver(dev->driver); 246 247 + udriver->disconnect(udev); 248 + if (!udriver->supports_autosuspend) 249 + usb_autosuspend_device(udev); 250 return 0; 251 } 252 ··· 274 intf->needs_binding = 0; 275 276 if (usb_device_is_owned(udev)) 277 + return error; 278 279 if (udev->authorized == 0) { 280 dev_err(&intf->dev, "Device is not authorized for usage\n"); 281 + return error; 282 } 283 284 id = usb_match_id(intf, driver->id_table); 285 if (!id) 286 id = usb_match_dynamic_id(intf, driver); 287 + if (!id) 288 + return error; 289 290 + dev_dbg(dev, "%s - got id\n", __func__); 291 292 + error = usb_autoresume_device(udev); 293 + if (error) 294 + return error; 295 296 + intf->condition = USB_INTERFACE_BINDING; 297 298 + /* Bound interfaces are initially active. They are 299 + * runtime-PM-enabled only if the driver has autosuspend support. 300 + * They are sensitive to their children's power states. 301 + */ 302 + pm_runtime_set_active(dev); 303 + pm_suspend_ignore_children(dev, false); 304 + if (driver->supports_autosuspend) 305 + pm_runtime_enable(dev); 306 307 + /* Carry out a deferred switch to altsetting 0 */ 308 + if (intf->needs_altsetting0) { 309 + error = usb_set_interface(udev, intf->altsetting[0]. 310 + desc.bInterfaceNumber, 0); 311 + if (error < 0) 312 goto err; 313 + intf->needs_altsetting0 = 0; 314 } 315 316 + error = driver->probe(intf, id); 317 + if (error) 318 + goto err; 319 + 320 + intf->condition = USB_INTERFACE_BOUND; 321 + usb_autosuspend_device(udev); 322 return error; 323 324 + err: 325 intf->needs_remote_wakeup = 0; 326 intf->condition = USB_INTERFACE_UNBOUND; 327 usb_cancel_queued_reset(intf); 328 + 329 + /* Unbound interfaces are always runtime-PM-disabled and -suspended */ 330 + pm_runtime_disable(dev); 331 + pm_runtime_set_suspended(dev); 332 + 333 usb_autosuspend_device(udev); 334 return error; 335 } ··· 377 usb_set_intfdata(intf, NULL); 378 379 intf->condition = USB_INTERFACE_UNBOUND; 380 intf->needs_remote_wakeup = 0; 381 + 382 + /* Unbound interfaces are always runtime-PM-disabled and -suspended */ 383 + pm_runtime_disable(dev); 384 + pm_runtime_set_suspended(dev); 385 + 386 + /* Undo any residual pm_autopm_get_interface_* calls */ 387 + for (r = atomic_read(&intf->pm_usage_cnt); r > 0; --r) 388 + usb_autopm_put_interface_no_suspend(intf); 389 + atomic_set(&intf->pm_usage_cnt, 0); 390 391 if (!error) 392 usb_autosuspend_device(udev); ··· 410 struct usb_interface *iface, void *priv) 411 { 412 struct device *dev = &iface->dev; 413 int retval = 0; 414 415 if (dev->driver) ··· 420 usb_set_intfdata(iface, priv); 421 iface->needs_binding = 0; 422 423 iface->condition = USB_INTERFACE_BOUND; 424 + 425 + /* Bound interfaces are initially active. They are 426 + * runtime-PM-enabled only if the driver has autosuspend support. 427 + * They are sensitive to their children's power states. 428 + */ 429 + pm_runtime_set_active(dev); 430 + pm_suspend_ignore_children(dev, false); 431 + if (driver->supports_autosuspend) 432 + pm_runtime_enable(dev); 433 434 /* if interface was already added, bind now; else let 435 * the future device_add() bind it, bypassing probe() ··· 691 { 692 struct usb_device *usb_dev; 693 694 if (is_usb_device(dev)) { 695 usb_dev = to_usb_device(dev); 696 } else if (is_usb_interface(dev)) { ··· 705 } 706 707 if (usb_dev->devnum < 0) { 708 + /* driver is often null here; dev_dbg() would oops */ 709 pr_debug("usb %s: already deleted?\n", dev_name(dev)); 710 return -ENODEV; 711 } ··· 983 } 984 } 985 986 static int usb_suspend_device(struct usb_device *udev, pm_message_t msg) 987 { 988 struct usb_device_driver *udriver; ··· 1007 return status; 1008 } 1009 1010 static int usb_resume_device(struct usb_device *udev, pm_message_t msg) 1011 { 1012 struct usb_device_driver *udriver; ··· 1041 return status; 1042 } 1043 1044 static int usb_suspend_interface(struct usb_device *udev, 1045 struct usb_interface *intf, pm_message_t msg) 1046 { 1047 struct usb_driver *driver; 1048 int status = 0; 1049 1050 + if (udev->state == USB_STATE_NOTATTACHED || 1051 + intf->condition == USB_INTERFACE_UNBOUND) 1052 goto done; 1053 driver = to_usb_driver(intf->dev.driver); 1054 1055 if (driver->suspend) { 1056 status = driver->suspend(intf, msg); 1057 + if (status && !(msg.event & PM_EVENT_AUTO)) 1058 dev_err(&intf->dev, "%s error %d\n", 1059 "suspend", status); 1060 } else { ··· 1069 intf->needs_binding = 1; 1070 dev_warn(&intf->dev, "no %s for driver %s?\n", 1071 "suspend", driver->name); 1072 } 1073 1074 done: ··· 1077 return status; 1078 } 1079 1080 static int usb_resume_interface(struct usb_device *udev, 1081 struct usb_interface *intf, pm_message_t msg, int reset_resume) 1082 { 1083 struct usb_driver *driver; 1084 int status = 0; 1085 1086 + if (udev->state == USB_STATE_NOTATTACHED) 1087 goto done; 1088 1089 /* Don't let autoresume interfere with unbinding */ ··· 1135 1136 done: 1137 dev_vdbg(&intf->dev, "%s: status %d\n", __func__, status); 1138 1139 /* Later we will unbind the driver and/or reprobe, if necessary */ 1140 return status; 1141 } 1142 1143 /** 1144 * usb_suspend_both - suspend a USB device and its interfaces ··· 1230 * all the interfaces which were suspended are resumed so that they remain 1231 * in the same state as the device. 1232 * 1233 + * Autosuspend requests originating from a child device or an interface 1234 + * driver may be made without the protection of @udev's device lock, but 1235 + * all other suspend calls will hold the lock. Usbcore will insure that 1236 + * method calls do not arrive during bind, unbind, or reset operations. 1237 + * However drivers must be prepared to handle suspend calls arriving at 1238 + * unpredictable times. 1239 * 1240 * This routine can run only in process context. 1241 */ ··· 1259 int status = 0; 1260 int i = 0; 1261 struct usb_interface *intf; 1262 1263 if (udev->state == USB_STATE_NOTATTACHED || 1264 udev->state == USB_STATE_SUSPENDED) 1265 goto done; 1266 1267 /* Suspend all the interfaces and then udev itself */ 1268 if (udev->actconfig) { ··· 1287 1288 /* If the suspend failed, resume interfaces that did get suspended */ 1289 if (status != 0) { 1290 + msg.event ^= (PM_EVENT_SUSPEND | PM_EVENT_RESUME); 1291 while (--i >= 0) { 1292 intf = udev->actconfig->interface[i]; 1293 + usb_resume_interface(udev, intf, msg, 0); 1294 } 1295 1296 + /* If the suspend succeeded then prevent any more URB submissions 1297 + * and flush any outstanding URBs. 1298 */ 1299 } else { 1300 udev->can_submit = 0; 1301 for (i = 0; i < 16; ++i) { 1302 usb_hcd_flush_endpoint(udev, udev->ep_out[i]); 1303 usb_hcd_flush_endpoint(udev, udev->ep_in[i]); 1304 } 1305 } 1306 1307 done: ··· 1332 * the resume method for @udev and then calls the resume methods for all 1333 * the interface drivers in @udev. 1334 * 1335 + * Autoresume requests originating from a child device or an interface 1336 + * driver may be made without the protection of @udev's device lock, but 1337 + * all other resume calls will hold the lock. Usbcore will insure that 1338 + * method calls do not arrive during bind, unbind, or reset operations. 1339 + * However drivers must be prepared to handle resume calls arriving at 1340 + * unpredictable times. 1341 * 1342 * This routine can run only in process context. 1343 */ ··· 1357 int status = 0; 1358 int i; 1359 struct usb_interface *intf; 1360 1361 if (udev->state == USB_STATE_NOTATTACHED) { 1362 status = -ENODEV; 1363 goto done; 1364 } 1365 udev->can_submit = 1; 1366 1367 + /* Resume the device */ 1368 + if (udev->state == USB_STATE_SUSPENDED || udev->reset_resume) 1369 status = usb_resume_device(udev, msg); 1370 1371 + /* Resume the interfaces */ 1372 if (status == 0 && udev->actconfig) { 1373 for (i = 0; i < udev->actconfig->desc.bNumInterfaces; i++) { 1374 intf = udev->actconfig->interface[i]; ··· 1414 return status; 1415 } 1416 1417 + /* The device lock is held by the PM core */ 1418 + int usb_suspend(struct device *dev, pm_message_t msg) 1419 { 1420 + struct usb_device *udev = to_usb_device(dev); 1421 1422 + do_unbind_rebind(udev, DO_UNBIND); 1423 + udev->do_remote_wakeup = device_may_wakeup(&udev->dev); 1424 + return usb_suspend_both(udev, msg); 1425 + } 1426 + 1427 + /* The device lock is held by the PM core */ 1428 + int usb_resume(struct device *dev, pm_message_t msg) 1429 + { 1430 + struct usb_device *udev = to_usb_device(dev); 1431 + int status; 1432 + 1433 + /* For PM complete calls, all we do is rebind interfaces */ 1434 + if (msg.event == PM_EVENT_ON) { 1435 + if (udev->state != USB_STATE_NOTATTACHED) 1436 + do_unbind_rebind(udev, DO_REBIND); 1437 + status = 0; 1438 + 1439 + /* For all other calls, take the device back to full power and 1440 + * tell the PM core in case it was autosuspended previously. 1441 + */ 1442 + } else { 1443 + status = usb_resume_both(udev, msg); 1444 + if (status == 0) { 1445 + pm_runtime_disable(dev); 1446 + pm_runtime_set_active(dev); 1447 + pm_runtime_enable(dev); 1448 udev->last_busy = jiffies; 1449 + } 1450 } 1451 + 1452 + /* Avoid PM error messages for devices disconnected while suspended 1453 + * as we'll display regular disconnect messages just a bit later. 1454 + */ 1455 + if (status == -ENODEV) 1456 + status = 0; 1457 return status; 1458 } 1459 1460 + #endif /* CONFIG_PM */ 1461 + 1462 + #ifdef CONFIG_USB_SUSPEND 1463 + 1464 + /** 1465 + * usb_enable_autosuspend - allow a USB device to be autosuspended 1466 + * @udev: the USB device which may be autosuspended 1467 + * 1468 + * This routine allows @udev to be autosuspended. An autosuspend won't 1469 + * take place until the autosuspend_delay has elapsed and all the other 1470 + * necessary conditions are satisfied. 1471 + * 1472 + * The caller must hold @udev's device lock. 1473 + */ 1474 + int usb_enable_autosuspend(struct usb_device *udev) 1475 { 1476 + if (udev->autosuspend_disabled) { 1477 + udev->autosuspend_disabled = 0; 1478 + usb_autosuspend_device(udev); 1479 + } 1480 + return 0; 1481 } 1482 + EXPORT_SYMBOL_GPL(usb_enable_autosuspend); 1483 1484 + /** 1485 + * usb_disable_autosuspend - prevent a USB device from being autosuspended 1486 + * @udev: the USB device which may not be autosuspended 1487 + * 1488 + * This routine prevents @udev from being autosuspended and wakes it up 1489 + * if it is already autosuspended. 1490 + * 1491 + * The caller must hold @udev's device lock. 1492 + */ 1493 + int usb_disable_autosuspend(struct usb_device *udev) 1494 { 1495 + int rc = 0; 1496 1497 + if (!udev->autosuspend_disabled) { 1498 + rc = usb_autoresume_device(udev); 1499 + if (rc == 0) 1500 + udev->autosuspend_disabled = 1; 1501 + } 1502 + return rc; 1503 } 1504 + EXPORT_SYMBOL_GPL(usb_disable_autosuspend); 1505 1506 /** 1507 * usb_autosuspend_device - delayed autosuspend of a USB device and its interfaces ··· 1472 * @udev and wants to allow it to autosuspend. Examples would be when 1473 * @udev's device file in usbfs is closed or after a configuration change. 1474 * 1475 + * @udev's usage counter is decremented; if it drops to 0 and all the 1476 + * interfaces are inactive then a delayed autosuspend will be attempted. 1477 + * The attempt may fail (see autosuspend_check()). 1478 * 1479 + * The caller must hold @udev's device lock. 1480 * 1481 * This routine can run only in process context. 1482 */ ··· 1488 { 1489 int status; 1490 1491 + udev->last_busy = jiffies; 1492 + status = pm_runtime_put_sync(&udev->dev); 1493 + dev_vdbg(&udev->dev, "%s: cnt %d -> %d\n", 1494 + __func__, atomic_read(&udev->dev.power.usage_count), 1495 + status); 1496 } 1497 1498 /** ··· 1500 * This routine should be called when a core subsystem thinks @udev may 1501 * be ready to autosuspend. 1502 * 1503 + * @udev's usage counter left unchanged. If it is 0 and all the interfaces 1504 + * are inactive then an autosuspend will be attempted. The attempt may 1505 + * fail or be delayed. 1506 + * 1507 + * The caller must hold @udev's device lock. 1508 * 1509 * This routine can run only in process context. 1510 */ 1511 void usb_try_autosuspend_device(struct usb_device *udev) 1512 { 1513 + int status; 1514 + 1515 + status = pm_runtime_idle(&udev->dev); 1516 + dev_vdbg(&udev->dev, "%s: cnt %d -> %d\n", 1517 + __func__, atomic_read(&udev->dev.power.usage_count), 1518 + status); 1519 } 1520 1521 /** ··· 1519 * 1520 * This routine should be called when a core subsystem wants to use @udev 1521 * and needs to guarantee that it is not suspended. No autosuspend will 1522 + * occur until usb_autosuspend_device() is called. (Note that this will 1523 + * not prevent suspend events originating in the PM core.) Examples would 1524 + * be when @udev's device file in usbfs is opened or when a remote-wakeup 1525 * request is received. 1526 * 1527 * @udev's usage counter is incremented to prevent subsequent autosuspends. 1528 * However if the autoresume fails then the usage counter is re-decremented. 1529 * 1530 + * The caller must hold @udev's device lock. 1531 * 1532 * This routine can run only in process context. 1533 */ ··· 1536 { 1537 int status; 1538 1539 + status = pm_runtime_get_sync(&udev->dev); 1540 + if (status < 0) 1541 + pm_runtime_put_sync(&udev->dev); 1542 + dev_vdbg(&udev->dev, "%s: cnt %d -> %d\n", 1543 + __func__, atomic_read(&udev->dev.power.usage_count), 1544 + status); 1545 + if (status > 0) 1546 + status = 0; 1547 return status; 1548 } 1549 ··· 1585 * closed. 1586 * 1587 * The routine decrements @intf's usage counter. When the counter reaches 1588 + * 0, a delayed autosuspend request for @intf's device is attempted. The 1589 + * attempt may fail (see autosuspend_check()). 1590 * 1591 * If the driver has set @intf->needs_remote_wakeup then autosuspend will 1592 * take place only if the device's remote-wakeup facility is enabled. 1593 * 1594 * This routine can run only in process context. 1595 */ 1596 void usb_autopm_put_interface(struct usb_interface *intf) 1597 { 1598 + struct usb_device *udev = interface_to_usbdev(intf); 1599 + int status; 1600 1601 + udev->last_busy = jiffies; 1602 + atomic_dec(&intf->pm_usage_cnt); 1603 + status = pm_runtime_put_sync(&intf->dev); 1604 + dev_vdbg(&intf->dev, "%s: cnt %d -> %d\n", 1605 + __func__, atomic_read(&intf->dev.power.usage_count), 1606 + status); 1607 } 1608 EXPORT_SYMBOL_GPL(usb_autopm_put_interface); 1609 ··· 1620 * usb_autopm_put_interface_async - decrement a USB interface's PM-usage counter 1621 * @intf: the usb_interface whose counter should be decremented 1622 * 1623 + * This routine does much the same thing as usb_autopm_put_interface(): 1624 + * It decrements @intf's usage counter and schedules a delayed 1625 + * autosuspend request if the counter is <= 0. The difference is that it 1626 + * does not perform any synchronization; callers should hold a private 1627 + * lock and handle all synchronization issues themselves. 1628 * 1629 * Typically a driver would call this routine during an URB's completion 1630 * handler, if no more URBs were pending. ··· 1634 void usb_autopm_put_interface_async(struct usb_interface *intf) 1635 { 1636 struct usb_device *udev = interface_to_usbdev(intf); 1637 + unsigned long last_busy; 1638 int status = 0; 1639 1640 + last_busy = udev->last_busy; 1641 + udev->last_busy = jiffies; 1642 + atomic_dec(&intf->pm_usage_cnt); 1643 + pm_runtime_put_noidle(&intf->dev); 1644 + 1645 + if (!udev->autosuspend_disabled) { 1646 + /* Optimization: Don't schedule a delayed autosuspend if 1647 + * the timer is already running and the expiration time 1648 + * wouldn't change. 1649 + * 1650 + * We have to use the interface's timer. Attempts to 1651 + * schedule a suspend for the device would fail because 1652 + * the interface is still active. 1653 + */ 1654 + if (intf->dev.power.timer_expires == 0 || 1655 + round_jiffies_up(last_busy) != 1656 + round_jiffies_up(jiffies)) { 1657 + status = pm_schedule_suspend(&intf->dev, 1658 + jiffies_to_msecs( 1659 round_jiffies_up_relative( 1660 + udev->autosuspend_delay))); 1661 } 1662 } 1663 + dev_vdbg(&intf->dev, "%s: cnt %d -> %d\n", 1664 + __func__, atomic_read(&intf->dev.power.usage_count), 1665 + status); 1666 } 1667 EXPORT_SYMBOL_GPL(usb_autopm_put_interface_async); 1668 + 1669 + /** 1670 + * usb_autopm_put_interface_no_suspend - decrement a USB interface's PM-usage counter 1671 + * @intf: the usb_interface whose counter should be decremented 1672 + * 1673 + * This routine decrements @intf's usage counter but does not carry out an 1674 + * autosuspend. 1675 + * 1676 + * This routine can run in atomic context. 1677 + */ 1678 + void usb_autopm_put_interface_no_suspend(struct usb_interface *intf) 1679 + { 1680 + struct usb_device *udev = interface_to_usbdev(intf); 1681 + 1682 + udev->last_busy = jiffies; 1683 + atomic_dec(&intf->pm_usage_cnt); 1684 + pm_runtime_put_noidle(&intf->dev); 1685 + } 1686 + EXPORT_SYMBOL_GPL(usb_autopm_put_interface_no_suspend); 1687 1688 /** 1689 * usb_autopm_get_interface - increment a USB interface's PM-usage counter ··· 1667 * or @intf is unbound. A typical example would be a character-device 1668 * driver when its device file is opened. 1669 * 1670 + * @intf's usage counter is incremented to prevent subsequent autosuspends. 1671 + * However if the autoresume fails then the counter is re-decremented. 1672 * 1673 * This routine can run only in process context. 1674 */ ··· 1693 { 1694 int status; 1695 1696 + status = pm_runtime_get_sync(&intf->dev); 1697 + if (status < 0) 1698 + pm_runtime_put_sync(&intf->dev); 1699 + else 1700 + atomic_inc(&intf->pm_usage_cnt); 1701 + dev_vdbg(&intf->dev, "%s: cnt %d -> %d\n", 1702 + __func__, atomic_read(&intf->dev.power.usage_count), 1703 + status); 1704 + if (status > 0) 1705 + status = 0; 1706 return status; 1707 } 1708 EXPORT_SYMBOL_GPL(usb_autopm_get_interface); ··· 1705 * @intf: the usb_interface whose counter should be incremented 1706 * 1707 * This routine does much the same thing as 1708 + * usb_autopm_get_interface(): It increments @intf's usage counter and 1709 + * queues an autoresume request if the device is suspended. The 1710 + * differences are that it does not perform any synchronization (callers 1711 + * should hold a private lock and handle all synchronization issues 1712 + * themselves), and it does not autoresume the device directly (it only 1713 + * queues a request). After a successful call, the device may not yet be 1714 + * resumed. 1715 * 1716 * This routine can run in atomic context. 1717 */ 1718 int usb_autopm_get_interface_async(struct usb_interface *intf) 1719 { 1720 + int status = 0; 1721 + enum rpm_status s; 1722 1723 + /* Don't request a resume unless the interface is already suspending 1724 + * or suspended. Doing so would force a running suspend timer to be 1725 + * cancelled. 1726 + */ 1727 + pm_runtime_get_noresume(&intf->dev); 1728 + s = ACCESS_ONCE(intf->dev.power.runtime_status); 1729 + if (s == RPM_SUSPENDING || s == RPM_SUSPENDED) 1730 + status = pm_request_resume(&intf->dev); 1731 + 1732 + if (status < 0 && status != -EINPROGRESS) 1733 + pm_runtime_put_noidle(&intf->dev); 1734 + else 1735 atomic_inc(&intf->pm_usage_cnt); 1736 + dev_vdbg(&intf->dev, "%s: cnt %d -> %d\n", 1737 + __func__, atomic_read(&intf->dev.power.usage_count), 1738 + status); 1739 + if (status > 0) 1740 + status = 0; 1741 return status; 1742 } 1743 EXPORT_SYMBOL_GPL(usb_autopm_get_interface_async); 1744 1745 /** 1746 + * usb_autopm_get_interface_no_resume - increment a USB interface's PM-usage counter 1747 + * @intf: the usb_interface whose counter should be incremented 1748 * 1749 + * This routine increments @intf's usage counter but does not carry out an 1750 + * autoresume. 1751 * 1752 + * This routine can run in atomic context. 1753 */ 1754 + void usb_autopm_get_interface_no_resume(struct usb_interface *intf) 1755 { 1756 + struct usb_device *udev = interface_to_usbdev(intf); 1757 1758 udev->last_busy = jiffies; 1759 + atomic_inc(&intf->pm_usage_cnt); 1760 + pm_runtime_get_noresume(&intf->dev); 1761 } 1762 + EXPORT_SYMBOL_GPL(usb_autopm_get_interface_no_resume); 1763 1764 + /* Internal routine to check whether we may autosuspend a device. */ 1765 + static int autosuspend_check(struct usb_device *udev) 1766 { 1767 + int i; 1768 + struct usb_interface *intf; 1769 + unsigned long suspend_time, j; 1770 1771 + /* Fail if autosuspend is disabled, or any interfaces are in use, or 1772 + * any interface drivers require remote wakeup but it isn't available. 1773 */ 1774 + udev->do_remote_wakeup = device_may_wakeup(&udev->dev); 1775 + if (udev->actconfig) { 1776 + for (i = 0; i < udev->actconfig->desc.bNumInterfaces; i++) { 1777 + intf = udev->actconfig->interface[i]; 1778 + 1779 + /* We don't need to check interfaces that are 1780 + * disabled for runtime PM. Either they are unbound 1781 + * or else their drivers don't support autosuspend 1782 + * and so they are permanently active. 1783 + */ 1784 + if (intf->dev.power.disable_depth) 1785 + continue; 1786 + if (atomic_read(&intf->dev.power.usage_count) > 0) 1787 + return -EBUSY; 1788 + if (intf->needs_remote_wakeup && 1789 + !udev->do_remote_wakeup) { 1790 + dev_dbg(&udev->dev, "remote wakeup needed " 1791 + "for autosuspend\n"); 1792 + return -EOPNOTSUPP; 1793 + } 1794 + 1795 + /* Don't allow autosuspend if the device will need 1796 + * a reset-resume and any of its interface drivers 1797 + * doesn't include support or needs remote wakeup. 1798 + */ 1799 + if (udev->quirks & USB_QUIRK_RESET_RESUME) { 1800 + struct usb_driver *driver; 1801 + 1802 + driver = to_usb_driver(intf->dev.driver); 1803 + if (!driver->reset_resume || 1804 + intf->needs_remote_wakeup) 1805 + return -EOPNOTSUPP; 1806 + } 1807 + } 1808 } 1809 1810 + /* If everything is okay but the device hasn't been idle for long 1811 + * enough, queue a delayed autosuspend request. 1812 + */ 1813 + j = ACCESS_ONCE(jiffies); 1814 + suspend_time = udev->last_busy + udev->autosuspend_delay; 1815 + if (time_before(j, suspend_time)) { 1816 + pm_schedule_suspend(&udev->dev, jiffies_to_msecs( 1817 + round_jiffies_up_relative(suspend_time - j))); 1818 + return -EAGAIN; 1819 + } 1820 + return 0; 1821 } 1822 1823 + static int usb_runtime_suspend(struct device *dev) 1824 { 1825 + int status = 0; 1826 1827 + /* A USB device can be suspended if it passes the various autosuspend 1828 + * checks. Runtime suspend for a USB device means suspending all the 1829 + * interfaces and then the device itself. 1830 */ 1831 + if (is_usb_device(dev)) { 1832 + struct usb_device *udev = to_usb_device(dev); 1833 1834 + if (autosuspend_check(udev) != 0) 1835 + return -EAGAIN; 1836 + 1837 + status = usb_suspend_both(udev, PMSG_AUTO_SUSPEND); 1838 + 1839 + /* If an interface fails the suspend, adjust the last_busy 1840 + * time so that we don't get another suspend attempt right 1841 + * away. 1842 + */ 1843 + if (status) { 1844 + udev->last_busy = jiffies + 1845 + (udev->autosuspend_delay == 0 ? 1846 + HZ/2 : 0); 1847 + } 1848 + 1849 + /* Prevent the parent from suspending immediately after */ 1850 + else if (udev->parent) { 1851 + udev->parent->last_busy = jiffies; 1852 + } 1853 + } 1854 + 1855 + /* Runtime suspend for a USB interface doesn't mean anything. */ 1856 return status; 1857 } 1858 1859 + static int usb_runtime_resume(struct device *dev) 1860 + { 1861 + /* Runtime resume for a USB device means resuming both the device 1862 + * and all its interfaces. 1863 + */ 1864 + if (is_usb_device(dev)) { 1865 + struct usb_device *udev = to_usb_device(dev); 1866 + int status; 1867 + 1868 + status = usb_resume_both(udev, PMSG_AUTO_RESUME); 1869 + udev->last_busy = jiffies; 1870 + return status; 1871 + } 1872 + 1873 + /* Runtime resume for a USB interface doesn't mean anything. */ 1874 + return 0; 1875 + } 1876 + 1877 + static int usb_runtime_idle(struct device *dev) 1878 + { 1879 + /* An idle USB device can be suspended if it passes the various 1880 + * autosuspend checks. An idle interface can be suspended at 1881 + * any time. 1882 + */ 1883 + if (is_usb_device(dev)) { 1884 + struct usb_device *udev = to_usb_device(dev); 1885 + 1886 + if (autosuspend_check(udev) != 0) 1887 + return 0; 1888 + } 1889 + 1890 + pm_runtime_suspend(dev); 1891 + return 0; 1892 + } 1893 + 1894 + static struct dev_pm_ops usb_bus_pm_ops = { 1895 + .runtime_suspend = usb_runtime_suspend, 1896 + .runtime_resume = usb_runtime_resume, 1897 + .runtime_idle = usb_runtime_idle, 1898 + }; 1899 + 1900 + #else 1901 + 1902 + #define usb_bus_pm_ops (*(struct dev_pm_ops *) NULL) 1903 + 1904 + #endif /* CONFIG_USB_SUSPEND */ 1905 1906 struct bus_type usb_bus_type = { 1907 .name = "usb", 1908 .match = usb_device_match, 1909 .uevent = usb_uevent, 1910 + .pm = &usb_bus_pm_ops, 1911 };
-2
drivers/usb/core/file.c
··· 34 int err = -ENODEV; 35 const struct file_operations *old_fops, *new_fops = NULL; 36 37 - lock_kernel(); 38 down_read(&minor_rwsem); 39 c = usb_minors[minor]; 40 ··· 52 fops_put(old_fops); 53 done: 54 up_read(&minor_rwsem); 55 - unlock_kernel(); 56 return err; 57 } 58
··· 34 int err = -ENODEV; 35 const struct file_operations *old_fops, *new_fops = NULL; 36 37 down_read(&minor_rwsem); 38 c = usb_minors[minor]; 39 ··· 53 fops_put(old_fops); 54 done: 55 up_read(&minor_rwsem); 56 return err; 57 } 58
+18 -9
drivers/usb/core/hcd.c
··· 39 #include <linux/platform_device.h> 40 #include <linux/workqueue.h> 41 #include <linux/mutex.h> 42 43 #include <linux/usb.h> 44 ··· 142 0x09, /* __u8 bMaxPacketSize0; 2^9 = 512 Bytes */ 143 144 0x6b, 0x1d, /* __le16 idVendor; Linux Foundation */ 145 - 0x02, 0x00, /* __le16 idProduct; device 0x0002 */ 146 KERNEL_VER, KERNEL_REL, /* __le16 bcdDevice */ 147 148 0x03, /* __u8 iManufacturer; */ ··· 1671 } 1672 } 1673 for (i = 0; i < num_intfs; ++i) { 1674 /* Set up endpoints for alternate interface setting 0 */ 1675 - alt = usb_find_alt_setting(new_config, i, 0); 1676 if (!alt) 1677 /* No alt setting 0? Pick the first setting. */ 1678 - alt = &new_config->intf_cache[i]->altsetting[0]; 1679 1680 for (j = 0; j < alt->desc.bNumEndpoints; j++) { 1681 ret = hcd->driver->add_endpoint(hcd, udev, &alt->endpoint[j]); ··· 1859 return status; 1860 } 1861 1862 /* Workqueue routine for root-hub remote wakeup */ 1863 static void hcd_resume_work(struct work_struct *work) 1864 { ··· 1870 struct usb_device *udev = hcd->self.root_hub; 1871 1872 usb_lock_device(udev); 1873 - usb_mark_last_busy(udev); 1874 - usb_external_resume_device(udev, PMSG_REMOTE_RESUME); 1875 usb_unlock_device(udev); 1876 } 1877 ··· 1889 1890 spin_lock_irqsave (&hcd_root_hub_lock, flags); 1891 if (hcd->rh_registered) 1892 - queue_work(ksuspend_usb_wq, &hcd->wakeup_work); 1893 spin_unlock_irqrestore (&hcd_root_hub_lock, flags); 1894 } 1895 EXPORT_SYMBOL_GPL(usb_hcd_resume_root_hub); 1896 1897 - #endif 1898 1899 /*-------------------------------------------------------------------------*/ 1900 ··· 2039 init_timer(&hcd->rh_timer); 2040 hcd->rh_timer.function = rh_timer_func; 2041 hcd->rh_timer.data = (unsigned long) hcd; 2042 - #ifdef CONFIG_PM 2043 INIT_WORK(&hcd->wakeup_work, hcd_resume_work); 2044 #endif 2045 mutex_init(&hcd->bandwidth_mutex); ··· 2239 hcd->rh_registered = 0; 2240 spin_unlock_irq (&hcd_root_hub_lock); 2241 2242 - #ifdef CONFIG_PM 2243 cancel_work_sync(&hcd->wakeup_work); 2244 #endif 2245
··· 39 #include <linux/platform_device.h> 40 #include <linux/workqueue.h> 41 #include <linux/mutex.h> 42 + #include <linux/pm_runtime.h> 43 44 #include <linux/usb.h> 45 ··· 141 0x09, /* __u8 bMaxPacketSize0; 2^9 = 512 Bytes */ 142 143 0x6b, 0x1d, /* __le16 idVendor; Linux Foundation */ 144 + 0x03, 0x00, /* __le16 idProduct; device 0x0003 */ 145 KERNEL_VER, KERNEL_REL, /* __le16 bcdDevice */ 146 147 0x03, /* __u8 iManufacturer; */ ··· 1670 } 1671 } 1672 for (i = 0; i < num_intfs; ++i) { 1673 + struct usb_host_interface *first_alt; 1674 + int iface_num; 1675 + 1676 + first_alt = &new_config->intf_cache[i]->altsetting[0]; 1677 + iface_num = first_alt->desc.bInterfaceNumber; 1678 /* Set up endpoints for alternate interface setting 0 */ 1679 + alt = usb_find_alt_setting(new_config, iface_num, 0); 1680 if (!alt) 1681 /* No alt setting 0? Pick the first setting. */ 1682 + alt = first_alt; 1683 1684 for (j = 0; j < alt->desc.bNumEndpoints; j++) { 1685 ret = hcd->driver->add_endpoint(hcd, udev, &alt->endpoint[j]); ··· 1853 return status; 1854 } 1855 1856 + #endif /* CONFIG_PM */ 1857 + 1858 + #ifdef CONFIG_USB_SUSPEND 1859 + 1860 /* Workqueue routine for root-hub remote wakeup */ 1861 static void hcd_resume_work(struct work_struct *work) 1862 { ··· 1860 struct usb_device *udev = hcd->self.root_hub; 1861 1862 usb_lock_device(udev); 1863 + usb_remote_wakeup(udev); 1864 usb_unlock_device(udev); 1865 } 1866 ··· 1880 1881 spin_lock_irqsave (&hcd_root_hub_lock, flags); 1882 if (hcd->rh_registered) 1883 + queue_work(pm_wq, &hcd->wakeup_work); 1884 spin_unlock_irqrestore (&hcd_root_hub_lock, flags); 1885 } 1886 EXPORT_SYMBOL_GPL(usb_hcd_resume_root_hub); 1887 1888 + #endif /* CONFIG_USB_SUSPEND */ 1889 1890 /*-------------------------------------------------------------------------*/ 1891 ··· 2030 init_timer(&hcd->rh_timer); 2031 hcd->rh_timer.function = rh_timer_func; 2032 hcd->rh_timer.data = (unsigned long) hcd; 2033 + #ifdef CONFIG_USB_SUSPEND 2034 INIT_WORK(&hcd->wakeup_work, hcd_resume_work); 2035 #endif 2036 mutex_init(&hcd->bandwidth_mutex); ··· 2230 hcd->rh_registered = 0; 2231 spin_unlock_irq (&hcd_root_hub_lock); 2232 2233 + #ifdef CONFIG_USB_SUSPEND 2234 cancel_work_sync(&hcd->wakeup_work); 2235 #endif 2236
+9 -4
drivers/usb/core/hcd.h
··· 80 81 struct timer_list rh_timer; /* drives root-hub polling */ 82 struct urb *status_urb; /* the current status urb */ 83 - #ifdef CONFIG_PM 84 struct work_struct wakeup_work; /* for remote wakeup */ 85 #endif 86 ··· 248 /* xHCI specific functions */ 249 /* Called by usb_alloc_dev to alloc HC device structures */ 250 int (*alloc_dev)(struct usb_hcd *, struct usb_device *); 251 - /* Called by usb_release_dev to free HC device structures */ 252 void (*free_dev)(struct usb_hcd *, struct usb_device *); 253 254 /* Bandwidth computation functions */ ··· 286 */ 287 int (*update_hub_device)(struct usb_hcd *, struct usb_device *hdev, 288 struct usb_tt *tt, gfp_t mem_flags); 289 }; 290 291 extern int usb_hcd_link_urb_to_ep(struct usb_hcd *hcd, struct urb *urb); ··· 464 #define usb_endpoint_out(ep_dir) (!((ep_dir) & USB_DIR_IN)) 465 466 #ifdef CONFIG_PM 467 - extern void usb_hcd_resume_root_hub(struct usb_hcd *hcd); 468 extern void usb_root_hub_lost_power(struct usb_device *rhdev); 469 extern int hcd_bus_suspend(struct usb_device *rhdev, pm_message_t msg); 470 extern int hcd_bus_resume(struct usb_device *rhdev, pm_message_t msg); 471 #else 472 static inline void usb_hcd_resume_root_hub(struct usb_hcd *hcd) 473 { 474 return; 475 } 476 - #endif /* CONFIG_PM */ 477 478 /* 479 * USB device fs stuff
··· 80 81 struct timer_list rh_timer; /* drives root-hub polling */ 82 struct urb *status_urb; /* the current status urb */ 83 + #ifdef CONFIG_USB_SUSPEND 84 struct work_struct wakeup_work; /* for remote wakeup */ 85 #endif 86 ··· 248 /* xHCI specific functions */ 249 /* Called by usb_alloc_dev to alloc HC device structures */ 250 int (*alloc_dev)(struct usb_hcd *, struct usb_device *); 251 + /* Called by usb_disconnect to free HC device structures */ 252 void (*free_dev)(struct usb_hcd *, struct usb_device *); 253 254 /* Bandwidth computation functions */ ··· 286 */ 287 int (*update_hub_device)(struct usb_hcd *, struct usb_device *hdev, 288 struct usb_tt *tt, gfp_t mem_flags); 289 + int (*reset_device)(struct usb_hcd *, struct usb_device *); 290 }; 291 292 extern int usb_hcd_link_urb_to_ep(struct usb_hcd *hcd, struct urb *urb); ··· 463 #define usb_endpoint_out(ep_dir) (!((ep_dir) & USB_DIR_IN)) 464 465 #ifdef CONFIG_PM 466 extern void usb_root_hub_lost_power(struct usb_device *rhdev); 467 extern int hcd_bus_suspend(struct usb_device *rhdev, pm_message_t msg); 468 extern int hcd_bus_resume(struct usb_device *rhdev, pm_message_t msg); 469 + #endif /* CONFIG_PM */ 470 + 471 + #ifdef CONFIG_USB_SUSPEND 472 + extern void usb_hcd_resume_root_hub(struct usb_hcd *hcd); 473 #else 474 static inline void usb_hcd_resume_root_hub(struct usb_hcd *hcd) 475 { 476 return; 477 } 478 + #endif /* CONFIG_USB_SUSPEND */ 479 + 480 481 /* 482 * USB device fs stuff
+53 -67
drivers/usb/core/hub.c
··· 22 #include <linux/kthread.h> 23 #include <linux/mutex.h> 24 #include <linux/freezer.h> 25 26 #include <asm/uaccess.h> 27 #include <asm/byteorder.h> ··· 72 73 unsigned mA_per_port; /* current for each child */ 74 75 - unsigned init_done:1; 76 unsigned limited_power:1; 77 unsigned quiescing:1; 78 unsigned disconnected:1; ··· 820 } 821 init3: 822 hub->quiescing = 0; 823 - hub->init_done = 1; 824 825 status = usb_submit_urb(hub->urb, GFP_NOIO); 826 if (status < 0) ··· 860 int i; 861 862 cancel_delayed_work_sync(&hub->init_work); 863 - if (!hub->init_done) { 864 - hub->init_done = 1; 865 - usb_autopm_put_interface_no_suspend( 866 - to_usb_interface(hub->intfdev)); 867 - } 868 869 /* khubd and related activity won't re-trigger */ 870 hub->quiescing = 1; ··· 1218 desc = intf->cur_altsetting; 1219 hdev = interface_to_usbdev(intf); 1220 1221 if (hdev->level == MAX_TOPO_LEVEL) { 1222 dev_err(&intf->dev, 1223 "Unsupported bus topology: hub nested too deep\n"); ··· 1399 if (udev->children[i]) 1400 recursively_mark_NOTATTACHED(udev->children[i]); 1401 } 1402 - if (udev->state == USB_STATE_SUSPENDED) { 1403 - udev->discon_suspended = 1; 1404 udev->active_duration -= jiffies; 1405 - } 1406 udev->state = USB_STATE_NOTATTACHED; 1407 } 1408 ··· 1443 || new_state == USB_STATE_SUSPENDED) 1444 ; /* No change to wakeup settings */ 1445 else if (new_state == USB_STATE_CONFIGURED) 1446 - device_init_wakeup(&udev->dev, 1447 (udev->actconfig->desc.bmAttributes 1448 & USB_CONFIG_ATT_WAKEUP)); 1449 else 1450 - device_init_wakeup(&udev->dev, 0); 1451 } 1452 if (udev->state == USB_STATE_SUSPENDED && 1453 new_state != USB_STATE_SUSPENDED) ··· 1524 udev->devnum = devnum; 1525 } 1526 1527 - #ifdef CONFIG_USB_SUSPEND 1528 - 1529 - static void usb_stop_pm(struct usb_device *udev) 1530 { 1531 - /* Synchronize with the ksuspend thread to prevent any more 1532 - * autosuspend requests from being submitted, and decrement 1533 - * the parent's count of unsuspended children. 1534 - */ 1535 - usb_pm_lock(udev); 1536 - if (udev->parent && !udev->discon_suspended) 1537 - usb_autosuspend_device(udev->parent); 1538 - usb_pm_unlock(udev); 1539 1540 - /* Stop any autosuspend or autoresume requests already submitted */ 1541 - cancel_delayed_work_sync(&udev->autosuspend); 1542 - cancel_work_sync(&udev->autoresume); 1543 } 1544 - 1545 - #else 1546 - 1547 - static inline void usb_stop_pm(struct usb_device *udev) 1548 - { } 1549 - 1550 - #endif 1551 1552 /** 1553 * usb_disconnect - disconnect a device (usbcore-internal) ··· 1601 *pdev = NULL; 1602 spin_unlock_irq(&device_state_lock); 1603 1604 - usb_stop_pm(udev); 1605 1606 put_device(&udev->dev); 1607 } ··· 1778 { 1779 int err; 1780 1781 - /* Increment the parent's count of unsuspended children */ 1782 - if (udev->parent) 1783 - usb_autoresume_device(udev->parent); 1784 1785 usb_detect_quirks(udev); 1786 err = usb_enumerate_device(udev); /* Read descriptors */ ··· 1821 1822 fail: 1823 usb_set_device_state(udev, USB_STATE_NOTATTACHED); 1824 - usb_stop_pm(udev); 1825 return err; 1826 } 1827 ··· 1971 if (!(portstatus & USB_PORT_STAT_RESET) && 1972 (portstatus & USB_PORT_STAT_ENABLE)) { 1973 if (hub_is_wusb(hub)) 1974 - udev->speed = USB_SPEED_VARIABLE; 1975 else if (portstatus & USB_PORT_STAT_HIGH_SPEED) 1976 udev->speed = USB_SPEED_HIGH; 1977 else if (portstatus & USB_PORT_STAT_LOW_SPEED) ··· 1997 struct usb_device *udev, unsigned int delay) 1998 { 1999 int i, status; 2000 2001 /* Block EHCI CF initialization during the port reset. 2002 * Some companion controllers don't like it when they mix. 2003 */ ··· 2027 /* TRSTRCY = 10 ms; plus some extra */ 2028 msleep(10 + 40); 2029 update_address(udev, 0); 2030 /* FALL THROUGH */ 2031 case -ENOTCONN: 2032 case -ENODEV: ··· 2380 } 2381 2382 /* caller has locked udev */ 2383 - static int remote_wakeup(struct usb_device *udev) 2384 { 2385 int status = 0; 2386 2387 if (udev->state == USB_STATE_SUSPENDED) { 2388 dev_dbg(&udev->dev, "usb %sresume\n", "wakeup-"); 2389 - usb_mark_last_busy(udev); 2390 - status = usb_external_resume_device(udev, PMSG_REMOTE_RESUME); 2391 } 2392 return status; 2393 } ··· 2425 status = usb_reset_and_verify_device(udev); 2426 } 2427 return status; 2428 - } 2429 - 2430 - static inline int remote_wakeup(struct usb_device *udev) 2431 - { 2432 - return 0; 2433 } 2434 2435 #endif ··· 2492 EXPORT_SYMBOL_GPL(usb_root_hub_lost_power); 2493 2494 #else /* CONFIG_PM */ 2495 - 2496 - static inline int remote_wakeup(struct usb_device *udev) 2497 - { 2498 - return 0; 2499 - } 2500 2501 #define hub_suspend NULL 2502 #define hub_resume NULL ··· 2637 2638 mutex_lock(&usb_address0_mutex); 2639 2640 - if ((hcd->driver->flags & HCD_USB3) && udev->config) { 2641 - /* FIXME this will need special handling by the xHCI driver. */ 2642 - dev_dbg(&udev->dev, 2643 - "xHCI reset of configured device " 2644 - "not supported yet.\n"); 2645 - retval = -EINVAL; 2646 - goto fail; 2647 - } else if (!udev->config && oldspeed == USB_SPEED_SUPER) { 2648 /* Don't reset USB 3.0 devices during an initial setup */ 2649 usb_set_device_state(udev, USB_STATE_DEFAULT); 2650 } else { ··· 2663 */ 2664 switch (udev->speed) { 2665 case USB_SPEED_SUPER: 2666 - case USB_SPEED_VARIABLE: /* fixed at 512 */ 2667 udev->ep0.desc.wMaxPacketSize = cpu_to_le16(512); 2668 break; 2669 case USB_SPEED_HIGH: /* fixed at 64 */ ··· 2691 case USB_SPEED_SUPER: 2692 speed = "super"; 2693 break; 2694 - case USB_SPEED_VARIABLE: 2695 speed = "variable"; 2696 type = "Wireless "; 2697 break; ··· 2991 /* For a suspended device, treat this as a 2992 * remote wakeup event. 2993 */ 2994 - status = remote_wakeup(udev); 2995 #endif 2996 2997 } else { ··· 3177 loop: 3178 usb_ep0_reinit(udev); 3179 release_address(udev); 3180 usb_put_dev(udev); 3181 if ((status == -ENOTCONN) || (status == -ENOTSUPP)) 3182 break; ··· 3245 * disconnected while waiting for the lock to succeed. */ 3246 usb_lock_device(hdev); 3247 if (unlikely(hub->disconnected)) 3248 - goto loop2; 3249 3250 /* If the hub has died, clean up after it */ 3251 if (hdev->state == USB_STATE_NOTATTACHED) { ··· 3338 msleep(10); 3339 3340 usb_lock_device(udev); 3341 - ret = remote_wakeup(hdev-> 3342 children[i-1]); 3343 usb_unlock_device(udev); 3344 if (ret < 0) ··· 3405 * kick_khubd() and allow autosuspend. 3406 */ 3407 usb_autopm_put_interface(intf); 3408 - loop2: 3409 usb_unlock_device(hdev); 3410 kref_put(&hub->kref, hub_release); 3411 ··· 3432 return 0; 3433 } 3434 3435 - static struct usb_device_id hub_id_table [] = { 3436 { .match_flags = USB_DEVICE_ID_MATCH_DEV_CLASS, 3437 .bDeviceClass = USB_CLASS_HUB}, 3438 { .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS,
··· 22 #include <linux/kthread.h> 23 #include <linux/mutex.h> 24 #include <linux/freezer.h> 25 + #include <linux/pm_runtime.h> 26 27 #include <asm/uaccess.h> 28 #include <asm/byteorder.h> ··· 71 72 unsigned mA_per_port; /* current for each child */ 73 74 unsigned limited_power:1; 75 unsigned quiescing:1; 76 unsigned disconnected:1; ··· 820 } 821 init3: 822 hub->quiescing = 0; 823 824 status = usb_submit_urb(hub->urb, GFP_NOIO); 825 if (status < 0) ··· 861 int i; 862 863 cancel_delayed_work_sync(&hub->init_work); 864 865 /* khubd and related activity won't re-trigger */ 866 hub->quiescing = 1; ··· 1224 desc = intf->cur_altsetting; 1225 hdev = interface_to_usbdev(intf); 1226 1227 + /* Hubs have proper suspend/resume support */ 1228 + usb_enable_autosuspend(hdev); 1229 + 1230 if (hdev->level == MAX_TOPO_LEVEL) { 1231 dev_err(&intf->dev, 1232 "Unsupported bus topology: hub nested too deep\n"); ··· 1402 if (udev->children[i]) 1403 recursively_mark_NOTATTACHED(udev->children[i]); 1404 } 1405 + if (udev->state == USB_STATE_SUSPENDED) 1406 udev->active_duration -= jiffies; 1407 udev->state = USB_STATE_NOTATTACHED; 1408 } 1409 ··· 1448 || new_state == USB_STATE_SUSPENDED) 1449 ; /* No change to wakeup settings */ 1450 else if (new_state == USB_STATE_CONFIGURED) 1451 + device_set_wakeup_capable(&udev->dev, 1452 (udev->actconfig->desc.bmAttributes 1453 & USB_CONFIG_ATT_WAKEUP)); 1454 else 1455 + device_set_wakeup_capable(&udev->dev, 0); 1456 } 1457 if (udev->state == USB_STATE_SUSPENDED && 1458 new_state != USB_STATE_SUSPENDED) ··· 1529 udev->devnum = devnum; 1530 } 1531 1532 + static void hub_free_dev(struct usb_device *udev) 1533 { 1534 + struct usb_hcd *hcd = bus_to_hcd(udev->bus); 1535 1536 + /* Root hubs aren't real devices, so don't free HCD resources */ 1537 + if (hcd->driver->free_dev && udev->parent) 1538 + hcd->driver->free_dev(hcd, udev); 1539 } 1540 1541 /** 1542 * usb_disconnect - disconnect a device (usbcore-internal) ··· 1622 *pdev = NULL; 1623 spin_unlock_irq(&device_state_lock); 1624 1625 + hub_free_dev(udev); 1626 1627 put_device(&udev->dev); 1628 } ··· 1799 { 1800 int err; 1801 1802 + if (udev->parent) { 1803 + /* Initialize non-root-hub device wakeup to disabled; 1804 + * device (un)configuration controls wakeup capable 1805 + * sysfs power/wakeup controls wakeup enabled/disabled 1806 + */ 1807 + device_init_wakeup(&udev->dev, 0); 1808 + device_set_wakeup_enable(&udev->dev, 1); 1809 + } 1810 + 1811 + /* Tell the runtime-PM framework the device is active */ 1812 + pm_runtime_set_active(&udev->dev); 1813 + pm_runtime_enable(&udev->dev); 1814 1815 usb_detect_quirks(udev); 1816 err = usb_enumerate_device(udev); /* Read descriptors */ ··· 1833 1834 fail: 1835 usb_set_device_state(udev, USB_STATE_NOTATTACHED); 1836 + pm_runtime_disable(&udev->dev); 1837 + pm_runtime_set_suspended(&udev->dev); 1838 return err; 1839 } 1840 ··· 1982 if (!(portstatus & USB_PORT_STAT_RESET) && 1983 (portstatus & USB_PORT_STAT_ENABLE)) { 1984 if (hub_is_wusb(hub)) 1985 + udev->speed = USB_SPEED_WIRELESS; 1986 else if (portstatus & USB_PORT_STAT_HIGH_SPEED) 1987 udev->speed = USB_SPEED_HIGH; 1988 else if (portstatus & USB_PORT_STAT_LOW_SPEED) ··· 2008 struct usb_device *udev, unsigned int delay) 2009 { 2010 int i, status; 2011 + struct usb_hcd *hcd; 2012 2013 + hcd = bus_to_hcd(udev->bus); 2014 /* Block EHCI CF initialization during the port reset. 2015 * Some companion controllers don't like it when they mix. 2016 */ ··· 2036 /* TRSTRCY = 10 ms; plus some extra */ 2037 msleep(10 + 40); 2038 update_address(udev, 0); 2039 + if (hcd->driver->reset_device) { 2040 + status = hcd->driver->reset_device(hcd, udev); 2041 + if (status < 0) { 2042 + dev_err(&udev->dev, "Cannot reset " 2043 + "HCD device state\n"); 2044 + break; 2045 + } 2046 + } 2047 /* FALL THROUGH */ 2048 case -ENOTCONN: 2049 case -ENODEV: ··· 2381 } 2382 2383 /* caller has locked udev */ 2384 + int usb_remote_wakeup(struct usb_device *udev) 2385 { 2386 int status = 0; 2387 2388 if (udev->state == USB_STATE_SUSPENDED) { 2389 dev_dbg(&udev->dev, "usb %sresume\n", "wakeup-"); 2390 + status = usb_autoresume_device(udev); 2391 + if (status == 0) { 2392 + /* Let the drivers do their thing, then... */ 2393 + usb_autosuspend_device(udev); 2394 + } 2395 } 2396 return status; 2397 } ··· 2423 status = usb_reset_and_verify_device(udev); 2424 } 2425 return status; 2426 } 2427 2428 #endif ··· 2495 EXPORT_SYMBOL_GPL(usb_root_hub_lost_power); 2496 2497 #else /* CONFIG_PM */ 2498 2499 #define hub_suspend NULL 2500 #define hub_resume NULL ··· 2645 2646 mutex_lock(&usb_address0_mutex); 2647 2648 + if (!udev->config && oldspeed == USB_SPEED_SUPER) { 2649 /* Don't reset USB 3.0 devices during an initial setup */ 2650 usb_set_device_state(udev, USB_STATE_DEFAULT); 2651 } else { ··· 2678 */ 2679 switch (udev->speed) { 2680 case USB_SPEED_SUPER: 2681 + case USB_SPEED_WIRELESS: /* fixed at 512 */ 2682 udev->ep0.desc.wMaxPacketSize = cpu_to_le16(512); 2683 break; 2684 case USB_SPEED_HIGH: /* fixed at 64 */ ··· 2706 case USB_SPEED_SUPER: 2707 speed = "super"; 2708 break; 2709 + case USB_SPEED_WIRELESS: 2710 speed = "variable"; 2711 type = "Wireless "; 2712 break; ··· 3006 /* For a suspended device, treat this as a 3007 * remote wakeup event. 3008 */ 3009 + status = usb_remote_wakeup(udev); 3010 #endif 3011 3012 } else { ··· 3192 loop: 3193 usb_ep0_reinit(udev); 3194 release_address(udev); 3195 + hub_free_dev(udev); 3196 usb_put_dev(udev); 3197 if ((status == -ENOTCONN) || (status == -ENOTSUPP)) 3198 break; ··· 3259 * disconnected while waiting for the lock to succeed. */ 3260 usb_lock_device(hdev); 3261 if (unlikely(hub->disconnected)) 3262 + goto loop_disconnected; 3263 3264 /* If the hub has died, clean up after it */ 3265 if (hdev->state == USB_STATE_NOTATTACHED) { ··· 3352 msleep(10); 3353 3354 usb_lock_device(udev); 3355 + ret = usb_remote_wakeup(hdev-> 3356 children[i-1]); 3357 usb_unlock_device(udev); 3358 if (ret < 0) ··· 3419 * kick_khubd() and allow autosuspend. 3420 */ 3421 usb_autopm_put_interface(intf); 3422 + loop_disconnected: 3423 usb_unlock_device(hdev); 3424 kref_put(&hub->kref, hub_release); 3425 ··· 3446 return 0; 3447 } 3448 3449 + static const struct usb_device_id hub_id_table[] = { 3450 { .match_flags = USB_DEVICE_ID_MATCH_DEV_CLASS, 3451 .bDeviceClass = USB_CLASS_HUB}, 3452 { .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS,
+2 -3
drivers/usb/core/message.c
··· 1316 1317 alt = usb_altnum_to_altsetting(iface, alternate); 1318 if (!alt) { 1319 - dev_warn(&dev->dev, "selecting invalid altsetting %d", 1320 alternate); 1321 return -EINVAL; 1322 } ··· 1471 /* If not, reinstate the old alternate settings */ 1472 if (retval < 0) { 1473 reset_old_alts: 1474 - for (; i >= 0; i--) { 1475 struct usb_interface *intf = config->interface[i]; 1476 struct usb_host_interface *alt; 1477 ··· 1843 intf->dev.dma_mask = dev->dev.dma_mask; 1844 INIT_WORK(&intf->reset_ws, __usb_queue_reset_device); 1845 device_initialize(&intf->dev); 1846 - mark_quiesced(intf); 1847 dev_set_name(&intf->dev, "%d-%s:%d.%d", 1848 dev->bus->busnum, dev->devpath, 1849 configuration, alt->desc.bInterfaceNumber);
··· 1316 1317 alt = usb_altnum_to_altsetting(iface, alternate); 1318 if (!alt) { 1319 + dev_warn(&dev->dev, "selecting invalid altsetting %d\n", 1320 alternate); 1321 return -EINVAL; 1322 } ··· 1471 /* If not, reinstate the old alternate settings */ 1472 if (retval < 0) { 1473 reset_old_alts: 1474 + for (i--; i >= 0; i--) { 1475 struct usb_interface *intf = config->interface[i]; 1476 struct usb_host_interface *alt; 1477 ··· 1843 intf->dev.dma_mask = dev->dev.dma_mask; 1844 INIT_WORK(&intf->reset_ws, __usb_queue_reset_device); 1845 device_initialize(&intf->dev); 1846 dev_set_name(&intf->dev, "%d-%s:%d.%d", 1847 dev->bus->busnum, dev->devpath, 1848 configuration, alt->desc.bInterfaceNumber);
+14 -4
drivers/usb/core/quirks.c
··· 103 dev_dbg(&udev->dev, "USB quirks for this device: %x\n", 104 udev->quirks); 105 106 - /* By default, disable autosuspend for all non-hubs */ 107 #ifdef CONFIG_USB_SUSPEND 108 - if (udev->descriptor.bDeviceClass != USB_CLASS_HUB) 109 - udev->autosuspend_disabled = 1; 110 #endif 111 112 /* For the present, all devices default to USB-PERSIST enabled */ ··· 129 * for all devices. It will affect things like hub resets 130 * and EMF-related port disables. 131 */ 132 - udev->persist_enabled = 1; 133 #endif /* CONFIG_PM */ 134 }
··· 103 dev_dbg(&udev->dev, "USB quirks for this device: %x\n", 104 udev->quirks); 105 106 #ifdef CONFIG_USB_SUSPEND 107 + 108 + /* By default, disable autosuspend for all devices. The hub driver 109 + * will enable it for hubs. 110 + */ 111 + usb_disable_autosuspend(udev); 112 + 113 + /* Autosuspend can also be disabled if the initial autosuspend_delay 114 + * is negative. 115 + */ 116 + if (udev->autosuspend_delay < 0) 117 + usb_autoresume_device(udev); 118 + 119 #endif 120 121 /* For the present, all devices default to USB-PERSIST enabled */ ··· 120 * for all devices. It will affect things like hub resets 121 * and EMF-related port disables. 122 */ 123 + if (!(udev->quirks & USB_QUIRK_RESET_MORPHS)) 124 + udev->persist_enabled = 1; 125 #endif /* CONFIG_PM */ 126 }
+61 -24
drivers/usb/core/sysfs.c
··· 115 case USB_SPEED_HIGH: 116 speed = "480"; 117 break; 118 - case USB_SPEED_VARIABLE: 119 speed = "480"; 120 break; 121 case USB_SPEED_SUPER: ··· 191 static DEVICE_ATTR(quirks, S_IRUGO, show_quirks, NULL); 192 193 static ssize_t 194 show_urbnum(struct device *dev, struct device_attribute *attr, char *buf) 195 { 196 struct usb_device *udev; ··· 256 257 if (sscanf(buf, "%d", &value) != 1) 258 return -EINVAL; 259 - usb_pm_lock(udev); 260 udev->persist_enabled = !!value; 261 - usb_pm_unlock(udev); 262 return count; 263 } 264 ··· 346 const char *buf, size_t count) 347 { 348 struct usb_device *udev = to_usb_device(dev); 349 - int value; 350 351 if (sscanf(buf, "%d", &value) != 1 || value >= INT_MAX/HZ || 352 value <= - INT_MAX/HZ) 353 return -EINVAL; 354 value *= HZ; 355 356 udev->autosuspend_delay = value; 357 - if (value >= 0) 358 - usb_try_autosuspend_device(udev); 359 - else { 360 - if (usb_autoresume_device(udev) == 0) 361 usb_autosuspend_device(udev); 362 } 363 return count; 364 } 365 ··· 401 struct usb_device *udev = to_usb_device(dev); 402 int len = count; 403 char *cp; 404 - int rc = 0; 405 - int old_autosuspend_disabled; 406 407 cp = memchr(buf, '\n', count); 408 if (cp) 409 len = cp - buf; 410 411 usb_lock_device(udev); 412 - old_autosuspend_disabled = udev->autosuspend_disabled; 413 414 - /* Setting the flags without calling usb_pm_lock is a subject to 415 - * races, but who cares... 416 - */ 417 if (len == sizeof on_string - 1 && 418 - strncmp(buf, on_string, len) == 0) { 419 - udev->autosuspend_disabled = 1; 420 - rc = usb_external_resume_device(udev, PMSG_USER_RESUME); 421 422 - } else if (len == sizeof auto_string - 1 && 423 - strncmp(buf, auto_string, len) == 0) { 424 - udev->autosuspend_disabled = 0; 425 - rc = usb_external_resume_device(udev, PMSG_USER_RESUME); 426 427 - } else 428 rc = -EINVAL; 429 430 - if (rc) 431 - udev->autosuspend_disabled = old_autosuspend_disabled; 432 usb_unlock_device(udev); 433 return (rc < 0 ? rc : count); 434 } ··· 594 &dev_attr_version.attr, 595 &dev_attr_maxchild.attr, 596 &dev_attr_quirks.attr, 597 &dev_attr_authorized.attr, 598 &dev_attr_remove.attr, 599 NULL,
··· 115 case USB_SPEED_HIGH: 116 speed = "480"; 117 break; 118 + case USB_SPEED_WIRELESS: 119 speed = "480"; 120 break; 121 case USB_SPEED_SUPER: ··· 191 static DEVICE_ATTR(quirks, S_IRUGO, show_quirks, NULL); 192 193 static ssize_t 194 + show_avoid_reset_quirk(struct device *dev, struct device_attribute *attr, char *buf) 195 + { 196 + struct usb_device *udev; 197 + 198 + udev = to_usb_device(dev); 199 + return sprintf(buf, "%d\n", !!(udev->quirks & USB_QUIRK_RESET_MORPHS)); 200 + } 201 + 202 + static ssize_t 203 + set_avoid_reset_quirk(struct device *dev, struct device_attribute *attr, 204 + const char *buf, size_t count) 205 + { 206 + struct usb_device *udev = to_usb_device(dev); 207 + int config; 208 + 209 + if (sscanf(buf, "%d", &config) != 1 || config < 0 || config > 1) 210 + return -EINVAL; 211 + usb_lock_device(udev); 212 + if (config) 213 + udev->quirks |= USB_QUIRK_RESET_MORPHS; 214 + else 215 + udev->quirks &= ~USB_QUIRK_RESET_MORPHS; 216 + usb_unlock_device(udev); 217 + return count; 218 + } 219 + 220 + static DEVICE_ATTR(avoid_reset_quirk, S_IRUGO | S_IWUSR, 221 + show_avoid_reset_quirk, set_avoid_reset_quirk); 222 + 223 + static ssize_t 224 show_urbnum(struct device *dev, struct device_attribute *attr, char *buf) 225 { 226 struct usb_device *udev; ··· 226 227 if (sscanf(buf, "%d", &value) != 1) 228 return -EINVAL; 229 + 230 + usb_lock_device(udev); 231 udev->persist_enabled = !!value; 232 + usb_unlock_device(udev); 233 return count; 234 } 235 ··· 315 const char *buf, size_t count) 316 { 317 struct usb_device *udev = to_usb_device(dev); 318 + int value, old_delay; 319 + int rc; 320 321 if (sscanf(buf, "%d", &value) != 1 || value >= INT_MAX/HZ || 322 value <= - INT_MAX/HZ) 323 return -EINVAL; 324 value *= HZ; 325 326 + usb_lock_device(udev); 327 + old_delay = udev->autosuspend_delay; 328 udev->autosuspend_delay = value; 329 + 330 + if (old_delay < 0) { /* Autosuspend wasn't allowed */ 331 + if (value >= 0) 332 usb_autosuspend_device(udev); 333 + } else { /* Autosuspend was allowed */ 334 + if (value < 0) { 335 + rc = usb_autoresume_device(udev); 336 + if (rc < 0) { 337 + count = rc; 338 + udev->autosuspend_delay = old_delay; 339 + } 340 + } else { 341 + usb_try_autosuspend_device(udev); 342 + } 343 } 344 + 345 + usb_unlock_device(udev); 346 return count; 347 } 348 ··· 356 struct usb_device *udev = to_usb_device(dev); 357 int len = count; 358 char *cp; 359 + int rc; 360 361 cp = memchr(buf, '\n', count); 362 if (cp) 363 len = cp - buf; 364 365 usb_lock_device(udev); 366 367 if (len == sizeof on_string - 1 && 368 + strncmp(buf, on_string, len) == 0) 369 + rc = usb_disable_autosuspend(udev); 370 371 + else if (len == sizeof auto_string - 1 && 372 + strncmp(buf, auto_string, len) == 0) 373 + rc = usb_enable_autosuspend(udev); 374 375 + else 376 rc = -EINVAL; 377 378 usb_unlock_device(udev); 379 return (rc < 0 ? rc : count); 380 } ··· 558 &dev_attr_version.attr, 559 &dev_attr_maxchild.attr, 560 &dev_attr_quirks.attr, 561 + &dev_attr_avoid_reset_quirk.attr, 562 &dev_attr_authorized.attr, 563 &dev_attr_remove.attr, 564 NULL,
+10 -3
drivers/usb/core/urb.c
··· 387 { 388 unsigned int orig_flags = urb->transfer_flags; 389 unsigned int allowed; 390 391 /* enforce simple/standard policy */ 392 allowed = (URB_NO_TRANSFER_DMA_MAP | URB_NO_SETUP_DMA_MAP | ··· 437 case USB_ENDPOINT_XFER_INT: 438 /* too small? */ 439 switch (dev->speed) { 440 - case USB_SPEED_VARIABLE: 441 if (urb->interval < 6) 442 return -EINVAL; 443 break; ··· 453 if (urb->interval > (1 << 15)) 454 return -EINVAL; 455 max = 1 << 15; 456 - case USB_SPEED_VARIABLE: 457 if (urb->interval > 16) 458 return -EINVAL; 459 break; ··· 480 default: 481 return -EINVAL; 482 } 483 - if (dev->speed != USB_SPEED_VARIABLE) { 484 /* Round down to a power of 2, no more than max */ 485 urb->interval = min(max, 1 << ilog2(urb->interval)); 486 }
··· 387 { 388 unsigned int orig_flags = urb->transfer_flags; 389 unsigned int allowed; 390 + static int pipetypes[4] = { 391 + PIPE_CONTROL, PIPE_ISOCHRONOUS, PIPE_BULK, PIPE_INTERRUPT 392 + }; 393 + 394 + /* Check that the pipe's type matches the endpoint's type */ 395 + if (usb_pipetype(urb->pipe) != pipetypes[xfertype]) 396 + return -EPIPE; /* The most suitable error code :-) */ 397 398 /* enforce simple/standard policy */ 399 allowed = (URB_NO_TRANSFER_DMA_MAP | URB_NO_SETUP_DMA_MAP | ··· 430 case USB_ENDPOINT_XFER_INT: 431 /* too small? */ 432 switch (dev->speed) { 433 + case USB_SPEED_WIRELESS: 434 if (urb->interval < 6) 435 return -EINVAL; 436 break; ··· 446 if (urb->interval > (1 << 15)) 447 return -EINVAL; 448 max = 1 << 15; 449 + case USB_SPEED_WIRELESS: 450 if (urb->interval > 16) 451 return -EINVAL; 452 break; ··· 473 default: 474 return -EINVAL; 475 } 476 + if (dev->speed != USB_SPEED_WIRELESS) { 477 /* Round down to a power of 2, no more than max */ 478 urb->interval = min(max, 1 << ilog2(urb->interval)); 479 }
+3 -35
drivers/usb/core/usb.c
··· 49 50 static int nousb; /* Disable USB when built into kernel image */ 51 52 - /* Workqueue for autosuspend and for remote wakeup of root hubs */ 53 - struct workqueue_struct *ksuspend_usb_wq; 54 - 55 #ifdef CONFIG_USB_SUSPEND 56 static int usb_autosuspend_delay = 2; /* Default delay value, 57 * in seconds */ ··· 225 hcd = bus_to_hcd(udev->bus); 226 227 usb_destroy_configuration(udev); 228 - /* Root hubs aren't real devices, so don't free HCD resources */ 229 - if (hcd->driver->free_dev && udev->parent) 230 - hcd->driver->free_dev(hcd, udev); 231 usb_put_hcd(hcd); 232 kfree(udev->product); 233 kfree(udev->manufacturer); ··· 258 259 #ifdef CONFIG_PM 260 261 - static int ksuspend_usb_init(void) 262 - { 263 - /* This workqueue is supposed to be both freezable and 264 - * singlethreaded. Its job doesn't justify running on more 265 - * than one CPU. 266 - */ 267 - ksuspend_usb_wq = create_freezeable_workqueue("ksuspend_usbd"); 268 - if (!ksuspend_usb_wq) 269 - return -ENOMEM; 270 - return 0; 271 - } 272 - 273 - static void ksuspend_usb_cleanup(void) 274 - { 275 - destroy_workqueue(ksuspend_usb_wq); 276 - } 277 - 278 /* USB device Power-Management thunks. 279 * There's no need to distinguish here between quiescing a USB device 280 * and powering it down; the generic_suspend() routine takes care of ··· 273 static void usb_dev_complete(struct device *dev) 274 { 275 /* Currently used only for rebinding interfaces */ 276 - usb_resume(dev, PMSG_RESUME); /* Message event is meaningless */ 277 } 278 279 static int usb_dev_suspend(struct device *dev) ··· 319 320 #else 321 322 - #define ksuspend_usb_init() 0 323 - #define ksuspend_usb_cleanup() do {} while (0) 324 - #define usb_device_pm_ops (*(struct dev_pm_ops *)0) 325 326 #endif /* CONFIG_PM */ 327 ··· 447 INIT_LIST_HEAD(&dev->filelist); 448 449 #ifdef CONFIG_PM 450 - mutex_init(&dev->pm_mutex); 451 - INIT_DELAYED_WORK(&dev->autosuspend, usb_autosuspend_work); 452 - INIT_WORK(&dev->autoresume, usb_autoresume_work); 453 dev->autosuspend_delay = usb_autosuspend_delay * HZ; 454 dev->connect_time = jiffies; 455 dev->active_duration = -jiffies; ··· 1089 if (retval) 1090 goto out; 1091 1092 - retval = ksuspend_usb_init(); 1093 - if (retval) 1094 - goto out; 1095 retval = bus_register(&usb_bus_type); 1096 if (retval) 1097 goto bus_register_failed; ··· 1128 bus_notifier_failed: 1129 bus_unregister(&usb_bus_type); 1130 bus_register_failed: 1131 - ksuspend_usb_cleanup(); 1132 out: 1133 return retval; 1134 } ··· 1150 usb_hub_cleanup(); 1151 bus_unregister_notifier(&usb_bus_type, &usb_bus_nb); 1152 bus_unregister(&usb_bus_type); 1153 - ksuspend_usb_cleanup(); 1154 usb_debugfs_cleanup(); 1155 } 1156
··· 49 50 static int nousb; /* Disable USB when built into kernel image */ 51 52 #ifdef CONFIG_USB_SUSPEND 53 static int usb_autosuspend_delay = 2; /* Default delay value, 54 * in seconds */ ··· 228 hcd = bus_to_hcd(udev->bus); 229 230 usb_destroy_configuration(udev); 231 usb_put_hcd(hcd); 232 kfree(udev->product); 233 kfree(udev->manufacturer); ··· 264 265 #ifdef CONFIG_PM 266 267 /* USB device Power-Management thunks. 268 * There's no need to distinguish here between quiescing a USB device 269 * and powering it down; the generic_suspend() routine takes care of ··· 296 static void usb_dev_complete(struct device *dev) 297 { 298 /* Currently used only for rebinding interfaces */ 299 + usb_resume(dev, PMSG_ON); /* FIXME: change to PMSG_COMPLETE */ 300 } 301 302 static int usb_dev_suspend(struct device *dev) ··· 342 343 #else 344 345 + #define usb_device_pm_ops (*(struct dev_pm_ops *) NULL) 346 347 #endif /* CONFIG_PM */ 348 ··· 472 INIT_LIST_HEAD(&dev->filelist); 473 474 #ifdef CONFIG_PM 475 dev->autosuspend_delay = usb_autosuspend_delay * HZ; 476 dev->connect_time = jiffies; 477 dev->active_duration = -jiffies; ··· 1117 if (retval) 1118 goto out; 1119 1120 retval = bus_register(&usb_bus_type); 1121 if (retval) 1122 goto bus_register_failed; ··· 1159 bus_notifier_failed: 1160 bus_unregister(&usb_bus_type); 1161 bus_register_failed: 1162 + usb_debugfs_cleanup(); 1163 out: 1164 return retval; 1165 } ··· 1181 usb_hub_cleanup(); 1182 bus_unregister_notifier(&usb_bus_type, &usb_bus_nb); 1183 bus_unregister(&usb_bus_type); 1184 usb_debugfs_cleanup(); 1185 } 1186
+6 -37
drivers/usb/core/usb.h
··· 55 extern int usb_suspend(struct device *dev, pm_message_t msg); 56 extern int usb_resume(struct device *dev, pm_message_t msg); 57 58 - extern void usb_autosuspend_work(struct work_struct *work); 59 - extern void usb_autoresume_work(struct work_struct *work); 60 extern int usb_port_suspend(struct usb_device *dev, pm_message_t msg); 61 extern int usb_port_resume(struct usb_device *dev, pm_message_t msg); 62 - extern int usb_external_suspend_device(struct usb_device *udev, 63 - pm_message_t msg); 64 - extern int usb_external_resume_device(struct usb_device *udev, 65 - pm_message_t msg); 66 - 67 - static inline void usb_pm_lock(struct usb_device *udev) 68 - { 69 - mutex_lock_nested(&udev->pm_mutex, udev->level); 70 - } 71 - 72 - static inline void usb_pm_unlock(struct usb_device *udev) 73 - { 74 - mutex_unlock(&udev->pm_mutex); 75 - } 76 77 #else 78 ··· 70 return 0; 71 } 72 73 - static inline void usb_pm_lock(struct usb_device *udev) {} 74 - static inline void usb_pm_unlock(struct usb_device *udev) {} 75 - 76 #endif 77 78 #ifdef CONFIG_USB_SUSPEND ··· 77 extern void usb_autosuspend_device(struct usb_device *udev); 78 extern void usb_try_autosuspend_device(struct usb_device *udev); 79 extern int usb_autoresume_device(struct usb_device *udev); 80 81 #else 82 ··· 88 return 0; 89 } 90 91 #endif 92 93 - extern struct workqueue_struct *ksuspend_usb_wq; 94 extern struct bus_type usb_bus_type; 95 extern struct device_type usb_device_type; 96 extern struct device_type usb_if_device_type; ··· 122 { 123 return container_of(drv, struct usbdrv_wrap, driver)-> 124 for_devices; 125 - } 126 - 127 - /* Interfaces and their "power state" are owned by usbcore */ 128 - 129 - static inline void mark_active(struct usb_interface *f) 130 - { 131 - f->is_active = 1; 132 - } 133 - 134 - static inline void mark_quiesced(struct usb_interface *f) 135 - { 136 - f->is_active = 0; 137 - } 138 - 139 - static inline int is_active(const struct usb_interface *f) 140 - { 141 - return f->is_active; 142 } 143 144
··· 55 extern int usb_suspend(struct device *dev, pm_message_t msg); 56 extern int usb_resume(struct device *dev, pm_message_t msg); 57 58 extern int usb_port_suspend(struct usb_device *dev, pm_message_t msg); 59 extern int usb_port_resume(struct usb_device *dev, pm_message_t msg); 60 61 #else 62 ··· 86 return 0; 87 } 88 89 #endif 90 91 #ifdef CONFIG_USB_SUSPEND ··· 96 extern void usb_autosuspend_device(struct usb_device *udev); 97 extern void usb_try_autosuspend_device(struct usb_device *udev); 98 extern int usb_autoresume_device(struct usb_device *udev); 99 + extern int usb_remote_wakeup(struct usb_device *dev); 100 101 #else 102 ··· 106 return 0; 107 } 108 109 + static inline int usb_remote_wakeup(struct usb_device *udev) 110 + { 111 + return 0; 112 + } 113 + 114 #endif 115 116 extern struct bus_type usb_bus_type; 117 extern struct device_type usb_device_type; 118 extern struct device_type usb_if_device_type; ··· 136 { 137 return container_of(drv, struct usbdrv_wrap, driver)-> 138 for_devices; 139 } 140 141
+28 -40
drivers/usb/early/ehci-dbgp.c
··· 66 67 #define USB_DEBUG_DEVNUM 127 68 69 - #define DBGP_DATA_TOGGLE 0x8800 70 - 71 #ifdef DBGP_DEBUG 72 #define dbgp_printk printk 73 static void dbgp_ehci_status(char *str) ··· 85 static inline void dbgp_ehci_status(char *str) { } 86 static inline void dbgp_printk(const char *fmt, ...) { } 87 #endif 88 - 89 - static inline u32 dbgp_pid_update(u32 x, u32 tok) 90 - { 91 - return ((x ^ DBGP_DATA_TOGGLE) & 0xffff00) | (tok & 0xff); 92 - } 93 94 static inline u32 dbgp_len_update(u32 x, u32 len) 95 { ··· 129 130 #define DBGP_MAX_PACKET 8 131 #define DBGP_TIMEOUT (250 * 1000) 132 133 static int dbgp_wait_until_complete(void) 134 { ··· 186 { 187 u32 pids, lpid; 188 int ret; 189 - int loop = 3; 190 191 retry: 192 writel(ctrl | DBGP_GO, &ehci_debug->control); ··· 203 */ 204 if (ret == -DBGP_TIMEOUT && !dbgp_not_safe) 205 dbgp_not_safe = 1; 206 return ret; 207 } 208 ··· 253 bytes[i] = (hi >> (8*(i - 4))) & 0xff; 254 } 255 256 - static int dbgp_out(u32 addr, const char *bytes, int size) 257 { 258 u32 pids, ctrl; 259 260 pids = readl(&ehci_debug->pids); 261 - pids = dbgp_pid_update(pids, USB_PID_OUT); 262 263 ctrl = readl(&ehci_debug->control); 264 ctrl = dbgp_len_update(ctrl, size); ··· 276 dbgp_set_data(bytes, size); 277 writel(addr, &ehci_debug->address); 278 writel(pids, &ehci_debug->pids); 279 - return dbgp_wait_until_done(ctrl); 280 - } 281 - 282 - static int dbgp_bulk_write(unsigned devnum, unsigned endpoint, 283 - const char *bytes, int size) 284 - { 285 - int ret; 286 - int loops = 5; 287 - u32 addr; 288 - if (size > DBGP_MAX_PACKET) 289 - return -1; 290 - 291 - addr = DBGP_EPADDR(devnum, endpoint); 292 - try_again: 293 - if (loops--) { 294 - ret = dbgp_out(addr, bytes, size); 295 - if (ret == -DBGP_ERR_BAD) { 296 - int try_loops = 3; 297 - do { 298 - /* Emit a dummy packet to re-sync communication 299 - * with the debug device */ 300 - if (dbgp_out(addr, "12345678", 8) >= 0) { 301 - udelay(2); 302 - goto try_again; 303 - } 304 - } while (try_loops--); 305 - } 306 - } 307 308 return ret; 309 } ··· 293 addr = DBGP_EPADDR(devnum, endpoint); 294 295 pids = readl(&ehci_debug->pids); 296 - pids = dbgp_pid_update(pids, USB_PID_IN); 297 298 ctrl = readl(&ehci_debug->control); 299 ctrl = dbgp_len_update(ctrl, size); ··· 350 /* Read the result */ 351 return dbgp_bulk_read(devnum, 0, data, size); 352 } 353 - 354 355 /* Find a PCI capability */ 356 static u32 __init find_cap(u32 num, u32 slot, u32 func, int cap)
··· 66 67 #define USB_DEBUG_DEVNUM 127 68 69 #ifdef DBGP_DEBUG 70 #define dbgp_printk printk 71 static void dbgp_ehci_status(char *str) ··· 87 static inline void dbgp_ehci_status(char *str) { } 88 static inline void dbgp_printk(const char *fmt, ...) { } 89 #endif 90 91 static inline u32 dbgp_len_update(u32 x, u32 len) 92 { ··· 136 137 #define DBGP_MAX_PACKET 8 138 #define DBGP_TIMEOUT (250 * 1000) 139 + #define DBGP_LOOPS 1000 140 + 141 + static inline u32 dbgp_pid_write_update(u32 x, u32 tok) 142 + { 143 + static int data0 = USB_PID_DATA1; 144 + data0 ^= USB_PID_DATA_TOGGLE; 145 + return (x & 0xffff0000) | (data0 << 8) | (tok & 0xff); 146 + } 147 + 148 + static inline u32 dbgp_pid_read_update(u32 x, u32 tok) 149 + { 150 + return (x & 0xffff0000) | (USB_PID_DATA0 << 8) | (tok & 0xff); 151 + } 152 153 static int dbgp_wait_until_complete(void) 154 { ··· 180 { 181 u32 pids, lpid; 182 int ret; 183 + int loop = DBGP_LOOPS; 184 185 retry: 186 writel(ctrl | DBGP_GO, &ehci_debug->control); ··· 197 */ 198 if (ret == -DBGP_TIMEOUT && !dbgp_not_safe) 199 dbgp_not_safe = 1; 200 + if (ret == -DBGP_ERR_BAD && --loop > 0) 201 + goto retry; 202 return ret; 203 } 204 ··· 245 bytes[i] = (hi >> (8*(i - 4))) & 0xff; 246 } 247 248 + static int dbgp_bulk_write(unsigned devnum, unsigned endpoint, 249 + const char *bytes, int size) 250 { 251 + int ret; 252 + u32 addr; 253 u32 pids, ctrl; 254 255 + if (size > DBGP_MAX_PACKET) 256 + return -1; 257 + 258 + addr = DBGP_EPADDR(devnum, endpoint); 259 + 260 pids = readl(&ehci_debug->pids); 261 + pids = dbgp_pid_write_update(pids, USB_PID_OUT); 262 263 ctrl = readl(&ehci_debug->control); 264 ctrl = dbgp_len_update(ctrl, size); ··· 260 dbgp_set_data(bytes, size); 261 writel(addr, &ehci_debug->address); 262 writel(pids, &ehci_debug->pids); 263 + ret = dbgp_wait_until_done(ctrl); 264 265 return ret; 266 } ··· 304 addr = DBGP_EPADDR(devnum, endpoint); 305 306 pids = readl(&ehci_debug->pids); 307 + pids = dbgp_pid_read_update(pids, USB_PID_IN); 308 309 ctrl = readl(&ehci_debug->control); 310 ctrl = dbgp_len_update(ctrl, size); ··· 361 /* Read the result */ 362 return dbgp_bulk_read(devnum, 0, data, size); 363 } 364 365 /* Find a PCI capability */ 366 static u32 __init find_cap(u32 num, u32 slot, u32 func, int cap)
+10
drivers/usb/gadget/Kconfig
··· 812 Say "y" to link the driver statically, or "m" to build a 813 dynamically linked module. 814 815 config USB_G_MULTI 816 tristate "Multifunction Composite Gadget (EXPERIMENTAL)" 817 depends on BLOCK && NET
··· 812 Say "y" to link the driver statically, or "m" to build a 813 dynamically linked module. 814 815 + config USB_G_NOKIA 816 + tristate "Nokia composite gadget" 817 + depends on PHONET 818 + help 819 + The Nokia composite gadget provides support for acm, obex 820 + and phonet in only one composite gadget driver. 821 + 822 + It's only really useful for N900 hardware. If you're building 823 + a kernel for N900, say Y or M here. If unsure, say N. 824 + 825 config USB_G_MULTI 826 tristate "Multifunction Composite Gadget (EXPERIMENTAL)" 827 depends on BLOCK && NET
+2
drivers/usb/gadget/Makefile
··· 43 g_printer-objs := printer.o 44 g_cdc-objs := cdc2.o 45 g_multi-objs := multi.o 46 47 obj-$(CONFIG_USB_ZERO) += g_zero.o 48 obj-$(CONFIG_USB_AUDIO) += g_audio.o ··· 56 obj-$(CONFIG_USB_MIDI_GADGET) += g_midi.o 57 obj-$(CONFIG_USB_CDC_COMPOSITE) += g_cdc.o 58 obj-$(CONFIG_USB_G_MULTI) += g_multi.o 59
··· 43 g_printer-objs := printer.o 44 g_cdc-objs := cdc2.o 45 g_multi-objs := multi.o 46 + g_nokia-objs := nokia.o 47 48 obj-$(CONFIG_USB_ZERO) += g_zero.o 49 obj-$(CONFIG_USB_AUDIO) += g_audio.o ··· 55 obj-$(CONFIG_USB_MIDI_GADGET) += g_midi.o 56 obj-$(CONFIG_USB_CDC_COMPOSITE) += g_cdc.o 57 obj-$(CONFIG_USB_G_MULTI) += g_multi.o 58 + obj-$(CONFIG_USB_G_NOKIA) += g_nokia.o 59
+4 -6
drivers/usb/gadget/at91_udc.c
··· 1656 if (!res) 1657 return -ENXIO; 1658 1659 - if (!request_mem_region(res->start, 1660 - res->end - res->start + 1, 1661 - driver_name)) { 1662 DBG("someone's using UDC memory\n"); 1663 return -EBUSY; 1664 } ··· 1697 udc->ep[3].maxpacket = 64; 1698 } 1699 1700 - udc->udp_baseaddr = ioremap(res->start, res->end - res->start + 1); 1701 if (!udc->udp_baseaddr) { 1702 retval = -ENOMEM; 1703 goto fail0a; ··· 1779 if (cpu_is_at91rm9200()) 1780 gpio_free(udc->board.pullup_pin); 1781 fail0: 1782 - release_mem_region(res->start, res->end - res->start + 1); 1783 DBG("%s probe failed, %d\n", driver_name, retval); 1784 return retval; 1785 } ··· 1811 gpio_free(udc->board.pullup_pin); 1812 1813 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1814 - release_mem_region(res->start, res->end - res->start + 1); 1815 1816 clk_put(udc->iclk); 1817 clk_put(udc->fclk);
··· 1656 if (!res) 1657 return -ENXIO; 1658 1659 + if (!request_mem_region(res->start, resource_size(res), driver_name)) { 1660 DBG("someone's using UDC memory\n"); 1661 return -EBUSY; 1662 } ··· 1699 udc->ep[3].maxpacket = 64; 1700 } 1701 1702 + udc->udp_baseaddr = ioremap(res->start, resource_size(res)); 1703 if (!udc->udp_baseaddr) { 1704 retval = -ENOMEM; 1705 goto fail0a; ··· 1781 if (cpu_is_at91rm9200()) 1782 gpio_free(udc->board.pullup_pin); 1783 fail0: 1784 + release_mem_region(res->start, resource_size(res)); 1785 DBG("%s probe failed, %d\n", driver_name, retval); 1786 return retval; 1787 } ··· 1813 gpio_free(udc->board.pullup_pin); 1814 1815 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1816 + release_mem_region(res->start, resource_size(res)); 1817 1818 clk_put(udc->iclk); 1819 clk_put(udc->fclk);
+5 -4
drivers/usb/gadget/atmel_usba_udc.c
··· 320 static int vbus_is_present(struct usba_udc *udc) 321 { 322 if (gpio_is_valid(udc->vbus_pin)) 323 - return gpio_get_value(udc->vbus_pin); 324 325 /* No Vbus detection: Assume always present */ 326 return 1; ··· 1763 if (!udc->driver) 1764 goto out; 1765 1766 - vbus = gpio_get_value(udc->vbus_pin); 1767 if (vbus != udc->vbus_prev) { 1768 if (vbus) { 1769 toggle_bias(1); ··· 1914 udc->vbus_pin = -ENODEV; 1915 1916 ret = -ENOMEM; 1917 - udc->regs = ioremap(regs->start, regs->end - regs->start + 1); 1918 if (!udc->regs) { 1919 dev_err(&pdev->dev, "Unable to map I/O memory, aborting.\n"); 1920 goto err_map_regs; 1921 } 1922 dev_info(&pdev->dev, "MMIO registers at 0x%08lx mapped at %p\n", 1923 (unsigned long)regs->start, udc->regs); 1924 - udc->fifo = ioremap(fifo->start, fifo->end - fifo->start + 1); 1925 if (!udc->fifo) { 1926 dev_err(&pdev->dev, "Unable to map FIFO, aborting.\n"); 1927 goto err_map_fifo; ··· 2000 if (gpio_is_valid(pdata->vbus_pin)) { 2001 if (!gpio_request(pdata->vbus_pin, "atmel_usba_udc")) { 2002 udc->vbus_pin = pdata->vbus_pin; 2003 2004 ret = request_irq(gpio_to_irq(udc->vbus_pin), 2005 usba_vbus_irq, 0,
··· 320 static int vbus_is_present(struct usba_udc *udc) 321 { 322 if (gpio_is_valid(udc->vbus_pin)) 323 + return gpio_get_value(udc->vbus_pin) ^ udc->vbus_pin_inverted; 324 325 /* No Vbus detection: Assume always present */ 326 return 1; ··· 1763 if (!udc->driver) 1764 goto out; 1765 1766 + vbus = vbus_is_present(udc); 1767 if (vbus != udc->vbus_prev) { 1768 if (vbus) { 1769 toggle_bias(1); ··· 1914 udc->vbus_pin = -ENODEV; 1915 1916 ret = -ENOMEM; 1917 + udc->regs = ioremap(regs->start, resource_size(regs)); 1918 if (!udc->regs) { 1919 dev_err(&pdev->dev, "Unable to map I/O memory, aborting.\n"); 1920 goto err_map_regs; 1921 } 1922 dev_info(&pdev->dev, "MMIO registers at 0x%08lx mapped at %p\n", 1923 (unsigned long)regs->start, udc->regs); 1924 + udc->fifo = ioremap(fifo->start, resource_size(fifo)); 1925 if (!udc->fifo) { 1926 dev_err(&pdev->dev, "Unable to map FIFO, aborting.\n"); 1927 goto err_map_fifo; ··· 2000 if (gpio_is_valid(pdata->vbus_pin)) { 2001 if (!gpio_request(pdata->vbus_pin, "atmel_usba_udc")) { 2002 udc->vbus_pin = pdata->vbus_pin; 2003 + udc->vbus_pin_inverted = pdata->vbus_pin_inverted; 2004 2005 ret = request_irq(gpio_to_irq(udc->vbus_pin), 2006 usba_vbus_irq, 0,
+1
drivers/usb/gadget/atmel_usba_udc.h
··· 323 struct platform_device *pdev; 324 int irq; 325 int vbus_pin; 326 struct clk *pclk; 327 struct clk *hclk; 328
··· 323 struct platform_device *pdev; 324 int irq; 325 int vbus_pin; 326 + int vbus_pin_inverted; 327 struct clk *pclk; 328 struct clk *hclk; 329
+16 -8
drivers/usb/gadget/epautoconf.c
··· 265 return ep; 266 } 267 268 - } else if (gadget_is_sh (gadget) && USB_ENDPOINT_XFER_INT == type) { 269 - /* single buffering is enough; maybe 8 byte fifo is too */ 270 - ep = find_ep (gadget, "ep3in-bulk"); 271 if (ep && ep_matches (gadget, ep, desc)) 272 return ep; 273 - 274 - } else if (gadget_is_mq11xx (gadget) && USB_ENDPOINT_XFER_INT == type) { 275 - ep = find_ep (gadget, "ep1-bulk"); 276 - if (ep && ep_matches (gadget, ep, desc)) 277 - return ep; 278 } 279 280 /* Second, look at endpoints until an unclaimed one looks usable */
··· 265 return ep; 266 } 267 268 + #ifdef CONFIG_BLACKFIN 269 + } else if (gadget_is_musbhsfc(gadget) || gadget_is_musbhdrc(gadget)) { 270 + if ((USB_ENDPOINT_XFER_BULK == type) || 271 + (USB_ENDPOINT_XFER_ISOC == type)) { 272 + if (USB_DIR_IN & desc->bEndpointAddress) 273 + ep = find_ep (gadget, "ep5in"); 274 + else 275 + ep = find_ep (gadget, "ep6out"); 276 + } else if (USB_ENDPOINT_XFER_INT == type) { 277 + if (USB_DIR_IN & desc->bEndpointAddress) 278 + ep = find_ep(gadget, "ep1in"); 279 + else 280 + ep = find_ep(gadget, "ep2out"); 281 + } else 282 + ep = NULL; 283 if (ep && ep_matches (gadget, ep, desc)) 284 return ep; 285 + #endif 286 } 287 288 /* Second, look at endpoints until an unclaimed one looks usable */
+1 -1
drivers/usb/gadget/ether.c
··· 259 260 /*-------------------------------------------------------------------------*/ 261 262 - #ifdef USB_ETH_EEM 263 static int use_eem = 1; 264 #else 265 static int use_eem;
··· 259 260 /*-------------------------------------------------------------------------*/ 261 262 + #ifdef CONFIG_USB_ETH_EEM 263 static int use_eem = 1; 264 #else 265 static int use_eem;
-8
drivers/usb/gadget/f_acm.c
··· 702 /* Some controllers can't support CDC ACM ... */ 703 static inline bool can_support_cdc(struct usb_configuration *c) 704 { 705 - /* SH3 doesn't support multiple interfaces */ 706 - if (gadget_is_sh(c->cdev->gadget)) 707 - return false; 708 - 709 - /* sa1100 doesn't have a third interrupt endpoint */ 710 - if (gadget_is_sa1100(c->cdev->gadget)) 711 - return false; 712 - 713 /* everything else is *probably* fine ... */ 714 return true; 715 }
··· 702 /* Some controllers can't support CDC ACM ... */ 703 static inline bool can_support_cdc(struct usb_configuration *c) 704 { 705 /* everything else is *probably* fine ... */ 706 return true; 707 }
+2 -5
drivers/usb/gadget/f_ecm.c
··· 497 struct net_device *net; 498 499 /* Enable zlps by default for ECM conformance; 500 - * override for musb_hdrc (avoids txdma ovhead) 501 - * and sa1100 (can't). 502 */ 503 - ecm->port.is_zlp_ok = !( 504 - gadget_is_sa1100(cdev->gadget) 505 - || gadget_is_musbhdrc(cdev->gadget) 506 ); 507 ecm->port.cdc_filter = DEFAULT_FILTER; 508 DBG(cdev, "activate ecm\n");
··· 497 struct net_device *net; 498 499 /* Enable zlps by default for ECM conformance; 500 + * override for musb_hdrc (avoids txdma ovhead). 501 */ 502 + ecm->port.is_zlp_ok = !(gadget_is_musbhdrc(cdev->gadget) 503 ); 504 ecm->port.cdc_filter = DEFAULT_FILTER; 505 DBG(cdev, "activate ecm\n");
+29 -21
drivers/usb/gadget/f_mass_storage.c
··· 368 struct task_struct *thread_task; 369 370 /* Callback function to call when thread exits. */ 371 - void (*thread_exits)(struct fsg_common *common); 372 /* Gadget's private data. */ 373 void *private_data; 374 ··· 392 const char *lun_name_format; 393 const char *thread_name; 394 395 - /* Callback function to call when thread exits. */ 396 - void (*thread_exits)(struct fsg_common *common); 397 /* Gadget's private data. */ 398 void *private_data; 399 ··· 618 return -EDOM; 619 VDBG(fsg, "get max LUN\n"); 620 *(u8 *) req->buf = fsg->common->nluns - 1; 621 - return 1; 622 } 623 624 VDBG(fsg, ··· 2533 2534 case FSG_STATE_CONFIG_CHANGE: 2535 rc = do_set_config(common, new_config); 2536 - if (common->ep0_req_tag != exception_req_tag) 2537 - break; 2538 - if (rc != 0) { /* STALL on errors */ 2539 - DBG(common, "ep0 set halt\n"); 2540 - usb_ep_set_halt(common->ep0); 2541 - } else { /* Complete the status stage */ 2542 - ep0_queue(common); 2543 - } 2544 break; 2545 2546 case FSG_STATE_EXIT: ··· 2616 common->thread_task = NULL; 2617 spin_unlock_irq(&common->lock); 2618 2619 - if (common->thread_exits) 2620 - common->thread_exits(common); 2621 2622 /* Let the unbind and cleanup routines know the thread has exited */ 2623 complete_and_exit(&common->thread_notifier, 0); ··· 2776 if (cfg->release != 0xffff) { 2777 i = cfg->release; 2778 } else { 2779 - /* The sa1100 controller is not supported */ 2780 - i = gadget_is_sa1100(gadget) 2781 - ? -1 2782 - : usb_gadget_controller_number(gadget); 2783 if (i >= 0) { 2784 i = 0x0300 + i; 2785 } else { ··· 2801 * disable stalls. 2802 */ 2803 common->can_stall = cfg->can_stall && 2804 - !(gadget_is_sh(common->gadget) || 2805 - gadget_is_at91(common->gadget)); 2806 2807 2808 spin_lock_init(&common->lock); ··· 2861 /* Call fsg_common_release() directly, ref might be not 2862 * initialised */ 2863 fsg_common_release(&common->ref); 2864 - complete(&common->thread_notifier); 2865 return ERR_PTR(rc); 2866 } 2867
··· 368 struct task_struct *thread_task; 369 370 /* Callback function to call when thread exits. */ 371 + int (*thread_exits)(struct fsg_common *common); 372 /* Gadget's private data. */ 373 void *private_data; 374 ··· 392 const char *lun_name_format; 393 const char *thread_name; 394 395 + /* Callback function to call when thread exits. If no 396 + * callback is set or it returns value lower then zero MSF 397 + * will force eject all LUNs it operates on (including those 398 + * marked as non-removable or with prevent_medium_removal flag 399 + * set). */ 400 + int (*thread_exits)(struct fsg_common *common); 401 /* Gadget's private data. */ 402 void *private_data; 403 ··· 614 return -EDOM; 615 VDBG(fsg, "get max LUN\n"); 616 *(u8 *) req->buf = fsg->common->nluns - 1; 617 + 618 + /* Respond with data/status */ 619 + req->length = min((u16)1, w_length); 620 + fsg->common->ep0req_name = 621 + ctrl->bRequestType & USB_DIR_IN ? "ep0-in" : "ep0-out"; 622 + return ep0_queue(fsg->common); 623 } 624 625 VDBG(fsg, ··· 2524 2525 case FSG_STATE_CONFIG_CHANGE: 2526 rc = do_set_config(common, new_config); 2527 break; 2528 2529 case FSG_STATE_EXIT: ··· 2615 common->thread_task = NULL; 2616 spin_unlock_irq(&common->lock); 2617 2618 + if (!common->thread_exits || common->thread_exits(common) < 0) { 2619 + struct fsg_lun *curlun = common->luns; 2620 + unsigned i = common->nluns; 2621 + 2622 + down_write(&common->filesem); 2623 + for (; i--; ++curlun) { 2624 + if (!fsg_lun_is_open(curlun)) 2625 + continue; 2626 + 2627 + fsg_lun_close(curlun); 2628 + curlun->unit_attention_data = SS_MEDIUM_NOT_PRESENT; 2629 + } 2630 + up_write(&common->filesem); 2631 + } 2632 2633 /* Let the unbind and cleanup routines know the thread has exited */ 2634 complete_and_exit(&common->thread_notifier, 0); ··· 2763 if (cfg->release != 0xffff) { 2764 i = cfg->release; 2765 } else { 2766 + i = usb_gadget_controller_number(gadget); 2767 if (i >= 0) { 2768 i = 0x0300 + i; 2769 } else { ··· 2791 * disable stalls. 2792 */ 2793 common->can_stall = cfg->can_stall && 2794 + !(gadget_is_at91(common->gadget)); 2795 2796 2797 spin_lock_init(&common->lock); ··· 2852 /* Call fsg_common_release() directly, ref might be not 2853 * initialised */ 2854 fsg_common_release(&common->ref); 2855 return ERR_PTR(rc); 2856 } 2857
-4
drivers/usb/gadget/f_rndis.c
··· 769 /* Some controllers can't support RNDIS ... */ 770 static inline bool can_support_rndis(struct usb_configuration *c) 771 { 772 - /* only two endpoints on sa1100 */ 773 - if (gadget_is_sa1100(c->cdev->gadget)) 774 - return false; 775 - 776 /* everything else is *presumably* fine */ 777 return true; 778 }
··· 769 /* Some controllers can't support RNDIS ... */ 770 static inline bool can_support_rndis(struct usb_configuration *c) 771 { 772 /* everything else is *presumably* fine */ 773 return true; 774 }
+2 -6
drivers/usb/gadget/file_storage.c
··· 3208 * halt bulk endpoints correctly. If one of them is present, 3209 * disable stalls. 3210 */ 3211 - if (gadget_is_sh(fsg->gadget) || gadget_is_at91(fsg->gadget)) 3212 mod_data.can_stall = 0; 3213 3214 if (mod_data.release == 0xffff) { // Parameter wasn't set 3215 - /* The sa1100 controller is not supported */ 3216 - if (gadget_is_sa1100(fsg->gadget)) 3217 - gcnum = -1; 3218 - else 3219 - gcnum = usb_gadget_controller_number(fsg->gadget); 3220 if (gcnum >= 0) 3221 mod_data.release = 0x0300 + gcnum; 3222 else {
··· 3208 * halt bulk endpoints correctly. If one of them is present, 3209 * disable stalls. 3210 */ 3211 + if (gadget_is_at91(fsg->gadget)) 3212 mod_data.can_stall = 0; 3213 3214 if (mod_data.release == 0xffff) { // Parameter wasn't set 3215 + gcnum = usb_gadget_controller_number(fsg->gadget); 3216 if (gcnum >= 0) 3217 mod_data.release = 0x0300 + gcnum; 3218 else {
+1 -1
drivers/usb/gadget/fsl_qe_udc.c
··· 2749 } 2750 2751 /*-------------------------------------------------------------------------*/ 2752 - static struct of_device_id __devinitdata qe_udc_match[] = { 2753 { 2754 .compatible = "fsl,mpc8323-qe-usb", 2755 .data = (void *)PORT_QE,
··· 2749 } 2750 2751 /*-------------------------------------------------------------------------*/ 2752 + static const struct of_device_id qe_udc_match[] __devinitconst = { 2753 { 2754 .compatible = "fsl,mpc8323-qe-usb", 2755 .data = (void *)PORT_QE,
-59
drivers/usb/gadget/gadget_chips.h
··· 45 #define gadget_is_goku(g) 0 46 #endif 47 48 - /* SH3 UDC -- not yet ported 2.4 --> 2.6 */ 49 - #ifdef CONFIG_USB_GADGET_SUPERH 50 - #define gadget_is_sh(g) !strcmp("sh_udc", (g)->name) 51 - #else 52 - #define gadget_is_sh(g) 0 53 - #endif 54 - 55 - /* not yet stable on 2.6 (would help "original Zaurus") */ 56 - #ifdef CONFIG_USB_GADGET_SA1100 57 - #define gadget_is_sa1100(g) !strcmp("sa1100_udc", (g)->name) 58 - #else 59 - #define gadget_is_sa1100(g) 0 60 - #endif 61 - 62 #ifdef CONFIG_USB_GADGET_LH7A40X 63 #define gadget_is_lh7a40x(g) !strcmp("lh7a40x_udc", (g)->name) 64 #else 65 #define gadget_is_lh7a40x(g) 0 66 #endif 67 68 - /* handhelds.org tree (?) */ 69 - #ifdef CONFIG_USB_GADGET_MQ11XX 70 - #define gadget_is_mq11xx(g) !strcmp("mq11xx_udc", (g)->name) 71 - #else 72 - #define gadget_is_mq11xx(g) 0 73 - #endif 74 - 75 #ifdef CONFIG_USB_GADGET_OMAP 76 #define gadget_is_omap(g) !strcmp("omap_udc", (g)->name) 77 #else 78 #define gadget_is_omap(g) 0 79 - #endif 80 - 81 - /* not yet ported 2.4 --> 2.6 */ 82 - #ifdef CONFIG_USB_GADGET_N9604 83 - #define gadget_is_n9604(g) !strcmp("n9604_udc", (g)->name) 84 - #else 85 - #define gadget_is_n9604(g) 0 86 #endif 87 88 /* various unstable versions available */ ··· 94 #define gadget_is_fsl_usb2(g) 0 95 #endif 96 97 - /* Mentor high speed function controller */ 98 - /* from Montavista kernel (?) */ 99 - #ifdef CONFIG_USB_GADGET_MUSBHSFC 100 - #define gadget_is_musbhsfc(g) !strcmp("musbhsfc_udc", (g)->name) 101 - #else 102 - #define gadget_is_musbhsfc(g) 0 103 - #endif 104 - 105 /* Mentor high speed "dual role" controller, in peripheral role */ 106 #ifdef CONFIG_USB_GADGET_MUSB_HDRC 107 #define gadget_is_musbhdrc(g) !strcmp("musb_hdrc", (g)->name) ··· 105 #define gadget_is_langwell(g) (!strcmp("langwell_udc", (g)->name)) 106 #else 107 #define gadget_is_langwell(g) 0 108 - #endif 109 - 110 - /* from Montavista kernel (?) */ 111 - #ifdef CONFIG_USB_GADGET_MPC8272 112 - #define gadget_is_mpc8272(g) !strcmp("mpc8272_udc", (g)->name) 113 - #else 114 - #define gadget_is_mpc8272(g) 0 115 #endif 116 117 #ifdef CONFIG_USB_GADGET_M66592 ··· 160 return 0x02; 161 else if (gadget_is_pxa(gadget)) 162 return 0x03; 163 - else if (gadget_is_sh(gadget)) 164 - return 0x04; 165 - else if (gadget_is_sa1100(gadget)) 166 - return 0x05; 167 else if (gadget_is_goku(gadget)) 168 return 0x06; 169 - else if (gadget_is_mq11xx(gadget)) 170 - return 0x07; 171 else if (gadget_is_omap(gadget)) 172 return 0x08; 173 else if (gadget_is_lh7a40x(gadget)) 174 return 0x09; 175 - else if (gadget_is_n9604(gadget)) 176 - return 0x10; 177 else if (gadget_is_pxa27x(gadget)) 178 return 0x11; 179 else if (gadget_is_s3c2410(gadget)) ··· 174 return 0x13; 175 else if (gadget_is_imx(gadget)) 176 return 0x14; 177 - else if (gadget_is_musbhsfc(gadget)) 178 - return 0x15; 179 else if (gadget_is_musbhdrc(gadget)) 180 return 0x16; 181 - else if (gadget_is_mpc8272(gadget)) 182 - return 0x17; 183 else if (gadget_is_atmel_usba(gadget)) 184 return 0x18; 185 else if (gadget_is_fsl_usb2(gadget)) ··· 208 209 /* PXA 27x and 3xx have *broken* altsetting support */ 210 if (gadget_is_pxa27x(gadget)) 211 - return false; 212 - 213 - /* SH3 hardware just doesn't do altsettings */ 214 - if (gadget_is_sh(gadget)) 215 return false; 216 217 /* Everything else is *presumably* fine ... */
··· 45 #define gadget_is_goku(g) 0 46 #endif 47 48 #ifdef CONFIG_USB_GADGET_LH7A40X 49 #define gadget_is_lh7a40x(g) !strcmp("lh7a40x_udc", (g)->name) 50 #else 51 #define gadget_is_lh7a40x(g) 0 52 #endif 53 54 #ifdef CONFIG_USB_GADGET_OMAP 55 #define gadget_is_omap(g) !strcmp("omap_udc", (g)->name) 56 #else 57 #define gadget_is_omap(g) 0 58 #endif 59 60 /* various unstable versions available */ ··· 122 #define gadget_is_fsl_usb2(g) 0 123 #endif 124 125 /* Mentor high speed "dual role" controller, in peripheral role */ 126 #ifdef CONFIG_USB_GADGET_MUSB_HDRC 127 #define gadget_is_musbhdrc(g) !strcmp("musb_hdrc", (g)->name) ··· 141 #define gadget_is_langwell(g) (!strcmp("langwell_udc", (g)->name)) 142 #else 143 #define gadget_is_langwell(g) 0 144 #endif 145 146 #ifdef CONFIG_USB_GADGET_M66592 ··· 203 return 0x02; 204 else if (gadget_is_pxa(gadget)) 205 return 0x03; 206 else if (gadget_is_goku(gadget)) 207 return 0x06; 208 else if (gadget_is_omap(gadget)) 209 return 0x08; 210 else if (gadget_is_lh7a40x(gadget)) 211 return 0x09; 212 else if (gadget_is_pxa27x(gadget)) 213 return 0x11; 214 else if (gadget_is_s3c2410(gadget)) ··· 225 return 0x13; 226 else if (gadget_is_imx(gadget)) 227 return 0x14; 228 else if (gadget_is_musbhdrc(gadget)) 229 return 0x16; 230 else if (gadget_is_atmel_usba(gadget)) 231 return 0x18; 232 else if (gadget_is_fsl_usb2(gadget)) ··· 263 264 /* PXA 27x and 3xx have *broken* altsetting support */ 265 if (gadget_is_pxa27x(gadget)) 266 return false; 267 268 /* Everything else is *presumably* fine ... */
-5
drivers/usb/gadget/gmidi.c
··· 618 } 619 #endif 620 621 - if (gadget_is_sa1100(gadget) && dev->config) { 622 - /* tx fifo is full, but we can't clear it...*/ 623 - ERROR(dev, "can't change configurations\n"); 624 - return -ESPIPE; 625 - } 626 gmidi_reset_config(dev); 627 628 switch (number) {
··· 618 } 619 #endif 620 621 gmidi_reset_config(dev); 622 623 switch (number) {
+1 -1
drivers/usb/gadget/goku_udc.c
··· 1859 1860 /*-------------------------------------------------------------------------*/ 1861 1862 - static struct pci_device_id pci_ids [] = { { 1863 .class = ((PCI_CLASS_SERIAL_USB << 8) | 0xfe), 1864 .class_mask = ~0, 1865 .vendor = 0x102f, /* Toshiba */
··· 1859 1860 /*-------------------------------------------------------------------------*/ 1861 1862 + static const struct pci_device_id pci_ids[] = { { 1863 .class = ((PCI_CLASS_SERIAL_USB << 8) | 0xfe), 1864 .class_mask = ~0, 1865 .vendor = 0x102f, /* Toshiba */
+21 -18
drivers/usb/gadget/inode.c
··· 194 }; 195 196 struct ep_data { 197 - struct semaphore lock; 198 enum ep_state state; 199 atomic_t count; 200 struct dev_data *dev; ··· 298 int val; 299 300 if (f_flags & O_NONBLOCK) { 301 - if (down_trylock (&epdata->lock) != 0) 302 goto nonblock; 303 if (epdata->state != STATE_EP_ENABLED) { 304 - up (&epdata->lock); 305 nonblock: 306 val = -EAGAIN; 307 } else ··· 309 return val; 310 } 311 312 - if ((val = down_interruptible (&epdata->lock)) < 0) 313 return val; 314 315 switch (epdata->state) { ··· 324 // FALLTHROUGH 325 case STATE_EP_UNBOUND: /* clean disconnect */ 326 val = -ENODEV; 327 - up (&epdata->lock); 328 } 329 return val; 330 } ··· 394 if (likely (data->ep != NULL)) 395 usb_ep_set_halt (data->ep); 396 spin_unlock_irq (&data->dev->lock); 397 - up (&data->lock); 398 return -EBADMSG; 399 } 400 ··· 412 value = -EFAULT; 413 414 free1: 415 - up (&data->lock); 416 kfree (kbuf); 417 return value; 418 } ··· 437 if (likely (data->ep != NULL)) 438 usb_ep_set_halt (data->ep); 439 spin_unlock_irq (&data->dev->lock); 440 - up (&data->lock); 441 return -EBADMSG; 442 } 443 ··· 456 VDEBUG (data->dev, "%s write %zu IN, status %d\n", 457 data->name, len, (int) value); 458 free1: 459 - up (&data->lock); 460 kfree (kbuf); 461 return value; 462 } ··· 467 struct ep_data *data = fd->private_data; 468 int value; 469 470 - if ((value = down_interruptible(&data->lock)) < 0) 471 return value; 472 473 /* clean up if this can be reopened */ ··· 478 data->hs_desc.bDescriptorType = 0; 479 usb_ep_disable(data->ep); 480 } 481 - up (&data->lock); 482 put_ep (data); 483 return 0; 484 } ··· 509 } else 510 status = -ENODEV; 511 spin_unlock_irq (&data->dev->lock); 512 - up (&data->lock); 513 return status; 514 } 515 ··· 675 value = -ENODEV; 676 spin_unlock_irq(&epdata->dev->lock); 677 678 - up(&epdata->lock); 679 680 if (unlikely(value)) { 681 kfree(priv); ··· 767 u32 tag; 768 int value, length = len; 769 770 - if ((value = down_interruptible (&data->lock)) < 0) 771 return value; 772 773 if (data->state != STATE_EP_READY) { ··· 857 data->desc.bDescriptorType = 0; 858 data->hs_desc.bDescriptorType = 0; 859 } 860 - up (&data->lock); 861 return value; 862 fail0: 863 value = -EINVAL; ··· 873 struct ep_data *data = inode->i_private; 874 int value = -EBUSY; 875 876 - if (down_interruptible (&data->lock) != 0) 877 return -EINTR; 878 spin_lock_irq (&data->dev->lock); 879 if (data->dev->state == STATE_DEV_UNBOUND) ··· 888 DBG (data->dev, "%s state %d\n", 889 data->name, data->state); 890 spin_unlock_irq (&data->dev->lock); 891 - up (&data->lock); 892 return value; 893 } 894 ··· 1634 if (!data) 1635 goto enomem0; 1636 data->state = STATE_EP_DISABLED; 1637 - init_MUTEX (&data->lock); 1638 init_waitqueue_head (&data->wait); 1639 1640 strncpy (data->name, ep->name, sizeof (data->name) - 1);
··· 194 }; 195 196 struct ep_data { 197 + struct mutex lock; 198 enum ep_state state; 199 atomic_t count; 200 struct dev_data *dev; ··· 298 int val; 299 300 if (f_flags & O_NONBLOCK) { 301 + if (!mutex_trylock(&epdata->lock)) 302 goto nonblock; 303 if (epdata->state != STATE_EP_ENABLED) { 304 + mutex_unlock(&epdata->lock); 305 nonblock: 306 val = -EAGAIN; 307 } else ··· 309 return val; 310 } 311 312 + val = mutex_lock_interruptible(&epdata->lock); 313 + if (val < 0) 314 return val; 315 316 switch (epdata->state) { ··· 323 // FALLTHROUGH 324 case STATE_EP_UNBOUND: /* clean disconnect */ 325 val = -ENODEV; 326 + mutex_unlock(&epdata->lock); 327 } 328 return val; 329 } ··· 393 if (likely (data->ep != NULL)) 394 usb_ep_set_halt (data->ep); 395 spin_unlock_irq (&data->dev->lock); 396 + mutex_unlock(&data->lock); 397 return -EBADMSG; 398 } 399 ··· 411 value = -EFAULT; 412 413 free1: 414 + mutex_unlock(&data->lock); 415 kfree (kbuf); 416 return value; 417 } ··· 436 if (likely (data->ep != NULL)) 437 usb_ep_set_halt (data->ep); 438 spin_unlock_irq (&data->dev->lock); 439 + mutex_unlock(&data->lock); 440 return -EBADMSG; 441 } 442 ··· 455 VDEBUG (data->dev, "%s write %zu IN, status %d\n", 456 data->name, len, (int) value); 457 free1: 458 + mutex_unlock(&data->lock); 459 kfree (kbuf); 460 return value; 461 } ··· 466 struct ep_data *data = fd->private_data; 467 int value; 468 469 + value = mutex_lock_interruptible(&data->lock); 470 + if (value < 0) 471 return value; 472 473 /* clean up if this can be reopened */ ··· 476 data->hs_desc.bDescriptorType = 0; 477 usb_ep_disable(data->ep); 478 } 479 + mutex_unlock(&data->lock); 480 put_ep (data); 481 return 0; 482 } ··· 507 } else 508 status = -ENODEV; 509 spin_unlock_irq (&data->dev->lock); 510 + mutex_unlock(&data->lock); 511 return status; 512 } 513 ··· 673 value = -ENODEV; 674 spin_unlock_irq(&epdata->dev->lock); 675 676 + mutex_unlock(&epdata->lock); 677 678 if (unlikely(value)) { 679 kfree(priv); ··· 765 u32 tag; 766 int value, length = len; 767 768 + value = mutex_lock_interruptible(&data->lock); 769 + if (value < 0) 770 return value; 771 772 if (data->state != STATE_EP_READY) { ··· 854 data->desc.bDescriptorType = 0; 855 data->hs_desc.bDescriptorType = 0; 856 } 857 + mutex_unlock(&data->lock); 858 return value; 859 fail0: 860 value = -EINVAL; ··· 870 struct ep_data *data = inode->i_private; 871 int value = -EBUSY; 872 873 + if (mutex_lock_interruptible(&data->lock) != 0) 874 return -EINTR; 875 spin_lock_irq (&data->dev->lock); 876 if (data->dev->state == STATE_DEV_UNBOUND) ··· 885 DBG (data->dev, "%s state %d\n", 886 data->name, data->state); 887 spin_unlock_irq (&data->dev->lock); 888 + mutex_unlock(&data->lock); 889 return value; 890 } 891 ··· 1631 if (!data) 1632 goto enomem0; 1633 data->state = STATE_EP_DISABLED; 1634 + mutex_init(&data->lock); 1635 init_waitqueue_head (&data->wait); 1636 1637 strncpy (data->name, ep->name, sizeof (data->name) - 1);
+7 -1
drivers/usb/gadget/mass_storage.c
··· 135 static unsigned long msg_registered = 0; 136 static void msg_cleanup(void); 137 138 static int __init msg_do_config(struct usb_configuration *c) 139 { 140 struct fsg_common *common; ··· 153 } 154 155 fsg_config_from_params(&config, &mod_data); 156 - config.thread_exits = (void(*)(struct fsg_common*))&msg_cleanup; 157 common = fsg_common_init(0, c->cdev, &config); 158 if (IS_ERR(common)) 159 return PTR_ERR(common);
··· 135 static unsigned long msg_registered = 0; 136 static void msg_cleanup(void); 137 138 + static int msg_thread_exits(struct fsg_common *common) 139 + { 140 + msg_cleanup(); 141 + return 0; 142 + } 143 + 144 static int __init msg_do_config(struct usb_configuration *c) 145 { 146 struct fsg_common *common; ··· 147 } 148 149 fsg_config_from_params(&config, &mod_data); 150 + config.thread_exits = msg_thread_exits; 151 common = fsg_common_init(0, c->cdev, &config); 152 if (IS_ERR(common)) 153 return PTR_ERR(common);
+259
drivers/usb/gadget/nokia.c
···
··· 1 + /* 2 + * nokia.c -- Nokia Composite Gadget Driver 3 + * 4 + * Copyright (C) 2008-2010 Nokia Corporation 5 + * Contact: Felipe Balbi <felipe.balbi@nokia.com> 6 + * 7 + * This gadget driver borrows from serial.c which is: 8 + * 9 + * Copyright (C) 2003 Al Borchers (alborchers@steinerpoint.com) 10 + * Copyright (C) 2008 by David Brownell 11 + * Copyright (C) 2008 by Nokia Corporation 12 + * 13 + * This software is distributed under the terms of the GNU General 14 + * Public License ("GPL") as published by the Free Software Foundation, 15 + * version 2 of that License. 16 + */ 17 + 18 + #include <linux/kernel.h> 19 + #include <linux/utsname.h> 20 + #include <linux/device.h> 21 + 22 + #include "u_serial.h" 23 + #include "u_ether.h" 24 + #include "u_phonet.h" 25 + #include "gadget_chips.h" 26 + 27 + /* Defines */ 28 + 29 + #define NOKIA_VERSION_NUM 0x0211 30 + #define NOKIA_LONG_NAME "N900 (PC-Suite Mode)" 31 + 32 + /*-------------------------------------------------------------------------*/ 33 + 34 + /* 35 + * Kbuild is not very cooperative with respect to linking separately 36 + * compiled library objects into one module. So for now we won't use 37 + * separate compilation ... ensuring init/exit sections work to shrink 38 + * the runtime footprint, and giving us at least some parts of what 39 + * a "gcc --combine ... part1.c part2.c part3.c ... " build would. 40 + */ 41 + #include "composite.c" 42 + #include "usbstring.c" 43 + #include "config.c" 44 + #include "epautoconf.c" 45 + 46 + #include "u_serial.c" 47 + #include "f_acm.c" 48 + #include "f_ecm.c" 49 + #include "f_obex.c" 50 + #include "f_serial.c" 51 + #include "f_phonet.c" 52 + #include "u_ether.c" 53 + 54 + /*-------------------------------------------------------------------------*/ 55 + 56 + #define NOKIA_VENDOR_ID 0x0421 /* Nokia */ 57 + #define NOKIA_PRODUCT_ID 0x01c8 /* Nokia Gadget */ 58 + 59 + /* string IDs are assigned dynamically */ 60 + 61 + #define STRING_MANUFACTURER_IDX 0 62 + #define STRING_PRODUCT_IDX 1 63 + #define STRING_DESCRIPTION_IDX 2 64 + 65 + static char manufacturer_nokia[] = "Nokia"; 66 + static const char product_nokia[] = NOKIA_LONG_NAME; 67 + static const char description_nokia[] = "PC-Suite Configuration"; 68 + 69 + static struct usb_string strings_dev[] = { 70 + [STRING_MANUFACTURER_IDX].s = manufacturer_nokia, 71 + [STRING_PRODUCT_IDX].s = NOKIA_LONG_NAME, 72 + [STRING_DESCRIPTION_IDX].s = description_nokia, 73 + { } /* end of list */ 74 + }; 75 + 76 + static struct usb_gadget_strings stringtab_dev = { 77 + .language = 0x0409, /* en-us */ 78 + .strings = strings_dev, 79 + }; 80 + 81 + static struct usb_gadget_strings *dev_strings[] = { 82 + &stringtab_dev, 83 + NULL, 84 + }; 85 + 86 + static struct usb_device_descriptor device_desc = { 87 + .bLength = USB_DT_DEVICE_SIZE, 88 + .bDescriptorType = USB_DT_DEVICE, 89 + .bcdUSB = __constant_cpu_to_le16(0x0200), 90 + .bDeviceClass = USB_CLASS_COMM, 91 + .idVendor = __constant_cpu_to_le16(NOKIA_VENDOR_ID), 92 + .idProduct = __constant_cpu_to_le16(NOKIA_PRODUCT_ID), 93 + /* .iManufacturer = DYNAMIC */ 94 + /* .iProduct = DYNAMIC */ 95 + .bNumConfigurations = 1, 96 + }; 97 + 98 + /*-------------------------------------------------------------------------*/ 99 + 100 + /* Module */ 101 + MODULE_DESCRIPTION("Nokia composite gadget driver for N900"); 102 + MODULE_AUTHOR("Felipe Balbi"); 103 + MODULE_LICENSE("GPL"); 104 + 105 + /*-------------------------------------------------------------------------*/ 106 + 107 + static u8 hostaddr[ETH_ALEN]; 108 + 109 + static int __init nokia_bind_config(struct usb_configuration *c) 110 + { 111 + int status = 0; 112 + 113 + status = phonet_bind_config(c); 114 + if (status) 115 + printk(KERN_DEBUG "could not bind phonet config\n"); 116 + 117 + status = obex_bind_config(c, 0); 118 + if (status) 119 + printk(KERN_DEBUG "could not bind obex config %d\n", 0); 120 + 121 + status = obex_bind_config(c, 1); 122 + if (status) 123 + printk(KERN_DEBUG "could not bind obex config %d\n", 0); 124 + 125 + status = acm_bind_config(c, 2); 126 + if (status) 127 + printk(KERN_DEBUG "could not bind acm config\n"); 128 + 129 + status = ecm_bind_config(c, hostaddr); 130 + if (status) 131 + printk(KERN_DEBUG "could not bind ecm config\n"); 132 + 133 + return status; 134 + } 135 + 136 + static struct usb_configuration nokia_config_500ma_driver = { 137 + .label = "Bus Powered", 138 + .bind = nokia_bind_config, 139 + .bConfigurationValue = 1, 140 + /* .iConfiguration = DYNAMIC */ 141 + .bmAttributes = USB_CONFIG_ATT_ONE, 142 + .bMaxPower = 250, /* 500mA */ 143 + }; 144 + 145 + static struct usb_configuration nokia_config_100ma_driver = { 146 + .label = "Self Powered", 147 + .bind = nokia_bind_config, 148 + .bConfigurationValue = 2, 149 + /* .iConfiguration = DYNAMIC */ 150 + .bmAttributes = USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER, 151 + .bMaxPower = 50, /* 100 mA */ 152 + }; 153 + 154 + static int __init nokia_bind(struct usb_composite_dev *cdev) 155 + { 156 + int gcnum; 157 + struct usb_gadget *gadget = cdev->gadget; 158 + int status; 159 + 160 + status = gphonet_setup(cdev->gadget); 161 + if (status < 0) 162 + goto err_phonet; 163 + 164 + status = gserial_setup(cdev->gadget, 3); 165 + if (status < 0) 166 + goto err_serial; 167 + 168 + status = gether_setup(cdev->gadget, hostaddr); 169 + if (status < 0) 170 + goto err_ether; 171 + 172 + status = usb_string_id(cdev); 173 + if (status < 0) 174 + goto err_usb; 175 + strings_dev[STRING_MANUFACTURER_IDX].id = status; 176 + 177 + device_desc.iManufacturer = status; 178 + 179 + status = usb_string_id(cdev); 180 + if (status < 0) 181 + goto err_usb; 182 + strings_dev[STRING_PRODUCT_IDX].id = status; 183 + 184 + device_desc.iProduct = status; 185 + 186 + /* config description */ 187 + status = usb_string_id(cdev); 188 + if (status < 0) 189 + goto err_usb; 190 + strings_dev[STRING_DESCRIPTION_IDX].id = status; 191 + 192 + nokia_config_500ma_driver.iConfiguration = status; 193 + nokia_config_100ma_driver.iConfiguration = status; 194 + 195 + /* set up other descriptors */ 196 + gcnum = usb_gadget_controller_number(gadget); 197 + if (gcnum >= 0) 198 + device_desc.bcdDevice = cpu_to_le16(NOKIA_VERSION_NUM); 199 + else { 200 + /* this should only work with hw that supports altsettings 201 + * and several endpoints, anything else, panic. 202 + */ 203 + pr_err("nokia_bind: controller '%s' not recognized\n", 204 + gadget->name); 205 + goto err_usb; 206 + } 207 + 208 + /* finaly register the configuration */ 209 + status = usb_add_config(cdev, &nokia_config_500ma_driver); 210 + if (status < 0) 211 + goto err_usb; 212 + 213 + status = usb_add_config(cdev, &nokia_config_100ma_driver); 214 + if (status < 0) 215 + goto err_usb; 216 + 217 + dev_info(&gadget->dev, "%s\n", NOKIA_LONG_NAME); 218 + 219 + return 0; 220 + 221 + err_usb: 222 + gether_cleanup(); 223 + err_ether: 224 + gserial_cleanup(); 225 + err_serial: 226 + gphonet_cleanup(); 227 + err_phonet: 228 + return status; 229 + } 230 + 231 + static int __exit nokia_unbind(struct usb_composite_dev *cdev) 232 + { 233 + gphonet_cleanup(); 234 + gserial_cleanup(); 235 + gether_cleanup(); 236 + 237 + return 0; 238 + } 239 + 240 + static struct usb_composite_driver nokia_driver = { 241 + .name = "g_nokia", 242 + .dev = &device_desc, 243 + .strings = dev_strings, 244 + .bind = nokia_bind, 245 + .unbind = __exit_p(nokia_unbind), 246 + }; 247 + 248 + static int __init nokia_init(void) 249 + { 250 + return usb_composite_register(&nokia_driver); 251 + } 252 + module_init(nokia_init); 253 + 254 + static void __exit nokia_cleanup(void) 255 + { 256 + usb_composite_unregister(&nokia_driver); 257 + } 258 + module_exit(nokia_cleanup); 259 +
-18
drivers/usb/gadget/printer.c
··· 949 int result = 0; 950 struct usb_gadget *gadget = dev->gadget; 951 952 - if (gadget_is_sa1100(gadget) && dev->config) { 953 - /* tx fifo is full, but we can't clear it...*/ 954 - INFO(dev, "can't change configurations\n"); 955 - return -ESPIPE; 956 - } 957 - 958 switch (number) { 959 case DEV_CONFIG_VALUE: 960 result = 0; ··· 1026 set_interface(struct printer_dev *dev, unsigned number) 1027 { 1028 int result = 0; 1029 - 1030 - if (gadget_is_sa1100(dev->gadget) && dev->interface < 0) { 1031 - /* tx fifo is full, but we can't clear it...*/ 1032 - INFO(dev, "can't change interfaces\n"); 1033 - return -ESPIPE; 1034 - } 1035 1036 /* Free the current interface */ 1037 switch (dev->interface) { ··· 1377 status = cdev_add(&dev->printer_cdev, g_printer_devno, 1); 1378 if (status) { 1379 ERROR(dev, "Failed to open char device\n"); 1380 - goto fail; 1381 - } 1382 - 1383 - if (gadget_is_sa1100(gadget)) { 1384 - /* hardware can't write zero length packets. */ 1385 - ERROR(dev, "SA1100 controller is unsupport by this driver\n"); 1386 goto fail; 1387 } 1388
··· 949 int result = 0; 950 struct usb_gadget *gadget = dev->gadget; 951 952 switch (number) { 953 case DEV_CONFIG_VALUE: 954 result = 0; ··· 1032 set_interface(struct printer_dev *dev, unsigned number) 1033 { 1034 int result = 0; 1035 1036 /* Free the current interface */ 1037 switch (dev->interface) { ··· 1389 status = cdev_add(&dev->printer_cdev, g_printer_devno, 1); 1390 if (status) { 1391 ERROR(dev, "Failed to open char device\n"); 1392 goto fail; 1393 } 1394
+93 -42
drivers/usb/gadget/pxa27x_udc.c
··· 742 * @ep: pxa physical endpoint 743 * @req: pxa request 744 * @status: usb request status sent to gadget API 745 * 746 - * Context: ep->lock held 747 * 748 * Retire a pxa27x usb request. Endpoint must be locked. 749 */ 750 - static void req_done(struct pxa_ep *ep, struct pxa27x_request *req, int status) 751 { 752 ep_del_request(ep, req); 753 if (likely(req->req.status == -EINPROGRESS)) 754 req->req.status = status; ··· 764 &req->req, status, 765 req->req.actual, req->req.length); 766 767 req->req.complete(&req->udc_usb_ep->usb_ep, &req->req); 768 } 769 770 /** 771 * ep_end_out_req - Ends endpoint OUT request 772 * @ep: physical endpoint 773 * @req: pxa request 774 * 775 - * Context: ep->lock held 776 * 777 * Ends endpoint OUT request (completes usb request). 778 */ 779 - static void ep_end_out_req(struct pxa_ep *ep, struct pxa27x_request *req) 780 { 781 inc_ep_stats_reqs(ep, !USB_DIR_IN); 782 - req_done(ep, req, 0); 783 } 784 785 /** 786 * ep0_end_out_req - Ends control endpoint OUT request (ends data stage) 787 * @ep: physical endpoint 788 * @req: pxa request 789 * 790 - * Context: ep->lock held 791 * 792 * Ends control endpoint OUT request (completes usb request), and puts 793 * control endpoint into idle state 794 */ 795 - static void ep0_end_out_req(struct pxa_ep *ep, struct pxa27x_request *req) 796 { 797 set_ep0state(ep->dev, OUT_STATUS_STAGE); 798 - ep_end_out_req(ep, req); 799 ep0_idle(ep->dev); 800 } 801 ··· 813 * ep_end_in_req - Ends endpoint IN request 814 * @ep: physical endpoint 815 * @req: pxa request 816 * 817 - * Context: ep->lock held 818 * 819 * Ends endpoint IN request (completes usb request). 820 */ 821 - static void ep_end_in_req(struct pxa_ep *ep, struct pxa27x_request *req) 822 { 823 inc_ep_stats_reqs(ep, USB_DIR_IN); 824 - req_done(ep, req, 0); 825 } 826 827 /** 828 * ep0_end_in_req - Ends control endpoint IN request (ends data stage) 829 * @ep: physical endpoint 830 * @req: pxa request 831 * 832 - * Context: ep->lock held 833 * 834 * Ends control endpoint IN request (completes usb request), and puts 835 * control endpoint into status state 836 */ 837 - static void ep0_end_in_req(struct pxa_ep *ep, struct pxa27x_request *req) 838 { 839 set_ep0state(ep->dev, IN_STATUS_STAGE); 840 - ep_end_in_req(ep, req); 841 } 842 843 /** ··· 849 * @ep: pxa endpoint 850 * @status: usb request status 851 * 852 - * Context: ep->lock held 853 * 854 * Dequeues all requests on an endpoint. As a side effect, interrupts will be 855 * disabled on that endpoint (because no more requests). 856 */ 857 static void nuke(struct pxa_ep *ep, int status) 858 { 859 - struct pxa27x_request *req; 860 861 while (!list_empty(&ep->queue)) { 862 req = list_entry(ep->queue.next, struct pxa27x_request, queue); 863 - req_done(ep, req, status); 864 } 865 } 866 867 /** ··· 1144 int rc = 0; 1145 int is_first_req; 1146 unsigned length; 1147 1148 req = container_of(_req, struct pxa27x_request, req); 1149 udc_usb_ep = container_of(_ep, struct udc_usb_ep, usb_ep); ··· 1174 return -EMSGSIZE; 1175 1176 spin_lock_irqsave(&ep->lock, flags); 1177 1178 is_first_req = list_empty(&ep->queue); 1179 ep_dbg(ep, "queue req %p(first=%s), len %d buf %p\n", ··· 1184 if (!ep->enabled) { 1185 _req->status = -ESHUTDOWN; 1186 rc = -ESHUTDOWN; 1187 - goto out; 1188 } 1189 1190 if (req->in_use) { 1191 ep_err(ep, "refusing to queue req %p (already queued)\n", req); 1192 - goto out; 1193 } 1194 1195 length = _req->length; ··· 1197 _req->actual = 0; 1198 1199 ep_add_request(ep, req); 1200 1201 if (is_ep0(ep)) { 1202 switch (dev->ep0state) { 1203 case WAIT_ACK_SET_CONF_INTERF: 1204 if (length == 0) { 1205 - ep_end_in_req(ep, req); 1206 } else { 1207 ep_err(ep, "got a request of %d bytes while" 1208 "in state WAIT_ACK_SET_CONF_INTERF\n", ··· 1216 case IN_DATA_STAGE: 1217 if (!ep_is_full(ep)) 1218 if (write_ep0_fifo(ep, req)) 1219 - ep0_end_in_req(ep, req); 1220 break; 1221 case OUT_DATA_STAGE: 1222 if ((length == 0) || !epout_has_pkt(ep)) 1223 if (read_ep0_fifo(ep, req)) 1224 - ep0_end_out_req(ep, req); 1225 break; 1226 default: 1227 ep_err(ep, "odd state %s to send me a request\n", ··· 1231 break; 1232 } 1233 } else { 1234 - handle_ep(ep); 1235 } 1236 1237 out: 1238 - spin_unlock_irqrestore(&ep->lock, flags); 1239 return rc; 1240 } 1241 1242 /** ··· 1269 /* make sure it's actually queued on this endpoint */ 1270 list_for_each_entry(req, &ep->queue, queue) { 1271 if (&req->req == _req) { 1272 - req_done(ep, req, -ECONNRESET); 1273 rc = 0; 1274 break; 1275 } 1276 } 1277 1278 spin_unlock_irqrestore(&ep->lock, flags); 1279 return rc; 1280 } 1281 ··· 1473 { 1474 struct pxa_ep *ep; 1475 struct udc_usb_ep *udc_usb_ep; 1476 - unsigned long flags; 1477 1478 if (!_ep) 1479 return -EINVAL; ··· 1482 if (!ep || is_ep0(ep) || !list_empty(&ep->queue)) 1483 return -EINVAL; 1484 1485 - spin_lock_irqsave(&ep->lock, flags); 1486 ep->enabled = 0; 1487 nuke(ep, -ESHUTDOWN); 1488 - spin_unlock_irqrestore(&ep->lock, flags); 1489 1490 pxa_ep_fifo_flush(_ep); 1491 udc_usb_ep->pxa_ep = NULL; ··· 1932 } u; 1933 int i; 1934 int have_extrabytes = 0; 1935 1936 nuke(ep, -EPROTO); 1937 1938 /* 1939 * In the PXA320 manual, in the section about Back-to-Back setup ··· 1974 /* Tell UDC to enter Data Stage */ 1975 ep_write_UDCCSR(ep, UDCCSR0_SA | UDCCSR0_OPC); 1976 1977 i = udc->driver->setup(&udc->gadget, &u.r); 1978 if (i < 0) 1979 goto stall; 1980 out: 1981 return; 1982 stall: 1983 ep_dbg(ep, "protocol STALL, udccsr0=%03x err %d\n", ··· 2085 if (req && !ep_is_full(ep)) 2086 completed = write_ep0_fifo(ep, req); 2087 if (completed) 2088 - ep0_end_in_req(ep, req); 2089 break; 2090 case OUT_DATA_STAGE: /* SET_DESCRIPTOR */ 2091 if (epout_has_pkt(ep) && req) 2092 completed = read_ep0_fifo(ep, req); 2093 if (completed) 2094 - ep0_end_out_req(ep, req); 2095 break; 2096 case STALL: 2097 ep_write_UDCCSR(ep, UDCCSR0_FST); ··· 2121 * Tries to transfer all pending request data into the endpoint and/or 2122 * transfer all pending data in the endpoint into usb requests. 2123 * 2124 - * Is always called when in_interrupt() or with ep->lock held. 2125 */ 2126 static void handle_ep(struct pxa_ep *ep) 2127 { ··· 2130 u32 udccsr; 2131 int is_in = ep->dir_in; 2132 int loop = 0; 2133 2134 do { 2135 completed = 0; 2136 udccsr = udc_ep_readl(ep, UDCCSR); 2137 if (likely(!list_empty(&ep->queue))) 2138 req = list_entry(ep->queue.next, 2139 struct pxa27x_request, queue); ··· 2159 if (unlikely(is_in)) { 2160 if (likely(!ep_is_full(ep))) 2161 completed = write_fifo(ep, req); 2162 - if (completed) 2163 - ep_end_in_req(ep, req); 2164 } else { 2165 if (likely(epout_has_pkt(ep))) 2166 completed = read_fifo(ep, req); 2167 - if (completed) 2168 - ep_end_out_req(ep, req); 2169 } 2170 } while (completed); 2171 } 2172 2173 /** ··· 2262 continue; 2263 2264 udc_writel(udc, UDCISR0, UDCISR_INT(i, UDCISR_INT_MASK)); 2265 - ep = &udc->pxa_ep[i]; 2266 - ep->stats.irqs++; 2267 - handle_ep(ep); 2268 } 2269 2270 for (i = 16; udcisr1 != 0 && i < 24; udcisr1 >>= 2, i++) { ··· 2276 if (!(udcisr1 & UDCISR_INT_MASK)) 2277 continue; 2278 2279 - ep = &udc->pxa_ep[i]; 2280 - ep->stats.irqs++; 2281 - handle_ep(ep); 2282 } 2283 2284 } ··· 2490 } 2491 2492 retval = -ENOMEM; 2493 - udc->regs = ioremap(regs->start, regs->end - regs->start + 1); 2494 if (!udc->regs) { 2495 dev_err(&pdev->dev, "Unable to map UDC I/O memory\n"); 2496 goto err_map;
··· 742 * @ep: pxa physical endpoint 743 * @req: pxa request 744 * @status: usb request status sent to gadget API 745 + * @pflags: flags of previous spinlock_irq_save() or NULL if no lock held 746 * 747 + * Context: ep->lock held if flags not NULL, else ep->lock released 748 * 749 * Retire a pxa27x usb request. Endpoint must be locked. 750 */ 751 + static void req_done(struct pxa_ep *ep, struct pxa27x_request *req, int status, 752 + unsigned long *pflags) 753 { 754 + unsigned long flags; 755 + 756 ep_del_request(ep, req); 757 if (likely(req->req.status == -EINPROGRESS)) 758 req->req.status = status; ··· 760 &req->req, status, 761 req->req.actual, req->req.length); 762 763 + if (pflags) 764 + spin_unlock_irqrestore(&ep->lock, *pflags); 765 + local_irq_save(flags); 766 req->req.complete(&req->udc_usb_ep->usb_ep, &req->req); 767 + local_irq_restore(flags); 768 + if (pflags) 769 + spin_lock_irqsave(&ep->lock, *pflags); 770 } 771 772 /** 773 * ep_end_out_req - Ends endpoint OUT request 774 * @ep: physical endpoint 775 * @req: pxa request 776 + * @pflags: flags of previous spinlock_irq_save() or NULL if no lock held 777 * 778 + * Context: ep->lock held or released (see req_done()) 779 * 780 * Ends endpoint OUT request (completes usb request). 781 */ 782 + static void ep_end_out_req(struct pxa_ep *ep, struct pxa27x_request *req, 783 + unsigned long *pflags) 784 { 785 inc_ep_stats_reqs(ep, !USB_DIR_IN); 786 + req_done(ep, req, 0, pflags); 787 } 788 789 /** 790 * ep0_end_out_req - Ends control endpoint OUT request (ends data stage) 791 * @ep: physical endpoint 792 * @req: pxa request 793 + * @pflags: flags of previous spinlock_irq_save() or NULL if no lock held 794 * 795 + * Context: ep->lock held or released (see req_done()) 796 * 797 * Ends control endpoint OUT request (completes usb request), and puts 798 * control endpoint into idle state 799 */ 800 + static void ep0_end_out_req(struct pxa_ep *ep, struct pxa27x_request *req, 801 + unsigned long *pflags) 802 { 803 set_ep0state(ep->dev, OUT_STATUS_STAGE); 804 + ep_end_out_req(ep, req, pflags); 805 ep0_idle(ep->dev); 806 } 807 ··· 799 * ep_end_in_req - Ends endpoint IN request 800 * @ep: physical endpoint 801 * @req: pxa request 802 + * @pflags: flags of previous spinlock_irq_save() or NULL if no lock held 803 * 804 + * Context: ep->lock held or released (see req_done()) 805 * 806 * Ends endpoint IN request (completes usb request). 807 */ 808 + static void ep_end_in_req(struct pxa_ep *ep, struct pxa27x_request *req, 809 + unsigned long *pflags) 810 { 811 inc_ep_stats_reqs(ep, USB_DIR_IN); 812 + req_done(ep, req, 0, pflags); 813 } 814 815 /** 816 * ep0_end_in_req - Ends control endpoint IN request (ends data stage) 817 * @ep: physical endpoint 818 * @req: pxa request 819 + * @pflags: flags of previous spinlock_irq_save() or NULL if no lock held 820 * 821 + * Context: ep->lock held or released (see req_done()) 822 * 823 * Ends control endpoint IN request (completes usb request), and puts 824 * control endpoint into status state 825 */ 826 + static void ep0_end_in_req(struct pxa_ep *ep, struct pxa27x_request *req, 827 + unsigned long *pflags) 828 { 829 set_ep0state(ep->dev, IN_STATUS_STAGE); 830 + ep_end_in_req(ep, req, pflags); 831 } 832 833 /** ··· 831 * @ep: pxa endpoint 832 * @status: usb request status 833 * 834 + * Context: ep->lock released 835 * 836 * Dequeues all requests on an endpoint. As a side effect, interrupts will be 837 * disabled on that endpoint (because no more requests). 838 */ 839 static void nuke(struct pxa_ep *ep, int status) 840 { 841 + struct pxa27x_request *req; 842 + unsigned long flags; 843 844 + spin_lock_irqsave(&ep->lock, flags); 845 while (!list_empty(&ep->queue)) { 846 req = list_entry(ep->queue.next, struct pxa27x_request, queue); 847 + req_done(ep, req, status, &flags); 848 } 849 + spin_unlock_irqrestore(&ep->lock, flags); 850 } 851 852 /** ··· 1123 int rc = 0; 1124 int is_first_req; 1125 unsigned length; 1126 + int recursion_detected; 1127 1128 req = container_of(_req, struct pxa27x_request, req); 1129 udc_usb_ep = container_of(_ep, struct udc_usb_ep, usb_ep); ··· 1152 return -EMSGSIZE; 1153 1154 spin_lock_irqsave(&ep->lock, flags); 1155 + recursion_detected = ep->in_handle_ep; 1156 1157 is_first_req = list_empty(&ep->queue); 1158 ep_dbg(ep, "queue req %p(first=%s), len %d buf %p\n", ··· 1161 if (!ep->enabled) { 1162 _req->status = -ESHUTDOWN; 1163 rc = -ESHUTDOWN; 1164 + goto out_locked; 1165 } 1166 1167 if (req->in_use) { 1168 ep_err(ep, "refusing to queue req %p (already queued)\n", req); 1169 + goto out_locked; 1170 } 1171 1172 length = _req->length; ··· 1174 _req->actual = 0; 1175 1176 ep_add_request(ep, req); 1177 + spin_unlock_irqrestore(&ep->lock, flags); 1178 1179 if (is_ep0(ep)) { 1180 switch (dev->ep0state) { 1181 case WAIT_ACK_SET_CONF_INTERF: 1182 if (length == 0) { 1183 + ep_end_in_req(ep, req, NULL); 1184 } else { 1185 ep_err(ep, "got a request of %d bytes while" 1186 "in state WAIT_ACK_SET_CONF_INTERF\n", ··· 1192 case IN_DATA_STAGE: 1193 if (!ep_is_full(ep)) 1194 if (write_ep0_fifo(ep, req)) 1195 + ep0_end_in_req(ep, req, NULL); 1196 break; 1197 case OUT_DATA_STAGE: 1198 if ((length == 0) || !epout_has_pkt(ep)) 1199 if (read_ep0_fifo(ep, req)) 1200 + ep0_end_out_req(ep, req, NULL); 1201 break; 1202 default: 1203 ep_err(ep, "odd state %s to send me a request\n", ··· 1207 break; 1208 } 1209 } else { 1210 + if (!recursion_detected) 1211 + handle_ep(ep); 1212 } 1213 1214 out: 1215 return rc; 1216 + out_locked: 1217 + spin_unlock_irqrestore(&ep->lock, flags); 1218 + goto out; 1219 } 1220 1221 /** ··· 1242 /* make sure it's actually queued on this endpoint */ 1243 list_for_each_entry(req, &ep->queue, queue) { 1244 if (&req->req == _req) { 1245 rc = 0; 1246 break; 1247 } 1248 } 1249 1250 spin_unlock_irqrestore(&ep->lock, flags); 1251 + if (!rc) 1252 + req_done(ep, req, -ECONNRESET, NULL); 1253 return rc; 1254 } 1255 ··· 1445 { 1446 struct pxa_ep *ep; 1447 struct udc_usb_ep *udc_usb_ep; 1448 1449 if (!_ep) 1450 return -EINVAL; ··· 1455 if (!ep || is_ep0(ep) || !list_empty(&ep->queue)) 1456 return -EINVAL; 1457 1458 ep->enabled = 0; 1459 nuke(ep, -ESHUTDOWN); 1460 1461 pxa_ep_fifo_flush(_ep); 1462 udc_usb_ep->pxa_ep = NULL; ··· 1907 } u; 1908 int i; 1909 int have_extrabytes = 0; 1910 + unsigned long flags; 1911 1912 nuke(ep, -EPROTO); 1913 + spin_lock_irqsave(&ep->lock, flags); 1914 1915 /* 1916 * In the PXA320 manual, in the section about Back-to-Back setup ··· 1947 /* Tell UDC to enter Data Stage */ 1948 ep_write_UDCCSR(ep, UDCCSR0_SA | UDCCSR0_OPC); 1949 1950 + spin_unlock_irqrestore(&ep->lock, flags); 1951 i = udc->driver->setup(&udc->gadget, &u.r); 1952 + spin_lock_irqsave(&ep->lock, flags); 1953 if (i < 0) 1954 goto stall; 1955 out: 1956 + spin_unlock_irqrestore(&ep->lock, flags); 1957 return; 1958 stall: 1959 ep_dbg(ep, "protocol STALL, udccsr0=%03x err %d\n", ··· 2055 if (req && !ep_is_full(ep)) 2056 completed = write_ep0_fifo(ep, req); 2057 if (completed) 2058 + ep0_end_in_req(ep, req, NULL); 2059 break; 2060 case OUT_DATA_STAGE: /* SET_DESCRIPTOR */ 2061 if (epout_has_pkt(ep) && req) 2062 completed = read_ep0_fifo(ep, req); 2063 if (completed) 2064 + ep0_end_out_req(ep, req, NULL); 2065 break; 2066 case STALL: 2067 ep_write_UDCCSR(ep, UDCCSR0_FST); ··· 2091 * Tries to transfer all pending request data into the endpoint and/or 2092 * transfer all pending data in the endpoint into usb requests. 2093 * 2094 + * Is always called when in_interrupt() and with ep->lock released. 2095 */ 2096 static void handle_ep(struct pxa_ep *ep) 2097 { ··· 2100 u32 udccsr; 2101 int is_in = ep->dir_in; 2102 int loop = 0; 2103 + unsigned long flags; 2104 + 2105 + spin_lock_irqsave(&ep->lock, flags); 2106 + if (ep->in_handle_ep) 2107 + goto recursion_detected; 2108 + ep->in_handle_ep = 1; 2109 2110 do { 2111 completed = 0; 2112 udccsr = udc_ep_readl(ep, UDCCSR); 2113 + 2114 if (likely(!list_empty(&ep->queue))) 2115 req = list_entry(ep->queue.next, 2116 struct pxa27x_request, queue); ··· 2122 if (unlikely(is_in)) { 2123 if (likely(!ep_is_full(ep))) 2124 completed = write_fifo(ep, req); 2125 } else { 2126 if (likely(epout_has_pkt(ep))) 2127 completed = read_fifo(ep, req); 2128 + } 2129 + 2130 + if (completed) { 2131 + if (is_in) 2132 + ep_end_in_req(ep, req, &flags); 2133 + else 2134 + ep_end_out_req(ep, req, &flags); 2135 } 2136 } while (completed); 2137 + 2138 + ep->in_handle_ep = 0; 2139 + recursion_detected: 2140 + spin_unlock_irqrestore(&ep->lock, flags); 2141 } 2142 2143 /** ··· 2218 continue; 2219 2220 udc_writel(udc, UDCISR0, UDCISR_INT(i, UDCISR_INT_MASK)); 2221 + 2222 + WARN_ON(i >= ARRAY_SIZE(udc->pxa_ep)); 2223 + if (i < ARRAY_SIZE(udc->pxa_ep)) { 2224 + ep = &udc->pxa_ep[i]; 2225 + ep->stats.irqs++; 2226 + handle_ep(ep); 2227 + } 2228 } 2229 2230 for (i = 16; udcisr1 != 0 && i < 24; udcisr1 >>= 2, i++) { ··· 2228 if (!(udcisr1 & UDCISR_INT_MASK)) 2229 continue; 2230 2231 + WARN_ON(i >= ARRAY_SIZE(udc->pxa_ep)); 2232 + if (i < ARRAY_SIZE(udc->pxa_ep)) { 2233 + ep = &udc->pxa_ep[i]; 2234 + ep->stats.irqs++; 2235 + handle_ep(ep); 2236 + } 2237 } 2238 2239 } ··· 2439 } 2440 2441 retval = -ENOMEM; 2442 + udc->regs = ioremap(regs->start, resource_size(regs)); 2443 if (!udc->regs) { 2444 dev_err(&pdev->dev, "Unable to map UDC I/O memory\n"); 2445 goto err_map;
+6
drivers/usb/gadget/pxa27x_udc.h
··· 318 * @queue: requests queue 319 * @lock: lock to pxa_ep data (queues and stats) 320 * @enabled: true when endpoint enabled (not stopped by gadget layer) 321 * @idx: endpoint index (1 => epA, 2 => epB, ..., 24 => epX) 322 * @name: endpoint name (for trace/debug purpose) 323 * @dir_in: 1 if IN endpoint, 0 if OUT endpoint ··· 351 spinlock_t lock; /* Protects this structure */ 352 /* (queues, stats) */ 353 unsigned enabled:1; 354 355 unsigned idx:5; 356 char *name;
··· 318 * @queue: requests queue 319 * @lock: lock to pxa_ep data (queues and stats) 320 * @enabled: true when endpoint enabled (not stopped by gadget layer) 321 + * @in_handle_ep: number of recursions of handle_ep() function 322 + * Prevents deadlocks or infinite recursions of types : 323 + * irq->handle_ep()->req_done()->req.complete()->pxa_ep_queue()->handle_ep() 324 + * or 325 + * pxa_ep_queue()->handle_ep()->req_done()->req.complete()->pxa_ep_queue() 326 * @idx: endpoint index (1 => epA, 2 => epB, ..., 24 => epX) 327 * @name: endpoint name (for trace/debug purpose) 328 * @dir_in: 1 if IN endpoint, 0 if OUT endpoint ··· 346 spinlock_t lock; /* Protects this structure */ 347 /* (queues, stats) */ 348 unsigned enabled:1; 349 + unsigned in_handle_ep:1; 350 351 unsigned idx:5; 352 char *name;
+6 -5
drivers/usb/gadget/s3c-hsotg.c
··· 317 * 318 * Allocate a new USB request structure appropriate for the specified endpoint 319 */ 320 - struct usb_request *s3c_hsotg_ep_alloc_request(struct usb_ep *ep, gfp_t flags) 321 { 322 struct s3c_hsotg_req *req; 323 ··· 374 req->dma = DMA_ADDR_INVALID; 375 hs_req->mapped = 0; 376 } else { 377 - dma_sync_single(hsotg->dev, req->dma, req->length, dir); 378 } 379 } 380 ··· 756 hs_req->mapped = 1; 757 req->dma = dma; 758 } else { 759 - dma_sync_single(hsotg->dev, req->dma, req->length, dir); 760 hs_req->mapped = 0; 761 } 762 ··· 1461 * as the actual data should be sent to the memory directly and we turn 1462 * on the completion interrupts to get notifications of transfer completion. 1463 */ 1464 - void s3c_hsotg_handle_rx(struct s3c_hsotg *hsotg) 1465 { 1466 u32 grxstsr = readl(hsotg->regs + S3C_GRXSTSP); 1467 u32 epnum, status, size; ··· 3095 local_irq_restore(flags); 3096 } 3097 3098 - struct s3c_hsotg_plat s3c_hsotg_default_pdata; 3099 3100 static int __devinit s3c_hsotg_probe(struct platform_device *pdev) 3101 {
··· 317 * 318 * Allocate a new USB request structure appropriate for the specified endpoint 319 */ 320 + static struct usb_request *s3c_hsotg_ep_alloc_request(struct usb_ep *ep, 321 + gfp_t flags) 322 { 323 struct s3c_hsotg_req *req; 324 ··· 373 req->dma = DMA_ADDR_INVALID; 374 hs_req->mapped = 0; 375 } else { 376 + dma_sync_single_for_cpu(hsotg->dev, req->dma, req->length, dir); 377 } 378 } 379 ··· 755 hs_req->mapped = 1; 756 req->dma = dma; 757 } else { 758 + dma_sync_single_for_cpu(hsotg->dev, req->dma, req->length, dir); 759 hs_req->mapped = 0; 760 } 761 ··· 1460 * as the actual data should be sent to the memory directly and we turn 1461 * on the completion interrupts to get notifications of transfer completion. 1462 */ 1463 + static void s3c_hsotg_handle_rx(struct s3c_hsotg *hsotg) 1464 { 1465 u32 grxstsr = readl(hsotg->regs + S3C_GRXSTSP); 1466 u32 epnum, status, size; ··· 3094 local_irq_restore(flags); 3095 } 3096 3097 + static struct s3c_hsotg_plat s3c_hsotg_default_pdata; 3098 3099 static int __devinit s3c_hsotg_probe(struct platform_device *pdev) 3100 {
+5
drivers/usb/gadget/u_ether.c
··· 746 .ndo_validate_addr = eth_validate_addr, 747 }; 748 749 /** 750 * gether_setup - initialize one ethernet-over-usb link 751 * @g: gadget to associated with these links ··· 812 813 dev->gadget = g; 814 SET_NETDEV_DEV(net, &g->dev); 815 816 status = register_netdev(net); 817 if (status < 0) {
··· 746 .ndo_validate_addr = eth_validate_addr, 747 }; 748 749 + static struct device_type gadget_type = { 750 + .name = "gadget", 751 + }; 752 + 753 /** 754 * gether_setup - initialize one ethernet-over-usb link 755 * @g: gadget to associated with these links ··· 808 809 dev->gadget = g; 810 SET_NETDEV_DEV(net, &g->dev); 811 + SET_NETDEV_DEVTYPE(net, &gadget_type); 812 813 status = register_netdev(net); 814 if (status < 0) {
-7
drivers/usb/gadget/u_ether.h
··· 93 if (!gadget_supports_altsettings(gadget)) 94 return false; 95 96 - /* SA1100 can do ECM, *without* status endpoint ... but we'll 97 - * only use it in non-ECM mode for backwards compatibility 98 - * (and since we currently require a status endpoint) 99 - */ 100 - if (gadget_is_sa1100(gadget)) 101 - return false; 102 - 103 /* Everything else is *presumably* fine ... but this is a bit 104 * chancy, so be **CERTAIN** there are no hardware issues with 105 * your controller. Add it above if it can't handle CDC.
··· 93 if (!gadget_supports_altsettings(gadget)) 94 return false; 95 96 /* Everything else is *presumably* fine ... but this is a bit 97 * chancy, so be **CERTAIN** there are no hardware issues with 98 * your controller. Add it above if it can't handle CDC.
+2 -4
drivers/usb/gadget/zero.c
··· 297 */ 298 if (loopdefault) { 299 loopback_add(cdev, autoresume != 0); 300 - if (!gadget_is_sh(gadget)) 301 - sourcesink_add(cdev, autoresume != 0); 302 } else { 303 sourcesink_add(cdev, autoresume != 0); 304 - if (!gadget_is_sh(gadget)) 305 - loopback_add(cdev, autoresume != 0); 306 } 307 308 gcnum = usb_gadget_controller_number(gadget);
··· 297 */ 298 if (loopdefault) { 299 loopback_add(cdev, autoresume != 0); 300 + sourcesink_add(cdev, autoresume != 0); 301 } else { 302 sourcesink_add(cdev, autoresume != 0); 303 + loopback_add(cdev, autoresume != 0); 304 } 305 306 gcnum = usb_gadget_controller_number(gadget);
+11
drivers/usb/host/Kconfig
··· 399 400 To compile this driver a module, choose M here: the module 401 will be called "hwa-hc".
··· 399 400 To compile this driver a module, choose M here: the module 401 will be called "hwa-hc". 402 + 403 + config USB_IMX21_HCD 404 + tristate "iMX21 HCD support" 405 + depends on USB && ARM && MACH_MX21 406 + help 407 + This driver enables support for the on-chip USB host in the 408 + iMX21 processor. 409 + 410 + To compile this driver as a module, choose M here: the 411 + module will be called "imx21-hcd". 412 +
+2
drivers/usb/host/Makefile
··· 32 obj-$(CONFIG_USB_R8A66597_HCD) += r8a66597-hcd.o 33 obj-$(CONFIG_USB_ISP1760_HCD) += isp1760.o 34 obj-$(CONFIG_USB_HWA_HCD) += hwa-hc.o
··· 32 obj-$(CONFIG_USB_R8A66597_HCD) += r8a66597-hcd.o 33 obj-$(CONFIG_USB_ISP1760_HCD) += isp1760.o 34 obj-$(CONFIG_USB_HWA_HCD) += hwa-hc.o 35 + obj-$(CONFIG_USB_IMX21_HCD) += imx21-hcd.o 36 +
+1 -1
drivers/usb/host/ehci-atmel.c
··· 149 goto fail_request_resource; 150 } 151 hcd->rsrc_start = res->start; 152 - hcd->rsrc_len = res->end - res->start + 1; 153 154 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, 155 driver->description)) {
··· 149 goto fail_request_resource; 150 } 151 hcd->rsrc_start = res->start; 152 + hcd->rsrc_len = resource_size(res); 153 154 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, 155 driver->description)) {
+4 -2
drivers/usb/host/ehci-au1xxx.c
··· 121 { 122 struct usb_hcd *hcd; 123 struct ehci_hcd *ehci; 124 int ret; 125 126 if (usb_disabled()) ··· 145 if (!hcd) 146 return -ENOMEM; 147 148 - hcd->rsrc_start = pdev->resource[0].start; 149 - hcd->rsrc_len = pdev->resource[0].end - pdev->resource[0].start + 1; 150 151 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { 152 pr_debug("request_mem_region failed");
··· 121 { 122 struct usb_hcd *hcd; 123 struct ehci_hcd *ehci; 124 + struct resource *res; 125 int ret; 126 127 if (usb_disabled()) ··· 144 if (!hcd) 145 return -ENOMEM; 146 147 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 148 + hcd->rsrc_start = res->start; 149 + hcd->rsrc_len = resource_size(res); 150 151 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { 152 pr_debug("request_mem_region failed");
+87 -10
drivers/usb/host/ehci-fsl.c
··· 1 /* 2 - * Copyright (c) 2005 MontaVista Software 3 * 4 * This program is free software; you can redistribute it and/or modify it 5 * under the terms of the GNU General Public License as published by the ··· 18 * 19 * Ported to 834x by Randy Vinson <rvinson@mvista.com> using code provided 20 * by Hunter Wu. 21 */ 22 23 #include <linux/platform_device.h> 24 #include <linux/fsl_devices.h> 25 26 #include "ehci-fsl.h" 27 - 28 - /* FIXME: Power Management is un-ported so temporarily disable it */ 29 - #undef CONFIG_PM 30 - 31 32 /* configure so an HC device and id are always provided */ 33 /* always called with process context; sleeping is OK */ ··· 44 * Allocates basic resources for this USB host controller. 45 * 46 */ 47 - int usb_hcd_fsl_probe(const struct hc_driver *driver, 48 - struct platform_device *pdev) 49 { 50 struct fsl_usb2_platform_data *pdata; 51 struct usb_hcd *hcd; ··· 151 * Reverses the effect of usb_hcd_fsl_probe(). 152 * 153 */ 154 - void usb_hcd_fsl_remove(struct usb_hcd *hcd, struct platform_device *pdev) 155 { 156 usb_remove_hcd(hcd); 157 iounmap(hcd->regs); ··· 289 return retval; 290 } 291 292 static const struct hc_driver ehci_fsl_hc_driver = { 293 .description = hcd_name, 294 .product_desc = "Freescale On-Chip EHCI Host Controller", 295 - .hcd_priv_size = sizeof(struct ehci_hcd), 296 297 /* 298 * generic hardware linkage ··· 430 .remove = ehci_fsl_drv_remove, 431 .shutdown = usb_hcd_platform_shutdown, 432 .driver = { 433 - .name = "fsl-ehci", 434 }, 435 };
··· 1 /* 2 + * Copyright 2005-2009 MontaVista Software, Inc. 3 + * Copyright 2008 Freescale Semiconductor, Inc. 4 * 5 * This program is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License as published by the ··· 17 * 18 * Ported to 834x by Randy Vinson <rvinson@mvista.com> using code provided 19 * by Hunter Wu. 20 + * Power Management support by Dave Liu <daveliu@freescale.com>, 21 + * Jerry Huang <Chang-Ming.Huang@freescale.com> and 22 + * Anton Vorontsov <avorontsov@ru.mvista.com>. 23 */ 24 25 + #include <linux/kernel.h> 26 + #include <linux/types.h> 27 + #include <linux/delay.h> 28 + #include <linux/pm.h> 29 #include <linux/platform_device.h> 30 #include <linux/fsl_devices.h> 31 32 #include "ehci-fsl.h" 33 34 /* configure so an HC device and id are always provided */ 35 /* always called with process context; sleeping is OK */ ··· 40 * Allocates basic resources for this USB host controller. 41 * 42 */ 43 + static int usb_hcd_fsl_probe(const struct hc_driver *driver, 44 + struct platform_device *pdev) 45 { 46 struct fsl_usb2_platform_data *pdata; 47 struct usb_hcd *hcd; ··· 147 * Reverses the effect of usb_hcd_fsl_probe(). 148 * 149 */ 150 + static void usb_hcd_fsl_remove(struct usb_hcd *hcd, 151 + struct platform_device *pdev) 152 { 153 usb_remove_hcd(hcd); 154 iounmap(hcd->regs); ··· 284 return retval; 285 } 286 287 + struct ehci_fsl { 288 + struct ehci_hcd ehci; 289 + 290 + #ifdef CONFIG_PM 291 + /* Saved USB PHY settings, need to restore after deep sleep. */ 292 + u32 usb_ctrl; 293 + #endif 294 + }; 295 + 296 + #ifdef CONFIG_PM 297 + 298 + static struct ehci_fsl *hcd_to_ehci_fsl(struct usb_hcd *hcd) 299 + { 300 + struct ehci_hcd *ehci = hcd_to_ehci(hcd); 301 + 302 + return container_of(ehci, struct ehci_fsl, ehci); 303 + } 304 + 305 + static int ehci_fsl_drv_suspend(struct device *dev) 306 + { 307 + struct usb_hcd *hcd = dev_get_drvdata(dev); 308 + struct ehci_fsl *ehci_fsl = hcd_to_ehci_fsl(hcd); 309 + void __iomem *non_ehci = hcd->regs; 310 + 311 + if (!fsl_deep_sleep()) 312 + return 0; 313 + 314 + ehci_fsl->usb_ctrl = in_be32(non_ehci + FSL_SOC_USB_CTRL); 315 + return 0; 316 + } 317 + 318 + static int ehci_fsl_drv_resume(struct device *dev) 319 + { 320 + struct usb_hcd *hcd = dev_get_drvdata(dev); 321 + struct ehci_fsl *ehci_fsl = hcd_to_ehci_fsl(hcd); 322 + struct ehci_hcd *ehci = hcd_to_ehci(hcd); 323 + void __iomem *non_ehci = hcd->regs; 324 + 325 + if (!fsl_deep_sleep()) 326 + return 0; 327 + 328 + usb_root_hub_lost_power(hcd->self.root_hub); 329 + 330 + /* Restore USB PHY settings and enable the controller. */ 331 + out_be32(non_ehci + FSL_SOC_USB_CTRL, ehci_fsl->usb_ctrl); 332 + 333 + ehci_reset(ehci); 334 + ehci_fsl_reinit(ehci); 335 + 336 + return 0; 337 + } 338 + 339 + static int ehci_fsl_drv_restore(struct device *dev) 340 + { 341 + struct usb_hcd *hcd = dev_get_drvdata(dev); 342 + 343 + usb_root_hub_lost_power(hcd->self.root_hub); 344 + return 0; 345 + } 346 + 347 + static struct dev_pm_ops ehci_fsl_pm_ops = { 348 + .suspend = ehci_fsl_drv_suspend, 349 + .resume = ehci_fsl_drv_resume, 350 + .restore = ehci_fsl_drv_restore, 351 + }; 352 + 353 + #define EHCI_FSL_PM_OPS (&ehci_fsl_pm_ops) 354 + #else 355 + #define EHCI_FSL_PM_OPS NULL 356 + #endif /* CONFIG_PM */ 357 + 358 static const struct hc_driver ehci_fsl_hc_driver = { 359 .description = hcd_name, 360 .product_desc = "Freescale On-Chip EHCI Host Controller", 361 + .hcd_priv_size = sizeof(struct ehci_fsl), 362 363 /* 364 * generic hardware linkage ··· 354 .remove = ehci_fsl_drv_remove, 355 .shutdown = usb_hcd_platform_shutdown, 356 .driver = { 357 + .name = "fsl-ehci", 358 + .pm = EHCI_FSL_PM_OPS, 359 }, 360 };
+11 -12
drivers/usb/host/ehci-mxc.c
··· 162 goto err_ioremap; 163 } 164 165 /* enable clocks */ 166 priv->usbclk = clk_get(dev, "usb"); 167 if (IS_ERR(priv->usbclk)) { ··· 202 ret = mxc_set_usbcontrol(pdev->id, pdata->flags); 203 if (ret < 0) 204 goto err_init; 205 - 206 - /* call platform specific init function */ 207 - if (pdata->init) { 208 - ret = pdata->init(pdev); 209 - if (ret) { 210 - dev_err(dev, "platform init failed\n"); 211 - goto err_init; 212 - } 213 - } 214 - 215 - /* most platforms need some time to settle changed IO settings */ 216 - mdelay(10); 217 218 /* Initialize the transceiver */ 219 if (pdata->otg) {
··· 162 goto err_ioremap; 163 } 164 165 + /* call platform specific init function */ 166 + if (pdata->init) { 167 + ret = pdata->init(pdev); 168 + if (ret) { 169 + dev_err(dev, "platform init failed\n"); 170 + goto err_init; 171 + } 172 + /* platforms need some time to settle changed IO settings */ 173 + mdelay(10); 174 + } 175 + 176 /* enable clocks */ 177 priv->usbclk = clk_get(dev, "usb"); 178 if (IS_ERR(priv->usbclk)) { ··· 191 ret = mxc_set_usbcontrol(pdev->id, pdata->flags); 192 if (ret < 0) 193 goto err_init; 194 195 /* Initialize the transceiver */ 196 if (pdata->otg) {
+41 -6
drivers/usb/host/ehci-omap.c
··· 26 * along with this program; if not, write to the Free Software 27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 28 * 29 - * TODO (last updated Feb 23rd, 2009): 30 * - add kernel-doc 31 * - enable AUTOIDLE 32 - * - move DPLL5 programming to clock fw 33 * - add suspend/resume 34 * - move workarounds to board-files 35 */ ··· 36 #include <linux/platform_device.h> 37 #include <linux/clk.h> 38 #include <linux/gpio.h> 39 #include <plat/usb.h> 40 41 /* ··· 178 void __iomem *uhh_base; 179 void __iomem *tll_base; 180 void __iomem *ehci_base; 181 }; 182 183 /*-------------------------------------------------------------------------*/ ··· 551 552 int irq = platform_get_irq(pdev, 0); 553 int ret = -ENODEV; 554 555 if (!pdata) { 556 dev_dbg(&pdev->dev, "missing platform_data\n"); ··· 620 goto err_tll_ioremap; 621 } 622 623 ret = omap_start_ehc(omap, hcd); 624 if (ret) { 625 dev_dbg(&pdev->dev, "failed to start ehci\n"); ··· 644 omap->ehci->regs = hcd->regs 645 + HC_LENGTH(readl(&omap->ehci->caps->hc_capbase)); 646 647 /* cache this readonly data; minimize chip reads */ 648 omap->ehci->hcs_params = readl(&omap->ehci->caps->hcs_params); 649 - 650 - /* SET 1 micro-frame Interrupt interval */ 651 - writel(readl(&omap->ehci->regs->command) | (1 << 16), 652 - &omap->ehci->regs->command); 653 654 ret = usb_add_hcd(hcd, irq, IRQF_DISABLED | IRQF_SHARED); 655 if (ret) { ··· 662 omap_stop_ehc(omap, hcd); 663 664 err_start: 665 iounmap(omap->tll_base); 666 667 err_tll_ioremap: ··· 701 { 702 struct ehci_hcd_omap *omap = platform_get_drvdata(pdev); 703 struct usb_hcd *hcd = ehci_to_hcd(omap->ehci); 704 705 usb_remove_hcd(hcd); 706 omap_stop_ehc(omap, hcd); 707 iounmap(hcd->regs); 708 iounmap(omap->tll_base); 709 iounmap(omap->uhh_base); 710 usb_put_hcd(hcd); 711 712 return 0; 713 }
··· 26 * along with this program; if not, write to the Free Software 27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 28 * 29 + * TODO (last updated Feb 12, 2010): 30 * - add kernel-doc 31 * - enable AUTOIDLE 32 * - add suspend/resume 33 * - move workarounds to board-files 34 */ ··· 37 #include <linux/platform_device.h> 38 #include <linux/clk.h> 39 #include <linux/gpio.h> 40 + #include <linux/regulator/consumer.h> 41 #include <plat/usb.h> 42 43 /* ··· 178 void __iomem *uhh_base; 179 void __iomem *tll_base; 180 void __iomem *ehci_base; 181 + 182 + /* Regulators for USB PHYs. 183 + * Each PHY can have a seperate regulator. 184 + */ 185 + struct regulator *regulator[OMAP3_HS_USB_PORTS]; 186 }; 187 188 /*-------------------------------------------------------------------------*/ ··· 546 547 int irq = platform_get_irq(pdev, 0); 548 int ret = -ENODEV; 549 + int i; 550 + char supply[7]; 551 552 if (!pdata) { 553 dev_dbg(&pdev->dev, "missing platform_data\n"); ··· 613 goto err_tll_ioremap; 614 } 615 616 + /* get ehci regulator and enable */ 617 + for (i = 0 ; i < OMAP3_HS_USB_PORTS ; i++) { 618 + if (omap->port_mode[i] != EHCI_HCD_OMAP_MODE_PHY) { 619 + omap->regulator[i] = NULL; 620 + continue; 621 + } 622 + snprintf(supply, sizeof(supply), "hsusb%d", i); 623 + omap->regulator[i] = regulator_get(omap->dev, supply); 624 + if (IS_ERR(omap->regulator[i])) 625 + dev_dbg(&pdev->dev, 626 + "failed to get ehci port%d regulator\n", i); 627 + else 628 + regulator_enable(omap->regulator[i]); 629 + } 630 + 631 ret = omap_start_ehc(omap, hcd); 632 if (ret) { 633 dev_dbg(&pdev->dev, "failed to start ehci\n"); ··· 622 omap->ehci->regs = hcd->regs 623 + HC_LENGTH(readl(&omap->ehci->caps->hc_capbase)); 624 625 + dbg_hcs_params(omap->ehci, "reset"); 626 + dbg_hcc_params(omap->ehci, "reset"); 627 + 628 /* cache this readonly data; minimize chip reads */ 629 omap->ehci->hcs_params = readl(&omap->ehci->caps->hcs_params); 630 631 ret = usb_add_hcd(hcd, irq, IRQF_DISABLED | IRQF_SHARED); 632 if (ret) { ··· 641 omap_stop_ehc(omap, hcd); 642 643 err_start: 644 + for (i = 0 ; i < OMAP3_HS_USB_PORTS ; i++) { 645 + if (omap->regulator[i]) { 646 + regulator_disable(omap->regulator[i]); 647 + regulator_put(omap->regulator[i]); 648 + } 649 + } 650 iounmap(omap->tll_base); 651 652 err_tll_ioremap: ··· 674 { 675 struct ehci_hcd_omap *omap = platform_get_drvdata(pdev); 676 struct usb_hcd *hcd = ehci_to_hcd(omap->ehci); 677 + int i; 678 679 usb_remove_hcd(hcd); 680 omap_stop_ehc(omap, hcd); 681 iounmap(hcd->regs); 682 + for (i = 0 ; i < OMAP3_HS_USB_PORTS ; i++) { 683 + if (omap->regulator[i]) { 684 + regulator_disable(omap->regulator[i]); 685 + regulator_put(omap->regulator[i]); 686 + } 687 + } 688 iounmap(omap->tll_base); 689 iounmap(omap->uhh_base); 690 usb_put_hcd(hcd); 691 + kfree(omap); 692 693 return 0; 694 }
+4 -4
drivers/usb/host/ehci-orion.c
··· 222 goto err1; 223 } 224 225 - if (!request_mem_region(res->start, res->end - res->start + 1, 226 ehci_orion_hc_driver.description)) { 227 dev_dbg(&pdev->dev, "controller already in use\n"); 228 err = -EBUSY; 229 goto err1; 230 } 231 232 - regs = ioremap(res->start, res->end - res->start + 1); 233 if (regs == NULL) { 234 dev_dbg(&pdev->dev, "error mapping memory\n"); 235 err = -EFAULT; ··· 244 } 245 246 hcd->rsrc_start = res->start; 247 - hcd->rsrc_len = res->end - res->start + 1; 248 hcd->regs = regs; 249 250 ehci = hcd_to_ehci(hcd); ··· 287 err3: 288 iounmap(regs); 289 err2: 290 - release_mem_region(res->start, res->end - res->start + 1); 291 err1: 292 dev_err(&pdev->dev, "init %s fail, %d\n", 293 dev_name(&pdev->dev), err);
··· 222 goto err1; 223 } 224 225 + if (!request_mem_region(res->start, resource_size(res), 226 ehci_orion_hc_driver.description)) { 227 dev_dbg(&pdev->dev, "controller already in use\n"); 228 err = -EBUSY; 229 goto err1; 230 } 231 232 + regs = ioremap(res->start, resource_size(res)); 233 if (regs == NULL) { 234 dev_dbg(&pdev->dev, "error mapping memory\n"); 235 err = -EFAULT; ··· 244 } 245 246 hcd->rsrc_start = res->start; 247 + hcd->rsrc_len = resource_size(res); 248 hcd->regs = regs; 249 250 ehci = hcd_to_ehci(hcd); ··· 287 err3: 288 iounmap(regs); 289 err2: 290 + release_mem_region(res->start, resource_size(res)); 291 err1: 292 dev_err(&pdev->dev, "init %s fail, %d\n", 293 dev_name(&pdev->dev), err);
+7 -7
drivers/usb/host/ehci-ppc-of.c
··· 134 hcd->rsrc_len = res.end - res.start + 1; 135 136 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { 137 - printk(KERN_ERR __FILE__ ": request_mem_region failed\n"); 138 rv = -EBUSY; 139 goto err_rmr; 140 } 141 142 irq = irq_of_parse_and_map(dn, 0); 143 if (irq == NO_IRQ) { 144 - printk(KERN_ERR __FILE__ ": irq_of_parse_and_map failed\n"); 145 rv = -EBUSY; 146 goto err_irq; 147 } 148 149 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); 150 if (!hcd->regs) { 151 - printk(KERN_ERR __FILE__ ": ioremap failed\n"); 152 rv = -ENOMEM; 153 goto err_ioremap; 154 } ··· 161 ehci->ohci_hcctrl_reg = ioremap(res.start + 162 OHCI_HCCTRL_OFFSET, OHCI_HCCTRL_LEN); 163 else 164 - pr_debug(__FILE__ ": no ohci offset in fdt\n"); 165 if (!ehci->ohci_hcctrl_reg) { 166 - pr_debug(__FILE__ ": ioremap for ohci hcctrl failed\n"); 167 } else { 168 ehci->has_amcc_usb23 = 1; 169 } ··· 241 else 242 release_mem_region(res.start, 0x4); 243 else 244 - pr_debug(__FILE__ ": no ohci offset in fdt\n"); 245 of_node_put(np); 246 } 247 ··· 264 } 265 266 267 - static struct of_device_id ehci_hcd_ppc_of_match[] = { 268 { 269 .compatible = "usb-ehci", 270 },
··· 134 hcd->rsrc_len = res.end - res.start + 1; 135 136 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { 137 + printk(KERN_ERR "%s: request_mem_region failed\n", __FILE__); 138 rv = -EBUSY; 139 goto err_rmr; 140 } 141 142 irq = irq_of_parse_and_map(dn, 0); 143 if (irq == NO_IRQ) { 144 + printk(KERN_ERR "%s: irq_of_parse_and_map failed\n", __FILE__); 145 rv = -EBUSY; 146 goto err_irq; 147 } 148 149 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); 150 if (!hcd->regs) { 151 + printk(KERN_ERR "%s: ioremap failed\n", __FILE__); 152 rv = -ENOMEM; 153 goto err_ioremap; 154 } ··· 161 ehci->ohci_hcctrl_reg = ioremap(res.start + 162 OHCI_HCCTRL_OFFSET, OHCI_HCCTRL_LEN); 163 else 164 + pr_debug("%s: no ohci offset in fdt\n", __FILE__); 165 if (!ehci->ohci_hcctrl_reg) { 166 + pr_debug("%s: ioremap for ohci hcctrl failed\n", __FILE__); 167 } else { 168 ehci->has_amcc_usb23 = 1; 169 } ··· 241 else 242 release_mem_region(res.start, 0x4); 243 else 244 + pr_debug("%s: no ohci offset in fdt\n", __FILE__); 245 of_node_put(np); 246 } 247 ··· 264 } 265 266 267 + static const struct of_device_id ehci_hcd_ppc_of_match[] = { 268 { 269 .compatible = "usb-ehci", 270 },
+9 -3
drivers/usb/host/ehci-sched.c
··· 510 ehci_writel(ehci, cmd, &ehci->regs->command); 511 /* posted write ... */ 512 513 ehci->next_uframe = -1; 514 return 0; 515 } ··· 2324 * No need to check for activity unless the 2325 * frame is current. 2326 */ 2327 - if (frame == clock_frame && live && 2328 - (q.sitd->hw_results & 2329 - SITD_ACTIVE(ehci))) { 2330 incomplete = true; 2331 q_p = &q.sitd->sitd_next; 2332 hw_p = &q.sitd->hw_next;
··· 510 ehci_writel(ehci, cmd, &ehci->regs->command); 511 /* posted write ... */ 512 513 + free_cached_itd_list(ehci); 514 + 515 ehci->next_uframe = -1; 516 return 0; 517 } ··· 2322 * No need to check for activity unless the 2323 * frame is current. 2324 */ 2325 + if (((frame == clock_frame) || 2326 + (((frame + 1) % ehci->periodic_size) 2327 + == clock_frame)) 2328 + && live 2329 + && (q.sitd->hw_results & 2330 + SITD_ACTIVE(ehci))) { 2331 + 2332 incomplete = true; 2333 q_p = &q.sitd->sitd_next; 2334 hw_p = &q.sitd->hw_next;
+4 -4
drivers/usb/host/ehci-xilinx-of.c
··· 177 hcd->rsrc_len = res.end - res.start + 1; 178 179 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { 180 - printk(KERN_ERR __FILE__ ": request_mem_region failed\n"); 181 rv = -EBUSY; 182 goto err_rmr; 183 } 184 185 irq = irq_of_parse_and_map(dn, 0); 186 if (irq == NO_IRQ) { 187 - printk(KERN_ERR __FILE__ ": irq_of_parse_and_map failed\n"); 188 rv = -EBUSY; 189 goto err_irq; 190 } 191 192 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); 193 if (!hcd->regs) { 194 - printk(KERN_ERR __FILE__ ": ioremap failed\n"); 195 rv = -ENOMEM; 196 goto err_ioremap; 197 } ··· 281 } 282 283 284 - static struct of_device_id ehci_hcd_xilinx_of_match[] = { 285 {.compatible = "xlnx,xps-usb-host-1.00.a",}, 286 {}, 287 };
··· 177 hcd->rsrc_len = res.end - res.start + 1; 178 179 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { 180 + printk(KERN_ERR "%s: request_mem_region failed\n", __FILE__); 181 rv = -EBUSY; 182 goto err_rmr; 183 } 184 185 irq = irq_of_parse_and_map(dn, 0); 186 if (irq == NO_IRQ) { 187 + printk(KERN_ERR "%s: irq_of_parse_and_map failed\n", __FILE__); 188 rv = -EBUSY; 189 goto err_irq; 190 } 191 192 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); 193 if (!hcd->regs) { 194 + printk(KERN_ERR "%s: ioremap failed\n", __FILE__); 195 rv = -ENOMEM; 196 goto err_ioremap; 197 } ··· 281 } 282 283 284 + static const struct of_device_id ehci_hcd_xilinx_of_match[] = { 285 {.compatible = "xlnx,xps-usb-host-1.00.a",}, 286 {}, 287 };
+2 -2
drivers/usb/host/fhci-hcd.c
··· 433 return -ENOMEM; 434 435 /* allocate the private part of the URB */ 436 - urb_priv->tds = kzalloc(size * sizeof(struct td), mem_flags); 437 if (!urb_priv->tds) { 438 kfree(urb_priv); 439 return -ENOMEM; ··· 805 return fhci_remove(&ofdev->dev); 806 } 807 808 - static struct of_device_id of_fhci_match[] = { 809 { .compatible = "fsl,mpc8323-qe-usb", }, 810 {}, 811 };
··· 433 return -ENOMEM; 434 435 /* allocate the private part of the URB */ 436 + urb_priv->tds = kcalloc(size, sizeof(*urb_priv->tds), mem_flags); 437 if (!urb_priv->tds) { 438 kfree(urb_priv); 439 return -ENOMEM; ··· 805 return fhci_remove(&ofdev->dev); 806 } 807 808 + static const struct of_device_id of_fhci_match[] = { 809 { .compatible = "fsl,mpc8323-qe-usb", }, 810 {}, 811 };
+527
drivers/usb/host/imx21-dbg.c
···
··· 1 + /* 2 + * Copyright (c) 2009 by Martin Fuzzey 3 + * 4 + * This program is free software; you can redistribute it and/or modify it 5 + * under the terms of the GNU General Public License as published by the 6 + * Free Software Foundation; either version 2 of the License, or (at your 7 + * option) any later version. 8 + * 9 + * This program is distributed in the hope that it will be useful, but 10 + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 11 + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 + * for more details. 13 + * 14 + * You should have received a copy of the GNU General Public License 15 + * along with this program; if not, write to the Free Software Foundation, 16 + * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 + */ 18 + 19 + /* this file is part of imx21-hcd.c */ 20 + 21 + #ifndef DEBUG 22 + 23 + static inline void create_debug_files(struct imx21 *imx21) { } 24 + static inline void remove_debug_files(struct imx21 *imx21) { } 25 + static inline void debug_urb_submitted(struct imx21 *imx21, struct urb *urb) {} 26 + static inline void debug_urb_completed(struct imx21 *imx21, struct urb *urb, 27 + int status) {} 28 + static inline void debug_urb_unlinked(struct imx21 *imx21, struct urb *urb) {} 29 + static inline void debug_urb_queued_for_etd(struct imx21 *imx21, 30 + struct urb *urb) {} 31 + static inline void debug_urb_queued_for_dmem(struct imx21 *imx21, 32 + struct urb *urb) {} 33 + static inline void debug_etd_allocated(struct imx21 *imx21) {} 34 + static inline void debug_etd_freed(struct imx21 *imx21) {} 35 + static inline void debug_dmem_allocated(struct imx21 *imx21, int size) {} 36 + static inline void debug_dmem_freed(struct imx21 *imx21, int size) {} 37 + static inline void debug_isoc_submitted(struct imx21 *imx21, 38 + int frame, struct td *td) {} 39 + static inline void debug_isoc_completed(struct imx21 *imx21, 40 + int frame, struct td *td, int cc, int len) {} 41 + 42 + #else 43 + 44 + #include <linux/debugfs.h> 45 + #include <linux/seq_file.h> 46 + 47 + static const char *dir_labels[] = { 48 + "TD 0", 49 + "OUT", 50 + "IN", 51 + "TD 1" 52 + }; 53 + 54 + static const char *speed_labels[] = { 55 + "Full", 56 + "Low" 57 + }; 58 + 59 + static const char *format_labels[] = { 60 + "Control", 61 + "ISO", 62 + "Bulk", 63 + "Interrupt" 64 + }; 65 + 66 + static inline struct debug_stats *stats_for_urb(struct imx21 *imx21, 67 + struct urb *urb) 68 + { 69 + return usb_pipeisoc(urb->pipe) ? 70 + &imx21->isoc_stats : &imx21->nonisoc_stats; 71 + } 72 + 73 + static void debug_urb_submitted(struct imx21 *imx21, struct urb *urb) 74 + { 75 + stats_for_urb(imx21, urb)->submitted++; 76 + } 77 + 78 + static void debug_urb_completed(struct imx21 *imx21, struct urb *urb, int st) 79 + { 80 + if (st) 81 + stats_for_urb(imx21, urb)->completed_failed++; 82 + else 83 + stats_for_urb(imx21, urb)->completed_ok++; 84 + } 85 + 86 + static void debug_urb_unlinked(struct imx21 *imx21, struct urb *urb) 87 + { 88 + stats_for_urb(imx21, urb)->unlinked++; 89 + } 90 + 91 + static void debug_urb_queued_for_etd(struct imx21 *imx21, struct urb *urb) 92 + { 93 + stats_for_urb(imx21, urb)->queue_etd++; 94 + } 95 + 96 + static void debug_urb_queued_for_dmem(struct imx21 *imx21, struct urb *urb) 97 + { 98 + stats_for_urb(imx21, urb)->queue_dmem++; 99 + } 100 + 101 + static inline void debug_etd_allocated(struct imx21 *imx21) 102 + { 103 + imx21->etd_usage.maximum = max( 104 + ++(imx21->etd_usage.value), 105 + imx21->etd_usage.maximum); 106 + } 107 + 108 + static inline void debug_etd_freed(struct imx21 *imx21) 109 + { 110 + imx21->etd_usage.value--; 111 + } 112 + 113 + static inline void debug_dmem_allocated(struct imx21 *imx21, int size) 114 + { 115 + imx21->dmem_usage.value += size; 116 + imx21->dmem_usage.maximum = max( 117 + imx21->dmem_usage.value, 118 + imx21->dmem_usage.maximum); 119 + } 120 + 121 + static inline void debug_dmem_freed(struct imx21 *imx21, int size) 122 + { 123 + imx21->dmem_usage.value -= size; 124 + } 125 + 126 + 127 + static void debug_isoc_submitted(struct imx21 *imx21, 128 + int frame, struct td *td) 129 + { 130 + struct debug_isoc_trace *trace = &imx21->isoc_trace[ 131 + imx21->isoc_trace_index++]; 132 + 133 + imx21->isoc_trace_index %= ARRAY_SIZE(imx21->isoc_trace); 134 + trace->schedule_frame = td->frame; 135 + trace->submit_frame = frame; 136 + trace->request_len = td->len; 137 + trace->td = td; 138 + } 139 + 140 + static inline void debug_isoc_completed(struct imx21 *imx21, 141 + int frame, struct td *td, int cc, int len) 142 + { 143 + struct debug_isoc_trace *trace, *trace_failed; 144 + int i; 145 + int found = 0; 146 + 147 + trace = imx21->isoc_trace; 148 + for (i = 0; i < ARRAY_SIZE(imx21->isoc_trace); i++, trace++) { 149 + if (trace->td == td) { 150 + trace->done_frame = frame; 151 + trace->done_len = len; 152 + trace->cc = cc; 153 + trace->td = NULL; 154 + found = 1; 155 + break; 156 + } 157 + } 158 + 159 + if (found && cc) { 160 + trace_failed = &imx21->isoc_trace_failed[ 161 + imx21->isoc_trace_index_failed++]; 162 + 163 + imx21->isoc_trace_index_failed %= ARRAY_SIZE( 164 + imx21->isoc_trace_failed); 165 + *trace_failed = *trace; 166 + } 167 + } 168 + 169 + 170 + static char *format_ep(struct usb_host_endpoint *ep, char *buf, int bufsize) 171 + { 172 + if (ep) 173 + snprintf(buf, bufsize, "ep_%02x (type:%02X kaddr:%p)", 174 + ep->desc.bEndpointAddress, 175 + usb_endpoint_type(&ep->desc), 176 + ep); 177 + else 178 + snprintf(buf, bufsize, "none"); 179 + return buf; 180 + } 181 + 182 + static char *format_etd_dword0(u32 value, char *buf, int bufsize) 183 + { 184 + snprintf(buf, bufsize, 185 + "addr=%d ep=%d dir=%s speed=%s format=%s halted=%d", 186 + value & 0x7F, 187 + (value >> DW0_ENDPNT) & 0x0F, 188 + dir_labels[(value >> DW0_DIRECT) & 0x03], 189 + speed_labels[(value >> DW0_SPEED) & 0x01], 190 + format_labels[(value >> DW0_FORMAT) & 0x03], 191 + (value >> DW0_HALTED) & 0x01); 192 + return buf; 193 + } 194 + 195 + static int debug_status_show(struct seq_file *s, void *v) 196 + { 197 + struct imx21 *imx21 = s->private; 198 + int etds_allocated = 0; 199 + int etds_sw_busy = 0; 200 + int etds_hw_busy = 0; 201 + int dmem_blocks = 0; 202 + int queued_for_etd = 0; 203 + int queued_for_dmem = 0; 204 + unsigned int dmem_bytes = 0; 205 + int i; 206 + struct etd_priv *etd; 207 + u32 etd_enable_mask; 208 + unsigned long flags; 209 + struct imx21_dmem_area *dmem; 210 + struct ep_priv *ep_priv; 211 + 212 + spin_lock_irqsave(&imx21->lock, flags); 213 + 214 + etd_enable_mask = readl(imx21->regs + USBH_ETDENSET); 215 + for (i = 0, etd = imx21->etd; i < USB_NUM_ETD; i++, etd++) { 216 + if (etd->alloc) 217 + etds_allocated++; 218 + if (etd->urb) 219 + etds_sw_busy++; 220 + if (etd_enable_mask & (1<<i)) 221 + etds_hw_busy++; 222 + } 223 + 224 + list_for_each_entry(dmem, &imx21->dmem_list, list) { 225 + dmem_bytes += dmem->size; 226 + dmem_blocks++; 227 + } 228 + 229 + list_for_each_entry(ep_priv, &imx21->queue_for_etd, queue) 230 + queued_for_etd++; 231 + 232 + list_for_each_entry(etd, &imx21->queue_for_dmem, queue) 233 + queued_for_dmem++; 234 + 235 + spin_unlock_irqrestore(&imx21->lock, flags); 236 + 237 + seq_printf(s, 238 + "Frame: %d\n" 239 + "ETDs allocated: %d/%d (max=%d)\n" 240 + "ETDs in use sw: %d\n" 241 + "ETDs in use hw: %d\n" 242 + "DMEM alocated: %d/%d (max=%d)\n" 243 + "DMEM blocks: %d\n" 244 + "Queued waiting for ETD: %d\n" 245 + "Queued waiting for DMEM: %d\n", 246 + readl(imx21->regs + USBH_FRMNUB) & 0xFFFF, 247 + etds_allocated, USB_NUM_ETD, imx21->etd_usage.maximum, 248 + etds_sw_busy, 249 + etds_hw_busy, 250 + dmem_bytes, DMEM_SIZE, imx21->dmem_usage.maximum, 251 + dmem_blocks, 252 + queued_for_etd, 253 + queued_for_dmem); 254 + 255 + return 0; 256 + } 257 + 258 + static int debug_dmem_show(struct seq_file *s, void *v) 259 + { 260 + struct imx21 *imx21 = s->private; 261 + struct imx21_dmem_area *dmem; 262 + unsigned long flags; 263 + char ep_text[40]; 264 + 265 + spin_lock_irqsave(&imx21->lock, flags); 266 + 267 + list_for_each_entry(dmem, &imx21->dmem_list, list) 268 + seq_printf(s, 269 + "%04X: size=0x%X " 270 + "ep=%s\n", 271 + dmem->offset, dmem->size, 272 + format_ep(dmem->ep, ep_text, sizeof(ep_text))); 273 + 274 + spin_unlock_irqrestore(&imx21->lock, flags); 275 + 276 + return 0; 277 + } 278 + 279 + static int debug_etd_show(struct seq_file *s, void *v) 280 + { 281 + struct imx21 *imx21 = s->private; 282 + struct etd_priv *etd; 283 + char buf[60]; 284 + u32 dword; 285 + int i, j; 286 + unsigned long flags; 287 + 288 + spin_lock_irqsave(&imx21->lock, flags); 289 + 290 + for (i = 0, etd = imx21->etd; i < USB_NUM_ETD; i++, etd++) { 291 + int state = -1; 292 + struct urb_priv *urb_priv; 293 + if (etd->urb) { 294 + urb_priv = etd->urb->hcpriv; 295 + if (urb_priv) 296 + state = urb_priv->state; 297 + } 298 + 299 + seq_printf(s, 300 + "etd_num: %d\n" 301 + "ep: %s\n" 302 + "alloc: %d\n" 303 + "len: %d\n" 304 + "busy sw: %d\n" 305 + "busy hw: %d\n" 306 + "urb state: %d\n" 307 + "current urb: %p\n", 308 + 309 + i, 310 + format_ep(etd->ep, buf, sizeof(buf)), 311 + etd->alloc, 312 + etd->len, 313 + etd->urb != NULL, 314 + (readl(imx21->regs + USBH_ETDENSET) & (1 << i)) > 0, 315 + state, 316 + etd->urb); 317 + 318 + for (j = 0; j < 4; j++) { 319 + dword = etd_readl(imx21, i, j); 320 + switch (j) { 321 + case 0: 322 + format_etd_dword0(dword, buf, sizeof(buf)); 323 + break; 324 + case 2: 325 + snprintf(buf, sizeof(buf), 326 + "cc=0X%02X", dword >> DW2_COMPCODE); 327 + break; 328 + default: 329 + *buf = 0; 330 + break; 331 + } 332 + seq_printf(s, 333 + "dword %d: submitted=%08X cur=%08X [%s]\n", 334 + j, 335 + etd->submitted_dwords[j], 336 + dword, 337 + buf); 338 + } 339 + seq_printf(s, "\n"); 340 + } 341 + 342 + spin_unlock_irqrestore(&imx21->lock, flags); 343 + 344 + return 0; 345 + } 346 + 347 + static void debug_statistics_show_one(struct seq_file *s, 348 + const char *name, struct debug_stats *stats) 349 + { 350 + seq_printf(s, "%s:\n" 351 + "submitted URBs: %lu\n" 352 + "completed OK: %lu\n" 353 + "completed failed: %lu\n" 354 + "unlinked: %lu\n" 355 + "queued for ETD: %lu\n" 356 + "queued for DMEM: %lu\n\n", 357 + name, 358 + stats->submitted, 359 + stats->completed_ok, 360 + stats->completed_failed, 361 + stats->unlinked, 362 + stats->queue_etd, 363 + stats->queue_dmem); 364 + } 365 + 366 + static int debug_statistics_show(struct seq_file *s, void *v) 367 + { 368 + struct imx21 *imx21 = s->private; 369 + unsigned long flags; 370 + 371 + spin_lock_irqsave(&imx21->lock, flags); 372 + 373 + debug_statistics_show_one(s, "nonisoc", &imx21->nonisoc_stats); 374 + debug_statistics_show_one(s, "isoc", &imx21->isoc_stats); 375 + seq_printf(s, "unblock kludge triggers: %lu\n", imx21->debug_unblocks); 376 + spin_unlock_irqrestore(&imx21->lock, flags); 377 + 378 + return 0; 379 + } 380 + 381 + static void debug_isoc_show_one(struct seq_file *s, 382 + const char *name, int index, struct debug_isoc_trace *trace) 383 + { 384 + seq_printf(s, "%s %d:\n" 385 + "cc=0X%02X\n" 386 + "scheduled frame %d (%d)\n" 387 + "submittted frame %d (%d)\n" 388 + "completed frame %d (%d)\n" 389 + "requested length=%d\n" 390 + "completed length=%d\n\n", 391 + name, index, 392 + trace->cc, 393 + trace->schedule_frame, trace->schedule_frame & 0xFFFF, 394 + trace->submit_frame, trace->submit_frame & 0xFFFF, 395 + trace->done_frame, trace->done_frame & 0xFFFF, 396 + trace->request_len, 397 + trace->done_len); 398 + } 399 + 400 + static int debug_isoc_show(struct seq_file *s, void *v) 401 + { 402 + struct imx21 *imx21 = s->private; 403 + struct debug_isoc_trace *trace; 404 + unsigned long flags; 405 + int i; 406 + 407 + spin_lock_irqsave(&imx21->lock, flags); 408 + 409 + trace = imx21->isoc_trace_failed; 410 + for (i = 0; i < ARRAY_SIZE(imx21->isoc_trace_failed); i++, trace++) 411 + debug_isoc_show_one(s, "isoc failed", i, trace); 412 + 413 + trace = imx21->isoc_trace; 414 + for (i = 0; i < ARRAY_SIZE(imx21->isoc_trace); i++, trace++) 415 + debug_isoc_show_one(s, "isoc", i, trace); 416 + 417 + spin_unlock_irqrestore(&imx21->lock, flags); 418 + 419 + return 0; 420 + } 421 + 422 + static int debug_status_open(struct inode *inode, struct file *file) 423 + { 424 + return single_open(file, debug_status_show, inode->i_private); 425 + } 426 + 427 + static int debug_dmem_open(struct inode *inode, struct file *file) 428 + { 429 + return single_open(file, debug_dmem_show, inode->i_private); 430 + } 431 + 432 + static int debug_etd_open(struct inode *inode, struct file *file) 433 + { 434 + return single_open(file, debug_etd_show, inode->i_private); 435 + } 436 + 437 + static int debug_statistics_open(struct inode *inode, struct file *file) 438 + { 439 + return single_open(file, debug_statistics_show, inode->i_private); 440 + } 441 + 442 + static int debug_isoc_open(struct inode *inode, struct file *file) 443 + { 444 + return single_open(file, debug_isoc_show, inode->i_private); 445 + } 446 + 447 + static const struct file_operations debug_status_fops = { 448 + .open = debug_status_open, 449 + .read = seq_read, 450 + .llseek = seq_lseek, 451 + .release = single_release, 452 + }; 453 + 454 + static const struct file_operations debug_dmem_fops = { 455 + .open = debug_dmem_open, 456 + .read = seq_read, 457 + .llseek = seq_lseek, 458 + .release = single_release, 459 + }; 460 + 461 + static const struct file_operations debug_etd_fops = { 462 + .open = debug_etd_open, 463 + .read = seq_read, 464 + .llseek = seq_lseek, 465 + .release = single_release, 466 + }; 467 + 468 + static const struct file_operations debug_statistics_fops = { 469 + .open = debug_statistics_open, 470 + .read = seq_read, 471 + .llseek = seq_lseek, 472 + .release = single_release, 473 + }; 474 + 475 + static const struct file_operations debug_isoc_fops = { 476 + .open = debug_isoc_open, 477 + .read = seq_read, 478 + .llseek = seq_lseek, 479 + .release = single_release, 480 + }; 481 + 482 + static void create_debug_files(struct imx21 *imx21) 483 + { 484 + imx21->debug_root = debugfs_create_dir(dev_name(imx21->dev), NULL); 485 + if (!imx21->debug_root) 486 + goto failed_create_rootdir; 487 + 488 + if (!debugfs_create_file("status", S_IRUGO, 489 + imx21->debug_root, imx21, &debug_status_fops)) 490 + goto failed_create; 491 + 492 + if (!debugfs_create_file("dmem", S_IRUGO, 493 + imx21->debug_root, imx21, &debug_dmem_fops)) 494 + goto failed_create; 495 + 496 + if (!debugfs_create_file("etd", S_IRUGO, 497 + imx21->debug_root, imx21, &debug_etd_fops)) 498 + goto failed_create; 499 + 500 + if (!debugfs_create_file("statistics", S_IRUGO, 501 + imx21->debug_root, imx21, &debug_statistics_fops)) 502 + goto failed_create; 503 + 504 + if (!debugfs_create_file("isoc", S_IRUGO, 505 + imx21->debug_root, imx21, &debug_isoc_fops)) 506 + goto failed_create; 507 + 508 + return; 509 + 510 + failed_create: 511 + debugfs_remove_recursive(imx21->debug_root); 512 + 513 + failed_create_rootdir: 514 + imx21->debug_root = NULL; 515 + } 516 + 517 + 518 + static void remove_debug_files(struct imx21 *imx21) 519 + { 520 + if (imx21->debug_root) { 521 + debugfs_remove_recursive(imx21->debug_root); 522 + imx21->debug_root = NULL; 523 + } 524 + } 525 + 526 + #endif 527 +
+1789
drivers/usb/host/imx21-hcd.c
···
··· 1 + /* 2 + * USB Host Controller Driver for IMX21 3 + * 4 + * Copyright (C) 2006 Loping Dog Embedded Systems 5 + * Copyright (C) 2009 Martin Fuzzey 6 + * Originally written by Jay Monkman <jtm@lopingdog.com> 7 + * Ported to 2.6.30, debugged and enhanced by Martin Fuzzey 8 + * 9 + * This program is free software; you can redistribute it and/or modify it 10 + * under the terms of the GNU General Public License as published by the 11 + * Free Software Foundation; either version 2 of the License, or (at your 12 + * option) any later version. 13 + * 14 + * This program is distributed in the hope that it will be useful, but 15 + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 16 + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 17 + * for more details. 18 + * 19 + * You should have received a copy of the GNU General Public License 20 + * along with this program; if not, write to the Free Software Foundation, 21 + * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 + */ 23 + 24 + 25 + /* 26 + * The i.MX21 USB hardware contains 27 + * * 32 transfer descriptors (called ETDs) 28 + * * 4Kb of Data memory 29 + * 30 + * The data memory is shared between the host and fuction controlers 31 + * (but this driver only supports the host controler) 32 + * 33 + * So setting up a transfer involves: 34 + * * Allocating a ETD 35 + * * Fill in ETD with appropriate information 36 + * * Allocating data memory (and putting the offset in the ETD) 37 + * * Activate the ETD 38 + * * Get interrupt when done. 39 + * 40 + * An ETD is assigned to each active endpoint. 41 + * 42 + * Low resource (ETD and Data memory) situations are handled differently for 43 + * isochronous and non insosynchronous transactions : 44 + * 45 + * Non ISOC transfers are queued if either ETDs or Data memory are unavailable 46 + * 47 + * ISOC transfers use 2 ETDs per endpoint to achieve double buffering. 48 + * They allocate both ETDs and Data memory during URB submission 49 + * (and fail if unavailable). 50 + */ 51 + 52 + #include <linux/clk.h> 53 + #include <linux/io.h> 54 + #include <linux/kernel.h> 55 + #include <linux/list.h> 56 + #include <linux/platform_device.h> 57 + #include <linux/usb.h> 58 + 59 + #include "../core/hcd.h" 60 + #include "imx21-hcd.h" 61 + 62 + #ifdef DEBUG 63 + #define DEBUG_LOG_FRAME(imx21, etd, event) \ 64 + (etd)->event##_frame = readl((imx21)->regs + USBH_FRMNUB) 65 + #else 66 + #define DEBUG_LOG_FRAME(imx21, etd, event) do { } while (0) 67 + #endif 68 + 69 + static const char hcd_name[] = "imx21-hcd"; 70 + 71 + static inline struct imx21 *hcd_to_imx21(struct usb_hcd *hcd) 72 + { 73 + return (struct imx21 *)hcd->hcd_priv; 74 + } 75 + 76 + 77 + /* =========================================== */ 78 + /* Hardware access helpers */ 79 + /* =========================================== */ 80 + 81 + static inline void set_register_bits(struct imx21 *imx21, u32 offset, u32 mask) 82 + { 83 + void __iomem *reg = imx21->regs + offset; 84 + writel(readl(reg) | mask, reg); 85 + } 86 + 87 + static inline void clear_register_bits(struct imx21 *imx21, 88 + u32 offset, u32 mask) 89 + { 90 + void __iomem *reg = imx21->regs + offset; 91 + writel(readl(reg) & ~mask, reg); 92 + } 93 + 94 + static inline void clear_toggle_bit(struct imx21 *imx21, u32 offset, u32 mask) 95 + { 96 + void __iomem *reg = imx21->regs + offset; 97 + 98 + if (readl(reg) & mask) 99 + writel(mask, reg); 100 + } 101 + 102 + static inline void set_toggle_bit(struct imx21 *imx21, u32 offset, u32 mask) 103 + { 104 + void __iomem *reg = imx21->regs + offset; 105 + 106 + if (!(readl(reg) & mask)) 107 + writel(mask, reg); 108 + } 109 + 110 + static void etd_writel(struct imx21 *imx21, int etd_num, int dword, u32 value) 111 + { 112 + writel(value, imx21->regs + USB_ETD_DWORD(etd_num, dword)); 113 + } 114 + 115 + static u32 etd_readl(struct imx21 *imx21, int etd_num, int dword) 116 + { 117 + return readl(imx21->regs + USB_ETD_DWORD(etd_num, dword)); 118 + } 119 + 120 + static inline int wrap_frame(int counter) 121 + { 122 + return counter & 0xFFFF; 123 + } 124 + 125 + static inline int frame_after(int frame, int after) 126 + { 127 + /* handle wrapping like jiffies time_afer */ 128 + return (s16)((s16)after - (s16)frame) < 0; 129 + } 130 + 131 + static int imx21_hc_get_frame(struct usb_hcd *hcd) 132 + { 133 + struct imx21 *imx21 = hcd_to_imx21(hcd); 134 + 135 + return wrap_frame(readl(imx21->regs + USBH_FRMNUB)); 136 + } 137 + 138 + 139 + #include "imx21-dbg.c" 140 + 141 + /* =========================================== */ 142 + /* ETD management */ 143 + /* =========================================== */ 144 + 145 + static int alloc_etd(struct imx21 *imx21) 146 + { 147 + int i; 148 + struct etd_priv *etd = imx21->etd; 149 + 150 + for (i = 0; i < USB_NUM_ETD; i++, etd++) { 151 + if (etd->alloc == 0) { 152 + memset(etd, 0, sizeof(imx21->etd[0])); 153 + etd->alloc = 1; 154 + debug_etd_allocated(imx21); 155 + return i; 156 + } 157 + } 158 + return -1; 159 + } 160 + 161 + static void disactivate_etd(struct imx21 *imx21, int num) 162 + { 163 + int etd_mask = (1 << num); 164 + struct etd_priv *etd = &imx21->etd[num]; 165 + 166 + writel(etd_mask, imx21->regs + USBH_ETDENCLR); 167 + clear_register_bits(imx21, USBH_ETDDONEEN, etd_mask); 168 + writel(etd_mask, imx21->regs + USB_ETDDMACHANLCLR); 169 + clear_toggle_bit(imx21, USBH_ETDDONESTAT, etd_mask); 170 + 171 + etd->active_count = 0; 172 + 173 + DEBUG_LOG_FRAME(imx21, etd, disactivated); 174 + } 175 + 176 + static void reset_etd(struct imx21 *imx21, int num) 177 + { 178 + struct etd_priv *etd = imx21->etd + num; 179 + int i; 180 + 181 + disactivate_etd(imx21, num); 182 + 183 + for (i = 0; i < 4; i++) 184 + etd_writel(imx21, num, i, 0); 185 + etd->urb = NULL; 186 + etd->ep = NULL; 187 + etd->td = NULL;; 188 + } 189 + 190 + static void free_etd(struct imx21 *imx21, int num) 191 + { 192 + if (num < 0) 193 + return; 194 + 195 + if (num >= USB_NUM_ETD) { 196 + dev_err(imx21->dev, "BAD etd=%d!\n", num); 197 + return; 198 + } 199 + if (imx21->etd[num].alloc == 0) { 200 + dev_err(imx21->dev, "ETD %d already free!\n", num); 201 + return; 202 + } 203 + 204 + debug_etd_freed(imx21); 205 + reset_etd(imx21, num); 206 + memset(&imx21->etd[num], 0, sizeof(imx21->etd[0])); 207 + } 208 + 209 + 210 + static void setup_etd_dword0(struct imx21 *imx21, 211 + int etd_num, struct urb *urb, u8 dir, u16 maxpacket) 212 + { 213 + etd_writel(imx21, etd_num, 0, 214 + ((u32) usb_pipedevice(urb->pipe)) << DW0_ADDRESS | 215 + ((u32) usb_pipeendpoint(urb->pipe) << DW0_ENDPNT) | 216 + ((u32) dir << DW0_DIRECT) | 217 + ((u32) ((urb->dev->speed == USB_SPEED_LOW) ? 218 + 1 : 0) << DW0_SPEED) | 219 + ((u32) fmt_urb_to_etd[usb_pipetype(urb->pipe)] << DW0_FORMAT) | 220 + ((u32) maxpacket << DW0_MAXPKTSIZ)); 221 + } 222 + 223 + static void activate_etd(struct imx21 *imx21, 224 + int etd_num, dma_addr_t dma, u8 dir) 225 + { 226 + u32 etd_mask = 1 << etd_num; 227 + struct etd_priv *etd = &imx21->etd[etd_num]; 228 + 229 + clear_toggle_bit(imx21, USBH_ETDDONESTAT, etd_mask); 230 + set_register_bits(imx21, USBH_ETDDONEEN, etd_mask); 231 + clear_toggle_bit(imx21, USBH_XFILLSTAT, etd_mask); 232 + clear_toggle_bit(imx21, USBH_YFILLSTAT, etd_mask); 233 + 234 + if (dma) { 235 + set_register_bits(imx21, USB_ETDDMACHANLCLR, etd_mask); 236 + clear_toggle_bit(imx21, USBH_XBUFSTAT, etd_mask); 237 + clear_toggle_bit(imx21, USBH_YBUFSTAT, etd_mask); 238 + writel(dma, imx21->regs + USB_ETDSMSA(etd_num)); 239 + set_register_bits(imx21, USB_ETDDMAEN, etd_mask); 240 + } else { 241 + if (dir != TD_DIR_IN) { 242 + /* need to set for ZLP */ 243 + set_toggle_bit(imx21, USBH_XFILLSTAT, etd_mask); 244 + set_toggle_bit(imx21, USBH_YFILLSTAT, etd_mask); 245 + } 246 + } 247 + 248 + DEBUG_LOG_FRAME(imx21, etd, activated); 249 + 250 + #ifdef DEBUG 251 + if (!etd->active_count) { 252 + int i; 253 + etd->activated_frame = readl(imx21->regs + USBH_FRMNUB); 254 + etd->disactivated_frame = -1; 255 + etd->last_int_frame = -1; 256 + etd->last_req_frame = -1; 257 + 258 + for (i = 0; i < 4; i++) 259 + etd->submitted_dwords[i] = etd_readl(imx21, etd_num, i); 260 + } 261 + #endif 262 + 263 + etd->active_count = 1; 264 + writel(etd_mask, imx21->regs + USBH_ETDENSET); 265 + } 266 + 267 + /* =========================================== */ 268 + /* Data memory management */ 269 + /* =========================================== */ 270 + 271 + static int alloc_dmem(struct imx21 *imx21, unsigned int size, 272 + struct usb_host_endpoint *ep) 273 + { 274 + unsigned int offset = 0; 275 + struct imx21_dmem_area *area; 276 + struct imx21_dmem_area *tmp; 277 + 278 + size += (~size + 1) & 0x3; /* Round to 4 byte multiple */ 279 + 280 + if (size > DMEM_SIZE) { 281 + dev_err(imx21->dev, "size=%d > DMEM_SIZE(%d)\n", 282 + size, DMEM_SIZE); 283 + return -EINVAL; 284 + } 285 + 286 + list_for_each_entry(tmp, &imx21->dmem_list, list) { 287 + if ((size + offset) < offset) 288 + goto fail; 289 + if ((size + offset) <= tmp->offset) 290 + break; 291 + offset = tmp->size + tmp->offset; 292 + if ((offset + size) > DMEM_SIZE) 293 + goto fail; 294 + } 295 + 296 + area = kmalloc(sizeof(struct imx21_dmem_area), GFP_ATOMIC); 297 + if (area == NULL) 298 + return -ENOMEM; 299 + 300 + area->ep = ep; 301 + area->offset = offset; 302 + area->size = size; 303 + list_add_tail(&area->list, &tmp->list); 304 + debug_dmem_allocated(imx21, size); 305 + return offset; 306 + 307 + fail: 308 + return -ENOMEM; 309 + } 310 + 311 + /* Memory now available for a queued ETD - activate it */ 312 + static void activate_queued_etd(struct imx21 *imx21, 313 + struct etd_priv *etd, u32 dmem_offset) 314 + { 315 + struct urb_priv *urb_priv = etd->urb->hcpriv; 316 + int etd_num = etd - &imx21->etd[0]; 317 + u32 maxpacket = etd_readl(imx21, etd_num, 1) >> DW1_YBUFSRTAD; 318 + u8 dir = (etd_readl(imx21, etd_num, 2) >> DW2_DIRPID) & 0x03; 319 + 320 + dev_dbg(imx21->dev, "activating queued ETD %d now DMEM available\n", 321 + etd_num); 322 + etd_writel(imx21, etd_num, 1, 323 + ((dmem_offset + maxpacket) << DW1_YBUFSRTAD) | dmem_offset); 324 + 325 + urb_priv->active = 1; 326 + activate_etd(imx21, etd_num, etd->dma_handle, dir); 327 + } 328 + 329 + static void free_dmem(struct imx21 *imx21, int offset) 330 + { 331 + struct imx21_dmem_area *area; 332 + struct etd_priv *etd, *tmp; 333 + int found = 0; 334 + 335 + list_for_each_entry(area, &imx21->dmem_list, list) { 336 + if (area->offset == offset) { 337 + debug_dmem_freed(imx21, area->size); 338 + list_del(&area->list); 339 + kfree(area); 340 + found = 1; 341 + break; 342 + } 343 + } 344 + 345 + if (!found) { 346 + dev_err(imx21->dev, 347 + "Trying to free unallocated DMEM %d\n", offset); 348 + return; 349 + } 350 + 351 + /* Try again to allocate memory for anything we've queued */ 352 + list_for_each_entry_safe(etd, tmp, &imx21->queue_for_dmem, queue) { 353 + offset = alloc_dmem(imx21, etd->dmem_size, etd->ep); 354 + if (offset >= 0) { 355 + list_del(&etd->queue); 356 + activate_queued_etd(imx21, etd, (u32)offset); 357 + } 358 + } 359 + } 360 + 361 + static void free_epdmem(struct imx21 *imx21, struct usb_host_endpoint *ep) 362 + { 363 + struct imx21_dmem_area *area, *tmp; 364 + 365 + list_for_each_entry_safe(area, tmp, &imx21->dmem_list, list) { 366 + if (area->ep == ep) { 367 + dev_err(imx21->dev, 368 + "Active DMEM %d for disabled ep=%p\n", 369 + area->offset, ep); 370 + list_del(&area->list); 371 + kfree(area); 372 + } 373 + } 374 + } 375 + 376 + 377 + /* =========================================== */ 378 + /* End handling */ 379 + /* =========================================== */ 380 + static void schedule_nonisoc_etd(struct imx21 *imx21, struct urb *urb); 381 + 382 + /* Endpoint now idle - release it's ETD(s) or asssign to queued request */ 383 + static void ep_idle(struct imx21 *imx21, struct ep_priv *ep_priv) 384 + { 385 + int etd_num; 386 + int i; 387 + 388 + for (i = 0; i < NUM_ISO_ETDS; i++) { 389 + etd_num = ep_priv->etd[i]; 390 + if (etd_num < 0) 391 + continue; 392 + 393 + ep_priv->etd[i] = -1; 394 + if (list_empty(&imx21->queue_for_etd)) { 395 + free_etd(imx21, etd_num); 396 + continue; 397 + } 398 + 399 + dev_dbg(imx21->dev, 400 + "assigning idle etd %d for queued request\n", etd_num); 401 + ep_priv = list_first_entry(&imx21->queue_for_etd, 402 + struct ep_priv, queue); 403 + list_del(&ep_priv->queue); 404 + reset_etd(imx21, etd_num); 405 + ep_priv->waiting_etd = 0; 406 + ep_priv->etd[i] = etd_num; 407 + 408 + if (list_empty(&ep_priv->ep->urb_list)) { 409 + dev_err(imx21->dev, "No urb for queued ep!\n"); 410 + continue; 411 + } 412 + schedule_nonisoc_etd(imx21, list_first_entry( 413 + &ep_priv->ep->urb_list, struct urb, urb_list)); 414 + } 415 + } 416 + 417 + static void urb_done(struct usb_hcd *hcd, struct urb *urb, int status) 418 + __releases(imx21->lock) 419 + __acquires(imx21->lock) 420 + { 421 + struct imx21 *imx21 = hcd_to_imx21(hcd); 422 + struct ep_priv *ep_priv = urb->ep->hcpriv; 423 + struct urb_priv *urb_priv = urb->hcpriv; 424 + 425 + debug_urb_completed(imx21, urb, status); 426 + dev_vdbg(imx21->dev, "urb %p done %d\n", urb, status); 427 + 428 + kfree(urb_priv->isoc_td); 429 + kfree(urb->hcpriv); 430 + urb->hcpriv = NULL; 431 + usb_hcd_unlink_urb_from_ep(hcd, urb); 432 + spin_unlock(&imx21->lock); 433 + usb_hcd_giveback_urb(hcd, urb, status); 434 + spin_lock(&imx21->lock); 435 + if (list_empty(&ep_priv->ep->urb_list)) 436 + ep_idle(imx21, ep_priv); 437 + } 438 + 439 + /* =========================================== */ 440 + /* ISOC Handling ... */ 441 + /* =========================================== */ 442 + 443 + static void schedule_isoc_etds(struct usb_hcd *hcd, 444 + struct usb_host_endpoint *ep) 445 + { 446 + struct imx21 *imx21 = hcd_to_imx21(hcd); 447 + struct ep_priv *ep_priv = ep->hcpriv; 448 + struct etd_priv *etd; 449 + struct urb_priv *urb_priv; 450 + struct td *td; 451 + int etd_num; 452 + int i; 453 + int cur_frame; 454 + u8 dir; 455 + 456 + for (i = 0; i < NUM_ISO_ETDS; i++) { 457 + too_late: 458 + if (list_empty(&ep_priv->td_list)) 459 + break; 460 + 461 + etd_num = ep_priv->etd[i]; 462 + if (etd_num < 0) 463 + break; 464 + 465 + etd = &imx21->etd[etd_num]; 466 + if (etd->urb) 467 + continue; 468 + 469 + td = list_entry(ep_priv->td_list.next, struct td, list); 470 + list_del(&td->list); 471 + urb_priv = td->urb->hcpriv; 472 + 473 + cur_frame = imx21_hc_get_frame(hcd); 474 + if (frame_after(cur_frame, td->frame)) { 475 + dev_dbg(imx21->dev, "isoc too late frame %d > %d\n", 476 + cur_frame, td->frame); 477 + urb_priv->isoc_status = -EXDEV; 478 + td->urb->iso_frame_desc[ 479 + td->isoc_index].actual_length = 0; 480 + td->urb->iso_frame_desc[td->isoc_index].status = -EXDEV; 481 + if (--urb_priv->isoc_remaining == 0) 482 + urb_done(hcd, td->urb, urb_priv->isoc_status); 483 + goto too_late; 484 + } 485 + 486 + urb_priv->active = 1; 487 + etd->td = td; 488 + etd->ep = td->ep; 489 + etd->urb = td->urb; 490 + etd->len = td->len; 491 + 492 + debug_isoc_submitted(imx21, cur_frame, td); 493 + 494 + dir = usb_pipeout(td->urb->pipe) ? TD_DIR_OUT : TD_DIR_IN; 495 + setup_etd_dword0(imx21, etd_num, td->urb, dir, etd->dmem_size); 496 + etd_writel(imx21, etd_num, 1, etd->dmem_offset); 497 + etd_writel(imx21, etd_num, 2, 498 + (TD_NOTACCESSED << DW2_COMPCODE) | 499 + ((td->frame & 0xFFFF) << DW2_STARTFRM)); 500 + etd_writel(imx21, etd_num, 3, 501 + (TD_NOTACCESSED << DW3_COMPCODE0) | 502 + (td->len << DW3_PKTLEN0)); 503 + 504 + activate_etd(imx21, etd_num, td->data, dir); 505 + } 506 + } 507 + 508 + static void isoc_etd_done(struct usb_hcd *hcd, struct urb *urb, int etd_num) 509 + { 510 + struct imx21 *imx21 = hcd_to_imx21(hcd); 511 + int etd_mask = 1 << etd_num; 512 + struct urb_priv *urb_priv = urb->hcpriv; 513 + struct etd_priv *etd = imx21->etd + etd_num; 514 + struct td *td = etd->td; 515 + struct usb_host_endpoint *ep = etd->ep; 516 + int isoc_index = td->isoc_index; 517 + unsigned int pipe = urb->pipe; 518 + int dir_in = usb_pipein(pipe); 519 + int cc; 520 + int bytes_xfrd; 521 + 522 + disactivate_etd(imx21, etd_num); 523 + 524 + cc = (etd_readl(imx21, etd_num, 3) >> DW3_COMPCODE0) & 0xf; 525 + bytes_xfrd = etd_readl(imx21, etd_num, 3) & 0x3ff; 526 + 527 + /* Input doesn't always fill the buffer, don't generate an error 528 + * when this happens. 529 + */ 530 + if (dir_in && (cc == TD_DATAUNDERRUN)) 531 + cc = TD_CC_NOERROR; 532 + 533 + if (cc == TD_NOTACCESSED) 534 + bytes_xfrd = 0; 535 + 536 + debug_isoc_completed(imx21, 537 + imx21_hc_get_frame(hcd), td, cc, bytes_xfrd); 538 + if (cc) { 539 + urb_priv->isoc_status = -EXDEV; 540 + dev_dbg(imx21->dev, 541 + "bad iso cc=0x%X frame=%d sched frame=%d " 542 + "cnt=%d len=%d urb=%p etd=%d index=%d\n", 543 + cc, imx21_hc_get_frame(hcd), td->frame, 544 + bytes_xfrd, td->len, urb, etd_num, isoc_index); 545 + } 546 + 547 + if (dir_in) 548 + clear_toggle_bit(imx21, USBH_XFILLSTAT, etd_mask); 549 + 550 + urb->actual_length += bytes_xfrd; 551 + urb->iso_frame_desc[isoc_index].actual_length = bytes_xfrd; 552 + urb->iso_frame_desc[isoc_index].status = cc_to_error[cc]; 553 + 554 + etd->td = NULL; 555 + etd->urb = NULL; 556 + etd->ep = NULL; 557 + 558 + if (--urb_priv->isoc_remaining == 0) 559 + urb_done(hcd, urb, urb_priv->isoc_status); 560 + 561 + schedule_isoc_etds(hcd, ep); 562 + } 563 + 564 + static struct ep_priv *alloc_isoc_ep( 565 + struct imx21 *imx21, struct usb_host_endpoint *ep) 566 + { 567 + struct ep_priv *ep_priv; 568 + int i; 569 + 570 + ep_priv = kzalloc(sizeof(struct ep_priv), GFP_ATOMIC); 571 + if (ep_priv == NULL) 572 + return NULL; 573 + 574 + /* Allocate the ETDs */ 575 + for (i = 0; i < NUM_ISO_ETDS; i++) { 576 + ep_priv->etd[i] = alloc_etd(imx21); 577 + if (ep_priv->etd[i] < 0) { 578 + int j; 579 + dev_err(imx21->dev, "isoc: Couldn't allocate etd\n"); 580 + for (j = 0; j < i; j++) 581 + free_etd(imx21, ep_priv->etd[j]); 582 + goto alloc_etd_failed; 583 + } 584 + imx21->etd[ep_priv->etd[i]].ep = ep; 585 + } 586 + 587 + INIT_LIST_HEAD(&ep_priv->td_list); 588 + ep_priv->ep = ep; 589 + ep->hcpriv = ep_priv; 590 + return ep_priv; 591 + 592 + alloc_etd_failed: 593 + kfree(ep_priv); 594 + return NULL; 595 + } 596 + 597 + static int imx21_hc_urb_enqueue_isoc(struct usb_hcd *hcd, 598 + struct usb_host_endpoint *ep, 599 + struct urb *urb, gfp_t mem_flags) 600 + { 601 + struct imx21 *imx21 = hcd_to_imx21(hcd); 602 + struct urb_priv *urb_priv; 603 + unsigned long flags; 604 + struct ep_priv *ep_priv; 605 + struct td *td = NULL; 606 + int i; 607 + int ret; 608 + int cur_frame; 609 + u16 maxpacket; 610 + 611 + urb_priv = kzalloc(sizeof(struct urb_priv), mem_flags); 612 + if (urb_priv == NULL) 613 + return -ENOMEM; 614 + 615 + urb_priv->isoc_td = kzalloc( 616 + sizeof(struct td) * urb->number_of_packets, mem_flags); 617 + if (urb_priv->isoc_td == NULL) { 618 + ret = -ENOMEM; 619 + goto alloc_td_failed; 620 + } 621 + 622 + spin_lock_irqsave(&imx21->lock, flags); 623 + 624 + if (ep->hcpriv == NULL) { 625 + ep_priv = alloc_isoc_ep(imx21, ep); 626 + if (ep_priv == NULL) { 627 + ret = -ENOMEM; 628 + goto alloc_ep_failed; 629 + } 630 + } else { 631 + ep_priv = ep->hcpriv; 632 + } 633 + 634 + ret = usb_hcd_link_urb_to_ep(hcd, urb); 635 + if (ret) 636 + goto link_failed; 637 + 638 + urb->status = -EINPROGRESS; 639 + urb->actual_length = 0; 640 + urb->error_count = 0; 641 + urb->hcpriv = urb_priv; 642 + urb_priv->ep = ep; 643 + 644 + /* allocate data memory for largest packets if not already done */ 645 + maxpacket = usb_maxpacket(urb->dev, urb->pipe, usb_pipeout(urb->pipe)); 646 + for (i = 0; i < NUM_ISO_ETDS; i++) { 647 + struct etd_priv *etd = &imx21->etd[ep_priv->etd[i]]; 648 + 649 + if (etd->dmem_size > 0 && etd->dmem_size < maxpacket) { 650 + /* not sure if this can really occur.... */ 651 + dev_err(imx21->dev, "increasing isoc buffer %d->%d\n", 652 + etd->dmem_size, maxpacket); 653 + ret = -EMSGSIZE; 654 + goto alloc_dmem_failed; 655 + } 656 + 657 + if (etd->dmem_size == 0) { 658 + etd->dmem_offset = alloc_dmem(imx21, maxpacket, ep); 659 + if (etd->dmem_offset < 0) { 660 + dev_dbg(imx21->dev, "failed alloc isoc dmem\n"); 661 + ret = -EAGAIN; 662 + goto alloc_dmem_failed; 663 + } 664 + etd->dmem_size = maxpacket; 665 + } 666 + } 667 + 668 + /* calculate frame */ 669 + cur_frame = imx21_hc_get_frame(hcd); 670 + if (urb->transfer_flags & URB_ISO_ASAP) { 671 + if (list_empty(&ep_priv->td_list)) 672 + urb->start_frame = cur_frame + 5; 673 + else 674 + urb->start_frame = list_entry( 675 + ep_priv->td_list.prev, 676 + struct td, list)->frame + urb->interval; 677 + } 678 + urb->start_frame = wrap_frame(urb->start_frame); 679 + if (frame_after(cur_frame, urb->start_frame)) { 680 + dev_dbg(imx21->dev, 681 + "enqueue: adjusting iso start %d (cur=%d) asap=%d\n", 682 + urb->start_frame, cur_frame, 683 + (urb->transfer_flags & URB_ISO_ASAP) != 0); 684 + urb->start_frame = wrap_frame(cur_frame + 1); 685 + } 686 + 687 + /* set up transfers */ 688 + td = urb_priv->isoc_td; 689 + for (i = 0; i < urb->number_of_packets; i++, td++) { 690 + td->ep = ep; 691 + td->urb = urb; 692 + td->len = urb->iso_frame_desc[i].length; 693 + td->isoc_index = i; 694 + td->frame = wrap_frame(urb->start_frame + urb->interval * i); 695 + td->data = urb->transfer_dma + urb->iso_frame_desc[i].offset; 696 + list_add_tail(&td->list, &ep_priv->td_list); 697 + } 698 + 699 + urb_priv->isoc_remaining = urb->number_of_packets; 700 + dev_vdbg(imx21->dev, "setup %d packets for iso frame %d->%d\n", 701 + urb->number_of_packets, urb->start_frame, td->frame); 702 + 703 + debug_urb_submitted(imx21, urb); 704 + schedule_isoc_etds(hcd, ep); 705 + 706 + spin_unlock_irqrestore(&imx21->lock, flags); 707 + return 0; 708 + 709 + alloc_dmem_failed: 710 + usb_hcd_unlink_urb_from_ep(hcd, urb); 711 + 712 + link_failed: 713 + alloc_ep_failed: 714 + spin_unlock_irqrestore(&imx21->lock, flags); 715 + kfree(urb_priv->isoc_td); 716 + 717 + alloc_td_failed: 718 + kfree(urb_priv); 719 + return ret; 720 + } 721 + 722 + static void dequeue_isoc_urb(struct imx21 *imx21, 723 + struct urb *urb, struct ep_priv *ep_priv) 724 + { 725 + struct urb_priv *urb_priv = urb->hcpriv; 726 + struct td *td, *tmp; 727 + int i; 728 + 729 + if (urb_priv->active) { 730 + for (i = 0; i < NUM_ISO_ETDS; i++) { 731 + int etd_num = ep_priv->etd[i]; 732 + if (etd_num != -1 && imx21->etd[etd_num].urb == urb) { 733 + struct etd_priv *etd = imx21->etd + etd_num; 734 + 735 + reset_etd(imx21, etd_num); 736 + if (etd->dmem_size) 737 + free_dmem(imx21, etd->dmem_offset); 738 + etd->dmem_size = 0; 739 + } 740 + } 741 + } 742 + 743 + list_for_each_entry_safe(td, tmp, &ep_priv->td_list, list) { 744 + if (td->urb == urb) { 745 + dev_vdbg(imx21->dev, "removing td %p\n", td); 746 + list_del(&td->list); 747 + } 748 + } 749 + } 750 + 751 + /* =========================================== */ 752 + /* NON ISOC Handling ... */ 753 + /* =========================================== */ 754 + 755 + static void schedule_nonisoc_etd(struct imx21 *imx21, struct urb *urb) 756 + { 757 + unsigned int pipe = urb->pipe; 758 + struct urb_priv *urb_priv = urb->hcpriv; 759 + struct ep_priv *ep_priv = urb_priv->ep->hcpriv; 760 + int state = urb_priv->state; 761 + int etd_num = ep_priv->etd[0]; 762 + struct etd_priv *etd; 763 + int dmem_offset; 764 + u32 count; 765 + u16 etd_buf_size; 766 + u16 maxpacket; 767 + u8 dir; 768 + u8 bufround; 769 + u8 datatoggle; 770 + u8 interval = 0; 771 + u8 relpolpos = 0; 772 + 773 + if (etd_num < 0) { 774 + dev_err(imx21->dev, "No valid ETD\n"); 775 + return; 776 + } 777 + if (readl(imx21->regs + USBH_ETDENSET) & (1 << etd_num)) 778 + dev_err(imx21->dev, "submitting to active ETD %d\n", etd_num); 779 + 780 + etd = &imx21->etd[etd_num]; 781 + maxpacket = usb_maxpacket(urb->dev, pipe, usb_pipeout(pipe)); 782 + if (!maxpacket) 783 + maxpacket = 8; 784 + 785 + if (usb_pipecontrol(pipe) && (state != US_CTRL_DATA)) { 786 + if (state == US_CTRL_SETUP) { 787 + dir = TD_DIR_SETUP; 788 + etd->dma_handle = urb->setup_dma; 789 + bufround = 0; 790 + count = 8; 791 + datatoggle = TD_TOGGLE_DATA0; 792 + } else { /* US_CTRL_ACK */ 793 + dir = usb_pipeout(pipe) ? TD_DIR_IN : TD_DIR_OUT; 794 + etd->dma_handle = urb->transfer_dma; 795 + bufround = 0; 796 + count = 0; 797 + datatoggle = TD_TOGGLE_DATA1; 798 + } 799 + } else { 800 + dir = usb_pipeout(pipe) ? TD_DIR_OUT : TD_DIR_IN; 801 + bufround = (dir == TD_DIR_IN) ? 1 : 0; 802 + etd->dma_handle = urb->transfer_dma; 803 + if (usb_pipebulk(pipe) && (state == US_BULK0)) 804 + count = 0; 805 + else 806 + count = urb->transfer_buffer_length; 807 + 808 + if (usb_pipecontrol(pipe)) { 809 + datatoggle = TD_TOGGLE_DATA1; 810 + } else { 811 + if (usb_gettoggle( 812 + urb->dev, 813 + usb_pipeendpoint(urb->pipe), 814 + usb_pipeout(urb->pipe))) 815 + datatoggle = TD_TOGGLE_DATA1; 816 + else 817 + datatoggle = TD_TOGGLE_DATA0; 818 + } 819 + } 820 + 821 + etd->urb = urb; 822 + etd->ep = urb_priv->ep; 823 + etd->len = count; 824 + 825 + if (usb_pipeint(pipe)) { 826 + interval = urb->interval; 827 + relpolpos = (readl(imx21->regs + USBH_FRMNUB) + 1) & 0xff; 828 + } 829 + 830 + /* Write ETD to device memory */ 831 + setup_etd_dword0(imx21, etd_num, urb, dir, maxpacket); 832 + 833 + etd_writel(imx21, etd_num, 2, 834 + (u32) interval << DW2_POLINTERV | 835 + ((u32) relpolpos << DW2_RELPOLPOS) | 836 + ((u32) dir << DW2_DIRPID) | 837 + ((u32) bufround << DW2_BUFROUND) | 838 + ((u32) datatoggle << DW2_DATATOG) | 839 + ((u32) TD_NOTACCESSED << DW2_COMPCODE)); 840 + 841 + /* DMA will always transfer buffer size even if TOBYCNT in DWORD3 842 + is smaller. Make sure we don't overrun the buffer! 843 + */ 844 + if (count && count < maxpacket) 845 + etd_buf_size = count; 846 + else 847 + etd_buf_size = maxpacket; 848 + 849 + etd_writel(imx21, etd_num, 3, 850 + ((u32) (etd_buf_size - 1) << DW3_BUFSIZE) | (u32) count); 851 + 852 + if (!count) 853 + etd->dma_handle = 0; 854 + 855 + /* allocate x and y buffer space at once */ 856 + etd->dmem_size = (count > maxpacket) ? maxpacket * 2 : maxpacket; 857 + dmem_offset = alloc_dmem(imx21, etd->dmem_size, urb_priv->ep); 858 + if (dmem_offset < 0) { 859 + /* Setup everything we can in HW and update when we get DMEM */ 860 + etd_writel(imx21, etd_num, 1, (u32)maxpacket << 16); 861 + 862 + dev_dbg(imx21->dev, "Queuing etd %d for DMEM\n", etd_num); 863 + debug_urb_queued_for_dmem(imx21, urb); 864 + list_add_tail(&etd->queue, &imx21->queue_for_dmem); 865 + return; 866 + } 867 + 868 + etd_writel(imx21, etd_num, 1, 869 + (((u32) dmem_offset + (u32) maxpacket) << DW1_YBUFSRTAD) | 870 + (u32) dmem_offset); 871 + 872 + urb_priv->active = 1; 873 + 874 + /* enable the ETD to kick off transfer */ 875 + dev_vdbg(imx21->dev, "Activating etd %d for %d bytes %s\n", 876 + etd_num, count, dir != TD_DIR_IN ? "out" : "in"); 877 + activate_etd(imx21, etd_num, etd->dma_handle, dir); 878 + 879 + } 880 + 881 + static void nonisoc_etd_done(struct usb_hcd *hcd, struct urb *urb, int etd_num) 882 + { 883 + struct imx21 *imx21 = hcd_to_imx21(hcd); 884 + struct etd_priv *etd = &imx21->etd[etd_num]; 885 + u32 etd_mask = 1 << etd_num; 886 + struct urb_priv *urb_priv = urb->hcpriv; 887 + int dir; 888 + u16 xbufaddr; 889 + int cc; 890 + u32 bytes_xfrd; 891 + int etd_done; 892 + 893 + disactivate_etd(imx21, etd_num); 894 + 895 + dir = (etd_readl(imx21, etd_num, 0) >> DW0_DIRECT) & 0x3; 896 + xbufaddr = etd_readl(imx21, etd_num, 1) & 0xffff; 897 + cc = (etd_readl(imx21, etd_num, 2) >> DW2_COMPCODE) & 0xf; 898 + bytes_xfrd = etd->len - (etd_readl(imx21, etd_num, 3) & 0x1fffff); 899 + 900 + /* save toggle carry */ 901 + usb_settoggle(urb->dev, usb_pipeendpoint(urb->pipe), 902 + usb_pipeout(urb->pipe), 903 + (etd_readl(imx21, etd_num, 0) >> DW0_TOGCRY) & 0x1); 904 + 905 + if (dir == TD_DIR_IN) { 906 + clear_toggle_bit(imx21, USBH_XFILLSTAT, etd_mask); 907 + clear_toggle_bit(imx21, USBH_YFILLSTAT, etd_mask); 908 + } 909 + free_dmem(imx21, xbufaddr); 910 + 911 + urb->error_count = 0; 912 + if (!(urb->transfer_flags & URB_SHORT_NOT_OK) 913 + && (cc == TD_DATAUNDERRUN)) 914 + cc = TD_CC_NOERROR; 915 + 916 + if (cc != 0) 917 + dev_vdbg(imx21->dev, "cc is 0x%x\n", cc); 918 + 919 + etd_done = (cc_to_error[cc] != 0); /* stop if error */ 920 + 921 + switch (usb_pipetype(urb->pipe)) { 922 + case PIPE_CONTROL: 923 + switch (urb_priv->state) { 924 + case US_CTRL_SETUP: 925 + if (urb->transfer_buffer_length > 0) 926 + urb_priv->state = US_CTRL_DATA; 927 + else 928 + urb_priv->state = US_CTRL_ACK; 929 + break; 930 + case US_CTRL_DATA: 931 + urb->actual_length += bytes_xfrd; 932 + urb_priv->state = US_CTRL_ACK; 933 + break; 934 + case US_CTRL_ACK: 935 + etd_done = 1; 936 + break; 937 + default: 938 + dev_err(imx21->dev, 939 + "Invalid pipe state %d\n", urb_priv->state); 940 + etd_done = 1; 941 + break; 942 + } 943 + break; 944 + 945 + case PIPE_BULK: 946 + urb->actual_length += bytes_xfrd; 947 + if ((urb_priv->state == US_BULK) 948 + && (urb->transfer_flags & URB_ZERO_PACKET) 949 + && urb->transfer_buffer_length > 0 950 + && ((urb->transfer_buffer_length % 951 + usb_maxpacket(urb->dev, urb->pipe, 952 + usb_pipeout(urb->pipe))) == 0)) { 953 + /* need a 0-packet */ 954 + urb_priv->state = US_BULK0; 955 + } else { 956 + etd_done = 1; 957 + } 958 + break; 959 + 960 + case PIPE_INTERRUPT: 961 + urb->actual_length += bytes_xfrd; 962 + etd_done = 1; 963 + break; 964 + } 965 + 966 + if (!etd_done) { 967 + dev_vdbg(imx21->dev, "next state=%d\n", urb_priv->state); 968 + schedule_nonisoc_etd(imx21, urb); 969 + } else { 970 + struct usb_host_endpoint *ep = urb->ep; 971 + 972 + urb_done(hcd, urb, cc_to_error[cc]); 973 + etd->urb = NULL; 974 + 975 + if (!list_empty(&ep->urb_list)) { 976 + urb = list_first_entry(&ep->urb_list, 977 + struct urb, urb_list); 978 + dev_vdbg(imx21->dev, "next URB %p\n", urb); 979 + schedule_nonisoc_etd(imx21, urb); 980 + } 981 + } 982 + } 983 + 984 + static struct ep_priv *alloc_ep(void) 985 + { 986 + int i; 987 + struct ep_priv *ep_priv; 988 + 989 + ep_priv = kzalloc(sizeof(struct ep_priv), GFP_ATOMIC); 990 + if (!ep_priv) 991 + return NULL; 992 + 993 + for (i = 0; i < NUM_ISO_ETDS; ++i) 994 + ep_priv->etd[i] = -1; 995 + 996 + return ep_priv; 997 + } 998 + 999 + static int imx21_hc_urb_enqueue(struct usb_hcd *hcd, 1000 + struct urb *urb, gfp_t mem_flags) 1001 + { 1002 + struct imx21 *imx21 = hcd_to_imx21(hcd); 1003 + struct usb_host_endpoint *ep = urb->ep; 1004 + struct urb_priv *urb_priv; 1005 + struct ep_priv *ep_priv; 1006 + struct etd_priv *etd; 1007 + int ret; 1008 + unsigned long flags; 1009 + int new_ep = 0; 1010 + 1011 + dev_vdbg(imx21->dev, 1012 + "enqueue urb=%p ep=%p len=%d " 1013 + "buffer=%p dma=%08X setupBuf=%p setupDma=%08X\n", 1014 + urb, ep, 1015 + urb->transfer_buffer_length, 1016 + urb->transfer_buffer, urb->transfer_dma, 1017 + urb->setup_packet, urb->setup_dma); 1018 + 1019 + if (usb_pipeisoc(urb->pipe)) 1020 + return imx21_hc_urb_enqueue_isoc(hcd, ep, urb, mem_flags); 1021 + 1022 + urb_priv = kzalloc(sizeof(struct urb_priv), mem_flags); 1023 + if (!urb_priv) 1024 + return -ENOMEM; 1025 + 1026 + spin_lock_irqsave(&imx21->lock, flags); 1027 + 1028 + ep_priv = ep->hcpriv; 1029 + if (ep_priv == NULL) { 1030 + ep_priv = alloc_ep(); 1031 + if (!ep_priv) { 1032 + ret = -ENOMEM; 1033 + goto failed_alloc_ep; 1034 + } 1035 + ep->hcpriv = ep_priv; 1036 + ep_priv->ep = ep; 1037 + new_ep = 1; 1038 + } 1039 + 1040 + ret = usb_hcd_link_urb_to_ep(hcd, urb); 1041 + if (ret) 1042 + goto failed_link; 1043 + 1044 + urb->status = -EINPROGRESS; 1045 + urb->actual_length = 0; 1046 + urb->error_count = 0; 1047 + urb->hcpriv = urb_priv; 1048 + urb_priv->ep = ep; 1049 + 1050 + switch (usb_pipetype(urb->pipe)) { 1051 + case PIPE_CONTROL: 1052 + urb_priv->state = US_CTRL_SETUP; 1053 + break; 1054 + case PIPE_BULK: 1055 + urb_priv->state = US_BULK; 1056 + break; 1057 + } 1058 + 1059 + debug_urb_submitted(imx21, urb); 1060 + if (ep_priv->etd[0] < 0) { 1061 + if (ep_priv->waiting_etd) { 1062 + dev_dbg(imx21->dev, 1063 + "no ETD available already queued %p\n", 1064 + ep_priv); 1065 + debug_urb_queued_for_etd(imx21, urb); 1066 + goto out; 1067 + } 1068 + ep_priv->etd[0] = alloc_etd(imx21); 1069 + if (ep_priv->etd[0] < 0) { 1070 + dev_dbg(imx21->dev, 1071 + "no ETD available queueing %p\n", ep_priv); 1072 + debug_urb_queued_for_etd(imx21, urb); 1073 + list_add_tail(&ep_priv->queue, &imx21->queue_for_etd); 1074 + ep_priv->waiting_etd = 1; 1075 + goto out; 1076 + } 1077 + } 1078 + 1079 + /* Schedule if no URB already active for this endpoint */ 1080 + etd = &imx21->etd[ep_priv->etd[0]]; 1081 + if (etd->urb == NULL) { 1082 + DEBUG_LOG_FRAME(imx21, etd, last_req); 1083 + schedule_nonisoc_etd(imx21, urb); 1084 + } 1085 + 1086 + out: 1087 + spin_unlock_irqrestore(&imx21->lock, flags); 1088 + return 0; 1089 + 1090 + failed_link: 1091 + failed_alloc_ep: 1092 + spin_unlock_irqrestore(&imx21->lock, flags); 1093 + kfree(urb_priv); 1094 + return ret; 1095 + } 1096 + 1097 + static int imx21_hc_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, 1098 + int status) 1099 + { 1100 + struct imx21 *imx21 = hcd_to_imx21(hcd); 1101 + unsigned long flags; 1102 + struct usb_host_endpoint *ep; 1103 + struct ep_priv *ep_priv; 1104 + struct urb_priv *urb_priv = urb->hcpriv; 1105 + int ret = -EINVAL; 1106 + 1107 + dev_vdbg(imx21->dev, "dequeue urb=%p iso=%d status=%d\n", 1108 + urb, usb_pipeisoc(urb->pipe), status); 1109 + 1110 + spin_lock_irqsave(&imx21->lock, flags); 1111 + 1112 + ret = usb_hcd_check_unlink_urb(hcd, urb, status); 1113 + if (ret) 1114 + goto fail; 1115 + ep = urb_priv->ep; 1116 + ep_priv = ep->hcpriv; 1117 + 1118 + debug_urb_unlinked(imx21, urb); 1119 + 1120 + if (usb_pipeisoc(urb->pipe)) { 1121 + dequeue_isoc_urb(imx21, urb, ep_priv); 1122 + schedule_isoc_etds(hcd, ep); 1123 + } else if (urb_priv->active) { 1124 + int etd_num = ep_priv->etd[0]; 1125 + if (etd_num != -1) { 1126 + disactivate_etd(imx21, etd_num); 1127 + free_dmem(imx21, etd_readl(imx21, etd_num, 1) & 0xffff); 1128 + imx21->etd[etd_num].urb = NULL; 1129 + } 1130 + } 1131 + 1132 + urb_done(hcd, urb, status); 1133 + 1134 + spin_unlock_irqrestore(&imx21->lock, flags); 1135 + return 0; 1136 + 1137 + fail: 1138 + spin_unlock_irqrestore(&imx21->lock, flags); 1139 + return ret; 1140 + } 1141 + 1142 + /* =========================================== */ 1143 + /* Interrupt dispatch */ 1144 + /* =========================================== */ 1145 + 1146 + static void process_etds(struct usb_hcd *hcd, struct imx21 *imx21, int sof) 1147 + { 1148 + int etd_num; 1149 + int enable_sof_int = 0; 1150 + unsigned long flags; 1151 + 1152 + spin_lock_irqsave(&imx21->lock, flags); 1153 + 1154 + for (etd_num = 0; etd_num < USB_NUM_ETD; etd_num++) { 1155 + u32 etd_mask = 1 << etd_num; 1156 + u32 enabled = readl(imx21->regs + USBH_ETDENSET) & etd_mask; 1157 + u32 done = readl(imx21->regs + USBH_ETDDONESTAT) & etd_mask; 1158 + struct etd_priv *etd = &imx21->etd[etd_num]; 1159 + 1160 + 1161 + if (done) { 1162 + DEBUG_LOG_FRAME(imx21, etd, last_int); 1163 + } else { 1164 + /* 1165 + * Kludge warning! 1166 + * 1167 + * When multiple transfers are using the bus we sometimes get into a state 1168 + * where the transfer has completed (the CC field of the ETD is != 0x0F), 1169 + * the ETD has self disabled but the ETDDONESTAT flag is not set 1170 + * (and hence no interrupt occurs). 1171 + * This causes the transfer in question to hang. 1172 + * The kludge below checks for this condition at each SOF and processes any 1173 + * blocked ETDs (after an arbitary 10 frame wait) 1174 + * 1175 + * With a single active transfer the usbtest test suite will run for days 1176 + * without the kludge. 1177 + * With other bus activity (eg mass storage) even just test1 will hang without 1178 + * the kludge. 1179 + */ 1180 + u32 dword0; 1181 + int cc; 1182 + 1183 + if (etd->active_count && !enabled) /* suspicious... */ 1184 + enable_sof_int = 1; 1185 + 1186 + if (!sof || enabled || !etd->active_count) 1187 + continue; 1188 + 1189 + cc = etd_readl(imx21, etd_num, 2) >> DW2_COMPCODE; 1190 + if (cc == TD_NOTACCESSED) 1191 + continue; 1192 + 1193 + if (++etd->active_count < 10) 1194 + continue; 1195 + 1196 + dword0 = etd_readl(imx21, etd_num, 0); 1197 + dev_dbg(imx21->dev, 1198 + "unblock ETD %d dev=0x%X ep=0x%X cc=0x%02X!\n", 1199 + etd_num, dword0 & 0x7F, 1200 + (dword0 >> DW0_ENDPNT) & 0x0F, 1201 + cc); 1202 + 1203 + #ifdef DEBUG 1204 + dev_dbg(imx21->dev, 1205 + "frame: act=%d disact=%d" 1206 + " int=%d req=%d cur=%d\n", 1207 + etd->activated_frame, 1208 + etd->disactivated_frame, 1209 + etd->last_int_frame, 1210 + etd->last_req_frame, 1211 + readl(imx21->regs + USBH_FRMNUB)); 1212 + imx21->debug_unblocks++; 1213 + #endif 1214 + etd->active_count = 0; 1215 + /* End of kludge */ 1216 + } 1217 + 1218 + if (etd->ep == NULL || etd->urb == NULL) { 1219 + dev_dbg(imx21->dev, 1220 + "Interrupt for unexpected etd %d" 1221 + " ep=%p urb=%p\n", 1222 + etd_num, etd->ep, etd->urb); 1223 + disactivate_etd(imx21, etd_num); 1224 + continue; 1225 + } 1226 + 1227 + if (usb_pipeisoc(etd->urb->pipe)) 1228 + isoc_etd_done(hcd, etd->urb, etd_num); 1229 + else 1230 + nonisoc_etd_done(hcd, etd->urb, etd_num); 1231 + } 1232 + 1233 + /* only enable SOF interrupt if it may be needed for the kludge */ 1234 + if (enable_sof_int) 1235 + set_register_bits(imx21, USBH_SYSIEN, USBH_SYSIEN_SOFINT); 1236 + else 1237 + clear_register_bits(imx21, USBH_SYSIEN, USBH_SYSIEN_SOFINT); 1238 + 1239 + 1240 + spin_unlock_irqrestore(&imx21->lock, flags); 1241 + } 1242 + 1243 + static irqreturn_t imx21_irq(struct usb_hcd *hcd) 1244 + { 1245 + struct imx21 *imx21 = hcd_to_imx21(hcd); 1246 + u32 ints = readl(imx21->regs + USBH_SYSISR); 1247 + 1248 + if (ints & USBH_SYSIEN_HERRINT) 1249 + dev_dbg(imx21->dev, "Scheduling error\n"); 1250 + 1251 + if (ints & USBH_SYSIEN_SORINT) 1252 + dev_dbg(imx21->dev, "Scheduling overrun\n"); 1253 + 1254 + if (ints & (USBH_SYSISR_DONEINT | USBH_SYSISR_SOFINT)) 1255 + process_etds(hcd, imx21, ints & USBH_SYSISR_SOFINT); 1256 + 1257 + writel(ints, imx21->regs + USBH_SYSISR); 1258 + return IRQ_HANDLED; 1259 + } 1260 + 1261 + static void imx21_hc_endpoint_disable(struct usb_hcd *hcd, 1262 + struct usb_host_endpoint *ep) 1263 + { 1264 + struct imx21 *imx21 = hcd_to_imx21(hcd); 1265 + unsigned long flags; 1266 + struct ep_priv *ep_priv; 1267 + int i; 1268 + 1269 + if (ep == NULL) 1270 + return; 1271 + 1272 + spin_lock_irqsave(&imx21->lock, flags); 1273 + ep_priv = ep->hcpriv; 1274 + dev_vdbg(imx21->dev, "disable ep=%p, ep->hcpriv=%p\n", ep, ep_priv); 1275 + 1276 + if (!list_empty(&ep->urb_list)) 1277 + dev_dbg(imx21->dev, "ep's URB list is not empty\n"); 1278 + 1279 + if (ep_priv != NULL) { 1280 + for (i = 0; i < NUM_ISO_ETDS; i++) { 1281 + if (ep_priv->etd[i] > -1) 1282 + dev_dbg(imx21->dev, "free etd %d for disable\n", 1283 + ep_priv->etd[i]); 1284 + 1285 + free_etd(imx21, ep_priv->etd[i]); 1286 + } 1287 + kfree(ep_priv); 1288 + ep->hcpriv = NULL; 1289 + } 1290 + 1291 + for (i = 0; i < USB_NUM_ETD; i++) { 1292 + if (imx21->etd[i].alloc && imx21->etd[i].ep == ep) { 1293 + dev_err(imx21->dev, 1294 + "Active etd %d for disabled ep=%p!\n", i, ep); 1295 + free_etd(imx21, i); 1296 + } 1297 + } 1298 + free_epdmem(imx21, ep); 1299 + spin_unlock_irqrestore(&imx21->lock, flags); 1300 + } 1301 + 1302 + /* =========================================== */ 1303 + /* Hub handling */ 1304 + /* =========================================== */ 1305 + 1306 + static int get_hub_descriptor(struct usb_hcd *hcd, 1307 + struct usb_hub_descriptor *desc) 1308 + { 1309 + struct imx21 *imx21 = hcd_to_imx21(hcd); 1310 + desc->bDescriptorType = 0x29; /* HUB descriptor */ 1311 + desc->bHubContrCurrent = 0; 1312 + 1313 + desc->bNbrPorts = readl(imx21->regs + USBH_ROOTHUBA) 1314 + & USBH_ROOTHUBA_NDNSTMPRT_MASK; 1315 + desc->bDescLength = 9; 1316 + desc->bPwrOn2PwrGood = 0; 1317 + desc->wHubCharacteristics = (__force __u16) cpu_to_le16( 1318 + 0x0002 | /* No power switching */ 1319 + 0x0010 | /* No over current protection */ 1320 + 0); 1321 + 1322 + desc->bitmap[0] = 1 << 1; 1323 + desc->bitmap[1] = ~0; 1324 + return 0; 1325 + } 1326 + 1327 + static int imx21_hc_hub_status_data(struct usb_hcd *hcd, char *buf) 1328 + { 1329 + struct imx21 *imx21 = hcd_to_imx21(hcd); 1330 + int ports; 1331 + int changed = 0; 1332 + int i; 1333 + unsigned long flags; 1334 + 1335 + spin_lock_irqsave(&imx21->lock, flags); 1336 + ports = readl(imx21->regs + USBH_ROOTHUBA) 1337 + & USBH_ROOTHUBA_NDNSTMPRT_MASK; 1338 + if (ports > 7) { 1339 + ports = 7; 1340 + dev_err(imx21->dev, "ports %d > 7\n", ports); 1341 + } 1342 + for (i = 0; i < ports; i++) { 1343 + if (readl(imx21->regs + USBH_PORTSTAT(i)) & 1344 + (USBH_PORTSTAT_CONNECTSC | 1345 + USBH_PORTSTAT_PRTENBLSC | 1346 + USBH_PORTSTAT_PRTSTATSC | 1347 + USBH_PORTSTAT_OVRCURIC | 1348 + USBH_PORTSTAT_PRTRSTSC)) { 1349 + 1350 + changed = 1; 1351 + buf[0] |= 1 << (i + 1); 1352 + } 1353 + } 1354 + spin_unlock_irqrestore(&imx21->lock, flags); 1355 + 1356 + if (changed) 1357 + dev_info(imx21->dev, "Hub status changed\n"); 1358 + return changed; 1359 + } 1360 + 1361 + static int imx21_hc_hub_control(struct usb_hcd *hcd, 1362 + u16 typeReq, 1363 + u16 wValue, u16 wIndex, char *buf, u16 wLength) 1364 + { 1365 + struct imx21 *imx21 = hcd_to_imx21(hcd); 1366 + int rc = 0; 1367 + u32 status_write = 0; 1368 + 1369 + switch (typeReq) { 1370 + case ClearHubFeature: 1371 + dev_dbg(imx21->dev, "ClearHubFeature\n"); 1372 + switch (wValue) { 1373 + case C_HUB_OVER_CURRENT: 1374 + dev_dbg(imx21->dev, " OVER_CURRENT\n"); 1375 + break; 1376 + case C_HUB_LOCAL_POWER: 1377 + dev_dbg(imx21->dev, " LOCAL_POWER\n"); 1378 + break; 1379 + default: 1380 + dev_dbg(imx21->dev, " unknown\n"); 1381 + rc = -EINVAL; 1382 + break; 1383 + } 1384 + break; 1385 + 1386 + case ClearPortFeature: 1387 + dev_dbg(imx21->dev, "ClearPortFeature\n"); 1388 + switch (wValue) { 1389 + case USB_PORT_FEAT_ENABLE: 1390 + dev_dbg(imx21->dev, " ENABLE\n"); 1391 + status_write = USBH_PORTSTAT_CURCONST; 1392 + break; 1393 + case USB_PORT_FEAT_SUSPEND: 1394 + dev_dbg(imx21->dev, " SUSPEND\n"); 1395 + status_write = USBH_PORTSTAT_PRTOVRCURI; 1396 + break; 1397 + case USB_PORT_FEAT_POWER: 1398 + dev_dbg(imx21->dev, " POWER\n"); 1399 + status_write = USBH_PORTSTAT_LSDEVCON; 1400 + break; 1401 + case USB_PORT_FEAT_C_ENABLE: 1402 + dev_dbg(imx21->dev, " C_ENABLE\n"); 1403 + status_write = USBH_PORTSTAT_PRTENBLSC; 1404 + break; 1405 + case USB_PORT_FEAT_C_SUSPEND: 1406 + dev_dbg(imx21->dev, " C_SUSPEND\n"); 1407 + status_write = USBH_PORTSTAT_PRTSTATSC; 1408 + break; 1409 + case USB_PORT_FEAT_C_CONNECTION: 1410 + dev_dbg(imx21->dev, " C_CONNECTION\n"); 1411 + status_write = USBH_PORTSTAT_CONNECTSC; 1412 + break; 1413 + case USB_PORT_FEAT_C_OVER_CURRENT: 1414 + dev_dbg(imx21->dev, " C_OVER_CURRENT\n"); 1415 + status_write = USBH_PORTSTAT_OVRCURIC; 1416 + break; 1417 + case USB_PORT_FEAT_C_RESET: 1418 + dev_dbg(imx21->dev, " C_RESET\n"); 1419 + status_write = USBH_PORTSTAT_PRTRSTSC; 1420 + break; 1421 + default: 1422 + dev_dbg(imx21->dev, " unknown\n"); 1423 + rc = -EINVAL; 1424 + break; 1425 + } 1426 + 1427 + break; 1428 + 1429 + case GetHubDescriptor: 1430 + dev_dbg(imx21->dev, "GetHubDescriptor\n"); 1431 + rc = get_hub_descriptor(hcd, (void *)buf); 1432 + break; 1433 + 1434 + case GetHubStatus: 1435 + dev_dbg(imx21->dev, " GetHubStatus\n"); 1436 + *(__le32 *) buf = 0; 1437 + break; 1438 + 1439 + case GetPortStatus: 1440 + dev_dbg(imx21->dev, "GetPortStatus: port: %d, 0x%x\n", 1441 + wIndex, USBH_PORTSTAT(wIndex - 1)); 1442 + *(__le32 *) buf = readl(imx21->regs + 1443 + USBH_PORTSTAT(wIndex - 1)); 1444 + break; 1445 + 1446 + case SetHubFeature: 1447 + dev_dbg(imx21->dev, "SetHubFeature\n"); 1448 + switch (wValue) { 1449 + case C_HUB_OVER_CURRENT: 1450 + dev_dbg(imx21->dev, " OVER_CURRENT\n"); 1451 + break; 1452 + 1453 + case C_HUB_LOCAL_POWER: 1454 + dev_dbg(imx21->dev, " LOCAL_POWER\n"); 1455 + break; 1456 + default: 1457 + dev_dbg(imx21->dev, " unknown\n"); 1458 + rc = -EINVAL; 1459 + break; 1460 + } 1461 + 1462 + break; 1463 + 1464 + case SetPortFeature: 1465 + dev_dbg(imx21->dev, "SetPortFeature\n"); 1466 + switch (wValue) { 1467 + case USB_PORT_FEAT_SUSPEND: 1468 + dev_dbg(imx21->dev, " SUSPEND\n"); 1469 + status_write = USBH_PORTSTAT_PRTSUSPST; 1470 + break; 1471 + case USB_PORT_FEAT_POWER: 1472 + dev_dbg(imx21->dev, " POWER\n"); 1473 + status_write = USBH_PORTSTAT_PRTPWRST; 1474 + break; 1475 + case USB_PORT_FEAT_RESET: 1476 + dev_dbg(imx21->dev, " RESET\n"); 1477 + status_write = USBH_PORTSTAT_PRTRSTST; 1478 + break; 1479 + default: 1480 + dev_dbg(imx21->dev, " unknown\n"); 1481 + rc = -EINVAL; 1482 + break; 1483 + } 1484 + break; 1485 + 1486 + default: 1487 + dev_dbg(imx21->dev, " unknown\n"); 1488 + rc = -EINVAL; 1489 + break; 1490 + } 1491 + 1492 + if (status_write) 1493 + writel(status_write, imx21->regs + USBH_PORTSTAT(wIndex - 1)); 1494 + return rc; 1495 + } 1496 + 1497 + /* =========================================== */ 1498 + /* Host controller management */ 1499 + /* =========================================== */ 1500 + 1501 + static int imx21_hc_reset(struct usb_hcd *hcd) 1502 + { 1503 + struct imx21 *imx21 = hcd_to_imx21(hcd); 1504 + unsigned long timeout; 1505 + unsigned long flags; 1506 + 1507 + spin_lock_irqsave(&imx21->lock, flags); 1508 + 1509 + /* Reset the Host controler modules */ 1510 + writel(USBOTG_RST_RSTCTRL | USBOTG_RST_RSTRH | 1511 + USBOTG_RST_RSTHSIE | USBOTG_RST_RSTHC, 1512 + imx21->regs + USBOTG_RST_CTRL); 1513 + 1514 + /* Wait for reset to finish */ 1515 + timeout = jiffies + HZ; 1516 + while (readl(imx21->regs + USBOTG_RST_CTRL) != 0) { 1517 + if (time_after(jiffies, timeout)) { 1518 + spin_unlock_irqrestore(&imx21->lock, flags); 1519 + dev_err(imx21->dev, "timeout waiting for reset\n"); 1520 + return -ETIMEDOUT; 1521 + } 1522 + spin_unlock_irq(&imx21->lock); 1523 + schedule_timeout(1); 1524 + spin_lock_irq(&imx21->lock); 1525 + } 1526 + spin_unlock_irqrestore(&imx21->lock, flags); 1527 + return 0; 1528 + } 1529 + 1530 + static int __devinit imx21_hc_start(struct usb_hcd *hcd) 1531 + { 1532 + struct imx21 *imx21 = hcd_to_imx21(hcd); 1533 + unsigned long flags; 1534 + int i, j; 1535 + u32 hw_mode = USBOTG_HWMODE_CRECFG_HOST; 1536 + u32 usb_control = 0; 1537 + 1538 + hw_mode |= ((imx21->pdata->host_xcvr << USBOTG_HWMODE_HOSTXCVR_SHIFT) & 1539 + USBOTG_HWMODE_HOSTXCVR_MASK); 1540 + hw_mode |= ((imx21->pdata->otg_xcvr << USBOTG_HWMODE_OTGXCVR_SHIFT) & 1541 + USBOTG_HWMODE_OTGXCVR_MASK); 1542 + 1543 + if (imx21->pdata->host1_txenoe) 1544 + usb_control |= USBCTRL_HOST1_TXEN_OE; 1545 + 1546 + if (!imx21->pdata->host1_xcverless) 1547 + usb_control |= USBCTRL_HOST1_BYP_TLL; 1548 + 1549 + if (imx21->pdata->otg_ext_xcvr) 1550 + usb_control |= USBCTRL_OTC_RCV_RXDP; 1551 + 1552 + 1553 + spin_lock_irqsave(&imx21->lock, flags); 1554 + 1555 + writel((USBOTG_CLK_CTRL_HST | USBOTG_CLK_CTRL_MAIN), 1556 + imx21->regs + USBOTG_CLK_CTRL); 1557 + writel(hw_mode, imx21->regs + USBOTG_HWMODE); 1558 + writel(usb_control, imx21->regs + USBCTRL); 1559 + writel(USB_MISCCONTROL_SKPRTRY | USB_MISCCONTROL_ARBMODE, 1560 + imx21->regs + USB_MISCCONTROL); 1561 + 1562 + /* Clear the ETDs */ 1563 + for (i = 0; i < USB_NUM_ETD; i++) 1564 + for (j = 0; j < 4; j++) 1565 + etd_writel(imx21, i, j, 0); 1566 + 1567 + /* Take the HC out of reset */ 1568 + writel(USBH_HOST_CTRL_HCUSBSTE_OPERATIONAL | USBH_HOST_CTRL_CTLBLKSR_1, 1569 + imx21->regs + USBH_HOST_CTRL); 1570 + 1571 + /* Enable ports */ 1572 + if (imx21->pdata->enable_otg_host) 1573 + writel(USBH_PORTSTAT_PRTPWRST | USBH_PORTSTAT_PRTENABST, 1574 + imx21->regs + USBH_PORTSTAT(0)); 1575 + 1576 + if (imx21->pdata->enable_host1) 1577 + writel(USBH_PORTSTAT_PRTPWRST | USBH_PORTSTAT_PRTENABST, 1578 + imx21->regs + USBH_PORTSTAT(1)); 1579 + 1580 + if (imx21->pdata->enable_host2) 1581 + writel(USBH_PORTSTAT_PRTPWRST | USBH_PORTSTAT_PRTENABST, 1582 + imx21->regs + USBH_PORTSTAT(2)); 1583 + 1584 + 1585 + hcd->state = HC_STATE_RUNNING; 1586 + 1587 + /* Enable host controller interrupts */ 1588 + set_register_bits(imx21, USBH_SYSIEN, 1589 + USBH_SYSIEN_HERRINT | 1590 + USBH_SYSIEN_DONEINT | USBH_SYSIEN_SORINT); 1591 + set_register_bits(imx21, USBOTG_CINT_STEN, USBOTG_HCINT); 1592 + 1593 + spin_unlock_irqrestore(&imx21->lock, flags); 1594 + 1595 + return 0; 1596 + } 1597 + 1598 + static void imx21_hc_stop(struct usb_hcd *hcd) 1599 + { 1600 + struct imx21 *imx21 = hcd_to_imx21(hcd); 1601 + unsigned long flags; 1602 + 1603 + spin_lock_irqsave(&imx21->lock, flags); 1604 + 1605 + writel(0, imx21->regs + USBH_SYSIEN); 1606 + clear_register_bits(imx21, USBOTG_CINT_STEN, USBOTG_HCINT); 1607 + clear_register_bits(imx21, USBOTG_CLK_CTRL_HST | USBOTG_CLK_CTRL_MAIN, 1608 + USBOTG_CLK_CTRL); 1609 + spin_unlock_irqrestore(&imx21->lock, flags); 1610 + } 1611 + 1612 + /* =========================================== */ 1613 + /* Driver glue */ 1614 + /* =========================================== */ 1615 + 1616 + static struct hc_driver imx21_hc_driver = { 1617 + .description = hcd_name, 1618 + .product_desc = "IMX21 USB Host Controller", 1619 + .hcd_priv_size = sizeof(struct imx21), 1620 + 1621 + .flags = HCD_USB11, 1622 + .irq = imx21_irq, 1623 + 1624 + .reset = imx21_hc_reset, 1625 + .start = imx21_hc_start, 1626 + .stop = imx21_hc_stop, 1627 + 1628 + /* I/O requests */ 1629 + .urb_enqueue = imx21_hc_urb_enqueue, 1630 + .urb_dequeue = imx21_hc_urb_dequeue, 1631 + .endpoint_disable = imx21_hc_endpoint_disable, 1632 + 1633 + /* scheduling support */ 1634 + .get_frame_number = imx21_hc_get_frame, 1635 + 1636 + /* Root hub support */ 1637 + .hub_status_data = imx21_hc_hub_status_data, 1638 + .hub_control = imx21_hc_hub_control, 1639 + 1640 + }; 1641 + 1642 + static struct mx21_usbh_platform_data default_pdata = { 1643 + .host_xcvr = MX21_USBXCVR_TXDIF_RXDIF, 1644 + .otg_xcvr = MX21_USBXCVR_TXDIF_RXDIF, 1645 + .enable_host1 = 1, 1646 + .enable_host2 = 1, 1647 + .enable_otg_host = 1, 1648 + 1649 + }; 1650 + 1651 + static int imx21_remove(struct platform_device *pdev) 1652 + { 1653 + struct usb_hcd *hcd = platform_get_drvdata(pdev); 1654 + struct imx21 *imx21 = hcd_to_imx21(hcd); 1655 + struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1656 + 1657 + remove_debug_files(imx21); 1658 + usb_remove_hcd(hcd); 1659 + 1660 + if (res != NULL) { 1661 + clk_disable(imx21->clk); 1662 + clk_put(imx21->clk); 1663 + iounmap(imx21->regs); 1664 + release_mem_region(res->start, resource_size(res)); 1665 + } 1666 + 1667 + kfree(hcd); 1668 + return 0; 1669 + } 1670 + 1671 + 1672 + static int imx21_probe(struct platform_device *pdev) 1673 + { 1674 + struct usb_hcd *hcd; 1675 + struct imx21 *imx21; 1676 + struct resource *res; 1677 + int ret; 1678 + int irq; 1679 + 1680 + printk(KERN_INFO "%s\n", imx21_hc_driver.product_desc); 1681 + 1682 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1683 + if (!res) 1684 + return -ENODEV; 1685 + irq = platform_get_irq(pdev, 0); 1686 + if (irq < 0) 1687 + return -ENXIO; 1688 + 1689 + hcd = usb_create_hcd(&imx21_hc_driver, 1690 + &pdev->dev, dev_name(&pdev->dev)); 1691 + if (hcd == NULL) { 1692 + dev_err(&pdev->dev, "Cannot create hcd (%s)\n", 1693 + dev_name(&pdev->dev)); 1694 + return -ENOMEM; 1695 + } 1696 + 1697 + imx21 = hcd_to_imx21(hcd); 1698 + imx21->dev = &pdev->dev; 1699 + imx21->pdata = pdev->dev.platform_data; 1700 + if (!imx21->pdata) 1701 + imx21->pdata = &default_pdata; 1702 + 1703 + spin_lock_init(&imx21->lock); 1704 + INIT_LIST_HEAD(&imx21->dmem_list); 1705 + INIT_LIST_HEAD(&imx21->queue_for_etd); 1706 + INIT_LIST_HEAD(&imx21->queue_for_dmem); 1707 + create_debug_files(imx21); 1708 + 1709 + res = request_mem_region(res->start, resource_size(res), hcd_name); 1710 + if (!res) { 1711 + ret = -EBUSY; 1712 + goto failed_request_mem; 1713 + } 1714 + 1715 + imx21->regs = ioremap(res->start, resource_size(res)); 1716 + if (imx21->regs == NULL) { 1717 + dev_err(imx21->dev, "Cannot map registers\n"); 1718 + ret = -ENOMEM; 1719 + goto failed_ioremap; 1720 + } 1721 + 1722 + /* Enable clocks source */ 1723 + imx21->clk = clk_get(imx21->dev, NULL); 1724 + if (IS_ERR(imx21->clk)) { 1725 + dev_err(imx21->dev, "no clock found\n"); 1726 + ret = PTR_ERR(imx21->clk); 1727 + goto failed_clock_get; 1728 + } 1729 + 1730 + ret = clk_set_rate(imx21->clk, clk_round_rate(imx21->clk, 48000000)); 1731 + if (ret) 1732 + goto failed_clock_set; 1733 + ret = clk_enable(imx21->clk); 1734 + if (ret) 1735 + goto failed_clock_enable; 1736 + 1737 + dev_info(imx21->dev, "Hardware HC revision: 0x%02X\n", 1738 + (readl(imx21->regs + USBOTG_HWMODE) >> 16) & 0xFF); 1739 + 1740 + ret = usb_add_hcd(hcd, irq, IRQF_DISABLED); 1741 + if (ret != 0) { 1742 + dev_err(imx21->dev, "usb_add_hcd() returned %d\n", ret); 1743 + goto failed_add_hcd; 1744 + } 1745 + 1746 + return 0; 1747 + 1748 + failed_add_hcd: 1749 + clk_disable(imx21->clk); 1750 + failed_clock_enable: 1751 + failed_clock_set: 1752 + clk_put(imx21->clk); 1753 + failed_clock_get: 1754 + iounmap(imx21->regs); 1755 + failed_ioremap: 1756 + release_mem_region(res->start, res->end - res->start); 1757 + failed_request_mem: 1758 + remove_debug_files(imx21); 1759 + usb_put_hcd(hcd); 1760 + return ret; 1761 + } 1762 + 1763 + static struct platform_driver imx21_hcd_driver = { 1764 + .driver = { 1765 + .name = (char *)hcd_name, 1766 + }, 1767 + .probe = imx21_probe, 1768 + .remove = imx21_remove, 1769 + .suspend = NULL, 1770 + .resume = NULL, 1771 + }; 1772 + 1773 + static int __init imx21_hcd_init(void) 1774 + { 1775 + return platform_driver_register(&imx21_hcd_driver); 1776 + } 1777 + 1778 + static void __exit imx21_hcd_cleanup(void) 1779 + { 1780 + platform_driver_unregister(&imx21_hcd_driver); 1781 + } 1782 + 1783 + module_init(imx21_hcd_init); 1784 + module_exit(imx21_hcd_cleanup); 1785 + 1786 + MODULE_DESCRIPTION("i.MX21 USB Host controller"); 1787 + MODULE_AUTHOR("Martin Fuzzey"); 1788 + MODULE_LICENSE("GPL"); 1789 + MODULE_ALIAS("platform:imx21-hcd");
+436
drivers/usb/host/imx21-hcd.h
···
··· 1 + /* 2 + * Macros and prototypes for i.MX21 3 + * 4 + * Copyright (C) 2006 Loping Dog Embedded Systems 5 + * Copyright (C) 2009 Martin Fuzzey 6 + * Originally written by Jay Monkman <jtm@lopingdog.com> 7 + * Ported to 2.6.30, debugged and enhanced by Martin Fuzzey 8 + * 9 + * This program is free software; you can redistribute it and/or modify it 10 + * under the terms of the GNU General Public License as published by the 11 + * Free Software Foundation; either version 2 of the License, or (at your 12 + * option) any later version. 13 + * 14 + * This program is distributed in the hope that it will be useful, but 15 + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 16 + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 17 + * for more details. 18 + * 19 + * You should have received a copy of the GNU General Public License 20 + * along with this program; if not, write to the Free Software Foundation, 21 + * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 + */ 23 + 24 + #ifndef __LINUX_IMX21_HCD_H__ 25 + #define __LINUX_IMX21_HCD_H__ 26 + 27 + #include <mach/mx21-usbhost.h> 28 + 29 + #define NUM_ISO_ETDS 2 30 + #define USB_NUM_ETD 32 31 + #define DMEM_SIZE 4096 32 + 33 + /* Register definitions */ 34 + #define USBOTG_HWMODE 0x00 35 + #define USBOTG_HWMODE_ANASDBEN (1 << 14) 36 + #define USBOTG_HWMODE_OTGXCVR_SHIFT 6 37 + #define USBOTG_HWMODE_OTGXCVR_MASK (3 << 6) 38 + #define USBOTG_HWMODE_OTGXCVR_TD_RD (0 << 6) 39 + #define USBOTG_HWMODE_OTGXCVR_TS_RD (2 << 6) 40 + #define USBOTG_HWMODE_OTGXCVR_TD_RS (1 << 6) 41 + #define USBOTG_HWMODE_OTGXCVR_TS_RS (3 << 6) 42 + #define USBOTG_HWMODE_HOSTXCVR_SHIFT 4 43 + #define USBOTG_HWMODE_HOSTXCVR_MASK (3 << 4) 44 + #define USBOTG_HWMODE_HOSTXCVR_TD_RD (0 << 4) 45 + #define USBOTG_HWMODE_HOSTXCVR_TS_RD (2 << 4) 46 + #define USBOTG_HWMODE_HOSTXCVR_TD_RS (1 << 4) 47 + #define USBOTG_HWMODE_HOSTXCVR_TS_RS (3 << 4) 48 + #define USBOTG_HWMODE_CRECFG_MASK (3 << 0) 49 + #define USBOTG_HWMODE_CRECFG_HOST (1 << 0) 50 + #define USBOTG_HWMODE_CRECFG_FUNC (2 << 0) 51 + #define USBOTG_HWMODE_CRECFG_HNP (3 << 0) 52 + 53 + #define USBOTG_CINT_STAT 0x04 54 + #define USBOTG_CINT_STEN 0x08 55 + #define USBOTG_ASHNPINT (1 << 5) 56 + #define USBOTG_ASFCINT (1 << 4) 57 + #define USBOTG_ASHCINT (1 << 3) 58 + #define USBOTG_SHNPINT (1 << 2) 59 + #define USBOTG_FCINT (1 << 1) 60 + #define USBOTG_HCINT (1 << 0) 61 + 62 + #define USBOTG_CLK_CTRL 0x0c 63 + #define USBOTG_CLK_CTRL_FUNC (1 << 2) 64 + #define USBOTG_CLK_CTRL_HST (1 << 1) 65 + #define USBOTG_CLK_CTRL_MAIN (1 << 0) 66 + 67 + #define USBOTG_RST_CTRL 0x10 68 + #define USBOTG_RST_RSTI2C (1 << 15) 69 + #define USBOTG_RST_RSTCTRL (1 << 5) 70 + #define USBOTG_RST_RSTFC (1 << 4) 71 + #define USBOTG_RST_RSTFSKE (1 << 3) 72 + #define USBOTG_RST_RSTRH (1 << 2) 73 + #define USBOTG_RST_RSTHSIE (1 << 1) 74 + #define USBOTG_RST_RSTHC (1 << 0) 75 + 76 + #define USBOTG_FRM_INTVL 0x14 77 + #define USBOTG_FRM_REMAIN 0x18 78 + #define USBOTG_HNP_CSR 0x1c 79 + #define USBOTG_HNP_ISR 0x2c 80 + #define USBOTG_HNP_IEN 0x30 81 + 82 + #define USBOTG_I2C_TXCVR_REG(x) (0x100 + (x)) 83 + #define USBOTG_I2C_XCVR_DEVAD 0x118 84 + #define USBOTG_I2C_SEQ_OP_REG 0x119 85 + #define USBOTG_I2C_SEQ_RD_STARTAD 0x11a 86 + #define USBOTG_I2C_OP_CTRL_REG 0x11b 87 + #define USBOTG_I2C_SCLK_TO_SCK_HPER 0x11e 88 + #define USBOTG_I2C_MASTER_INT_REG 0x11f 89 + 90 + #define USBH_HOST_CTRL 0x80 91 + #define USBH_HOST_CTRL_HCRESET (1 << 31) 92 + #define USBH_HOST_CTRL_SCHDOVR(x) ((x) << 16) 93 + #define USBH_HOST_CTRL_RMTWUEN (1 << 4) 94 + #define USBH_HOST_CTRL_HCUSBSTE_RESET (0 << 2) 95 + #define USBH_HOST_CTRL_HCUSBSTE_RESUME (1 << 2) 96 + #define USBH_HOST_CTRL_HCUSBSTE_OPERATIONAL (2 << 2) 97 + #define USBH_HOST_CTRL_HCUSBSTE_SUSPEND (3 << 2) 98 + #define USBH_HOST_CTRL_CTLBLKSR_1 (0 << 0) 99 + #define USBH_HOST_CTRL_CTLBLKSR_2 (1 << 0) 100 + #define USBH_HOST_CTRL_CTLBLKSR_3 (2 << 0) 101 + #define USBH_HOST_CTRL_CTLBLKSR_4 (3 << 0) 102 + 103 + #define USBH_SYSISR 0x88 104 + #define USBH_SYSISR_PSCINT (1 << 6) 105 + #define USBH_SYSISR_FMOFINT (1 << 5) 106 + #define USBH_SYSISR_HERRINT (1 << 4) 107 + #define USBH_SYSISR_RESDETINT (1 << 3) 108 + #define USBH_SYSISR_SOFINT (1 << 2) 109 + #define USBH_SYSISR_DONEINT (1 << 1) 110 + #define USBH_SYSISR_SORINT (1 << 0) 111 + 112 + #define USBH_SYSIEN 0x8c 113 + #define USBH_SYSIEN_PSCINT (1 << 6) 114 + #define USBH_SYSIEN_FMOFINT (1 << 5) 115 + #define USBH_SYSIEN_HERRINT (1 << 4) 116 + #define USBH_SYSIEN_RESDETINT (1 << 3) 117 + #define USBH_SYSIEN_SOFINT (1 << 2) 118 + #define USBH_SYSIEN_DONEINT (1 << 1) 119 + #define USBH_SYSIEN_SORINT (1 << 0) 120 + 121 + #define USBH_XBUFSTAT 0x98 122 + #define USBH_YBUFSTAT 0x9c 123 + #define USBH_XYINTEN 0xa0 124 + #define USBH_XFILLSTAT 0xa8 125 + #define USBH_YFILLSTAT 0xac 126 + #define USBH_ETDENSET 0xc0 127 + #define USBH_ETDENCLR 0xc4 128 + #define USBH_IMMEDINT 0xcc 129 + #define USBH_ETDDONESTAT 0xd0 130 + #define USBH_ETDDONEEN 0xd4 131 + #define USBH_FRMNUB 0xe0 132 + #define USBH_LSTHRESH 0xe4 133 + 134 + #define USBH_ROOTHUBA 0xe8 135 + #define USBH_ROOTHUBA_PWRTOGOOD_MASK (0xff) 136 + #define USBH_ROOTHUBA_PWRTOGOOD_SHIFT (24) 137 + #define USBH_ROOTHUBA_NOOVRCURP (1 << 12) 138 + #define USBH_ROOTHUBA_OVRCURPM (1 << 11) 139 + #define USBH_ROOTHUBA_DEVTYPE (1 << 10) 140 + #define USBH_ROOTHUBA_PWRSWTMD (1 << 9) 141 + #define USBH_ROOTHUBA_NOPWRSWT (1 << 8) 142 + #define USBH_ROOTHUBA_NDNSTMPRT_MASK (0xff) 143 + 144 + #define USBH_ROOTHUBB 0xec 145 + #define USBH_ROOTHUBB_PRTPWRCM(x) (1 << ((x) + 16)) 146 + #define USBH_ROOTHUBB_DEVREMOVE(x) (1 << (x)) 147 + 148 + #define USBH_ROOTSTAT 0xf0 149 + #define USBH_ROOTSTAT_CLRRMTWUE (1 << 31) 150 + #define USBH_ROOTSTAT_OVRCURCHG (1 << 17) 151 + #define USBH_ROOTSTAT_DEVCONWUE (1 << 15) 152 + #define USBH_ROOTSTAT_OVRCURI (1 << 1) 153 + #define USBH_ROOTSTAT_LOCPWRS (1 << 0) 154 + 155 + #define USBH_PORTSTAT(x) (0xf4 + ((x) * 4)) 156 + #define USBH_PORTSTAT_PRTRSTSC (1 << 20) 157 + #define USBH_PORTSTAT_OVRCURIC (1 << 19) 158 + #define USBH_PORTSTAT_PRTSTATSC (1 << 18) 159 + #define USBH_PORTSTAT_PRTENBLSC (1 << 17) 160 + #define USBH_PORTSTAT_CONNECTSC (1 << 16) 161 + #define USBH_PORTSTAT_LSDEVCON (1 << 9) 162 + #define USBH_PORTSTAT_PRTPWRST (1 << 8) 163 + #define USBH_PORTSTAT_PRTRSTST (1 << 4) 164 + #define USBH_PORTSTAT_PRTOVRCURI (1 << 3) 165 + #define USBH_PORTSTAT_PRTSUSPST (1 << 2) 166 + #define USBH_PORTSTAT_PRTENABST (1 << 1) 167 + #define USBH_PORTSTAT_CURCONST (1 << 0) 168 + 169 + #define USB_DMAREV 0x800 170 + #define USB_DMAINTSTAT 0x804 171 + #define USB_DMAINTSTAT_EPERR (1 << 1) 172 + #define USB_DMAINTSTAT_ETDERR (1 << 0) 173 + 174 + #define USB_DMAINTEN 0x808 175 + #define USB_DMAINTEN_EPERRINTEN (1 << 1) 176 + #define USB_DMAINTEN_ETDERRINTEN (1 << 0) 177 + 178 + #define USB_ETDDMAERSTAT 0x80c 179 + #define USB_EPDMAERSTAT 0x810 180 + #define USB_ETDDMAEN 0x820 181 + #define USB_EPDMAEN 0x824 182 + #define USB_ETDDMAXTEN 0x828 183 + #define USB_EPDMAXTEN 0x82c 184 + #define USB_ETDDMAENXYT 0x830 185 + #define USB_EPDMAENXYT 0x834 186 + #define USB_ETDDMABST4EN 0x838 187 + #define USB_EPDMABST4EN 0x83c 188 + 189 + #define USB_MISCCONTROL 0x840 190 + #define USB_MISCCONTROL_ISOPREVFRM (1 << 3) 191 + #define USB_MISCCONTROL_SKPRTRY (1 << 2) 192 + #define USB_MISCCONTROL_ARBMODE (1 << 1) 193 + #define USB_MISCCONTROL_FILTCC (1 << 0) 194 + 195 + #define USB_ETDDMACHANLCLR 0x848 196 + #define USB_EPDMACHANLCLR 0x84c 197 + #define USB_ETDSMSA(x) (0x900 + ((x) * 4)) 198 + #define USB_EPSMSA(x) (0x980 + ((x) * 4)) 199 + #define USB_ETDDMABUFPTR(x) (0xa00 + ((x) * 4)) 200 + #define USB_EPDMABUFPTR(x) (0xa80 + ((x) * 4)) 201 + 202 + #define USB_ETD_DWORD(x, w) (0x200 + ((x) * 16) + ((w) * 4)) 203 + #define DW0_ADDRESS 0 204 + #define DW0_ENDPNT 7 205 + #define DW0_DIRECT 11 206 + #define DW0_SPEED 13 207 + #define DW0_FORMAT 14 208 + #define DW0_MAXPKTSIZ 16 209 + #define DW0_HALTED 27 210 + #define DW0_TOGCRY 28 211 + #define DW0_SNDNAK 30 212 + 213 + #define DW1_XBUFSRTAD 0 214 + #define DW1_YBUFSRTAD 16 215 + 216 + #define DW2_RTRYDELAY 0 217 + #define DW2_POLINTERV 0 218 + #define DW2_STARTFRM 0 219 + #define DW2_RELPOLPOS 8 220 + #define DW2_DIRPID 16 221 + #define DW2_BUFROUND 18 222 + #define DW2_DELAYINT 19 223 + #define DW2_DATATOG 22 224 + #define DW2_ERRORCNT 24 225 + #define DW2_COMPCODE 28 226 + 227 + #define DW3_TOTBYECNT 0 228 + #define DW3_PKTLEN0 0 229 + #define DW3_COMPCODE0 12 230 + #define DW3_PKTLEN1 16 231 + #define DW3_BUFSIZE 21 232 + #define DW3_COMPCODE1 28 233 + 234 + #define USBCTRL 0x600 235 + #define USBCTRL_I2C_WU_INT_STAT (1 << 27) 236 + #define USBCTRL_OTG_WU_INT_STAT (1 << 26) 237 + #define USBCTRL_HOST_WU_INT_STAT (1 << 25) 238 + #define USBCTRL_FNT_WU_INT_STAT (1 << 24) 239 + #define USBCTRL_I2C_WU_INT_EN (1 << 19) 240 + #define USBCTRL_OTG_WU_INT_EN (1 << 18) 241 + #define USBCTRL_HOST_WU_INT_EN (1 << 17) 242 + #define USBCTRL_FNT_WU_INT_EN (1 << 16) 243 + #define USBCTRL_OTC_RCV_RXDP (1 << 13) 244 + #define USBCTRL_HOST1_BYP_TLL (1 << 12) 245 + #define USBCTRL_OTG_BYP_VAL(x) ((x) << 10) 246 + #define USBCTRL_HOST1_BYP_VAL(x) ((x) << 8) 247 + #define USBCTRL_OTG_PWR_MASK (1 << 6) 248 + #define USBCTRL_HOST1_PWR_MASK (1 << 5) 249 + #define USBCTRL_HOST2_PWR_MASK (1 << 4) 250 + #define USBCTRL_USB_BYP (1 << 2) 251 + #define USBCTRL_HOST1_TXEN_OE (1 << 1) 252 + 253 + 254 + /* Values in TD blocks */ 255 + #define TD_DIR_SETUP 0 256 + #define TD_DIR_OUT 1 257 + #define TD_DIR_IN 2 258 + #define TD_FORMAT_CONTROL 0 259 + #define TD_FORMAT_ISO 1 260 + #define TD_FORMAT_BULK 2 261 + #define TD_FORMAT_INT 3 262 + #define TD_TOGGLE_CARRY 0 263 + #define TD_TOGGLE_DATA0 2 264 + #define TD_TOGGLE_DATA1 3 265 + 266 + /* control transfer states */ 267 + #define US_CTRL_SETUP 2 268 + #define US_CTRL_DATA 1 269 + #define US_CTRL_ACK 0 270 + 271 + /* bulk transfer main state and 0-length packet */ 272 + #define US_BULK 1 273 + #define US_BULK0 0 274 + 275 + /*ETD format description*/ 276 + #define IMX_FMT_CTRL 0x0 277 + #define IMX_FMT_ISO 0x1 278 + #define IMX_FMT_BULK 0x2 279 + #define IMX_FMT_INT 0x3 280 + 281 + static char fmt_urb_to_etd[4] = { 282 + /*PIPE_ISOCHRONOUS*/ IMX_FMT_ISO, 283 + /*PIPE_INTERRUPT*/ IMX_FMT_INT, 284 + /*PIPE_CONTROL*/ IMX_FMT_CTRL, 285 + /*PIPE_BULK*/ IMX_FMT_BULK 286 + }; 287 + 288 + /* condition (error) CC codes and mapping (OHCI like) */ 289 + 290 + #define TD_CC_NOERROR 0x00 291 + #define TD_CC_CRC 0x01 292 + #define TD_CC_BITSTUFFING 0x02 293 + #define TD_CC_DATATOGGLEM 0x03 294 + #define TD_CC_STALL 0x04 295 + #define TD_DEVNOTRESP 0x05 296 + #define TD_PIDCHECKFAIL 0x06 297 + /*#define TD_UNEXPECTEDPID 0x07 - reserved, not active on MX2*/ 298 + #define TD_DATAOVERRUN 0x08 299 + #define TD_DATAUNDERRUN 0x09 300 + #define TD_BUFFEROVERRUN 0x0C 301 + #define TD_BUFFERUNDERRUN 0x0D 302 + #define TD_SCHEDULEOVERRUN 0x0E 303 + #define TD_NOTACCESSED 0x0F 304 + 305 + static const int cc_to_error[16] = { 306 + /* No Error */ 0, 307 + /* CRC Error */ -EILSEQ, 308 + /* Bit Stuff */ -EPROTO, 309 + /* Data Togg */ -EILSEQ, 310 + /* Stall */ -EPIPE, 311 + /* DevNotResp */ -ETIMEDOUT, 312 + /* PIDCheck */ -EPROTO, 313 + /* UnExpPID */ -EPROTO, 314 + /* DataOver */ -EOVERFLOW, 315 + /* DataUnder */ -EREMOTEIO, 316 + /* (for hw) */ -EIO, 317 + /* (for hw) */ -EIO, 318 + /* BufferOver */ -ECOMM, 319 + /* BuffUnder */ -ENOSR, 320 + /* (for HCD) */ -ENOSPC, 321 + /* (for HCD) */ -EALREADY 322 + }; 323 + 324 + /* HCD data associated with a usb core URB */ 325 + struct urb_priv { 326 + struct urb *urb; 327 + struct usb_host_endpoint *ep; 328 + int active; 329 + int state; 330 + struct td *isoc_td; 331 + int isoc_remaining; 332 + int isoc_status; 333 + }; 334 + 335 + /* HCD data associated with a usb core endpoint */ 336 + struct ep_priv { 337 + struct usb_host_endpoint *ep; 338 + struct list_head td_list; 339 + struct list_head queue; 340 + int etd[NUM_ISO_ETDS]; 341 + int waiting_etd; 342 + }; 343 + 344 + /* isoc packet */ 345 + struct td { 346 + struct list_head list; 347 + struct urb *urb; 348 + struct usb_host_endpoint *ep; 349 + dma_addr_t data; 350 + unsigned long buf_addr; 351 + int len; 352 + int frame; 353 + int isoc_index; 354 + }; 355 + 356 + /* HCD data associated with a hardware ETD */ 357 + struct etd_priv { 358 + struct usb_host_endpoint *ep; 359 + struct urb *urb; 360 + struct td *td; 361 + struct list_head queue; 362 + dma_addr_t dma_handle; 363 + int alloc; 364 + int len; 365 + int dmem_size; 366 + int dmem_offset; 367 + int active_count; 368 + #ifdef DEBUG 369 + int activated_frame; 370 + int disactivated_frame; 371 + int last_int_frame; 372 + int last_req_frame; 373 + u32 submitted_dwords[4]; 374 + #endif 375 + }; 376 + 377 + /* Hardware data memory info */ 378 + struct imx21_dmem_area { 379 + struct usb_host_endpoint *ep; 380 + unsigned int offset; 381 + unsigned int size; 382 + struct list_head list; 383 + }; 384 + 385 + #ifdef DEBUG 386 + struct debug_usage_stats { 387 + unsigned int value; 388 + unsigned int maximum; 389 + }; 390 + 391 + struct debug_stats { 392 + unsigned long submitted; 393 + unsigned long completed_ok; 394 + unsigned long completed_failed; 395 + unsigned long unlinked; 396 + unsigned long queue_etd; 397 + unsigned long queue_dmem; 398 + }; 399 + 400 + struct debug_isoc_trace { 401 + int schedule_frame; 402 + int submit_frame; 403 + int request_len; 404 + int done_frame; 405 + int done_len; 406 + int cc; 407 + struct td *td; 408 + }; 409 + #endif 410 + 411 + /* HCD data structure */ 412 + struct imx21 { 413 + spinlock_t lock; 414 + struct device *dev; 415 + struct mx21_usbh_platform_data *pdata; 416 + struct list_head dmem_list; 417 + struct list_head queue_for_etd; /* eps queued due to etd shortage */ 418 + struct list_head queue_for_dmem; /* etds queued due to dmem shortage */ 419 + struct etd_priv etd[USB_NUM_ETD]; 420 + struct clk *clk; 421 + void __iomem *regs; 422 + #ifdef DEBUG 423 + struct dentry *debug_root; 424 + struct debug_stats nonisoc_stats; 425 + struct debug_stats isoc_stats; 426 + struct debug_usage_stats etd_usage; 427 + struct debug_usage_stats dmem_usage; 428 + struct debug_isoc_trace isoc_trace[20]; 429 + struct debug_isoc_trace isoc_trace_failed[20]; 430 + unsigned long debug_unblocks; 431 + int isoc_trace_index; 432 + int isoc_trace_index_failed; 433 + #endif 434 + }; 435 + 436 + #endif
+1 -14
drivers/usb/host/isp1362-hcd.c
··· 1257 1258 /* avoid all allocations within spinlocks: request or endpoint */ 1259 if (!hep->hcpriv) { 1260 - ep = kcalloc(1, sizeof *ep, mem_flags); 1261 if (!ep) 1262 return -ENOMEM; 1263 } ··· 2719 } 2720 irq = irq_res->start; 2721 2722 - #ifdef CONFIG_USB_HCD_DMA 2723 - if (pdev->dev.dma_mask) { 2724 - struct resource *dma_res = platform_get_resource(pdev, IORESOURCE_MEM, 2); 2725 - 2726 - if (!dma_res) { 2727 - retval = -ENODEV; 2728 - goto err1; 2729 - } 2730 - isp1362_hcd->data_dma = dma_res->start; 2731 - isp1362_hcd->max_dma_size = resource_len(dma_res); 2732 - } 2733 - #else 2734 if (pdev->dev.dma_mask) { 2735 DBG(1, "won't do DMA"); 2736 retval = -ENODEV; 2737 goto err1; 2738 } 2739 - #endif 2740 2741 if (!request_mem_region(addr->start, resource_len(addr), hcd_name)) { 2742 retval = -EBUSY;
··· 1257 1258 /* avoid all allocations within spinlocks: request or endpoint */ 1259 if (!hep->hcpriv) { 1260 + ep = kzalloc(sizeof *ep, mem_flags); 1261 if (!ep) 1262 return -ENOMEM; 1263 } ··· 2719 } 2720 irq = irq_res->start; 2721 2722 if (pdev->dev.dma_mask) { 2723 DBG(1, "won't do DMA"); 2724 retval = -ENODEV; 2725 goto err1; 2726 } 2727 2728 if (!request_mem_region(addr->start, resource_len(addr), hcd_name)) { 2729 retval = -EBUSY;
+10
drivers/usb/host/isp1760-hcd.c
··· 17 #include <linux/debugfs.h> 18 #include <linux/uaccess.h> 19 #include <linux/io.h> 20 #include <asm/unaligned.h> 21 22 #include "../core/hcd.h" 23 #include "isp1760-hcd.h" ··· 904 if (!urb->unlinked) { 905 if (status == -EINPROGRESS) 906 status = 0; 907 } 908 909 /* complete() can reenter this HCD */
··· 17 #include <linux/debugfs.h> 18 #include <linux/uaccess.h> 19 #include <linux/io.h> 20 + #include <linux/mm.h> 21 #include <asm/unaligned.h> 22 + #include <asm/cacheflush.h> 23 24 #include "../core/hcd.h" 25 #include "isp1760-hcd.h" ··· 902 if (!urb->unlinked) { 903 if (status == -EINPROGRESS) 904 status = 0; 905 + } 906 + 907 + if (usb_pipein(urb->pipe) && usb_pipetype(urb->pipe) != PIPE_CONTROL) { 908 + void *ptr; 909 + for (ptr = urb->transfer_buffer; 910 + ptr < urb->transfer_buffer + urb->transfer_buffer_length; 911 + ptr += PAGE_SIZE) 912 + flush_dcache_page(virt_to_page(ptr)); 913 } 914 915 /* complete() can reenter this HCD */
+1 -1
drivers/usb/host/isp1760-if.c
··· 109 return 0; 110 } 111 112 - static struct of_device_id of_isp1760_match[] = { 113 { 114 .compatible = "nxp,usb-isp1760", 115 },
··· 109 return 0; 110 } 111 112 + static const struct of_device_id of_isp1760_match[] = { 113 { 114 .compatible = "nxp,usb-isp1760", 115 },
+456
drivers/usb/host/ohci-da8xx.c
···
··· 1 + /* 2 + * OHCI HCD (Host Controller Driver) for USB. 3 + * 4 + * TI DA8xx (OMAP-L1x) Bus Glue 5 + * 6 + * Derived from: ohci-omap.c and ohci-s3c2410.c 7 + * Copyright (C) 2008-2009 MontaVista Software, Inc. <source@mvista.com> 8 + * 9 + * This file is licensed under the terms of the GNU General Public License 10 + * version 2. This program is licensed "as is" without any warranty of any 11 + * kind, whether express or implied. 12 + */ 13 + 14 + #include <linux/interrupt.h> 15 + #include <linux/jiffies.h> 16 + #include <linux/platform_device.h> 17 + #include <linux/clk.h> 18 + 19 + #include <mach/da8xx.h> 20 + #include <mach/usb.h> 21 + 22 + #ifndef CONFIG_ARCH_DAVINCI_DA8XX 23 + #error "This file is DA8xx bus glue. Define CONFIG_ARCH_DAVINCI_DA8XX." 24 + #endif 25 + 26 + #define CFGCHIP2 DA8XX_SYSCFG_VIRT(DA8XX_CFGCHIP2_REG) 27 + 28 + static struct clk *usb11_clk; 29 + static struct clk *usb20_clk; 30 + 31 + /* Over-current indicator change bitmask */ 32 + static volatile u16 ocic_mask; 33 + 34 + static void ohci_da8xx_clock(int on) 35 + { 36 + u32 cfgchip2; 37 + 38 + cfgchip2 = __raw_readl(CFGCHIP2); 39 + if (on) { 40 + clk_enable(usb11_clk); 41 + 42 + /* 43 + * If USB 1.1 reference clock is sourced from USB 2.0 PHY, we 44 + * need to enable the USB 2.0 module clocking, start its PHY, 45 + * and not allow it to stop the clock during USB 2.0 suspend. 46 + */ 47 + if (!(cfgchip2 & CFGCHIP2_USB1PHYCLKMUX)) { 48 + clk_enable(usb20_clk); 49 + 50 + cfgchip2 &= ~(CFGCHIP2_RESET | CFGCHIP2_PHYPWRDN); 51 + cfgchip2 |= CFGCHIP2_PHY_PLLON; 52 + __raw_writel(cfgchip2, CFGCHIP2); 53 + 54 + pr_info("Waiting for USB PHY clock good...\n"); 55 + while (!(__raw_readl(CFGCHIP2) & CFGCHIP2_PHYCLKGD)) 56 + cpu_relax(); 57 + } 58 + 59 + /* Enable USB 1.1 PHY */ 60 + cfgchip2 |= CFGCHIP2_USB1SUSPENDM; 61 + } else { 62 + clk_disable(usb11_clk); 63 + if (!(cfgchip2 & CFGCHIP2_USB1PHYCLKMUX)) 64 + clk_disable(usb20_clk); 65 + 66 + /* Disable USB 1.1 PHY */ 67 + cfgchip2 &= ~CFGCHIP2_USB1SUSPENDM; 68 + } 69 + __raw_writel(cfgchip2, CFGCHIP2); 70 + } 71 + 72 + /* 73 + * Handle the port over-current indicator change. 74 + */ 75 + static void ohci_da8xx_ocic_handler(struct da8xx_ohci_root_hub *hub, 76 + unsigned port) 77 + { 78 + ocic_mask |= 1 << port; 79 + 80 + /* Once over-current is detected, the port needs to be powered down */ 81 + if (hub->get_oci(port) > 0) 82 + hub->set_power(port, 0); 83 + } 84 + 85 + static int ohci_da8xx_init(struct usb_hcd *hcd) 86 + { 87 + struct device *dev = hcd->self.controller; 88 + struct da8xx_ohci_root_hub *hub = dev->platform_data; 89 + struct ohci_hcd *ohci = hcd_to_ohci(hcd); 90 + int result; 91 + u32 rh_a; 92 + 93 + dev_dbg(dev, "starting USB controller\n"); 94 + 95 + ohci_da8xx_clock(1); 96 + 97 + /* 98 + * DA8xx only have 1 port connected to the pins but the HC root hub 99 + * register A reports 2 ports, thus we'll have to override it... 100 + */ 101 + ohci->num_ports = 1; 102 + 103 + result = ohci_init(ohci); 104 + if (result < 0) 105 + return result; 106 + 107 + /* 108 + * Since we're providing a board-specific root hub port power control 109 + * and over-current reporting, we have to override the HC root hub A 110 + * register's default value, so that ohci_hub_control() could return 111 + * the correct hub descriptor... 112 + */ 113 + rh_a = ohci_readl(ohci, &ohci->regs->roothub.a); 114 + if (hub->set_power) { 115 + rh_a &= ~RH_A_NPS; 116 + rh_a |= RH_A_PSM; 117 + } 118 + if (hub->get_oci) { 119 + rh_a &= ~RH_A_NOCP; 120 + rh_a |= RH_A_OCPM; 121 + } 122 + rh_a &= ~RH_A_POTPGT; 123 + rh_a |= hub->potpgt << 24; 124 + ohci_writel(ohci, rh_a, &ohci->regs->roothub.a); 125 + 126 + return result; 127 + } 128 + 129 + static void ohci_da8xx_stop(struct usb_hcd *hcd) 130 + { 131 + ohci_stop(hcd); 132 + ohci_da8xx_clock(0); 133 + } 134 + 135 + static int ohci_da8xx_start(struct usb_hcd *hcd) 136 + { 137 + struct ohci_hcd *ohci = hcd_to_ohci(hcd); 138 + int result; 139 + 140 + result = ohci_run(ohci); 141 + if (result < 0) 142 + ohci_da8xx_stop(hcd); 143 + 144 + return result; 145 + } 146 + 147 + /* 148 + * Update the status data from the hub with the over-current indicator change. 149 + */ 150 + static int ohci_da8xx_hub_status_data(struct usb_hcd *hcd, char *buf) 151 + { 152 + int length = ohci_hub_status_data(hcd, buf); 153 + 154 + /* See if we have OCIC bit set on port 1 */ 155 + if (ocic_mask & (1 << 1)) { 156 + dev_dbg(hcd->self.controller, "over-current indicator change " 157 + "on port 1\n"); 158 + 159 + if (!length) 160 + length = 1; 161 + 162 + buf[0] |= 1 << 1; 163 + } 164 + return length; 165 + } 166 + 167 + /* 168 + * Look at the control requests to the root hub and see if we need to override. 169 + */ 170 + static int ohci_da8xx_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, 171 + u16 wIndex, char *buf, u16 wLength) 172 + { 173 + struct device *dev = hcd->self.controller; 174 + struct da8xx_ohci_root_hub *hub = dev->platform_data; 175 + int temp; 176 + 177 + switch (typeReq) { 178 + case GetPortStatus: 179 + /* Check the port number */ 180 + if (wIndex != 1) 181 + break; 182 + 183 + dev_dbg(dev, "GetPortStatus(%u)\n", wIndex); 184 + 185 + temp = roothub_portstatus(hcd_to_ohci(hcd), wIndex - 1); 186 + 187 + /* The port power status (PPS) bit defaults to 1 */ 188 + if (hub->get_power && hub->get_power(wIndex) == 0) 189 + temp &= ~RH_PS_PPS; 190 + 191 + /* The port over-current indicator (POCI) bit is always 0 */ 192 + if (hub->get_oci && hub->get_oci(wIndex) > 0) 193 + temp |= RH_PS_POCI; 194 + 195 + /* The over-current indicator change (OCIC) bit is 0 too */ 196 + if (ocic_mask & (1 << wIndex)) 197 + temp |= RH_PS_OCIC; 198 + 199 + put_unaligned(cpu_to_le32(temp), (__le32 *)buf); 200 + return 0; 201 + case SetPortFeature: 202 + temp = 1; 203 + goto check_port; 204 + case ClearPortFeature: 205 + temp = 0; 206 + 207 + check_port: 208 + /* Check the port number */ 209 + if (wIndex != 1) 210 + break; 211 + 212 + switch (wValue) { 213 + case USB_PORT_FEAT_POWER: 214 + dev_dbg(dev, "%sPortFeature(%u): %s\n", 215 + temp ? "Set" : "Clear", wIndex, "POWER"); 216 + 217 + if (!hub->set_power) 218 + return -EPIPE; 219 + 220 + return hub->set_power(wIndex, temp) ? -EPIPE : 0; 221 + case USB_PORT_FEAT_C_OVER_CURRENT: 222 + dev_dbg(dev, "%sPortFeature(%u): %s\n", 223 + temp ? "Set" : "Clear", wIndex, 224 + "C_OVER_CURRENT"); 225 + 226 + if (temp) 227 + ocic_mask |= 1 << wIndex; 228 + else 229 + ocic_mask &= ~(1 << wIndex); 230 + return 0; 231 + } 232 + } 233 + 234 + return ohci_hub_control(hcd, typeReq, wValue, wIndex, buf, wLength); 235 + } 236 + 237 + static const struct hc_driver ohci_da8xx_hc_driver = { 238 + .description = hcd_name, 239 + .product_desc = "DA8xx OHCI", 240 + .hcd_priv_size = sizeof(struct ohci_hcd), 241 + 242 + /* 243 + * generic hardware linkage 244 + */ 245 + .irq = ohci_irq, 246 + .flags = HCD_USB11 | HCD_MEMORY, 247 + 248 + /* 249 + * basic lifecycle operations 250 + */ 251 + .reset = ohci_da8xx_init, 252 + .start = ohci_da8xx_start, 253 + .stop = ohci_da8xx_stop, 254 + .shutdown = ohci_shutdown, 255 + 256 + /* 257 + * managing i/o requests and associated device resources 258 + */ 259 + .urb_enqueue = ohci_urb_enqueue, 260 + .urb_dequeue = ohci_urb_dequeue, 261 + .endpoint_disable = ohci_endpoint_disable, 262 + 263 + /* 264 + * scheduling support 265 + */ 266 + .get_frame_number = ohci_get_frame, 267 + 268 + /* 269 + * root hub support 270 + */ 271 + .hub_status_data = ohci_da8xx_hub_status_data, 272 + .hub_control = ohci_da8xx_hub_control, 273 + 274 + #ifdef CONFIG_PM 275 + .bus_suspend = ohci_bus_suspend, 276 + .bus_resume = ohci_bus_resume, 277 + #endif 278 + .start_port_reset = ohci_start_port_reset, 279 + }; 280 + 281 + /*-------------------------------------------------------------------------*/ 282 + 283 + 284 + /** 285 + * usb_hcd_da8xx_probe - initialize DA8xx-based HCDs 286 + * Context: !in_interrupt() 287 + * 288 + * Allocates basic resources for this USB host controller, and 289 + * then invokes the start() method for the HCD associated with it 290 + * through the hotplug entry's driver_data. 291 + */ 292 + static int usb_hcd_da8xx_probe(const struct hc_driver *driver, 293 + struct platform_device *pdev) 294 + { 295 + struct da8xx_ohci_root_hub *hub = pdev->dev.platform_data; 296 + struct usb_hcd *hcd; 297 + struct resource *mem; 298 + int error, irq; 299 + 300 + if (hub == NULL) 301 + return -ENODEV; 302 + 303 + usb11_clk = clk_get(&pdev->dev, "usb11"); 304 + if (IS_ERR(usb11_clk)) 305 + return PTR_ERR(usb11_clk); 306 + 307 + usb20_clk = clk_get(&pdev->dev, "usb20"); 308 + if (IS_ERR(usb20_clk)) { 309 + error = PTR_ERR(usb20_clk); 310 + goto err0; 311 + } 312 + 313 + hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev)); 314 + if (!hcd) { 315 + error = -ENOMEM; 316 + goto err1; 317 + } 318 + 319 + mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 320 + if (!mem) { 321 + error = -ENODEV; 322 + goto err2; 323 + } 324 + hcd->rsrc_start = mem->start; 325 + hcd->rsrc_len = mem->end - mem->start + 1; 326 + 327 + if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { 328 + dev_dbg(&pdev->dev, "request_mem_region failed\n"); 329 + error = -EBUSY; 330 + goto err2; 331 + } 332 + 333 + hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); 334 + if (!hcd->regs) { 335 + dev_err(&pdev->dev, "ioremap failed\n"); 336 + error = -ENOMEM; 337 + goto err3; 338 + } 339 + 340 + ohci_hcd_init(hcd_to_ohci(hcd)); 341 + 342 + irq = platform_get_irq(pdev, 0); 343 + if (irq < 0) { 344 + error = -ENODEV; 345 + goto err4; 346 + } 347 + error = usb_add_hcd(hcd, irq, IRQF_DISABLED); 348 + if (error) 349 + goto err4; 350 + 351 + if (hub->ocic_notify) { 352 + error = hub->ocic_notify(ohci_da8xx_ocic_handler); 353 + if (!error) 354 + return 0; 355 + } 356 + 357 + usb_remove_hcd(hcd); 358 + err4: 359 + iounmap(hcd->regs); 360 + err3: 361 + release_mem_region(hcd->rsrc_start, hcd->rsrc_len); 362 + err2: 363 + usb_put_hcd(hcd); 364 + err1: 365 + clk_put(usb20_clk); 366 + err0: 367 + clk_put(usb11_clk); 368 + return error; 369 + } 370 + 371 + /** 372 + * usb_hcd_da8xx_remove - shutdown processing for DA8xx-based HCDs 373 + * @dev: USB Host Controller being removed 374 + * Context: !in_interrupt() 375 + * 376 + * Reverses the effect of usb_hcd_da8xx_probe(), first invoking 377 + * the HCD's stop() method. It is always called from a thread 378 + * context, normally "rmmod", "apmd", or something similar. 379 + */ 380 + static inline void 381 + usb_hcd_da8xx_remove(struct usb_hcd *hcd, struct platform_device *pdev) 382 + { 383 + struct da8xx_ohci_root_hub *hub = pdev->dev.platform_data; 384 + 385 + hub->ocic_notify(NULL); 386 + usb_remove_hcd(hcd); 387 + iounmap(hcd->regs); 388 + release_mem_region(hcd->rsrc_start, hcd->rsrc_len); 389 + usb_put_hcd(hcd); 390 + clk_put(usb20_clk); 391 + clk_put(usb11_clk); 392 + } 393 + 394 + static int ohci_hcd_da8xx_drv_probe(struct platform_device *dev) 395 + { 396 + return usb_hcd_da8xx_probe(&ohci_da8xx_hc_driver, dev); 397 + } 398 + 399 + static int ohci_hcd_da8xx_drv_remove(struct platform_device *dev) 400 + { 401 + struct usb_hcd *hcd = platform_get_drvdata(dev); 402 + 403 + usb_hcd_da8xx_remove(hcd, dev); 404 + platform_set_drvdata(dev, NULL); 405 + 406 + return 0; 407 + } 408 + 409 + #ifdef CONFIG_PM 410 + static int ohci_da8xx_suspend(struct platform_device *dev, pm_message_t message) 411 + { 412 + struct usb_hcd *hcd = platform_get_drvdata(dev); 413 + struct ohci_hcd *ohci = hcd_to_ohci(hcd); 414 + 415 + if (time_before(jiffies, ohci->next_statechange)) 416 + msleep(5); 417 + ohci->next_statechange = jiffies; 418 + 419 + ohci_da8xx_clock(0); 420 + hcd->state = HC_STATE_SUSPENDED; 421 + dev->dev.power.power_state = PMSG_SUSPEND; 422 + return 0; 423 + } 424 + 425 + static int ohci_da8xx_resume(struct platform_device *dev) 426 + { 427 + struct usb_hcd *hcd = platform_get_drvdata(dev); 428 + struct ohci_hcd *ohci = hcd_to_ohci(hcd); 429 + 430 + if (time_before(jiffies, ohci->next_statechange)) 431 + msleep(5); 432 + ohci->next_statechange = jiffies; 433 + 434 + ohci_da8xx_clock(1); 435 + dev->dev.power.power_state = PMSG_ON; 436 + usb_hcd_resume_root_hub(hcd); 437 + return 0; 438 + } 439 + #endif 440 + 441 + /* 442 + * Driver definition to register with platform structure. 443 + */ 444 + static struct platform_driver ohci_hcd_da8xx_driver = { 445 + .probe = ohci_hcd_da8xx_drv_probe, 446 + .remove = ohci_hcd_da8xx_drv_remove, 447 + .shutdown = usb_hcd_platform_shutdown, 448 + #ifdef CONFIG_PM 449 + .suspend = ohci_da8xx_suspend, 450 + .resume = ohci_da8xx_resume, 451 + #endif 452 + .driver = { 453 + .owner = THIS_MODULE, 454 + .name = "ohci", 455 + }, 456 + };
+2 -2
drivers/usb/host/ohci-dbg.c
··· 53 int i, len; 54 55 if (usb_pipecontrol (pipe)) { 56 - printk (KERN_DEBUG __FILE__ ": setup(8):"); 57 for (i = 0; i < 8 ; i++) 58 printk (" %02x", ((__u8 *) urb->setup_packet) [i]); 59 printk ("\n"); 60 } 61 if (urb->transfer_buffer_length > 0 && urb->transfer_buffer) { 62 - printk (KERN_DEBUG __FILE__ ": data(%d/%d):", 63 urb->actual_length, 64 urb->transfer_buffer_length); 65 len = usb_pipeout (pipe)?
··· 53 int i, len; 54 55 if (usb_pipecontrol (pipe)) { 56 + printk (KERN_DEBUG "%s: setup(8):", __FILE__); 57 for (i = 0; i < 8 ; i++) 58 printk (" %02x", ((__u8 *) urb->setup_packet) [i]); 59 printk ("\n"); 60 } 61 if (urb->transfer_buffer_length > 0 && urb->transfer_buffer) { 62 + printk (KERN_DEBUG "%s: data(%d/%d):", __FILE__, 63 urb->actual_length, 64 urb->transfer_buffer_length); 65 len = usb_pipeout (pipe)?
+5
drivers/usb/host/ohci-hcd.c
··· 1051 #define PLATFORM_DRIVER usb_hcd_pnx4008_driver 1052 #endif 1053 1054 #if defined(CONFIG_CPU_SUBTYPE_SH7720) || \ 1055 defined(CONFIG_CPU_SUBTYPE_SH7721) || \ 1056 defined(CONFIG_CPU_SUBTYPE_SH7763) || \
··· 1051 #define PLATFORM_DRIVER usb_hcd_pnx4008_driver 1052 #endif 1053 1054 + #ifdef CONFIG_ARCH_DAVINCI_DA8XX 1055 + #include "ohci-da8xx.c" 1056 + #define PLATFORM_DRIVER ohci_hcd_da8xx_driver 1057 + #endif 1058 + 1059 #if defined(CONFIG_CPU_SUBTYPE_SH7720) || \ 1060 defined(CONFIG_CPU_SUBTYPE_SH7721) || \ 1061 defined(CONFIG_CPU_SUBTYPE_SH7763) || \
+5 -6
drivers/usb/host/ohci-lh7a404.c
··· 28 29 static void lh7a404_start_hc(struct platform_device *dev) 30 { 31 - printk(KERN_DEBUG __FILE__ 32 - ": starting LH7A404 OHCI USB Controller\n"); 33 34 /* 35 * Now, carefully enable the USB clock, and take ··· 39 udelay(1000); 40 USBH_CMDSTATUS = OHCI_HCR; 41 42 - printk(KERN_DEBUG __FILE__ 43 - ": Clock to USB host has been enabled \n"); 44 } 45 46 static void lh7a404_stop_hc(struct platform_device *dev) 47 { 48 - printk(KERN_DEBUG __FILE__ 49 - ": stopping LH7A404 OHCI USB Controller\n"); 50 51 CSC_PWRCNT &= ~CSC_PWRCNT_USBH_EN; /* Disable clock */ 52 }
··· 28 29 static void lh7a404_start_hc(struct platform_device *dev) 30 { 31 + printk(KERN_DEBUG "%s: starting LH7A404 OHCI USB Controller\n", 32 + __FILE__); 33 34 /* 35 * Now, carefully enable the USB clock, and take ··· 39 udelay(1000); 40 USBH_CMDSTATUS = OHCI_HCR; 41 42 + printk(KERN_DEBUG "%s: Clock to USB host has been enabled \n", __FILE__); 43 } 44 45 static void lh7a404_stop_hc(struct platform_device *dev) 46 { 47 + printk(KERN_DEBUG "%s: stopping LH7A404 OHCI USB Controller\n", 48 + __FILE__); 49 50 CSC_PWRCNT &= ~CSC_PWRCNT_USBH_EN; /* Disable clock */ 51 }
+3 -3
drivers/usb/host/ohci-pnx4008.c
··· 327 } 328 i2c_adap = i2c_get_adapter(2); 329 memset(&i2c_info, 0, sizeof(struct i2c_board_info)); 330 - strlcpy(i2c_info.name, "isp1301_pnx", I2C_NAME_SIZE); 331 isp1301_i2c_client = i2c_new_probed_device(i2c_adap, &i2c_info, 332 normal_i2c); 333 i2c_put_adapter(i2c_adap); ··· 411 out2: 412 clk_put(usb_clk); 413 out1: 414 - i2c_unregister_client(isp1301_i2c_client); 415 isp1301_i2c_client = NULL; 416 out_i2c_driver: 417 i2c_del_driver(&isp1301_driver); ··· 430 pnx4008_unset_usb_bits(); 431 clk_disable(usb_clk); 432 clk_put(usb_clk); 433 - i2c_unregister_client(isp1301_i2c_client); 434 isp1301_i2c_client = NULL; 435 i2c_del_driver(&isp1301_driver); 436
··· 327 } 328 i2c_adap = i2c_get_adapter(2); 329 memset(&i2c_info, 0, sizeof(struct i2c_board_info)); 330 + strlcpy(i2c_info.type, "isp1301_pnx", I2C_NAME_SIZE); 331 isp1301_i2c_client = i2c_new_probed_device(i2c_adap, &i2c_info, 332 normal_i2c); 333 i2c_put_adapter(i2c_adap); ··· 411 out2: 412 clk_put(usb_clk); 413 out1: 414 + i2c_unregister_device(isp1301_i2c_client); 415 isp1301_i2c_client = NULL; 416 out_i2c_driver: 417 i2c_del_driver(&isp1301_driver); ··· 430 pnx4008_unset_usb_bits(); 431 clk_disable(usb_clk); 432 clk_put(usb_clk); 433 + i2c_unregister_device(isp1301_i2c_client); 434 isp1301_i2c_client = NULL; 435 i2c_del_driver(&isp1301_driver); 436
+5 -5
drivers/usb/host/ohci-ppc-of.c
··· 114 hcd->rsrc_len = res.end - res.start + 1; 115 116 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { 117 - printk(KERN_ERR __FILE__ ": request_mem_region failed\n"); 118 rv = -EBUSY; 119 goto err_rmr; 120 } 121 122 irq = irq_of_parse_and_map(dn, 0); 123 if (irq == NO_IRQ) { 124 - printk(KERN_ERR __FILE__ ": irq_of_parse_and_map failed\n"); 125 rv = -EBUSY; 126 goto err_irq; 127 } 128 129 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); 130 if (!hcd->regs) { 131 - printk(KERN_ERR __FILE__ ": ioremap failed\n"); 132 rv = -ENOMEM; 133 goto err_ioremap; 134 } ··· 169 } else 170 release_mem_region(res.start, 0x4); 171 } else 172 - pr_debug(__FILE__ ": cannot get ehci offset from fdt\n"); 173 } 174 175 iounmap(hcd->regs); ··· 212 } 213 214 215 - static struct of_device_id ohci_hcd_ppc_of_match[] = { 216 #ifdef CONFIG_USB_OHCI_HCD_PPC_OF_BE 217 { 218 .name = "usb",
··· 114 hcd->rsrc_len = res.end - res.start + 1; 115 116 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { 117 + printk(KERN_ERR "%s: request_mem_region failed\n", __FILE__); 118 rv = -EBUSY; 119 goto err_rmr; 120 } 121 122 irq = irq_of_parse_and_map(dn, 0); 123 if (irq == NO_IRQ) { 124 + printk(KERN_ERR "%s: irq_of_parse_and_map failed\n", __FILE__); 125 rv = -EBUSY; 126 goto err_irq; 127 } 128 129 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); 130 if (!hcd->regs) { 131 + printk(KERN_ERR "%s: ioremap failed\n", __FILE__); 132 rv = -ENOMEM; 133 goto err_ioremap; 134 } ··· 169 } else 170 release_mem_region(res.start, 0x4); 171 } else 172 + pr_debug("%s: cannot get ehci offset from fdt\n", __FILE__); 173 } 174 175 iounmap(hcd->regs); ··· 212 } 213 214 215 + static const struct of_device_id ohci_hcd_ppc_of_match[] = { 216 #ifdef CONFIG_USB_OHCI_HCD_PPC_OF_BE 217 { 218 .name = "usb",
+4 -4
drivers/usb/host/ohci-ppc-soc.c
··· 41 42 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 43 if (!res) { 44 - pr_debug(__FILE__ ": no irq\n"); 45 return -ENODEV; 46 } 47 irq = res->start; 48 49 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 50 if (!res) { 51 - pr_debug(__FILE__ ": no reg addr\n"); 52 return -ENODEV; 53 } 54 ··· 59 hcd->rsrc_len = res->end - res->start + 1; 60 61 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { 62 - pr_debug(__FILE__ ": request_mem_region failed\n"); 63 retval = -EBUSY; 64 goto err1; 65 } 66 67 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); 68 if (!hcd->regs) { 69 - pr_debug(__FILE__ ": ioremap failed\n"); 70 retval = -ENOMEM; 71 goto err2; 72 }
··· 41 42 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 43 if (!res) { 44 + pr_debug("%s: no irq\n", __FILE__); 45 return -ENODEV; 46 } 47 irq = res->start; 48 49 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 50 if (!res) { 51 + pr_debug("%s: no reg addr\n", __FILE__); 52 return -ENODEV; 53 } 54 ··· 59 hcd->rsrc_len = res->end - res->start + 1; 60 61 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { 62 + pr_debug("%s: request_mem_region failed\n", __FILE__); 63 retval = -EBUSY; 64 goto err1; 65 } 66 67 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); 68 if (!hcd->regs) { 69 + pr_debug("%s: ioremap failed\n", __FILE__); 70 retval = -ENOMEM; 71 goto err2; 72 }
+4 -4
drivers/usb/host/ohci-sa1111.c
··· 31 { 32 unsigned int usb_rst = 0; 33 34 - printk(KERN_DEBUG __FILE__ 35 - ": starting SA-1111 OHCI USB Controller\n"); 36 37 #ifdef CONFIG_SA1100_BADGE4 38 if (machine_is_badge4()) { ··· 65 static void sa1111_stop_hc(struct sa1111_dev *dev) 66 { 67 unsigned int usb_rst; 68 - printk(KERN_DEBUG __FILE__ 69 - ": stopping SA-1111 OHCI USB Controller\n"); 70 71 /* 72 * Put the USB host controller into reset.
··· 31 { 32 unsigned int usb_rst = 0; 33 34 + printk(KERN_DEBUG "%s: starting SA-1111 OHCI USB Controller\n", 35 + __FILE__); 36 37 #ifdef CONFIG_SA1100_BADGE4 38 if (machine_is_badge4()) { ··· 65 static void sa1111_stop_hc(struct sa1111_dev *dev) 66 { 67 unsigned int usb_rst; 68 + printk(KERN_DEBUG "%s: stopping SA-1111 OHCI USB Controller\n", 69 + __FILE__); 70 71 /* 72 * Put the USB host controller into reset.
+3 -2
drivers/usb/host/sl811-hcd.c
··· 51 #include <asm/irq.h> 52 #include <asm/system.h> 53 #include <asm/byteorder.h> 54 55 #include "../core/hcd.h" 56 #include "sl811.h" ··· 1273 sl811h_hub_descriptor(sl811, (struct usb_hub_descriptor *) buf); 1274 break; 1275 case GetHubStatus: 1276 - *(__le32 *) buf = cpu_to_le32(0); 1277 break; 1278 case GetPortStatus: 1279 if (wIndex != 1) 1280 goto error; 1281 - *(__le32 *) buf = cpu_to_le32(sl811->port1); 1282 1283 #ifndef VERBOSE 1284 if (*(u16*)(buf+2)) /* only if wPortChange is interesting */
··· 51 #include <asm/irq.h> 52 #include <asm/system.h> 53 #include <asm/byteorder.h> 54 + #include <asm/unaligned.h> 55 56 #include "../core/hcd.h" 57 #include "sl811.h" ··· 1272 sl811h_hub_descriptor(sl811, (struct usb_hub_descriptor *) buf); 1273 break; 1274 case GetHubStatus: 1275 + put_unaligned_le32(0, buf); 1276 break; 1277 case GetPortStatus: 1278 if (wIndex != 1) 1279 goto error; 1280 + put_unaligned_le32(sl811->port1, buf); 1281 1282 #ifndef VERBOSE 1283 if (*(u16*)(buf+2)) /* only if wPortChange is interesting */
+1
drivers/usb/host/uhci-hcd.c
··· 735 uhci_hc_died(uhci); 736 uhci_scan_schedule(uhci); 737 spin_unlock_irq(&uhci->lock); 738 739 del_timer_sync(&uhci->fsbr_timer); 740 release_uhci(uhci);
··· 735 uhci_hc_died(uhci); 736 uhci_scan_schedule(uhci); 737 spin_unlock_irq(&uhci->lock); 738 + synchronize_irq(hcd->irq); 739 740 del_timer_sync(&uhci->fsbr_timer); 741 release_uhci(uhci);
+19
drivers/usb/host/xhci-dbg.c
··· 406 } 407 } 408 409 void xhci_dbg_slot_ctx(struct xhci_hcd *xhci, struct xhci_container_ctx *ctx) 410 { 411 /* Fields are 32 bits wide, DMA addresses are in bytes */
··· 406 } 407 } 408 409 + char *xhci_get_slot_state(struct xhci_hcd *xhci, 410 + struct xhci_container_ctx *ctx) 411 + { 412 + struct xhci_slot_ctx *slot_ctx = xhci_get_slot_ctx(xhci, ctx); 413 + 414 + switch (GET_SLOT_STATE(slot_ctx->dev_state)) { 415 + case 0: 416 + return "enabled/disabled"; 417 + case 1: 418 + return "default"; 419 + case 2: 420 + return "addressed"; 421 + case 3: 422 + return "configured"; 423 + default: 424 + return "reserved"; 425 + } 426 + } 427 + 428 void xhci_dbg_slot_ctx(struct xhci_hcd *xhci, struct xhci_container_ctx *ctx) 429 { 430 /* Fields are 32 bits wide, DMA addresses are in bytes */
+5 -2
drivers/usb/host/xhci-ext-caps.h
··· 101 102 next = readl(base + ext_offset); 103 104 - if (ext_offset == XHCI_HCC_PARAMS_OFFSET) 105 /* Find the first extended capability */ 106 next = XHCI_HCC_EXT_CAPS(next); 107 - else 108 /* Find the next extended capability */ 109 next = XHCI_EXT_CAPS_NEXT(next); 110 if (!next) 111 return 0; 112 /*
··· 101 102 next = readl(base + ext_offset); 103 104 + if (ext_offset == XHCI_HCC_PARAMS_OFFSET) { 105 /* Find the first extended capability */ 106 next = XHCI_HCC_EXT_CAPS(next); 107 + ext_offset = 0; 108 + } else { 109 /* Find the next extended capability */ 110 next = XHCI_EXT_CAPS_NEXT(next); 111 + } 112 + 113 if (!next) 114 return 0; 115 /*
+130 -20
drivers/usb/host/xhci-hcd.c
··· 1007 * for usb_set_interface() and usb_set_configuration() claim). 1008 */ 1009 if (xhci_endpoint_init(xhci, xhci->devs[udev->slot_id], 1010 - udev, ep, GFP_KERNEL) < 0) { 1011 dev_dbg(&udev->dev, "%s - could not initialize ep %#x\n", 1012 __func__, ep->desc.bEndpointAddress); 1013 return -ENOMEM; ··· 1181 ret = xhci_queue_evaluate_context(xhci, in_ctx->dma, 1182 udev->slot_id); 1183 if (ret < 0) { 1184 spin_unlock_irqrestore(&xhci->lock, flags); 1185 xhci_dbg(xhci, "FIXME allocate a new ring segment\n"); 1186 return -ENOMEM; ··· 1266 xhci_zero_in_ctx(xhci, virt_dev); 1267 /* Install new rings and free or cache any old rings */ 1268 for (i = 1; i < 31; ++i) { 1269 - int rings_cached; 1270 - 1271 if (!virt_dev->eps[i].new_ring) 1272 continue; 1273 /* Only cache or free the old ring if it exists. 1274 * It may not if this is the first add of an endpoint. 1275 */ 1276 if (virt_dev->eps[i].ring) { 1277 - rings_cached = virt_dev->num_rings_cached; 1278 - if (rings_cached < XHCI_MAX_RINGS_CACHED) { 1279 - virt_dev->num_rings_cached++; 1280 - rings_cached = virt_dev->num_rings_cached; 1281 - virt_dev->ring_cache[rings_cached] = 1282 - virt_dev->eps[i].ring; 1283 - xhci_dbg(xhci, "Cached old ring, " 1284 - "%d ring%s cached\n", 1285 - rings_cached, 1286 - (rings_cached > 1) ? "s" : ""); 1287 - } else { 1288 - xhci_ring_free(xhci, virt_dev->eps[i].ring); 1289 - xhci_dbg(xhci, "Ring cache full (%d rings), " 1290 - "freeing ring\n", 1291 - virt_dev->num_rings_cached); 1292 - } 1293 } 1294 virt_dev->eps[i].ring = virt_dev->eps[i].new_ring; 1295 virt_dev->eps[i].new_ring = NULL; ··· 1440 1441 if (ret) 1442 xhci_warn(xhci, "FIXME allocate a new ring segment\n"); 1443 } 1444 1445 /* ··· 1804 xhci_warn(xhci, "Cannot update hub desc for unknown device.\n"); 1805 return -EINVAL; 1806 } 1807 - config_cmd = xhci_alloc_command(xhci, true, mem_flags); 1808 if (!config_cmd) { 1809 xhci_dbg(xhci, "Could not allocate xHCI command structure.\n"); 1810 return -ENOMEM;
··· 1007 * for usb_set_interface() and usb_set_configuration() claim). 1008 */ 1009 if (xhci_endpoint_init(xhci, xhci->devs[udev->slot_id], 1010 + udev, ep, GFP_NOIO) < 0) { 1011 dev_dbg(&udev->dev, "%s - could not initialize ep %#x\n", 1012 __func__, ep->desc.bEndpointAddress); 1013 return -ENOMEM; ··· 1181 ret = xhci_queue_evaluate_context(xhci, in_ctx->dma, 1182 udev->slot_id); 1183 if (ret < 0) { 1184 + if (command) 1185 + list_del(&command->cmd_list); 1186 spin_unlock_irqrestore(&xhci->lock, flags); 1187 xhci_dbg(xhci, "FIXME allocate a new ring segment\n"); 1188 return -ENOMEM; ··· 1264 xhci_zero_in_ctx(xhci, virt_dev); 1265 /* Install new rings and free or cache any old rings */ 1266 for (i = 1; i < 31; ++i) { 1267 if (!virt_dev->eps[i].new_ring) 1268 continue; 1269 /* Only cache or free the old ring if it exists. 1270 * It may not if this is the first add of an endpoint. 1271 */ 1272 if (virt_dev->eps[i].ring) { 1273 + xhci_free_or_cache_endpoint_ring(xhci, virt_dev, i); 1274 } 1275 virt_dev->eps[i].ring = virt_dev->eps[i].new_ring; 1276 virt_dev->eps[i].new_ring = NULL; ··· 1455 1456 if (ret) 1457 xhci_warn(xhci, "FIXME allocate a new ring segment\n"); 1458 + } 1459 + 1460 + /* 1461 + * This submits a Reset Device Command, which will set the device state to 0, 1462 + * set the device address to 0, and disable all the endpoints except the default 1463 + * control endpoint. The USB core should come back and call 1464 + * xhci_address_device(), and then re-set up the configuration. If this is 1465 + * called because of a usb_reset_and_verify_device(), then the old alternate 1466 + * settings will be re-installed through the normal bandwidth allocation 1467 + * functions. 1468 + * 1469 + * Wait for the Reset Device command to finish. Remove all structures 1470 + * associated with the endpoints that were disabled. Clear the input device 1471 + * structure? Cache the rings? Reset the control endpoint 0 max packet size? 1472 + */ 1473 + int xhci_reset_device(struct usb_hcd *hcd, struct usb_device *udev) 1474 + { 1475 + int ret, i; 1476 + unsigned long flags; 1477 + struct xhci_hcd *xhci; 1478 + unsigned int slot_id; 1479 + struct xhci_virt_device *virt_dev; 1480 + struct xhci_command *reset_device_cmd; 1481 + int timeleft; 1482 + int last_freed_endpoint; 1483 + 1484 + ret = xhci_check_args(hcd, udev, NULL, 0, __func__); 1485 + if (ret <= 0) 1486 + return ret; 1487 + xhci = hcd_to_xhci(hcd); 1488 + slot_id = udev->slot_id; 1489 + virt_dev = xhci->devs[slot_id]; 1490 + if (!virt_dev) { 1491 + xhci_dbg(xhci, "%s called with invalid slot ID %u\n", 1492 + __func__, slot_id); 1493 + return -EINVAL; 1494 + } 1495 + 1496 + xhci_dbg(xhci, "Resetting device with slot ID %u\n", slot_id); 1497 + /* Allocate the command structure that holds the struct completion. 1498 + * Assume we're in process context, since the normal device reset 1499 + * process has to wait for the device anyway. Storage devices are 1500 + * reset as part of error handling, so use GFP_NOIO instead of 1501 + * GFP_KERNEL. 1502 + */ 1503 + reset_device_cmd = xhci_alloc_command(xhci, false, true, GFP_NOIO); 1504 + if (!reset_device_cmd) { 1505 + xhci_dbg(xhci, "Couldn't allocate command structure.\n"); 1506 + return -ENOMEM; 1507 + } 1508 + 1509 + /* Attempt to submit the Reset Device command to the command ring */ 1510 + spin_lock_irqsave(&xhci->lock, flags); 1511 + reset_device_cmd->command_trb = xhci->cmd_ring->enqueue; 1512 + list_add_tail(&reset_device_cmd->cmd_list, &virt_dev->cmd_list); 1513 + ret = xhci_queue_reset_device(xhci, slot_id); 1514 + if (ret) { 1515 + xhci_dbg(xhci, "FIXME: allocate a command ring segment\n"); 1516 + list_del(&reset_device_cmd->cmd_list); 1517 + spin_unlock_irqrestore(&xhci->lock, flags); 1518 + goto command_cleanup; 1519 + } 1520 + xhci_ring_cmd_db(xhci); 1521 + spin_unlock_irqrestore(&xhci->lock, flags); 1522 + 1523 + /* Wait for the Reset Device command to finish */ 1524 + timeleft = wait_for_completion_interruptible_timeout( 1525 + reset_device_cmd->completion, 1526 + USB_CTRL_SET_TIMEOUT); 1527 + if (timeleft <= 0) { 1528 + xhci_warn(xhci, "%s while waiting for reset device command\n", 1529 + timeleft == 0 ? "Timeout" : "Signal"); 1530 + spin_lock_irqsave(&xhci->lock, flags); 1531 + /* The timeout might have raced with the event ring handler, so 1532 + * only delete from the list if the item isn't poisoned. 1533 + */ 1534 + if (reset_device_cmd->cmd_list.next != LIST_POISON1) 1535 + list_del(&reset_device_cmd->cmd_list); 1536 + spin_unlock_irqrestore(&xhci->lock, flags); 1537 + ret = -ETIME; 1538 + goto command_cleanup; 1539 + } 1540 + 1541 + /* The Reset Device command can't fail, according to the 0.95/0.96 spec, 1542 + * unless we tried to reset a slot ID that wasn't enabled, 1543 + * or the device wasn't in the addressed or configured state. 1544 + */ 1545 + ret = reset_device_cmd->status; 1546 + switch (ret) { 1547 + case COMP_EBADSLT: /* 0.95 completion code for bad slot ID */ 1548 + case COMP_CTX_STATE: /* 0.96 completion code for same thing */ 1549 + xhci_info(xhci, "Can't reset device (slot ID %u) in %s state\n", 1550 + slot_id, 1551 + xhci_get_slot_state(xhci, virt_dev->out_ctx)); 1552 + xhci_info(xhci, "Not freeing device rings.\n"); 1553 + /* Don't treat this as an error. May change my mind later. */ 1554 + ret = 0; 1555 + goto command_cleanup; 1556 + case COMP_SUCCESS: 1557 + xhci_dbg(xhci, "Successful reset device command.\n"); 1558 + break; 1559 + default: 1560 + if (xhci_is_vendor_info_code(xhci, ret)) 1561 + break; 1562 + xhci_warn(xhci, "Unknown completion code %u for " 1563 + "reset device command.\n", ret); 1564 + ret = -EINVAL; 1565 + goto command_cleanup; 1566 + } 1567 + 1568 + /* Everything but endpoint 0 is disabled, so free or cache the rings. */ 1569 + last_freed_endpoint = 1; 1570 + for (i = 1; i < 31; ++i) { 1571 + if (!virt_dev->eps[i].ring) 1572 + continue; 1573 + xhci_free_or_cache_endpoint_ring(xhci, virt_dev, i); 1574 + last_freed_endpoint = i; 1575 + } 1576 + xhci_dbg(xhci, "Output context after successful reset device cmd:\n"); 1577 + xhci_dbg_ctx(xhci, virt_dev->out_ctx, last_freed_endpoint); 1578 + ret = 0; 1579 + 1580 + command_cleanup: 1581 + xhci_free_command(xhci, reset_device_cmd); 1582 + return ret; 1583 } 1584 1585 /* ··· 1694 xhci_warn(xhci, "Cannot update hub desc for unknown device.\n"); 1695 return -EINVAL; 1696 } 1697 + config_cmd = xhci_alloc_command(xhci, true, true, mem_flags); 1698 if (!config_cmd) { 1699 xhci_dbg(xhci, "Could not allocate xHCI command structure.\n"); 1700 return -ENOMEM;
+50 -15
drivers/usb/host/xhci-hub.c
··· 129 return (state & XHCI_PORT_RO) | (state & XHCI_PORT_RWS); 130 } 131 132 int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, 133 u16 wIndex, char *buf, u16 wLength) 134 { ··· 182 u32 temp, status; 183 int retval = 0; 184 u32 __iomem *addr; 185 - char *port_change_bit; 186 187 ports = HCS_MAX_PORTS(xhci->hcs_params1); 188 ··· 272 temp = xhci_port_state_to_neutral(temp); 273 switch (wValue) { 274 case USB_PORT_FEAT_C_RESET: 275 - status = PORT_RC; 276 - port_change_bit = "reset"; 277 - break; 278 case USB_PORT_FEAT_C_CONNECTION: 279 - status = PORT_CSC; 280 - port_change_bit = "connect"; 281 - break; 282 case USB_PORT_FEAT_C_OVER_CURRENT: 283 - status = PORT_OCC; 284 - port_change_bit = "over-current"; 285 break; 286 default: 287 goto error; 288 } 289 - /* Change bits are all write 1 to clear */ 290 - xhci_writel(xhci, temp | status, addr); 291 - temp = xhci_readl(xhci, addr); 292 - xhci_dbg(xhci, "clear port %s change, actual port %d status = 0x%x\n", 293 - port_change_bit, wIndex, temp); 294 - temp = xhci_readl(xhci, addr); /* unblock any posted writes */ 295 break; 296 default: 297 error:
··· 129 return (state & XHCI_PORT_RO) | (state & XHCI_PORT_RWS); 130 } 131 132 + static void xhci_disable_port(struct xhci_hcd *xhci, u16 wIndex, 133 + u32 __iomem *addr, u32 port_status) 134 + { 135 + /* Write 1 to disable the port */ 136 + xhci_writel(xhci, port_status | PORT_PE, addr); 137 + port_status = xhci_readl(xhci, addr); 138 + xhci_dbg(xhci, "disable port, actual port %d status = 0x%x\n", 139 + wIndex, port_status); 140 + } 141 + 142 + static void xhci_clear_port_change_bit(struct xhci_hcd *xhci, u16 wValue, 143 + u16 wIndex, u32 __iomem *addr, u32 port_status) 144 + { 145 + char *port_change_bit; 146 + u32 status; 147 + 148 + switch (wValue) { 149 + case USB_PORT_FEAT_C_RESET: 150 + status = PORT_RC; 151 + port_change_bit = "reset"; 152 + break; 153 + case USB_PORT_FEAT_C_CONNECTION: 154 + status = PORT_CSC; 155 + port_change_bit = "connect"; 156 + break; 157 + case USB_PORT_FEAT_C_OVER_CURRENT: 158 + status = PORT_OCC; 159 + port_change_bit = "over-current"; 160 + break; 161 + case USB_PORT_FEAT_C_ENABLE: 162 + status = PORT_PEC; 163 + port_change_bit = "enable/disable"; 164 + break; 165 + default: 166 + /* Should never happen */ 167 + return; 168 + } 169 + /* Change bits are all write 1 to clear */ 170 + xhci_writel(xhci, port_status | status, addr); 171 + port_status = xhci_readl(xhci, addr); 172 + xhci_dbg(xhci, "clear port %s change, actual port %d status = 0x%x\n", 173 + port_change_bit, wIndex, port_status); 174 + } 175 + 176 int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, 177 u16 wIndex, char *buf, u16 wLength) 178 { ··· 138 u32 temp, status; 139 int retval = 0; 140 u32 __iomem *addr; 141 142 ports = HCS_MAX_PORTS(xhci->hcs_params1); 143 ··· 229 temp = xhci_port_state_to_neutral(temp); 230 switch (wValue) { 231 case USB_PORT_FEAT_C_RESET: 232 case USB_PORT_FEAT_C_CONNECTION: 233 case USB_PORT_FEAT_C_OVER_CURRENT: 234 + case USB_PORT_FEAT_C_ENABLE: 235 + xhci_clear_port_change_bit(xhci, wValue, wIndex, 236 + addr, temp); 237 + break; 238 + case USB_PORT_FEAT_ENABLE: 239 + xhci_disable_port(xhci, wIndex, addr, temp); 240 break; 241 default: 242 goto error; 243 } 244 break; 245 default: 246 error:
+39 -8
drivers/usb/host/xhci-mem.c
··· 198 return 0; 199 } 200 201 /* Zero an endpoint ring (except for link TRBs) and move the enqueue and dequeue 202 * pointers to the beginning of the ring. 203 */ ··· 267 void xhci_free_container_ctx(struct xhci_hcd *xhci, 268 struct xhci_container_ctx *ctx) 269 { 270 dma_pool_free(xhci->device_pool, ctx->bytes, ctx->dma); 271 kfree(ctx); 272 } ··· 454 case USB_SPEED_LOW: 455 slot_ctx->dev_info |= (u32) SLOT_SPEED_LS; 456 break; 457 - case USB_SPEED_VARIABLE: 458 xhci_dbg(xhci, "FIXME xHCI doesn't support wireless speeds\n"); 459 return -EINVAL; 460 break; ··· 498 case USB_SPEED_LOW: 499 ep0_ctx->ep_info2 |= MAX_PACKET(8); 500 break; 501 - case USB_SPEED_VARIABLE: 502 xhci_dbg(xhci, "FIXME xHCI doesn't support wireless speeds\n"); 503 return -EINVAL; 504 break; ··· 846 } 847 848 struct xhci_command *xhci_alloc_command(struct xhci_hcd *xhci, 849 - bool allocate_completion, gfp_t mem_flags) 850 { 851 struct xhci_command *command; 852 ··· 855 if (!command) 856 return NULL; 857 858 - command->in_ctx = 859 - xhci_alloc_container_ctx(xhci, XHCI_CTX_TYPE_INPUT, mem_flags); 860 - if (!command->in_ctx) { 861 - kfree(command); 862 - return NULL; 863 } 864 865 if (allocate_completion) {
··· 198 return 0; 199 } 200 201 + void xhci_free_or_cache_endpoint_ring(struct xhci_hcd *xhci, 202 + struct xhci_virt_device *virt_dev, 203 + unsigned int ep_index) 204 + { 205 + int rings_cached; 206 + 207 + rings_cached = virt_dev->num_rings_cached; 208 + if (rings_cached < XHCI_MAX_RINGS_CACHED) { 209 + virt_dev->num_rings_cached++; 210 + rings_cached = virt_dev->num_rings_cached; 211 + virt_dev->ring_cache[rings_cached] = 212 + virt_dev->eps[ep_index].ring; 213 + xhci_dbg(xhci, "Cached old ring, " 214 + "%d ring%s cached\n", 215 + rings_cached, 216 + (rings_cached > 1) ? "s" : ""); 217 + } else { 218 + xhci_ring_free(xhci, virt_dev->eps[ep_index].ring); 219 + xhci_dbg(xhci, "Ring cache full (%d rings), " 220 + "freeing ring\n", 221 + virt_dev->num_rings_cached); 222 + } 223 + virt_dev->eps[ep_index].ring = NULL; 224 + } 225 + 226 /* Zero an endpoint ring (except for link TRBs) and move the enqueue and dequeue 227 * pointers to the beginning of the ring. 228 */ ··· 242 void xhci_free_container_ctx(struct xhci_hcd *xhci, 243 struct xhci_container_ctx *ctx) 244 { 245 + if (!ctx) 246 + return; 247 dma_pool_free(xhci->device_pool, ctx->bytes, ctx->dma); 248 kfree(ctx); 249 } ··· 427 case USB_SPEED_LOW: 428 slot_ctx->dev_info |= (u32) SLOT_SPEED_LS; 429 break; 430 + case USB_SPEED_WIRELESS: 431 xhci_dbg(xhci, "FIXME xHCI doesn't support wireless speeds\n"); 432 return -EINVAL; 433 break; ··· 471 case USB_SPEED_LOW: 472 ep0_ctx->ep_info2 |= MAX_PACKET(8); 473 break; 474 + case USB_SPEED_WIRELESS: 475 xhci_dbg(xhci, "FIXME xHCI doesn't support wireless speeds\n"); 476 return -EINVAL; 477 break; ··· 819 } 820 821 struct xhci_command *xhci_alloc_command(struct xhci_hcd *xhci, 822 + bool allocate_in_ctx, bool allocate_completion, 823 + gfp_t mem_flags) 824 { 825 struct xhci_command *command; 826 ··· 827 if (!command) 828 return NULL; 829 830 + if (allocate_in_ctx) { 831 + command->in_ctx = 832 + xhci_alloc_container_ctx(xhci, XHCI_CTX_TYPE_INPUT, 833 + mem_flags); 834 + if (!command->in_ctx) { 835 + kfree(command); 836 + return NULL; 837 + } 838 } 839 840 if (allocate_completion) {
+1
drivers/usb/host/xhci-pci.c
··· 139 .reset_bandwidth = xhci_reset_bandwidth, 140 .address_device = xhci_address_device, 141 .update_hub_device = xhci_update_hub_device, 142 143 /* 144 * scheduling support
··· 139 .reset_bandwidth = xhci_reset_bandwidth, 140 .address_device = xhci_address_device, 141 .update_hub_device = xhci_update_hub_device, 142 + .reset_device = xhci_reset_device, 143 144 /* 145 * scheduling support
+34 -7
drivers/usb/host/xhci-ring.c
··· 953 case TRB_TYPE(TRB_RESET_EP): 954 handle_reset_ep_completion(xhci, event, xhci->cmd_ring->dequeue); 955 break; 956 default: 957 /* Skip over unknown commands on the event ring */ 958 xhci->error_bitmask |= 1 << 6; ··· 1091 return 0; 1092 } 1093 1094 /* 1095 * If this function returns an error condition, it means it got a Transfer 1096 * event with a corrupted Slot ID, Endpoint ID, or TRB DMA address. ··· 1221 status = -ENOSR; 1222 break; 1223 default: 1224 - if (trb_comp_code >= 224 && trb_comp_code <= 255) { 1225 - /* Vendor defined "informational" completion code, 1226 - * treat as not-an-error. 1227 - */ 1228 - xhci_dbg(xhci, "Vendor defined info completion code %u\n", 1229 - trb_comp_code); 1230 - xhci_dbg(xhci, "Treating code as success.\n"); 1231 status = 0; 1232 break; 1233 } ··· 2197 return queue_command(xhci, lower_32_bits(in_ctx_ptr), 2198 upper_32_bits(in_ctx_ptr), 0, 2199 TRB_TYPE(TRB_ADDR_DEV) | SLOT_ID_FOR_TRB(slot_id), 2200 false); 2201 } 2202
··· 953 case TRB_TYPE(TRB_RESET_EP): 954 handle_reset_ep_completion(xhci, event, xhci->cmd_ring->dequeue); 955 break; 956 + case TRB_TYPE(TRB_RESET_DEV): 957 + xhci_dbg(xhci, "Completed reset device command.\n"); 958 + slot_id = TRB_TO_SLOT_ID( 959 + xhci->cmd_ring->dequeue->generic.field[3]); 960 + virt_dev = xhci->devs[slot_id]; 961 + if (virt_dev) 962 + handle_cmd_in_cmd_wait_list(xhci, virt_dev, event); 963 + else 964 + xhci_warn(xhci, "Reset device command completion " 965 + "for disabled slot %u\n", slot_id); 966 + break; 967 default: 968 /* Skip over unknown commands on the event ring */ 969 xhci->error_bitmask |= 1 << 6; ··· 1080 return 0; 1081 } 1082 1083 + int xhci_is_vendor_info_code(struct xhci_hcd *xhci, unsigned int trb_comp_code) 1084 + { 1085 + if (trb_comp_code >= 224 && trb_comp_code <= 255) { 1086 + /* Vendor defined "informational" completion code, 1087 + * treat as not-an-error. 1088 + */ 1089 + xhci_dbg(xhci, "Vendor defined info completion code %u\n", 1090 + trb_comp_code); 1091 + xhci_dbg(xhci, "Treating code as success.\n"); 1092 + return 1; 1093 + } 1094 + return 0; 1095 + } 1096 + 1097 /* 1098 * If this function returns an error condition, it means it got a Transfer 1099 * event with a corrupted Slot ID, Endpoint ID, or TRB DMA address. ··· 1196 status = -ENOSR; 1197 break; 1198 default: 1199 + if (xhci_is_vendor_info_code(xhci, trb_comp_code)) { 1200 status = 0; 1201 break; 1202 } ··· 2178 return queue_command(xhci, lower_32_bits(in_ctx_ptr), 2179 upper_32_bits(in_ctx_ptr), 0, 2180 TRB_TYPE(TRB_ADDR_DEV) | SLOT_ID_FOR_TRB(slot_id), 2181 + false); 2182 + } 2183 + 2184 + /* Queue a reset device command TRB */ 2185 + int xhci_queue_reset_device(struct xhci_hcd *xhci, u32 slot_id) 2186 + { 2187 + return queue_command(xhci, 0, 0, 0, 2188 + TRB_TYPE(TRB_RESET_DEV) | SLOT_ID_FOR_TRB(slot_id), 2189 false); 2190 } 2191
+10 -1
drivers/usb/host/xhci.h
··· 1210 void xhci_dbg_cmd_ptrs(struct xhci_hcd *xhci); 1211 void xhci_dbg_ring_ptrs(struct xhci_hcd *xhci, struct xhci_ring *ring); 1212 void xhci_dbg_ctx(struct xhci_hcd *xhci, struct xhci_container_ctx *ctx, unsigned int last_ep); 1213 1214 /* xHCI memory management */ 1215 void xhci_mem_cleanup(struct xhci_hcd *xhci); ··· 1235 struct usb_device *udev, struct usb_host_endpoint *ep, 1236 gfp_t mem_flags); 1237 void xhci_ring_free(struct xhci_hcd *xhci, struct xhci_ring *ring); 1238 struct xhci_command *xhci_alloc_command(struct xhci_hcd *xhci, 1239 - bool allocate_completion, gfp_t mem_flags); 1240 void xhci_free_command(struct xhci_hcd *xhci, 1241 struct xhci_command *command); 1242 ··· 1270 int xhci_add_endpoint(struct usb_hcd *hcd, struct usb_device *udev, struct usb_host_endpoint *ep); 1271 int xhci_drop_endpoint(struct usb_hcd *hcd, struct usb_device *udev, struct usb_host_endpoint *ep); 1272 void xhci_endpoint_reset(struct usb_hcd *hcd, struct usb_host_endpoint *ep); 1273 int xhci_check_bandwidth(struct usb_hcd *hcd, struct usb_device *udev); 1274 void xhci_reset_bandwidth(struct usb_hcd *hcd, struct usb_device *udev); 1275 ··· 1279 struct xhci_segment *trb_in_td(struct xhci_segment *start_seg, 1280 union xhci_trb *start_trb, union xhci_trb *end_trb, 1281 dma_addr_t suspect_dma); 1282 void xhci_ring_cmd_db(struct xhci_hcd *xhci); 1283 void *xhci_setup_one_noop(struct xhci_hcd *xhci); 1284 void xhci_handle_event(struct xhci_hcd *xhci); ··· 1301 u32 slot_id); 1302 int xhci_queue_reset_ep(struct xhci_hcd *xhci, int slot_id, 1303 unsigned int ep_index); 1304 void xhci_find_new_dequeue_state(struct xhci_hcd *xhci, 1305 unsigned int slot_id, unsigned int ep_index, 1306 struct xhci_td *cur_td, struct xhci_dequeue_state *state);
··· 1210 void xhci_dbg_cmd_ptrs(struct xhci_hcd *xhci); 1211 void xhci_dbg_ring_ptrs(struct xhci_hcd *xhci, struct xhci_ring *ring); 1212 void xhci_dbg_ctx(struct xhci_hcd *xhci, struct xhci_container_ctx *ctx, unsigned int last_ep); 1213 + char *xhci_get_slot_state(struct xhci_hcd *xhci, 1214 + struct xhci_container_ctx *ctx); 1215 1216 /* xHCI memory management */ 1217 void xhci_mem_cleanup(struct xhci_hcd *xhci); ··· 1233 struct usb_device *udev, struct usb_host_endpoint *ep, 1234 gfp_t mem_flags); 1235 void xhci_ring_free(struct xhci_hcd *xhci, struct xhci_ring *ring); 1236 + void xhci_free_or_cache_endpoint_ring(struct xhci_hcd *xhci, 1237 + struct xhci_virt_device *virt_dev, 1238 + unsigned int ep_index); 1239 struct xhci_command *xhci_alloc_command(struct xhci_hcd *xhci, 1240 + bool allocate_in_ctx, bool allocate_completion, 1241 + gfp_t mem_flags); 1242 void xhci_free_command(struct xhci_hcd *xhci, 1243 struct xhci_command *command); 1244 ··· 1264 int xhci_add_endpoint(struct usb_hcd *hcd, struct usb_device *udev, struct usb_host_endpoint *ep); 1265 int xhci_drop_endpoint(struct usb_hcd *hcd, struct usb_device *udev, struct usb_host_endpoint *ep); 1266 void xhci_endpoint_reset(struct usb_hcd *hcd, struct usb_host_endpoint *ep); 1267 + int xhci_reset_device(struct usb_hcd *hcd, struct usb_device *udev); 1268 int xhci_check_bandwidth(struct usb_hcd *hcd, struct usb_device *udev); 1269 void xhci_reset_bandwidth(struct usb_hcd *hcd, struct usb_device *udev); 1270 ··· 1272 struct xhci_segment *trb_in_td(struct xhci_segment *start_seg, 1273 union xhci_trb *start_trb, union xhci_trb *end_trb, 1274 dma_addr_t suspect_dma); 1275 + int xhci_is_vendor_info_code(struct xhci_hcd *xhci, unsigned int trb_comp_code); 1276 void xhci_ring_cmd_db(struct xhci_hcd *xhci); 1277 void *xhci_setup_one_noop(struct xhci_hcd *xhci); 1278 void xhci_handle_event(struct xhci_hcd *xhci); ··· 1293 u32 slot_id); 1294 int xhci_queue_reset_ep(struct xhci_hcd *xhci, int slot_id, 1295 unsigned int ep_index); 1296 + int xhci_queue_reset_device(struct xhci_hcd *xhci, u32 slot_id); 1297 void xhci_find_new_dequeue_state(struct xhci_hcd *xhci, 1298 unsigned int slot_id, unsigned int ep_index, 1299 struct xhci_td *cur_td, struct xhci_dequeue_state *state);
+1 -1
drivers/usb/image/mdc800.c
··· 967 968 969 970 - static struct usb_device_id mdc800_table [] = { 971 { USB_DEVICE(MDC800_VENDOR_ID, MDC800_PRODUCT_ID) }, 972 { } /* Terminating entry */ 973 };
··· 967 968 969 970 + static const struct usb_device_id mdc800_table[] = { 971 { USB_DEVICE(MDC800_VENDOR_ID, MDC800_PRODUCT_ID) }, 972 { } /* Terminating entry */ 973 };
+2 -2
drivers/usb/image/microtek.c
··· 155 const struct usb_device_id *id); 156 static void mts_usb_disconnect(struct usb_interface *intf); 157 158 - static struct usb_device_id mts_usb_ids []; 159 160 static struct usb_driver mts_usb_driver = { 161 .name = "microtekX6", ··· 656 /* The entries of microtek_table must correspond, line-by-line to 657 the entries of mts_supported_products[]. */ 658 659 - static struct usb_device_id mts_usb_ids [] = 660 { 661 { USB_DEVICE(0x4ce, 0x0300) }, 662 { USB_DEVICE(0x5da, 0x0094) },
··· 155 const struct usb_device_id *id); 156 static void mts_usb_disconnect(struct usb_interface *intf); 157 158 + static const struct usb_device_id mts_usb_ids[]; 159 160 static struct usb_driver mts_usb_driver = { 161 .name = "microtekX6", ··· 656 /* The entries of microtek_table must correspond, line-by-line to 657 the entries of mts_supported_products[]. */ 658 659 + static const struct usb_device_id mts_usb_ids[] = 660 { 661 { USB_DEVICE(0x4ce, 0x0300) }, 662 { USB_DEVICE(0x5da, 0x0094) },
-25
drivers/usb/misc/Kconfig
··· 87 To compile this driver as a module, choose M here: the 88 module will be called usblcd. 89 90 - config USB_BERRY_CHARGE 91 - tristate "USB BlackBerry recharge support" 92 - depends on USB 93 - help 94 - Say Y here if you want to connect a BlackBerry device to your 95 - computer's USB port and have it automatically switch to "recharge" 96 - mode. 97 - 98 - To compile this driver as a module, choose M here: the 99 - module will be called berry_charge. 100 - 101 config USB_LED 102 tristate "USB LED driver support" 103 depends on USB ··· 230 The firmware for this driver must be extracted from the MacOS 231 driver beforehand. Tools for doing so are available at 232 http://bersace03.free.fr 233 - 234 - config USB_VST 235 - tristate "USB VST driver" 236 - depends on USB 237 - help 238 - This driver is intended for Vernier Software Technologies 239 - bulk usb devices such as their Ocean-Optics spectrometers or 240 - Labquest. 241 - It is a bulk channel driver with configurable read and write 242 - timeouts. 243 - 244 - To compile this driver as a module, choose M here: the 245 - module will be called vstusb. 246 - 247
··· 87 To compile this driver as a module, choose M here: the 88 module will be called usblcd. 89 90 config USB_LED 91 tristate "USB LED driver support" 92 depends on USB ··· 241 The firmware for this driver must be extracted from the MacOS 242 driver beforehand. Tools for doing so are available at 243 http://bersace03.free.fr 244
-2
drivers/usb/misc/Makefile
··· 5 6 obj-$(CONFIG_USB_ADUTUX) += adutux.o 7 obj-$(CONFIG_USB_APPLEDISPLAY) += appledisplay.o 8 - obj-$(CONFIG_USB_BERRY_CHARGE) += berry_charge.o 9 obj-$(CONFIG_USB_CYPRESS_CY7C63)+= cypress_cy7c63.o 10 obj-$(CONFIG_USB_CYTHERM) += cytherm.o 11 obj-$(CONFIG_USB_EMI26) += emi26.o ··· 22 obj-$(CONFIG_USB_TRANCEVIBRATOR) += trancevibrator.o 23 obj-$(CONFIG_USB_USS720) += uss720.o 24 obj-$(CONFIG_USB_SEVSEG) += usbsevseg.o 25 - obj-$(CONFIG_USB_VST) += vstusb.o 26 27 obj-$(CONFIG_USB_SISUSBVGA) += sisusbvga/ 28
··· 5 6 obj-$(CONFIG_USB_ADUTUX) += adutux.o 7 obj-$(CONFIG_USB_APPLEDISPLAY) += appledisplay.o 8 obj-$(CONFIG_USB_CYPRESS_CY7C63)+= cypress_cy7c63.o 9 obj-$(CONFIG_USB_CYTHERM) += cytherm.o 10 obj-$(CONFIG_USB_EMI26) += emi26.o ··· 23 obj-$(CONFIG_USB_TRANCEVIBRATOR) += trancevibrator.o 24 obj-$(CONFIG_USB_USS720) += uss720.o 25 obj-$(CONFIG_USB_SEVSEG) += usbsevseg.o 26 27 obj-$(CONFIG_USB_SISUSBVGA) += sisusbvga/ 28
+4 -4
drivers/usb/misc/adutux.c
··· 38 #define dbg(lvl, format, arg...) \ 39 do { \ 40 if (debug >= lvl) \ 41 - printk(KERN_DEBUG __FILE__ " : " format " \n", ## arg); \ 42 } while (0) 43 44 ··· 56 #define ADU_PRODUCT_ID 0x0064 57 58 /* table of devices that work with this driver */ 59 - static struct usb_device_id device_table [] = { 60 { USB_DEVICE(ADU_VENDOR_ID, ADU_PRODUCT_ID) }, /* ADU100 */ 61 { USB_DEVICE(ADU_VENDOR_ID, ADU_PRODUCT_ID+20) }, /* ADU120 */ 62 { USB_DEVICE(ADU_VENDOR_ID, ADU_PRODUCT_ID+30) }, /* ADU130 */ ··· 132 if (debug < level) 133 return; 134 135 - printk(KERN_DEBUG __FILE__": %s - length = %d, data = ", 136 - function, size); 137 for (i = 0; i < size; ++i) 138 printk("%.2x ", data[i]); 139 printk("\n");
··· 38 #define dbg(lvl, format, arg...) \ 39 do { \ 40 if (debug >= lvl) \ 41 + printk(KERN_DEBUG "%s: " format "\n", __FILE__, ##arg); \ 42 } while (0) 43 44 ··· 56 #define ADU_PRODUCT_ID 0x0064 57 58 /* table of devices that work with this driver */ 59 + static const struct usb_device_id device_table[] = { 60 { USB_DEVICE(ADU_VENDOR_ID, ADU_PRODUCT_ID) }, /* ADU100 */ 61 { USB_DEVICE(ADU_VENDOR_ID, ADU_PRODUCT_ID+20) }, /* ADU120 */ 62 { USB_DEVICE(ADU_VENDOR_ID, ADU_PRODUCT_ID+30) }, /* ADU130 */ ··· 132 if (debug < level) 133 return; 134 135 + printk(KERN_DEBUG "%s: %s - length = %d, data = ", 136 + __FILE__, function, size); 137 for (i = 0; i < size; ++i) 138 printk("%.2x ", data[i]); 139 printk("\n");
+3 -2
drivers/usb/misc/appledisplay.c
··· 57 .bInterfaceProtocol = 0x00 58 59 /* table of devices that work with this driver */ 60 - static struct usb_device_id appledisplay_table [] = { 61 { APPLEDISPLAY_DEVICE(0x9218) }, 62 { APPLEDISPLAY_DEVICE(0x9219) }, 63 { APPLEDISPLAY_DEVICE(0x921c) }, ··· 179 return pdata->msgdata[1]; 180 } 181 182 - static struct backlight_ops appledisplay_bl_data = { 183 .get_brightness = appledisplay_bl_get_brightness, 184 .update_status = appledisplay_bl_update_status, 185 }; ··· 283 &appledisplay_bl_data); 284 if (IS_ERR(pdata->bd)) { 285 dev_err(&iface->dev, "Backlight registration failed\n"); 286 goto error; 287 } 288
··· 57 .bInterfaceProtocol = 0x00 58 59 /* table of devices that work with this driver */ 60 + static const struct usb_device_id appledisplay_table[] = { 61 { APPLEDISPLAY_DEVICE(0x9218) }, 62 { APPLEDISPLAY_DEVICE(0x9219) }, 63 { APPLEDISPLAY_DEVICE(0x921c) }, ··· 179 return pdata->msgdata[1]; 180 } 181 182 + static const struct backlight_ops appledisplay_bl_data = { 183 .get_brightness = appledisplay_bl_get_brightness, 184 .update_status = appledisplay_bl_update_status, 185 }; ··· 283 &appledisplay_bl_data); 284 if (IS_ERR(pdata->bd)) { 285 dev_err(&iface->dev, "Backlight registration failed\n"); 286 + retval = PTR_ERR(pdata->bd); 287 goto error; 288 } 289
-183
drivers/usb/misc/berry_charge.c
··· 1 - /* 2 - * USB BlackBerry charging module 3 - * 4 - * Copyright (C) 2007 Greg Kroah-Hartman <gregkh@suse.de> 5 - * 6 - * This program is free software; you can redistribute it and/or 7 - * modify it under the terms of the GNU General Public License as 8 - * published by the Free Software Foundation, version 2. 9 - * 10 - * Information on how to switch configs was taken by the bcharge.cc file 11 - * created by the barry.sf.net project. 12 - * 13 - * bcharge.cc has the following copyright: 14 - * Copyright (C) 2006, Net Direct Inc. (http://www.netdirect.ca/) 15 - * and is released under the GPLv2. 16 - * 17 - * 18 - */ 19 - 20 - #include <linux/kernel.h> 21 - #include <linux/errno.h> 22 - #include <linux/init.h> 23 - #include <linux/slab.h> 24 - #include <linux/module.h> 25 - #include <linux/usb.h> 26 - 27 - #define RIM_VENDOR 0x0fca 28 - #define BLACKBERRY 0x0001 29 - #define BLACKBERRY_PEARL_DUAL 0x0004 30 - #define BLACKBERRY_PEARL 0x0006 31 - 32 - static int debug; 33 - static int pearl_dual_mode = 1; 34 - 35 - #ifdef dbg 36 - #undef dbg 37 - #endif 38 - #define dbg(dev, format, arg...) \ 39 - if (debug) \ 40 - dev_printk(KERN_DEBUG , dev , format , ## arg) 41 - 42 - static struct usb_device_id id_table [] = { 43 - { USB_DEVICE(RIM_VENDOR, BLACKBERRY) }, 44 - { USB_DEVICE(RIM_VENDOR, BLACKBERRY_PEARL) }, 45 - { USB_DEVICE(RIM_VENDOR, BLACKBERRY_PEARL_DUAL) }, 46 - { }, /* Terminating entry */ 47 - }; 48 - MODULE_DEVICE_TABLE(usb, id_table); 49 - 50 - static int magic_charge(struct usb_device *udev) 51 - { 52 - char *dummy_buffer = kzalloc(2, GFP_KERNEL); 53 - int retval; 54 - 55 - if (!dummy_buffer) 56 - return -ENOMEM; 57 - 58 - /* send two magic commands and then set the configuration. The device 59 - * will then reset itself with the new power usage and should start 60 - * charging. */ 61 - 62 - /* Note, with testing, it only seems that the first message is really 63 - * needed (at least for the 8700c), but to be safe, we emulate what 64 - * other operating systems seem to be sending to their device. We 65 - * really need to get some specs for this device to be sure about what 66 - * is going on here. 67 - */ 68 - dbg(&udev->dev, "Sending first magic command\n"); 69 - retval = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 70 - 0xa5, 0xc0, 0, 1, dummy_buffer, 2, 100); 71 - if (retval != 2) { 72 - dev_err(&udev->dev, "First magic command failed: %d.\n", 73 - retval); 74 - goto exit; 75 - } 76 - 77 - dbg(&udev->dev, "Sending second magic command\n"); 78 - retval = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 79 - 0xa2, 0x40, 0, 1, dummy_buffer, 0, 100); 80 - if (retval != 0) { 81 - dev_err(&udev->dev, "Second magic command failed: %d.\n", 82 - retval); 83 - goto exit; 84 - } 85 - 86 - dbg(&udev->dev, "Calling set_configuration\n"); 87 - retval = usb_driver_set_configuration(udev, 1); 88 - if (retval) 89 - dev_err(&udev->dev, "Set Configuration failed :%d.\n", retval); 90 - 91 - exit: 92 - kfree(dummy_buffer); 93 - return retval; 94 - } 95 - 96 - static int magic_dual_mode(struct usb_device *udev) 97 - { 98 - char *dummy_buffer = kzalloc(2, GFP_KERNEL); 99 - int retval; 100 - 101 - if (!dummy_buffer) 102 - return -ENOMEM; 103 - 104 - /* send magic command so that the Blackberry Pearl device exposes 105 - * two interfaces: both the USB mass-storage one and one which can 106 - * be used for database access. */ 107 - dbg(&udev->dev, "Sending magic pearl command\n"); 108 - retval = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 109 - 0xa9, 0xc0, 1, 1, dummy_buffer, 2, 100); 110 - dbg(&udev->dev, "Magic pearl command returned %d\n", retval); 111 - 112 - dbg(&udev->dev, "Calling set_configuration\n"); 113 - retval = usb_driver_set_configuration(udev, 1); 114 - if (retval) 115 - dev_err(&udev->dev, "Set Configuration failed :%d.\n", retval); 116 - 117 - kfree(dummy_buffer); 118 - return retval; 119 - } 120 - 121 - static int berry_probe(struct usb_interface *intf, 122 - const struct usb_device_id *id) 123 - { 124 - struct usb_device *udev = interface_to_usbdev(intf); 125 - 126 - if (udev->bus_mA < 500) { 127 - dbg(&udev->dev, "Not enough power to charge available\n"); 128 - return -ENODEV; 129 - } 130 - 131 - dbg(&udev->dev, "Power is set to %dmA\n", 132 - udev->actconfig->desc.bMaxPower * 2); 133 - 134 - /* check the power usage so we don't try to enable something that is 135 - * already enabled */ 136 - if ((udev->actconfig->desc.bMaxPower * 2) == 500) { 137 - dbg(&udev->dev, "device is already charging, power is " 138 - "set to %dmA\n", udev->actconfig->desc.bMaxPower * 2); 139 - return -ENODEV; 140 - } 141 - 142 - /* turn the power on */ 143 - magic_charge(udev); 144 - 145 - if ((le16_to_cpu(udev->descriptor.idProduct) == BLACKBERRY_PEARL) && 146 - (pearl_dual_mode)) 147 - magic_dual_mode(udev); 148 - 149 - /* we don't really want to bind to the device, userspace programs can 150 - * handle the syncing just fine, so get outta here. */ 151 - return -ENODEV; 152 - } 153 - 154 - static void berry_disconnect(struct usb_interface *intf) 155 - { 156 - } 157 - 158 - static struct usb_driver berry_driver = { 159 - .name = "berry_charge", 160 - .probe = berry_probe, 161 - .disconnect = berry_disconnect, 162 - .id_table = id_table, 163 - }; 164 - 165 - static int __init berry_init(void) 166 - { 167 - return usb_register(&berry_driver); 168 - } 169 - 170 - static void __exit berry_exit(void) 171 - { 172 - usb_deregister(&berry_driver); 173 - } 174 - 175 - module_init(berry_init); 176 - module_exit(berry_exit); 177 - 178 - MODULE_LICENSE("GPL"); 179 - MODULE_AUTHOR("Greg Kroah-Hartman <gregkh@suse.de>"); 180 - module_param(debug, bool, S_IRUGO | S_IWUSR); 181 - MODULE_PARM_DESC(debug, "Debug enabled or not"); 182 - module_param(pearl_dual_mode, bool, S_IRUGO | S_IWUSR); 183 - MODULE_PARM_DESC(pearl_dual_mode, "Change Blackberry Pearl to run in dual mode");
···
+1 -1
drivers/usb/misc/cypress_cy7c63.c
··· 56 57 58 /* table of devices that work with this driver */ 59 - static struct usb_device_id cypress_table [] = { 60 { USB_DEVICE(CYPRESS_VENDOR_ID, CYPRESS_PRODUCT_ID) }, 61 { } 62 };
··· 56 57 58 /* table of devices that work with this driver */ 59 + static const struct usb_device_id cypress_table[] = { 60 { USB_DEVICE(CYPRESS_VENDOR_ID, CYPRESS_PRODUCT_ID) }, 61 { } 62 };
+1 -1
drivers/usb/misc/cytherm.c
··· 27 #define USB_SKEL_VENDOR_ID 0x04b4 28 #define USB_SKEL_PRODUCT_ID 0x0002 29 30 - static struct usb_device_id id_table [] = { 31 { USB_DEVICE(USB_SKEL_VENDOR_ID, USB_SKEL_PRODUCT_ID) }, 32 { } 33 };
··· 27 #define USB_SKEL_VENDOR_ID 0x04b4 28 #define USB_SKEL_PRODUCT_ID 0x0002 29 30 + static const struct usb_device_id id_table[] = { 31 { USB_DEVICE(USB_SKEL_VENDOR_ID, USB_SKEL_PRODUCT_ID) }, 32 { } 33 };
+1 -1
drivers/usb/misc/emi26.c
··· 245 return err; 246 } 247 248 - static struct usb_device_id id_table [] = { 249 { USB_DEVICE(EMI26_VENDOR_ID, EMI26_PRODUCT_ID) }, 250 { USB_DEVICE(EMI26_VENDOR_ID, EMI26B_PRODUCT_ID) }, 251 { } /* Terminating entry */
··· 245 return err; 246 } 247 248 + static const struct usb_device_id id_table[] = { 249 { USB_DEVICE(EMI26_VENDOR_ID, EMI26_PRODUCT_ID) }, 250 { USB_DEVICE(EMI26_VENDOR_ID, EMI26B_PRODUCT_ID) }, 251 { } /* Terminating entry */
+1 -1
drivers/usb/misc/emi62.c
··· 259 return err; 260 } 261 262 - static __devinitdata struct usb_device_id id_table [] = { 263 { USB_DEVICE(EMI62_VENDOR_ID, EMI62_PRODUCT_ID) }, 264 { } /* Terminating entry */ 265 };
··· 259 return err; 260 } 261 262 + static const struct usb_device_id id_table[] __devinitconst = { 263 { USB_DEVICE(EMI62_VENDOR_ID, EMI62_PRODUCT_ID) }, 264 { } /* Terminating entry */ 265 };
+7 -4
drivers/usb/misc/ftdi-elan.c
··· 86 #define USB_FTDI_ELAN_VENDOR_ID 0x0403 87 #define USB_FTDI_ELAN_PRODUCT_ID 0xd6ea 88 /* table of devices that work with this driver*/ 89 - static struct usb_device_id ftdi_elan_table[] = { 90 {USB_DEVICE(USB_FTDI_ELAN_VENDOR_ID, USB_FTDI_ELAN_PRODUCT_ID)}, 91 { /* Terminating entry */ } 92 }; ··· 623 */ 624 static int ftdi_elan_open(struct inode *inode, struct file *file) 625 { 626 - int subminor = iminor(inode); 627 - struct usb_interface *interface = usb_find_interface(&ftdi_elan_driver, 628 - subminor); 629 if (!interface) { 630 printk(KERN_ERR "can't find device for minor %d\n", subminor); 631 return -ENODEV;
··· 86 #define USB_FTDI_ELAN_VENDOR_ID 0x0403 87 #define USB_FTDI_ELAN_PRODUCT_ID 0xd6ea 88 /* table of devices that work with this driver*/ 89 + static const struct usb_device_id ftdi_elan_table[] = { 90 {USB_DEVICE(USB_FTDI_ELAN_VENDOR_ID, USB_FTDI_ELAN_PRODUCT_ID)}, 91 { /* Terminating entry */ } 92 }; ··· 623 */ 624 static int ftdi_elan_open(struct inode *inode, struct file *file) 625 { 626 + int subminor; 627 + struct usb_interface *interface; 628 + 629 + subminor = iminor(inode); 630 + interface = usb_find_interface(&ftdi_elan_driver, subminor); 631 + 632 if (!interface) { 633 printk(KERN_ERR "can't find device for minor %d\n", subminor); 634 return -ENODEV;
+1 -1
drivers/usb/misc/idmouse.c
··· 48 #define ID_CHERRY 0x0010 49 50 /* device ID table */ 51 - static struct usb_device_id idmouse_table[] = { 52 {USB_DEVICE(ID_SIEMENS, ID_IDMOUSE)}, /* Siemens ID Mouse (Professional) */ 53 {USB_DEVICE(ID_SIEMENS, ID_CHERRY )}, /* Cherry FingerTIP ID Board */ 54 {} /* terminating null entry */
··· 48 #define ID_CHERRY 0x0010 49 50 /* device ID table */ 51 + static const struct usb_device_id idmouse_table[] = { 52 {USB_DEVICE(ID_SIEMENS, ID_IDMOUSE)}, /* Siemens ID Mouse (Professional) */ 53 {USB_DEVICE(ID_SIEMENS, ID_CHERRY )}, /* Cherry FingerTIP ID Board */ 54 {} /* terminating null entry */
+5 -1
drivers/usb/misc/iowarrior.c
··· 139 /* driver registration */ 140 /*---------------------*/ 141 /* table of devices that work with this driver */ 142 - static struct usb_device_id iowarrior_ids[] = { 143 {USB_DEVICE(USB_VENDOR_ID_CODEMERCS, USB_DEVICE_ID_CODEMERCS_IOW40)}, 144 {USB_DEVICE(USB_VENDOR_ID_CODEMERCS, USB_DEVICE_ID_CODEMERCS_IOW24)}, 145 {USB_DEVICE(USB_VENDOR_ID_CODEMERCS, USB_DEVICE_ID_CODEMERCS_IOWPV1)}, ··· 602 603 dbg("%s", __func__); 604 605 subminor = iminor(inode); 606 607 interface = usb_find_interface(&iowarrior_driver, subminor); 608 if (!interface) { 609 err("%s - error, can't find device for minor %d", __func__, 610 subminor); 611 return -ENODEV; ··· 617 dev = usb_get_intfdata(interface); 618 if (!dev) { 619 mutex_unlock(&iowarrior_open_disc_lock); 620 return -ENODEV; 621 } 622 ··· 644 645 out: 646 mutex_unlock(&dev->mutex); 647 return retval; 648 } 649
··· 139 /* driver registration */ 140 /*---------------------*/ 141 /* table of devices that work with this driver */ 142 + static const struct usb_device_id iowarrior_ids[] = { 143 {USB_DEVICE(USB_VENDOR_ID_CODEMERCS, USB_DEVICE_ID_CODEMERCS_IOW40)}, 144 {USB_DEVICE(USB_VENDOR_ID_CODEMERCS, USB_DEVICE_ID_CODEMERCS_IOW24)}, 145 {USB_DEVICE(USB_VENDOR_ID_CODEMERCS, USB_DEVICE_ID_CODEMERCS_IOWPV1)}, ··· 602 603 dbg("%s", __func__); 604 605 + lock_kernel(); 606 subminor = iminor(inode); 607 608 interface = usb_find_interface(&iowarrior_driver, subminor); 609 if (!interface) { 610 + unlock_kernel(); 611 err("%s - error, can't find device for minor %d", __func__, 612 subminor); 613 return -ENODEV; ··· 615 dev = usb_get_intfdata(interface); 616 if (!dev) { 617 mutex_unlock(&iowarrior_open_disc_lock); 618 + unlock_kernel(); 619 return -ENODEV; 620 } 621 ··· 641 642 out: 643 mutex_unlock(&dev->mutex); 644 + unlock_kernel(); 645 return retval; 646 } 647
+3 -1
drivers/usb/misc/isight_firmware.c
··· 26 #include <linux/errno.h> 27 #include <linux/module.h> 28 29 - static struct usb_device_id id_table[] = { 30 {USB_DEVICE(0x05ac, 0x8300)}, 31 {}, 32 }; ··· 111 release_firmware(firmware); 112 return ret; 113 } 114 115 static void isight_firmware_disconnect(struct usb_interface *intf) 116 {
··· 26 #include <linux/errno.h> 27 #include <linux/module.h> 28 29 + static const struct usb_device_id id_table[] = { 30 {USB_DEVICE(0x05ac, 0x8300)}, 31 {}, 32 }; ··· 111 release_firmware(firmware); 112 return ret; 113 } 114 + 115 + MODULE_FIRMWARE("isight.fw"); 116 117 static void isight_firmware_disconnect(struct usb_interface *intf) 118 {
+2 -2
drivers/usb/misc/ldusb.c
··· 69 #endif 70 71 /* table of devices that work with this driver */ 72 - static struct usb_device_id ld_usb_table [] = { 73 { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CASSY) }, 74 { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POCKETCASSY) }, 75 { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOBILECASSY) }, ··· 798 /* register this driver with the USB subsystem */ 799 retval = usb_register(&ld_usb_driver); 800 if (retval) 801 - err("usb_register failed for the "__FILE__" driver. Error number %d\n", retval); 802 803 return retval; 804 }
··· 69 #endif 70 71 /* table of devices that work with this driver */ 72 + static const struct usb_device_id ld_usb_table[] = { 73 { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CASSY) }, 74 { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POCKETCASSY) }, 75 { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOBILECASSY) }, ··· 798 /* register this driver with the USB subsystem */ 799 retval = usb_register(&ld_usb_driver); 800 if (retval) 801 + err("usb_register failed for the %s driver. Error number %d\n", __FILE__, retval); 802 803 return retval; 804 }
+8 -5
drivers/usb/misc/legousbtower.c
··· 95 96 /* Use our own dbg macro */ 97 #undef dbg 98 - #define dbg(lvl, format, arg...) do { if (debug >= lvl) printk(KERN_DEBUG __FILE__ ": " format "\n", ## arg); } while (0) 99 - 100 101 /* Version Information */ 102 #define DRIVER_VERSION "v0.96" ··· 195 196 197 /* table of devices that work with this driver */ 198 - static struct usb_device_id tower_table [] = { 199 { USB_DEVICE(LEGO_USB_TOWER_VENDOR_ID, LEGO_USB_TOWER_PRODUCT_ID) }, 200 { } /* Terminating entry */ 201 }; ··· 305 if (debug < level) 306 return; 307 308 - printk (KERN_DEBUG __FILE__": %s - length = %d, data = ", function, size); 309 for (i = 0; i < size; ++i) { 310 printk ("%.2x ", data[i]); 311 } ··· 1058 /* register this driver with the USB subsystem */ 1059 result = usb_register(&tower_driver); 1060 if (result < 0) { 1061 - err("usb_register failed for the "__FILE__" driver. Error number %d", result); 1062 retval = -1; 1063 goto exit; 1064 }
··· 95 96 /* Use our own dbg macro */ 97 #undef dbg 98 + #define dbg(lvl, format, arg...) \ 99 + do { \ 100 + if (debug >= lvl) \ 101 + printk(KERN_DEBUG "%s: " format "\n", __FILE__, ##arg); \ 102 + } while (0) 103 104 /* Version Information */ 105 #define DRIVER_VERSION "v0.96" ··· 192 193 194 /* table of devices that work with this driver */ 195 + static const struct usb_device_id tower_table[] = { 196 { USB_DEVICE(LEGO_USB_TOWER_VENDOR_ID, LEGO_USB_TOWER_PRODUCT_ID) }, 197 { } /* Terminating entry */ 198 }; ··· 302 if (debug < level) 303 return; 304 305 + printk (KERN_DEBUG "%s: %s - length = %d, data = ", __FILE__, function, size); 306 for (i = 0; i < size; ++i) { 307 printk ("%.2x ", data[i]); 308 } ··· 1055 /* register this driver with the USB subsystem */ 1056 result = usb_register(&tower_driver); 1057 if (result < 0) { 1058 + err("usb_register failed for the %s driver. Error number %d", __FILE__, result); 1059 retval = -1; 1060 goto exit; 1061 }
+8 -3
drivers/usb/misc/rio500.c
··· 78 { 79 struct rio_usb_data *rio = &rio_instance; 80 81 mutex_lock(&(rio->lock)); 82 83 if (rio->isopen || !rio->present) { 84 mutex_unlock(&(rio->lock)); 85 return -EBUSY; 86 } 87 rio->isopen = 1; ··· 94 mutex_unlock(&(rio->lock)); 95 96 dev_info(&rio->rio_dev->dev, "Rio opened.\n"); 97 98 return 0; 99 } ··· 119 int retries; 120 int retval=0; 121 122 - lock_kernel(); 123 mutex_lock(&(rio->lock)); 124 /* Sanity check to make sure rio is connected, powered, etc */ 125 if (rio->present == 0 || rio->rio_dev == NULL) { ··· 257 258 err_out: 259 mutex_unlock(&(rio->lock)); 260 - unlock_kernel(); 261 return retval; 262 } 263 ··· 491 struct rio_usb_data *rio = usb_get_intfdata (intf); 492 493 usb_set_intfdata (intf, NULL); 494 if (rio) { 495 usb_deregister_dev(intf, &usb_rio_class); 496 ··· 501 /* better let it finish - the release will do whats needed */ 502 rio->rio_dev = NULL; 503 mutex_unlock(&(rio->lock)); 504 return; 505 } 506 kfree(rio->ibuf); ··· 512 rio->present = 0; 513 mutex_unlock(&(rio->lock)); 514 } 515 } 516 517 - static struct usb_device_id rio_table [] = { 518 { USB_DEVICE(0x0841, 1) }, /* Rio 500 */ 519 { } /* Terminating entry */ 520 };
··· 78 { 79 struct rio_usb_data *rio = &rio_instance; 80 81 + /* against disconnect() */ 82 + lock_kernel(); 83 mutex_lock(&(rio->lock)); 84 85 if (rio->isopen || !rio->present) { 86 mutex_unlock(&(rio->lock)); 87 + unlock_kernel(); 88 return -EBUSY; 89 } 90 rio->isopen = 1; ··· 91 mutex_unlock(&(rio->lock)); 92 93 dev_info(&rio->rio_dev->dev, "Rio opened.\n"); 94 + unlock_kernel(); 95 96 return 0; 97 } ··· 115 int retries; 116 int retval=0; 117 118 mutex_lock(&(rio->lock)); 119 /* Sanity check to make sure rio is connected, powered, etc */ 120 if (rio->present == 0 || rio->rio_dev == NULL) { ··· 254 255 err_out: 256 mutex_unlock(&(rio->lock)); 257 return retval; 258 } 259 ··· 489 struct rio_usb_data *rio = usb_get_intfdata (intf); 490 491 usb_set_intfdata (intf, NULL); 492 + lock_kernel(); 493 if (rio) { 494 usb_deregister_dev(intf, &usb_rio_class); 495 ··· 498 /* better let it finish - the release will do whats needed */ 499 rio->rio_dev = NULL; 500 mutex_unlock(&(rio->lock)); 501 + unlock_kernel(); 502 return; 503 } 504 kfree(rio->ibuf); ··· 508 rio->present = 0; 509 mutex_unlock(&(rio->lock)); 510 } 511 + unlock_kernel(); 512 } 513 514 + static const struct usb_device_id rio_table[] = { 515 { USB_DEVICE(0x0841, 1) }, /* Rio 500 */ 516 { } /* Terminating entry */ 517 };
+15 -5
drivers/usb/misc/sisusbvga/sisusb.c
··· 250 sisusb->urbstatus[index] |= SU_URB_BUSY; 251 252 /* Submit URB */ 253 - retval = usb_submit_urb(urb, GFP_ATOMIC); 254 255 /* If OK, and if timeout > 0, wait for completion */ 256 if ((retval == 0) && timeout) { ··· 306 urb->actual_length = 0; 307 308 sisusb->completein = 0; 309 - retval = usb_submit_urb(urb, GFP_ATOMIC); 310 if (retval == 0) { 311 wait_event_timeout(sisusb->wait_q, sisusb->completein, timeout); 312 if (!sisusb->completein) { ··· 2416 struct usb_interface *interface; 2417 int subminor = iminor(inode); 2418 2419 - if (!(interface = usb_find_interface(&sisusb_driver, subminor))) 2420 return -ENODEV; 2421 2422 - if (!(sisusb = usb_get_intfdata(interface))) 2423 return -ENODEV; 2424 2425 mutex_lock(&sisusb->lock); 2426 2427 if (!sisusb->present || !sisusb->ready) { 2428 mutex_unlock(&sisusb->lock); 2429 return -ENODEV; 2430 } 2431 2432 if (sisusb->isopen) { 2433 mutex_unlock(&sisusb->lock); 2434 return -EBUSY; 2435 } 2436 ··· 2446 if (sisusb_init_gfxdevice(sisusb, 0)) { 2447 mutex_unlock(&sisusb->lock); 2448 dev_err(&sisusb->sisusb_dev->dev, "Failed to initialize device\n"); 2449 return -EIO; 2450 } 2451 } else { 2452 mutex_unlock(&sisusb->lock); 2453 dev_err(&sisusb->sisusb_dev->dev, "Device not attached to USB 2.0 hub\n"); 2454 return -EIO; 2455 } 2456 } ··· 2465 file->private_data = sisusb; 2466 2467 mutex_unlock(&sisusb->lock); 2468 2469 return 0; 2470 } ··· 3248 kref_put(&sisusb->kref, sisusb_delete); 3249 } 3250 3251 - static struct usb_device_id sisusb_table [] = { 3252 { USB_DEVICE(0x0711, 0x0550) }, 3253 { USB_DEVICE(0x0711, 0x0900) }, 3254 { USB_DEVICE(0x0711, 0x0901) },
··· 250 sisusb->urbstatus[index] |= SU_URB_BUSY; 251 252 /* Submit URB */ 253 + retval = usb_submit_urb(urb, GFP_KERNEL); 254 255 /* If OK, and if timeout > 0, wait for completion */ 256 if ((retval == 0) && timeout) { ··· 306 urb->actual_length = 0; 307 308 sisusb->completein = 0; 309 + retval = usb_submit_urb(urb, GFP_KERNEL); 310 if (retval == 0) { 311 wait_event_timeout(sisusb->wait_q, sisusb->completein, timeout); 312 if (!sisusb->completein) { ··· 2416 struct usb_interface *interface; 2417 int subminor = iminor(inode); 2418 2419 + lock_kernel(); 2420 + if (!(interface = usb_find_interface(&sisusb_driver, subminor))) { 2421 + unlock_kernel(); 2422 return -ENODEV; 2423 + } 2424 2425 + if (!(sisusb = usb_get_intfdata(interface))) { 2426 + unlock_kernel(); 2427 return -ENODEV; 2428 + } 2429 2430 mutex_lock(&sisusb->lock); 2431 2432 if (!sisusb->present || !sisusb->ready) { 2433 mutex_unlock(&sisusb->lock); 2434 + unlock_kernel(); 2435 return -ENODEV; 2436 } 2437 2438 if (sisusb->isopen) { 2439 mutex_unlock(&sisusb->lock); 2440 + unlock_kernel(); 2441 return -EBUSY; 2442 } 2443 ··· 2439 if (sisusb_init_gfxdevice(sisusb, 0)) { 2440 mutex_unlock(&sisusb->lock); 2441 dev_err(&sisusb->sisusb_dev->dev, "Failed to initialize device\n"); 2442 + unlock_kernel(); 2443 return -EIO; 2444 } 2445 } else { 2446 mutex_unlock(&sisusb->lock); 2447 dev_err(&sisusb->sisusb_dev->dev, "Device not attached to USB 2.0 hub\n"); 2448 + unlock_kernel(); 2449 return -EIO; 2450 } 2451 } ··· 2456 file->private_data = sisusb; 2457 2458 mutex_unlock(&sisusb->lock); 2459 + unlock_kernel(); 2460 2461 return 0; 2462 } ··· 3238 kref_put(&sisusb->kref, sisusb_delete); 3239 } 3240 3241 + static const struct usb_device_id sisusb_table[] = { 3242 { USB_DEVICE(0x0711, 0x0550) }, 3243 { USB_DEVICE(0x0711, 0x0900) }, 3244 { USB_DEVICE(0x0711, 0x0901) },
+1 -1
drivers/usb/misc/trancevibrator.c
··· 33 #define TRANCEVIBRATOR_VENDOR_ID 0x0b49 /* ASCII Corporation */ 34 #define TRANCEVIBRATOR_PRODUCT_ID 0x064f /* Trance Vibrator */ 35 36 - static struct usb_device_id id_table [] = { 37 { USB_DEVICE(TRANCEVIBRATOR_VENDOR_ID, TRANCEVIBRATOR_PRODUCT_ID) }, 38 { }, 39 };
··· 33 #define TRANCEVIBRATOR_VENDOR_ID 0x0b49 /* ASCII Corporation */ 34 #define TRANCEVIBRATOR_PRODUCT_ID 0x064f /* Trance Vibrator */ 35 36 + static const struct usb_device_id id_table[] = { 37 { USB_DEVICE(TRANCEVIBRATOR_VENDOR_ID, TRANCEVIBRATOR_PRODUCT_ID) }, 38 { }, 39 };
+6 -1
drivers/usb/misc/usblcd.c
··· 30 #define IOCTL_GET_DRV_VERSION 2 31 32 33 - static struct usb_device_id id_table [] = { 34 { .idVendor = 0x10D2, .match_flags = USB_DEVICE_ID_MATCH_VENDOR, }, 35 { }, 36 }; ··· 74 struct usb_interface *interface; 75 int subminor, r; 76 77 subminor = iminor(inode); 78 79 interface = usb_find_interface(&lcd_driver, subminor); 80 if (!interface) { 81 err ("USBLCD: %s - error, can't find device for minor %d", 82 __func__, subminor); 83 return -ENODEV; ··· 89 dev = usb_get_intfdata(interface); 90 if (!dev) { 91 mutex_unlock(&open_disc_mutex); 92 return -ENODEV; 93 } 94 ··· 101 r = usb_autopm_get_interface(interface); 102 if (r < 0) { 103 kref_put(&dev->kref, lcd_delete); 104 return r; 105 } 106 107 /* save our object in the file's private structure */ 108 file->private_data = dev; 109 110 return 0; 111 }
··· 30 #define IOCTL_GET_DRV_VERSION 2 31 32 33 + static const struct usb_device_id id_table[] = { 34 { .idVendor = 0x10D2, .match_flags = USB_DEVICE_ID_MATCH_VENDOR, }, 35 { }, 36 }; ··· 74 struct usb_interface *interface; 75 int subminor, r; 76 77 + lock_kernel(); 78 subminor = iminor(inode); 79 80 interface = usb_find_interface(&lcd_driver, subminor); 81 if (!interface) { 82 + unlock_kernel(); 83 err ("USBLCD: %s - error, can't find device for minor %d", 84 __func__, subminor); 85 return -ENODEV; ··· 87 dev = usb_get_intfdata(interface); 88 if (!dev) { 89 mutex_unlock(&open_disc_mutex); 90 + unlock_kernel(); 91 return -ENODEV; 92 } 93 ··· 98 r = usb_autopm_get_interface(interface); 99 if (r < 0) { 100 kref_put(&dev->kref, lcd_delete); 101 + unlock_kernel(); 102 return r; 103 } 104 105 /* save our object in the file's private structure */ 106 file->private_data = dev; 107 + unlock_kernel(); 108 109 return 0; 110 }
+1 -1
drivers/usb/misc/usbled.c
··· 24 #define PRODUCT_ID 0x1223 25 26 /* table of devices that work with this driver */ 27 - static struct usb_device_id id_table [] = { 28 { USB_DEVICE(VENDOR_ID, PRODUCT_ID) }, 29 { }, 30 };
··· 24 #define PRODUCT_ID 0x1223 25 26 /* table of devices that work with this driver */ 27 + static const struct usb_device_id id_table[] = { 28 { USB_DEVICE(VENDOR_ID, PRODUCT_ID) }, 29 { }, 30 };
+1 -1
drivers/usb/misc/usbsevseg.c
··· 27 #define MAXLEN 6 28 29 /* table of devices that work with this driver */ 30 - static struct usb_device_id id_table[] = { 31 { USB_DEVICE(VENDOR_ID, PRODUCT_ID) }, 32 { }, 33 };
··· 27 #define MAXLEN 6 28 29 /* table of devices that work with this driver */ 30 + static const struct usb_device_id id_table[] = { 31 { USB_DEVICE(VENDOR_ID, PRODUCT_ID) }, 32 { }, 33 };
+1 -5
drivers/usb/misc/usbtest.c
··· 1580 return -ERESTARTSYS; 1581 1582 /* FIXME: What if a system sleep starts while a test is running? */ 1583 - if (!intf->is_active) { 1584 - mutex_unlock(&dev->lock); 1585 - return -EHOSTUNREACH; 1586 - } 1587 1588 /* some devices, like ez-usb default devices, need a non-default 1589 * altsetting to have any active endpoints. some tests change ··· 2097 #endif 2098 2099 2100 - static struct usb_device_id id_table [] = { 2101 2102 /*-------------------------------------------------------------*/ 2103
··· 1580 return -ERESTARTSYS; 1581 1582 /* FIXME: What if a system sleep starts while a test is running? */ 1583 1584 /* some devices, like ez-usb default devices, need a non-default 1585 * altsetting to have any active endpoints. some tests change ··· 2101 #endif 2102 2103 2104 + static const struct usb_device_id id_table[] = { 2105 2106 /*-------------------------------------------------------------*/ 2107
+1 -1
drivers/usb/misc/uss720.c
··· 770 } 771 772 /* table of cables that work through this driver */ 773 - static struct usb_device_id uss720_table [] = { 774 { USB_DEVICE(0x047e, 0x1001) }, 775 { USB_DEVICE(0x0557, 0x2001) }, 776 { USB_DEVICE(0x0729, 0x1284) },
··· 770 } 771 772 /* table of cables that work through this driver */ 773 + static const struct usb_device_id uss720_table[] = { 774 { USB_DEVICE(0x047e, 0x1001) }, 775 { USB_DEVICE(0x0557, 0x2001) }, 776 { USB_DEVICE(0x0729, 0x1284) },
-783
drivers/usb/misc/vstusb.c
··· 1 - /***************************************************************************** 2 - * File: drivers/usb/misc/vstusb.c 3 - * 4 - * Purpose: Support for the bulk USB Vernier Spectrophotometers 5 - * 6 - * Author: Johnnie Peters 7 - * Axian Consulting 8 - * Beaverton, OR, USA 97005 9 - * 10 - * Modified by: EQware Engineering, Inc. 11 - * Oregon City, OR, USA 97045 12 - * 13 - * Copyright: 2007, 2008 14 - * Vernier Software & Technology 15 - * Beaverton, OR, USA 97005 16 - * 17 - * Web: www.vernier.com 18 - * 19 - * This program is free software; you can redistribute it and/or modify 20 - * it under the terms of the GNU General Public License version 2 as 21 - * published by the Free Software Foundation. 22 - * 23 - *****************************************************************************/ 24 - #include <linux/kernel.h> 25 - #include <linux/errno.h> 26 - #include <linux/init.h> 27 - #include <linux/slab.h> 28 - #include <linux/module.h> 29 - #include <linux/mutex.h> 30 - #include <linux/uaccess.h> 31 - #include <linux/usb.h> 32 - 33 - #include <linux/usb/vstusb.h> 34 - 35 - #define DRIVER_VERSION "VST USB Driver Version 1.5" 36 - #define DRIVER_DESC "Vernier Software Technology Bulk USB Driver" 37 - 38 - #ifdef CONFIG_USB_DYNAMIC_MINORS 39 - #define VSTUSB_MINOR_BASE 0 40 - #else 41 - #define VSTUSB_MINOR_BASE 199 42 - #endif 43 - 44 - #define USB_VENDOR_OCEANOPTICS 0x2457 45 - #define USB_VENDOR_VERNIER 0x08F7 /* Vernier Software & Technology */ 46 - 47 - #define USB_PRODUCT_USB2000 0x1002 48 - #define USB_PRODUCT_ADC1000_FW 0x1003 /* firmware download (renumerates) */ 49 - #define USB_PRODUCT_ADC1000 0x1004 50 - #define USB_PRODUCT_HR2000_FW 0x1009 /* firmware download (renumerates) */ 51 - #define USB_PRODUCT_HR2000 0x100A 52 - #define USB_PRODUCT_HR4000_FW 0x1011 /* firmware download (renumerates) */ 53 - #define USB_PRODUCT_HR4000 0x1012 54 - #define USB_PRODUCT_USB650 0x1014 /* "Red Tide" */ 55 - #define USB_PRODUCT_QE65000 0x1018 56 - #define USB_PRODUCT_USB4000 0x1022 57 - #define USB_PRODUCT_USB325 0x1024 /* "Vernier Spectrometer" */ 58 - 59 - #define USB_PRODUCT_LABPRO 0x0001 60 - #define USB_PRODUCT_LABQUEST 0x0005 61 - 62 - #define VST_MAXBUFFER (64*1024) 63 - 64 - static struct usb_device_id id_table[] = { 65 - { USB_DEVICE(USB_VENDOR_OCEANOPTICS, USB_PRODUCT_USB2000)}, 66 - { USB_DEVICE(USB_VENDOR_OCEANOPTICS, USB_PRODUCT_HR4000)}, 67 - { USB_DEVICE(USB_VENDOR_OCEANOPTICS, USB_PRODUCT_USB650)}, 68 - { USB_DEVICE(USB_VENDOR_OCEANOPTICS, USB_PRODUCT_USB4000)}, 69 - { USB_DEVICE(USB_VENDOR_OCEANOPTICS, USB_PRODUCT_USB325)}, 70 - { USB_DEVICE(USB_VENDOR_VERNIER, USB_PRODUCT_LABQUEST)}, 71 - { USB_DEVICE(USB_VENDOR_VERNIER, USB_PRODUCT_LABPRO)}, 72 - {}, 73 - }; 74 - 75 - MODULE_DEVICE_TABLE(usb, id_table); 76 - 77 - struct vstusb_device { 78 - struct kref kref; 79 - struct mutex lock; 80 - struct usb_device *usb_dev; 81 - char present; 82 - char isopen; 83 - struct usb_anchor submitted; 84 - int rd_pipe; 85 - int rd_timeout_ms; 86 - int wr_pipe; 87 - int wr_timeout_ms; 88 - }; 89 - #define to_vst_dev(d) container_of(d, struct vstusb_device, kref) 90 - 91 - static struct usb_driver vstusb_driver; 92 - 93 - static void vstusb_delete(struct kref *kref) 94 - { 95 - struct vstusb_device *vstdev = to_vst_dev(kref); 96 - 97 - usb_put_dev(vstdev->usb_dev); 98 - kfree(vstdev); 99 - } 100 - 101 - static int vstusb_open(struct inode *inode, struct file *file) 102 - { 103 - struct vstusb_device *vstdev; 104 - struct usb_interface *interface; 105 - 106 - interface = usb_find_interface(&vstusb_driver, iminor(inode)); 107 - 108 - if (!interface) { 109 - printk(KERN_ERR KBUILD_MODNAME 110 - ": %s - error, can't find device for minor %d\n", 111 - __func__, iminor(inode)); 112 - return -ENODEV; 113 - } 114 - 115 - vstdev = usb_get_intfdata(interface); 116 - 117 - if (!vstdev) 118 - return -ENODEV; 119 - 120 - /* lock this device */ 121 - mutex_lock(&vstdev->lock); 122 - 123 - /* can only open one time */ 124 - if ((!vstdev->present) || (vstdev->isopen)) { 125 - mutex_unlock(&vstdev->lock); 126 - return -EBUSY; 127 - } 128 - 129 - /* increment our usage count */ 130 - kref_get(&vstdev->kref); 131 - 132 - vstdev->isopen = 1; 133 - 134 - /* save device in the file's private structure */ 135 - file->private_data = vstdev; 136 - 137 - dev_dbg(&vstdev->usb_dev->dev, "%s: opened\n", __func__); 138 - 139 - mutex_unlock(&vstdev->lock); 140 - 141 - return 0; 142 - } 143 - 144 - static int vstusb_release(struct inode *inode, struct file *file) 145 - { 146 - struct vstusb_device *vstdev; 147 - 148 - vstdev = file->private_data; 149 - 150 - if (vstdev == NULL) 151 - return -ENODEV; 152 - 153 - mutex_lock(&vstdev->lock); 154 - 155 - vstdev->isopen = 0; 156 - 157 - dev_dbg(&vstdev->usb_dev->dev, "%s: released\n", __func__); 158 - 159 - mutex_unlock(&vstdev->lock); 160 - 161 - kref_put(&vstdev->kref, vstusb_delete); 162 - 163 - return 0; 164 - } 165 - 166 - static void usb_api_blocking_completion(struct urb *urb) 167 - { 168 - struct completion *completeit = urb->context; 169 - 170 - complete(completeit); 171 - } 172 - 173 - static int vstusb_fill_and_send_urb(struct urb *urb, 174 - struct usb_device *usb_dev, 175 - unsigned int pipe, void *data, 176 - unsigned int len, struct completion *done) 177 - { 178 - struct usb_host_endpoint *ep; 179 - struct usb_host_endpoint **hostep; 180 - unsigned int pipend; 181 - 182 - int status; 183 - 184 - hostep = usb_pipein(pipe) ? usb_dev->ep_in : usb_dev->ep_out; 185 - pipend = usb_pipeendpoint(pipe); 186 - ep = hostep[pipend]; 187 - 188 - if (!ep || (len == 0)) 189 - return -EINVAL; 190 - 191 - if ((ep->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) 192 - == USB_ENDPOINT_XFER_INT) { 193 - pipe = (pipe & ~(3 << 30)) | (PIPE_INTERRUPT << 30); 194 - usb_fill_int_urb(urb, usb_dev, pipe, data, len, 195 - (usb_complete_t)usb_api_blocking_completion, 196 - NULL, ep->desc.bInterval); 197 - } else 198 - usb_fill_bulk_urb(urb, usb_dev, pipe, data, len, 199 - (usb_complete_t)usb_api_blocking_completion, 200 - NULL); 201 - 202 - init_completion(done); 203 - urb->context = done; 204 - urb->actual_length = 0; 205 - status = usb_submit_urb(urb, GFP_KERNEL); 206 - 207 - return status; 208 - } 209 - 210 - static int vstusb_complete_urb(struct urb *urb, struct completion *done, 211 - int timeout, int *actual_length) 212 - { 213 - unsigned long expire; 214 - int status; 215 - 216 - expire = timeout ? msecs_to_jiffies(timeout) : MAX_SCHEDULE_TIMEOUT; 217 - if (!wait_for_completion_interruptible_timeout(done, expire)) { 218 - usb_kill_urb(urb); 219 - status = urb->status == -ENOENT ? -ETIMEDOUT : urb->status; 220 - 221 - dev_dbg(&urb->dev->dev, 222 - "%s timed out on ep%d%s len=%d/%d, urb status = %d\n", 223 - current->comm, 224 - usb_pipeendpoint(urb->pipe), 225 - usb_pipein(urb->pipe) ? "in" : "out", 226 - urb->actual_length, 227 - urb->transfer_buffer_length, 228 - urb->status); 229 - 230 - } else { 231 - if (signal_pending(current)) { 232 - /* if really an error */ 233 - if (urb->status && !((urb->status == -ENOENT) || 234 - (urb->status == -ECONNRESET) || 235 - (urb->status == -ESHUTDOWN))) { 236 - status = -EINTR; 237 - usb_kill_urb(urb); 238 - } else { 239 - status = 0; 240 - } 241 - 242 - dev_dbg(&urb->dev->dev, 243 - "%s: signal pending on ep%d%s len=%d/%d," 244 - "urb status = %d\n", 245 - current->comm, 246 - usb_pipeendpoint(urb->pipe), 247 - usb_pipein(urb->pipe) ? "in" : "out", 248 - urb->actual_length, 249 - urb->transfer_buffer_length, 250 - urb->status); 251 - 252 - } else { 253 - status = urb->status; 254 - } 255 - } 256 - 257 - if (actual_length) 258 - *actual_length = urb->actual_length; 259 - 260 - return status; 261 - } 262 - 263 - static ssize_t vstusb_read(struct file *file, char __user *buffer, 264 - size_t count, loff_t *ppos) 265 - { 266 - struct vstusb_device *vstdev; 267 - int cnt = -1; 268 - void *buf; 269 - int retval = 0; 270 - 271 - struct urb *urb; 272 - struct usb_device *dev; 273 - unsigned int pipe; 274 - int timeout; 275 - 276 - DECLARE_COMPLETION_ONSTACK(done); 277 - 278 - vstdev = file->private_data; 279 - 280 - if (vstdev == NULL) 281 - return -ENODEV; 282 - 283 - /* verify that we actually want to read some data */ 284 - if ((count == 0) || (count > VST_MAXBUFFER)) 285 - return -EINVAL; 286 - 287 - /* lock this object */ 288 - if (mutex_lock_interruptible(&vstdev->lock)) 289 - return -ERESTARTSYS; 290 - 291 - /* anyone home */ 292 - if (!vstdev->present) { 293 - mutex_unlock(&vstdev->lock); 294 - printk(KERN_ERR KBUILD_MODNAME 295 - ": %s: device not present\n", __func__); 296 - return -ENODEV; 297 - } 298 - 299 - /* pull out the necessary data */ 300 - dev = vstdev->usb_dev; 301 - pipe = usb_rcvbulkpipe(dev, vstdev->rd_pipe); 302 - timeout = vstdev->rd_timeout_ms; 303 - 304 - buf = kmalloc(count, GFP_KERNEL); 305 - if (buf == NULL) { 306 - mutex_unlock(&vstdev->lock); 307 - return -ENOMEM; 308 - } 309 - 310 - urb = usb_alloc_urb(0, GFP_KERNEL); 311 - if (!urb) { 312 - kfree(buf); 313 - mutex_unlock(&vstdev->lock); 314 - return -ENOMEM; 315 - } 316 - 317 - usb_anchor_urb(urb, &vstdev->submitted); 318 - retval = vstusb_fill_and_send_urb(urb, dev, pipe, buf, count, &done); 319 - mutex_unlock(&vstdev->lock); 320 - if (retval) { 321 - usb_unanchor_urb(urb); 322 - dev_err(&dev->dev, "%s: error %d filling and sending urb %d\n", 323 - __func__, retval, pipe); 324 - goto exit; 325 - } 326 - 327 - retval = vstusb_complete_urb(urb, &done, timeout, &cnt); 328 - if (retval) { 329 - dev_err(&dev->dev, "%s: error %d completing urb %d\n", 330 - __func__, retval, pipe); 331 - goto exit; 332 - } 333 - 334 - if (copy_to_user(buffer, buf, cnt)) { 335 - dev_err(&dev->dev, "%s: can't copy_to_user\n", __func__); 336 - retval = -EFAULT; 337 - } else { 338 - retval = cnt; 339 - dev_dbg(&dev->dev, "%s: read %d bytes from pipe %d\n", 340 - __func__, cnt, pipe); 341 - } 342 - 343 - exit: 344 - usb_free_urb(urb); 345 - kfree(buf); 346 - return retval; 347 - } 348 - 349 - static ssize_t vstusb_write(struct file *file, const char __user *buffer, 350 - size_t count, loff_t *ppos) 351 - { 352 - struct vstusb_device *vstdev; 353 - int cnt = -1; 354 - void *buf; 355 - int retval = 0; 356 - 357 - struct urb *urb; 358 - struct usb_device *dev; 359 - unsigned int pipe; 360 - int timeout; 361 - 362 - DECLARE_COMPLETION_ONSTACK(done); 363 - 364 - vstdev = file->private_data; 365 - 366 - if (vstdev == NULL) 367 - return -ENODEV; 368 - 369 - /* verify that we actually have some data to write */ 370 - if ((count == 0) || (count > VST_MAXBUFFER)) 371 - return retval; 372 - 373 - /* lock this object */ 374 - if (mutex_lock_interruptible(&vstdev->lock)) 375 - return -ERESTARTSYS; 376 - 377 - /* anyone home */ 378 - if (!vstdev->present) { 379 - mutex_unlock(&vstdev->lock); 380 - printk(KERN_ERR KBUILD_MODNAME 381 - ": %s: device not present\n", __func__); 382 - return -ENODEV; 383 - } 384 - 385 - /* pull out the necessary data */ 386 - dev = vstdev->usb_dev; 387 - pipe = usb_sndbulkpipe(dev, vstdev->wr_pipe); 388 - timeout = vstdev->wr_timeout_ms; 389 - 390 - buf = kmalloc(count, GFP_KERNEL); 391 - if (buf == NULL) { 392 - mutex_unlock(&vstdev->lock); 393 - return -ENOMEM; 394 - } 395 - 396 - urb = usb_alloc_urb(0, GFP_KERNEL); 397 - if (!urb) { 398 - kfree(buf); 399 - mutex_unlock(&vstdev->lock); 400 - return -ENOMEM; 401 - } 402 - 403 - if (copy_from_user(buf, buffer, count)) { 404 - mutex_unlock(&vstdev->lock); 405 - dev_err(&dev->dev, "%s: can't copy_from_user\n", __func__); 406 - retval = -EFAULT; 407 - goto exit; 408 - } 409 - 410 - usb_anchor_urb(urb, &vstdev->submitted); 411 - retval = vstusb_fill_and_send_urb(urb, dev, pipe, buf, count, &done); 412 - mutex_unlock(&vstdev->lock); 413 - if (retval) { 414 - usb_unanchor_urb(urb); 415 - dev_err(&dev->dev, "%s: error %d filling and sending urb %d\n", 416 - __func__, retval, pipe); 417 - goto exit; 418 - } 419 - 420 - retval = vstusb_complete_urb(urb, &done, timeout, &cnt); 421 - if (retval) { 422 - dev_err(&dev->dev, "%s: error %d completing urb %d\n", 423 - __func__, retval, pipe); 424 - goto exit; 425 - } else { 426 - retval = cnt; 427 - dev_dbg(&dev->dev, "%s: sent %d bytes to pipe %d\n", 428 - __func__, cnt, pipe); 429 - } 430 - 431 - exit: 432 - usb_free_urb(urb); 433 - kfree(buf); 434 - return retval; 435 - } 436 - 437 - static long vstusb_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 438 - { 439 - int retval = 0; 440 - int cnt = -1; 441 - void __user *data = (void __user *)arg; 442 - struct vstusb_args usb_data; 443 - 444 - struct vstusb_device *vstdev; 445 - void *buffer = NULL; /* must be initialized. buffer is 446 - * referenced on exit but not all 447 - * ioctls allocate it */ 448 - 449 - struct urb *urb = NULL; /* must be initialized. urb is 450 - * referenced on exit but not all 451 - * ioctls allocate it */ 452 - struct usb_device *dev; 453 - unsigned int pipe; 454 - int timeout; 455 - 456 - DECLARE_COMPLETION_ONSTACK(done); 457 - 458 - vstdev = file->private_data; 459 - 460 - if (_IOC_TYPE(cmd) != VST_IOC_MAGIC) { 461 - dev_warn(&vstdev->usb_dev->dev, 462 - "%s: ioctl command %x, bad ioctl magic %x, " 463 - "expected %x\n", __func__, cmd, 464 - _IOC_TYPE(cmd), VST_IOC_MAGIC); 465 - return -EINVAL; 466 - } 467 - 468 - if (vstdev == NULL) 469 - return -ENODEV; 470 - 471 - if (copy_from_user(&usb_data, data, sizeof(struct vstusb_args))) { 472 - dev_err(&vstdev->usb_dev->dev, "%s: can't copy_from_user\n", 473 - __func__); 474 - return -EFAULT; 475 - } 476 - 477 - /* lock this object */ 478 - if (mutex_lock_interruptible(&vstdev->lock)) { 479 - retval = -ERESTARTSYS; 480 - goto exit; 481 - } 482 - 483 - /* anyone home */ 484 - if (!vstdev->present) { 485 - mutex_unlock(&vstdev->lock); 486 - dev_err(&vstdev->usb_dev->dev, "%s: device not present\n", 487 - __func__); 488 - retval = -ENODEV; 489 - goto exit; 490 - } 491 - 492 - /* pull out the necessary data */ 493 - dev = vstdev->usb_dev; 494 - 495 - switch (cmd) { 496 - 497 - case IOCTL_VSTUSB_CONFIG_RW: 498 - 499 - vstdev->rd_pipe = usb_data.rd_pipe; 500 - vstdev->rd_timeout_ms = usb_data.rd_timeout_ms; 501 - vstdev->wr_pipe = usb_data.wr_pipe; 502 - vstdev->wr_timeout_ms = usb_data.wr_timeout_ms; 503 - 504 - mutex_unlock(&vstdev->lock); 505 - 506 - dev_dbg(&dev->dev, "%s: setting pipes/timeouts, " 507 - "rdpipe = %d, rdtimeout = %d, " 508 - "wrpipe = %d, wrtimeout = %d\n", __func__, 509 - vstdev->rd_pipe, vstdev->rd_timeout_ms, 510 - vstdev->wr_pipe, vstdev->wr_timeout_ms); 511 - break; 512 - 513 - case IOCTL_VSTUSB_SEND_PIPE: 514 - 515 - if ((usb_data.count == 0) || (usb_data.count > VST_MAXBUFFER)) { 516 - mutex_unlock(&vstdev->lock); 517 - retval = -EINVAL; 518 - goto exit; 519 - } 520 - 521 - buffer = kmalloc(usb_data.count, GFP_KERNEL); 522 - if (buffer == NULL) { 523 - mutex_unlock(&vstdev->lock); 524 - retval = -ENOMEM; 525 - goto exit; 526 - } 527 - 528 - urb = usb_alloc_urb(0, GFP_KERNEL); 529 - if (!urb) { 530 - mutex_unlock(&vstdev->lock); 531 - retval = -ENOMEM; 532 - goto exit; 533 - } 534 - 535 - timeout = usb_data.timeout_ms; 536 - 537 - pipe = usb_sndbulkpipe(dev, usb_data.pipe); 538 - 539 - if (copy_from_user(buffer, usb_data.buffer, usb_data.count)) { 540 - dev_err(&dev->dev, "%s: can't copy_from_user\n", 541 - __func__); 542 - mutex_unlock(&vstdev->lock); 543 - retval = -EFAULT; 544 - goto exit; 545 - } 546 - 547 - usb_anchor_urb(urb, &vstdev->submitted); 548 - retval = vstusb_fill_and_send_urb(urb, dev, pipe, buffer, 549 - usb_data.count, &done); 550 - mutex_unlock(&vstdev->lock); 551 - if (retval) { 552 - usb_unanchor_urb(urb); 553 - dev_err(&dev->dev, 554 - "%s: error %d filling and sending urb %d\n", 555 - __func__, retval, pipe); 556 - goto exit; 557 - } 558 - 559 - retval = vstusb_complete_urb(urb, &done, timeout, &cnt); 560 - if (retval) { 561 - dev_err(&dev->dev, "%s: error %d completing urb %d\n", 562 - __func__, retval, pipe); 563 - } 564 - 565 - break; 566 - case IOCTL_VSTUSB_RECV_PIPE: 567 - 568 - if ((usb_data.count == 0) || (usb_data.count > VST_MAXBUFFER)) { 569 - mutex_unlock(&vstdev->lock); 570 - retval = -EINVAL; 571 - goto exit; 572 - } 573 - 574 - buffer = kmalloc(usb_data.count, GFP_KERNEL); 575 - if (buffer == NULL) { 576 - mutex_unlock(&vstdev->lock); 577 - retval = -ENOMEM; 578 - goto exit; 579 - } 580 - 581 - urb = usb_alloc_urb(0, GFP_KERNEL); 582 - if (!urb) { 583 - mutex_unlock(&vstdev->lock); 584 - retval = -ENOMEM; 585 - goto exit; 586 - } 587 - 588 - timeout = usb_data.timeout_ms; 589 - 590 - pipe = usb_rcvbulkpipe(dev, usb_data.pipe); 591 - 592 - usb_anchor_urb(urb, &vstdev->submitted); 593 - retval = vstusb_fill_and_send_urb(urb, dev, pipe, buffer, 594 - usb_data.count, &done); 595 - mutex_unlock(&vstdev->lock); 596 - if (retval) { 597 - usb_unanchor_urb(urb); 598 - dev_err(&dev->dev, 599 - "%s: error %d filling and sending urb %d\n", 600 - __func__, retval, pipe); 601 - goto exit; 602 - } 603 - 604 - retval = vstusb_complete_urb(urb, &done, timeout, &cnt); 605 - if (retval) { 606 - dev_err(&dev->dev, "%s: error %d completing urb %d\n", 607 - __func__, retval, pipe); 608 - goto exit; 609 - } 610 - 611 - if (copy_to_user(usb_data.buffer, buffer, cnt)) { 612 - dev_err(&dev->dev, "%s: can't copy_to_user\n", 613 - __func__); 614 - retval = -EFAULT; 615 - goto exit; 616 - } 617 - 618 - usb_data.count = cnt; 619 - if (copy_to_user(data, &usb_data, sizeof(struct vstusb_args))) { 620 - dev_err(&dev->dev, "%s: can't copy_to_user\n", 621 - __func__); 622 - retval = -EFAULT; 623 - } else { 624 - dev_dbg(&dev->dev, "%s: recv %zd bytes from pipe %d\n", 625 - __func__, usb_data.count, usb_data.pipe); 626 - } 627 - 628 - break; 629 - 630 - default: 631 - mutex_unlock(&vstdev->lock); 632 - dev_warn(&dev->dev, "ioctl_vstusb: invalid ioctl cmd %x\n", 633 - cmd); 634 - return -EINVAL; 635 - break; 636 - } 637 - exit: 638 - usb_free_urb(urb); 639 - kfree(buffer); 640 - return retval; 641 - } 642 - 643 - static const struct file_operations vstusb_fops = { 644 - .owner = THIS_MODULE, 645 - .read = vstusb_read, 646 - .write = vstusb_write, 647 - .unlocked_ioctl = vstusb_ioctl, 648 - .compat_ioctl = vstusb_ioctl, 649 - .open = vstusb_open, 650 - .release = vstusb_release, 651 - }; 652 - 653 - static struct usb_class_driver usb_vstusb_class = { 654 - .name = "usb/vstusb%d", 655 - .fops = &vstusb_fops, 656 - .minor_base = VSTUSB_MINOR_BASE, 657 - }; 658 - 659 - static int vstusb_probe(struct usb_interface *intf, 660 - const struct usb_device_id *id) 661 - { 662 - struct usb_device *dev = interface_to_usbdev(intf); 663 - struct vstusb_device *vstdev; 664 - int i; 665 - int retval = 0; 666 - 667 - /* allocate memory for our device state and intialize it */ 668 - 669 - vstdev = kzalloc(sizeof(*vstdev), GFP_KERNEL); 670 - if (vstdev == NULL) 671 - return -ENOMEM; 672 - 673 - /* must do usb_get_dev() prior to kref_init() since the kref_put() 674 - * release function will do a usb_put_dev() */ 675 - usb_get_dev(dev); 676 - kref_init(&vstdev->kref); 677 - mutex_init(&vstdev->lock); 678 - 679 - i = dev->descriptor.bcdDevice; 680 - 681 - dev_dbg(&intf->dev, "Version %1d%1d.%1d%1d found at address %d\n", 682 - (i & 0xF000) >> 12, (i & 0xF00) >> 8, 683 - (i & 0xF0) >> 4, (i & 0xF), dev->devnum); 684 - 685 - vstdev->present = 1; 686 - vstdev->isopen = 0; 687 - vstdev->usb_dev = dev; 688 - init_usb_anchor(&vstdev->submitted); 689 - 690 - usb_set_intfdata(intf, vstdev); 691 - retval = usb_register_dev(intf, &usb_vstusb_class); 692 - if (retval) { 693 - dev_err(&intf->dev, 694 - "%s: Not able to get a minor for this device.\n", 695 - __func__); 696 - usb_set_intfdata(intf, NULL); 697 - kref_put(&vstdev->kref, vstusb_delete); 698 - return retval; 699 - } 700 - 701 - /* let the user know what node this device is now attached to */ 702 - dev_info(&intf->dev, 703 - "VST USB Device #%d now attached to major %d minor %d\n", 704 - (intf->minor - VSTUSB_MINOR_BASE), USB_MAJOR, intf->minor); 705 - 706 - dev_info(&intf->dev, "%s, %s\n", DRIVER_DESC, DRIVER_VERSION); 707 - 708 - return retval; 709 - } 710 - 711 - static void vstusb_disconnect(struct usb_interface *intf) 712 - { 713 - struct vstusb_device *vstdev = usb_get_intfdata(intf); 714 - 715 - usb_deregister_dev(intf, &usb_vstusb_class); 716 - usb_set_intfdata(intf, NULL); 717 - 718 - if (vstdev) { 719 - 720 - mutex_lock(&vstdev->lock); 721 - vstdev->present = 0; 722 - 723 - usb_kill_anchored_urbs(&vstdev->submitted); 724 - 725 - mutex_unlock(&vstdev->lock); 726 - 727 - kref_put(&vstdev->kref, vstusb_delete); 728 - } 729 - 730 - } 731 - 732 - static int vstusb_suspend(struct usb_interface *intf, pm_message_t message) 733 - { 734 - struct vstusb_device *vstdev = usb_get_intfdata(intf); 735 - int time; 736 - if (!vstdev) 737 - return 0; 738 - 739 - mutex_lock(&vstdev->lock); 740 - time = usb_wait_anchor_empty_timeout(&vstdev->submitted, 1000); 741 - if (!time) 742 - usb_kill_anchored_urbs(&vstdev->submitted); 743 - mutex_unlock(&vstdev->lock); 744 - 745 - return 0; 746 - } 747 - 748 - static int vstusb_resume(struct usb_interface *intf) 749 - { 750 - return 0; 751 - } 752 - 753 - static struct usb_driver vstusb_driver = { 754 - .name = "vstusb", 755 - .probe = vstusb_probe, 756 - .disconnect = vstusb_disconnect, 757 - .suspend = vstusb_suspend, 758 - .resume = vstusb_resume, 759 - .id_table = id_table, 760 - }; 761 - 762 - static int __init vstusb_init(void) 763 - { 764 - int rc; 765 - 766 - rc = usb_register(&vstusb_driver); 767 - if (rc) 768 - printk(KERN_ERR "%s: failed to register (%d)", __func__, rc); 769 - 770 - return rc; 771 - } 772 - 773 - static void __exit vstusb_exit(void) 774 - { 775 - usb_deregister(&vstusb_driver); 776 - } 777 - 778 - module_init(vstusb_init); 779 - module_exit(vstusb_exit); 780 - 781 - MODULE_AUTHOR("Dennis O'Brien/Stephen Ware"); 782 - MODULE_DESCRIPTION(DRIVER_VERSION); 783 - MODULE_LICENSE("GPL");
···
+6 -1
drivers/usb/mon/mon_bin.c
··· 460 char ev_type, int status) 461 { 462 const struct usb_endpoint_descriptor *epd = &urb->ep->desc; 463 - unsigned long flags; 464 struct timeval ts; 465 unsigned int urb_length; 466 unsigned int offset; 467 unsigned int length; ··· 600 static void mon_bin_error(void *data, struct urb *urb, int error) 601 { 602 struct mon_reader_bin *rp = data; 603 unsigned long flags; 604 unsigned int offset; 605 struct mon_bin_hdr *ep; 606 607 spin_lock_irqsave(&rp->b_lock, flags); 608 ··· 626 ep->devnum = urb->dev->devnum; 627 ep->busnum = urb->dev->bus->busnum; 628 ep->id = (unsigned long) urb; 629 ep->status = error; 630 631 ep->flag_setup = '-';
··· 460 char ev_type, int status) 461 { 462 const struct usb_endpoint_descriptor *epd = &urb->ep->desc; 463 struct timeval ts; 464 + unsigned long flags; 465 unsigned int urb_length; 466 unsigned int offset; 467 unsigned int length; ··· 600 static void mon_bin_error(void *data, struct urb *urb, int error) 601 { 602 struct mon_reader_bin *rp = data; 603 + struct timeval ts; 604 unsigned long flags; 605 unsigned int offset; 606 struct mon_bin_hdr *ep; 607 + 608 + do_gettimeofday(&ts); 609 610 spin_lock_irqsave(&rp->b_lock, flags); 611 ··· 623 ep->devnum = urb->dev->devnum; 624 ep->busnum = urb->dev->bus->busnum; 625 ep->id = (unsigned long) urb; 626 + ep->ts_sec = ts.tv_sec; 627 + ep->ts_usec = ts.tv_usec; 628 ep->status = error; 629 630 ep->flag_setup = '-';
+3 -3
drivers/usb/mon/mon_text.c
··· 180 unsigned int stamp; 181 182 do_gettimeofday(&tval); 183 - stamp = tval.tv_sec & 0xFFFF; /* 2^32 = 4294967296. Limit to 4096s. */ 184 stamp = stamp * 1000000 + tval.tv_usec; 185 return stamp; 186 } ··· 273 274 ep->type = 'E'; 275 ep->id = (unsigned long) urb; 276 - ep->busnum = 0; 277 ep->devnum = urb->dev->devnum; 278 ep->epnum = usb_endpoint_num(&urb->ep->desc); 279 ep->xfertype = usb_endpoint_type(&urb->ep->desc); 280 ep->is_in = usb_urb_dir_in(urb); 281 - ep->tstamp = 0; 282 ep->length = 0; 283 ep->status = error; 284
··· 180 unsigned int stamp; 181 182 do_gettimeofday(&tval); 183 + stamp = tval.tv_sec & 0xFFF; /* 2^32 = 4294967296. Limit to 4096s. */ 184 stamp = stamp * 1000000 + tval.tv_usec; 185 return stamp; 186 } ··· 273 274 ep->type = 'E'; 275 ep->id = (unsigned long) urb; 276 + ep->busnum = urb->dev->bus->busnum; 277 ep->devnum = urb->dev->devnum; 278 ep->epnum = usb_endpoint_num(&urb->ep->desc); 279 ep->xfertype = usb_endpoint_type(&urb->ep->desc); 280 ep->is_in = usb_urb_dir_in(urb); 281 + ep->tstamp = mon_get_timestamp(); 282 ep->length = 0; 283 ep->status = error; 284
+13 -15
drivers/usb/musb/blackfin.c
··· 30 void __iomem *fifo = hw_ep->fifo; 31 void __iomem *epio = hw_ep->regs; 32 u8 epnum = hw_ep->epnum; 33 - u16 dma_reg = 0; 34 35 prefetch((u8 *)src); 36 ··· 41 dump_fifo_data(src, len); 42 43 if (!ANOMALY_05000380 && epnum != 0) { 44 - flush_dcache_range((unsigned int)src, 45 - (unsigned int)(src + len)); 46 47 /* Setup DMA address register */ 48 - dma_reg = (u16) ((u32) src & 0xFFFF); 49 bfin_write16(USB_DMA_REG(epnum, USB_DMAx_ADDR_LOW), dma_reg); 50 SSYNC(); 51 52 - dma_reg = (u16) (((u32) src >> 16) & 0xFFFF); 53 bfin_write16(USB_DMA_REG(epnum, USB_DMAx_ADDR_HIGH), dma_reg); 54 SSYNC(); 55 ··· 80 SSYNC(); 81 82 if (unlikely((unsigned long)src & 0x01)) 83 - outsw_8((unsigned long)fifo, src, 84 - len & 0x01 ? (len >> 1) + 1 : len >> 1); 85 else 86 - outsw((unsigned long)fifo, src, 87 - len & 0x01 ? (len >> 1) + 1 : len >> 1); 88 - 89 } 90 } 91 /* ··· 92 { 93 void __iomem *fifo = hw_ep->fifo; 94 u8 epnum = hw_ep->epnum; 95 - u16 dma_reg = 0; 96 97 if (ANOMALY_05000467 && epnum != 0) { 98 99 - invalidate_dcache_range((unsigned int)dst, 100 - (unsigned int)(dst + len)); 101 102 /* Setup DMA address register */ 103 - dma_reg = (u16) ((u32) dst & 0xFFFF); 104 bfin_write16(USB_DMA_REG(epnum, USB_DMAx_ADDR_LOW), dma_reg); 105 SSYNC(); 106 107 - dma_reg = (u16) (((u32) dst >> 16) & 0xFFFF); 108 bfin_write16(USB_DMA_REG(epnum, USB_DMAx_ADDR_HIGH), dma_reg); 109 SSYNC(); 110
··· 30 void __iomem *fifo = hw_ep->fifo; 31 void __iomem *epio = hw_ep->regs; 32 u8 epnum = hw_ep->epnum; 33 34 prefetch((u8 *)src); 35 ··· 42 dump_fifo_data(src, len); 43 44 if (!ANOMALY_05000380 && epnum != 0) { 45 + u16 dma_reg; 46 + 47 + flush_dcache_range((unsigned long)src, 48 + (unsigned long)(src + len)); 49 50 /* Setup DMA address register */ 51 + dma_reg = (u32)src; 52 bfin_write16(USB_DMA_REG(epnum, USB_DMAx_ADDR_LOW), dma_reg); 53 SSYNC(); 54 55 + dma_reg = (u32)src >> 16; 56 bfin_write16(USB_DMA_REG(epnum, USB_DMAx_ADDR_HIGH), dma_reg); 57 SSYNC(); 58 ··· 79 SSYNC(); 80 81 if (unlikely((unsigned long)src & 0x01)) 82 + outsw_8((unsigned long)fifo, src, (len + 1) >> 1); 83 else 84 + outsw((unsigned long)fifo, src, (len + 1) >> 1); 85 } 86 } 87 /* ··· 94 { 95 void __iomem *fifo = hw_ep->fifo; 96 u8 epnum = hw_ep->epnum; 97 98 if (ANOMALY_05000467 && epnum != 0) { 99 + u16 dma_reg; 100 101 + invalidate_dcache_range((unsigned long)dst, 102 + (unsigned long)(dst + len)); 103 104 /* Setup DMA address register */ 105 + dma_reg = (u32)dst; 106 bfin_write16(USB_DMA_REG(epnum, USB_DMAx_ADDR_LOW), dma_reg); 107 SSYNC(); 108 109 + dma_reg = (u32)dst >> 16; 110 bfin_write16(USB_DMA_REG(epnum, USB_DMAx_ADDR_HIGH), dma_reg); 111 SSYNC(); 112
+10 -23
drivers/usb/musb/cppi_dma.c
··· 1191 1192 bd = tx_ch->head; 1193 1194 if (NULL == bd) { 1195 DBG(1, "null BD\n"); 1196 continue; 1197 } 1198 ··· 1417 1418 if (cppi_ch->transmit) { 1419 struct cppi_tx_stateram __iomem *tx_ram; 1420 - int enabled; 1421 - 1422 - /* mask interrupts raised to signal teardown complete. */ 1423 - enabled = musb_readl(tibase, DAVINCI_TXCPPI_INTENAB_REG) 1424 - & (1 << cppi_ch->index); 1425 - if (enabled) 1426 - musb_writel(tibase, DAVINCI_TXCPPI_INTCLR_REG, 1427 - (1 << cppi_ch->index)); 1428 - 1429 /* REVISIT put timeouts on these controller handshakes */ 1430 1431 cppi_dump_tx(6, cppi_ch, " (teardown)"); ··· 1431 do { 1432 value = musb_readl(&tx_ram->tx_complete, 0); 1433 } while (0xFFFFFFFC != value); 1434 - musb_writel(&tx_ram->tx_complete, 0, 0xFFFFFFFC); 1435 1436 /* FIXME clean up the transfer state ... here? 1437 * the completion routine should get called with ··· 1443 musb_writew(regs, MUSB_TXCSR, value); 1444 musb_writew(regs, MUSB_TXCSR, value); 1445 1446 - /* While we scrub the TX state RAM, ensure that we clean 1447 - * up any interrupt that's currently asserted: 1448 * 1. Write to completion Ptr value 0x1(bit 0 set) 1449 * (write back mode) 1450 - * 2. Write to completion Ptr value 0x0(bit 0 cleared) 1451 - * (compare mode) 1452 - * Value written is compared(for bits 31:2) and when 1453 - * equal, interrupt is deasserted. 1454 */ 1455 cppi_reset_tx(tx_ram, 1); 1456 - musb_writel(&tx_ram->tx_complete, 0, 0); 1457 - 1458 - /* re-enable interrupt */ 1459 - if (enabled) 1460 - musb_writel(tibase, DAVINCI_TXCPPI_INTENAB_REG, 1461 - (1 << cppi_ch->index)); 1462 - 1463 cppi_dump_tx(5, cppi_ch, " (done teardown)"); 1464 1465 /* REVISIT tx side _should_ clean up the same way
··· 1191 1192 bd = tx_ch->head; 1193 1194 + /* 1195 + * If Head is null then this could mean that a abort interrupt 1196 + * that needs to be acknowledged. 1197 + */ 1198 if (NULL == bd) { 1199 DBG(1, "null BD\n"); 1200 + tx_ram->tx_complete = 0; 1201 continue; 1202 } 1203 ··· 1412 1413 if (cppi_ch->transmit) { 1414 struct cppi_tx_stateram __iomem *tx_ram; 1415 /* REVISIT put timeouts on these controller handshakes */ 1416 1417 cppi_dump_tx(6, cppi_ch, " (teardown)"); ··· 1435 do { 1436 value = musb_readl(&tx_ram->tx_complete, 0); 1437 } while (0xFFFFFFFC != value); 1438 1439 /* FIXME clean up the transfer state ... here? 1440 * the completion routine should get called with ··· 1448 musb_writew(regs, MUSB_TXCSR, value); 1449 musb_writew(regs, MUSB_TXCSR, value); 1450 1451 + /* 1452 * 1. Write to completion Ptr value 0x1(bit 0 set) 1453 * (write back mode) 1454 + * 2. Wait for abort interrupt and then put the channel in 1455 + * compare mode by writing 1 to the tx_complete register. 1456 */ 1457 cppi_reset_tx(tx_ram, 1); 1458 + cppi_ch->head = 0; 1459 + musb_writel(&tx_ram->tx_complete, 0, 1); 1460 cppi_dump_tx(5, cppi_ch, " (done teardown)"); 1461 1462 /* REVISIT tx side _should_ clean up the same way
+399 -265
drivers/usb/musb/musb_core.c
··· 557 handled = IRQ_HANDLED; 558 } 559 560 if (int_usb & MUSB_INTR_CONNECT) { 561 struct usb_hcd *hcd = musb_to_hcd(musb); 562 ··· 688 } 689 #endif /* CONFIG_USB_MUSB_HDRC_HCD */ 690 691 - /* mentor saves a bit: bus reset and babble share the same irq. 692 - * only host sees babble; only peripheral sees bus reset. 693 - */ 694 - if (int_usb & MUSB_INTR_RESET) { 695 - if (is_host_capable() && (devctl & MUSB_DEVCTL_HM) != 0) { 696 - /* 697 - * Looks like non-HS BABBLE can be ignored, but 698 - * HS BABBLE is an error condition. For HS the solution 699 - * is to avoid babble in the first place and fix what 700 - * caused BABBLE. When HS BABBLE happens we can only 701 - * stop the session. 702 - */ 703 - if (devctl & (MUSB_DEVCTL_FSDEV | MUSB_DEVCTL_LSDEV)) 704 - DBG(1, "BABBLE devctl: %02x\n", devctl); 705 - else { 706 - ERR("Stopping host session -- babble\n"); 707 - musb_writeb(mbase, MUSB_DEVCTL, 0); 708 - } 709 - } else if (is_peripheral_capable()) { 710 - DBG(1, "BUS RESET as %s\n", otg_state_string(musb)); 711 - switch (musb->xceiv->state) { 712 - #ifdef CONFIG_USB_OTG 713 - case OTG_STATE_A_SUSPEND: 714 - /* We need to ignore disconnect on suspend 715 - * otherwise tusb 2.0 won't reconnect after a 716 - * power cycle, which breaks otg compliance. 717 - */ 718 - musb->ignore_disconnect = 1; 719 - musb_g_reset(musb); 720 - /* FALLTHROUGH */ 721 - case OTG_STATE_A_WAIT_BCON: /* OPT TD.4.7-900ms */ 722 - /* never use invalid T(a_wait_bcon) */ 723 - DBG(1, "HNP: in %s, %d msec timeout\n", 724 - otg_state_string(musb), 725 - TA_WAIT_BCON(musb)); 726 - mod_timer(&musb->otg_timer, jiffies 727 - + msecs_to_jiffies(TA_WAIT_BCON(musb))); 728 - break; 729 - case OTG_STATE_A_PERIPHERAL: 730 - musb->ignore_disconnect = 0; 731 - del_timer(&musb->otg_timer); 732 - musb_g_reset(musb); 733 - break; 734 - case OTG_STATE_B_WAIT_ACON: 735 - DBG(1, "HNP: RESET (%s), to b_peripheral\n", 736 - otg_state_string(musb)); 737 - musb->xceiv->state = OTG_STATE_B_PERIPHERAL; 738 - musb_g_reset(musb); 739 - break; 740 - #endif 741 - case OTG_STATE_B_IDLE: 742 - musb->xceiv->state = OTG_STATE_B_PERIPHERAL; 743 - /* FALLTHROUGH */ 744 - case OTG_STATE_B_PERIPHERAL: 745 - musb_g_reset(musb); 746 - break; 747 - default: 748 - DBG(1, "Unhandled BUS RESET as %s\n", 749 - otg_state_string(musb)); 750 - } 751 - } 752 - 753 - handled = IRQ_HANDLED; 754 - } 755 - schedule_work(&musb->irq_work); 756 - 757 - return handled; 758 - } 759 - 760 - /* 761 - * Interrupt Service Routine to record USB "global" interrupts. 762 - * Since these do not happen often and signify things of 763 - * paramount importance, it seems OK to check them individually; 764 - * the order of the tests is specified in the manual 765 - * 766 - * @param musb instance pointer 767 - * @param int_usb register contents 768 - * @param devctl 769 - * @param power 770 - */ 771 - static irqreturn_t musb_stage2_irq(struct musb *musb, u8 int_usb, 772 - u8 devctl, u8 power) 773 - { 774 - irqreturn_t handled = IRQ_NONE; 775 - 776 - #if 0 777 - /* REVISIT ... this would be for multiplexing periodic endpoints, or 778 - * supporting transfer phasing to prevent exceeding ISO bandwidth 779 - * limits of a given frame or microframe. 780 - * 781 - * It's not needed for peripheral side, which dedicates endpoints; 782 - * though it _might_ use SOF irqs for other purposes. 783 - * 784 - * And it's not currently needed for host side, which also dedicates 785 - * endpoints, relies on TX/RX interval registers, and isn't claimed 786 - * to support ISO transfers yet. 787 - */ 788 - if (int_usb & MUSB_INTR_SOF) { 789 - void __iomem *mbase = musb->mregs; 790 - struct musb_hw_ep *ep; 791 - u8 epnum; 792 - u16 frame; 793 - 794 - DBG(6, "START_OF_FRAME\n"); 795 - handled = IRQ_HANDLED; 796 - 797 - /* start any periodic Tx transfers waiting for current frame */ 798 - frame = musb_readw(mbase, MUSB_FRAME); 799 - ep = musb->endpoints; 800 - for (epnum = 1; (epnum < musb->nr_endpoints) 801 - && (musb->epmask >= (1 << epnum)); 802 - epnum++, ep++) { 803 - /* 804 - * FIXME handle framecounter wraps (12 bits) 805 - * eliminate duplicated StartUrb logic 806 - */ 807 - if (ep->dwWaitFrame >= frame) { 808 - ep->dwWaitFrame = 0; 809 - pr_debug("SOF --> periodic TX%s on %d\n", 810 - ep->tx_channel ? " DMA" : "", 811 - epnum); 812 - if (!ep->tx_channel) 813 - musb_h_tx_start(musb, epnum); 814 - else 815 - cppi_hostdma_start(musb, epnum); 816 - } 817 - } /* end of for loop */ 818 - } 819 - #endif 820 - 821 if ((int_usb & MUSB_INTR_DISCONNECT) && !musb->ignore_disconnect) { 822 DBG(1, "DISCONNECT (%s) as %s, devctl %02x\n", 823 otg_state_string(musb), ··· 736 otg_state_string(musb)); 737 break; 738 } 739 - 740 - schedule_work(&musb->irq_work); 741 } 742 743 - if (int_usb & MUSB_INTR_SUSPEND) { 744 - DBG(1, "SUSPEND (%s) devctl %02x power %02x\n", 745 - otg_state_string(musb), devctl, power); 746 handled = IRQ_HANDLED; 747 748 - switch (musb->xceiv->state) { 749 - #ifdef CONFIG_USB_MUSB_OTG 750 - case OTG_STATE_A_PERIPHERAL: 751 - /* We also come here if the cable is removed, since 752 - * this silicon doesn't report ID-no-longer-grounded. 753 - * 754 - * We depend on T(a_wait_bcon) to shut us down, and 755 - * hope users don't do anything dicey during this 756 - * undesired detour through A_WAIT_BCON. 757 */ 758 - musb_hnp_stop(musb); 759 - usb_hcd_resume_root_hub(musb_to_hcd(musb)); 760 - musb_root_disconnect(musb); 761 - musb_platform_try_idle(musb, jiffies 762 - + msecs_to_jiffies(musb->a_wait_bcon 763 - ? : OTG_TIME_A_WAIT_BCON)); 764 - break; 765 - #endif 766 - case OTG_STATE_B_PERIPHERAL: 767 - musb_g_suspend(musb); 768 - musb->is_active = is_otg_enabled(musb) 769 - && musb->xceiv->gadget->b_hnp_enable; 770 - if (musb->is_active) { 771 - #ifdef CONFIG_USB_MUSB_OTG 772 - musb->xceiv->state = OTG_STATE_B_WAIT_ACON; 773 - DBG(1, "HNP: Setting timer for b_ase0_brst\n"); 774 - mod_timer(&musb->otg_timer, jiffies 775 - + msecs_to_jiffies( 776 - OTG_TIME_B_ASE0_BRST)); 777 - #endif 778 } 779 - break; 780 - case OTG_STATE_A_WAIT_BCON: 781 - if (musb->a_wait_bcon != 0) 782 - musb_platform_try_idle(musb, jiffies 783 - + msecs_to_jiffies(musb->a_wait_bcon)); 784 - break; 785 - case OTG_STATE_A_HOST: 786 - musb->xceiv->state = OTG_STATE_A_SUSPEND; 787 - musb->is_active = is_otg_enabled(musb) 788 - && musb->xceiv->host->b_hnp_enable; 789 - break; 790 - case OTG_STATE_B_HOST: 791 - /* Transition to B_PERIPHERAL, see 6.8.2.6 p 44 */ 792 - DBG(1, "REVISIT: SUSPEND as B_HOST\n"); 793 - break; 794 - default: 795 - /* "should not happen" */ 796 - musb->is_active = 0; 797 - break; 798 - } 799 - schedule_work(&musb->irq_work); 800 } 801 802 803 return handled; 804 } ··· 1077 { .hw_ep_num = 15, .style = FIFO_RXTX, .maxpacket = 1024, }, 1078 }; 1079 1080 1081 /* 1082 * configure a fifo; for non-shared endpoints, this may be called ··· 1222 cfg = mode_4_cfg; 1223 n = ARRAY_SIZE(mode_4_cfg); 1224 break; 1225 } 1226 1227 printk(KERN_DEBUG "%s: setup fifo_mode %d\n", ··· 1330 */ 1331 static int __init musb_core_init(u16 musb_type, struct musb *musb) 1332 { 1333 - #ifdef MUSB_AHB_ID 1334 - u32 data; 1335 - #endif 1336 u8 reg; 1337 char *type; 1338 char aInfo[90], aRevision[32], aDate[12]; ··· 1341 reg = musb_read_configdata(mbase); 1342 1343 strcpy(aInfo, (reg & MUSB_CONFIGDATA_UTMIDW) ? "UTMI-16" : "UTMI-8"); 1344 - if (reg & MUSB_CONFIGDATA_DYNFIFO) 1345 strcat(aInfo, ", dyn FIFOs"); 1346 if (reg & MUSB_CONFIGDATA_MPRXE) { 1347 strcat(aInfo, ", bulk combine"); 1348 - #ifdef C_MP_RX 1349 musb->bulk_combine = true; 1350 - #else 1351 - strcat(aInfo, " (X)"); /* no driver support */ 1352 - #endif 1353 } 1354 if (reg & MUSB_CONFIGDATA_MPTXE) { 1355 strcat(aInfo, ", bulk split"); 1356 - #ifdef C_MP_TX 1357 musb->bulk_split = true; 1358 - #else 1359 - strcat(aInfo, " (X)"); /* no driver support */ 1360 - #endif 1361 } 1362 if (reg & MUSB_CONFIGDATA_HBRXE) { 1363 strcat(aInfo, ", HB-ISO Rx"); ··· 1367 printk(KERN_DEBUG "%s: ConfigData=0x%02x (%s)\n", 1368 musb_driver_name, reg, aInfo); 1369 1370 - #ifdef MUSB_AHB_ID 1371 - data = musb_readl(mbase, 0x404); 1372 - sprintf(aDate, "%04d-%02x-%02x", (data & 0xffff), 1373 - (data >> 16) & 0xff, (data >> 24) & 0xff); 1374 - /* FIXME ID2 and ID3 are unused */ 1375 - data = musb_readl(mbase, 0x408); 1376 - printk(KERN_DEBUG "ID2=%lx\n", (long unsigned)data); 1377 - data = musb_readl(mbase, 0x40c); 1378 - printk(KERN_DEBUG "ID3=%lx\n", (long unsigned)data); 1379 - reg = musb_readb(mbase, 0x400); 1380 - musb_type = ('M' == reg) ? MUSB_CONTROLLER_MHDRC : MUSB_CONTROLLER_HDRC; 1381 - #else 1382 aDate[0] = 0; 1383 - #endif 1384 if (MUSB_CONTROLLER_MHDRC == musb_type) { 1385 musb->is_multipoint = 1; 1386 type = "M"; ··· 1398 musb->nr_endpoints = 1; 1399 musb->epmask = 1; 1400 1401 - if (reg & MUSB_CONFIGDATA_DYNFIFO) { 1402 - if (musb->config->dyn_fifo) 1403 - status = ep_config_from_table(musb); 1404 - else { 1405 - ERR("reconfigure software for Dynamic FIFOs\n"); 1406 - status = -ENODEV; 1407 - } 1408 - } else { 1409 - if (!musb->config->dyn_fifo) 1410 - status = ep_config_from_hw(musb); 1411 - else { 1412 - ERR("reconfigure software for static FIFOs\n"); 1413 - return -ENODEV; 1414 - } 1415 - } 1416 1417 if (status < 0) 1418 return status; ··· 1570 ep_num++; 1571 } 1572 1573 - /* finish handling "global" interrupts after handling fifos */ 1574 - if (musb->int_usb) 1575 - retval |= musb_stage2_irq(musb, 1576 - musb->int_usb, devctl, power); 1577 - 1578 return retval; 1579 } 1580 ··· 1674 unsigned long val; 1675 1676 if (sscanf(buf, "%lu", &val) < 1) { 1677 - printk(KERN_ERR "Invalid VBUS timeout ms value\n"); 1678 return -EINVAL; 1679 } 1680 ··· 1724 1725 if (sscanf(buf, "%hu", &srp) != 1 1726 || (srp != 1)) { 1727 - printk(KERN_ERR "SRP: Value must be 1\n"); 1728 return -EINVAL; 1729 } 1730 ··· 1736 static DEVICE_ATTR(srp, 0644, NULL, musb_srp_store); 1737 1738 #endif /* CONFIG_USB_GADGET_MUSB_HDRC */ 1739 1740 #endif /* sysfs */ 1741 ··· 1824 */ 1825 1826 #ifdef CONFIG_SYSFS 1827 - device_remove_file(musb->controller, &dev_attr_mode); 1828 - device_remove_file(musb->controller, &dev_attr_vbus); 1829 - #ifdef CONFIG_USB_GADGET_MUSB_HDRC 1830 - device_remove_file(musb->controller, &dev_attr_srp); 1831 - #endif 1832 #endif 1833 1834 #ifdef CONFIG_USB_GADGET_MUSB_HDRC ··· 2004 musb->irq_wake = 0; 2005 } 2006 2007 - pr_info("%s: USB %s mode controller at %p using %s, IRQ %d\n", 2008 - musb_driver_name, 2009 - ({char *s; 2010 - switch (musb->board_mode) { 2011 - case MUSB_HOST: s = "Host"; break; 2012 - case MUSB_PERIPHERAL: s = "Peripheral"; break; 2013 - default: s = "OTG"; break; 2014 - }; s; }), 2015 - ctrl, 2016 - (is_dma_capable() && musb->dma_controller) 2017 - ? "DMA" : "PIO", 2018 - musb->nIrq); 2019 - 2020 /* host side needs more setup */ 2021 if (is_host_enabled(musb)) { 2022 struct usb_hcd *hcd = musb_to_hcd(musb); 2023 2024 otg_set_host(musb->xceiv, &hcd->self); 2025 ··· 2015 hcd->self.otg_port = 1; 2016 musb->xceiv->host = &hcd->self; 2017 hcd->power_budget = 2 * (plat->power ? : 250); 2018 } 2019 2020 /* For the host-only role, we can activate right away. ··· 2061 } 2062 2063 #ifdef CONFIG_SYSFS 2064 - status = device_create_file(dev, &dev_attr_mode); 2065 - status = device_create_file(dev, &dev_attr_vbus); 2066 - #ifdef CONFIG_USB_GADGET_MUSB_HDRC 2067 - status = device_create_file(dev, &dev_attr_srp); 2068 - #endif /* CONFIG_USB_GADGET_MUSB_HDRC */ 2069 - status = 0; 2070 #endif 2071 if (status) 2072 goto fail2; 2073 2074 return 0; 2075 2076 fail2: 2077 - #ifdef CONFIG_SYSFS 2078 - device_remove_file(musb->controller, &dev_attr_mode); 2079 - device_remove_file(musb->controller, &dev_attr_vbus); 2080 - #ifdef CONFIG_USB_GADGET_MUSB_HDRC 2081 - device_remove_file(musb->controller, &dev_attr_srp); 2082 - #endif 2083 - #endif 2084 musb_platform_exit(musb); 2085 fail: 2086 dev_err(musb->controller, ··· 2109 { 2110 struct device *dev = &pdev->dev; 2111 int irq = platform_get_irq(pdev, 0); 2112 struct resource *iomem; 2113 void __iomem *base; 2114 ··· 2117 if (!iomem || irq == 0) 2118 return -ENODEV; 2119 2120 - base = ioremap(iomem->start, iomem->end - iomem->start + 1); 2121 if (!base) { 2122 dev_err(dev, "ioremap failed\n"); 2123 return -ENOMEM; ··· 2127 /* clobbered by use_dma=n */ 2128 orig_dma_mask = dev->dma_mask; 2129 #endif 2130 - return musb_init_controller(dev, irq, base); 2131 } 2132 2133 static int __exit musb_remove(struct platform_device *pdev) ··· 2161 2162 #ifdef CONFIG_PM 2163 2164 static int musb_suspend(struct device *dev) 2165 { 2166 struct platform_device *pdev = to_platform_device(dev); ··· 2324 */ 2325 } 2326 2327 if (musb->set_clock) 2328 musb->set_clock(musb->clock, 0); 2329 else ··· 2346 musb->set_clock(musb->clock, 1); 2347 else 2348 clk_enable(musb->clock); 2349 2350 /* for static cmos like DaVinci, register values were preserved 2351 * unless for some reason the whole soc powered down or the USB
··· 557 handled = IRQ_HANDLED; 558 } 559 560 + 561 + if (int_usb & MUSB_INTR_SUSPEND) { 562 + DBG(1, "SUSPEND (%s) devctl %02x power %02x\n", 563 + otg_state_string(musb), devctl, power); 564 + handled = IRQ_HANDLED; 565 + 566 + switch (musb->xceiv->state) { 567 + #ifdef CONFIG_USB_MUSB_OTG 568 + case OTG_STATE_A_PERIPHERAL: 569 + /* We also come here if the cable is removed, since 570 + * this silicon doesn't report ID-no-longer-grounded. 571 + * 572 + * We depend on T(a_wait_bcon) to shut us down, and 573 + * hope users don't do anything dicey during this 574 + * undesired detour through A_WAIT_BCON. 575 + */ 576 + musb_hnp_stop(musb); 577 + usb_hcd_resume_root_hub(musb_to_hcd(musb)); 578 + musb_root_disconnect(musb); 579 + musb_platform_try_idle(musb, jiffies 580 + + msecs_to_jiffies(musb->a_wait_bcon 581 + ? : OTG_TIME_A_WAIT_BCON)); 582 + 583 + break; 584 + #endif 585 + case OTG_STATE_B_IDLE: 586 + if (!musb->is_active) 587 + break; 588 + case OTG_STATE_B_PERIPHERAL: 589 + musb_g_suspend(musb); 590 + musb->is_active = is_otg_enabled(musb) 591 + && musb->xceiv->gadget->b_hnp_enable; 592 + if (musb->is_active) { 593 + #ifdef CONFIG_USB_MUSB_OTG 594 + musb->xceiv->state = OTG_STATE_B_WAIT_ACON; 595 + DBG(1, "HNP: Setting timer for b_ase0_brst\n"); 596 + mod_timer(&musb->otg_timer, jiffies 597 + + msecs_to_jiffies( 598 + OTG_TIME_B_ASE0_BRST)); 599 + #endif 600 + } 601 + break; 602 + case OTG_STATE_A_WAIT_BCON: 603 + if (musb->a_wait_bcon != 0) 604 + musb_platform_try_idle(musb, jiffies 605 + + msecs_to_jiffies(musb->a_wait_bcon)); 606 + break; 607 + case OTG_STATE_A_HOST: 608 + musb->xceiv->state = OTG_STATE_A_SUSPEND; 609 + musb->is_active = is_otg_enabled(musb) 610 + && musb->xceiv->host->b_hnp_enable; 611 + break; 612 + case OTG_STATE_B_HOST: 613 + /* Transition to B_PERIPHERAL, see 6.8.2.6 p 44 */ 614 + DBG(1, "REVISIT: SUSPEND as B_HOST\n"); 615 + break; 616 + default: 617 + /* "should not happen" */ 618 + musb->is_active = 0; 619 + break; 620 + } 621 + } 622 + 623 if (int_usb & MUSB_INTR_CONNECT) { 624 struct usb_hcd *hcd = musb_to_hcd(musb); 625 ··· 625 } 626 #endif /* CONFIG_USB_MUSB_HDRC_HCD */ 627 628 if ((int_usb & MUSB_INTR_DISCONNECT) && !musb->ignore_disconnect) { 629 DBG(1, "DISCONNECT (%s) as %s, devctl %02x\n", 630 otg_state_string(musb), ··· 803 otg_state_string(musb)); 804 break; 805 } 806 } 807 808 + /* mentor saves a bit: bus reset and babble share the same irq. 809 + * only host sees babble; only peripheral sees bus reset. 810 + */ 811 + if (int_usb & MUSB_INTR_RESET) { 812 + handled = IRQ_HANDLED; 813 + if (is_host_capable() && (devctl & MUSB_DEVCTL_HM) != 0) { 814 + /* 815 + * Looks like non-HS BABBLE can be ignored, but 816 + * HS BABBLE is an error condition. For HS the solution 817 + * is to avoid babble in the first place and fix what 818 + * caused BABBLE. When HS BABBLE happens we can only 819 + * stop the session. 820 + */ 821 + if (devctl & (MUSB_DEVCTL_FSDEV | MUSB_DEVCTL_LSDEV)) 822 + DBG(1, "BABBLE devctl: %02x\n", devctl); 823 + else { 824 + ERR("Stopping host session -- babble\n"); 825 + musb_writeb(musb->mregs, MUSB_DEVCTL, 0); 826 + } 827 + } else if (is_peripheral_capable()) { 828 + DBG(1, "BUS RESET as %s\n", otg_state_string(musb)); 829 + switch (musb->xceiv->state) { 830 + #ifdef CONFIG_USB_OTG 831 + case OTG_STATE_A_SUSPEND: 832 + /* We need to ignore disconnect on suspend 833 + * otherwise tusb 2.0 won't reconnect after a 834 + * power cycle, which breaks otg compliance. 835 + */ 836 + musb->ignore_disconnect = 1; 837 + musb_g_reset(musb); 838 + /* FALLTHROUGH */ 839 + case OTG_STATE_A_WAIT_BCON: /* OPT TD.4.7-900ms */ 840 + /* never use invalid T(a_wait_bcon) */ 841 + DBG(1, "HNP: in %s, %d msec timeout\n", 842 + otg_state_string(musb), 843 + TA_WAIT_BCON(musb)); 844 + mod_timer(&musb->otg_timer, jiffies 845 + + msecs_to_jiffies(TA_WAIT_BCON(musb))); 846 + break; 847 + case OTG_STATE_A_PERIPHERAL: 848 + musb->ignore_disconnect = 0; 849 + del_timer(&musb->otg_timer); 850 + musb_g_reset(musb); 851 + break; 852 + case OTG_STATE_B_WAIT_ACON: 853 + DBG(1, "HNP: RESET (%s), to b_peripheral\n", 854 + otg_state_string(musb)); 855 + musb->xceiv->state = OTG_STATE_B_PERIPHERAL; 856 + musb_g_reset(musb); 857 + break; 858 + #endif 859 + case OTG_STATE_B_IDLE: 860 + musb->xceiv->state = OTG_STATE_B_PERIPHERAL; 861 + /* FALLTHROUGH */ 862 + case OTG_STATE_B_PERIPHERAL: 863 + musb_g_reset(musb); 864 + break; 865 + default: 866 + DBG(1, "Unhandled BUS RESET as %s\n", 867 + otg_state_string(musb)); 868 + } 869 + } 870 + } 871 + 872 + #if 0 873 + /* REVISIT ... this would be for multiplexing periodic endpoints, or 874 + * supporting transfer phasing to prevent exceeding ISO bandwidth 875 + * limits of a given frame or microframe. 876 + * 877 + * It's not needed for peripheral side, which dedicates endpoints; 878 + * though it _might_ use SOF irqs for other purposes. 879 + * 880 + * And it's not currently needed for host side, which also dedicates 881 + * endpoints, relies on TX/RX interval registers, and isn't claimed 882 + * to support ISO transfers yet. 883 + */ 884 + if (int_usb & MUSB_INTR_SOF) { 885 + void __iomem *mbase = musb->mregs; 886 + struct musb_hw_ep *ep; 887 + u8 epnum; 888 + u16 frame; 889 + 890 + DBG(6, "START_OF_FRAME\n"); 891 handled = IRQ_HANDLED; 892 893 + /* start any periodic Tx transfers waiting for current frame */ 894 + frame = musb_readw(mbase, MUSB_FRAME); 895 + ep = musb->endpoints; 896 + for (epnum = 1; (epnum < musb->nr_endpoints) 897 + && (musb->epmask >= (1 << epnum)); 898 + epnum++, ep++) { 899 + /* 900 + * FIXME handle framecounter wraps (12 bits) 901 + * eliminate duplicated StartUrb logic 902 */ 903 + if (ep->dwWaitFrame >= frame) { 904 + ep->dwWaitFrame = 0; 905 + pr_debug("SOF --> periodic TX%s on %d\n", 906 + ep->tx_channel ? " DMA" : "", 907 + epnum); 908 + if (!ep->tx_channel) 909 + musb_h_tx_start(musb, epnum); 910 + else 911 + cppi_hostdma_start(musb, epnum); 912 } 913 + } /* end of for loop */ 914 } 915 + #endif 916 917 + schedule_work(&musb->irq_work); 918 919 return handled; 920 } ··· 1095 { .hw_ep_num = 15, .style = FIFO_RXTX, .maxpacket = 1024, }, 1096 }; 1097 1098 + /* mode 5 - fits in 8KB */ 1099 + static struct fifo_cfg __initdata mode_5_cfg[] = { 1100 + { .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, }, 1101 + { .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, }, 1102 + { .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 512, }, 1103 + { .hw_ep_num = 2, .style = FIFO_RX, .maxpacket = 512, }, 1104 + { .hw_ep_num = 3, .style = FIFO_TX, .maxpacket = 512, }, 1105 + { .hw_ep_num = 3, .style = FIFO_RX, .maxpacket = 512, }, 1106 + { .hw_ep_num = 4, .style = FIFO_TX, .maxpacket = 512, }, 1107 + { .hw_ep_num = 4, .style = FIFO_RX, .maxpacket = 512, }, 1108 + { .hw_ep_num = 5, .style = FIFO_TX, .maxpacket = 512, }, 1109 + { .hw_ep_num = 5, .style = FIFO_RX, .maxpacket = 512, }, 1110 + { .hw_ep_num = 6, .style = FIFO_TX, .maxpacket = 32, }, 1111 + { .hw_ep_num = 6, .style = FIFO_RX, .maxpacket = 32, }, 1112 + { .hw_ep_num = 7, .style = FIFO_TX, .maxpacket = 32, }, 1113 + { .hw_ep_num = 7, .style = FIFO_RX, .maxpacket = 32, }, 1114 + { .hw_ep_num = 8, .style = FIFO_TX, .maxpacket = 32, }, 1115 + { .hw_ep_num = 8, .style = FIFO_RX, .maxpacket = 32, }, 1116 + { .hw_ep_num = 9, .style = FIFO_TX, .maxpacket = 32, }, 1117 + { .hw_ep_num = 9, .style = FIFO_RX, .maxpacket = 32, }, 1118 + { .hw_ep_num = 10, .style = FIFO_TX, .maxpacket = 32, }, 1119 + { .hw_ep_num = 10, .style = FIFO_RX, .maxpacket = 32, }, 1120 + { .hw_ep_num = 11, .style = FIFO_TX, .maxpacket = 32, }, 1121 + { .hw_ep_num = 11, .style = FIFO_RX, .maxpacket = 32, }, 1122 + { .hw_ep_num = 12, .style = FIFO_TX, .maxpacket = 32, }, 1123 + { .hw_ep_num = 12, .style = FIFO_RX, .maxpacket = 32, }, 1124 + { .hw_ep_num = 13, .style = FIFO_RXTX, .maxpacket = 512, }, 1125 + { .hw_ep_num = 14, .style = FIFO_RXTX, .maxpacket = 1024, }, 1126 + { .hw_ep_num = 15, .style = FIFO_RXTX, .maxpacket = 1024, }, 1127 + }; 1128 1129 /* 1130 * configure a fifo; for non-shared endpoints, this may be called ··· 1210 cfg = mode_4_cfg; 1211 n = ARRAY_SIZE(mode_4_cfg); 1212 break; 1213 + case 5: 1214 + cfg = mode_5_cfg; 1215 + n = ARRAY_SIZE(mode_5_cfg); 1216 + break; 1217 } 1218 1219 printk(KERN_DEBUG "%s: setup fifo_mode %d\n", ··· 1314 */ 1315 static int __init musb_core_init(u16 musb_type, struct musb *musb) 1316 { 1317 u8 reg; 1318 char *type; 1319 char aInfo[90], aRevision[32], aDate[12]; ··· 1328 reg = musb_read_configdata(mbase); 1329 1330 strcpy(aInfo, (reg & MUSB_CONFIGDATA_UTMIDW) ? "UTMI-16" : "UTMI-8"); 1331 + if (reg & MUSB_CONFIGDATA_DYNFIFO) { 1332 strcat(aInfo, ", dyn FIFOs"); 1333 + musb->dyn_fifo = true; 1334 + } 1335 if (reg & MUSB_CONFIGDATA_MPRXE) { 1336 strcat(aInfo, ", bulk combine"); 1337 musb->bulk_combine = true; 1338 } 1339 if (reg & MUSB_CONFIGDATA_MPTXE) { 1340 strcat(aInfo, ", bulk split"); 1341 musb->bulk_split = true; 1342 } 1343 if (reg & MUSB_CONFIGDATA_HBRXE) { 1344 strcat(aInfo, ", HB-ISO Rx"); ··· 1360 printk(KERN_DEBUG "%s: ConfigData=0x%02x (%s)\n", 1361 musb_driver_name, reg, aInfo); 1362 1363 aDate[0] = 0; 1364 if (MUSB_CONTROLLER_MHDRC == musb_type) { 1365 musb->is_multipoint = 1; 1366 type = "M"; ··· 1404 musb->nr_endpoints = 1; 1405 musb->epmask = 1; 1406 1407 + if (musb->dyn_fifo) 1408 + status = ep_config_from_table(musb); 1409 + else 1410 + status = ep_config_from_hw(musb); 1411 1412 if (status < 0) 1413 return status; ··· 1587 ep_num++; 1588 } 1589 1590 return retval; 1591 } 1592 ··· 1696 unsigned long val; 1697 1698 if (sscanf(buf, "%lu", &val) < 1) { 1699 + dev_err(dev, "Invalid VBUS timeout ms value\n"); 1700 return -EINVAL; 1701 } 1702 ··· 1746 1747 if (sscanf(buf, "%hu", &srp) != 1 1748 || (srp != 1)) { 1749 + dev_err(dev, "SRP: Value must be 1\n"); 1750 return -EINVAL; 1751 } 1752 ··· 1758 static DEVICE_ATTR(srp, 0644, NULL, musb_srp_store); 1759 1760 #endif /* CONFIG_USB_GADGET_MUSB_HDRC */ 1761 + 1762 + static struct attribute *musb_attributes[] = { 1763 + &dev_attr_mode.attr, 1764 + &dev_attr_vbus.attr, 1765 + #ifdef CONFIG_USB_GADGET_MUSB_HDRC 1766 + &dev_attr_srp.attr, 1767 + #endif 1768 + NULL 1769 + }; 1770 + 1771 + static const struct attribute_group musb_attr_group = { 1772 + .attrs = musb_attributes, 1773 + }; 1774 1775 #endif /* sysfs */ 1776 ··· 1833 */ 1834 1835 #ifdef CONFIG_SYSFS 1836 + sysfs_remove_group(&musb->controller->kobj, &musb_attr_group); 1837 #endif 1838 1839 #ifdef CONFIG_USB_GADGET_MUSB_HDRC ··· 2017 musb->irq_wake = 0; 2018 } 2019 2020 /* host side needs more setup */ 2021 if (is_host_enabled(musb)) { 2022 struct usb_hcd *hcd = musb_to_hcd(musb); 2023 + u8 busctl; 2024 2025 otg_set_host(musb->xceiv, &hcd->self); 2026 ··· 2040 hcd->self.otg_port = 1; 2041 musb->xceiv->host = &hcd->self; 2042 hcd->power_budget = 2 * (plat->power ? : 250); 2043 + 2044 + /* program PHY to use external vBus if required */ 2045 + if (plat->extvbus) { 2046 + busctl = musb_readb(musb->mregs, MUSB_ULPI_BUSCONTROL); 2047 + busctl |= MUSB_ULPI_USE_EXTVBUS; 2048 + musb_writeb(musb->mregs, MUSB_ULPI_BUSCONTROL, busctl); 2049 + } 2050 } 2051 2052 /* For the host-only role, we can activate right away. ··· 2079 } 2080 2081 #ifdef CONFIG_SYSFS 2082 + status = sysfs_create_group(&musb->controller->kobj, &musb_attr_group); 2083 #endif 2084 if (status) 2085 goto fail2; 2086 2087 + dev_info(dev, "USB %s mode controller at %p using %s, IRQ %d\n", 2088 + ({char *s; 2089 + switch (musb->board_mode) { 2090 + case MUSB_HOST: s = "Host"; break; 2091 + case MUSB_PERIPHERAL: s = "Peripheral"; break; 2092 + default: s = "OTG"; break; 2093 + }; s; }), 2094 + ctrl, 2095 + (is_dma_capable() && musb->dma_controller) 2096 + ? "DMA" : "PIO", 2097 + musb->nIrq); 2098 + 2099 return 0; 2100 2101 fail2: 2102 musb_platform_exit(musb); 2103 fail: 2104 dev_err(musb->controller, ··· 2127 { 2128 struct device *dev = &pdev->dev; 2129 int irq = platform_get_irq(pdev, 0); 2130 + int status; 2131 struct resource *iomem; 2132 void __iomem *base; 2133 ··· 2134 if (!iomem || irq == 0) 2135 return -ENODEV; 2136 2137 + base = ioremap(iomem->start, resource_size(iomem)); 2138 if (!base) { 2139 dev_err(dev, "ioremap failed\n"); 2140 return -ENOMEM; ··· 2144 /* clobbered by use_dma=n */ 2145 orig_dma_mask = dev->dma_mask; 2146 #endif 2147 + 2148 + status = musb_init_controller(dev, irq, base); 2149 + if (status < 0) 2150 + iounmap(base); 2151 + 2152 + return status; 2153 } 2154 2155 static int __exit musb_remove(struct platform_device *pdev) ··· 2173 2174 #ifdef CONFIG_PM 2175 2176 + static struct musb_context_registers musb_context; 2177 + 2178 + void musb_save_context(struct musb *musb) 2179 + { 2180 + int i; 2181 + void __iomem *musb_base = musb->mregs; 2182 + 2183 + if (is_host_enabled(musb)) { 2184 + musb_context.frame = musb_readw(musb_base, MUSB_FRAME); 2185 + musb_context.testmode = musb_readb(musb_base, MUSB_TESTMODE); 2186 + } 2187 + musb_context.power = musb_readb(musb_base, MUSB_POWER); 2188 + musb_context.intrtxe = musb_readw(musb_base, MUSB_INTRTXE); 2189 + musb_context.intrrxe = musb_readw(musb_base, MUSB_INTRRXE); 2190 + musb_context.intrusbe = musb_readb(musb_base, MUSB_INTRUSBE); 2191 + musb_context.index = musb_readb(musb_base, MUSB_INDEX); 2192 + musb_context.devctl = musb_readb(musb_base, MUSB_DEVCTL); 2193 + 2194 + for (i = 0; i < MUSB_C_NUM_EPS; ++i) { 2195 + musb_writeb(musb_base, MUSB_INDEX, i); 2196 + musb_context.index_regs[i].txmaxp = 2197 + musb_readw(musb_base, 0x10 + MUSB_TXMAXP); 2198 + musb_context.index_regs[i].txcsr = 2199 + musb_readw(musb_base, 0x10 + MUSB_TXCSR); 2200 + musb_context.index_regs[i].rxmaxp = 2201 + musb_readw(musb_base, 0x10 + MUSB_RXMAXP); 2202 + musb_context.index_regs[i].rxcsr = 2203 + musb_readw(musb_base, 0x10 + MUSB_RXCSR); 2204 + 2205 + if (musb->dyn_fifo) { 2206 + musb_context.index_regs[i].txfifoadd = 2207 + musb_read_txfifoadd(musb_base); 2208 + musb_context.index_regs[i].rxfifoadd = 2209 + musb_read_rxfifoadd(musb_base); 2210 + musb_context.index_regs[i].txfifosz = 2211 + musb_read_txfifosz(musb_base); 2212 + musb_context.index_regs[i].rxfifosz = 2213 + musb_read_rxfifosz(musb_base); 2214 + } 2215 + if (is_host_enabled(musb)) { 2216 + musb_context.index_regs[i].txtype = 2217 + musb_readb(musb_base, 0x10 + MUSB_TXTYPE); 2218 + musb_context.index_regs[i].txinterval = 2219 + musb_readb(musb_base, 0x10 + MUSB_TXINTERVAL); 2220 + musb_context.index_regs[i].rxtype = 2221 + musb_readb(musb_base, 0x10 + MUSB_RXTYPE); 2222 + musb_context.index_regs[i].rxinterval = 2223 + musb_readb(musb_base, 0x10 + MUSB_RXINTERVAL); 2224 + 2225 + musb_context.index_regs[i].txfunaddr = 2226 + musb_read_txfunaddr(musb_base, i); 2227 + musb_context.index_regs[i].txhubaddr = 2228 + musb_read_txhubaddr(musb_base, i); 2229 + musb_context.index_regs[i].txhubport = 2230 + musb_read_txhubport(musb_base, i); 2231 + 2232 + musb_context.index_regs[i].rxfunaddr = 2233 + musb_read_rxfunaddr(musb_base, i); 2234 + musb_context.index_regs[i].rxhubaddr = 2235 + musb_read_rxhubaddr(musb_base, i); 2236 + musb_context.index_regs[i].rxhubport = 2237 + musb_read_rxhubport(musb_base, i); 2238 + } 2239 + } 2240 + 2241 + musb_writeb(musb_base, MUSB_INDEX, musb_context.index); 2242 + 2243 + musb_platform_save_context(musb, &musb_context); 2244 + } 2245 + 2246 + void musb_restore_context(struct musb *musb) 2247 + { 2248 + int i; 2249 + void __iomem *musb_base = musb->mregs; 2250 + void __iomem *ep_target_regs; 2251 + 2252 + musb_platform_restore_context(musb, &musb_context); 2253 + 2254 + if (is_host_enabled(musb)) { 2255 + musb_writew(musb_base, MUSB_FRAME, musb_context.frame); 2256 + musb_writeb(musb_base, MUSB_TESTMODE, musb_context.testmode); 2257 + } 2258 + musb_writeb(musb_base, MUSB_POWER, musb_context.power); 2259 + musb_writew(musb_base, MUSB_INTRTXE, musb_context.intrtxe); 2260 + musb_writew(musb_base, MUSB_INTRRXE, musb_context.intrrxe); 2261 + musb_writeb(musb_base, MUSB_INTRUSBE, musb_context.intrusbe); 2262 + musb_writeb(musb_base, MUSB_DEVCTL, musb_context.devctl); 2263 + 2264 + for (i = 0; i < MUSB_C_NUM_EPS; ++i) { 2265 + musb_writeb(musb_base, MUSB_INDEX, i); 2266 + musb_writew(musb_base, 0x10 + MUSB_TXMAXP, 2267 + musb_context.index_regs[i].txmaxp); 2268 + musb_writew(musb_base, 0x10 + MUSB_TXCSR, 2269 + musb_context.index_regs[i].txcsr); 2270 + musb_writew(musb_base, 0x10 + MUSB_RXMAXP, 2271 + musb_context.index_regs[i].rxmaxp); 2272 + musb_writew(musb_base, 0x10 + MUSB_RXCSR, 2273 + musb_context.index_regs[i].rxcsr); 2274 + 2275 + if (musb->dyn_fifo) { 2276 + musb_write_txfifosz(musb_base, 2277 + musb_context.index_regs[i].txfifosz); 2278 + musb_write_rxfifosz(musb_base, 2279 + musb_context.index_regs[i].rxfifosz); 2280 + musb_write_txfifoadd(musb_base, 2281 + musb_context.index_regs[i].txfifoadd); 2282 + musb_write_rxfifoadd(musb_base, 2283 + musb_context.index_regs[i].rxfifoadd); 2284 + } 2285 + 2286 + if (is_host_enabled(musb)) { 2287 + musb_writeb(musb_base, 0x10 + MUSB_TXTYPE, 2288 + musb_context.index_regs[i].txtype); 2289 + musb_writeb(musb_base, 0x10 + MUSB_TXINTERVAL, 2290 + musb_context.index_regs[i].txinterval); 2291 + musb_writeb(musb_base, 0x10 + MUSB_RXTYPE, 2292 + musb_context.index_regs[i].rxtype); 2293 + musb_writeb(musb_base, 0x10 + MUSB_RXINTERVAL, 2294 + 2295 + musb_context.index_regs[i].rxinterval); 2296 + musb_write_txfunaddr(musb_base, i, 2297 + musb_context.index_regs[i].txfunaddr); 2298 + musb_write_txhubaddr(musb_base, i, 2299 + musb_context.index_regs[i].txhubaddr); 2300 + musb_write_txhubport(musb_base, i, 2301 + musb_context.index_regs[i].txhubport); 2302 + 2303 + ep_target_regs = 2304 + musb_read_target_reg_base(i, musb_base); 2305 + 2306 + musb_write_rxfunaddr(ep_target_regs, 2307 + musb_context.index_regs[i].rxfunaddr); 2308 + musb_write_rxhubaddr(ep_target_regs, 2309 + musb_context.index_regs[i].rxhubaddr); 2310 + musb_write_rxhubport(ep_target_regs, 2311 + musb_context.index_regs[i].rxhubport); 2312 + } 2313 + } 2314 + 2315 + musb_writeb(musb_base, MUSB_INDEX, musb_context.index); 2316 + } 2317 + 2318 static int musb_suspend(struct device *dev) 2319 { 2320 struct platform_device *pdev = to_platform_device(dev); ··· 2194 */ 2195 } 2196 2197 + musb_save_context(musb); 2198 + 2199 if (musb->set_clock) 2200 musb->set_clock(musb->clock, 0); 2201 else ··· 2214 musb->set_clock(musb->clock, 1); 2215 else 2216 clk_enable(musb->clock); 2217 + 2218 + musb_restore_context(musb); 2219 2220 /* for static cmos like DaVinci, register values were preserved 2221 * unless for some reason the whole soc powered down or the USB
+53 -19
drivers/usb/musb/musb_core.h
··· 52 struct musb_hw_ep; 53 struct musb_ep; 54 55 56 #include "musb_debug.h" 57 #include "musb_dma.h" ··· 331 struct clk *clock; 332 irqreturn_t (*isr)(int, void *); 333 struct work_struct irq_work; 334 - #define MUSB_HWVERS_MAJOR(x) ((x >> 10) & 0x1f) 335 - #define MUSB_HWVERS_MINOR(x) (x & 0x3ff) 336 - #define MUSB_HWVERS_RC 0x8000 337 - #define MUSB_HWVERS_1300 0x52C 338 - #define MUSB_HWVERS_1400 0x590 339 - #define MUSB_HWVERS_1800 0x720 340 - #define MUSB_HWVERS_2000 0x800 341 u16 hwvers; 342 343 /* this hub status bit is reserved by USB 2.0 and not seen by usbcore */ ··· 413 414 unsigned hb_iso_rx:1; /* high bandwidth iso rx? */ 415 unsigned hb_iso_tx:1; /* high bandwidth iso tx? */ 416 417 - #ifdef C_MP_TX 418 - unsigned bulk_split:1; 419 #define can_bulk_split(musb,type) \ 420 - (((type) == USB_ENDPOINT_XFER_BULK) && (musb)->bulk_split) 421 - #else 422 - #define can_bulk_split(musb, type) 0 423 - #endif 424 425 - #ifdef C_MP_RX 426 - unsigned bulk_combine:1; 427 #define can_bulk_combine(musb,type) \ 428 - (((type) == USB_ENDPOINT_XFER_BULK) && (musb)->bulk_combine) 429 - #else 430 - #define can_bulk_combine(musb, type) 0 431 - #endif 432 433 #ifdef CONFIG_USB_GADGET_MUSB_HDRC 434 /* is_suspended means USB B_PERIPHERAL suspend */ ··· 455 struct proc_dir_entry *proc_entry; 456 #endif 457 }; 458 459 static inline void musb_set_vbus(struct musb *musb, int is_on) 460 {
··· 52 struct musb_hw_ep; 53 struct musb_ep; 54 55 + /* Helper defines for struct musb->hwvers */ 56 + #define MUSB_HWVERS_MAJOR(x) ((x >> 10) & 0x1f) 57 + #define MUSB_HWVERS_MINOR(x) (x & 0x3ff) 58 + #define MUSB_HWVERS_RC 0x8000 59 + #define MUSB_HWVERS_1300 0x52C 60 + #define MUSB_HWVERS_1400 0x590 61 + #define MUSB_HWVERS_1800 0x720 62 + #define MUSB_HWVERS_1900 0x784 63 + #define MUSB_HWVERS_2000 0x800 64 65 #include "musb_debug.h" 66 #include "musb_dma.h" ··· 322 struct clk *clock; 323 irqreturn_t (*isr)(int, void *); 324 struct work_struct irq_work; 325 u16 hwvers; 326 327 /* this hub status bit is reserved by USB 2.0 and not seen by usbcore */ ··· 411 412 unsigned hb_iso_rx:1; /* high bandwidth iso rx? */ 413 unsigned hb_iso_tx:1; /* high bandwidth iso tx? */ 414 + unsigned dyn_fifo:1; /* dynamic FIFO supported? */ 415 416 + unsigned bulk_split:1; 417 #define can_bulk_split(musb,type) \ 418 + (((type) == USB_ENDPOINT_XFER_BULK) && (musb)->bulk_split) 419 420 + unsigned bulk_combine:1; 421 #define can_bulk_combine(musb,type) \ 422 + (((type) == USB_ENDPOINT_XFER_BULK) && (musb)->bulk_combine) 423 424 #ifdef CONFIG_USB_GADGET_MUSB_HDRC 425 /* is_suspended means USB B_PERIPHERAL suspend */ ··· 460 struct proc_dir_entry *proc_entry; 461 #endif 462 }; 463 + 464 + #ifdef CONFIG_PM 465 + struct musb_csr_regs { 466 + /* FIFO registers */ 467 + u16 txmaxp, txcsr, rxmaxp, rxcsr; 468 + u16 rxfifoadd, txfifoadd; 469 + u8 txtype, txinterval, rxtype, rxinterval; 470 + u8 rxfifosz, txfifosz; 471 + u8 txfunaddr, txhubaddr, txhubport; 472 + u8 rxfunaddr, rxhubaddr, rxhubport; 473 + }; 474 + 475 + struct musb_context_registers { 476 + 477 + #if defined(CONFIG_ARCH_OMAP34XX) || defined(CONFIG_ARCH_OMAP2430) 478 + u32 otg_sysconfig, otg_forcestandby; 479 + #endif 480 + u8 power; 481 + u16 intrtxe, intrrxe; 482 + u8 intrusbe; 483 + u16 frame; 484 + u8 index, testmode; 485 + 486 + u8 devctl, misc; 487 + 488 + struct musb_csr_regs index_regs[MUSB_C_NUM_EPS]; 489 + }; 490 + 491 + #if defined(CONFIG_ARCH_OMAP34XX) || defined(CONFIG_ARCH_OMAP2430) 492 + extern void musb_platform_save_context(struct musb *musb, 493 + struct musb_context_registers *musb_context); 494 + extern void musb_platform_restore_context(struct musb *musb, 495 + struct musb_context_registers *musb_context); 496 + #else 497 + #define musb_platform_save_context(m, x) do {} while (0) 498 + #define musb_platform_restore_context(m, x) do {} while (0) 499 + #endif 500 + 501 + #endif 502 503 static inline void musb_set_vbus(struct musb *musb, int is_on) 504 {
+16 -4
drivers/usb/musb/musb_gadget.c
··· 895 /* REVISIT if can_bulk_split(), use by updating "tmp"; 896 * likewise high bandwidth periodic tx 897 */ 898 - musb_writew(regs, MUSB_TXMAXP, tmp); 899 900 csr = MUSB_TXCSR_MODE | MUSB_TXCSR_CLRDATATOG; 901 if (musb_readw(regs, MUSB_TXCSR) ··· 932 /* REVISIT if can_bulk_combine() use by updating "tmp" 933 * likewise high bandwidth periodic rx 934 */ 935 - musb_writew(regs, MUSB_RXMAXP, tmp); 936 937 /* force shared fifo to OUT-only mode */ 938 if (hw_ep->is_shared_fifo) { ··· 1710 return -EINVAL; 1711 1712 /* driver must be initialized to support peripheral mode */ 1713 - if (!musb || !(musb->board_mode == MUSB_OTG 1714 - || musb->board_mode != MUSB_OTG)) { 1715 DBG(1, "%s, no dev??\n", __func__); 1716 return -ENODEV; 1717 }
··· 895 /* REVISIT if can_bulk_split(), use by updating "tmp"; 896 * likewise high bandwidth periodic tx 897 */ 898 + /* Set TXMAXP with the FIFO size of the endpoint 899 + * to disable double buffering mode. Currently, It seems that double 900 + * buffering has problem if musb RTL revision number < 2.0. 901 + */ 902 + if (musb->hwvers < MUSB_HWVERS_2000) 903 + musb_writew(regs, MUSB_TXMAXP, hw_ep->max_packet_sz_tx); 904 + else 905 + musb_writew(regs, MUSB_TXMAXP, tmp); 906 907 csr = MUSB_TXCSR_MODE | MUSB_TXCSR_CLRDATATOG; 908 if (musb_readw(regs, MUSB_TXCSR) ··· 925 /* REVISIT if can_bulk_combine() use by updating "tmp" 926 * likewise high bandwidth periodic rx 927 */ 928 + /* Set RXMAXP with the FIFO size of the endpoint 929 + * to disable double buffering mode. 930 + */ 931 + if (musb->hwvers < MUSB_HWVERS_2000) 932 + musb_writew(regs, MUSB_RXMAXP, hw_ep->max_packet_sz_rx); 933 + else 934 + musb_writew(regs, MUSB_RXMAXP, tmp); 935 936 /* force shared fifo to OUT-only mode */ 937 if (hw_ep->is_shared_fifo) { ··· 1697 return -EINVAL; 1698 1699 /* driver must be initialized to support peripheral mode */ 1700 + if (!musb) { 1701 DBG(1, "%s, no dev??\n", __func__); 1702 return -ENODEV; 1703 }
+32 -2
drivers/usb/musb/musb_host.c
··· 605 musb_writeb(ep->regs, MUSB_RXTYPE, qh->type_reg); 606 musb_writeb(ep->regs, MUSB_RXINTERVAL, qh->intv_reg); 607 /* NOTE: bulk combining rewrites high bits of maxpacket */ 608 - musb_writew(ep->regs, MUSB_RXMAXP, 609 - qh->maxpacket | ((qh->hb_mult - 1) << 11)); 610 611 ep->rx_reinit = 0; 612 } ··· 1777 int best_end, epnum; 1778 struct musb_hw_ep *hw_ep = NULL; 1779 struct list_head *head = NULL; 1780 1781 /* use fixed hardware for control and bulk */ 1782 if (qh->type == USB_ENDPOINT_XFER_CONTROL) { ··· 1818 diff -= (qh->maxpacket * qh->hb_mult); 1819 1820 if (diff >= 0 && best_diff > diff) { 1821 best_diff = diff; 1822 best_end = epnum; 1823 }
··· 605 musb_writeb(ep->regs, MUSB_RXTYPE, qh->type_reg); 606 musb_writeb(ep->regs, MUSB_RXINTERVAL, qh->intv_reg); 607 /* NOTE: bulk combining rewrites high bits of maxpacket */ 608 + /* Set RXMAXP with the FIFO size of the endpoint 609 + * to disable double buffer mode. 610 + */ 611 + if (musb->hwvers < MUSB_HWVERS_2000) 612 + musb_writew(ep->regs, MUSB_RXMAXP, ep->max_packet_sz_rx); 613 + else 614 + musb_writew(ep->regs, MUSB_RXMAXP, 615 + qh->maxpacket | ((qh->hb_mult - 1) << 11)); 616 617 ep->rx_reinit = 0; 618 } ··· 1771 int best_end, epnum; 1772 struct musb_hw_ep *hw_ep = NULL; 1773 struct list_head *head = NULL; 1774 + u8 toggle; 1775 + u8 txtype; 1776 + struct urb *urb = next_urb(qh); 1777 1778 /* use fixed hardware for control and bulk */ 1779 if (qh->type == USB_ENDPOINT_XFER_CONTROL) { ··· 1809 diff -= (qh->maxpacket * qh->hb_mult); 1810 1811 if (diff >= 0 && best_diff > diff) { 1812 + 1813 + /* 1814 + * Mentor controller has a bug in that if we schedule 1815 + * a BULK Tx transfer on an endpoint that had earlier 1816 + * handled ISOC then the BULK transfer has to start on 1817 + * a zero toggle. If the BULK transfer starts on a 1 1818 + * toggle then this transfer will fail as the mentor 1819 + * controller starts the Bulk transfer on a 0 toggle 1820 + * irrespective of the programming of the toggle bits 1821 + * in the TXCSR register. Check for this condition 1822 + * while allocating the EP for a Tx Bulk transfer. If 1823 + * so skip this EP. 1824 + */ 1825 + hw_ep = musb->endpoints + epnum; 1826 + toggle = usb_gettoggle(urb->dev, qh->epnum, !is_in); 1827 + txtype = (musb_readb(hw_ep->regs, MUSB_TXTYPE) 1828 + >> 4) & 0x3; 1829 + if (!is_in && (qh->type == USB_ENDPOINT_XFER_BULK) && 1830 + toggle && (txtype == USB_ENDPOINT_XFER_ISOC)) 1831 + continue; 1832 + 1833 best_diff = diff; 1834 best_end = epnum; 1835 }
+100 -1
drivers/usb/musb/musb_regs.h
··· 72 #define MUSB_DEVCTL_HR 0x02 73 #define MUSB_DEVCTL_SESSION 0x01 74 75 /* TESTMODE */ 76 #define MUSB_TEST_FORCE_HOST 0x80 77 #define MUSB_TEST_FIFO_ACCESS 0x40 ··· 250 251 /* REVISIT: vctrl/vstatus: optional vendor utmi+phy register at 0x68 */ 252 #define MUSB_HWVERS 0x6C /* 8 bit */ 253 254 #define MUSB_EPINFO 0x78 /* 8 bit */ 255 #define MUSB_RAMINFO 0x79 /* 8 bit */ ··· 326 musb_writew(mbase, MUSB_RXFIFOADD, c_off); 327 } 328 329 static inline u8 musb_read_configdata(void __iomem *mbase) 330 { 331 musb_writeb(mbase, MUSB_INDEX, 0); ··· 399 { 400 musb_writeb(mbase, MUSB_BUSCTL_OFFSET(epnum, MUSB_TXHUBPORT), 401 qh_h_port_reg); 402 } 403 404 #else /* CONFIG_BLACKFIN */ ··· 510 { 511 } 512 513 static inline u8 musb_read_configdata(void __iomem *mbase) 514 { 515 return 0; ··· 533 534 static inline u16 musb_read_hwvers(void __iomem *mbase) 535 { 536 - return 0; 537 } 538 539 static inline void __iomem *musb_read_target_reg_base(u8 i, void __iomem *mbase) ··· 572 573 static inline void musb_write_txhubport(void __iomem *mbase, u8 epnum, 574 u8 qh_h_port_reg) 575 { 576 } 577
··· 72 #define MUSB_DEVCTL_HR 0x02 73 #define MUSB_DEVCTL_SESSION 0x01 74 75 + /* MUSB ULPI VBUSCONTROL */ 76 + #define MUSB_ULPI_USE_EXTVBUS 0x01 77 + #define MUSB_ULPI_USE_EXTVBUSIND 0x02 78 + 79 /* TESTMODE */ 80 #define MUSB_TEST_FORCE_HOST 0x80 81 #define MUSB_TEST_FIFO_ACCESS 0x40 ··· 246 247 /* REVISIT: vctrl/vstatus: optional vendor utmi+phy register at 0x68 */ 248 #define MUSB_HWVERS 0x6C /* 8 bit */ 249 + #define MUSB_ULPI_BUSCONTROL 0x70 /* 8 bit */ 250 251 #define MUSB_EPINFO 0x78 /* 8 bit */ 252 #define MUSB_RAMINFO 0x79 /* 8 bit */ ··· 321 musb_writew(mbase, MUSB_RXFIFOADD, c_off); 322 } 323 324 + static inline u8 musb_read_txfifosz(void __iomem *mbase) 325 + { 326 + return musb_readb(mbase, MUSB_TXFIFOSZ); 327 + } 328 + 329 + static inline u16 musb_read_txfifoadd(void __iomem *mbase) 330 + { 331 + return musb_readw(mbase, MUSB_TXFIFOADD); 332 + } 333 + 334 + static inline u8 musb_read_rxfifosz(void __iomem *mbase) 335 + { 336 + return musb_readb(mbase, MUSB_RXFIFOSZ); 337 + } 338 + 339 + static inline u16 musb_read_rxfifoadd(void __iomem *mbase) 340 + { 341 + return musb_readw(mbase, MUSB_RXFIFOADD); 342 + } 343 + 344 static inline u8 musb_read_configdata(void __iomem *mbase) 345 { 346 musb_writeb(mbase, MUSB_INDEX, 0); ··· 374 { 375 musb_writeb(mbase, MUSB_BUSCTL_OFFSET(epnum, MUSB_TXHUBPORT), 376 qh_h_port_reg); 377 + } 378 + 379 + static inline u8 musb_read_rxfunaddr(void __iomem *mbase, u8 epnum) 380 + { 381 + return musb_readb(mbase, MUSB_BUSCTL_OFFSET(epnum, MUSB_RXFUNCADDR)); 382 + } 383 + 384 + static inline u8 musb_read_rxhubaddr(void __iomem *mbase, u8 epnum) 385 + { 386 + return musb_readb(mbase, MUSB_BUSCTL_OFFSET(epnum, MUSB_RXHUBADDR)); 387 + } 388 + 389 + static inline u8 musb_read_rxhubport(void __iomem *mbase, u8 epnum) 390 + { 391 + return musb_readb(mbase, MUSB_BUSCTL_OFFSET(epnum, MUSB_RXHUBPORT)); 392 + } 393 + 394 + static inline u8 musb_read_txfunaddr(void __iomem *mbase, u8 epnum) 395 + { 396 + return musb_readb(mbase, MUSB_BUSCTL_OFFSET(epnum, MUSB_TXFUNCADDR)); 397 + } 398 + 399 + static inline u8 musb_read_txhubaddr(void __iomem *mbase, u8 epnum) 400 + { 401 + return musb_readb(mbase, MUSB_BUSCTL_OFFSET(epnum, MUSB_TXHUBADDR)); 402 + } 403 + 404 + static inline u8 musb_read_txhubport(void __iomem *mbase, u8 epnum) 405 + { 406 + return musb_readb(mbase, MUSB_BUSCTL_OFFSET(epnum, MUSB_TXHUBPORT)); 407 } 408 409 #else /* CONFIG_BLACKFIN */ ··· 455 { 456 } 457 458 + static inline u8 musb_read_txfifosz(void __iomem *mbase) 459 + { 460 + } 461 + 462 + static inline u16 musb_read_txfifoadd(void __iomem *mbase) 463 + { 464 + } 465 + 466 + static inline u8 musb_read_rxfifosz(void __iomem *mbase) 467 + { 468 + } 469 + 470 + static inline u16 musb_read_rxfifoadd(void __iomem *mbase) 471 + { 472 + } 473 + 474 static inline u8 musb_read_configdata(void __iomem *mbase) 475 { 476 return 0; ··· 462 463 static inline u16 musb_read_hwvers(void __iomem *mbase) 464 { 465 + /* 466 + * This register is invisible on Blackfin, actually the MUSB 467 + * RTL version of Blackfin is 1.9, so just harcode its value. 468 + */ 469 + return MUSB_HWVERS_1900; 470 } 471 472 static inline void __iomem *musb_read_target_reg_base(u8 i, void __iomem *mbase) ··· 497 498 static inline void musb_write_txhubport(void __iomem *mbase, u8 epnum, 499 u8 qh_h_port_reg) 500 + { 501 + } 502 + 503 + static inline u8 musb_read_rxfunaddr(void __iomem *mbase, u8 epnum) 504 + { 505 + } 506 + 507 + static inline u8 musb_read_rxhubaddr(void __iomem *mbase, u8 epnum) 508 + { 509 + } 510 + 511 + static inline u8 musb_read_rxhubport(void __iomem *mbase, u8 epnum) 512 + { 513 + } 514 + 515 + static inline u8 musb_read_txfunaddr(void __iomem *mbase, u8 epnum) 516 + { 517 + } 518 + 519 + static inline u8 musb_read_txhubaddr(void __iomem *mbase, u8 epnum) 520 + { 521 + } 522 + 523 + static inline void musb_read_txhubport(void __iomem *mbase, u8 epnum) 524 { 525 } 526
+22 -3
drivers/usb/musb/musbhsdma.c
··· 250 u8 bchannel; 251 u8 int_hsdma; 252 253 - u32 addr; 254 u16 csr; 255 256 spin_lock_irqsave(&musb->lock, flags); 257 258 int_hsdma = musb_readb(mbase, MUSB_HSDMA_INTR); 259 - if (!int_hsdma) 260 - goto done; 261 262 #ifdef CONFIG_BLACKFIN 263 /* Clear DMA interrupt flags */ 264 musb_writeb(mbase, MUSB_HSDMA_INTR, int_hsdma); 265 #endif 266 267 for (bchannel = 0; bchannel < MUSB_HSDMA_CHANNELS; bchannel++) { 268 if (int_hsdma & (1 << bchannel)) {
··· 250 u8 bchannel; 251 u8 int_hsdma; 252 253 + u32 addr, count; 254 u16 csr; 255 256 spin_lock_irqsave(&musb->lock, flags); 257 258 int_hsdma = musb_readb(mbase, MUSB_HSDMA_INTR); 259 260 #ifdef CONFIG_BLACKFIN 261 /* Clear DMA interrupt flags */ 262 musb_writeb(mbase, MUSB_HSDMA_INTR, int_hsdma); 263 #endif 264 + 265 + if (!int_hsdma) { 266 + DBG(2, "spurious DMA irq\n"); 267 + 268 + for (bchannel = 0; bchannel < MUSB_HSDMA_CHANNELS; bchannel++) { 269 + musb_channel = (struct musb_dma_channel *) 270 + &(controller->channel[bchannel]); 271 + channel = &musb_channel->channel; 272 + if (channel->status == MUSB_DMA_STATUS_BUSY) { 273 + count = musb_read_hsdma_count(mbase, bchannel); 274 + 275 + if (count == 0) 276 + int_hsdma |= (1 << bchannel); 277 + } 278 + } 279 + 280 + DBG(2, "int_hsdma = 0x%x\n", int_hsdma); 281 + 282 + if (!int_hsdma) 283 + goto done; 284 + } 285 286 for (bchannel = 0; bchannel < MUSB_HSDMA_CHANNELS; bchannel++) { 287 if (int_hsdma & (1 << bchannel)) {
+17
drivers/usb/musb/musbhsdma.h
··· 55 MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_ADDRESS), \ 56 addr) 57 58 #define musb_write_hsdma_count(mbase, bchannel, len) \ 59 musb_writel(mbase, \ 60 MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_COUNT), \ ··· 98 musb_writew(mbase, 99 MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_ADDR_HIGH), 100 ((u16)(((u32) dma_addr >> 16) & 0xFFFF))); 101 } 102 103 static inline void musb_write_hsdma_count(void __iomem *mbase,
··· 55 MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_ADDRESS), \ 56 addr) 57 58 + #define musb_read_hsdma_count(mbase, bchannel) \ 59 + musb_readl(mbase, \ 60 + MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_COUNT)) 61 + 62 #define musb_write_hsdma_count(mbase, bchannel, len) \ 63 musb_writel(mbase, \ 64 MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_COUNT), \ ··· 94 musb_writew(mbase, 95 MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_ADDR_HIGH), 96 ((u16)(((u32) dma_addr >> 16) & 0xFFFF))); 97 + } 98 + 99 + static inline u32 musb_read_hsdma_count(void __iomem *mbase, u8 bchannel) 100 + { 101 + u32 count = musb_readw(mbase, 102 + MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_COUNT_HIGH)); 103 + 104 + count = count << 16; 105 + 106 + count |= musb_readw(mbase, 107 + MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_COUNT_LOW)); 108 + 109 + return count; 110 } 111 112 static inline void musb_write_hsdma_count(void __iomem *mbase,
+33 -15
drivers/usb/musb/omap2430.c
··· 220 221 musb_platform_resume(musb); 222 223 - l = omap_readl(OTG_SYSCONFIG); 224 l &= ~ENABLEWAKEUP; /* disable wakeup */ 225 l &= ~NOSTDBY; /* remove possible nostdby */ 226 l |= SMARTSTDBY; /* enable smart standby */ ··· 233 */ 234 if (!cpu_is_omap3430()) 235 l |= AUTOIDLE; /* enable auto idle */ 236 - omap_writel(l, OTG_SYSCONFIG); 237 238 - l = omap_readl(OTG_INTERFSEL); 239 l |= ULPI_12PIN; 240 - omap_writel(l, OTG_INTERFSEL); 241 242 pr_debug("HS USB OTG: revision 0x%x, sysconfig 0x%02x, " 243 "sysstatus 0x%x, intrfsel 0x%x, simenable 0x%x\n", 244 - omap_readl(OTG_REVISION), omap_readl(OTG_SYSCONFIG), 245 - omap_readl(OTG_SYSSTATUS), omap_readl(OTG_INTERFSEL), 246 - omap_readl(OTG_SIMENABLE)); 247 248 omap_vbus_power(musb, musb->board_mode == MUSB_HOST, 1); 249 ··· 257 return 0; 258 } 259 260 int musb_platform_suspend(struct musb *musb) 261 { 262 u32 l; ··· 281 return 0; 282 283 /* in any role */ 284 - l = omap_readl(OTG_FORCESTDBY); 285 l |= ENABLEFORCE; /* enable MSTANDBY */ 286 - omap_writel(l, OTG_FORCESTDBY); 287 288 - l = omap_readl(OTG_SYSCONFIG); 289 l |= ENABLEWAKEUP; /* enable wakeup */ 290 - omap_writel(l, OTG_SYSCONFIG); 291 292 otg_set_suspend(musb->xceiv, 1); 293 ··· 313 else 314 clk_enable(musb->clock); 315 316 - l = omap_readl(OTG_SYSCONFIG); 317 l &= ~ENABLEWAKEUP; /* disable wakeup */ 318 - omap_writel(l, OTG_SYSCONFIG); 319 320 - l = omap_readl(OTG_FORCESTDBY); 321 l &= ~ENABLEFORCE; /* disable MSTANDBY */ 322 - omap_writel(l, OTG_FORCESTDBY); 323 324 return 0; 325 }
··· 220 221 musb_platform_resume(musb); 222 223 + l = musb_readl(musb->mregs, OTG_SYSCONFIG); 224 l &= ~ENABLEWAKEUP; /* disable wakeup */ 225 l &= ~NOSTDBY; /* remove possible nostdby */ 226 l |= SMARTSTDBY; /* enable smart standby */ ··· 233 */ 234 if (!cpu_is_omap3430()) 235 l |= AUTOIDLE; /* enable auto idle */ 236 + musb_writel(musb->mregs, OTG_SYSCONFIG, l); 237 238 + l = musb_readl(musb->mregs, OTG_INTERFSEL); 239 l |= ULPI_12PIN; 240 + musb_writel(musb->mregs, OTG_INTERFSEL, l); 241 242 pr_debug("HS USB OTG: revision 0x%x, sysconfig 0x%02x, " 243 "sysstatus 0x%x, intrfsel 0x%x, simenable 0x%x\n", 244 + musb_readl(musb->mregs, OTG_REVISION), 245 + musb_readl(musb->mregs, OTG_SYSCONFIG), 246 + musb_readl(musb->mregs, OTG_SYSSTATUS), 247 + musb_readl(musb->mregs, OTG_INTERFSEL), 248 + musb_readl(musb->mregs, OTG_SIMENABLE)); 249 250 omap_vbus_power(musb, musb->board_mode == MUSB_HOST, 1); 251 ··· 255 return 0; 256 } 257 258 + #ifdef CONFIG_PM 259 + void musb_platform_save_context(struct musb *musb, 260 + struct musb_context_registers *musb_context) 261 + { 262 + musb_context->otg_sysconfig = musb_readl(musb->mregs, OTG_SYSCONFIG); 263 + musb_context->otg_forcestandby = musb_readl(musb->mregs, OTG_FORCESTDBY); 264 + } 265 + 266 + void musb_platform_restore_context(struct musb *musb, 267 + struct musb_context_registers *musb_context) 268 + { 269 + musb_writel(musb->mregs, OTG_SYSCONFIG, musb_context->otg_sysconfig); 270 + musb_writel(musb->mregs, OTG_FORCESTDBY, musb_context->otg_forcestandby); 271 + } 272 + #endif 273 + 274 int musb_platform_suspend(struct musb *musb) 275 { 276 u32 l; ··· 263 return 0; 264 265 /* in any role */ 266 + l = musb_readl(musb->mregs, OTG_FORCESTDBY); 267 l |= ENABLEFORCE; /* enable MSTANDBY */ 268 + musb_writel(musb->mregs, OTG_FORCESTDBY, l); 269 270 + l = musb_readl(musb->mregs, OTG_SYSCONFIG); 271 l |= ENABLEWAKEUP; /* enable wakeup */ 272 + musb_writel(musb->mregs, OTG_SYSCONFIG, l); 273 274 otg_set_suspend(musb->xceiv, 1); 275 ··· 295 else 296 clk_enable(musb->clock); 297 298 + l = musb_readl(musb->mregs, OTG_SYSCONFIG); 299 l &= ~ENABLEWAKEUP; /* disable wakeup */ 300 + musb_writel(musb->mregs, OTG_SYSCONFIG, l); 301 302 + l = musb_readl(musb->mregs, OTG_FORCESTDBY); 303 l &= ~ENABLEFORCE; /* disable MSTANDBY */ 304 + musb_writel(musb->mregs, OTG_FORCESTDBY, l); 305 306 return 0; 307 }
+15 -19
drivers/usb/musb/omap2430.h
··· 10 #ifndef __MUSB_OMAP243X_H__ 11 #define __MUSB_OMAP243X_H__ 12 13 - #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3430) 14 - #include <mach/hardware.h> 15 #include <plat/usb.h> 16 17 /* 18 * OMAP2430-specific definitions 19 */ 20 21 - #define MENTOR_BASE_OFFSET 0 22 - #if defined(CONFIG_ARCH_OMAP2430) 23 - #define OMAP_HSOTG_BASE (OMAP243X_HS_BASE) 24 - #elif defined(CONFIG_ARCH_OMAP3430) 25 - #define OMAP_HSOTG_BASE (OMAP34XX_HSUSB_OTG_BASE) 26 - #endif 27 - #define OMAP_HSOTG(offset) (OMAP_HSOTG_BASE + 0x400 + (offset)) 28 - #define OTG_REVISION OMAP_HSOTG(0x0) 29 - #define OTG_SYSCONFIG OMAP_HSOTG(0x4) 30 # define MIDLEMODE 12 /* bit position */ 31 # define FORCESTDBY (0 << MIDLEMODE) 32 # define NOSTDBY (1 << MIDLEMODE) 33 # define SMARTSTDBY (2 << MIDLEMODE) 34 # define SIDLEMODE 3 /* bit position */ 35 # define FORCEIDLE (0 << SIDLEMODE) 36 # define NOIDLE (1 << SIDLEMODE) 37 # define SMARTIDLE (2 << SIDLEMODE) 38 # define ENABLEWAKEUP (1 << 2) 39 # define SOFTRST (1 << 1) 40 # define AUTOIDLE (1 << 0) 41 - #define OTG_SYSSTATUS OMAP_HSOTG(0x8) 42 # define RESETDONE (1 << 0) 43 - #define OTG_INTERFSEL OMAP_HSOTG(0xc) 44 # define EXTCP (1 << 2) 45 - # define PHYSEL 0 /* bit position */ 46 # define UTMI_8BIT (0 << PHYSEL) 47 # define ULPI_12PIN (1 << PHYSEL) 48 # define ULPI_8PIN (2 << PHYSEL) 49 - #define OTG_SIMENABLE OMAP_HSOTG(0x10) 50 - # define TM1 (1 << 0) 51 - #define OTG_FORCESTDBY OMAP_HSOTG(0x14) 52 - # define ENABLEFORCE (1 << 0) 53 54 - #endif /* CONFIG_ARCH_OMAP2430 */ 55 56 #endif /* __MUSB_OMAP243X_H__ */
··· 10 #ifndef __MUSB_OMAP243X_H__ 11 #define __MUSB_OMAP243X_H__ 12 13 #include <plat/usb.h> 14 15 /* 16 * OMAP2430-specific definitions 17 */ 18 19 + #define OTG_REVISION 0x400 20 + 21 + #define OTG_SYSCONFIG 0x404 22 # define MIDLEMODE 12 /* bit position */ 23 # define FORCESTDBY (0 << MIDLEMODE) 24 # define NOSTDBY (1 << MIDLEMODE) 25 # define SMARTSTDBY (2 << MIDLEMODE) 26 + 27 # define SIDLEMODE 3 /* bit position */ 28 # define FORCEIDLE (0 << SIDLEMODE) 29 # define NOIDLE (1 << SIDLEMODE) 30 # define SMARTIDLE (2 << SIDLEMODE) 31 + 32 # define ENABLEWAKEUP (1 << 2) 33 # define SOFTRST (1 << 1) 34 # define AUTOIDLE (1 << 0) 35 + 36 + #define OTG_SYSSTATUS 0x408 37 # define RESETDONE (1 << 0) 38 + 39 + #define OTG_INTERFSEL 0x40c 40 # define EXTCP (1 << 2) 41 + # define PHYSEL 0 /* bit position */ 42 # define UTMI_8BIT (0 << PHYSEL) 43 # define ULPI_12PIN (1 << PHYSEL) 44 # define ULPI_8PIN (2 << PHYSEL) 45 46 + #define OTG_SIMENABLE 0x410 47 + # define TM1 (1 << 0) 48 + 49 + #define OTG_FORCESTDBY 0x414 50 + # define ENABLEFORCE (1 << 0) 51 52 #endif /* __MUSB_OMAP243X_H__ */
+1 -1
drivers/usb/musb/tusb6010.c
··· 1118 } 1119 musb->sync = mem->start; 1120 1121 - sync = ioremap(mem->start, mem->end - mem->start + 1); 1122 if (!sync) { 1123 pr_debug("ioremap for sync failed\n"); 1124 ret = -ENOMEM;
··· 1118 } 1119 musb->sync = mem->start; 1120 1121 + sync = ioremap(mem->start, resource_size(mem)); 1122 if (!sync) { 1123 pr_debug("ioremap for sync failed\n"); 1124 ret = -ENOMEM;
+1 -1
drivers/usb/musb/tusb6010_omap.c
··· 648 } 649 } 650 651 - if (!tusb_dma->multichannel && tusb_dma && tusb_dma->ch >= 0) 652 omap_free_dma(tusb_dma->ch); 653 654 kfree(tusb_dma);
··· 648 } 649 } 650 651 + if (tusb_dma && !tusb_dma->multichannel && tusb_dma->ch >= 0) 652 omap_free_dma(tusb_dma->ch); 653 654 kfree(tusb_dma);
+15 -30
drivers/usb/otg/twl4030-usb.c
··· 36 #include <linux/i2c/twl.h> 37 #include <linux/regulator/consumer.h> 38 #include <linux/err.h> 39 - 40 41 /* Register defines */ 42 ··· 236 #define PMBR1 0x0D 237 #define GPIO_USB_4PIN_ULPI_2430C (3 << 0) 238 239 - 240 - 241 - enum linkstat { 242 - USB_LINK_UNKNOWN = 0, 243 - USB_LINK_NONE, 244 - USB_LINK_VBUS, 245 - USB_LINK_ID, 246 - }; 247 - 248 struct twl4030_usb { 249 struct otg_transceiver otg; 250 struct device *dev; ··· 338 339 /*-------------------------------------------------------------------------*/ 340 341 - static enum linkstat twl4030_usb_linkstat(struct twl4030_usb *twl) 342 { 343 int status; 344 - int linkstat = USB_LINK_UNKNOWN; 345 346 /* 347 * For ID/VBUS sensing, see manual section 15.4.8 ... ··· 359 dev_err(twl->dev, "USB link status err %d\n", status); 360 else if (status & (BIT(7) | BIT(2))) { 361 if (status & BIT(2)) 362 - linkstat = USB_LINK_ID; 363 else 364 - linkstat = USB_LINK_VBUS; 365 } else 366 - linkstat = USB_LINK_NONE; 367 368 dev_dbg(twl->dev, "HW_CONDITIONS 0x%02x/%d; link %d\n", 369 status, status, linkstat); ··· 374 375 spin_lock_irq(&twl->lock); 376 twl->linkstat = linkstat; 377 - if (linkstat == USB_LINK_ID) { 378 twl->otg.default_a = true; 379 twl->otg.state = OTG_STATE_A_IDLE; 380 } else { ··· 555 556 spin_lock_irqsave(&twl->lock, flags); 557 ret = sprintf(buf, "%s\n", 558 - (twl->linkstat == USB_LINK_VBUS) ? "on" : "off"); 559 spin_unlock_irqrestore(&twl->lock, flags); 560 561 return ret; ··· 567 struct twl4030_usb *twl = _twl; 568 int status; 569 570 - #ifdef CONFIG_LOCKDEP 571 - /* WORKAROUND for lockdep forcing IRQF_DISABLED on us, which 572 - * we don't want and can't tolerate. Although it might be 573 - * friendlier not to borrow this thread context... 574 - */ 575 - local_irq_enable(); 576 - #endif 577 - 578 status = twl4030_usb_linkstat(twl); 579 - if (status != USB_LINK_UNKNOWN) { 580 - 581 /* FIXME add a set_power() method so that B-devices can 582 * configure the charger appropriately. It's not always 583 * correct to consume VBUS power, and how much current to ··· 580 * USB_LINK_VBUS state. musb_hdrc won't care until it 581 * starts to handle softconnect right. 582 */ 583 - if (status == USB_LINK_NONE) 584 twl4030_phy_suspend(twl, 0); 585 else 586 twl4030_phy_resume(twl); 587 588 - twl4030charger_usb_en(status == USB_LINK_VBUS); 589 } 590 sysfs_notify(&twl->dev->kobj, NULL, "vbus"); 591 ··· 676 if (device_create_file(&pdev->dev, &dev_attr_vbus)) 677 dev_warn(&pdev->dev, "could not create sysfs file\n"); 678 679 /* Our job is to use irqs and status from the power module 680 * to keep the transceiver disabled when nothing's connected. 681 * ··· 687 * need both handles, otherwise just one suffices. 688 */ 689 twl->irq_enabled = true; 690 - status = request_irq(twl->irq, twl4030_usb_irq, 691 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING, 692 "twl4030_usb", twl); 693 if (status < 0) {
··· 36 #include <linux/i2c/twl.h> 37 #include <linux/regulator/consumer.h> 38 #include <linux/err.h> 39 + #include <linux/notifier.h> 40 41 /* Register defines */ 42 ··· 236 #define PMBR1 0x0D 237 #define GPIO_USB_4PIN_ULPI_2430C (3 << 0) 238 239 struct twl4030_usb { 240 struct otg_transceiver otg; 241 struct device *dev; ··· 347 348 /*-------------------------------------------------------------------------*/ 349 350 + static enum usb_xceiv_events twl4030_usb_linkstat(struct twl4030_usb *twl) 351 { 352 int status; 353 + int linkstat = USB_EVENT_NONE; 354 355 /* 356 * For ID/VBUS sensing, see manual section 15.4.8 ... ··· 368 dev_err(twl->dev, "USB link status err %d\n", status); 369 else if (status & (BIT(7) | BIT(2))) { 370 if (status & BIT(2)) 371 + linkstat = USB_EVENT_ID; 372 else 373 + linkstat = USB_EVENT_VBUS; 374 } else 375 + linkstat = USB_EVENT_NONE; 376 377 dev_dbg(twl->dev, "HW_CONDITIONS 0x%02x/%d; link %d\n", 378 status, status, linkstat); ··· 383 384 spin_lock_irq(&twl->lock); 385 twl->linkstat = linkstat; 386 + if (linkstat == USB_EVENT_ID) { 387 twl->otg.default_a = true; 388 twl->otg.state = OTG_STATE_A_IDLE; 389 } else { ··· 564 565 spin_lock_irqsave(&twl->lock, flags); 566 ret = sprintf(buf, "%s\n", 567 + (twl->linkstat == USB_EVENT_VBUS) ? "on" : "off"); 568 spin_unlock_irqrestore(&twl->lock, flags); 569 570 return ret; ··· 576 struct twl4030_usb *twl = _twl; 577 int status; 578 579 status = twl4030_usb_linkstat(twl); 580 + if (status >= 0) { 581 /* FIXME add a set_power() method so that B-devices can 582 * configure the charger appropriately. It's not always 583 * correct to consume VBUS power, and how much current to ··· 598 * USB_LINK_VBUS state. musb_hdrc won't care until it 599 * starts to handle softconnect right. 600 */ 601 + if (status == USB_EVENT_NONE) 602 twl4030_phy_suspend(twl, 0); 603 else 604 twl4030_phy_resume(twl); 605 606 + blocking_notifier_call_chain(&twl->otg.notifier, status, 607 + twl->otg.gadget); 608 } 609 sysfs_notify(&twl->dev->kobj, NULL, "vbus"); 610 ··· 693 if (device_create_file(&pdev->dev, &dev_attr_vbus)) 694 dev_warn(&pdev->dev, "could not create sysfs file\n"); 695 696 + BLOCKING_INIT_NOTIFIER_HEAD(&twl->otg.notifier); 697 + 698 /* Our job is to use irqs and status from the power module 699 * to keep the transceiver disabled when nothing's connected. 700 * ··· 702 * need both handles, otherwise just one suffices. 703 */ 704 twl->irq_enabled = true; 705 + status = request_threaded_irq(twl->irq, NULL, twl4030_usb_irq, 706 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING, 707 "twl4030_usb", twl); 708 if (status < 0) {
+19
drivers/usb/serial/Kconfig
··· 472 To compile this driver as a module, choose M here: the 473 module will be called oti6858. 474 475 config USB_SERIAL_QUALCOMM 476 tristate "USB Qualcomm Serial modem" 477 help ··· 610 611 To compile this driver as a module, choose M here: the 612 module will be called opticon. 613 614 config USB_SERIAL_DEBUG 615 tristate "USB Debugging Device"
··· 472 To compile this driver as a module, choose M here: the 473 module will be called oti6858. 474 475 + config USB_SERIAL_QCAUX 476 + tristate "USB Qualcomm Auxiliary Serial Port Driver" 477 + ---help--- 478 + Say Y here if you want to use the auxiliary serial ports provided 479 + by many modems based on Qualcomm chipsets. These ports often use 480 + a proprietary protocol called DM and cannot be used for AT- or 481 + PPP-based communication. 482 + 483 + To compile this driver as a module, choose M here: the 484 + module will be called moto_modem. If unsure, choose N. 485 + 486 config USB_SERIAL_QUALCOMM 487 tristate "USB Qualcomm Serial modem" 488 help ··· 599 600 To compile this driver as a module, choose M here: the 601 module will be called opticon. 602 + 603 + config USB_SERIAL_VIVOPAY_SERIAL 604 + tristate "USB ViVOpay serial interface driver" 605 + help 606 + Say Y here if you want to use a ViVOtech ViVOpay USB device. 607 + 608 + To compile this driver as a module, choose M here: the 609 + module will be called vivopay-serial. 610 611 config USB_SERIAL_DEBUG 612 tristate "USB Debugging Device"
+2
drivers/usb/serial/Makefile
··· 45 obj-$(CONFIG_USB_SERIAL_OPTION) += option.o 46 obj-$(CONFIG_USB_SERIAL_OTI6858) += oti6858.o 47 obj-$(CONFIG_USB_SERIAL_PL2303) += pl2303.o 48 obj-$(CONFIG_USB_SERIAL_QUALCOMM) += qcserial.o 49 obj-$(CONFIG_USB_SERIAL_SAFE) += safe_serial.o 50 obj-$(CONFIG_USB_SERIAL_SIEMENS_MPI) += siemens_mpi.o ··· 56 obj-$(CONFIG_USB_SERIAL_VISOR) += visor.o 57 obj-$(CONFIG_USB_SERIAL_WHITEHEAT) += whiteheat.o 58 obj-$(CONFIG_USB_SERIAL_XIRCOM) += keyspan_pda.o 59
··· 45 obj-$(CONFIG_USB_SERIAL_OPTION) += option.o 46 obj-$(CONFIG_USB_SERIAL_OTI6858) += oti6858.o 47 obj-$(CONFIG_USB_SERIAL_PL2303) += pl2303.o 48 + obj-$(CONFIG_USB_SERIAL_QCAUX) += qcaux.o 49 obj-$(CONFIG_USB_SERIAL_QUALCOMM) += qcserial.o 50 obj-$(CONFIG_USB_SERIAL_SAFE) += safe_serial.o 51 obj-$(CONFIG_USB_SERIAL_SIEMENS_MPI) += siemens_mpi.o ··· 55 obj-$(CONFIG_USB_SERIAL_VISOR) += visor.o 56 obj-$(CONFIG_USB_SERIAL_WHITEHEAT) += whiteheat.o 57 obj-$(CONFIG_USB_SERIAL_XIRCOM) += keyspan_pda.o 58 + obj-$(CONFIG_USB_SERIAL_VIVOPAY_SERIAL) += vivopay-serial.o 59
+13 -21
drivers/usb/serial/aircable.c
··· 78 #define DRIVER_DESC "AIRcable USB Driver" 79 80 /* ID table that will be registered with USB core */ 81 - static struct usb_device_id id_table [] = { 82 { USB_DEVICE(AIRCABLE_VID, AIRCABLE_USB_PID) }, 83 { }, 84 }; ··· 468 469 if (status) { 470 dbg("%s - urb status = %d", __func__, status); 471 - if (!port->port.count) { 472 - dbg("%s - port is closed, exiting.", __func__); 473 - return; 474 - } 475 if (status == -EPROTO) { 476 dbg("%s - caught -EPROTO, resubmitting the urb", 477 __func__); ··· 526 } 527 tty_kref_put(tty); 528 529 - /* Schedule the next read _if_ we are still open */ 530 - if (port->port.count) { 531 - usb_fill_bulk_urb(port->read_urb, port->serial->dev, 532 - usb_rcvbulkpipe(port->serial->dev, 533 - port->bulk_in_endpointAddress), 534 - port->read_urb->transfer_buffer, 535 - port->read_urb->transfer_buffer_length, 536 - aircable_read_bulk_callback, port); 537 538 - result = usb_submit_urb(urb, GFP_ATOMIC); 539 - if (result) 540 - dev_err(&urb->dev->dev, 541 - "%s - failed resubmitting read urb, error %d\n", 542 - __func__, result); 543 - } 544 - 545 - return; 546 } 547 548 /* Based on ftdi_sio.c throttle */
··· 78 #define DRIVER_DESC "AIRcable USB Driver" 79 80 /* ID table that will be registered with USB core */ 81 + static const struct usb_device_id id_table[] = { 82 { USB_DEVICE(AIRCABLE_VID, AIRCABLE_USB_PID) }, 83 { }, 84 }; ··· 468 469 if (status) { 470 dbg("%s - urb status = %d", __func__, status); 471 if (status == -EPROTO) { 472 dbg("%s - caught -EPROTO, resubmitting the urb", 473 __func__); ··· 530 } 531 tty_kref_put(tty); 532 533 + /* Schedule the next read */ 534 + usb_fill_bulk_urb(port->read_urb, port->serial->dev, 535 + usb_rcvbulkpipe(port->serial->dev, 536 + port->bulk_in_endpointAddress), 537 + port->read_urb->transfer_buffer, 538 + port->read_urb->transfer_buffer_length, 539 + aircable_read_bulk_callback, port); 540 541 + result = usb_submit_urb(urb, GFP_ATOMIC); 542 + if (result && result != -EPERM) 543 + dev_err(&urb->dev->dev, 544 + "%s - failed resubmitting read urb, error %d\n", 545 + __func__, result); 546 } 547 548 /* Based on ftdi_sio.c throttle */
+1 -2
drivers/usb/serial/ark3116.c
··· 50 /* usb timeout of 1 second */ 51 #define ARK_TIMEOUT (1*HZ) 52 53 - static struct usb_device_id id_table [] = { 54 { USB_DEVICE(0x6547, 0x0232) }, 55 { USB_DEVICE(0x18ec, 0x3118) }, /* USB to IrDA adapter */ 56 { }, ··· 733 734 tty = tty_port_tty_get(&port->port); 735 if (tty) { 736 - tty_buffer_request_room(tty, urb->actual_length + 1); 737 /* overrun is special, not associated with a char */ 738 if (unlikely(lsr & UART_LSR_OE)) 739 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
··· 50 /* usb timeout of 1 second */ 51 #define ARK_TIMEOUT (1*HZ) 52 53 + static const struct usb_device_id id_table[] = { 54 { USB_DEVICE(0x6547, 0x0232) }, 55 { USB_DEVICE(0x18ec, 0x3118) }, /* USB to IrDA adapter */ 56 { }, ··· 733 734 tty = tty_port_tty_get(&port->port); 735 if (tty) { 736 /* overrun is special, not associated with a char */ 737 if (unlikely(lsr & UART_LSR_OE)) 738 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
+1 -1
drivers/usb/serial/belkin_sa.c
··· 103 unsigned int set, unsigned int clear); 104 105 106 - static struct usb_device_id id_table_combined [] = { 107 { USB_DEVICE(BELKIN_SA_VID, BELKIN_SA_PID) }, 108 { USB_DEVICE(BELKIN_OLD_VID, BELKIN_OLD_PID) }, 109 { USB_DEVICE(PERACOM_VID, PERACOM_PID) },
··· 103 unsigned int set, unsigned int clear); 104 105 106 + static const struct usb_device_id id_table_combined[] = { 107 { USB_DEVICE(BELKIN_SA_VID, BELKIN_SA_PID) }, 108 { USB_DEVICE(BELKIN_OLD_VID, BELKIN_OLD_PID) }, 109 { USB_DEVICE(PERACOM_VID, PERACOM_PID) },
+19 -10
drivers/usb/serial/ch341.c
··· 22 #include <linux/usb.h> 23 #include <linux/usb/serial.h> 24 #include <linux/serial.h> 25 26 #define DEFAULT_BAUD_RATE 9600 27 #define DEFAULT_TIMEOUT 1000 ··· 71 72 static int debug; 73 74 - static struct usb_device_id id_table [] = { 75 { USB_DEVICE(0x4348, 0x5523) }, 76 { USB_DEVICE(0x1a86, 0x7523) }, 77 { }, ··· 393 struct usb_serial_port *port = tty->driver_data; 394 int r; 395 uint16_t reg_contents; 396 - uint8_t break_reg[2]; 397 398 dbg("%s()", __func__); 399 400 - r = ch341_control_in(port->serial->dev, CH341_REQ_READ_REG, 401 - ch341_break_reg, 0, break_reg, sizeof(break_reg)); 402 - if (r < 0) { 403 - printk(KERN_WARNING "%s: USB control read error whilst getting" 404 - " break register contents.\n", __FILE__); 405 return; 406 } 407 dbg("%s - initial ch341 break register contents - reg1: %x, reg2: %x", 408 __func__, break_reg[0], break_reg[1]); ··· 423 } 424 dbg("%s - New ch341 break register contents - reg1: %x, reg2: %x", 425 __func__, break_reg[0], break_reg[1]); 426 - reg_contents = (uint16_t)break_reg[0] | ((uint16_t)break_reg[1] << 8); 427 r = ch341_control_out(port->serial->dev, CH341_REQ_WRITE_REG, 428 ch341_break_reg, reg_contents); 429 if (r < 0) 430 - printk(KERN_WARNING "%s: USB control write error whilst setting" 431 - " break register contents.\n", __FILE__); 432 } 433 434 static int ch341_tiocmset(struct tty_struct *tty, struct file *file,
··· 22 #include <linux/usb.h> 23 #include <linux/usb/serial.h> 24 #include <linux/serial.h> 25 + #include <asm/unaligned.h> 26 27 #define DEFAULT_BAUD_RATE 9600 28 #define DEFAULT_TIMEOUT 1000 ··· 70 71 static int debug; 72 73 + static const struct usb_device_id id_table[] = { 74 { USB_DEVICE(0x4348, 0x5523) }, 75 { USB_DEVICE(0x1a86, 0x7523) }, 76 { }, ··· 392 struct usb_serial_port *port = tty->driver_data; 393 int r; 394 uint16_t reg_contents; 395 + uint8_t *break_reg; 396 397 dbg("%s()", __func__); 398 399 + break_reg = kmalloc(2, GFP_KERNEL); 400 + if (!break_reg) { 401 + dev_err(&port->dev, "%s - kmalloc failed\n", __func__); 402 return; 403 + } 404 + 405 + r = ch341_control_in(port->serial->dev, CH341_REQ_READ_REG, 406 + ch341_break_reg, 0, break_reg, 2); 407 + if (r < 0) { 408 + dev_err(&port->dev, "%s - USB control read error (%d)\n", 409 + __func__, r); 410 + goto out; 411 } 412 dbg("%s - initial ch341 break register contents - reg1: %x, reg2: %x", 413 __func__, break_reg[0], break_reg[1]); ··· 416 } 417 dbg("%s - New ch341 break register contents - reg1: %x, reg2: %x", 418 __func__, break_reg[0], break_reg[1]); 419 + reg_contents = get_unaligned_le16(break_reg); 420 r = ch341_control_out(port->serial->dev, CH341_REQ_WRITE_REG, 421 ch341_break_reg, reg_contents); 422 if (r < 0) 423 + dev_err(&port->dev, "%s - USB control write error (%d)\n", 424 + __func__, r); 425 + out: 426 + kfree(break_reg); 427 } 428 429 static int ch341_tiocmset(struct tty_struct *tty, struct file *file,
+4 -3
drivers/usb/serial/cp210x.c
··· 55 56 static int debug; 57 58 - static struct usb_device_id id_table [] = { 59 { USB_DEVICE(0x0471, 0x066A) }, /* AKTAKOM ACE-1001 cable */ 60 { USB_DEVICE(0x0489, 0xE000) }, /* Pirelli Broadband S.p.A, DP-L10 SIP/GSM Mobile */ 61 { USB_DEVICE(0x0745, 0x1000) }, /* CipherLab USB CCD Barcode Scanner 1000 */ ··· 91 { USB_DEVICE(0x10C4, 0x81C8) }, /* Lipowsky Industrie Elektronik GmbH, Baby-JTAG */ 92 { USB_DEVICE(0x10C4, 0x81E2) }, /* Lipowsky Industrie Elektronik GmbH, Baby-LIN */ 93 { USB_DEVICE(0x10C4, 0x81E7) }, /* Aerocomm Radio */ 94 { USB_DEVICE(0x10C4, 0x81F2) }, /* C1007 HF band RFID controller */ 95 { USB_DEVICE(0x10C4, 0x8218) }, /* Lipowsky Industrie Elektronik GmbH, HARP-1 */ 96 { USB_DEVICE(0x10C4, 0x822B) }, /* Modem EDGE(GSM) Comander 2 */ 97 { USB_DEVICE(0x10C4, 0x826B) }, /* Cygnal Integrated Products, Inc., Fasttrax GPS demostration module */ 98 - { USB_DEVICE(0x10c4, 0x8293) }, /* Telegesys ETRX2USB */ 99 { USB_DEVICE(0x10C4, 0x82F9) }, /* Procyon AVS */ 100 { USB_DEVICE(0x10C4, 0x8341) }, /* Siemens MC35PU GPRS Modem */ 101 { USB_DEVICE(0x10C4, 0x8382) }, /* Cygnal Integrated Products, Inc. */ ··· 613 baud); 614 if (cp210x_set_config_single(port, CP210X_SET_BAUDDIV, 615 ((BAUD_RATE_GEN_FREQ + baud/2) / baud))) { 616 - dbg("Baud rate requested not supported by device\n"); 617 baud = tty_termios_baud_rate(old_termios); 618 } 619 }
··· 55 56 static int debug; 57 58 + static const struct usb_device_id id_table[] = { 59 { USB_DEVICE(0x0471, 0x066A) }, /* AKTAKOM ACE-1001 cable */ 60 { USB_DEVICE(0x0489, 0xE000) }, /* Pirelli Broadband S.p.A, DP-L10 SIP/GSM Mobile */ 61 { USB_DEVICE(0x0745, 0x1000) }, /* CipherLab USB CCD Barcode Scanner 1000 */ ··· 91 { USB_DEVICE(0x10C4, 0x81C8) }, /* Lipowsky Industrie Elektronik GmbH, Baby-JTAG */ 92 { USB_DEVICE(0x10C4, 0x81E2) }, /* Lipowsky Industrie Elektronik GmbH, Baby-LIN */ 93 { USB_DEVICE(0x10C4, 0x81E7) }, /* Aerocomm Radio */ 94 + { USB_DEVICE(0x10C4, 0x81E8) }, /* Zephyr Bioharness */ 95 { USB_DEVICE(0x10C4, 0x81F2) }, /* C1007 HF band RFID controller */ 96 { USB_DEVICE(0x10C4, 0x8218) }, /* Lipowsky Industrie Elektronik GmbH, HARP-1 */ 97 { USB_DEVICE(0x10C4, 0x822B) }, /* Modem EDGE(GSM) Comander 2 */ 98 { USB_DEVICE(0x10C4, 0x826B) }, /* Cygnal Integrated Products, Inc., Fasttrax GPS demostration module */ 99 + { USB_DEVICE(0x10C4, 0x8293) }, /* Telegesys ETRX2USB */ 100 { USB_DEVICE(0x10C4, 0x82F9) }, /* Procyon AVS */ 101 { USB_DEVICE(0x10C4, 0x8341) }, /* Siemens MC35PU GPRS Modem */ 102 { USB_DEVICE(0x10C4, 0x8382) }, /* Cygnal Integrated Products, Inc. */ ··· 612 baud); 613 if (cp210x_set_config_single(port, CP210X_SET_BAUDDIV, 614 ((BAUD_RATE_GEN_FREQ + baud/2) / baud))) { 615 + dbg("Baud rate requested not supported by device"); 616 baud = tty_termios_baud_rate(old_termios); 617 } 618 }
+2 -3
drivers/usb/serial/cyberjack.c
··· 70 static void cyberjack_read_bulk_callback(struct urb *urb); 71 static void cyberjack_write_bulk_callback(struct urb *urb); 72 73 - static struct usb_device_id id_table [] = { 74 { USB_DEVICE(CYBERJACK_VENDOR_ID, CYBERJACK_PRODUCT_ID) }, 75 { } /* Terminating entry */ 76 }; ··· 391 392 tty = tty_port_tty_get(&port->port); 393 if (!tty) { 394 - dbg("%s - ignoring since device not open\n", __func__); 395 return; 396 } 397 if (urb->actual_length) { 398 - tty_buffer_request_room(tty, urb->actual_length); 399 tty_insert_flip_string(tty, data, urb->actual_length); 400 tty_flip_buffer_push(tty); 401 }
··· 70 static void cyberjack_read_bulk_callback(struct urb *urb); 71 static void cyberjack_write_bulk_callback(struct urb *urb); 72 73 + static const struct usb_device_id id_table[] = { 74 { USB_DEVICE(CYBERJACK_VENDOR_ID, CYBERJACK_PRODUCT_ID) }, 75 { } /* Terminating entry */ 76 }; ··· 391 392 tty = tty_port_tty_get(&port->port); 393 if (!tty) { 394 + dbg("%s - ignoring since device not open", __func__); 395 return; 396 } 397 if (urb->actual_length) { 398 tty_insert_flip_string(tty, data, urb->actual_length); 399 tty_flip_buffer_push(tty); 400 }
+40 -42
drivers/usb/serial/cypress_m8.c
··· 66 #include <linux/serial.h> 67 #include <linux/delay.h> 68 #include <linux/uaccess.h> 69 70 #include "cypress_m8.h" 71 72 73 - #ifdef CONFIG_USB_SERIAL_DEBUG 74 - static int debug = 1; 75 - #else 76 - static int debug; 77 - #endif 78 static int stats; 79 static int interval; 80 81 /* 82 * Version Information ··· 87 #define CYPRESS_BUF_SIZE 1024 88 #define CYPRESS_CLOSING_WAIT (30*HZ) 89 90 - static struct usb_device_id id_table_earthmate [] = { 91 { USB_DEVICE(VENDOR_ID_DELORME, PRODUCT_ID_EARTHMATEUSB) }, 92 { USB_DEVICE(VENDOR_ID_DELORME, PRODUCT_ID_EARTHMATEUSB_LT20) }, 93 { } /* Terminating entry */ 94 }; 95 96 - static struct usb_device_id id_table_cyphidcomrs232 [] = { 97 { USB_DEVICE(VENDOR_ID_CYPRESS, PRODUCT_ID_CYPHIDCOM) }, 98 { USB_DEVICE(VENDOR_ID_POWERCOM, PRODUCT_ID_UPS) }, 99 { } /* Terminating entry */ 100 }; 101 102 - static struct usb_device_id id_table_nokiaca42v2 [] = { 103 { USB_DEVICE(VENDOR_ID_DAZZLE, PRODUCT_ID_CA42) }, 104 { } /* Terminating entry */ 105 }; 106 107 - static struct usb_device_id id_table_combined [] = { 108 { USB_DEVICE(VENDOR_ID_DELORME, PRODUCT_ID_EARTHMATEUSB) }, 109 { USB_DEVICE(VENDOR_ID_DELORME, PRODUCT_ID_EARTHMATEUSB_LT20) }, 110 { USB_DEVICE(VENDOR_ID_CYPRESS, PRODUCT_ID_CYPHIDCOM) }, ··· 293 struct cypress_private *priv; 294 priv = usb_get_serial_port_data(port); 295 296 /* 297 * The general purpose firmware for the Cypress M8 allows for 298 * a maximum speed of 57600bps (I have no idea whether DeLorme ··· 345 { 346 int new_baudrate = 0, retval = 0, tries = 0; 347 struct cypress_private *priv; 348 - __u8 feature_buffer[5]; 349 unsigned long flags; 350 351 dbg("%s", __func__); ··· 356 if (!priv->comm_is_ok) 357 return -ENODEV; 358 359 switch (cypress_request_type) { 360 case CYPRESS_SET_CONFIG: 361 - new_baudrate = priv->baud_rate; 362 /* 0 means 'Hang up' so doesn't change the true bit rate */ 363 - if (baud_rate == 0) 364 - new_baudrate = priv->baud_rate; 365 - /* Change of speed ? */ 366 - else if (baud_rate != priv->baud_rate) { 367 dbg("%s - baud rate is changing", __func__); 368 retval = analyze_baud_rate(port, baud_rate); 369 - if (retval >= 0) { 370 new_baudrate = retval; 371 dbg("%s - New baud rate set to %d", 372 __func__, new_baudrate); ··· 376 dbg("%s - baud rate is being sent as %d", 377 __func__, new_baudrate); 378 379 - memset(feature_buffer, 0, sizeof(feature_buffer)); 380 /* fill the feature_buffer with new configuration */ 381 - *((u_int32_t *)feature_buffer) = new_baudrate; 382 feature_buffer[4] |= data_bits; /* assign data bits in 2 bit space ( max 3 ) */ 383 /* 1 bit gap */ 384 feature_buffer[4] |= (stop_bits << 3); /* assign stop bits in 1 bit space */ ··· 399 HID_REQ_SET_REPORT, 400 USB_DIR_OUT | USB_RECIP_INTERFACE | USB_TYPE_CLASS, 401 0x0300, 0, feature_buffer, 402 - sizeof(feature_buffer), 500); 403 404 if (tries++ >= 3) 405 break; 406 407 - } while (retval != sizeof(feature_buffer) && 408 retval != -ENODEV); 409 410 - if (retval != sizeof(feature_buffer)) { 411 dev_err(&port->dev, "%s - failed sending serial " 412 "line settings - %d\n", __func__, retval); 413 cypress_set_dead(port); ··· 427 /* Not implemented for this device, 428 and if we try to do it we're likely 429 to crash the hardware. */ 430 - return -ENOTTY; 431 } 432 dbg("%s - retreiving serial line settings", __func__); 433 - /* set initial values in feature buffer */ 434 - memset(feature_buffer, 0, sizeof(feature_buffer)); 435 - 436 do { 437 retval = usb_control_msg(port->serial->dev, 438 usb_rcvctrlpipe(port->serial->dev, 0), 439 HID_REQ_GET_REPORT, 440 USB_DIR_IN | USB_RECIP_INTERFACE | USB_TYPE_CLASS, 441 0x0300, 0, feature_buffer, 442 - sizeof(feature_buffer), 500); 443 444 if (tries++ >= 3) 445 break; 446 - } while (retval != sizeof(feature_buffer) 447 && retval != -ENODEV); 448 449 - if (retval != sizeof(feature_buffer)) { 450 dev_err(&port->dev, "%s - failed to retrieve serial " 451 "line settings - %d\n", __func__, retval); 452 cypress_set_dead(port); 453 - return retval; 454 } else { 455 spin_lock_irqsave(&priv->lock, flags); 456 /* store the config in one byte, and later 457 use bit masks to check values */ 458 priv->current_config = feature_buffer[4]; 459 - priv->baud_rate = *((u_int32_t *)feature_buffer); 460 spin_unlock_irqrestore(&priv->lock, flags); 461 } 462 } 463 spin_lock_irqsave(&priv->lock, flags); 464 ++priv->cmd_count; 465 spin_unlock_irqrestore(&priv->lock, flags); 466 - 467 return retval; 468 } /* cypress_serial_control */ 469 ··· 691 { 692 struct cypress_private *priv = usb_get_serial_port_data(port); 693 /* drop dtr and rts */ 694 - priv = usb_get_serial_port_data(port); 695 spin_lock_irq(&priv->lock); 696 if (on == 0) 697 priv->line_control = 0; ··· 1307 spin_unlock_irqrestore(&priv->lock, flags); 1308 1309 /* process read if there is data other than line status */ 1310 - if (tty && (bytes > i)) { 1311 - bytes = tty_buffer_request_room(tty, bytes); 1312 - for (; i < bytes ; ++i) { 1313 - dbg("pushing byte number %d - %d - %c", i, data[i], 1314 - data[i]); 1315 - tty_insert_flip_char(tty, data[i], tty_flag); 1316 - } 1317 tty_flip_buffer_push(tty); 1318 } 1319 ··· 1321 continue_read: 1322 tty_kref_put(tty); 1323 1324 - /* Continue trying to always read... unless the port has closed. */ 1325 1326 - if (port->port.count > 0 && priv->comm_is_ok) { 1327 usb_fill_int_urb(port->interrupt_in_urb, port->serial->dev, 1328 usb_rcvintpipe(port->serial->dev, 1329 port->interrupt_in_endpointAddress), ··· 1332 cypress_read_int_callback, port, 1333 priv->read_urb_interval); 1334 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); 1335 - if (result) { 1336 dev_err(&urb->dev->dev, "%s - failed resubmitting " 1337 "read urb, error %d\n", __func__, 1338 result); ··· 1646 MODULE_PARM_DESC(stats, "Enable statistics or not"); 1647 module_param(interval, int, S_IRUGO | S_IWUSR); 1648 MODULE_PARM_DESC(interval, "Overrides interrupt interval");
··· 66 #include <linux/serial.h> 67 #include <linux/delay.h> 68 #include <linux/uaccess.h> 69 + #include <asm/unaligned.h> 70 71 #include "cypress_m8.h" 72 73 74 + static int debug; 75 static int stats; 76 static int interval; 77 + static int unstable_bauds; 78 79 /* 80 * Version Information ··· 89 #define CYPRESS_BUF_SIZE 1024 90 #define CYPRESS_CLOSING_WAIT (30*HZ) 91 92 + static const struct usb_device_id id_table_earthmate[] = { 93 { USB_DEVICE(VENDOR_ID_DELORME, PRODUCT_ID_EARTHMATEUSB) }, 94 { USB_DEVICE(VENDOR_ID_DELORME, PRODUCT_ID_EARTHMATEUSB_LT20) }, 95 { } /* Terminating entry */ 96 }; 97 98 + static const struct usb_device_id id_table_cyphidcomrs232[] = { 99 { USB_DEVICE(VENDOR_ID_CYPRESS, PRODUCT_ID_CYPHIDCOM) }, 100 { USB_DEVICE(VENDOR_ID_POWERCOM, PRODUCT_ID_UPS) }, 101 { } /* Terminating entry */ 102 }; 103 104 + static const struct usb_device_id id_table_nokiaca42v2[] = { 105 { USB_DEVICE(VENDOR_ID_DAZZLE, PRODUCT_ID_CA42) }, 106 { } /* Terminating entry */ 107 }; 108 109 + static const struct usb_device_id id_table_combined[] = { 110 { USB_DEVICE(VENDOR_ID_DELORME, PRODUCT_ID_EARTHMATEUSB) }, 111 { USB_DEVICE(VENDOR_ID_DELORME, PRODUCT_ID_EARTHMATEUSB_LT20) }, 112 { USB_DEVICE(VENDOR_ID_CYPRESS, PRODUCT_ID_CYPHIDCOM) }, ··· 295 struct cypress_private *priv; 296 priv = usb_get_serial_port_data(port); 297 298 + if (unstable_bauds) 299 + return new_rate; 300 + 301 /* 302 * The general purpose firmware for the Cypress M8 allows for 303 * a maximum speed of 57600bps (I have no idea whether DeLorme ··· 344 { 345 int new_baudrate = 0, retval = 0, tries = 0; 346 struct cypress_private *priv; 347 + u8 *feature_buffer; 348 + const unsigned int feature_len = 5; 349 unsigned long flags; 350 351 dbg("%s", __func__); ··· 354 if (!priv->comm_is_ok) 355 return -ENODEV; 356 357 + feature_buffer = kcalloc(feature_len, sizeof(u8), GFP_KERNEL); 358 + if (!feature_buffer) 359 + return -ENOMEM; 360 + 361 switch (cypress_request_type) { 362 case CYPRESS_SET_CONFIG: 363 /* 0 means 'Hang up' so doesn't change the true bit rate */ 364 + new_baudrate = priv->baud_rate; 365 + if (baud_rate && baud_rate != priv->baud_rate) { 366 dbg("%s - baud rate is changing", __func__); 367 retval = analyze_baud_rate(port, baud_rate); 368 + if (retval >= 0) { 369 new_baudrate = retval; 370 dbg("%s - New baud rate set to %d", 371 __func__, new_baudrate); ··· 373 dbg("%s - baud rate is being sent as %d", 374 __func__, new_baudrate); 375 376 /* fill the feature_buffer with new configuration */ 377 + put_unaligned_le32(new_baudrate, feature_buffer); 378 feature_buffer[4] |= data_bits; /* assign data bits in 2 bit space ( max 3 ) */ 379 /* 1 bit gap */ 380 feature_buffer[4] |= (stop_bits << 3); /* assign stop bits in 1 bit space */ ··· 397 HID_REQ_SET_REPORT, 398 USB_DIR_OUT | USB_RECIP_INTERFACE | USB_TYPE_CLASS, 399 0x0300, 0, feature_buffer, 400 + feature_len, 500); 401 402 if (tries++ >= 3) 403 break; 404 405 + } while (retval != feature_len && 406 retval != -ENODEV); 407 408 + if (retval != feature_len) { 409 dev_err(&port->dev, "%s - failed sending serial " 410 "line settings - %d\n", __func__, retval); 411 cypress_set_dead(port); ··· 425 /* Not implemented for this device, 426 and if we try to do it we're likely 427 to crash the hardware. */ 428 + retval = -ENOTTY; 429 + goto out; 430 } 431 dbg("%s - retreiving serial line settings", __func__); 432 do { 433 retval = usb_control_msg(port->serial->dev, 434 usb_rcvctrlpipe(port->serial->dev, 0), 435 HID_REQ_GET_REPORT, 436 USB_DIR_IN | USB_RECIP_INTERFACE | USB_TYPE_CLASS, 437 0x0300, 0, feature_buffer, 438 + feature_len, 500); 439 440 if (tries++ >= 3) 441 break; 442 + } while (retval != feature_len 443 && retval != -ENODEV); 444 445 + if (retval != feature_len) { 446 dev_err(&port->dev, "%s - failed to retrieve serial " 447 "line settings - %d\n", __func__, retval); 448 cypress_set_dead(port); 449 + goto out; 450 } else { 451 spin_lock_irqsave(&priv->lock, flags); 452 /* store the config in one byte, and later 453 use bit masks to check values */ 454 priv->current_config = feature_buffer[4]; 455 + priv->baud_rate = get_unaligned_le32(feature_buffer); 456 spin_unlock_irqrestore(&priv->lock, flags); 457 } 458 } 459 spin_lock_irqsave(&priv->lock, flags); 460 ++priv->cmd_count; 461 spin_unlock_irqrestore(&priv->lock, flags); 462 + out: 463 + kfree(feature_buffer); 464 return retval; 465 } /* cypress_serial_control */ 466 ··· 690 { 691 struct cypress_private *priv = usb_get_serial_port_data(port); 692 /* drop dtr and rts */ 693 spin_lock_irq(&priv->lock); 694 if (on == 0) 695 priv->line_control = 0; ··· 1307 spin_unlock_irqrestore(&priv->lock, flags); 1308 1309 /* process read if there is data other than line status */ 1310 + if (tty && bytes > i) { 1311 + tty_insert_flip_string_fixed_flag(tty, data + i, 1312 + bytes - i, tty_flag); 1313 tty_flip_buffer_push(tty); 1314 } 1315 ··· 1325 continue_read: 1326 tty_kref_put(tty); 1327 1328 + /* Continue trying to always read */ 1329 1330 + if (priv->comm_is_ok) { 1331 usb_fill_int_urb(port->interrupt_in_urb, port->serial->dev, 1332 usb_rcvintpipe(port->serial->dev, 1333 port->interrupt_in_endpointAddress), ··· 1336 cypress_read_int_callback, port, 1337 priv->read_urb_interval); 1338 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); 1339 + if (result && result != -EPERM) { 1340 dev_err(&urb->dev->dev, "%s - failed resubmitting " 1341 "read urb, error %d\n", __func__, 1342 result); ··· 1650 MODULE_PARM_DESC(stats, "Enable statistics or not"); 1651 module_param(interval, int, S_IRUGO | S_IWUSR); 1652 MODULE_PARM_DESC(interval, "Overrides interrupt interval"); 1653 + module_param(unstable_bauds, bool, S_IRUGO | S_IWUSR); 1654 + MODULE_PARM_DESC(unstable_bauds, "Allow unstable baud rates");
+13 -25
drivers/usb/serial/digi_acceleport.c
··· 470 471 static int debug; 472 473 - static struct usb_device_id id_table_combined [] = { 474 { USB_DEVICE(DIGI_VENDOR_ID, DIGI_2_ID) }, 475 { USB_DEVICE(DIGI_VENDOR_ID, DIGI_4_ID) }, 476 { } /* Terminating entry */ 477 }; 478 479 - static struct usb_device_id id_table_2 [] = { 480 { USB_DEVICE(DIGI_VENDOR_ID, DIGI_2_ID) }, 481 { } /* Terminating entry */ 482 }; 483 484 - static struct usb_device_id id_table_4 [] = { 485 { USB_DEVICE(DIGI_VENDOR_ID, DIGI_4_ID) }, 486 { } /* Terminating entry */ 487 }; ··· 1262 return; 1263 } 1264 1265 - /* try to send any buffered data on this port, if it is open */ 1266 spin_lock(&priv->dp_port_lock); 1267 priv->dp_write_urb_in_use = 0; 1268 - if (port->port.count && priv->dp_out_buf_len > 0) { 1269 *((unsigned char *)(port->write_urb->transfer_buffer)) 1270 = (unsigned char)DIGI_CMD_SEND_DATA; 1271 *((unsigned char *)(port->write_urb->transfer_buffer) + 1) ··· 1288 schedule_work(&priv->dp_wakeup_work); 1289 1290 spin_unlock(&priv->dp_port_lock); 1291 - if (ret) 1292 dev_err(&port->dev, 1293 "%s: usb_submit_urb failed, ret=%d, port=%d\n", 1294 __func__, ret, priv->dp_port_num); ··· 1353 struct digi_port *priv = usb_get_serial_port_data(port); 1354 struct ktermios not_termios; 1355 1356 - dbg("digi_open: TOP: port=%d, open_count=%d", 1357 - priv->dp_port_num, port->port.count); 1358 1359 /* be sure the device is started up */ 1360 if (digi_startup_device(port->serial) != 0) ··· 1392 unsigned char buf[32]; 1393 struct digi_port *priv = usb_get_serial_port_data(port); 1394 1395 - dbg("digi_close: TOP: port=%d, open_count=%d", 1396 - priv->dp_port_num, port->port.count); 1397 1398 mutex_lock(&port->serial->disc_mutex); 1399 /* if disconnected, just clear flags */ ··· 1627 /* continue read */ 1628 urb->dev = port->serial->dev; 1629 ret = usb_submit_urb(urb, GFP_ATOMIC); 1630 - if (ret != 0) { 1631 dev_err(&port->dev, 1632 "%s: failed resubmitting urb, ret=%d, port=%d\n", 1633 __func__, ret, priv->dp_port_num); ··· 1656 int port_status = ((unsigned char *)urb->transfer_buffer)[2]; 1657 unsigned char *data = ((unsigned char *)urb->transfer_buffer) + 3; 1658 int flag, throttled; 1659 - int i; 1660 int status = urb->status; 1661 1662 /* do not process callbacks on closed ports */ 1663 /* but do continue the read chain */ 1664 - if (port->port.count == 0) 1665 return 0; 1666 1667 /* short/multiple packet check */ ··· 1702 1703 /* data length is len-1 (one byte of len is port_status) */ 1704 --len; 1705 - 1706 - len = tty_buffer_request_room(tty, len); 1707 if (len > 0) { 1708 - /* Hot path */ 1709 - if (flag == TTY_NORMAL) 1710 - tty_insert_flip_string(tty, data, len); 1711 - else { 1712 - for (i = 0; i < len; i++) 1713 - tty_insert_flip_char(tty, 1714 - data[i], flag); 1715 - } 1716 tty_flip_buffer_push(tty); 1717 } 1718 } ··· 1765 1766 tty = tty_port_tty_get(&port->port); 1767 rts = 0; 1768 - if (port->port.count) 1769 - rts = tty->termios->c_cflag & CRTSCTS; 1770 1771 if (opcode == DIGI_CMD_READ_INPUT_SIGNALS) { 1772 spin_lock(&priv->dp_port_lock);
··· 470 471 static int debug; 472 473 + static const struct usb_device_id id_table_combined[] = { 474 { USB_DEVICE(DIGI_VENDOR_ID, DIGI_2_ID) }, 475 { USB_DEVICE(DIGI_VENDOR_ID, DIGI_4_ID) }, 476 { } /* Terminating entry */ 477 }; 478 479 + static const struct usb_device_id id_table_2[] = { 480 { USB_DEVICE(DIGI_VENDOR_ID, DIGI_2_ID) }, 481 { } /* Terminating entry */ 482 }; 483 484 + static const struct usb_device_id id_table_4[] = { 485 { USB_DEVICE(DIGI_VENDOR_ID, DIGI_4_ID) }, 486 { } /* Terminating entry */ 487 }; ··· 1262 return; 1263 } 1264 1265 + /* try to send any buffered data on this port */ 1266 spin_lock(&priv->dp_port_lock); 1267 priv->dp_write_urb_in_use = 0; 1268 + if (priv->dp_out_buf_len > 0) { 1269 *((unsigned char *)(port->write_urb->transfer_buffer)) 1270 = (unsigned char)DIGI_CMD_SEND_DATA; 1271 *((unsigned char *)(port->write_urb->transfer_buffer) + 1) ··· 1288 schedule_work(&priv->dp_wakeup_work); 1289 1290 spin_unlock(&priv->dp_port_lock); 1291 + if (ret && ret != -EPERM) 1292 dev_err(&port->dev, 1293 "%s: usb_submit_urb failed, ret=%d, port=%d\n", 1294 __func__, ret, priv->dp_port_num); ··· 1353 struct digi_port *priv = usb_get_serial_port_data(port); 1354 struct ktermios not_termios; 1355 1356 + dbg("digi_open: TOP: port=%d", priv->dp_port_num); 1357 1358 /* be sure the device is started up */ 1359 if (digi_startup_device(port->serial) != 0) ··· 1393 unsigned char buf[32]; 1394 struct digi_port *priv = usb_get_serial_port_data(port); 1395 1396 + dbg("digi_close: TOP: port=%d", priv->dp_port_num); 1397 1398 mutex_lock(&port->serial->disc_mutex); 1399 /* if disconnected, just clear flags */ ··· 1629 /* continue read */ 1630 urb->dev = port->serial->dev; 1631 ret = usb_submit_urb(urb, GFP_ATOMIC); 1632 + if (ret != 0 && ret != -EPERM) { 1633 dev_err(&port->dev, 1634 "%s: failed resubmitting urb, ret=%d, port=%d\n", 1635 __func__, ret, priv->dp_port_num); ··· 1658 int port_status = ((unsigned char *)urb->transfer_buffer)[2]; 1659 unsigned char *data = ((unsigned char *)urb->transfer_buffer) + 3; 1660 int flag, throttled; 1661 int status = urb->status; 1662 1663 /* do not process callbacks on closed ports */ 1664 /* but do continue the read chain */ 1665 + if (urb->status == -ENOENT) 1666 return 0; 1667 1668 /* short/multiple packet check */ ··· 1705 1706 /* data length is len-1 (one byte of len is port_status) */ 1707 --len; 1708 if (len > 0) { 1709 + tty_insert_flip_string_fixed_flag(tty, data, len, 1710 + flag); 1711 tty_flip_buffer_push(tty); 1712 } 1713 } ··· 1776 1777 tty = tty_port_tty_get(&port->port); 1778 rts = 0; 1779 + rts = tty->termios->c_cflag & CRTSCTS; 1780 1781 if (opcode == DIGI_CMD_READ_INPUT_SIGNALS) { 1782 spin_lock(&priv->dp_port_lock);
+1 -2
drivers/usb/serial/empeg.c
··· 93 static void empeg_write_bulk_callback(struct urb *urb); 94 static void empeg_read_bulk_callback(struct urb *urb); 95 96 - static struct usb_device_id id_table [] = { 97 { USB_DEVICE(EMPEG_VENDOR_ID, EMPEG_PRODUCT_ID) }, 98 { } /* Terminating entry */ 99 }; ··· 346 tty = tty_port_tty_get(&port->port); 347 348 if (urb->actual_length) { 349 - tty_buffer_request_room(tty, urb->actual_length); 350 tty_insert_flip_string(tty, data, urb->actual_length); 351 tty_flip_buffer_push(tty); 352 bytes_in += urb->actual_length;
··· 93 static void empeg_write_bulk_callback(struct urb *urb); 94 static void empeg_read_bulk_callback(struct urb *urb); 95 96 + static const struct usb_device_id id_table[] = { 97 { USB_DEVICE(EMPEG_VENDOR_ID, EMPEG_PRODUCT_ID) }, 98 { } /* Terminating entry */ 99 }; ··· 346 tty = tty_port_tty_get(&port->port); 347 348 if (urb->actual_length) { 349 tty_insert_flip_string(tty, data, urb->actual_length); 350 tty_flip_buffer_push(tty); 351 bytes_in += urb->actual_length;
+89 -106
drivers/usb/serial/ftdi_sio.c
··· 33 #include <linux/errno.h> 34 #include <linux/init.h> 35 #include <linux/slab.h> 36 - #include <linux/smp_lock.h> 37 #include <linux/tty.h> 38 #include <linux/tty_driver.h> 39 #include <linux/tty_flip.h> 40 #include <linux/module.h> 41 #include <linux/spinlock.h> 42 #include <linux/uaccess.h> 43 #include <linux/usb.h> 44 #include <linux/serial.h> ··· 88 89 unsigned int latency; /* latency setting in use */ 90 spinlock_t tx_lock; /* spinlock for transmit state */ 91 - unsigned long tx_bytes; 92 unsigned long tx_outstanding_bytes; 93 unsigned long tx_outstanding_urbs; 94 unsigned short max_packet_size; 95 }; 96 97 /* struct ftdi_sio_quirk is used by devices requiring special attention. */ ··· 614 { USB_DEVICE(FTDI_VID, FTDI_OCEANIC_PID) }, 615 { USB_DEVICE(TTI_VID, TTI_QL355P_PID) }, 616 { USB_DEVICE(FTDI_VID, FTDI_RM_CANVIEW_PID) }, 617 { USB_DEVICE(BANDB_VID, BANDB_USOTL4_PID) }, 618 { USB_DEVICE(BANDB_VID, BANDB_USTL4_PID) }, 619 { USB_DEVICE(BANDB_VID, BANDB_USO9ML2_PID) }, ··· 738 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 739 { USB_DEVICE(FTDI_VID, HAMEG_HO820_PID) }, 740 { USB_DEVICE(FTDI_VID, HAMEG_HO870_PID) }, 741 { }, /* Optional parameter entry */ 742 { } /* Terminating entry */ 743 }; ··· 817 .name = "ftdi_sio", 818 }, 819 .description = "FTDI USB Serial Device", 820 - .usb_driver = &ftdi_driver , 821 .id_table = id_table_combined, 822 .num_ports = 1, 823 .probe = ftdi_sio_probe, ··· 833 .chars_in_buffer = ftdi_chars_in_buffer, 834 .read_bulk_callback = ftdi_read_bulk_callback, 835 .write_bulk_callback = ftdi_write_bulk_callback, 836 - .tiocmget = ftdi_tiocmget, 837 - .tiocmset = ftdi_tiocmset, 838 .ioctl = ftdi_ioctl, 839 .set_termios = ftdi_set_termios, 840 .break_ctl = ftdi_break_ctl, ··· 940 unsigned int clear) 941 { 942 struct ftdi_private *priv = usb_get_serial_port_data(port); 943 - char *buf; 944 unsigned urb_value; 945 int rv; 946 ··· 947 dbg("%s - DTR|RTS not being set|cleared", __func__); 948 return 0; /* no change */ 949 } 950 - 951 - buf = kmalloc(1, GFP_NOIO); 952 - if (!buf) 953 - return -ENOMEM; 954 955 clear &= ~set; /* 'set' takes precedence over 'clear' */ 956 urb_value = 0; ··· 963 FTDI_SIO_SET_MODEM_CTRL_REQUEST, 964 FTDI_SIO_SET_MODEM_CTRL_REQUEST_TYPE, 965 urb_value, priv->interface, 966 - buf, 0, WDR_TIMEOUT); 967 - 968 - kfree(buf); 969 if (rv < 0) { 970 dbg("%s Error from MODEM_CTRL urb: DTR %s, RTS %s", 971 __func__, ··· 1122 static int change_speed(struct tty_struct *tty, struct usb_serial_port *port) 1123 { 1124 struct ftdi_private *priv = usb_get_serial_port_data(port); 1125 - char *buf; 1126 __u16 urb_value; 1127 __u16 urb_index; 1128 __u32 urb_index_value; 1129 int rv; 1130 - 1131 - buf = kmalloc(1, GFP_NOIO); 1132 - if (!buf) 1133 - return -ENOMEM; 1134 1135 urb_index_value = get_ftdi_divisor(tty, port); 1136 urb_value = (__u16)urb_index_value; ··· 1139 FTDI_SIO_SET_BAUDRATE_REQUEST, 1140 FTDI_SIO_SET_BAUDRATE_REQUEST_TYPE, 1141 urb_value, urb_index, 1142 - buf, 0, WDR_SHORT_TIMEOUT); 1143 - 1144 - kfree(buf); 1145 return rv; 1146 } 1147 ··· 1147 { 1148 struct ftdi_private *priv = usb_get_serial_port_data(port); 1149 struct usb_device *udev = port->serial->dev; 1150 - char buf[1]; 1151 - int rv = 0; 1152 int l = priv->latency; 1153 1154 if (priv->flags & ASYNC_LOW_LATENCY) ··· 1160 FTDI_SIO_SET_LATENCY_TIMER_REQUEST, 1161 FTDI_SIO_SET_LATENCY_TIMER_REQUEST_TYPE, 1162 l, priv->interface, 1163 - buf, 0, WDR_TIMEOUT); 1164 - 1165 if (rv < 0) 1166 dev_err(&port->dev, "Unable to write latency timer: %i\n", rv); 1167 return rv; ··· 1170 { 1171 struct ftdi_private *priv = usb_get_serial_port_data(port); 1172 struct usb_device *udev = port->serial->dev; 1173 - unsigned short latency = 0; 1174 - int rv = 0; 1175 - 1176 1177 dbg("%s", __func__); 1178 1179 rv = usb_control_msg(udev, 1180 usb_rcvctrlpipe(udev, 0), 1181 FTDI_SIO_GET_LATENCY_TIMER_REQUEST, 1182 FTDI_SIO_GET_LATENCY_TIMER_REQUEST_TYPE, 1183 0, priv->interface, 1184 - (char *) &latency, 1, WDR_TIMEOUT); 1185 - 1186 - if (rv < 0) { 1187 dev_err(&port->dev, "Unable to read latency timer: %i\n", rv); 1188 - return -EIO; 1189 - } 1190 - return latency; 1191 } 1192 1193 static int get_serial_info(struct usb_serial_port *port, ··· 1223 if (copy_from_user(&new_serial, newinfo, sizeof(new_serial))) 1224 return -EFAULT; 1225 1226 - lock_kernel(); 1227 old_priv = *priv; 1228 1229 /* Do error checking and permission checking */ ··· 1231 if (!capable(CAP_SYS_ADMIN)) { 1232 if (((new_serial.flags & ~ASYNC_USR_MASK) != 1233 (priv->flags & ~ASYNC_USR_MASK))) { 1234 - unlock_kernel(); 1235 return -EPERM; 1236 } 1237 priv->flags = ((priv->flags & ~ASYNC_USR_MASK) | ··· 1242 1243 if ((new_serial.baud_base != priv->baud_base) && 1244 (new_serial.baud_base < 9600)) { 1245 - unlock_kernel(); 1246 return -EINVAL; 1247 } 1248 ··· 1272 (priv->flags & ASYNC_SPD_MASK)) || 1273 (((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) && 1274 (old_priv.custom_divisor != priv->custom_divisor))) { 1275 - unlock_kernel(); 1276 change_speed(tty, port); 1277 } 1278 else 1279 - unlock_kernel(); 1280 return 0; 1281 1282 } /* set_serial_info */ ··· 1332 __func__); 1333 } 1334 } else if (version < 0x200) { 1335 - /* Old device. Assume its the original SIO. */ 1336 priv->chip_type = SIO; 1337 priv->baud_base = 12000000 / 16; 1338 priv->write_offset = 1; 1339 } else if (version < 0x400) { 1340 - /* Assume its an FT8U232AM (or FT8U245AM) */ 1341 /* (It might be a BM because of the iSerialNumber bug, 1342 * but it will still work as an AM device.) */ 1343 priv->chip_type = FT8U232AM; 1344 } else if (version < 0x600) { 1345 - /* Assume its an FT232BM (or FT245BM) */ 1346 priv->chip_type = FT232BM; 1347 } else { 1348 - /* Assume its an FT232R */ 1349 priv->chip_type = FT232RL; 1350 } 1351 dev_info(&udev->dev, "Detected %s\n", ftdi_chip_name[priv->chip_type]); ··· 1365 struct usb_endpoint_descriptor *ep_desc = &interface->cur_altsetting->endpoint[1].desc; 1366 1367 unsigned num_endpoints; 1368 - int i = 0; 1369 1370 num_endpoints = interface->cur_altsetting->desc.bNumEndpoints; 1371 dev_info(&udev->dev, "Number of endpoints %d\n", num_endpoints); ··· 1417 struct usb_serial_port *port = to_usb_serial_port(dev); 1418 struct ftdi_private *priv = usb_get_serial_port_data(port); 1419 int v = simple_strtoul(valbuf, NULL, 10); 1420 - int rv = 0; 1421 1422 priv->latency = v; 1423 rv = write_latency_timer(port); ··· 1434 struct usb_serial_port *port = to_usb_serial_port(dev); 1435 struct ftdi_private *priv = usb_get_serial_port_data(port); 1436 struct usb_device *udev = port->serial->dev; 1437 - char buf[1]; 1438 int v = simple_strtoul(valbuf, NULL, 10); 1439 - int rv = 0; 1440 1441 dbg("%s: setting event char = %i", __func__, v); 1442 ··· 1444 FTDI_SIO_SET_EVENT_CHAR_REQUEST, 1445 FTDI_SIO_SET_EVENT_CHAR_REQUEST_TYPE, 1446 v, priv->interface, 1447 - buf, 0, WDR_TIMEOUT); 1448 - 1449 if (rv < 0) { 1450 dbg("Unable to write event character: %i", rv); 1451 return -EIO; ··· 1543 1544 kref_init(&priv->kref); 1545 spin_lock_init(&priv->tx_lock); 1546 init_waitqueue_head(&priv->delta_msr_wait); 1547 - /* This will push the characters through immediately rather 1548 - than queue a task to deliver them */ 1549 priv->flags = ASYNC_LOW_LATENCY; 1550 1551 if (quirk && quirk->port_probe) ··· 1577 1578 ftdi_determine_type(port); 1579 ftdi_set_max_packet_size(port); 1580 - read_latency_timer(port); 1581 create_sysfs_attrs(port); 1582 return 0; 1583 } ··· 1623 { 1624 struct usb_device *udev = serial->dev; 1625 int latency = ndi_latency_timer; 1626 - int rv = 0; 1627 - char buf[1]; 1628 1629 if (latency == 0) 1630 latency = 1; ··· 1632 dbg("%s setting NDI device latency to %d", __func__, latency); 1633 dev_info(&udev->dev, "NDI device with a latency value of %d", latency); 1634 1635 - rv = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 1636 FTDI_SIO_SET_LATENCY_TIMER_REQUEST, 1637 FTDI_SIO_SET_LATENCY_TIMER_REQUEST_TYPE, 1638 - latency, 0, buf, 0, WDR_TIMEOUT); 1639 return 0; 1640 } 1641 ··· 1712 urb->transfer_buffer_length, 1713 ftdi_read_bulk_callback, port); 1714 result = usb_submit_urb(urb, mem_flags); 1715 - if (result) 1716 dev_err(&port->dev, 1717 "%s - failed submitting read urb, error %d\n", 1718 __func__, result); ··· 1724 struct usb_device *dev = port->serial->dev; 1725 struct ftdi_private *priv = usb_get_serial_port_data(port); 1726 unsigned long flags; 1727 - 1728 - int result = 0; 1729 - char buf[1]; /* Needed for the usb_control_msg I think */ 1730 1731 dbg("%s", __func__); 1732 - 1733 - spin_lock_irqsave(&priv->tx_lock, flags); 1734 - priv->tx_bytes = 0; 1735 - spin_unlock_irqrestore(&priv->tx_lock, flags); 1736 1737 write_latency_timer(port); 1738 ··· 1735 usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 1736 FTDI_SIO_RESET_REQUEST, FTDI_SIO_RESET_REQUEST_TYPE, 1737 FTDI_SIO_RESET_SIO, 1738 - priv->interface, buf, 0, WDR_TIMEOUT); 1739 1740 /* Termios defaults are set by usb_serial_init. We don't change 1741 port->tty->termios - this would lose speed settings, etc. ··· 1763 static void ftdi_dtr_rts(struct usb_serial_port *port, int on) 1764 { 1765 struct ftdi_private *priv = usb_get_serial_port_data(port); 1766 - char buf[1]; 1767 1768 mutex_lock(&port->serial->disc_mutex); 1769 if (!port->serial->disconnected) { ··· 1771 usb_sndctrlpipe(port->serial->dev, 0), 1772 FTDI_SIO_SET_FLOW_CTRL_REQUEST, 1773 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 1774 - 0, priv->interface, buf, 0, 1775 WDR_TIMEOUT) < 0) { 1776 dev_err(&port->dev, "error from flowcontrol urb\n"); 1777 } ··· 1832 spin_lock_irqsave(&priv->tx_lock, flags); 1833 if (priv->tx_outstanding_urbs > URB_UPPER_LIMIT) { 1834 spin_unlock_irqrestore(&priv->tx_lock, flags); 1835 - dbg("%s - write limit hit\n", __func__); 1836 return 0; 1837 } 1838 priv->tx_outstanding_urbs++; ··· 1912 } else { 1913 spin_lock_irqsave(&priv->tx_lock, flags); 1914 priv->tx_outstanding_bytes += count; 1915 - priv->tx_bytes += count; 1916 spin_unlock_irqrestore(&priv->tx_lock, flags); 1917 } 1918 ··· 2138 { 2139 struct usb_serial_port *port = tty->driver_data; 2140 struct ftdi_private *priv = usb_get_serial_port_data(port); 2141 - __u16 urb_value = 0; 2142 - char buf[1]; 2143 2144 /* break_state = -1 to turn on break, and 0 to turn off break */ 2145 /* see drivers/char/tty_io.c to see it used */ ··· 2154 FTDI_SIO_SET_DATA_REQUEST, 2155 FTDI_SIO_SET_DATA_REQUEST_TYPE, 2156 urb_value , priv->interface, 2157 - buf, 0, WDR_TIMEOUT) < 0) { 2158 dev_err(&port->dev, "%s FAILED to enable/disable break state " 2159 "(state was %d)\n", __func__, break_state); 2160 } ··· 2178 struct ktermios *termios = tty->termios; 2179 unsigned int cflag = termios->c_cflag; 2180 __u16 urb_value; /* will hold the new flags */ 2181 - char buf[1]; /* Perhaps I should dynamically alloc this? */ 2182 2183 /* Added for xon/xoff support */ 2184 unsigned int iflag = termios->c_iflag; ··· 2228 } 2229 if (cflag & CSIZE) { 2230 switch (cflag & CSIZE) { 2231 - case CS5: urb_value |= 5; dbg("Setting CS5"); break; 2232 - case CS6: urb_value |= 6; dbg("Setting CS6"); break; 2233 case CS7: urb_value |= 7; dbg("Setting CS7"); break; 2234 case CS8: urb_value |= 8; dbg("Setting CS8"); break; 2235 default: 2236 - dev_err(&port->dev, "CSIZE was set but not CS5-CS8\n"); 2237 } 2238 } 2239 ··· 2243 FTDI_SIO_SET_DATA_REQUEST, 2244 FTDI_SIO_SET_DATA_REQUEST_TYPE, 2245 urb_value , priv->interface, 2246 - buf, 0, WDR_SHORT_TIMEOUT) < 0) { 2247 dev_err(&port->dev, "%s FAILED to set " 2248 "databits/stopbits/parity\n", __func__); 2249 } ··· 2255 FTDI_SIO_SET_FLOW_CTRL_REQUEST, 2256 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 2257 0, priv->interface, 2258 - buf, 0, WDR_TIMEOUT) < 0) { 2259 dev_err(&port->dev, 2260 "%s error from disable flowcontrol urb\n", 2261 __func__); ··· 2281 FTDI_SIO_SET_FLOW_CTRL_REQUEST, 2282 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 2283 0 , (FTDI_SIO_RTS_CTS_HS | priv->interface), 2284 - buf, 0, WDR_TIMEOUT) < 0) { 2285 dev_err(&port->dev, 2286 "urb failed to set to rts/cts flow control\n"); 2287 } ··· 2313 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 2314 urb_value , (FTDI_SIO_XON_XOFF_HS 2315 | priv->interface), 2316 - buf, 0, WDR_TIMEOUT) < 0) { 2317 dev_err(&port->dev, "urb failed to set to " 2318 "xon/xoff flow control\n"); 2319 } ··· 2327 FTDI_SIO_SET_FLOW_CTRL_REQUEST, 2328 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 2329 0, priv->interface, 2330 - buf, 0, WDR_TIMEOUT) < 0) { 2331 dev_err(&port->dev, 2332 "urb failed to clear flow control\n"); 2333 } ··· 2341 { 2342 struct usb_serial_port *port = tty->driver_data; 2343 struct ftdi_private *priv = usb_get_serial_port_data(port); 2344 - unsigned char buf[2]; 2345 int ret; 2346 2347 dbg("%s TIOCMGET", __func__); 2348 switch (priv->chip_type) { 2349 case SIO: 2350 - /* Request the status from the device */ 2351 - ret = usb_control_msg(port->serial->dev, 2352 - usb_rcvctrlpipe(port->serial->dev, 0), 2353 - FTDI_SIO_GET_MODEM_STATUS_REQUEST, 2354 - FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE, 2355 - 0, 0, 2356 - buf, 1, WDR_TIMEOUT); 2357 - if (ret < 0) 2358 - return ret; 2359 break; 2360 case FT8U232AM: 2361 case FT232BM: ··· 2364 case FT232RL: 2365 case FT2232H: 2366 case FT4232H: 2367 - /* the 8U232AM returns a two byte value (the sio is a 1 byte 2368 - value) - in the same format as the data returned from the in 2369 - point */ 2370 - ret = usb_control_msg(port->serial->dev, 2371 - usb_rcvctrlpipe(port->serial->dev, 0), 2372 - FTDI_SIO_GET_MODEM_STATUS_REQUEST, 2373 - FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE, 2374 - 0, priv->interface, 2375 - buf, 2, WDR_TIMEOUT); 2376 - if (ret < 0) 2377 - return ret; 2378 break; 2379 default: 2380 - return -EFAULT; 2381 } 2382 2383 - return (buf[0] & FTDI_SIO_DSR_MASK ? TIOCM_DSR : 0) | 2384 (buf[0] & FTDI_SIO_CTS_MASK ? TIOCM_CTS : 0) | 2385 (buf[0] & FTDI_SIO_RI_MASK ? TIOCM_RI : 0) | 2386 (buf[0] & FTDI_SIO_RLSD_MASK ? TIOCM_CD : 0) | 2387 priv->last_dtr_rts; 2388 } 2389 2390 static int ftdi_tiocmset(struct tty_struct *tty, struct file *file, ··· 2492 port->throttled = port->throttle_req = 0; 2493 spin_unlock_irqrestore(&port->lock, flags); 2494 2495 - /* Resubmit urb if throttled and open. */ 2496 - if (was_throttled && test_bit(ASYNCB_INITIALIZED, &port->port.flags)) 2497 ftdi_submit_read_urb(port, GFP_KERNEL); 2498 } 2499
··· 33 #include <linux/errno.h> 34 #include <linux/init.h> 35 #include <linux/slab.h> 36 #include <linux/tty.h> 37 #include <linux/tty_driver.h> 38 #include <linux/tty_flip.h> 39 #include <linux/module.h> 40 #include <linux/spinlock.h> 41 + #include <linux/mutex.h> 42 #include <linux/uaccess.h> 43 #include <linux/usb.h> 44 #include <linux/serial.h> ··· 88 89 unsigned int latency; /* latency setting in use */ 90 spinlock_t tx_lock; /* spinlock for transmit state */ 91 unsigned long tx_outstanding_bytes; 92 unsigned long tx_outstanding_urbs; 93 unsigned short max_packet_size; 94 + struct mutex cfg_lock; /* Avoid mess by parallel calls of config ioctl() */ 95 }; 96 97 /* struct ftdi_sio_quirk is used by devices requiring special attention. */ ··· 614 { USB_DEVICE(FTDI_VID, FTDI_OCEANIC_PID) }, 615 { USB_DEVICE(TTI_VID, TTI_QL355P_PID) }, 616 { USB_DEVICE(FTDI_VID, FTDI_RM_CANVIEW_PID) }, 617 + { USB_DEVICE(CONTEC_VID, CONTEC_COM1USBH_PID) }, 618 { USB_DEVICE(BANDB_VID, BANDB_USOTL4_PID) }, 619 { USB_DEVICE(BANDB_VID, BANDB_USTL4_PID) }, 620 { USB_DEVICE(BANDB_VID, BANDB_USO9ML2_PID) }, ··· 737 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 738 { USB_DEVICE(FTDI_VID, HAMEG_HO820_PID) }, 739 { USB_DEVICE(FTDI_VID, HAMEG_HO870_PID) }, 740 + { USB_DEVICE(FTDI_VID, MJSG_GENERIC_PID) }, 741 + { USB_DEVICE(FTDI_VID, MJSG_SR_RADIO_PID) }, 742 + { USB_DEVICE(FTDI_VID, MJSG_HD_RADIO_PID) }, 743 + { USB_DEVICE(FTDI_VID, MJSG_XM_RADIO_PID) }, 744 { }, /* Optional parameter entry */ 745 { } /* Terminating entry */ 746 }; ··· 812 .name = "ftdi_sio", 813 }, 814 .description = "FTDI USB Serial Device", 815 + .usb_driver = &ftdi_driver, 816 .id_table = id_table_combined, 817 .num_ports = 1, 818 .probe = ftdi_sio_probe, ··· 828 .chars_in_buffer = ftdi_chars_in_buffer, 829 .read_bulk_callback = ftdi_read_bulk_callback, 830 .write_bulk_callback = ftdi_write_bulk_callback, 831 + .tiocmget = ftdi_tiocmget, 832 + .tiocmset = ftdi_tiocmset, 833 .ioctl = ftdi_ioctl, 834 .set_termios = ftdi_set_termios, 835 .break_ctl = ftdi_break_ctl, ··· 935 unsigned int clear) 936 { 937 struct ftdi_private *priv = usb_get_serial_port_data(port); 938 unsigned urb_value; 939 int rv; 940 ··· 943 dbg("%s - DTR|RTS not being set|cleared", __func__); 944 return 0; /* no change */ 945 } 946 947 clear &= ~set; /* 'set' takes precedence over 'clear' */ 948 urb_value = 0; ··· 963 FTDI_SIO_SET_MODEM_CTRL_REQUEST, 964 FTDI_SIO_SET_MODEM_CTRL_REQUEST_TYPE, 965 urb_value, priv->interface, 966 + NULL, 0, WDR_TIMEOUT); 967 if (rv < 0) { 968 dbg("%s Error from MODEM_CTRL urb: DTR %s, RTS %s", 969 __func__, ··· 1124 static int change_speed(struct tty_struct *tty, struct usb_serial_port *port) 1125 { 1126 struct ftdi_private *priv = usb_get_serial_port_data(port); 1127 __u16 urb_value; 1128 __u16 urb_index; 1129 __u32 urb_index_value; 1130 int rv; 1131 1132 urb_index_value = get_ftdi_divisor(tty, port); 1133 urb_value = (__u16)urb_index_value; ··· 1146 FTDI_SIO_SET_BAUDRATE_REQUEST, 1147 FTDI_SIO_SET_BAUDRATE_REQUEST_TYPE, 1148 urb_value, urb_index, 1149 + NULL, 0, WDR_SHORT_TIMEOUT); 1150 return rv; 1151 } 1152 ··· 1156 { 1157 struct ftdi_private *priv = usb_get_serial_port_data(port); 1158 struct usb_device *udev = port->serial->dev; 1159 + int rv; 1160 int l = priv->latency; 1161 1162 if (priv->flags & ASYNC_LOW_LATENCY) ··· 1170 FTDI_SIO_SET_LATENCY_TIMER_REQUEST, 1171 FTDI_SIO_SET_LATENCY_TIMER_REQUEST_TYPE, 1172 l, priv->interface, 1173 + NULL, 0, WDR_TIMEOUT); 1174 if (rv < 0) 1175 dev_err(&port->dev, "Unable to write latency timer: %i\n", rv); 1176 return rv; ··· 1181 { 1182 struct ftdi_private *priv = usb_get_serial_port_data(port); 1183 struct usb_device *udev = port->serial->dev; 1184 + unsigned char *buf; 1185 + int rv; 1186 1187 dbg("%s", __func__); 1188 + 1189 + buf = kmalloc(1, GFP_KERNEL); 1190 + if (!buf) 1191 + return -ENOMEM; 1192 1193 rv = usb_control_msg(udev, 1194 usb_rcvctrlpipe(udev, 0), 1195 FTDI_SIO_GET_LATENCY_TIMER_REQUEST, 1196 FTDI_SIO_GET_LATENCY_TIMER_REQUEST_TYPE, 1197 0, priv->interface, 1198 + buf, 1, WDR_TIMEOUT); 1199 + if (rv < 0) 1200 dev_err(&port->dev, "Unable to read latency timer: %i\n", rv); 1201 + else 1202 + priv->latency = buf[0]; 1203 + 1204 + kfree(buf); 1205 + 1206 + return rv; 1207 } 1208 1209 static int get_serial_info(struct usb_serial_port *port, ··· 1229 if (copy_from_user(&new_serial, newinfo, sizeof(new_serial))) 1230 return -EFAULT; 1231 1232 + mutex_lock(&priv->cfg_lock); 1233 old_priv = *priv; 1234 1235 /* Do error checking and permission checking */ ··· 1237 if (!capable(CAP_SYS_ADMIN)) { 1238 if (((new_serial.flags & ~ASYNC_USR_MASK) != 1239 (priv->flags & ~ASYNC_USR_MASK))) { 1240 + mutex_unlock(&priv->cfg_lock); 1241 return -EPERM; 1242 } 1243 priv->flags = ((priv->flags & ~ASYNC_USR_MASK) | ··· 1248 1249 if ((new_serial.baud_base != priv->baud_base) && 1250 (new_serial.baud_base < 9600)) { 1251 + mutex_unlock(&priv->cfg_lock); 1252 return -EINVAL; 1253 } 1254 ··· 1278 (priv->flags & ASYNC_SPD_MASK)) || 1279 (((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) && 1280 (old_priv.custom_divisor != priv->custom_divisor))) { 1281 + mutex_unlock(&priv->cfg_lock); 1282 change_speed(tty, port); 1283 } 1284 else 1285 + mutex_unlock(&priv->cfg_lock); 1286 return 0; 1287 1288 } /* set_serial_info */ ··· 1338 __func__); 1339 } 1340 } else if (version < 0x200) { 1341 + /* Old device. Assume it's the original SIO. */ 1342 priv->chip_type = SIO; 1343 priv->baud_base = 12000000 / 16; 1344 priv->write_offset = 1; 1345 } else if (version < 0x400) { 1346 + /* Assume it's an FT8U232AM (or FT8U245AM) */ 1347 /* (It might be a BM because of the iSerialNumber bug, 1348 * but it will still work as an AM device.) */ 1349 priv->chip_type = FT8U232AM; 1350 } else if (version < 0x600) { 1351 + /* Assume it's an FT232BM (or FT245BM) */ 1352 priv->chip_type = FT232BM; 1353 } else { 1354 + /* Assume it's an FT232R */ 1355 priv->chip_type = FT232RL; 1356 } 1357 dev_info(&udev->dev, "Detected %s\n", ftdi_chip_name[priv->chip_type]); ··· 1371 struct usb_endpoint_descriptor *ep_desc = &interface->cur_altsetting->endpoint[1].desc; 1372 1373 unsigned num_endpoints; 1374 + int i; 1375 1376 num_endpoints = interface->cur_altsetting->desc.bNumEndpoints; 1377 dev_info(&udev->dev, "Number of endpoints %d\n", num_endpoints); ··· 1423 struct usb_serial_port *port = to_usb_serial_port(dev); 1424 struct ftdi_private *priv = usb_get_serial_port_data(port); 1425 int v = simple_strtoul(valbuf, NULL, 10); 1426 + int rv; 1427 1428 priv->latency = v; 1429 rv = write_latency_timer(port); ··· 1440 struct usb_serial_port *port = to_usb_serial_port(dev); 1441 struct ftdi_private *priv = usb_get_serial_port_data(port); 1442 struct usb_device *udev = port->serial->dev; 1443 int v = simple_strtoul(valbuf, NULL, 10); 1444 + int rv; 1445 1446 dbg("%s: setting event char = %i", __func__, v); 1447 ··· 1451 FTDI_SIO_SET_EVENT_CHAR_REQUEST, 1452 FTDI_SIO_SET_EVENT_CHAR_REQUEST_TYPE, 1453 v, priv->interface, 1454 + NULL, 0, WDR_TIMEOUT); 1455 if (rv < 0) { 1456 dbg("Unable to write event character: %i", rv); 1457 return -EIO; ··· 1551 1552 kref_init(&priv->kref); 1553 spin_lock_init(&priv->tx_lock); 1554 + mutex_init(&priv->cfg_lock); 1555 init_waitqueue_head(&priv->delta_msr_wait); 1556 + 1557 priv->flags = ASYNC_LOW_LATENCY; 1558 1559 if (quirk && quirk->port_probe) ··· 1585 1586 ftdi_determine_type(port); 1587 ftdi_set_max_packet_size(port); 1588 + if (read_latency_timer(port) < 0) 1589 + priv->latency = 16; 1590 create_sysfs_attrs(port); 1591 return 0; 1592 } ··· 1630 { 1631 struct usb_device *udev = serial->dev; 1632 int latency = ndi_latency_timer; 1633 1634 if (latency == 0) 1635 latency = 1; ··· 1641 dbg("%s setting NDI device latency to %d", __func__, latency); 1642 dev_info(&udev->dev, "NDI device with a latency value of %d", latency); 1643 1644 + /* FIXME: errors are not returned */ 1645 + usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 1646 FTDI_SIO_SET_LATENCY_TIMER_REQUEST, 1647 FTDI_SIO_SET_LATENCY_TIMER_REQUEST_TYPE, 1648 + latency, 0, NULL, 0, WDR_TIMEOUT); 1649 return 0; 1650 } 1651 ··· 1720 urb->transfer_buffer_length, 1721 ftdi_read_bulk_callback, port); 1722 result = usb_submit_urb(urb, mem_flags); 1723 + if (result && result != -EPERM) 1724 dev_err(&port->dev, 1725 "%s - failed submitting read urb, error %d\n", 1726 __func__, result); ··· 1732 struct usb_device *dev = port->serial->dev; 1733 struct ftdi_private *priv = usb_get_serial_port_data(port); 1734 unsigned long flags; 1735 + int result; 1736 1737 dbg("%s", __func__); 1738 1739 write_latency_timer(port); 1740 ··· 1749 usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 1750 FTDI_SIO_RESET_REQUEST, FTDI_SIO_RESET_REQUEST_TYPE, 1751 FTDI_SIO_RESET_SIO, 1752 + priv->interface, NULL, 0, WDR_TIMEOUT); 1753 1754 /* Termios defaults are set by usb_serial_init. We don't change 1755 port->tty->termios - this would lose speed settings, etc. ··· 1777 static void ftdi_dtr_rts(struct usb_serial_port *port, int on) 1778 { 1779 struct ftdi_private *priv = usb_get_serial_port_data(port); 1780 1781 mutex_lock(&port->serial->disc_mutex); 1782 if (!port->serial->disconnected) { ··· 1786 usb_sndctrlpipe(port->serial->dev, 0), 1787 FTDI_SIO_SET_FLOW_CTRL_REQUEST, 1788 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 1789 + 0, priv->interface, NULL, 0, 1790 WDR_TIMEOUT) < 0) { 1791 dev_err(&port->dev, "error from flowcontrol urb\n"); 1792 } ··· 1847 spin_lock_irqsave(&priv->tx_lock, flags); 1848 if (priv->tx_outstanding_urbs > URB_UPPER_LIMIT) { 1849 spin_unlock_irqrestore(&priv->tx_lock, flags); 1850 + dbg("%s - write limit hit", __func__); 1851 return 0; 1852 } 1853 priv->tx_outstanding_urbs++; ··· 1927 } else { 1928 spin_lock_irqsave(&priv->tx_lock, flags); 1929 priv->tx_outstanding_bytes += count; 1930 spin_unlock_irqrestore(&priv->tx_lock, flags); 1931 } 1932 ··· 2154 { 2155 struct usb_serial_port *port = tty->driver_data; 2156 struct ftdi_private *priv = usb_get_serial_port_data(port); 2157 + __u16 urb_value; 2158 2159 /* break_state = -1 to turn on break, and 0 to turn off break */ 2160 /* see drivers/char/tty_io.c to see it used */ ··· 2171 FTDI_SIO_SET_DATA_REQUEST, 2172 FTDI_SIO_SET_DATA_REQUEST_TYPE, 2173 urb_value , priv->interface, 2174 + NULL, 0, WDR_TIMEOUT) < 0) { 2175 dev_err(&port->dev, "%s FAILED to enable/disable break state " 2176 "(state was %d)\n", __func__, break_state); 2177 } ··· 2195 struct ktermios *termios = tty->termios; 2196 unsigned int cflag = termios->c_cflag; 2197 __u16 urb_value; /* will hold the new flags */ 2198 2199 /* Added for xon/xoff support */ 2200 unsigned int iflag = termios->c_iflag; ··· 2246 } 2247 if (cflag & CSIZE) { 2248 switch (cflag & CSIZE) { 2249 case CS7: urb_value |= 7; dbg("Setting CS7"); break; 2250 case CS8: urb_value |= 8; dbg("Setting CS8"); break; 2251 default: 2252 + dev_err(&port->dev, "CSIZE was set but not CS7-CS8\n"); 2253 } 2254 } 2255 ··· 2263 FTDI_SIO_SET_DATA_REQUEST, 2264 FTDI_SIO_SET_DATA_REQUEST_TYPE, 2265 urb_value , priv->interface, 2266 + NULL, 0, WDR_SHORT_TIMEOUT) < 0) { 2267 dev_err(&port->dev, "%s FAILED to set " 2268 "databits/stopbits/parity\n", __func__); 2269 } ··· 2275 FTDI_SIO_SET_FLOW_CTRL_REQUEST, 2276 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 2277 0, priv->interface, 2278 + NULL, 0, WDR_TIMEOUT) < 0) { 2279 dev_err(&port->dev, 2280 "%s error from disable flowcontrol urb\n", 2281 __func__); ··· 2301 FTDI_SIO_SET_FLOW_CTRL_REQUEST, 2302 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 2303 0 , (FTDI_SIO_RTS_CTS_HS | priv->interface), 2304 + NULL, 0, WDR_TIMEOUT) < 0) { 2305 dev_err(&port->dev, 2306 "urb failed to set to rts/cts flow control\n"); 2307 } ··· 2333 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 2334 urb_value , (FTDI_SIO_XON_XOFF_HS 2335 | priv->interface), 2336 + NULL, 0, WDR_TIMEOUT) < 0) { 2337 dev_err(&port->dev, "urb failed to set to " 2338 "xon/xoff flow control\n"); 2339 } ··· 2347 FTDI_SIO_SET_FLOW_CTRL_REQUEST, 2348 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 2349 0, priv->interface, 2350 + NULL, 0, WDR_TIMEOUT) < 0) { 2351 dev_err(&port->dev, 2352 "urb failed to clear flow control\n"); 2353 } ··· 2361 { 2362 struct usb_serial_port *port = tty->driver_data; 2363 struct ftdi_private *priv = usb_get_serial_port_data(port); 2364 + unsigned char *buf; 2365 + int len; 2366 int ret; 2367 2368 dbg("%s TIOCMGET", __func__); 2369 + 2370 + buf = kmalloc(2, GFP_KERNEL); 2371 + if (!buf) 2372 + return -ENOMEM; 2373 + /* 2374 + * The 8U232AM returns a two byte value (the SIO a 1 byte value) in 2375 + * the same format as the data returned from the in point. 2376 + */ 2377 switch (priv->chip_type) { 2378 case SIO: 2379 + len = 1; 2380 break; 2381 case FT8U232AM: 2382 case FT232BM: ··· 2383 case FT232RL: 2384 case FT2232H: 2385 case FT4232H: 2386 + len = 2; 2387 break; 2388 default: 2389 + ret = -EFAULT; 2390 + goto out; 2391 } 2392 2393 + ret = usb_control_msg(port->serial->dev, 2394 + usb_rcvctrlpipe(port->serial->dev, 0), 2395 + FTDI_SIO_GET_MODEM_STATUS_REQUEST, 2396 + FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE, 2397 + 0, priv->interface, 2398 + buf, len, WDR_TIMEOUT); 2399 + if (ret < 0) 2400 + goto out; 2401 + 2402 + ret = (buf[0] & FTDI_SIO_DSR_MASK ? TIOCM_DSR : 0) | 2403 (buf[0] & FTDI_SIO_CTS_MASK ? TIOCM_CTS : 0) | 2404 (buf[0] & FTDI_SIO_RI_MASK ? TIOCM_RI : 0) | 2405 (buf[0] & FTDI_SIO_RLSD_MASK ? TIOCM_CD : 0) | 2406 priv->last_dtr_rts; 2407 + out: 2408 + kfree(buf); 2409 + return ret; 2410 } 2411 2412 static int ftdi_tiocmset(struct tty_struct *tty, struct file *file, ··· 2508 port->throttled = port->throttle_req = 0; 2509 spin_unlock_irqrestore(&port->lock, flags); 2510 2511 + if (was_throttled) 2512 ftdi_submit_read_urb(port, GFP_KERNEL); 2513 } 2514
+3 -3
drivers/usb/serial/ftdi_sio.h
··· 28 #define FTDI_SIO_SET_FLOW_CTRL 2 /* Set flow control register */ 29 #define FTDI_SIO_SET_BAUD_RATE 3 /* Set baud rate */ 30 #define FTDI_SIO_SET_DATA 4 /* Set the data characteristics of the port */ 31 - #define FTDI_SIO_GET_MODEM_STATUS 5 /* Retrieve current value of modern status register */ 32 #define FTDI_SIO_SET_EVENT_CHAR 6 /* Set the event character */ 33 #define FTDI_SIO_SET_ERROR_CHAR 7 /* Set the error character */ 34 #define FTDI_SIO_SET_LATENCY_TIMER 9 /* Set the latency timer */ 35 #define FTDI_SIO_GET_LATENCY_TIMER 10 /* Get the latency timer */ 36 37 - /* Interface indicies for FT2232, FT2232H and FT4232H devices*/ 38 #define INTERFACE_A 1 39 #define INTERFACE_B 2 40 #define INTERFACE_C 3 ··· 270 * BmRequestType: 0100 0000b 271 * bRequest: FTDI_SIO_SET_FLOW_CTRL 272 * wValue: Xoff/Xon 273 - * wIndex: Protocol/Port - hIndex is protocl / lIndex is port 274 * wLength: 0 275 * Data: None 276 *
··· 28 #define FTDI_SIO_SET_FLOW_CTRL 2 /* Set flow control register */ 29 #define FTDI_SIO_SET_BAUD_RATE 3 /* Set baud rate */ 30 #define FTDI_SIO_SET_DATA 4 /* Set the data characteristics of the port */ 31 + #define FTDI_SIO_GET_MODEM_STATUS 5 /* Retrieve current value of modem status register */ 32 #define FTDI_SIO_SET_EVENT_CHAR 6 /* Set the event character */ 33 #define FTDI_SIO_SET_ERROR_CHAR 7 /* Set the error character */ 34 #define FTDI_SIO_SET_LATENCY_TIMER 9 /* Set the latency timer */ 35 #define FTDI_SIO_GET_LATENCY_TIMER 10 /* Get the latency timer */ 36 37 + /* Interface indices for FT2232, FT2232H and FT4232H devices */ 38 #define INTERFACE_A 1 39 #define INTERFACE_B 2 40 #define INTERFACE_C 3 ··· 270 * BmRequestType: 0100 0000b 271 * bRequest: FTDI_SIO_SET_FLOW_CTRL 272 * wValue: Xoff/Xon 273 + * wIndex: Protocol/Port - hIndex is protocol / lIndex is port 274 * wLength: 0 275 * Data: None 276 *
+27 -12
drivers/usb/serial/ftdi_sio_ids.h
··· 22 #define FTDI_8U232AM_ALT_PID 0x6006 /* FTDI's alternate PID for above */ 23 #define FTDI_8U2232C_PID 0x6010 /* Dual channel device */ 24 #define FTDI_4232H_PID 0x6011 /* Quad channel hi-speed device */ 25 - #define FTDI_SIO_PID 0x8372 /* Product Id SIO application of 8U100AX */ 26 #define FTDI_232RL_PID 0xFBFA /* Product ID for FT232RL */ 27 28 ··· 49 #define LMI_LM3S_DEVEL_BOARD_PID 0xbcd8 50 #define LMI_LM3S_EVAL_BOARD_PID 0xbcd9 51 52 - #define FTDI_TURTELIZER_PID 0xBDC8 /* JTAG/RS-232 adapter by egnite GmBH */ 53 54 /* OpenDCC (www.opendcc.de) product id */ 55 #define FTDI_OPENDCC_PID 0xBFD8 ··· 185 #define FTDI_ELV_TFD128_PID 0xE0EC /* ELV Temperatur-Feuchte-Datenlogger TFD 128 */ 186 #define FTDI_ELV_FM3RX_PID 0xE0ED /* ELV Messwertuebertragung FM3 RX */ 187 #define FTDI_ELV_WS777_PID 0xE0EE /* Conrad WS 777 */ 188 - #define FTDI_ELV_EM1010PC_PID 0xE0EF /* Engery monitor EM 1010 PC */ 189 #define FTDI_ELV_CSI8_PID 0xE0F0 /* Computer-Schalt-Interface (CSI 8) */ 190 #define FTDI_ELV_EM1000DL_PID 0xE0F1 /* PC-Datenlogger fuer Energiemonitor (EM 1000 DL) */ 191 #define FTDI_ELV_PCK100_PID 0xE0F2 /* PC-Kabeltester (PCK 100) */ ··· 212 * drivers, or possibly the Comedi drivers in some cases. */ 213 #define FTDI_ELV_CLI7000_PID 0xFB59 /* Computer-Light-Interface (CLI 7000) */ 214 #define FTDI_ELV_PPS7330_PID 0xFB5C /* Processor-Power-Supply (PPS 7330) */ 215 - #define FTDI_ELV_TFM100_PID 0xFB5D /* Temperartur-Feuchte Messgeraet (TFM 100) */ 216 - #define FTDI_ELV_UDF77_PID 0xFB5E /* USB DCF Funkurh (UDF 77) */ 217 #define FTDI_ELV_UIO88_PID 0xFB5F /* USB-I/O Interface (UIO 88) */ 218 219 /* ··· 320 321 /* 322 * 4N-GALAXY.DE PIDs for CAN-USB, USB-RS232, USB-RS422, USB-RS485, 323 - * USB-TTY activ, USB-TTY passiv. Some PIDs are used by several devices 324 * and I'm not entirely sure which are used by which. 325 */ 326 #define FTDI_4N_GALAXY_DE_1_PID 0xF3C0 ··· 330 * Linx Technologies product ids 331 */ 332 #define LINX_SDMUSBQSS_PID 0xF448 /* Linx SDM-USB-QS-S */ 333 - #define LINX_MASTERDEVEL2_PID 0xF449 /* Linx Master Development 2.0 */ 334 - #define LINX_FUTURE_0_PID 0xF44A /* Linx future device */ 335 - #define LINX_FUTURE_1_PID 0xF44B /* Linx future device */ 336 - #define LINX_FUTURE_2_PID 0xF44C /* Linx future device */ 337 338 /* 339 * Oceanic product ids ··· 494 #define RATOC_PRODUCT_ID_USB60F 0xb020 495 496 /* 497 * Definitions for B&B Electronics products. 498 */ 499 #define BANDB_VID 0x0856 /* B&B Electronics Vendor ID */ ··· 649 #define FALCOM_TWIST_PID 0x0001 /* Falcom Twist USB GPRS modem */ 650 #define FALCOM_SAMBA_PID 0x0005 /* Falcom Samba USB GPRS modem */ 651 652 - /* Larsen and Brusgaard AltiTrack/USBtrack */ 653 #define LARSENBRUSGAARD_VID 0x0FD8 654 #define LB_ALTITRACK_PID 0x0001 655 ··· 978 #define ALTI2_N3_PID 0x6001 /* Neptune 3 */ 979 980 /* 981 - * Dresden Elektronic Sensor Terminal Board 982 */ 983 #define DE_VID 0x1cf1 /* Vendor ID */ 984 #define STB_PID 0x0001 /* Sensor Terminal Board */ ··· 1009 #define EVO_8U232AM_PID 0x02FF /* Evolution robotics RCM2 (FT232AM)*/ 1010 #define EVO_HYBRID_PID 0x0302 /* Evolution robotics RCM4 PID (FT232BM)*/ 1011 #define EVO_RCM4_PID 0x0303 /* Evolution robotics RCM4 PID */
··· 22 #define FTDI_8U232AM_ALT_PID 0x6006 /* FTDI's alternate PID for above */ 23 #define FTDI_8U2232C_PID 0x6010 /* Dual channel device */ 24 #define FTDI_4232H_PID 0x6011 /* Quad channel hi-speed device */ 25 + #define FTDI_SIO_PID 0x8372 /* Product Id SIO application of 8U100AX */ 26 #define FTDI_232RL_PID 0xFBFA /* Product ID for FT232RL */ 27 28 ··· 49 #define LMI_LM3S_DEVEL_BOARD_PID 0xbcd8 50 #define LMI_LM3S_EVAL_BOARD_PID 0xbcd9 51 52 + #define FTDI_TURTELIZER_PID 0xBDC8 /* JTAG/RS-232 adapter by egnite GmbH */ 53 54 /* OpenDCC (www.opendcc.de) product id */ 55 #define FTDI_OPENDCC_PID 0xBFD8 ··· 185 #define FTDI_ELV_TFD128_PID 0xE0EC /* ELV Temperatur-Feuchte-Datenlogger TFD 128 */ 186 #define FTDI_ELV_FM3RX_PID 0xE0ED /* ELV Messwertuebertragung FM3 RX */ 187 #define FTDI_ELV_WS777_PID 0xE0EE /* Conrad WS 777 */ 188 + #define FTDI_ELV_EM1010PC_PID 0xE0EF /* Energy monitor EM 1010 PC */ 189 #define FTDI_ELV_CSI8_PID 0xE0F0 /* Computer-Schalt-Interface (CSI 8) */ 190 #define FTDI_ELV_EM1000DL_PID 0xE0F1 /* PC-Datenlogger fuer Energiemonitor (EM 1000 DL) */ 191 #define FTDI_ELV_PCK100_PID 0xE0F2 /* PC-Kabeltester (PCK 100) */ ··· 212 * drivers, or possibly the Comedi drivers in some cases. */ 213 #define FTDI_ELV_CLI7000_PID 0xFB59 /* Computer-Light-Interface (CLI 7000) */ 214 #define FTDI_ELV_PPS7330_PID 0xFB5C /* Processor-Power-Supply (PPS 7330) */ 215 + #define FTDI_ELV_TFM100_PID 0xFB5D /* Temperatur-Feuchte-Messgeraet (TFM 100) */ 216 + #define FTDI_ELV_UDF77_PID 0xFB5E /* USB DCF Funkuhr (UDF 77) */ 217 #define FTDI_ELV_UIO88_PID 0xFB5F /* USB-I/O Interface (UIO 88) */ 218 219 /* ··· 320 321 /* 322 * 4N-GALAXY.DE PIDs for CAN-USB, USB-RS232, USB-RS422, USB-RS485, 323 + * USB-TTY aktiv, USB-TTY passiv. Some PIDs are used by several devices 324 * and I'm not entirely sure which are used by which. 325 */ 326 #define FTDI_4N_GALAXY_DE_1_PID 0xF3C0 ··· 330 * Linx Technologies product ids 331 */ 332 #define LINX_SDMUSBQSS_PID 0xF448 /* Linx SDM-USB-QS-S */ 333 + #define LINX_MASTERDEVEL2_PID 0xF449 /* Linx Master Development 2.0 */ 334 + #define LINX_FUTURE_0_PID 0xF44A /* Linx future device */ 335 + #define LINX_FUTURE_1_PID 0xF44B /* Linx future device */ 336 + #define LINX_FUTURE_2_PID 0xF44C /* Linx future device */ 337 338 /* 339 * Oceanic product ids ··· 494 #define RATOC_PRODUCT_ID_USB60F 0xb020 495 496 /* 497 + * Contec products (http://www.contec.com) 498 + * Submitted by Daniel Sangorrin 499 + */ 500 + #define CONTEC_VID 0x06CE /* Vendor ID */ 501 + #define CONTEC_COM1USBH_PID 0x8311 /* COM-1(USB)H */ 502 + 503 + /* 504 * Definitions for B&B Electronics products. 505 */ 506 #define BANDB_VID 0x0856 /* B&B Electronics Vendor ID */ ··· 642 #define FALCOM_TWIST_PID 0x0001 /* Falcom Twist USB GPRS modem */ 643 #define FALCOM_SAMBA_PID 0x0005 /* Falcom Samba USB GPRS modem */ 644 645 + /* Larsen and Brusgaard AltiTrack/USBtrack */ 646 #define LARSENBRUSGAARD_VID 0x0FD8 647 #define LB_ALTITRACK_PID 0x0001 648 ··· 971 #define ALTI2_N3_PID 0x6001 /* Neptune 3 */ 972 973 /* 974 + * Dresden Elektronik Sensor Terminal Board 975 */ 976 #define DE_VID 0x1cf1 /* Vendor ID */ 977 #define STB_PID 0x0001 /* Sensor Terminal Board */ ··· 1002 #define EVO_8U232AM_PID 0x02FF /* Evolution robotics RCM2 (FT232AM)*/ 1003 #define EVO_HYBRID_PID 0x0302 /* Evolution robotics RCM4 PID (FT232BM)*/ 1004 #define EVO_RCM4_PID 0x0303 /* Evolution robotics RCM4 PID */ 1005 + 1006 + /* 1007 + * MJS Gadgets HD Radio / XM Radio / Sirius Radio interfaces (using VID 0x0403) 1008 + */ 1009 + #define MJSG_GENERIC_PID 0x9378 1010 + #define MJSG_SR_RADIO_PID 0x9379 1011 + #define MJSG_XM_RADIO_PID 0x937A 1012 + #define MJSG_HD_RADIO_PID 0x937C
+1 -1
drivers/usb/serial/funsoft.c
··· 18 19 static int debug; 20 21 - static struct usb_device_id id_table [] = { 22 { USB_DEVICE(0x1404, 0xcddc) }, 23 { }, 24 };
··· 18 19 static int debug; 20 21 + static const struct usb_device_id id_table[] = { 22 { USB_DEVICE(0x1404, 0xcddc) }, 23 { }, 24 };
+1 -2
drivers/usb/serial/garmin_gps.c
··· 210 211 212 213 - static struct usb_device_id id_table [] = { 214 /* the same device id seems to be used by all 215 usb enabled GPS devices */ 216 { USB_DEVICE(GARMIN_VENDOR_ID, 3) }, ··· 271 usb_serial_debug_data(debug, &port->dev, 272 __func__, actual_length, data); 273 274 - tty_buffer_request_room(tty, actual_length); 275 tty_insert_flip_string(tty, data, actual_length); 276 tty_flip_buffer_push(tty); 277 }
··· 210 211 212 213 + static const struct usb_device_id id_table[] = { 214 /* the same device id seems to be used by all 215 usb enabled GPS devices */ 216 { USB_DEVICE(GARMIN_VENDOR_ID, 3) }, ··· 271 usb_serial_debug_data(debug, &port->dev, 272 __func__, actual_length, data); 273 274 tty_insert_flip_string(tty, data, actual_length); 275 tty_flip_buffer_push(tty); 276 }
+4 -3
drivers/usb/serial/generic.c
··· 20 #include <linux/usb/serial.h> 21 #include <linux/uaccess.h> 22 #include <linux/kfifo.h> 23 24 static int debug; 25 ··· 42 43 /* we want to look at all devices, as the vendor/product id can change 44 * depending on the command line argument */ 45 - static struct usb_device_id generic_serial_ids[] = { 46 {.driver_info = 42}, 47 {} 48 }; ··· 195 if (port->urbs_in_flight > 196 port->serial->type->max_in_flight_urbs) { 197 spin_unlock_irqrestore(&port->lock, flags); 198 - dbg("%s - write limit hit\n", __func__); 199 return bwrite; 200 } 201 port->tx_bytes_flight += towrite; ··· 586 587 for (i = 0; i < serial->num_ports; i++) { 588 port = serial->port[i]; 589 - if (!port->port.count) 590 continue; 591 592 if (port->read_urb) {
··· 20 #include <linux/usb/serial.h> 21 #include <linux/uaccess.h> 22 #include <linux/kfifo.h> 23 + #include <linux/serial.h> 24 25 static int debug; 26 ··· 41 42 /* we want to look at all devices, as the vendor/product id can change 43 * depending on the command line argument */ 44 + static const struct usb_device_id generic_serial_ids[] = { 45 {.driver_info = 42}, 46 {} 47 }; ··· 194 if (port->urbs_in_flight > 195 port->serial->type->max_in_flight_urbs) { 196 spin_unlock_irqrestore(&port->lock, flags); 197 + dbg("%s - write limit hit", __func__); 198 return bwrite; 199 } 200 port->tx_bytes_flight += towrite; ··· 585 586 for (i = 0; i < serial->num_ports; i++) { 587 port = serial->port[i]; 588 + if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) 589 continue; 590 591 if (port->read_urb) {
+1 -1
drivers/usb/serial/hp4x.c
··· 29 #define HP_VENDOR_ID 0x03f0 30 #define HP49GP_PRODUCT_ID 0x0121 31 32 - static struct usb_device_id id_table [] = { 33 { USB_DEVICE(HP_VENDOR_ID, HP49GP_PRODUCT_ID) }, 34 { } /* Terminating entry */ 35 };
··· 29 #define HP_VENDOR_ID 0x03f0 30 #define HP49GP_PRODUCT_ID 0x0121 31 32 + static const struct usb_device_id id_table[] = { 33 { USB_DEVICE(HP_VENDOR_ID, HP49GP_PRODUCT_ID) }, 34 { } /* Terminating entry */ 35 };
+15 -54
drivers/usb/serial/io_edgeport.c
··· 364 release_firmware(fw); 365 } 366 367 - 368 - /************************************************************************ 369 - * * 370 - * Get string descriptor from device * 371 - * * 372 - ************************************************************************/ 373 - static int get_string(struct usb_device *dev, int Id, char *string, int buflen) 374 - { 375 - struct usb_string_descriptor StringDesc; 376 - struct usb_string_descriptor *pStringDesc; 377 - 378 - dbg("%s - USB String ID = %d", __func__, Id); 379 - 380 - if (!usb_get_descriptor(dev, USB_DT_STRING, Id, 381 - &StringDesc, sizeof(StringDesc))) 382 - return 0; 383 - 384 - pStringDesc = kmalloc(StringDesc.bLength, GFP_KERNEL); 385 - if (!pStringDesc) 386 - return 0; 387 - 388 - if (!usb_get_descriptor(dev, USB_DT_STRING, Id, 389 - pStringDesc, StringDesc.bLength)) { 390 - kfree(pStringDesc); 391 - return 0; 392 - } 393 - 394 - unicode_to_ascii(string, buflen, 395 - pStringDesc->wData, pStringDesc->bLength/2); 396 - 397 - kfree(pStringDesc); 398 - dbg("%s - USB String %s", __func__, string); 399 - return strlen(string); 400 - } 401 - 402 - 403 #if 0 404 /************************************************************************ 405 * ··· 1971 return; 1972 1973 case IOSP_EXT_STATUS_RX_CHECK_RSP: 1974 - dbg("%s ========== Port %u CHECK_RSP Sequence = %02x =============\n", __func__, edge_serial->rxPort, byte3); 1975 /* Port->RxCheckRsp = true; */ 1976 return; 1977 } ··· 2039 break; 2040 2041 default: 2042 - dbg("%s - Unrecognized IOSP status code %u\n", __func__, code); 2043 break; 2044 } 2045 return; ··· 2055 { 2056 int cnt; 2057 2058 - do { 2059 - cnt = tty_buffer_request_room(tty, length); 2060 - if (cnt < length) { 2061 - dev_err(dev, "%s - dropping data, %d bytes lost\n", 2062 - __func__, length - cnt); 2063 - if (cnt == 0) 2064 - break; 2065 - } 2066 - tty_insert_flip_string(tty, data, cnt); 2067 - data += cnt; 2068 - length -= cnt; 2069 - } while (length > 0); 2070 2071 tty_flip_buffer_push(tty); 2072 } ··· 2489 2490 *divisor = custom; 2491 2492 - dbg("%s - Baud %d = %d\n", __func__, baudrate, custom); 2493 return 0; 2494 } 2495 ··· 2874 break; 2875 2876 case EDGE_DOWNLOAD_FILE_NONE: 2877 - dbg ("No download file specified, skipping download\n"); 2878 return; 2879 2880 default: ··· 2956 usb_set_serial_data(serial, edge_serial); 2957 2958 /* get the name for the device from the device */ 2959 - i = get_string(dev, dev->descriptor.iManufacturer, 2960 &edge_serial->name[0], MAX_NAME_LEN+1); 2961 edge_serial->name[i++] = ' '; 2962 - get_string(dev, dev->descriptor.iProduct, 2963 &edge_serial->name[i], MAX_NAME_LEN+2 - i); 2964 2965 dev_info(&serial->dev->dev, "%s detected\n", edge_serial->name);
··· 364 release_firmware(fw); 365 } 366 367 #if 0 368 /************************************************************************ 369 * ··· 2007 return; 2008 2009 case IOSP_EXT_STATUS_RX_CHECK_RSP: 2010 + dbg("%s ========== Port %u CHECK_RSP Sequence = %02x =============", __func__, edge_serial->rxPort, byte3); 2011 /* Port->RxCheckRsp = true; */ 2012 return; 2013 } ··· 2075 break; 2076 2077 default: 2078 + dbg("%s - Unrecognized IOSP status code %u", __func__, code); 2079 break; 2080 } 2081 return; ··· 2091 { 2092 int cnt; 2093 2094 + cnt = tty_insert_flip_string(tty, data, length); 2095 + if (cnt < length) { 2096 + dev_err(dev, "%s - dropping data, %d bytes lost\n", 2097 + __func__, length - cnt); 2098 + } 2099 + data += cnt; 2100 + length -= cnt; 2101 2102 tty_flip_buffer_push(tty); 2103 } ··· 2530 2531 *divisor = custom; 2532 2533 + dbg("%s - Baud %d = %d", __func__, baudrate, custom); 2534 return 0; 2535 } 2536 ··· 2915 break; 2916 2917 case EDGE_DOWNLOAD_FILE_NONE: 2918 + dbg("No download file specified, skipping download"); 2919 return; 2920 2921 default: ··· 2997 usb_set_serial_data(serial, edge_serial); 2998 2999 /* get the name for the device from the device */ 3000 + i = usb_string(dev, dev->descriptor.iManufacturer, 3001 &edge_serial->name[0], MAX_NAME_LEN+1); 3002 + if (i < 0) 3003 + i = 0; 3004 edge_serial->name[i++] = ' '; 3005 + usb_string(dev, dev->descriptor.iProduct, 3006 &edge_serial->name[i], MAX_NAME_LEN+2 - i); 3007 3008 dev_info(&serial->dev->dev, "%s detected\n", edge_serial->name);
+5 -5
drivers/usb/serial/io_tables.h
··· 14 #ifndef IO_TABLES_H 15 #define IO_TABLES_H 16 17 - static struct usb_device_id edgeport_2port_id_table [] = { 18 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_EDGEPORT_2) }, 19 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_EDGEPORT_2I) }, 20 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_EDGEPORT_421) }, ··· 23 { } 24 }; 25 26 - static struct usb_device_id edgeport_4port_id_table [] = { 27 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_EDGEPORT_4) }, 28 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_RAPIDPORT_4) }, 29 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_EDGEPORT_4T) }, ··· 37 { } 38 }; 39 40 - static struct usb_device_id edgeport_8port_id_table [] = { 41 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_EDGEPORT_8) }, 42 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_EDGEPORT_16_DUAL_CPU) }, 43 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_EDGEPORT_8I) }, ··· 47 { } 48 }; 49 50 - static struct usb_device_id Epic_port_id_table [] = { 51 { USB_DEVICE(USB_VENDOR_ID_NCR, NCR_DEVICE_ID_EPIC_0202) }, 52 { USB_DEVICE(USB_VENDOR_ID_NCR, NCR_DEVICE_ID_EPIC_0203) }, 53 { USB_DEVICE(USB_VENDOR_ID_NCR, NCR_DEVICE_ID_EPIC_0310) }, ··· 60 }; 61 62 /* Devices that this driver supports */ 63 - static struct usb_device_id id_table_combined [] = { 64 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_EDGEPORT_4) }, 65 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_RAPIDPORT_4) }, 66 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_EDGEPORT_4T) },
··· 14 #ifndef IO_TABLES_H 15 #define IO_TABLES_H 16 17 + static const struct usb_device_id edgeport_2port_id_table[] = { 18 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_EDGEPORT_2) }, 19 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_EDGEPORT_2I) }, 20 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_EDGEPORT_421) }, ··· 23 { } 24 }; 25 26 + static const struct usb_device_id edgeport_4port_id_table[] = { 27 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_EDGEPORT_4) }, 28 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_RAPIDPORT_4) }, 29 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_EDGEPORT_4T) }, ··· 37 { } 38 }; 39 40 + static const struct usb_device_id edgeport_8port_id_table[] = { 41 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_EDGEPORT_8) }, 42 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_EDGEPORT_16_DUAL_CPU) }, 43 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_EDGEPORT_8I) }, ··· 47 { } 48 }; 49 50 + static const struct usb_device_id Epic_port_id_table[] = { 51 { USB_DEVICE(USB_VENDOR_ID_NCR, NCR_DEVICE_ID_EPIC_0202) }, 52 { USB_DEVICE(USB_VENDOR_ID_NCR, NCR_DEVICE_ID_EPIC_0203) }, 53 { USB_DEVICE(USB_VENDOR_ID_NCR, NCR_DEVICE_ID_EPIC_0310) }, ··· 60 }; 61 62 /* Devices that this driver supports */ 63 + static const struct usb_device_id id_table_combined[] = { 64 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_EDGEPORT_4) }, 65 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_RAPIDPORT_4) }, 66 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_EDGEPORT_4T) },
+52 -23
drivers/usb/serial/io_ti.c
··· 134 135 136 /* Devices that this driver supports */ 137 - static struct usb_device_id edgeport_1port_id_table [] = { 138 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_1) }, 139 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_TI3410_EDGEPORT_1) }, 140 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_TI3410_EDGEPORT_1I) }, ··· 154 { } 155 }; 156 157 - static struct usb_device_id edgeport_2port_id_table [] = { 158 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_2) }, 159 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_2C) }, 160 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_2I) }, ··· 177 }; 178 179 /* Devices that this driver supports */ 180 - static struct usb_device_id id_table_combined [] = { 181 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_1) }, 182 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_TI3410_EDGEPORT_1) }, 183 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_TI3410_EDGEPORT_1I) }, ··· 413 { 414 int status = 0; 415 int i; 416 - __u8 temp; 417 418 /* Must do a read before write */ 419 if (!serial->TiReadI2C) { 420 - status = read_boot_mem(serial, 0, 1, &temp); 421 if (status) 422 return status; 423 } ··· 942 static int i2c_type_bootmode(struct edgeport_serial *serial) 943 { 944 int status; 945 - __u8 data; 946 947 /* Try to read type 2 */ 948 status = ti_vread_sync(serial->serial->dev, UMPC_MEMORY_READ, 949 - DTK_ADDR_SPACE_I2C_TYPE_II, 0, &data, 0x01); 950 if (status) 951 dbg("%s - read 2 status error = %d", __func__, status); 952 else 953 - dbg("%s - read 2 data = 0x%x", __func__, data); 954 - if ((!status) && (data == UMP5152 || data == UMP3410)) { 955 dbg("%s - ROM_TYPE_II", __func__); 956 serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_II; 957 - return 0; 958 } 959 960 /* Try to read type 3 */ 961 status = ti_vread_sync(serial->serial->dev, UMPC_MEMORY_READ, 962 - DTK_ADDR_SPACE_I2C_TYPE_III, 0, &data, 0x01); 963 if (status) 964 dbg("%s - read 3 status error = %d", __func__, status); 965 else 966 - dbg("%s - read 2 data = 0x%x", __func__, data); 967 - if ((!status) && (data == UMP5152 || data == UMP3410)) { 968 dbg("%s - ROM_TYPE_III", __func__); 969 serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_III; 970 - return 0; 971 } 972 973 dbg("%s - Unknown", __func__); 974 serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_II; 975 - return -ENODEV; 976 } 977 978 static int bulk_xfer(struct usb_serial *serial, void *buffer, ··· 1130 I2C_DESC_TYPE_FIRMWARE_BASIC, rom_desc); 1131 if (start_address != 0) { 1132 struct ti_i2c_firmware_rec *firmware_version; 1133 - __u8 record; 1134 1135 dbg("%s - Found Type FIRMWARE (Type 2) record", 1136 __func__); ··· 1182 OperationalMajorVersion, 1183 OperationalMinorVersion); 1184 1185 /* In order to update the I2C firmware we must 1186 * change the type 2 record to type 0xF2. This 1187 * will force the UMP to come up in Boot Mode. ··· 1203 * firmware will update the record type from 1204 * 0xf2 to 0x02. 1205 */ 1206 - record = I2C_DESC_TYPE_FIRMWARE_BLANK; 1207 1208 /* Change the I2C Firmware record type to 1209 0xf2 to trigger an update */ 1210 status = write_rom(serial, start_address, 1211 - sizeof(record), &record); 1212 if (status) { 1213 kfree(firmware_version); 1214 kfree(rom_desc); 1215 kfree(ti_manuf_desc); ··· 1223 */ 1224 status = read_rom(serial, 1225 start_address, 1226 - sizeof(record), 1227 - &record); 1228 if (status) { 1229 kfree(firmware_version); 1230 kfree(rom_desc); 1231 kfree(ti_manuf_desc); 1232 return status; 1233 } 1234 1235 - if (record != I2C_DESC_TYPE_FIRMWARE_BLANK) { 1236 dev_err(dev, 1237 "%s - error resetting device\n", 1238 __func__); 1239 kfree(firmware_version); 1240 kfree(rom_desc); 1241 kfree(ti_manuf_desc); ··· 1255 __func__, status); 1256 1257 /* return an error on purpose. */ 1258 kfree(firmware_version); 1259 kfree(rom_desc); 1260 kfree(ti_manuf_desc); ··· 1716 case TIUMP_INTERRUPT_CODE_MSR: /* MSR */ 1717 /* Copy MSR from UMP */ 1718 msr = data[1]; 1719 - dbg("%s - ===== Port %u MSR Status = %02x ======\n", 1720 __func__, port_number, msr); 1721 handle_new_msr(edge_port, msr); 1722 break; ··· 1820 { 1821 int queued; 1822 1823 - tty_buffer_request_room(tty, length); 1824 queued = tty_insert_flip_string(tty, data, length); 1825 if (queued < length) 1826 dev_err(dev, "%s - dropping data, %d bytes lost\n",
··· 134 135 136 /* Devices that this driver supports */ 137 + static const struct usb_device_id edgeport_1port_id_table[] = { 138 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_1) }, 139 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_TI3410_EDGEPORT_1) }, 140 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_TI3410_EDGEPORT_1I) }, ··· 154 { } 155 }; 156 157 + static const struct usb_device_id edgeport_2port_id_table[] = { 158 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_2) }, 159 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_2C) }, 160 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_2I) }, ··· 177 }; 178 179 /* Devices that this driver supports */ 180 + static const struct usb_device_id id_table_combined[] = { 181 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_1) }, 182 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_TI3410_EDGEPORT_1) }, 183 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_TI3410_EDGEPORT_1I) }, ··· 413 { 414 int status = 0; 415 int i; 416 + u8 *temp; 417 418 /* Must do a read before write */ 419 if (!serial->TiReadI2C) { 420 + temp = kmalloc(1, GFP_KERNEL); 421 + if (!temp) { 422 + dev_err(&serial->serial->dev->dev, 423 + "%s - out of memory\n", __func__); 424 + return -ENOMEM; 425 + } 426 + status = read_boot_mem(serial, 0, 1, temp); 427 + kfree(temp); 428 if (status) 429 return status; 430 } ··· 935 static int i2c_type_bootmode(struct edgeport_serial *serial) 936 { 937 int status; 938 + u8 *data; 939 + 940 + data = kmalloc(1, GFP_KERNEL); 941 + if (!data) { 942 + dev_err(&serial->serial->dev->dev, 943 + "%s - out of memory\n", __func__); 944 + return -ENOMEM; 945 + } 946 947 /* Try to read type 2 */ 948 status = ti_vread_sync(serial->serial->dev, UMPC_MEMORY_READ, 949 + DTK_ADDR_SPACE_I2C_TYPE_II, 0, data, 0x01); 950 if (status) 951 dbg("%s - read 2 status error = %d", __func__, status); 952 else 953 + dbg("%s - read 2 data = 0x%x", __func__, *data); 954 + if ((!status) && (*data == UMP5152 || *data == UMP3410)) { 955 dbg("%s - ROM_TYPE_II", __func__); 956 serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_II; 957 + goto out; 958 } 959 960 /* Try to read type 3 */ 961 status = ti_vread_sync(serial->serial->dev, UMPC_MEMORY_READ, 962 + DTK_ADDR_SPACE_I2C_TYPE_III, 0, data, 0x01); 963 if (status) 964 dbg("%s - read 3 status error = %d", __func__, status); 965 else 966 + dbg("%s - read 2 data = 0x%x", __func__, *data); 967 + if ((!status) && (*data == UMP5152 || *data == UMP3410)) { 968 dbg("%s - ROM_TYPE_III", __func__); 969 serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_III; 970 + goto out; 971 } 972 973 dbg("%s - Unknown", __func__); 974 serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_II; 975 + status = -ENODEV; 976 + out: 977 + kfree(data); 978 + return status; 979 } 980 981 static int bulk_xfer(struct usb_serial *serial, void *buffer, ··· 1113 I2C_DESC_TYPE_FIRMWARE_BASIC, rom_desc); 1114 if (start_address != 0) { 1115 struct ti_i2c_firmware_rec *firmware_version; 1116 + u8 *record; 1117 1118 dbg("%s - Found Type FIRMWARE (Type 2) record", 1119 __func__); ··· 1165 OperationalMajorVersion, 1166 OperationalMinorVersion); 1167 1168 + record = kmalloc(1, GFP_KERNEL); 1169 + if (!record) { 1170 + dev_err(dev, "%s - out of memory.\n", 1171 + __func__); 1172 + kfree(firmware_version); 1173 + kfree(rom_desc); 1174 + kfree(ti_manuf_desc); 1175 + return -ENOMEM; 1176 + } 1177 /* In order to update the I2C firmware we must 1178 * change the type 2 record to type 0xF2. This 1179 * will force the UMP to come up in Boot Mode. ··· 1177 * firmware will update the record type from 1178 * 0xf2 to 0x02. 1179 */ 1180 + *record = I2C_DESC_TYPE_FIRMWARE_BLANK; 1181 1182 /* Change the I2C Firmware record type to 1183 0xf2 to trigger an update */ 1184 status = write_rom(serial, start_address, 1185 + sizeof(*record), record); 1186 if (status) { 1187 + kfree(record); 1188 kfree(firmware_version); 1189 kfree(rom_desc); 1190 kfree(ti_manuf_desc); ··· 1196 */ 1197 status = read_rom(serial, 1198 start_address, 1199 + sizeof(*record), 1200 + record); 1201 if (status) { 1202 + kfree(record); 1203 kfree(firmware_version); 1204 kfree(rom_desc); 1205 kfree(ti_manuf_desc); 1206 return status; 1207 } 1208 1209 + if (*record != I2C_DESC_TYPE_FIRMWARE_BLANK) { 1210 dev_err(dev, 1211 "%s - error resetting device\n", 1212 __func__); 1213 + kfree(record); 1214 kfree(firmware_version); 1215 kfree(rom_desc); 1216 kfree(ti_manuf_desc); ··· 1226 __func__, status); 1227 1228 /* return an error on purpose. */ 1229 + kfree(record); 1230 kfree(firmware_version); 1231 kfree(rom_desc); 1232 kfree(ti_manuf_desc); ··· 1686 case TIUMP_INTERRUPT_CODE_MSR: /* MSR */ 1687 /* Copy MSR from UMP */ 1688 msr = data[1]; 1689 + dbg("%s - ===== Port %u MSR Status = %02x ======", 1690 __func__, port_number, msr); 1691 handle_new_msr(edge_port, msr); 1692 break; ··· 1790 { 1791 int queued; 1792 1793 queued = tty_insert_flip_string(tty, data, length); 1794 if (queued < length) 1795 dev_err(dev, "%s - dropping data, %d bytes lost\n",
-1
drivers/usb/serial/ipaq.c
··· 747 748 tty = tty_port_tty_get(&port->port); 749 if (tty && urb->actual_length) { 750 - tty_buffer_request_room(tty, urb->actual_length); 751 tty_insert_flip_string(tty, data, urb->actual_length); 752 tty_flip_buffer_push(tty); 753 bytes_in += urb->actual_length;
··· 747 748 tty = tty_port_tty_get(&port->port); 749 if (tty && urb->actual_length) { 750 tty_insert_flip_string(tty, data, urb->actual_length); 751 tty_flip_buffer_push(tty); 752 bytes_in += urb->actual_length;
+1 -2
drivers/usb/serial/ipw.c
··· 134 135 #define IPW_WANTS_TO_SEND 0x30 136 137 - static struct usb_device_id usb_ipw_ids[] = { 138 { USB_DEVICE(IPW_VID, IPW_PID) }, 139 { }, 140 }; ··· 172 173 tty = tty_port_tty_get(&port->port); 174 if (tty && urb->actual_length) { 175 - tty_buffer_request_room(tty, urb->actual_length); 176 tty_insert_flip_string(tty, data, urb->actual_length); 177 tty_flip_buffer_push(tty); 178 }
··· 134 135 #define IPW_WANTS_TO_SEND 0x30 136 137 + static const struct usb_device_id usb_ipw_ids[] = { 138 { USB_DEVICE(IPW_VID, IPW_PID) }, 139 { }, 140 }; ··· 172 173 tty = tty_port_tty_get(&port->port); 174 if (tty && urb->actual_length) { 175 tty_insert_flip_string(tty, data, urb->actual_length); 176 tty_flip_buffer_push(tty); 177 }
+3 -10
drivers/usb/serial/ir-usb.c
··· 100 static u8 ir_xbof; 101 static u8 ir_add_bof; 102 103 - static struct usb_device_id ir_id_table[] = { 104 { USB_DEVICE(0x050f, 0x0180) }, /* KC Technology, KC-180 */ 105 { USB_DEVICE(0x08e9, 0x0100) }, /* XTNDAccess */ 106 { USB_DEVICE(0x09c4, 0x0011) }, /* ACTiSys ACT-IR2000U */ ··· 445 446 dbg("%s - port %d", __func__, port->number); 447 448 - if (!port->port.count) { 449 - dbg("%s - port closed.", __func__); 450 - return; 451 - } 452 - 453 switch (status) { 454 case 0: /* Successful */ 455 /* ··· 457 usb_serial_debug_data(debug, &port->dev, __func__, 458 urb->actual_length, data); 459 tty = tty_port_tty_get(&port->port); 460 - if (tty_buffer_request_room(tty, urb->actual_length - 1)) { 461 - tty_insert_flip_string(tty, data+1, urb->actual_length - 1); 462 - tty_flip_buffer_push(tty); 463 - } 464 tty_kref_put(tty); 465 466 /*
··· 100 static u8 ir_xbof; 101 static u8 ir_add_bof; 102 103 + static const struct usb_device_id ir_id_table[] = { 104 { USB_DEVICE(0x050f, 0x0180) }, /* KC Technology, KC-180 */ 105 { USB_DEVICE(0x08e9, 0x0100) }, /* XTNDAccess */ 106 { USB_DEVICE(0x09c4, 0x0011) }, /* ACTiSys ACT-IR2000U */ ··· 445 446 dbg("%s - port %d", __func__, port->number); 447 448 switch (status) { 449 case 0: /* Successful */ 450 /* ··· 462 usb_serial_debug_data(debug, &port->dev, __func__, 463 urb->actual_length, data); 464 tty = tty_port_tty_get(&port->port); 465 + tty_insert_flip_string(tty, data+1, urb->actual_length - 1); 466 + tty_flip_buffer_push(tty); 467 tty_kref_put(tty); 468 469 /*
+1 -1
drivers/usb/serial/iuu_phoenix.c
··· 43 #define DRIVER_VERSION "v0.11" 44 #define DRIVER_DESC "Infinity USB Unlimited Phoenix driver" 45 46 - static struct usb_device_id id_table[] = { 47 {USB_DEVICE(IUU_USB_VENDOR_ID, IUU_USB_PRODUCT_ID)}, 48 {} /* Terminating entry */ 49 };
··· 43 #define DRIVER_VERSION "v0.11" 44 #define DRIVER_DESC "Infinity USB Unlimited Phoenix driver" 45 46 + static const struct usb_device_id id_table[] = { 47 {USB_DEVICE(IUU_USB_VENDOR_ID, IUU_USB_PRODUCT_ID)}, 48 {} /* Terminating entry */ 49 };
+18 -39
drivers/usb/serial/keyspan.c
··· 464 465 /* Resubmit urb so we continue receiving */ 466 urb->dev = port->serial->dev; 467 - if (port->port.count) { 468 - err = usb_submit_urb(urb, GFP_ATOMIC); 469 - if (err != 0) 470 - dbg("%s - resubmit read urb failed. (%d)", 471 - __func__, err); 472 - } 473 - return; 474 } 475 476 /* Outdat handling is common for all devices */ ··· 479 p_priv = usb_get_serial_port_data(port); 480 dbg("%s - urb %d", __func__, urb == p_priv->out_urbs[1]); 481 482 - if (port->port.count) 483 - usb_serial_port_softint(port); 484 } 485 486 static void usa26_inack_callback(struct urb *urb) ··· 610 611 /* Resubmit urb so we continue receiving */ 612 urb->dev = port->serial->dev; 613 - if (port->port.count) { 614 - err = usb_submit_urb(urb, GFP_ATOMIC); 615 - if (err != 0) 616 - dbg("%s - resubmit read urb failed. (%d)", 617 - __func__, err); 618 - } 619 p_priv->in_flip ^= 1; 620 621 urb = p_priv->in_urbs[p_priv->in_flip]; ··· 849 850 /* Resubmit urb so we continue receiving */ 851 urb->dev = port->serial->dev; 852 - if (port->port.count) { 853 - err = usb_submit_urb(urb, GFP_ATOMIC); 854 - if (err != 0) 855 - dbg("%s - resubmit read urb failed. (%d)", 856 - __func__, err); 857 - } 858 } 859 860 static void usa49wg_indat_callback(struct urb *urb) ··· 894 /* no error on any byte */ 895 i++; 896 for (x = 1; x < len ; ++x) 897 - if (port->port.count) 898 - tty_insert_flip_char(tty, 899 - data[i++], 0); 900 - else 901 - i++; 902 } else { 903 /* 904 * some bytes had errors, every byte has status ··· 908 if (stat & RXERROR_PARITY) 909 flag |= TTY_PARITY; 910 /* XXX should handle break (0x10) */ 911 - if (port->port.count) 912 - tty_insert_flip_char(tty, 913 data[i+1], flag); 914 i += 2; 915 } 916 } 917 - if (port->port.count) 918 - tty_flip_buffer_push(tty); 919 tty_kref_put(tty); 920 } 921 } ··· 997 998 /* Resubmit urb so we continue receiving */ 999 urb->dev = port->serial->dev; 1000 - if (port->port.count) { 1001 - err = usb_submit_urb(urb, GFP_ATOMIC); 1002 - if (err != 0) 1003 - dbg("%s - resubmit read urb failed. (%d)", 1004 - __func__, err); 1005 - } 1006 - return; 1007 } 1008 1009 ··· 2398 msg.portEnabled = 0; 2399 /* Sending intermediate configs */ 2400 else { 2401 - if (port->port.count) 2402 - msg.portEnabled = 1; 2403 msg.txBreak = (p_priv->break_on); 2404 } 2405
··· 464 465 /* Resubmit urb so we continue receiving */ 466 urb->dev = port->serial->dev; 467 + err = usb_submit_urb(urb, GFP_ATOMIC); 468 + if (err != 0) 469 + dbg("%s - resubmit read urb failed. (%d)", __func__, err); 470 } 471 472 /* Outdat handling is common for all devices */ ··· 483 p_priv = usb_get_serial_port_data(port); 484 dbg("%s - urb %d", __func__, urb == p_priv->out_urbs[1]); 485 486 + usb_serial_port_softint(port); 487 } 488 489 static void usa26_inack_callback(struct urb *urb) ··· 615 616 /* Resubmit urb so we continue receiving */ 617 urb->dev = port->serial->dev; 618 + err = usb_submit_urb(urb, GFP_ATOMIC); 619 + if (err != 0) 620 + dbg("%s - resubmit read urb failed. (%d)", 621 + __func__, err); 622 p_priv->in_flip ^= 1; 623 624 urb = p_priv->in_urbs[p_priv->in_flip]; ··· 856 857 /* Resubmit urb so we continue receiving */ 858 urb->dev = port->serial->dev; 859 + err = usb_submit_urb(urb, GFP_ATOMIC); 860 + if (err != 0) 861 + dbg("%s - resubmit read urb failed. (%d)", __func__, err); 862 } 863 864 static void usa49wg_indat_callback(struct urb *urb) ··· 904 /* no error on any byte */ 905 i++; 906 for (x = 1; x < len ; ++x) 907 + tty_insert_flip_char(tty, data[i++], 0); 908 } else { 909 /* 910 * some bytes had errors, every byte has status ··· 922 if (stat & RXERROR_PARITY) 923 flag |= TTY_PARITY; 924 /* XXX should handle break (0x10) */ 925 + tty_insert_flip_char(tty, 926 data[i+1], flag); 927 i += 2; 928 } 929 } 930 + tty_flip_buffer_push(tty); 931 tty_kref_put(tty); 932 } 933 } ··· 1013 1014 /* Resubmit urb so we continue receiving */ 1015 urb->dev = port->serial->dev; 1016 + err = usb_submit_urb(urb, GFP_ATOMIC); 1017 + if (err != 0) 1018 + dbg("%s - resubmit read urb failed. (%d)", __func__, err); 1019 } 1020 1021 ··· 2418 msg.portEnabled = 0; 2419 /* Sending intermediate configs */ 2420 else { 2421 + msg.portEnabled = 1; 2422 msg.txBreak = (p_priv->break_on); 2423 } 2424
+5 -5
drivers/usb/serial/keyspan.h
··· 456 NULL, 457 }; 458 459 - static struct usb_device_id keyspan_ids_combined[] = { 460 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa18x_pre_product_id) }, 461 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19_pre_product_id) }, 462 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19w_pre_product_id) }, ··· 497 }; 498 499 /* usb_device_id table for the pre-firmware download keyspan devices */ 500 - static struct usb_device_id keyspan_pre_ids[] = { 501 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa18x_pre_product_id) }, 502 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19_pre_product_id) }, 503 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19qi_pre_product_id) }, ··· 513 { } /* Terminating entry */ 514 }; 515 516 - static struct usb_device_id keyspan_1port_ids[] = { 517 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa18x_product_id) }, 518 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19_product_id) }, 519 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19qi_product_id) }, ··· 524 { } /* Terminating entry */ 525 }; 526 527 - static struct usb_device_id keyspan_2port_ids[] = { 528 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28_product_id) }, 529 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28x_product_id) }, 530 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28xa_product_id) }, ··· 532 { } /* Terminating entry */ 533 }; 534 535 - static struct usb_device_id keyspan_4port_ids[] = { 536 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49w_product_id) }, 537 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49wlc_product_id)}, 538 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49wg_product_id)},
··· 456 NULL, 457 }; 458 459 + static const struct usb_device_id keyspan_ids_combined[] = { 460 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa18x_pre_product_id) }, 461 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19_pre_product_id) }, 462 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19w_pre_product_id) }, ··· 497 }; 498 499 /* usb_device_id table for the pre-firmware download keyspan devices */ 500 + static const struct usb_device_id keyspan_pre_ids[] = { 501 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa18x_pre_product_id) }, 502 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19_pre_product_id) }, 503 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19qi_pre_product_id) }, ··· 513 { } /* Terminating entry */ 514 }; 515 516 + static const struct usb_device_id keyspan_1port_ids[] = { 517 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa18x_product_id) }, 518 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19_product_id) }, 519 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19qi_product_id) }, ··· 524 { } /* Terminating entry */ 525 }; 526 527 + static const struct usb_device_id keyspan_2port_ids[] = { 528 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28_product_id) }, 529 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28x_product_id) }, 530 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28xa_product_id) }, ··· 532 { } /* Terminating entry */ 533 }; 534 535 + static const struct usb_device_id keyspan_4port_ids[] = { 536 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49w_product_id) }, 537 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49wlc_product_id)}, 538 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49wg_product_id)},
+37 -16
drivers/usb/serial/keyspan_pda.c
··· 125 #define ENTREGRA_VENDOR_ID 0x1645 126 #define ENTREGRA_FAKE_ID 0x8093 127 128 - static struct usb_device_id id_table_combined [] = { 129 #ifdef KEYSPAN 130 { USB_DEVICE(KEYSPAN_VENDOR_ID, KEYSPAN_PDA_FAKE_ID) }, 131 #endif ··· 147 .no_dynamic_id = 1, 148 }; 149 150 - static struct usb_device_id id_table_std [] = { 151 { USB_DEVICE(KEYSPAN_VENDOR_ID, KEYSPAN_PDA_ID) }, 152 { } /* Terminating entry */ 153 }; 154 155 #ifdef KEYSPAN 156 - static struct usb_device_id id_table_fake [] = { 157 { USB_DEVICE(KEYSPAN_VENDOR_ID, KEYSPAN_PDA_FAKE_ID) }, 158 { } /* Terminating entry */ 159 }; 160 #endif 161 162 #ifdef XIRCOM 163 - static struct usb_device_id id_table_fake_xircom [] = { 164 { USB_DEVICE(XIRCOM_VENDOR_ID, XIRCOM_FAKE_ID) }, 165 { USB_DEVICE(ENTREGRA_VENDOR_ID, ENTREGRA_FAKE_ID) }, 166 { } ··· 429 unsigned char *value) 430 { 431 int rc; 432 - unsigned char data; 433 rc = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), 434 3, /* get pins */ 435 USB_TYPE_VENDOR|USB_RECIP_INTERFACE|USB_DIR_IN, 436 - 0, 0, &data, 1, 2000); 437 if (rc >= 0) 438 - *value = data; 439 return rc; 440 } 441 ··· 550 device how much room it really has. This is done only on 551 scheduler time, since usb_control_msg() sleeps. */ 552 if (count > priv->tx_room && !in_interrupt()) { 553 - unsigned char room; 554 rc = usb_control_msg(serial->dev, 555 usb_rcvctrlpipe(serial->dev, 0), 556 6, /* write_room */ ··· 565 | USB_DIR_IN, 566 0, /* value: 0 means "remaining room" */ 567 0, /* index */ 568 - &room, 569 1, 570 2000); 571 if (rc < 0) { 572 dbg(" roomquery failed"); 573 goto exit; ··· 582 rc = -EIO; /* device didn't return any data */ 583 goto exit; 584 } 585 - dbg(" roomquery says %d", room); 586 - priv->tx_room = room; 587 } 588 if (count > priv->tx_room) { 589 /* we're about to completely fill the Tx buffer, so ··· 701 struct usb_serial_port *port) 702 { 703 struct usb_serial *serial = port->serial; 704 - unsigned char room; 705 int rc = 0; 706 struct keyspan_pda_private *priv; 707 708 /* find out how much room is in the Tx ring */ 709 rc = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), 710 6, /* write_room */ 711 USB_TYPE_VENDOR | USB_RECIP_INTERFACE 712 | USB_DIR_IN, 713 0, /* value */ 714 0, /* index */ 715 - &room, 716 1, 717 2000); 718 if (rc < 0) { ··· 729 goto error; 730 } 731 priv = usb_get_serial_port_data(port); 732 - priv->tx_room = room; 733 - priv->tx_throttled = room ? 0 : 1; 734 735 /*Start reading from the device*/ 736 port->interrupt_in_urb->dev = serial->dev; ··· 739 dbg("%s - usb_submit_urb(read int) failed", __func__); 740 goto error; 741 } 742 - 743 error: 744 return rc; 745 } 746 static void keyspan_pda_close(struct usb_serial_port *port)
··· 125 #define ENTREGRA_VENDOR_ID 0x1645 126 #define ENTREGRA_FAKE_ID 0x8093 127 128 + static const struct usb_device_id id_table_combined[] = { 129 #ifdef KEYSPAN 130 { USB_DEVICE(KEYSPAN_VENDOR_ID, KEYSPAN_PDA_FAKE_ID) }, 131 #endif ··· 147 .no_dynamic_id = 1, 148 }; 149 150 + static const struct usb_device_id id_table_std[] = { 151 { USB_DEVICE(KEYSPAN_VENDOR_ID, KEYSPAN_PDA_ID) }, 152 { } /* Terminating entry */ 153 }; 154 155 #ifdef KEYSPAN 156 + static const struct usb_device_id id_table_fake[] = { 157 { USB_DEVICE(KEYSPAN_VENDOR_ID, KEYSPAN_PDA_FAKE_ID) }, 158 { } /* Terminating entry */ 159 }; 160 #endif 161 162 #ifdef XIRCOM 163 + static const struct usb_device_id id_table_fake_xircom[] = { 164 { USB_DEVICE(XIRCOM_VENDOR_ID, XIRCOM_FAKE_ID) }, 165 { USB_DEVICE(ENTREGRA_VENDOR_ID, ENTREGRA_FAKE_ID) }, 166 { } ··· 429 unsigned char *value) 430 { 431 int rc; 432 + u8 *data; 433 + 434 + data = kmalloc(1, GFP_KERNEL); 435 + if (!data) 436 + return -ENOMEM; 437 + 438 rc = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), 439 3, /* get pins */ 440 USB_TYPE_VENDOR|USB_RECIP_INTERFACE|USB_DIR_IN, 441 + 0, 0, data, 1, 2000); 442 if (rc >= 0) 443 + *value = *data; 444 + 445 + kfree(data); 446 return rc; 447 } 448 ··· 543 device how much room it really has. This is done only on 544 scheduler time, since usb_control_msg() sleeps. */ 545 if (count > priv->tx_room && !in_interrupt()) { 546 + u8 *room; 547 + 548 + room = kmalloc(1, GFP_KERNEL); 549 + if (!room) { 550 + rc = -ENOMEM; 551 + goto exit; 552 + } 553 + 554 rc = usb_control_msg(serial->dev, 555 usb_rcvctrlpipe(serial->dev, 0), 556 6, /* write_room */ ··· 551 | USB_DIR_IN, 552 0, /* value: 0 means "remaining room" */ 553 0, /* index */ 554 + room, 555 1, 556 2000); 557 + if (rc > 0) { 558 + dbg(" roomquery says %d", *room); 559 + priv->tx_room = *room; 560 + } 561 + kfree(room); 562 if (rc < 0) { 563 dbg(" roomquery failed"); 564 goto exit; ··· 563 rc = -EIO; /* device didn't return any data */ 564 goto exit; 565 } 566 } 567 if (count > priv->tx_room) { 568 /* we're about to completely fill the Tx buffer, so ··· 684 struct usb_serial_port *port) 685 { 686 struct usb_serial *serial = port->serial; 687 + u8 *room; 688 int rc = 0; 689 struct keyspan_pda_private *priv; 690 691 /* find out how much room is in the Tx ring */ 692 + room = kmalloc(1, GFP_KERNEL); 693 + if (!room) 694 + return -ENOMEM; 695 + 696 rc = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), 697 6, /* write_room */ 698 USB_TYPE_VENDOR | USB_RECIP_INTERFACE 699 | USB_DIR_IN, 700 0, /* value */ 701 0, /* index */ 702 + room, 703 1, 704 2000); 705 if (rc < 0) { ··· 708 goto error; 709 } 710 priv = usb_get_serial_port_data(port); 711 + priv->tx_room = *room; 712 + priv->tx_throttled = *room ? 0 : 1; 713 714 /*Start reading from the device*/ 715 port->interrupt_in_urb->dev = serial->dev; ··· 718 dbg("%s - usb_submit_urb(read int) failed", __func__); 719 goto error; 720 } 721 error: 722 + kfree(room); 723 return rc; 724 } 725 static void keyspan_pda_close(struct usb_serial_port *port)
+46 -20
drivers/usb/serial/kl5kusb105.c
··· 94 /* 95 * All of the device info needed for the KLSI converters. 96 */ 97 - static struct usb_device_id id_table [] = { 98 { USB_DEVICE(PALMCONNECT_VID, PALMCONNECT_PID) }, 99 { USB_DEVICE(KLSI_VID, KLSI_KL5KUSB105D_PID) }, 100 { } /* Terminating entry */ ··· 212 unsigned long *line_state_p) 213 { 214 int rc; 215 - __u8 status_buf[KLSI_STATUSBUF_LEN] = { -1, -1}; 216 __u16 status; 217 218 dev_info(&port->serial->dev->dev, "sending SIO Poll request\n"); 219 rc = usb_control_msg(port->serial->dev, 220 usb_rcvctrlpipe(port->serial->dev, 0), 221 KL5KUSB105A_SIO_POLL, ··· 245 246 *line_state_p = klsi_105_status2linestate(status); 247 } 248 return rc; 249 } 250 ··· 375 int rc; 376 int i; 377 unsigned long line_state; 378 - struct klsi_105_port_settings cfg; 379 unsigned long flags; 380 381 dbg("%s port %d", __func__, port->number); ··· 387 * Then read the modem line control and store values in 388 * priv->line_state. 389 */ 390 - cfg.pktlen = 5; 391 - cfg.baudrate = kl5kusb105a_sio_b9600; 392 - cfg.databits = kl5kusb105a_dtb_8; 393 - cfg.unknown1 = 0; 394 - cfg.unknown2 = 1; 395 - klsi_105_chg_port_settings(port, &cfg); 396 397 /* set up termios structure */ 398 spin_lock_irqsave(&priv->lock, flags); ··· 408 priv->termios.c_lflag = tty->termios->c_lflag; 409 for (i = 0; i < NCCS; i++) 410 priv->termios.c_cc[i] = tty->termios->c_cc[i]; 411 - priv->cfg.pktlen = cfg.pktlen; 412 - priv->cfg.baudrate = cfg.baudrate; 413 - priv->cfg.databits = cfg.databits; 414 - priv->cfg.unknown1 = cfg.unknown1; 415 - priv->cfg.unknown2 = cfg.unknown2; 416 spin_unlock_irqrestore(&priv->lock, flags); 417 418 /* READ_ON and urb submission */ ··· 458 retval = rc; 459 460 exit: 461 return retval; 462 } /* klsi_105_open */ 463 ··· 699 bytes_sent = urb->actual_length - 2; 700 } 701 702 - tty_buffer_request_room(tty, bytes_sent); 703 tty_insert_flip_string(tty, data + 2, bytes_sent); 704 tty_flip_buffer_push(tty); 705 tty_kref_put(tty); ··· 731 unsigned int old_iflag = old_termios->c_iflag; 732 unsigned int cflag = tty->termios->c_cflag; 733 unsigned int old_cflag = old_termios->c_cflag; 734 - struct klsi_105_port_settings cfg; 735 unsigned long flags; 736 speed_t baud; 737 738 /* lock while we are modifying the settings */ 739 spin_lock_irqsave(&priv->lock, flags); ··· 817 case CS5: 818 dbg("%s - 5 bits/byte not supported", __func__); 819 spin_unlock_irqrestore(&priv->lock, flags); 820 - return ; 821 case CS6: 822 dbg("%s - 6 bits/byte not supported", __func__); 823 spin_unlock_irqrestore(&priv->lock, flags); 824 - return ; 825 case CS7: 826 priv->cfg.databits = kl5kusb105a_dtb_7; 827 break; ··· 880 #endif 881 ; 882 } 883 - memcpy(&cfg, &priv->cfg, sizeof(cfg)); 884 spin_unlock_irqrestore(&priv->lock, flags); 885 886 /* now commit changes to device */ 887 - klsi_105_chg_port_settings(port, &cfg); 888 } /* klsi_105_set_termios */ 889 890
··· 94 /* 95 * All of the device info needed for the KLSI converters. 96 */ 97 + static const struct usb_device_id id_table[] = { 98 { USB_DEVICE(PALMCONNECT_VID, PALMCONNECT_PID) }, 99 { USB_DEVICE(KLSI_VID, KLSI_KL5KUSB105D_PID) }, 100 { } /* Terminating entry */ ··· 212 unsigned long *line_state_p) 213 { 214 int rc; 215 + u8 *status_buf; 216 __u16 status; 217 218 dev_info(&port->serial->dev->dev, "sending SIO Poll request\n"); 219 + 220 + status_buf = kmalloc(KLSI_STATUSBUF_LEN, GFP_KERNEL); 221 + if (!status_buf) { 222 + dev_err(&port->dev, "%s - out of memory for status buffer.\n", 223 + __func__); 224 + return -ENOMEM; 225 + } 226 + status_buf[0] = 0xff; 227 + status_buf[1] = 0xff; 228 rc = usb_control_msg(port->serial->dev, 229 usb_rcvctrlpipe(port->serial->dev, 0), 230 KL5KUSB105A_SIO_POLL, ··· 236 237 *line_state_p = klsi_105_status2linestate(status); 238 } 239 + 240 + kfree(status_buf); 241 return rc; 242 } 243 ··· 364 int rc; 365 int i; 366 unsigned long line_state; 367 + struct klsi_105_port_settings *cfg; 368 unsigned long flags; 369 370 dbg("%s port %d", __func__, port->number); ··· 376 * Then read the modem line control and store values in 377 * priv->line_state. 378 */ 379 + cfg = kmalloc(sizeof(*cfg), GFP_KERNEL); 380 + if (!cfg) { 381 + dev_err(&port->dev, "%s - out of memory for config buffer.\n", 382 + __func__); 383 + return -ENOMEM; 384 + } 385 + cfg->pktlen = 5; 386 + cfg->baudrate = kl5kusb105a_sio_b9600; 387 + cfg->databits = kl5kusb105a_dtb_8; 388 + cfg->unknown1 = 0; 389 + cfg->unknown2 = 1; 390 + klsi_105_chg_port_settings(port, cfg); 391 392 /* set up termios structure */ 393 spin_lock_irqsave(&priv->lock, flags); ··· 391 priv->termios.c_lflag = tty->termios->c_lflag; 392 for (i = 0; i < NCCS; i++) 393 priv->termios.c_cc[i] = tty->termios->c_cc[i]; 394 + priv->cfg.pktlen = cfg->pktlen; 395 + priv->cfg.baudrate = cfg->baudrate; 396 + priv->cfg.databits = cfg->databits; 397 + priv->cfg.unknown1 = cfg->unknown1; 398 + priv->cfg.unknown2 = cfg->unknown2; 399 spin_unlock_irqrestore(&priv->lock, flags); 400 401 /* READ_ON and urb submission */ ··· 441 retval = rc; 442 443 exit: 444 + kfree(cfg); 445 return retval; 446 } /* klsi_105_open */ 447 ··· 681 bytes_sent = urb->actual_length - 2; 682 } 683 684 tty_insert_flip_string(tty, data + 2, bytes_sent); 685 tty_flip_buffer_push(tty); 686 tty_kref_put(tty); ··· 714 unsigned int old_iflag = old_termios->c_iflag; 715 unsigned int cflag = tty->termios->c_cflag; 716 unsigned int old_cflag = old_termios->c_cflag; 717 + struct klsi_105_port_settings *cfg; 718 unsigned long flags; 719 speed_t baud; 720 + 721 + cfg = kmalloc(sizeof(*cfg), GFP_KERNEL); 722 + if (!cfg) { 723 + dev_err(&port->dev, "%s - out of memory for config buffer.\n", 724 + __func__); 725 + return; 726 + } 727 728 /* lock while we are modifying the settings */ 729 spin_lock_irqsave(&priv->lock, flags); ··· 793 case CS5: 794 dbg("%s - 5 bits/byte not supported", __func__); 795 spin_unlock_irqrestore(&priv->lock, flags); 796 + goto err; 797 case CS6: 798 dbg("%s - 6 bits/byte not supported", __func__); 799 spin_unlock_irqrestore(&priv->lock, flags); 800 + goto err; 801 case CS7: 802 priv->cfg.databits = kl5kusb105a_dtb_7; 803 break; ··· 856 #endif 857 ; 858 } 859 + memcpy(cfg, &priv->cfg, sizeof(*cfg)); 860 spin_unlock_irqrestore(&priv->lock, flags); 861 862 /* now commit changes to device */ 863 + klsi_105_chg_port_settings(port, cfg); 864 + err: 865 + kfree(cfg); 866 } /* klsi_105_set_termios */ 867 868
+5 -20
drivers/usb/serial/kobil_sct.c
··· 86 struct usb_serial_port *port, struct ktermios *old); 87 static void kobil_init_termios(struct tty_struct *tty); 88 89 - static struct usb_device_id id_table [] = { 90 { USB_DEVICE(KOBIL_VENDOR_ID, KOBIL_ADAPTER_B_PRODUCT_ID) }, 91 { USB_DEVICE(KOBIL_VENDOR_ID, KOBIL_ADAPTER_K_PRODUCT_ID) }, 92 { USB_DEVICE(KOBIL_VENDOR_ID, KOBIL_USBTWIN_PRODUCT_ID) }, ··· 388 */ 389 /* END DEBUG */ 390 391 - tty_buffer_request_room(tty, urb->actual_length); 392 tty_insert_flip_string(tty, data, urb->actual_length); 393 tty_flip_buffer_push(tty); 394 } ··· 623 unsigned short urb_val = 0; 624 int c_cflag = tty->termios->c_cflag; 625 speed_t speed; 626 - void *settings; 627 628 priv = usb_get_serial_port_data(port); 629 if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID || ··· 645 } 646 urb_val |= (c_cflag & CSTOPB) ? SUSBCR_SPASB_2StopBits : 647 SUSBCR_SPASB_1StopBit; 648 - 649 - settings = kzalloc(50, GFP_KERNEL); 650 - if (!settings) 651 - return; 652 - 653 - sprintf(settings, "%d ", speed); 654 - 655 if (c_cflag & PARENB) { 656 - if (c_cflag & PARODD) { 657 urb_val |= SUSBCR_SPASB_OddParity; 658 - strcat(settings, "Odd Parity"); 659 - } else { 660 urb_val |= SUSBCR_SPASB_EvenParity; 661 - strcat(settings, "Even Parity"); 662 - } 663 - } else { 664 urb_val |= SUSBCR_SPASB_NoParity; 665 - strcat(settings, "No Parity"); 666 - } 667 tty->termios->c_cflag &= ~CMSPAR; 668 tty_encode_baud_rate(tty, speed, speed); 669 ··· 661 USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT, 662 urb_val, 663 0, 664 - settings, 665 0, 666 KOBIL_TIMEOUT 667 ); 668 - kfree(settings); 669 } 670 671 static int kobil_ioctl(struct tty_struct *tty, struct file *file,
··· 86 struct usb_serial_port *port, struct ktermios *old); 87 static void kobil_init_termios(struct tty_struct *tty); 88 89 + static const struct usb_device_id id_table[] = { 90 { USB_DEVICE(KOBIL_VENDOR_ID, KOBIL_ADAPTER_B_PRODUCT_ID) }, 91 { USB_DEVICE(KOBIL_VENDOR_ID, KOBIL_ADAPTER_K_PRODUCT_ID) }, 92 { USB_DEVICE(KOBIL_VENDOR_ID, KOBIL_USBTWIN_PRODUCT_ID) }, ··· 388 */ 389 /* END DEBUG */ 390 391 tty_insert_flip_string(tty, data, urb->actual_length); 392 tty_flip_buffer_push(tty); 393 } ··· 624 unsigned short urb_val = 0; 625 int c_cflag = tty->termios->c_cflag; 626 speed_t speed; 627 628 priv = usb_get_serial_port_data(port); 629 if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID || ··· 647 } 648 urb_val |= (c_cflag & CSTOPB) ? SUSBCR_SPASB_2StopBits : 649 SUSBCR_SPASB_1StopBit; 650 if (c_cflag & PARENB) { 651 + if (c_cflag & PARODD) 652 urb_val |= SUSBCR_SPASB_OddParity; 653 + else 654 urb_val |= SUSBCR_SPASB_EvenParity; 655 + } else 656 urb_val |= SUSBCR_SPASB_NoParity; 657 tty->termios->c_cflag &= ~CMSPAR; 658 tty_encode_baud_rate(tty, speed, speed); 659 ··· 675 USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT, 676 urb_val, 677 0, 678 + NULL, 679 0, 680 KOBIL_TIMEOUT 681 ); 682 } 683 684 static int kobil_ioctl(struct tty_struct *tty, struct file *file,
+45 -12
drivers/usb/serial/mct_u232.c
··· 75 #include <linux/module.h> 76 #include <linux/spinlock.h> 77 #include <linux/uaccess.h> 78 #include <linux/usb.h> 79 #include <linux/usb/serial.h> 80 #include "mct_u232.h" ··· 111 /* 112 * All of the device info needed for the MCT USB-RS232 converter. 113 */ 114 - static struct usb_device_id id_table_combined [] = { 115 { USB_DEVICE(MCT_U232_VID, MCT_U232_PID) }, 116 { USB_DEVICE(MCT_U232_VID, MCT_U232_SITECOM_PID) }, 117 { USB_DEVICE(MCT_U232_VID, MCT_U232_DU_H3SP_PID) }, ··· 232 static int mct_u232_set_baud_rate(struct tty_struct *tty, 233 struct usb_serial *serial, struct usb_serial_port *port, speed_t value) 234 { 235 - __le32 divisor; 236 int rc; 237 - unsigned char zero_byte = 0; 238 unsigned char cts_enable_byte = 0; 239 speed_t speed; 240 241 - divisor = cpu_to_le32(mct_u232_calculate_baud_rate(serial, value, 242 - &speed)); 243 244 rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 245 MCT_U232_SET_BAUD_RATE_REQUEST, 246 MCT_U232_SET_REQUEST_TYPE, 247 - 0, 0, &divisor, MCT_U232_SET_BAUD_RATE_SIZE, 248 WDR_TIMEOUT); 249 if (rc < 0) /*FIXME: What value speed results */ 250 dev_err(&port->dev, "Set BAUD RATE %d failed (error = %d)\n", ··· 273 a device which is not asserting 'CTS'. 274 */ 275 276 rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 277 MCT_U232_SET_UNKNOWN1_REQUEST, 278 MCT_U232_SET_REQUEST_TYPE, 279 - 0, 0, &zero_byte, MCT_U232_SET_UNKNOWN1_SIZE, 280 WDR_TIMEOUT); 281 if (rc < 0) 282 dev_err(&port->dev, "Sending USB device request code %d " ··· 289 290 dbg("set_baud_rate: send second control message, data = %02X", 291 cts_enable_byte); 292 rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 293 MCT_U232_SET_CTS_REQUEST, 294 MCT_U232_SET_REQUEST_TYPE, 295 - 0, 0, &cts_enable_byte, MCT_U232_SET_CTS_SIZE, 296 WDR_TIMEOUT); 297 if (rc < 0) 298 dev_err(&port->dev, "Sending USB device request code %d " 299 "failed (error = %d)\n", MCT_U232_SET_CTS_REQUEST, rc); 300 301 return rc; 302 } /* mct_u232_set_baud_rate */ 303 304 static int mct_u232_set_line_ctrl(struct usb_serial *serial, unsigned char lcr) 305 { 306 int rc; 307 rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 308 MCT_U232_SET_LINE_CTRL_REQUEST, 309 MCT_U232_SET_REQUEST_TYPE, 310 - 0, 0, &lcr, MCT_U232_SET_LINE_CTRL_SIZE, 311 WDR_TIMEOUT); 312 if (rc < 0) 313 dev_err(&serial->dev->dev, 314 "Set LINE CTRL 0x%x failed (error = %d)\n", lcr, rc); 315 dbg("set_line_ctrl: 0x%x", lcr); 316 return rc; 317 } /* mct_u232_set_line_ctrl */ 318 ··· 330 unsigned int control_state) 331 { 332 int rc; 333 - unsigned char mcr = MCT_U232_MCR_NONE; 334 335 if (control_state & TIOCM_DTR) 336 mcr |= MCT_U232_MCR_DTR; 337 if (control_state & TIOCM_RTS) 338 mcr |= MCT_U232_MCR_RTS; 339 340 rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 341 MCT_U232_SET_MODEM_CTRL_REQUEST, 342 MCT_U232_SET_REQUEST_TYPE, 343 - 0, 0, &mcr, MCT_U232_SET_MODEM_CTRL_SIZE, 344 WDR_TIMEOUT); 345 if (rc < 0) 346 dev_err(&serial->dev->dev, 347 "Set MODEM CTRL 0x%x failed (error = %d)\n", mcr, rc); 348 dbg("set_modem_ctrl: state=0x%x ==> mcr=0x%x", control_state, mcr); 349 350 return rc; 351 } /* mct_u232_set_modem_ctrl */ 352 ··· 362 unsigned char *msr) 363 { 364 int rc; 365 rc = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), 366 MCT_U232_GET_MODEM_STAT_REQUEST, 367 MCT_U232_GET_REQUEST_TYPE, 368 - 0, 0, msr, MCT_U232_GET_MODEM_STAT_SIZE, 369 WDR_TIMEOUT); 370 if (rc < 0) { 371 dev_err(&serial->dev->dev, 372 "Get MODEM STATus failed (error = %d)\n", rc); 373 *msr = 0; 374 } 375 dbg("get_modem_stat: 0x%x", *msr); 376 return rc; 377 } /* mct_u232_get_modem_stat */ 378
··· 75 #include <linux/module.h> 76 #include <linux/spinlock.h> 77 #include <linux/uaccess.h> 78 + #include <asm/unaligned.h> 79 #include <linux/usb.h> 80 #include <linux/usb/serial.h> 81 #include "mct_u232.h" ··· 110 /* 111 * All of the device info needed for the MCT USB-RS232 converter. 112 */ 113 + static const struct usb_device_id id_table_combined[] = { 114 { USB_DEVICE(MCT_U232_VID, MCT_U232_PID) }, 115 { USB_DEVICE(MCT_U232_VID, MCT_U232_SITECOM_PID) }, 116 { USB_DEVICE(MCT_U232_VID, MCT_U232_DU_H3SP_PID) }, ··· 231 static int mct_u232_set_baud_rate(struct tty_struct *tty, 232 struct usb_serial *serial, struct usb_serial_port *port, speed_t value) 233 { 234 + unsigned int divisor; 235 int rc; 236 + unsigned char *buf; 237 unsigned char cts_enable_byte = 0; 238 speed_t speed; 239 240 + buf = kmalloc(MCT_U232_MAX_SIZE, GFP_KERNEL); 241 + if (buf == NULL) 242 + return -ENOMEM; 243 244 + divisor = mct_u232_calculate_baud_rate(serial, value, &speed); 245 + put_unaligned_le32(cpu_to_le32(divisor), buf); 246 rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 247 MCT_U232_SET_BAUD_RATE_REQUEST, 248 MCT_U232_SET_REQUEST_TYPE, 249 + 0, 0, buf, MCT_U232_SET_BAUD_RATE_SIZE, 250 WDR_TIMEOUT); 251 if (rc < 0) /*FIXME: What value speed results */ 252 dev_err(&port->dev, "Set BAUD RATE %d failed (error = %d)\n", ··· 269 a device which is not asserting 'CTS'. 270 */ 271 272 + buf[0] = 0; 273 rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 274 MCT_U232_SET_UNKNOWN1_REQUEST, 275 MCT_U232_SET_REQUEST_TYPE, 276 + 0, 0, buf, MCT_U232_SET_UNKNOWN1_SIZE, 277 WDR_TIMEOUT); 278 if (rc < 0) 279 dev_err(&port->dev, "Sending USB device request code %d " ··· 284 285 dbg("set_baud_rate: send second control message, data = %02X", 286 cts_enable_byte); 287 + buf[0] = cts_enable_byte; 288 rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 289 MCT_U232_SET_CTS_REQUEST, 290 MCT_U232_SET_REQUEST_TYPE, 291 + 0, 0, buf, MCT_U232_SET_CTS_SIZE, 292 WDR_TIMEOUT); 293 if (rc < 0) 294 dev_err(&port->dev, "Sending USB device request code %d " 295 "failed (error = %d)\n", MCT_U232_SET_CTS_REQUEST, rc); 296 297 + kfree(buf); 298 return rc; 299 } /* mct_u232_set_baud_rate */ 300 301 static int mct_u232_set_line_ctrl(struct usb_serial *serial, unsigned char lcr) 302 { 303 int rc; 304 + unsigned char *buf; 305 + 306 + buf = kmalloc(MCT_U232_MAX_SIZE, GFP_KERNEL); 307 + if (buf == NULL) 308 + return -ENOMEM; 309 + 310 + buf[0] = lcr; 311 rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 312 MCT_U232_SET_LINE_CTRL_REQUEST, 313 MCT_U232_SET_REQUEST_TYPE, 314 + 0, 0, buf, MCT_U232_SET_LINE_CTRL_SIZE, 315 WDR_TIMEOUT); 316 if (rc < 0) 317 dev_err(&serial->dev->dev, 318 "Set LINE CTRL 0x%x failed (error = %d)\n", lcr, rc); 319 dbg("set_line_ctrl: 0x%x", lcr); 320 + kfree(buf); 321 return rc; 322 } /* mct_u232_set_line_ctrl */ 323 ··· 315 unsigned int control_state) 316 { 317 int rc; 318 + unsigned char mcr; 319 + unsigned char *buf; 320 321 + buf = kmalloc(MCT_U232_MAX_SIZE, GFP_KERNEL); 322 + if (buf == NULL) 323 + return -ENOMEM; 324 + 325 + mcr = MCT_U232_MCR_NONE; 326 if (control_state & TIOCM_DTR) 327 mcr |= MCT_U232_MCR_DTR; 328 if (control_state & TIOCM_RTS) 329 mcr |= MCT_U232_MCR_RTS; 330 331 + buf[0] = mcr; 332 rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 333 MCT_U232_SET_MODEM_CTRL_REQUEST, 334 MCT_U232_SET_REQUEST_TYPE, 335 + 0, 0, buf, MCT_U232_SET_MODEM_CTRL_SIZE, 336 WDR_TIMEOUT); 337 if (rc < 0) 338 dev_err(&serial->dev->dev, 339 "Set MODEM CTRL 0x%x failed (error = %d)\n", mcr, rc); 340 dbg("set_modem_ctrl: state=0x%x ==> mcr=0x%x", control_state, mcr); 341 342 + kfree(buf); 343 return rc; 344 } /* mct_u232_set_modem_ctrl */ 345 ··· 339 unsigned char *msr) 340 { 341 int rc; 342 + unsigned char *buf; 343 + 344 + buf = kmalloc(MCT_U232_MAX_SIZE, GFP_KERNEL); 345 + if (buf == NULL) { 346 + *msr = 0; 347 + return -ENOMEM; 348 + } 349 rc = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), 350 MCT_U232_GET_MODEM_STAT_REQUEST, 351 MCT_U232_GET_REQUEST_TYPE, 352 + 0, 0, buf, MCT_U232_GET_MODEM_STAT_SIZE, 353 WDR_TIMEOUT); 354 if (rc < 0) { 355 dev_err(&serial->dev->dev, 356 "Get MODEM STATus failed (error = %d)\n", rc); 357 *msr = 0; 358 + } else { 359 + *msr = buf[0]; 360 } 361 dbg("get_modem_stat: 0x%x", *msr); 362 + kfree(buf); 363 return rc; 364 } /* mct_u232_get_modem_stat */ 365
+2
drivers/usb/serial/mct_u232.h
··· 73 #define MCT_U232_SET_CTS_REQUEST 12 74 #define MCT_U232_SET_CTS_SIZE 1 75 76 /* 77 * Baud rate (divisor) 78 * Actually, there are two of them, MCT website calls them "Philips solution"
··· 73 #define MCT_U232_SET_CTS_REQUEST 12 74 #define MCT_U232_SET_CTS_SIZE 1 75 76 + #define MCT_U232_MAX_SIZE 4 /* of MCT_XXX_SIZE */ 77 + 78 /* 79 * Baud rate (divisor) 80 * Actually, there are two of them, MCT website calls them "Philips solution"
+155 -30
drivers/usb/serial/mos7720.c
··· 81 82 static int debug; 83 84 #define USB_VENDOR_ID_MOSCHIP 0x9710 85 #define MOSCHIP_DEVICE_ID_7720 0x7720 86 #define MOSCHIP_DEVICE_ID_7715 0x7715 87 88 - static struct usb_device_id moschip_port_id_table[] = { 89 { USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7720) }, 90 { } /* terminating entry */ 91 }; 92 MODULE_DEVICE_TABLE(usb, moschip_port_id_table); ··· 109 __u8 sp1; 110 __u8 sp2; 111 112 - dbg("%s", " : Entering\n"); 113 114 switch (status) { 115 case 0: ··· 189 } 190 191 /* 192 * mos7720_bulk_in_callback 193 * this is the callback function for when we have received data on the 194 * bulk in endpoint. ··· 278 279 mos7720_port = urb->context; 280 if (!mos7720_port) { 281 - dbg("%s", "NULL mos7720_port pointer \n"); 282 return ; 283 } 284 ··· 290 291 tty = tty_port_tty_get(&port->port); 292 if (tty && urb->actual_length) { 293 - tty_buffer_request_room(tty, urb->actual_length); 294 tty_insert_flip_string(tty, data, urb->actual_length); 295 tty_flip_buffer_push(tty); 296 } ··· 346 * this function will be used for sending command to device 347 */ 348 static int send_mos_cmd(struct usb_serial *serial, __u8 request, __u16 value, 349 - __u16 index, void *data) 350 { 351 int status; 352 - unsigned int pipe; 353 u16 product = le16_to_cpu(serial->dev->descriptor.idProduct); 354 - __u8 requesttype; 355 - __u16 size = 0x0000; 356 357 if (value < MOS_MAX_PORT) { 358 if (product == MOSCHIP_DEVICE_ID_7715) 359 - value = value*0x100+0x100; 360 else 361 value = value*0x100+0x200; 362 } else { ··· 367 } 368 369 if (request == MOS_WRITE) { 370 - request = (__u8)MOS_WRITE; 371 - requesttype = (__u8)0x40; 372 - value = value + (__u16)*((unsigned char *)data); 373 - data = NULL; 374 - pipe = usb_sndctrlpipe(serial->dev, 0); 375 } else { 376 - request = (__u8)MOS_READ; 377 - requesttype = (__u8)0xC0; 378 - size = 0x01; 379 - pipe = usb_rcvctrlpipe(serial->dev, 0); 380 } 381 - 382 - status = usb_control_msg(serial->dev, pipe, request, requesttype, 383 - value, index, data, size, MOS_WDR_TIMEOUT); 384 - 385 if (status < 0) 386 - dbg("Command Write failed Value %x index %x\n", value, index); 387 388 return status; 389 } 390 391 static int mos7720_open(struct tty_struct *tty, struct usb_serial_port *port) ··· 490 */ 491 port_number = port->number - port->serial->minor; 492 send_mos_cmd(port->serial, MOS_READ, port_number, UART_LSR, &data); 493 - dbg("SS::%p LSR:%x\n", mos7720_port, data); 494 495 dbg("Check:Sending Command .........."); 496 ··· 829 struct moschip_port *mos7720_port; 830 int status; 831 832 - dbg("%s- port %d\n", __func__, port->number); 833 834 mos7720_port = usb_get_serial_port_data(port); 835 ··· 1308 return; 1309 } 1310 1311 - dbg("%s\n", "setting termios - ASPIRE"); 1312 1313 cflag = tty->termios->c_cflag; 1314 ··· 1326 change_port_settings(tty, mos7720_port, old_termios); 1327 1328 if (!port->read_urb) { 1329 - dbg("%s", "URB KILLED !!!!!\n"); 1330 return; 1331 } 1332 ··· 1595 struct usb_device *dev; 1596 int i; 1597 char data; 1598 1599 dbg("%s: Entering ..........", __func__); 1600 ··· 1615 1616 usb_set_serial_data(serial, mos7720_serial); 1617 1618 /* we set up the pointers to the endpoints in the mos7720_open * 1619 * function, as the structures aren't created yet. */ 1620 ··· 1653 1654 /* Initialize all port interrupt end point to port 0 int 1655 * endpoint. Our device has only one interrupt endpoint 1656 - * comman to all ports */ 1657 serial->port[i]->interrupt_in_endpointAddress = 1658 serial->port[0]->interrupt_in_endpointAddress; 1659 ··· 1708 .description = "Moschip 2 port adapter", 1709 .usb_driver = &usb_driver, 1710 .id_table = moschip_port_id_table, 1711 - .num_ports = 2, 1712 .open = mos7720_open, 1713 .close = mos7720_close, 1714 .throttle = mos7720_throttle, 1715 .unthrottle = mos7720_unthrottle, 1716 .attach = mos7720_startup, 1717 .release = mos7720_release, 1718 .ioctl = mos7720_ioctl, ··· 1725 .chars_in_buffer = mos7720_chars_in_buffer, 1726 .break_ctl = mos7720_break, 1727 .read_bulk_callback = mos7720_bulk_in_callback, 1728 - .read_int_callback = mos7720_interrupt_callback, 1729 }; 1730 1731 static int __init moschip7720_init(void)
··· 81 82 static int debug; 83 84 + static struct usb_serial_driver moschip7720_2port_driver; 85 + 86 #define USB_VENDOR_ID_MOSCHIP 0x9710 87 #define MOSCHIP_DEVICE_ID_7720 0x7720 88 #define MOSCHIP_DEVICE_ID_7715 0x7715 89 90 + static const struct usb_device_id moschip_port_id_table[] = { 91 { USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7720) }, 92 + { USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7715) }, 93 { } /* terminating entry */ 94 }; 95 MODULE_DEVICE_TABLE(usb, moschip_port_id_table); ··· 106 __u8 sp1; 107 __u8 sp2; 108 109 + dbg(" : Entering"); 110 111 switch (status) { 112 case 0: ··· 186 } 187 188 /* 189 + * mos7715_interrupt_callback 190 + * this is the 7715's callback function for when we have received data on 191 + * the interrupt endpoint. 192 + */ 193 + static void mos7715_interrupt_callback(struct urb *urb) 194 + { 195 + int result; 196 + int length; 197 + int status = urb->status; 198 + __u8 *data; 199 + __u8 iir; 200 + 201 + switch (status) { 202 + case 0: 203 + /* success */ 204 + break; 205 + case -ECONNRESET: 206 + case -ENOENT: 207 + case -ESHUTDOWN: 208 + /* this urb is terminated, clean up */ 209 + dbg("%s - urb shutting down with status: %d", __func__, 210 + status); 211 + return; 212 + default: 213 + dbg("%s - nonzero urb status received: %d", __func__, 214 + status); 215 + goto exit; 216 + } 217 + 218 + length = urb->actual_length; 219 + data = urb->transfer_buffer; 220 + 221 + /* Structure of data from 7715 device: 222 + * Byte 1: IIR serial Port 223 + * Byte 2: unused 224 + * Byte 2: DSR parallel port 225 + * Byte 4: FIFO status for both */ 226 + 227 + if (unlikely(length != 4)) { 228 + dbg("Wrong data !!!"); 229 + return; 230 + } 231 + 232 + iir = data[0]; 233 + if (!(iir & 0x01)) { /* serial port interrupt pending */ 234 + switch (iir & 0x0f) { 235 + case SERIAL_IIR_RLS: 236 + dbg("Serial Port: Receiver status error or address " 237 + "bit detected in 9-bit mode\n"); 238 + break; 239 + case SERIAL_IIR_CTI: 240 + dbg("Serial Port: Receiver time out"); 241 + break; 242 + case SERIAL_IIR_MS: 243 + dbg("Serial Port: Modem status change"); 244 + break; 245 + } 246 + } 247 + 248 + exit: 249 + result = usb_submit_urb(urb, GFP_ATOMIC); 250 + if (result) 251 + dev_err(&urb->dev->dev, 252 + "%s - Error %d submitting control urb\n", 253 + __func__, result); 254 + return; 255 + } 256 + 257 + /* 258 * mos7720_bulk_in_callback 259 * this is the callback function for when we have received data on the 260 * bulk in endpoint. ··· 206 207 mos7720_port = urb->context; 208 if (!mos7720_port) { 209 + dbg("NULL mos7720_port pointer"); 210 return ; 211 } 212 ··· 218 219 tty = tty_port_tty_get(&port->port); 220 if (tty && urb->actual_length) { 221 tty_insert_flip_string(tty, data, urb->actual_length); 222 tty_flip_buffer_push(tty); 223 } ··· 275 * this function will be used for sending command to device 276 */ 277 static int send_mos_cmd(struct usb_serial *serial, __u8 request, __u16 value, 278 + __u16 index, u8 *data) 279 { 280 int status; 281 + u8 *buf; 282 u16 product = le16_to_cpu(serial->dev->descriptor.idProduct); 283 284 if (value < MOS_MAX_PORT) { 285 if (product == MOSCHIP_DEVICE_ID_7715) 286 + value = 0x0200; /* identifies the 7715's serial port */ 287 else 288 value = value*0x100+0x200; 289 } else { ··· 298 } 299 300 if (request == MOS_WRITE) { 301 + value = value + *data; 302 + status = usb_control_msg(serial->dev, 303 + usb_sndctrlpipe(serial->dev, 0), MOS_WRITE, 304 + 0x40, value, index, NULL, 0, MOS_WDR_TIMEOUT); 305 } else { 306 + buf = kmalloc(1, GFP_KERNEL); 307 + if (!buf) { 308 + status = -ENOMEM; 309 + goto out; 310 + } 311 + status = usb_control_msg(serial->dev, 312 + usb_rcvctrlpipe(serial->dev, 0), MOS_READ, 313 + 0xc0, value, index, buf, 1, MOS_WDR_TIMEOUT); 314 + *data = *buf; 315 + kfree(buf); 316 } 317 + out: 318 if (status < 0) 319 + dbg("Command Write failed Value %x index %x", value, index); 320 321 return status; 322 + } 323 + 324 + 325 + /* 326 + * mos77xx_probe 327 + * this function installs the appropriate read interrupt endpoint callback 328 + * depending on whether the device is a 7720 or 7715, thus avoiding costly 329 + * run-time checks in the high-frequency callback routine itself. 330 + */ 331 + static int mos77xx_probe(struct usb_serial *serial, 332 + const struct usb_device_id *id) 333 + { 334 + if (id->idProduct == MOSCHIP_DEVICE_ID_7715) 335 + moschip7720_2port_driver.read_int_callback = 336 + mos7715_interrupt_callback; 337 + else 338 + moschip7720_2port_driver.read_int_callback = 339 + mos7720_interrupt_callback; 340 + 341 + return 0; 342 + } 343 + 344 + static int mos77xx_calc_num_ports(struct usb_serial *serial) 345 + { 346 + u16 product = le16_to_cpu(serial->dev->descriptor.idProduct); 347 + if (product == MOSCHIP_DEVICE_ID_7715) 348 + return 1; 349 + 350 + return 2; 351 } 352 353 static int mos7720_open(struct tty_struct *tty, struct usb_serial_port *port) ··· 390 */ 391 port_number = port->number - port->serial->minor; 392 send_mos_cmd(port->serial, MOS_READ, port_number, UART_LSR, &data); 393 + dbg("SS::%p LSR:%x", mos7720_port, data); 394 395 dbg("Check:Sending Command .........."); 396 ··· 729 struct moschip_port *mos7720_port; 730 int status; 731 732 + dbg("%s- port %d", __func__, port->number); 733 734 mos7720_port = usb_get_serial_port_data(port); 735 ··· 1208 return; 1209 } 1210 1211 + dbg("setting termios - ASPIRE"); 1212 1213 cflag = tty->termios->c_cflag; 1214 ··· 1226 change_port_settings(tty, mos7720_port, old_termios); 1227 1228 if (!port->read_urb) { 1229 + dbg("URB KILLED !!!!!"); 1230 return; 1231 } 1232 ··· 1495 struct usb_device *dev; 1496 int i; 1497 char data; 1498 + u16 product = le16_to_cpu(serial->dev->descriptor.idProduct); 1499 1500 dbg("%s: Entering ..........", __func__); 1501 ··· 1514 1515 usb_set_serial_data(serial, mos7720_serial); 1516 1517 + /* 1518 + * The 7715 uses the first bulk in/out endpoint pair for the parallel 1519 + * port, and the second for the serial port. Because the usbserial core 1520 + * assumes both pairs are serial ports, we must engage in a bit of 1521 + * subterfuge and swap the pointers for ports 0 and 1 in order to make 1522 + * port 0 point to the serial port. However, both moschip devices use a 1523 + * single interrupt-in endpoint for both ports (as mentioned a little 1524 + * further down), and this endpoint was assigned to port 0. So after 1525 + * the swap, we must copy the interrupt endpoint elements from port 1 1526 + * (as newly assigned) to port 0, and null out port 1 pointers. 1527 + */ 1528 + if (product == MOSCHIP_DEVICE_ID_7715) { 1529 + struct usb_serial_port *tmp = serial->port[0]; 1530 + serial->port[0] = serial->port[1]; 1531 + serial->port[1] = tmp; 1532 + serial->port[0]->interrupt_in_urb = tmp->interrupt_in_urb; 1533 + serial->port[0]->interrupt_in_buffer = tmp->interrupt_in_buffer; 1534 + serial->port[0]->interrupt_in_endpointAddress = 1535 + tmp->interrupt_in_endpointAddress; 1536 + serial->port[1]->interrupt_in_urb = NULL; 1537 + serial->port[1]->interrupt_in_buffer = NULL; 1538 + } 1539 + 1540 /* we set up the pointers to the endpoints in the mos7720_open * 1541 * function, as the structures aren't created yet. */ 1542 ··· 1529 1530 /* Initialize all port interrupt end point to port 0 int 1531 * endpoint. Our device has only one interrupt endpoint 1532 + * common to all ports */ 1533 serial->port[i]->interrupt_in_endpointAddress = 1534 serial->port[0]->interrupt_in_endpointAddress; 1535 ··· 1584 .description = "Moschip 2 port adapter", 1585 .usb_driver = &usb_driver, 1586 .id_table = moschip_port_id_table, 1587 + .calc_num_ports = mos77xx_calc_num_ports, 1588 .open = mos7720_open, 1589 .close = mos7720_close, 1590 .throttle = mos7720_throttle, 1591 .unthrottle = mos7720_unthrottle, 1592 + .probe = mos77xx_probe, 1593 .attach = mos7720_startup, 1594 .release = mos7720_release, 1595 .ioctl = mos7720_ioctl, ··· 1600 .chars_in_buffer = mos7720_chars_in_buffer, 1601 .break_ctl = mos7720_break, 1602 .read_bulk_callback = mos7720_bulk_in_callback, 1603 + .read_int_callback = NULL /* dynamically assigned in probe() */ 1604 }; 1605 1606 static int __init moschip7720_init(void)
+20 -7
drivers/usb/serial/mos7840.c
··· 181 #define URB_TRANSFER_BUFFER_SIZE 32 /* URB Size */ 182 183 184 - static struct usb_device_id moschip_port_id_table[] = { 185 {USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7840)}, 186 {USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7820)}, 187 {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USO9ML2_2)}, ··· 198 {} /* terminating entry */ 199 }; 200 201 - static __devinitdata struct usb_device_id moschip_id_table_combined[] = { 202 {USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7840)}, 203 {USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7820)}, 204 {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USO9ML2_2)}, ··· 283 { 284 struct usb_device *dev = port->serial->dev; 285 int ret = 0; 286 287 ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), MCS_RDREQ, 288 - MCS_RD_RTYPE, 0, reg, val, VENDOR_READ_LENGTH, 289 MOS_WDR_TIMEOUT); 290 dbg("mos7840_get_reg_sync offset is %x, return val %x", reg, *val); 291 - *val = (*val) & 0x00ff; 292 return ret; 293 } 294 ··· 348 struct usb_device *dev = port->serial->dev; 349 int ret = 0; 350 __u16 Wval; 351 352 /* dbg("application number is %4x", 353 (((__u16)port->number - (__u16)(port->serial->minor))+1)<<8); */ ··· 376 } 377 } 378 ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), MCS_RDREQ, 379 - MCS_RD_RTYPE, Wval, reg, val, VENDOR_READ_LENGTH, 380 MOS_WDR_TIMEOUT); 381 - *val = (*val) & 0x00ff; 382 return ret; 383 } 384 ··· 764 if (urb->actual_length) { 765 tty = tty_port_tty_get(&mos7840_port->port->port); 766 if (tty) { 767 - tty_buffer_request_room(tty, urb->actual_length); 768 tty_insert_flip_string(tty, data, urb->actual_length); 769 dbg(" %s ", data); 770 tty_flip_buffer_push(tty);
··· 181 #define URB_TRANSFER_BUFFER_SIZE 32 /* URB Size */ 182 183 184 + static const struct usb_device_id moschip_port_id_table[] = { 185 {USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7840)}, 186 {USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7820)}, 187 {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USO9ML2_2)}, ··· 198 {} /* terminating entry */ 199 }; 200 201 + static const struct usb_device_id moschip_id_table_combined[] __devinitconst = { 202 {USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7840)}, 203 {USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7820)}, 204 {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USO9ML2_2)}, ··· 283 { 284 struct usb_device *dev = port->serial->dev; 285 int ret = 0; 286 + u8 *buf; 287 + 288 + buf = kmalloc(VENDOR_READ_LENGTH, GFP_KERNEL); 289 + if (!buf) 290 + return -ENOMEM; 291 292 ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), MCS_RDREQ, 293 + MCS_RD_RTYPE, 0, reg, buf, VENDOR_READ_LENGTH, 294 MOS_WDR_TIMEOUT); 295 + *val = buf[0]; 296 dbg("mos7840_get_reg_sync offset is %x, return val %x", reg, *val); 297 + 298 + kfree(buf); 299 return ret; 300 } 301 ··· 341 struct usb_device *dev = port->serial->dev; 342 int ret = 0; 343 __u16 Wval; 344 + u8 *buf; 345 + 346 + buf = kmalloc(VENDOR_READ_LENGTH, GFP_KERNEL); 347 + if (!buf) 348 + return -ENOMEM; 349 350 /* dbg("application number is %4x", 351 (((__u16)port->number - (__u16)(port->serial->minor))+1)<<8); */ ··· 364 } 365 } 366 ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), MCS_RDREQ, 367 + MCS_RD_RTYPE, Wval, reg, buf, VENDOR_READ_LENGTH, 368 MOS_WDR_TIMEOUT); 369 + *val = buf[0]; 370 + 371 + kfree(buf); 372 return ret; 373 } 374 ··· 750 if (urb->actual_length) { 751 tty = tty_port_tty_get(&mos7840_port->port->port); 752 if (tty) { 753 tty_insert_flip_string(tty, data, urb->actual_length); 754 dbg(" %s ", data); 755 tty_flip_buffer_push(tty);
+1 -1
drivers/usb/serial/moto_modem.c
··· 21 #include <linux/usb.h> 22 #include <linux/usb/serial.h> 23 24 - static struct usb_device_id id_table [] = { 25 { USB_DEVICE(0x05c6, 0x3197) }, /* unknown Motorola phone */ 26 { USB_DEVICE(0x0c44, 0x0022) }, /* unknown Mororola phone */ 27 { USB_DEVICE(0x22b8, 0x2a64) }, /* Motorola KRZR K1m */
··· 21 #include <linux/usb.h> 22 #include <linux/usb/serial.h> 23 24 + static const struct usb_device_id id_table[] = { 25 { USB_DEVICE(0x05c6, 0x3197) }, /* unknown Motorola phone */ 26 { USB_DEVICE(0x0c44, 0x0022) }, /* unknown Mororola phone */ 27 { USB_DEVICE(0x22b8, 0x2a64) }, /* Motorola KRZR K1m */
+1 -2
drivers/usb/serial/navman.c
··· 22 23 static int debug; 24 25 - static struct usb_device_id id_table [] = { 26 { USB_DEVICE(0x0a99, 0x0001) }, /* Talon Technology device */ 27 { }, 28 }; ··· 66 67 tty = tty_port_tty_get(&port->port); 68 if (tty && urb->actual_length) { 69 - tty_buffer_request_room(tty, urb->actual_length); 70 tty_insert_flip_string(tty, data, urb->actual_length); 71 tty_flip_buffer_push(tty); 72 }
··· 22 23 static int debug; 24 25 + static const struct usb_device_id id_table[] = { 26 { USB_DEVICE(0x0a99, 0x0001) }, /* Talon Technology device */ 27 { }, 28 }; ··· 66 67 tty = tty_port_tty_get(&port->port); 68 if (tty && urb->actual_length) { 69 tty_insert_flip_string(tty, data, urb->actual_length); 70 tty_flip_buffer_push(tty); 71 }
+4 -4
drivers/usb/serial/omninet.c
··· 75 static void omninet_release(struct usb_serial *serial); 76 static int omninet_attach(struct usb_serial *serial); 77 78 - static struct usb_device_id id_table[] = { 79 { USB_DEVICE(ZYXEL_VENDOR_ID, ZYXEL_OMNINET_ID) }, 80 { USB_DEVICE(ZYXEL_VENDOR_ID, BT_IGNITIONPRO_ID) }, 81 { } /* Terminating entry */ ··· 218 219 if (debug && header->oh_xxx != 0x30) { 220 if (urb->actual_length) { 221 - printk(KERN_DEBUG __FILE__ 222 - ": omninet_read %d: ", header->oh_len); 223 for (i = 0; i < (header->oh_len + 224 OMNINET_HEADERLEN); i++) 225 printk("%.2x ", data[i]); ··· 332 struct usb_serial_port *port = urb->context; 333 int status = urb->status; 334 335 - dbg("%s - port %0x\n", __func__, port->number); 336 337 port->write_urb_busy = 0; 338 if (status) {
··· 75 static void omninet_release(struct usb_serial *serial); 76 static int omninet_attach(struct usb_serial *serial); 77 78 + static const struct usb_device_id id_table[] = { 79 { USB_DEVICE(ZYXEL_VENDOR_ID, ZYXEL_OMNINET_ID) }, 80 { USB_DEVICE(ZYXEL_VENDOR_ID, BT_IGNITIONPRO_ID) }, 81 { } /* Terminating entry */ ··· 218 219 if (debug && header->oh_xxx != 0x30) { 220 if (urb->actual_length) { 221 + printk(KERN_DEBUG "%s: omninet_read %d: ", 222 + __FILE__, header->oh_len); 223 for (i = 0; i < (header->oh_len + 224 OMNINET_HEADERLEN); i++) 225 printk("%.2x ", data[i]); ··· 332 struct usb_serial_port *port = urb->context; 333 int status = urb->status; 334 335 + dbg("%s - port %0x", __func__, port->number); 336 337 port->write_urb_busy = 0; 338 if (status) {
+6 -11
drivers/usb/serial/opticon.c
··· 22 23 static int debug; 24 25 - static struct usb_device_id id_table[] = { 26 { USB_DEVICE(0x065a, 0x0009) }, 27 { }, 28 }; ··· 55 int status = urb->status; 56 struct tty_struct *tty; 57 int result; 58 - int available_room = 0; 59 int data_length; 60 61 dbg("%s - port %d", __func__, port->number); ··· 95 /* real data, send it to the tty layer */ 96 tty = tty_port_tty_get(&port->port); 97 if (tty) { 98 - available_room = tty_buffer_request_room(tty, 99 - data_length); 100 - if (available_room) { 101 - tty_insert_flip_string(tty, data, 102 - available_room); 103 - tty_flip_buffer_push(tty); 104 - } 105 tty_kref_put(tty); 106 } 107 } else { ··· 212 spin_lock_irqsave(&priv->lock, flags); 213 if (priv->outstanding_urbs > URB_UPPER_LIMIT) { 214 spin_unlock_irqrestore(&priv->lock, flags); 215 - dbg("%s - write limit hit\n", __func__); 216 return 0; 217 } 218 priv->outstanding_urbs++; ··· 283 spin_lock_irqsave(&priv->lock, flags); 284 if (priv->outstanding_urbs > URB_UPPER_LIMIT * 2 / 3) { 285 spin_unlock_irqrestore(&priv->lock, flags); 286 - dbg("%s - write limit hit\n", __func__); 287 return 0; 288 } 289 spin_unlock_irqrestore(&priv->lock, flags);
··· 22 23 static int debug; 24 25 + static const struct usb_device_id id_table[] = { 26 { USB_DEVICE(0x065a, 0x0009) }, 27 { }, 28 }; ··· 55 int status = urb->status; 56 struct tty_struct *tty; 57 int result; 58 int data_length; 59 60 dbg("%s - port %d", __func__, port->number); ··· 96 /* real data, send it to the tty layer */ 97 tty = tty_port_tty_get(&port->port); 98 if (tty) { 99 + tty_insert_flip_string(tty, data, 100 + data_length); 101 + tty_flip_buffer_push(tty); 102 tty_kref_put(tty); 103 } 104 } else { ··· 217 spin_lock_irqsave(&priv->lock, flags); 218 if (priv->outstanding_urbs > URB_UPPER_LIMIT) { 219 spin_unlock_irqrestore(&priv->lock, flags); 220 + dbg("%s - write limit hit", __func__); 221 return 0; 222 } 223 priv->outstanding_urbs++; ··· 288 spin_lock_irqsave(&priv->lock, flags); 289 if (priv->outstanding_urbs > URB_UPPER_LIMIT * 2 / 3) { 290 spin_unlock_irqrestore(&priv->lock, flags); 291 + dbg("%s - write limit hit", __func__); 292 return 0; 293 } 294 spin_unlock_irqrestore(&priv->lock, flags);
+63 -8
drivers/usb/serial/option.c
··· 336 #define AIRPLUS_VENDOR_ID 0x1011 337 #define AIRPLUS_PRODUCT_MCD650 0x3198 338 339 /* 4G Systems products */ 340 - #define FOUR_G_SYSTEMS_VENDOR_ID 0x1c9e 341 #define FOUR_G_SYSTEMS_PRODUCT_W14 0x9603 342 343 /* Haier products */ 344 #define HAIER_VENDOR_ID 0x201e 345 #define HAIER_PRODUCT_CE100 0x2009 346 347 - static struct usb_device_id option_ids[] = { 348 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) }, 349 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) }, 350 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_LIGHT) }, ··· 671 { USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_X060S) }, 672 { USB_DEVICE(AIRPLUS_VENDOR_ID, AIRPLUS_PRODUCT_MCD650) }, 673 { USB_DEVICE(TLAYTECH_VENDOR_ID, TLAYTECH_PRODUCT_TEU800) }, 674 - { USB_DEVICE(FOUR_G_SYSTEMS_VENDOR_ID, FOUR_G_SYSTEMS_PRODUCT_W14) }, 675 { USB_DEVICE(HAIER_VENDOR_ID, HAIER_PRODUCT_CE100) }, 676 { } /* Terminating entry */ 677 }; ··· 738 spinlock_t susp_lock; 739 unsigned int suspended:1; 740 int in_flight; 741 }; 742 743 struct option_port_private { ··· 808 if (!data) 809 return -ENOMEM; 810 spin_lock_init(&data->susp_lock); 811 return 0; 812 } 813 814 static void option_set_termios(struct tty_struct *tty, ··· 969 } else { 970 tty = tty_port_tty_get(&port->port); 971 if (urb->actual_length) { 972 - tty_buffer_request_room(tty, urb->actual_length); 973 tty_insert_flip_string(tty, data, urb->actual_length); 974 tty_flip_buffer_push(tty); 975 } else ··· 976 tty_kref_put(tty); 977 978 /* Resubmit urb so we continue receiving */ 979 - if (port->port.count && status != -ESHUTDOWN) { 980 err = usb_submit_urb(urb, GFP_ATOMIC); 981 - if (err) 982 printk(KERN_ERR "%s: resubmit read urb failed. " 983 "(%d)", __func__, err); 984 else ··· 1032 (struct usb_ctrlrequest *)urb->transfer_buffer; 1033 1034 if (!req_pkt) { 1035 - dbg("%s: NULL req_pkt\n", __func__); 1036 return; 1037 } 1038 if ((req_pkt->bRequestType == 0xA1) && ··· 1258 static int option_send_setup(struct usb_serial_port *port) 1259 { 1260 struct usb_serial *serial = port->serial; 1261 struct option_port_private *portdata; 1262 int ifNum = serial->interface->cur_altsetting->desc.bInterfaceNumber; 1263 int val = 0; 1264 dbg("%s", __func__); 1265 1266 portdata = usb_get_serial_port_data(port); 1267 ··· 1456 for (i = 0; i < serial->num_ports; i++) { 1457 port = serial->port[i]; 1458 if (!port->interrupt_in_urb) { 1459 - dbg("%s: No interrupt URB for port %d\n", __func__, i); 1460 continue; 1461 } 1462 err = usb_submit_urb(port->interrupt_in_urb, GFP_NOIO);
··· 336 #define AIRPLUS_VENDOR_ID 0x1011 337 #define AIRPLUS_PRODUCT_MCD650 0x3198 338 339 + /* Longcheer/Longsung vendor ID; makes whitelabel devices that 340 + * many other vendors like 4G Systems, Alcatel, ChinaBird, 341 + * Mobidata, etc sell under their own brand names. 342 + */ 343 + #define LONGCHEER_VENDOR_ID 0x1c9e 344 + 345 /* 4G Systems products */ 346 + /* This is the 4G XS Stick W14 a.k.a. Mobilcom Debitel Surf-Stick * 347 + * It seems to contain a Qualcomm QSC6240/6290 chipset */ 348 #define FOUR_G_SYSTEMS_PRODUCT_W14 0x9603 349 350 /* Haier products */ 351 #define HAIER_VENDOR_ID 0x201e 352 #define HAIER_PRODUCT_CE100 0x2009 353 354 + /* some devices interfaces need special handling due to a number of reasons */ 355 + enum option_blacklist_reason { 356 + OPTION_BLACKLIST_NONE = 0, 357 + OPTION_BLACKLIST_SENDSETUP = 1, 358 + OPTION_BLACKLIST_RESERVED_IF = 2 359 + }; 360 + 361 + struct option_blacklist_info { 362 + const u32 infolen; /* number of interface numbers on blacklist */ 363 + const u8 *ifaceinfo; /* pointer to the array holding the numbers */ 364 + enum option_blacklist_reason reason; 365 + }; 366 + 367 + static const u8 four_g_w14_no_sendsetup[] = { 0, 1 }; 368 + static const struct option_blacklist_info four_g_w14_blacklist = { 369 + .infolen = ARRAY_SIZE(four_g_w14_no_sendsetup), 370 + .ifaceinfo = four_g_w14_no_sendsetup, 371 + .reason = OPTION_BLACKLIST_SENDSETUP 372 + }; 373 + 374 + static const struct usb_device_id option_ids[] = { 375 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) }, 376 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) }, 377 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_LIGHT) }, ··· 644 { USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_X060S) }, 645 { USB_DEVICE(AIRPLUS_VENDOR_ID, AIRPLUS_PRODUCT_MCD650) }, 646 { USB_DEVICE(TLAYTECH_VENDOR_ID, TLAYTECH_PRODUCT_TEU800) }, 647 + { USB_DEVICE(LONGCHEER_VENDOR_ID, FOUR_G_SYSTEMS_PRODUCT_W14), 648 + .driver_info = (kernel_ulong_t)&four_g_w14_blacklist 649 + }, 650 { USB_DEVICE(HAIER_VENDOR_ID, HAIER_PRODUCT_CE100) }, 651 { } /* Terminating entry */ 652 }; ··· 709 spinlock_t susp_lock; 710 unsigned int suspended:1; 711 int in_flight; 712 + struct option_blacklist_info *blacklist_info; 713 }; 714 715 struct option_port_private { ··· 778 if (!data) 779 return -ENOMEM; 780 spin_lock_init(&data->susp_lock); 781 + data->blacklist_info = (struct option_blacklist_info*) id->driver_info; 782 return 0; 783 + } 784 + 785 + static enum option_blacklist_reason is_blacklisted(const u8 ifnum, 786 + const struct option_blacklist_info *blacklist) 787 + { 788 + const u8 *info; 789 + int i; 790 + 791 + if (blacklist) { 792 + info = blacklist->ifaceinfo; 793 + 794 + for (i = 0; i < blacklist->infolen; i++) { 795 + if (info[i] == ifnum) 796 + return blacklist->reason; 797 + } 798 + } 799 + return OPTION_BLACKLIST_NONE; 800 } 801 802 static void option_set_termios(struct tty_struct *tty, ··· 921 } else { 922 tty = tty_port_tty_get(&port->port); 923 if (urb->actual_length) { 924 tty_insert_flip_string(tty, data, urb->actual_length); 925 tty_flip_buffer_push(tty); 926 } else ··· 929 tty_kref_put(tty); 930 931 /* Resubmit urb so we continue receiving */ 932 + if (status != -ESHUTDOWN) { 933 err = usb_submit_urb(urb, GFP_ATOMIC); 934 + if (err && err != -EPERM) 935 printk(KERN_ERR "%s: resubmit read urb failed. " 936 "(%d)", __func__, err); 937 else ··· 985 (struct usb_ctrlrequest *)urb->transfer_buffer; 986 987 if (!req_pkt) { 988 + dbg("%s: NULL req_pkt", __func__); 989 return; 990 } 991 if ((req_pkt->bRequestType == 0xA1) && ··· 1211 static int option_send_setup(struct usb_serial_port *port) 1212 { 1213 struct usb_serial *serial = port->serial; 1214 + struct option_intf_private *intfdata = 1215 + (struct option_intf_private *) serial->private; 1216 struct option_port_private *portdata; 1217 int ifNum = serial->interface->cur_altsetting->desc.bInterfaceNumber; 1218 int val = 0; 1219 dbg("%s", __func__); 1220 + 1221 + if (is_blacklisted(ifNum, intfdata->blacklist_info) == 1222 + OPTION_BLACKLIST_SENDSETUP) { 1223 + dbg("No send_setup on blacklisted interface #%d\n", ifNum); 1224 + return -EIO; 1225 + } 1226 1227 portdata = usb_get_serial_port_data(port); 1228 ··· 1401 for (i = 0; i < serial->num_ports; i++) { 1402 port = serial->port[i]; 1403 if (!port->interrupt_in_urb) { 1404 + dbg("%s: No interrupt URB for port %d", __func__, i); 1405 continue; 1406 } 1407 err = usb_submit_urb(port->interrupt_in_urb, GFP_NOIO);
+17 -19
drivers/usb/serial/oti6858.c
··· 58 #define OTI6858_AUTHOR "Tomasz Michal Lukaszewski <FIXME@FIXME>" 59 #define OTI6858_VERSION "0.1" 60 61 - static struct usb_device_id id_table [] = { 62 { USB_DEVICE(OTI6858_VENDOR_ID, OTI6858_PRODUCT_ID) }, 63 { } 64 }; ··· 302 struct usb_serial_port *port = priv->port; 303 int count = 0, result; 304 unsigned long flags; 305 - unsigned char allow; 306 307 dbg("%s(port = %d)", __func__, port->number); 308 ··· 321 count = port->bulk_out_size; 322 323 if (count != 0) { 324 result = usb_control_msg(port->serial->dev, 325 usb_rcvctrlpipe(port->serial->dev, 0), 326 OTI6858_REQ_T_CHECK_TXBUFF, 327 OTI6858_REQ_CHECK_TXBUFF, 328 - count, 0, &allow, 1, 100); 329 - if (result != 1 || allow != 0) 330 count = 0; 331 } 332 333 if (count == 0) { ··· 584 585 usb_clear_halt(serial->dev, port->write_urb->pipe); 586 usb_clear_halt(serial->dev, port->read_urb->pipe); 587 - 588 - if (port->port.count != 1) 589 - return 0; 590 591 buf = kmalloc(OTI6858_CTRL_PKT_SIZE, GFP_KERNEL); 592 if (buf == NULL) { ··· 931 spin_unlock_irqrestore(&priv->lock, flags); 932 933 if (status != 0) { 934 - if (!port->port.count) { 935 - dbg("%s(): port is closed, exiting", __func__); 936 - return; 937 - } 938 /* 939 if (status == -EPROTO) { 940 * PL2303 mysteriously fails with -EPROTO reschedule ··· 954 } 955 tty_kref_put(tty); 956 957 - /* schedule the interrupt urb if we are still open */ 958 - if (port->port.count != 0) { 959 - port->interrupt_in_urb->dev = port->serial->dev; 960 - result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); 961 - if (result != 0) { 962 - dev_err(&port->dev, "%s(): usb_submit_urb() failed," 963 - " error %d\n", __func__, result); 964 - } 965 } 966 } 967
··· 58 #define OTI6858_AUTHOR "Tomasz Michal Lukaszewski <FIXME@FIXME>" 59 #define OTI6858_VERSION "0.1" 60 61 + static const struct usb_device_id id_table[] = { 62 { USB_DEVICE(OTI6858_VENDOR_ID, OTI6858_PRODUCT_ID) }, 63 { } 64 }; ··· 302 struct usb_serial_port *port = priv->port; 303 int count = 0, result; 304 unsigned long flags; 305 + u8 *allow; 306 307 dbg("%s(port = %d)", __func__, port->number); 308 ··· 321 count = port->bulk_out_size; 322 323 if (count != 0) { 324 + allow = kmalloc(1, GFP_KERNEL); 325 + if (!allow) { 326 + dev_err(&port->dev, "%s(): kmalloc failed\n", 327 + __func__); 328 + return; 329 + } 330 result = usb_control_msg(port->serial->dev, 331 usb_rcvctrlpipe(port->serial->dev, 0), 332 OTI6858_REQ_T_CHECK_TXBUFF, 333 OTI6858_REQ_CHECK_TXBUFF, 334 + count, 0, allow, 1, 100); 335 + if (result != 1 || *allow != 0) 336 count = 0; 337 + kfree(allow); 338 } 339 340 if (count == 0) { ··· 577 578 usb_clear_halt(serial->dev, port->write_urb->pipe); 579 usb_clear_halt(serial->dev, port->read_urb->pipe); 580 581 buf = kmalloc(OTI6858_CTRL_PKT_SIZE, GFP_KERNEL); 582 if (buf == NULL) { ··· 927 spin_unlock_irqrestore(&priv->lock, flags); 928 929 if (status != 0) { 930 /* 931 if (status == -EPROTO) { 932 * PL2303 mysteriously fails with -EPROTO reschedule ··· 954 } 955 tty_kref_put(tty); 956 957 + /* schedule the interrupt urb */ 958 + port->interrupt_in_urb->dev = port->serial->dev; 959 + result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); 960 + if (result != 0 && result != -EPERM) { 961 + dev_err(&port->dev, "%s(): usb_submit_urb() failed," 962 + " error %d\n", __func__, result); 963 } 964 } 965
+18 -20
drivers/usb/serial/pl2303.c
··· 50 char *buf_put; 51 }; 52 53 - static struct usb_device_id id_table [] = { 54 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID) }, 55 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_RSAQ2) }, 56 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_DCU11) }, ··· 451 port->write_urb->transfer_buffer); 452 453 port->write_urb->transfer_buffer_length = count; 454 - port->write_urb->dev = port->serial->dev; 455 result = usb_submit_urb(port->write_urb, GFP_ATOMIC); 456 if (result) { 457 dev_err(&port->dev, "%s - failed submitting write urb," ··· 768 pl2303_set_termios(tty, port, &tmp_termios); 769 770 dbg("%s - submitting read urb", __func__); 771 - port->read_urb->dev = serial->dev; 772 result = usb_submit_urb(port->read_urb, GFP_KERNEL); 773 if (result) { 774 dev_err(&port->dev, "%s - failed submitting read urb," ··· 777 } 778 779 dbg("%s - submitting interrupt urb", __func__); 780 - port->interrupt_in_urb->dev = serial->dev; 781 result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); 782 if (result) { 783 dev_err(&port->dev, "%s - failed submitting interrupt urb," ··· 892 static int pl2303_ioctl(struct tty_struct *tty, struct file *file, 893 unsigned int cmd, unsigned long arg) 894 { 895 struct usb_serial_port *port = tty->driver_data; 896 dbg("%s (%d) cmd = 0x%04x", __func__, port->number, cmd); 897 898 switch (cmd) { 899 case TIOCMIWAIT: 900 dbg("%s (%d) TIOCMIWAIT", __func__, port->number); 901 return wait_modem_info(port, arg); ··· 1052 tty_flag = TTY_FRAME; 1053 dbg("%s - tty_flag = %d", __func__, tty_flag); 1054 1055 - tty_buffer_request_room(tty, urb->actual_length + 1); 1056 /* overrun is special, not associated with a char */ 1057 if (line_status & UART_OVERRUN_ERROR) 1058 tty_insert_flip_char(tty, 0, TTY_OVERRUN); ··· 1081 1082 if (status) { 1083 dbg("%s - urb status = %d", __func__, status); 1084 - if (!port->port.count) { 1085 - dbg("%s - port is closed, exiting.", __func__); 1086 - return; 1087 - } 1088 if (status == -EPROTO) { 1089 /* PL2303 mysteriously fails with -EPROTO reschedule 1090 * the read */ 1091 dbg("%s - caught -EPROTO, resubmitting the urb", 1092 __func__); 1093 - urb->dev = port->serial->dev; 1094 result = usb_submit_urb(urb, GFP_ATOMIC); 1095 if (result) 1096 dev_err(&urb->dev->dev, "%s - failed" ··· 1112 } 1113 tty_kref_put(tty); 1114 /* Schedule the next read _if_ we are still open */ 1115 - if (port->port.count) { 1116 - urb->dev = port->serial->dev; 1117 - result = usb_submit_urb(urb, GFP_ATOMIC); 1118 - if (result) 1119 - dev_err(&urb->dev->dev, "%s - failed resubmitting" 1120 - " read urb, error %d\n", __func__, result); 1121 - } 1122 - 1123 - return; 1124 } 1125 1126 static void pl2303_write_bulk_callback(struct urb *urb) ··· 1145 dbg("%s - nonzero write bulk status received: %d", __func__, 1146 status); 1147 port->write_urb->transfer_buffer_length = 1; 1148 - port->write_urb->dev = port->serial->dev; 1149 result = usb_submit_urb(port->write_urb, GFP_ATOMIC); 1150 if (result) 1151 dev_err(&urb->dev->dev, "%s - failed resubmitting write"
··· 50 char *buf_put; 51 }; 52 53 + static const struct usb_device_id id_table[] = { 54 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID) }, 55 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_RSAQ2) }, 56 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_DCU11) }, ··· 451 port->write_urb->transfer_buffer); 452 453 port->write_urb->transfer_buffer_length = count; 454 result = usb_submit_urb(port->write_urb, GFP_ATOMIC); 455 if (result) { 456 dev_err(&port->dev, "%s - failed submitting write urb," ··· 769 pl2303_set_termios(tty, port, &tmp_termios); 770 771 dbg("%s - submitting read urb", __func__); 772 result = usb_submit_urb(port->read_urb, GFP_KERNEL); 773 if (result) { 774 dev_err(&port->dev, "%s - failed submitting read urb," ··· 779 } 780 781 dbg("%s - submitting interrupt urb", __func__); 782 result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); 783 if (result) { 784 dev_err(&port->dev, "%s - failed submitting interrupt urb," ··· 895 static int pl2303_ioctl(struct tty_struct *tty, struct file *file, 896 unsigned int cmd, unsigned long arg) 897 { 898 + struct serial_struct ser; 899 struct usb_serial_port *port = tty->driver_data; 900 dbg("%s (%d) cmd = 0x%04x", __func__, port->number, cmd); 901 902 switch (cmd) { 903 + case TIOCGSERIAL: 904 + memset(&ser, 0, sizeof ser); 905 + ser.type = PORT_16654; 906 + ser.line = port->serial->minor; 907 + ser.port = port->number; 908 + ser.baud_base = 460800; 909 + 910 + if (copy_to_user((void __user *)arg, &ser, sizeof ser)) 911 + return -EFAULT; 912 + 913 + return 0; 914 + 915 case TIOCMIWAIT: 916 dbg("%s (%d) TIOCMIWAIT", __func__, port->number); 917 return wait_modem_info(port, arg); ··· 1042 tty_flag = TTY_FRAME; 1043 dbg("%s - tty_flag = %d", __func__, tty_flag); 1044 1045 /* overrun is special, not associated with a char */ 1046 if (line_status & UART_OVERRUN_ERROR) 1047 tty_insert_flip_char(tty, 0, TTY_OVERRUN); ··· 1072 1073 if (status) { 1074 dbg("%s - urb status = %d", __func__, status); 1075 if (status == -EPROTO) { 1076 /* PL2303 mysteriously fails with -EPROTO reschedule 1077 * the read */ 1078 dbg("%s - caught -EPROTO, resubmitting the urb", 1079 __func__); 1080 result = usb_submit_urb(urb, GFP_ATOMIC); 1081 if (result) 1082 dev_err(&urb->dev->dev, "%s - failed" ··· 1108 } 1109 tty_kref_put(tty); 1110 /* Schedule the next read _if_ we are still open */ 1111 + result = usb_submit_urb(urb, GFP_ATOMIC); 1112 + if (result && result != -EPERM) 1113 + dev_err(&urb->dev->dev, "%s - failed resubmitting" 1114 + " read urb, error %d\n", __func__, result); 1115 } 1116 1117 static void pl2303_write_bulk_callback(struct urb *urb) ··· 1146 dbg("%s - nonzero write bulk status received: %d", __func__, 1147 status); 1148 port->write_urb->transfer_buffer_length = 1; 1149 result = usb_submit_urb(port->write_urb, GFP_ATOMIC); 1150 if (result) 1151 dev_err(&urb->dev->dev, "%s - failed resubmitting write"
+96
drivers/usb/serial/qcaux.c
···
··· 1 + /* 2 + * Qualcomm USB Auxiliary Serial Port driver 3 + * 4 + * Copyright (C) 2008 Greg Kroah-Hartman <greg@kroah.com> 5 + * Copyright (C) 2010 Dan Williams <dcbw@redhat.com> 6 + * 7 + * This program is free software; you can redistribute it and/or modify 8 + * it under the terms of the GNU General Public License version 2 as 9 + * published by the Free Software Foundation. 10 + * 11 + * Devices listed here usually provide a CDC ACM port on which normal modem 12 + * AT commands and PPP can be used. But when that port is in-use by PPP it 13 + * cannot be used simultaneously for status or signal strength. Instead, the 14 + * ports here can be queried for that information using the Qualcomm DM 15 + * protocol. 16 + */ 17 + 18 + #include <linux/kernel.h> 19 + #include <linux/init.h> 20 + #include <linux/tty.h> 21 + #include <linux/module.h> 22 + #include <linux/usb.h> 23 + #include <linux/usb/serial.h> 24 + 25 + /* NOTE: for now, only use this driver for devices that provide a CDC-ACM port 26 + * for normal AT commands, but also provide secondary USB interfaces for the 27 + * QCDM-capable ports. Devices that do not provide a CDC-ACM port should 28 + * probably be driven by option.ko. 29 + */ 30 + 31 + /* UTStarcom/Pantech/Curitel devices */ 32 + #define UTSTARCOM_VENDOR_ID 0x106c 33 + #define UTSTARCOM_PRODUCT_PC5740 0x3701 34 + #define UTSTARCOM_PRODUCT_PC5750 0x3702 /* aka Pantech PX-500 */ 35 + #define UTSTARCOM_PRODUCT_UM150 0x3711 36 + #define UTSTARCOM_PRODUCT_UM175_V1 0x3712 37 + #define UTSTARCOM_PRODUCT_UM175_V2 0x3714 38 + #define UTSTARCOM_PRODUCT_UM175_ALLTEL 0x3715 39 + 40 + /* CMOTECH devices */ 41 + #define CMOTECH_VENDOR_ID 0x16d8 42 + #define CMOTECH_PRODUCT_CDU550 0x5553 43 + #define CMOTECH_PRODUCT_CDX650 0x6512 44 + 45 + static struct usb_device_id id_table[] = { 46 + { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, UTSTARCOM_PRODUCT_PC5740, 0xff, 0x00, 0x00) }, 47 + { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, UTSTARCOM_PRODUCT_PC5750, 0xff, 0x00, 0x00) }, 48 + { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, UTSTARCOM_PRODUCT_UM150, 0xff, 0x00, 0x00) }, 49 + { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, UTSTARCOM_PRODUCT_UM175_V1, 0xff, 0x00, 0x00) }, 50 + { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, UTSTARCOM_PRODUCT_UM175_V2, 0xff, 0x00, 0x00) }, 51 + { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, UTSTARCOM_PRODUCT_UM175_ALLTEL, 0xff, 0x00, 0x00) }, 52 + { USB_DEVICE_AND_INTERFACE_INFO(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CDU550, 0xff, 0xff, 0x00) }, 53 + { USB_DEVICE_AND_INTERFACE_INFO(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CDX650, 0xff, 0xff, 0x00) }, 54 + { }, 55 + }; 56 + MODULE_DEVICE_TABLE(usb, id_table); 57 + 58 + static struct usb_driver qcaux_driver = { 59 + .name = "qcaux", 60 + .probe = usb_serial_probe, 61 + .disconnect = usb_serial_disconnect, 62 + .id_table = id_table, 63 + .no_dynamic_id = 1, 64 + }; 65 + 66 + static struct usb_serial_driver qcaux_device = { 67 + .driver = { 68 + .owner = THIS_MODULE, 69 + .name = "qcaux", 70 + }, 71 + .id_table = id_table, 72 + .num_ports = 1, 73 + }; 74 + 75 + static int __init qcaux_init(void) 76 + { 77 + int retval; 78 + 79 + retval = usb_serial_register(&qcaux_device); 80 + if (retval) 81 + return retval; 82 + retval = usb_register(&qcaux_driver); 83 + if (retval) 84 + usb_serial_deregister(&qcaux_device); 85 + return retval; 86 + } 87 + 88 + static void __exit qcaux_exit(void) 89 + { 90 + usb_deregister(&qcaux_driver); 91 + usb_serial_deregister(&qcaux_device); 92 + } 93 + 94 + module_init(qcaux_init); 95 + module_exit(qcaux_exit); 96 + MODULE_LICENSE("GPL");
+1 -1
drivers/usb/serial/qcserial.c
··· 21 22 static int debug; 23 24 - static struct usb_device_id id_table[] = { 25 {USB_DEVICE(0x05c6, 0x9211)}, /* Acer Gobi QDL device */ 26 {USB_DEVICE(0x05c6, 0x9212)}, /* Acer Gobi Modem Device */ 27 {USB_DEVICE(0x03f0, 0x1f1d)}, /* HP un2400 Gobi Modem Device */
··· 21 22 static int debug; 23 24 + static const struct usb_device_id id_table[] = { 25 {USB_DEVICE(0x05c6, 0x9211)}, /* Acer Gobi QDL device */ 26 {USB_DEVICE(0x05c6, 0x9212)}, /* Acer Gobi Modem Device */ 27 {USB_DEVICE(0x03f0, 0x1f1d)}, /* HP un2400 Gobi Modem Device */
+1 -1
drivers/usb/serial/siemens_mpi.c
··· 22 #define DRIVER_DESC "Driver for Siemens USB/MPI adapter" 23 24 25 - static struct usb_device_id id_table[] = { 26 /* Vendor and product id for 6ES7-972-0CB20-0XA0 */ 27 { USB_DEVICE(0x908, 0x0004) }, 28 { },
··· 22 #define DRIVER_DESC "Driver for Siemens USB/MPI adapter" 23 24 25 + static const struct usb_device_id id_table[] = { 26 /* Vendor and product id for 6ES7-972-0CB20-0XA0 */ 27 { USB_DEVICE(0x908, 0x0004) }, 28 { },
+34 -23
drivers/usb/serial/sierra.c
··· 226 .ifaceinfo = direct_ip_non_serial_ifaces, 227 }; 228 229 - static struct usb_device_id id_table [] = { 230 { USB_DEVICE(0x0F3D, 0x0112) }, /* Airprime/Sierra PC 5220 */ 231 { USB_DEVICE(0x03F0, 0x1B1D) }, /* HP ev2200 a.k.a MC5720 */ 232 { USB_DEVICE(0x03F0, 0x1E1D) }, /* HP hs2300 a.k.a MC8775 */ ··· 304 }; 305 MODULE_DEVICE_TABLE(usb, id_table); 306 307 - static struct usb_driver sierra_driver = { 308 - .name = "sierra", 309 - .probe = usb_serial_probe, 310 - .disconnect = usb_serial_disconnect, 311 - .suspend = usb_serial_suspend, 312 - .resume = usb_serial_resume, 313 - .id_table = id_table, 314 - .no_dynamic_id = 1, 315 - .supports_autosuspend = 1, 316 - }; 317 318 struct sierra_port_private { 319 spinlock_t lock; /* lock the structure */ ··· 467 static int sierra_write(struct tty_struct *tty, struct usb_serial_port *port, 468 const unsigned char *buf, int count) 469 { 470 - struct sierra_port_private *portdata = usb_get_serial_port_data(port); 471 struct sierra_intf_private *intfdata; 472 struct usb_serial *serial = port->serial; 473 unsigned long flags; ··· 594 } else { 595 if (urb->actual_length) { 596 tty = tty_port_tty_get(&port->port); 597 598 - tty_buffer_request_room(tty, urb->actual_length); 599 - tty_insert_flip_string(tty, data, urb->actual_length); 600 - tty_flip_buffer_push(tty); 601 - 602 - tty_kref_put(tty); 603 - usb_serial_debug_data(debug, &port->dev, __func__, 604 - urb->actual_length, data); 605 } else { 606 dev_dbg(&port->dev, "%s: empty read urb" 607 " received\n", __func__); ··· 610 } 611 612 /* Resubmit urb so we continue receiving */ 613 - if (port->port.count && status != -ESHUTDOWN && status != -EPERM) { 614 usb_mark_last_busy(port->serial->dev); 615 err = usb_submit_urb(urb, GFP_ATOMIC); 616 - if (err) 617 dev_err(&port->dev, "resubmit read urb failed." 618 "(%d)\n", err); 619 } ··· 672 dev_dbg(&port->dev, "%s: error %d\n", __func__, status); 673 674 /* Resubmit urb so we continue receiving IRQ data */ 675 - if (port->port.count && status != -ESHUTDOWN && status != -ENOENT) { 676 usb_mark_last_busy(serial->dev); 677 urb->dev = serial->dev; 678 err = usb_submit_urb(urb, GFP_ATOMIC); 679 - if (err) 680 dev_err(&port->dev, "%s: resubmit intr urb " 681 "failed. (%d)\n", __func__, err); 682 } ··· 1052 1053 return ec ? -EIO : 0; 1054 } 1055 #else 1056 #define sierra_suspend NULL 1057 #define sierra_resume NULL 1058 #endif 1059 1060 static struct usb_serial_driver sierra_device = { 1061 .driver = {
··· 226 .ifaceinfo = direct_ip_non_serial_ifaces, 227 }; 228 229 + static const struct usb_device_id id_table[] = { 230 { USB_DEVICE(0x0F3D, 0x0112) }, /* Airprime/Sierra PC 5220 */ 231 { USB_DEVICE(0x03F0, 0x1B1D) }, /* HP ev2200 a.k.a MC5720 */ 232 { USB_DEVICE(0x03F0, 0x1E1D) }, /* HP hs2300 a.k.a MC8775 */ ··· 304 }; 305 MODULE_DEVICE_TABLE(usb, id_table); 306 307 308 struct sierra_port_private { 309 spinlock_t lock; /* lock the structure */ ··· 477 static int sierra_write(struct tty_struct *tty, struct usb_serial_port *port, 478 const unsigned char *buf, int count) 479 { 480 + struct sierra_port_private *portdata; 481 struct sierra_intf_private *intfdata; 482 struct usb_serial *serial = port->serial; 483 unsigned long flags; ··· 604 } else { 605 if (urb->actual_length) { 606 tty = tty_port_tty_get(&port->port); 607 + if (tty) { 608 + tty_insert_flip_string(tty, data, 609 + urb->actual_length); 610 + tty_flip_buffer_push(tty); 611 612 + tty_kref_put(tty); 613 + usb_serial_debug_data(debug, &port->dev, 614 + __func__, urb->actual_length, data); 615 + } 616 } else { 617 dev_dbg(&port->dev, "%s: empty read urb" 618 " received\n", __func__); ··· 619 } 620 621 /* Resubmit urb so we continue receiving */ 622 + if (status != -ESHUTDOWN && status != -EPERM) { 623 usb_mark_last_busy(port->serial->dev); 624 err = usb_submit_urb(urb, GFP_ATOMIC); 625 + if (err && err != -EPERM) 626 dev_err(&port->dev, "resubmit read urb failed." 627 "(%d)\n", err); 628 } ··· 681 dev_dbg(&port->dev, "%s: error %d\n", __func__, status); 682 683 /* Resubmit urb so we continue receiving IRQ data */ 684 + if (status != -ESHUTDOWN && status != -ENOENT) { 685 usb_mark_last_busy(serial->dev); 686 urb->dev = serial->dev; 687 err = usb_submit_urb(urb, GFP_ATOMIC); 688 + if (err && err != -EPERM) 689 dev_err(&port->dev, "%s: resubmit intr urb " 690 "failed. (%d)\n", __func__, err); 691 } ··· 1061 1062 return ec ? -EIO : 0; 1063 } 1064 + 1065 + static int sierra_reset_resume(struct usb_interface *intf) 1066 + { 1067 + struct usb_serial *serial = usb_get_intfdata(intf); 1068 + dev_err(&serial->dev->dev, "%s\n", __func__); 1069 + return usb_serial_resume(intf); 1070 + } 1071 #else 1072 #define sierra_suspend NULL 1073 #define sierra_resume NULL 1074 + #define sierra_reset_resume NULL 1075 #endif 1076 + 1077 + static struct usb_driver sierra_driver = { 1078 + .name = "sierra", 1079 + .probe = usb_serial_probe, 1080 + .disconnect = usb_serial_disconnect, 1081 + .suspend = usb_serial_suspend, 1082 + .resume = usb_serial_resume, 1083 + .reset_resume = sierra_reset_resume, 1084 + .id_table = id_table, 1085 + .no_dynamic_id = 1, 1086 + .supports_autosuspend = 1, 1087 + }; 1088 1089 static struct usb_serial_driver sierra_device = { 1090 .driver = {
+9 -18
drivers/usb/serial/spcp8x5.c
··· 45 #define SPCP8x5_835_VID 0x04fc 46 #define SPCP8x5_835_PID 0x0231 47 48 - static struct usb_device_id id_table [] = { 49 { USB_DEVICE(SPCP8x5_PHILIPS_VID , SPCP8x5_PHILIPS_PID)}, 50 { USB_DEVICE(SPCP8x5_INTERMATIC_VID, SPCP8x5_INTERMATIC_PID)}, 51 { USB_DEVICE(SPCP8x5_835_VID, SPCP8x5_835_PID)}, ··· 609 if (i < 0) 610 dev_err(&port->dev, "Set UART format %#x failed (error = %d)\n", 611 uartdata, i); 612 - dbg("0x21:0x40:0:0 %d\n", i); 613 614 if (cflag & CRTSCTS) { 615 /* enable hardware flow control */ ··· 677 struct tty_struct *tty; 678 unsigned char *data = urb->transfer_buffer; 679 unsigned long flags; 680 - int i; 681 int result = urb->status; 682 u8 status; 683 char tty_flag; ··· 686 687 /* check the urb status */ 688 if (result) { 689 - if (!port->port.count) 690 - return; 691 if (result == -EPROTO) { 692 /* spcp8x5 mysteriously fails with -EPROTO */ 693 /* reschedule the read */ ··· 723 724 tty = tty_port_tty_get(&port->port); 725 if (tty && urb->actual_length) { 726 - tty_buffer_request_room(tty, urb->actual_length + 1); 727 /* overrun is special, not associated with a char */ 728 if (status & UART_OVERRUN_ERROR) 729 tty_insert_flip_char(tty, 0, TTY_OVERRUN); 730 - for (i = 0; i < urb->actual_length; ++i) 731 - tty_insert_flip_char(tty, data[i], tty_flag); 732 tty_flip_buffer_push(tty); 733 } 734 tty_kref_put(tty); 735 736 - /* Schedule the next read _if_ we are still open */ 737 - if (port->port.count) { 738 - urb->dev = port->serial->dev; 739 - result = usb_submit_urb(urb , GFP_ATOMIC); 740 - if (result) 741 - dev_dbg(&port->dev, "failed submitting read urb %d\n", 742 - result); 743 - } 744 - 745 - return; 746 } 747 748 /* get data from ring buffer and then write to usb bus */
··· 45 #define SPCP8x5_835_VID 0x04fc 46 #define SPCP8x5_835_PID 0x0231 47 48 + static const struct usb_device_id id_table[] = { 49 { USB_DEVICE(SPCP8x5_PHILIPS_VID , SPCP8x5_PHILIPS_PID)}, 50 { USB_DEVICE(SPCP8x5_INTERMATIC_VID, SPCP8x5_INTERMATIC_PID)}, 51 { USB_DEVICE(SPCP8x5_835_VID, SPCP8x5_835_PID)}, ··· 609 if (i < 0) 610 dev_err(&port->dev, "Set UART format %#x failed (error = %d)\n", 611 uartdata, i); 612 + dbg("0x21:0x40:0:0 %d", i); 613 614 if (cflag & CRTSCTS) { 615 /* enable hardware flow control */ ··· 677 struct tty_struct *tty; 678 unsigned char *data = urb->transfer_buffer; 679 unsigned long flags; 680 int result = urb->status; 681 u8 status; 682 char tty_flag; ··· 687 688 /* check the urb status */ 689 if (result) { 690 if (result == -EPROTO) { 691 /* spcp8x5 mysteriously fails with -EPROTO */ 692 /* reschedule the read */ ··· 726 727 tty = tty_port_tty_get(&port->port); 728 if (tty && urb->actual_length) { 729 /* overrun is special, not associated with a char */ 730 if (status & UART_OVERRUN_ERROR) 731 tty_insert_flip_char(tty, 0, TTY_OVERRUN); 732 + tty_insert_flip_string_fixed_flag(tty, data, 733 + urb->actual_length, tty_flag); 734 tty_flip_buffer_push(tty); 735 } 736 tty_kref_put(tty); 737 738 + /* Schedule the next read */ 739 + urb->dev = port->serial->dev; 740 + result = usb_submit_urb(urb , GFP_ATOMIC); 741 + if (result) 742 + dev_dbg(&port->dev, "failed submitting read urb %d\n", result); 743 } 744 745 /* get data from ring buffer and then write to usb bus */
+3 -9
drivers/usb/serial/symbolserial.c
··· 21 22 static int debug; 23 24 - static struct usb_device_id id_table[] = { 25 { USB_DEVICE(0x05e0, 0x0600) }, 26 { }, 27 }; ··· 51 int status = urb->status; 52 struct tty_struct *tty; 53 int result; 54 - int available_room = 0; 55 int data_length; 56 57 dbg("%s - port %d", __func__, port->number); ··· 88 */ 89 tty = tty_port_tty_get(&port->port); 90 if (tty) { 91 - available_room = tty_buffer_request_room(tty, 92 - data_length); 93 - if (available_room) { 94 - tty_insert_flip_string(tty, &data[1], 95 - available_room); 96 - tty_flip_buffer_push(tty); 97 - } 98 tty_kref_put(tty); 99 } 100 } else {
··· 21 22 static int debug; 23 24 + static const struct usb_device_id id_table[] = { 25 { USB_DEVICE(0x05e0, 0x0600) }, 26 { }, 27 }; ··· 51 int status = urb->status; 52 struct tty_struct *tty; 53 int result; 54 int data_length; 55 56 dbg("%s - port %d", __func__, port->number); ··· 89 */ 90 tty = tty_port_tty_get(&port->port); 91 if (tty) { 92 + tty_insert_flip_string(tty, &data[1], data_length); 93 + tty_flip_buffer_push(tty); 94 tty_kref_put(tty); 95 } 96 } else {
+1 -2
drivers/usb/serial/ti_usb_3410_5052.c
··· 1271 int cnt; 1272 1273 do { 1274 - cnt = tty_buffer_request_room(tty, length); 1275 if (cnt < length) { 1276 dev_err(dev, "%s - dropping data, %d bytes lost\n", 1277 __func__, length - cnt); 1278 if (cnt == 0) 1279 break; 1280 } 1281 - tty_insert_flip_string(tty, data, cnt); 1282 tty_flip_buffer_push(tty); 1283 data += cnt; 1284 length -= cnt;
··· 1271 int cnt; 1272 1273 do { 1274 + cnt = tty_insert_flip_string(tty, data, length); 1275 if (cnt < length) { 1276 dev_err(dev, "%s - dropping data, %d bytes lost\n", 1277 __func__, length - cnt); 1278 if (cnt == 0) 1279 break; 1280 } 1281 tty_flip_buffer_push(tty); 1282 data += cnt; 1283 length -= cnt;
+1 -14
drivers/usb/serial/usb-serial.c
··· 358 359 dbg("%s - port %d, %d byte(s)", __func__, port->number, count); 360 361 - /* count is managed under the mutex lock for the tty so cannot 362 - drop to zero until after the last close completes */ 363 - WARN_ON(!port->port.count); 364 - 365 /* pass on to the driver specific version of this function */ 366 retval = port->serial->type->write(tty, port, buf, count); 367 ··· 369 { 370 struct usb_serial_port *port = tty->driver_data; 371 dbg("%s - port %d", __func__, port->number); 372 - WARN_ON(!port->port.count); 373 /* pass on to the driver specific version of this function */ 374 return port->serial->type->write_room(tty); 375 } ··· 376 static int serial_chars_in_buffer(struct tty_struct *tty) 377 { 378 struct usb_serial_port *port = tty->driver_data; 379 - dbg("%s = port %d", __func__, port->number); 380 381 /* if the device was unplugged then any remaining characters 382 fell out of the connector ;) */ ··· 391 struct usb_serial_port *port = tty->driver_data; 392 dbg("%s - port %d", __func__, port->number); 393 394 - WARN_ON(!port->port.count); 395 /* pass on to the driver specific version of this function */ 396 if (port->serial->type->throttle) 397 port->serial->type->throttle(tty); ··· 401 struct usb_serial_port *port = tty->driver_data; 402 dbg("%s - port %d", __func__, port->number); 403 404 - WARN_ON(!port->port.count); 405 /* pass on to the driver specific version of this function */ 406 if (port->serial->type->unthrottle) 407 port->serial->type->unthrottle(tty); ··· 413 int retval = -ENODEV; 414 415 dbg("%s - port %d, cmd 0x%.4x", __func__, port->number, cmd); 416 - 417 - WARN_ON(!port->port.count); 418 419 /* pass on to the driver specific version of this function 420 if it is available */ ··· 428 struct usb_serial_port *port = tty->driver_data; 429 dbg("%s - port %d", __func__, port->number); 430 431 - WARN_ON(!port->port.count); 432 /* pass on to the driver specific version of this function 433 if it is available */ 434 if (port->serial->type->set_termios) ··· 442 443 dbg("%s - port %d", __func__, port->number); 444 445 - WARN_ON(!port->port.count); 446 /* pass on to the driver specific version of this function 447 if it is available */ 448 if (port->serial->type->break_ctl) ··· 502 503 dbg("%s - port %d", __func__, port->number); 504 505 - WARN_ON(!port->port.count); 506 if (port->serial->type->tiocmget) 507 return port->serial->type->tiocmget(tty, file); 508 return -EINVAL; ··· 514 515 dbg("%s - port %d", __func__, port->number); 516 517 - WARN_ON(!port->port.count); 518 if (port->serial->type->tiocmset) 519 return port->serial->type->tiocmset(tty, file, set, clear); 520 return -EINVAL;
··· 358 359 dbg("%s - port %d, %d byte(s)", __func__, port->number, count); 360 361 /* pass on to the driver specific version of this function */ 362 retval = port->serial->type->write(tty, port, buf, count); 363 ··· 373 { 374 struct usb_serial_port *port = tty->driver_data; 375 dbg("%s - port %d", __func__, port->number); 376 /* pass on to the driver specific version of this function */ 377 return port->serial->type->write_room(tty); 378 } ··· 381 static int serial_chars_in_buffer(struct tty_struct *tty) 382 { 383 struct usb_serial_port *port = tty->driver_data; 384 + dbg("%s - port %d", __func__, port->number); 385 386 /* if the device was unplugged then any remaining characters 387 fell out of the connector ;) */ ··· 396 struct usb_serial_port *port = tty->driver_data; 397 dbg("%s - port %d", __func__, port->number); 398 399 /* pass on to the driver specific version of this function */ 400 if (port->serial->type->throttle) 401 port->serial->type->throttle(tty); ··· 407 struct usb_serial_port *port = tty->driver_data; 408 dbg("%s - port %d", __func__, port->number); 409 410 /* pass on to the driver specific version of this function */ 411 if (port->serial->type->unthrottle) 412 port->serial->type->unthrottle(tty); ··· 420 int retval = -ENODEV; 421 422 dbg("%s - port %d, cmd 0x%.4x", __func__, port->number, cmd); 423 424 /* pass on to the driver specific version of this function 425 if it is available */ ··· 437 struct usb_serial_port *port = tty->driver_data; 438 dbg("%s - port %d", __func__, port->number); 439 440 /* pass on to the driver specific version of this function 441 if it is available */ 442 if (port->serial->type->set_termios) ··· 452 453 dbg("%s - port %d", __func__, port->number); 454 455 /* pass on to the driver specific version of this function 456 if it is available */ 457 if (port->serial->type->break_ctl) ··· 513 514 dbg("%s - port %d", __func__, port->number); 515 516 if (port->serial->type->tiocmget) 517 return port->serial->type->tiocmget(tty, file); 518 return -EINVAL; ··· 526 527 dbg("%s - port %d", __func__, port->number); 528 529 if (port->serial->type->tiocmset) 530 return port->serial->type->tiocmset(tty, file, set, clear); 531 return -EINVAL;
+1 -1
drivers/usb/serial/usb_debug.c
··· 29 0xff, 30 }; 31 32 - static struct usb_device_id id_table [] = { 33 { USB_DEVICE(0x0525, 0x127a) }, 34 { }, 35 };
··· 29 0xff, 30 }; 31 32 + static const struct usb_device_id id_table[] = { 33 { USB_DEVICE(0x0525, 0x127a) }, 34 { }, 35 };
+23 -17
drivers/usb/serial/visor.c
··· 368 spin_lock_irqsave(&priv->lock, flags); 369 if (priv->outstanding_urbs > URB_UPPER_LIMIT) { 370 spin_unlock_irqrestore(&priv->lock, flags); 371 - dbg("%s - write limit hit\n", __func__); 372 return 0; 373 } 374 priv->outstanding_urbs++; ··· 446 spin_lock_irqsave(&priv->lock, flags); 447 if (priv->outstanding_urbs > URB_UPPER_LIMIT * 2 / 3) { 448 spin_unlock_irqrestore(&priv->lock, flags); 449 - dbg("%s - write limit hit\n", __func__); 450 return 0; 451 } 452 spin_unlock_irqrestore(&priv->lock, flags); ··· 503 if (urb->actual_length) { 504 tty = tty_port_tty_get(&port->port); 505 if (tty) { 506 - available_room = tty_buffer_request_room(tty, 507 - urb->actual_length); 508 - if (available_room) { 509 - tty_insert_flip_string(tty, data, 510 - available_room); 511 - tty_flip_buffer_push(tty); 512 - } 513 tty_kref_put(tty); 514 } 515 spin_lock(&priv->lock); ··· 803 { 804 struct device *dev = &serial->dev->dev; 805 int result; 806 - u8 data; 807 808 dbg("%s", __func__); 809 810 /* 811 * Note that PEG-300 series devices expect the following two calls. ··· 818 /* get the config number */ 819 result = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), 820 USB_REQ_GET_CONFIGURATION, USB_DIR_IN, 821 - 0, 0, &data, 1, 3000); 822 if (result < 0) { 823 dev_err(dev, "%s: get config number failed: %d\n", 824 __func__, result); 825 - return result; 826 } 827 if (result != 1) { 828 dev_err(dev, "%s: get config number bad return length: %d\n", 829 __func__, result); 830 - return -EIO; 831 } 832 833 /* get the interface number */ 834 result = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), 835 USB_REQ_GET_INTERFACE, 836 USB_DIR_IN | USB_RECIP_INTERFACE, 837 - 0, 0, &data, 1, 3000); 838 if (result < 0) { 839 dev_err(dev, "%s: get interface number failed: %d\n", 840 __func__, result); 841 - return result; 842 } 843 if (result != 1) { 844 dev_err(dev, 845 "%s: get interface number bad return length: %d\n", 846 __func__, result); 847 - return -EIO; 848 } 849 850 - return generic_startup(serial); 851 } 852 853 static int treo_attach(struct usb_serial *serial)
··· 368 spin_lock_irqsave(&priv->lock, flags); 369 if (priv->outstanding_urbs > URB_UPPER_LIMIT) { 370 spin_unlock_irqrestore(&priv->lock, flags); 371 + dbg("%s - write limit hit", __func__); 372 return 0; 373 } 374 priv->outstanding_urbs++; ··· 446 spin_lock_irqsave(&priv->lock, flags); 447 if (priv->outstanding_urbs > URB_UPPER_LIMIT * 2 / 3) { 448 spin_unlock_irqrestore(&priv->lock, flags); 449 + dbg("%s - write limit hit", __func__); 450 return 0; 451 } 452 spin_unlock_irqrestore(&priv->lock, flags); ··· 503 if (urb->actual_length) { 504 tty = tty_port_tty_get(&port->port); 505 if (tty) { 506 + tty_insert_flip_string(tty, data, 507 + urb->actual_length); 508 + tty_flip_buffer_push(tty); 509 tty_kref_put(tty); 510 } 511 spin_lock(&priv->lock); ··· 807 { 808 struct device *dev = &serial->dev->dev; 809 int result; 810 + u8 *data; 811 812 dbg("%s", __func__); 813 + 814 + data = kmalloc(1, GFP_KERNEL); 815 + if (!data) 816 + return -ENOMEM; 817 818 /* 819 * Note that PEG-300 series devices expect the following two calls. ··· 818 /* get the config number */ 819 result = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), 820 USB_REQ_GET_CONFIGURATION, USB_DIR_IN, 821 + 0, 0, data, 1, 3000); 822 if (result < 0) { 823 dev_err(dev, "%s: get config number failed: %d\n", 824 __func__, result); 825 + goto out; 826 } 827 if (result != 1) { 828 dev_err(dev, "%s: get config number bad return length: %d\n", 829 __func__, result); 830 + result = -EIO; 831 + goto out; 832 } 833 834 /* get the interface number */ 835 result = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), 836 USB_REQ_GET_INTERFACE, 837 USB_DIR_IN | USB_RECIP_INTERFACE, 838 + 0, 0, data, 1, 3000); 839 if (result < 0) { 840 dev_err(dev, "%s: get interface number failed: %d\n", 841 __func__, result); 842 + goto out; 843 } 844 if (result != 1) { 845 dev_err(dev, 846 "%s: get interface number bad return length: %d\n", 847 __func__, result); 848 + result = -EIO; 849 + goto out; 850 } 851 852 + result = generic_startup(serial); 853 + out: 854 + kfree(data); 855 + 856 + return result; 857 } 858 859 static int treo_attach(struct usb_serial *serial)
+76
drivers/usb/serial/vivopay-serial.c
···
··· 1 + /* 2 + * Copyright (C) 2001-2005 Greg Kroah-Hartman (greg@kroah.com) 3 + * Copyright (C) 2009 Outpost Embedded, LLC 4 + */ 5 + 6 + #include <linux/kernel.h> 7 + #include <linux/init.h> 8 + #include <linux/tty.h> 9 + #include <linux/module.h> 10 + #include <linux/usb.h> 11 + #include <linux/usb/serial.h> 12 + 13 + 14 + #define DRIVER_VERSION "v1.0" 15 + #define DRIVER_DESC "ViVOpay USB Serial Driver" 16 + 17 + #define VIVOPAY_VENDOR_ID 0x1d5f 18 + 19 + 20 + static struct usb_device_id id_table [] = { 21 + /* ViVOpay 8800 */ 22 + { USB_DEVICE(VIVOPAY_VENDOR_ID, 0x1004) }, 23 + { }, 24 + }; 25 + 26 + MODULE_DEVICE_TABLE(usb, id_table); 27 + 28 + static struct usb_driver vivopay_serial_driver = { 29 + .name = "vivopay-serial", 30 + .probe = usb_serial_probe, 31 + .disconnect = usb_serial_disconnect, 32 + .id_table = id_table, 33 + .no_dynamic_id = 1, 34 + }; 35 + 36 + static struct usb_serial_driver vivopay_serial_device = { 37 + .driver = { 38 + .owner = THIS_MODULE, 39 + .name = "vivopay-serial", 40 + }, 41 + .id_table = id_table, 42 + .usb_driver = &vivopay_serial_driver, 43 + .num_ports = 1, 44 + }; 45 + 46 + static int __init vivopay_serial_init(void) 47 + { 48 + int retval; 49 + retval = usb_serial_register(&vivopay_serial_device); 50 + if (retval) 51 + goto failed_usb_serial_register; 52 + retval = usb_register(&vivopay_serial_driver); 53 + if (retval) 54 + goto failed_usb_register; 55 + printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" 56 + DRIVER_DESC "\n"); 57 + return 0; 58 + failed_usb_register: 59 + usb_serial_deregister(&vivopay_serial_device); 60 + failed_usb_serial_register: 61 + return retval; 62 + } 63 + 64 + static void __exit vivopay_serial_exit(void) 65 + { 66 + usb_deregister(&vivopay_serial_driver); 67 + usb_serial_deregister(&vivopay_serial_device); 68 + } 69 + 70 + module_init(vivopay_serial_init); 71 + module_exit(vivopay_serial_exit); 72 + 73 + MODULE_AUTHOR("Forest Bond <forest.bond@outpostembedded.com>"); 74 + MODULE_DESCRIPTION(DRIVER_DESC); 75 + MODULE_VERSION(DRIVER_VERSION); 76 + MODULE_LICENSE("GPL");
+6 -18
drivers/usb/serial/whiteheat.c
··· 111 separate ID tables, and then a third table that combines them 112 just for the purpose of exporting the autoloading information. 113 */ 114 - static struct usb_device_id id_table_std [] = { 115 { USB_DEVICE(CONNECT_TECH_VENDOR_ID, CONNECT_TECH_WHITE_HEAT_ID) }, 116 { } /* Terminating entry */ 117 }; 118 119 - static struct usb_device_id id_table_prerenumeration [] = { 120 { USB_DEVICE(CONNECT_TECH_VENDOR_ID, CONNECT_TECH_FAKE_WHITE_HEAT_ID) }, 121 { } /* Terminating entry */ 122 }; 123 124 - static struct usb_device_id id_table_combined [] = { 125 { USB_DEVICE(CONNECT_TECH_VENDOR_ID, CONNECT_TECH_WHITE_HEAT_ID) }, 126 { USB_DEVICE(CONNECT_TECH_VENDOR_ID, CONNECT_TECH_FAKE_WHITE_HEAT_ID) }, 127 { } /* Terminating entry */ ··· 1492 wrap = list_entry(tmp, struct whiteheat_urb_wrap, list); 1493 urb = wrap->urb; 1494 1495 - if (tty && urb->actual_length) { 1496 - int len = tty_buffer_request_room(tty, 1497 - urb->actual_length); 1498 - /* This stuff can go away now I suspect */ 1499 - if (unlikely(len < urb->actual_length)) { 1500 - spin_lock_irqsave(&info->lock, flags); 1501 - list_add(tmp, &info->rx_urb_q); 1502 - spin_unlock_irqrestore(&info->lock, flags); 1503 - tty_flip_buffer_push(tty); 1504 - schedule_work(&info->rx_work); 1505 - goto out; 1506 - } 1507 - tty_insert_flip_string(tty, urb->transfer_buffer, len); 1508 - sent += len; 1509 - } 1510 1511 urb->dev = port->serial->dev; 1512 result = usb_submit_urb(urb, GFP_ATOMIC);
··· 111 separate ID tables, and then a third table that combines them 112 just for the purpose of exporting the autoloading information. 113 */ 114 + static const struct usb_device_id id_table_std[] = { 115 { USB_DEVICE(CONNECT_TECH_VENDOR_ID, CONNECT_TECH_WHITE_HEAT_ID) }, 116 { } /* Terminating entry */ 117 }; 118 119 + static const struct usb_device_id id_table_prerenumeration[] = { 120 { USB_DEVICE(CONNECT_TECH_VENDOR_ID, CONNECT_TECH_FAKE_WHITE_HEAT_ID) }, 121 { } /* Terminating entry */ 122 }; 123 124 + static const struct usb_device_id id_table_combined[] = { 125 { USB_DEVICE(CONNECT_TECH_VENDOR_ID, CONNECT_TECH_WHITE_HEAT_ID) }, 126 { USB_DEVICE(CONNECT_TECH_VENDOR_ID, CONNECT_TECH_FAKE_WHITE_HEAT_ID) }, 127 { } /* Terminating entry */ ··· 1492 wrap = list_entry(tmp, struct whiteheat_urb_wrap, list); 1493 urb = wrap->urb; 1494 1495 + if (tty && urb->actual_length) 1496 + sent += tty_insert_flip_string(tty, 1497 + urb->transfer_buffer, urb->actual_length); 1498 1499 urb->dev = port->serial->dev; 1500 result = usb_submit_urb(urb, GFP_ATOMIC);
+1 -1
drivers/usb/storage/onetouch.c
··· 202 goto fail1; 203 204 onetouch->data = usb_buffer_alloc(udev, ONETOUCH_PKT_LEN, 205 - GFP_ATOMIC, &onetouch->data_dma); 206 if (!onetouch->data) 207 goto fail1; 208
··· 202 goto fail1; 203 204 onetouch->data = usb_buffer_alloc(udev, ONETOUCH_PKT_LEN, 205 + GFP_KERNEL, &onetouch->data_dma); 206 if (!onetouch->data) 207 goto fail1; 208
+5 -5
drivers/usb/storage/scsiglue.c
··· 133 134 if (us->fflags & US_FL_MAX_SECTORS_MIN) 135 max_sectors = PAGE_CACHE_SIZE >> 9; 136 - if (queue_max_sectors(sdev->request_queue) > max_sectors) 137 blk_queue_max_hw_sectors(sdev->request_queue, 138 max_sectors); 139 } else if (sdev->type == TYPE_TAPE) { ··· 484 { 485 struct scsi_device *sdev = to_scsi_device(dev); 486 487 - return sprintf(buf, "%u\n", queue_max_sectors(sdev->request_queue)); 488 } 489 490 /* Input routine for the sysfs max_sectors file */ ··· 494 struct scsi_device *sdev = to_scsi_device(dev); 495 unsigned short ms; 496 497 - if (sscanf(buf, "%hu", &ms) > 0 && ms <= SCSI_DEFAULT_MAX_SECTORS) { 498 blk_queue_max_hw_sectors(sdev->request_queue, ms); 499 - return strlen(buf); 500 } 501 return -EINVAL; 502 } ··· 539 .slave_configure = slave_configure, 540 541 /* lots of sg segments can be handled */ 542 - .sg_tablesize = SG_ALL, 543 544 /* limit the total size of a transfer to 120 KB */ 545 .max_sectors = 240,
··· 133 134 if (us->fflags & US_FL_MAX_SECTORS_MIN) 135 max_sectors = PAGE_CACHE_SIZE >> 9; 136 + if (queue_max_hw_sectors(sdev->request_queue) > max_sectors) 137 blk_queue_max_hw_sectors(sdev->request_queue, 138 max_sectors); 139 } else if (sdev->type == TYPE_TAPE) { ··· 484 { 485 struct scsi_device *sdev = to_scsi_device(dev); 486 487 + return sprintf(buf, "%u\n", queue_max_hw_sectors(sdev->request_queue)); 488 } 489 490 /* Input routine for the sysfs max_sectors file */ ··· 494 struct scsi_device *sdev = to_scsi_device(dev); 495 unsigned short ms; 496 497 + if (sscanf(buf, "%hu", &ms) > 0) { 498 blk_queue_max_hw_sectors(sdev->request_queue, ms); 499 + return count; 500 } 501 return -EINVAL; 502 } ··· 539 .slave_configure = slave_configure, 540 541 /* lots of sg segments can be handled */ 542 + .sg_tablesize = SCSI_MAX_SG_CHAIN_SEGMENTS, 543 544 /* limit the total size of a transfer to 120 KB */ 545 .max_sectors = 240,
+7 -8
drivers/usb/storage/shuttle_usbat.c
··· 1628 return USB_STOR_TRANSPORT_ERROR; 1629 } 1630 1631 - if ( (result = usbat_multiple_write(us, 1632 - registers, data, 7)) != USB_STOR_TRANSPORT_GOOD) { 1633 return result; 1634 - } 1635 1636 /* 1637 * Write the 12-byte command header. ··· 1643 * AT SPEED 4 IS UNRELIABLE!!! 1644 */ 1645 1646 - if ((result = usbat_write_block(us, 1647 - USBAT_ATA, srb->cmnd, 12, 1648 - (srb->cmnd[0]==GPCMD_BLANK ? 75 : 10), 0) != 1649 - USB_STOR_TRANSPORT_GOOD)) { 1650 return result; 1651 - } 1652 1653 /* If there is response data to be read in then do it here. */ 1654
··· 1628 return USB_STOR_TRANSPORT_ERROR; 1629 } 1630 1631 + result = usbat_multiple_write(us, registers, data, 7); 1632 + 1633 + if (result != USB_STOR_TRANSPORT_GOOD) 1634 return result; 1635 1636 /* 1637 * Write the 12-byte command header. ··· 1643 * AT SPEED 4 IS UNRELIABLE!!! 1644 */ 1645 1646 + result = usbat_write_block(us, USBAT_ATA, srb->cmnd, 12, 1647 + srb->cmnd[0] == GPCMD_BLANK ? 75 : 10, 0); 1648 + 1649 + if (result != USB_STOR_TRANSPORT_GOOD) 1650 return result; 1651 1652 /* If there is response data to be read in then do it here. */ 1653
+6
drivers/usb/storage/transport.c
··· 47 #include <linux/errno.h> 48 #include <linux/slab.h> 49 50 #include <scsi/scsi.h> 51 #include <scsi/scsi_eh.h> 52 #include <scsi/scsi_device.h> ··· 1298 int usb_stor_port_reset(struct us_data *us) 1299 { 1300 int result; 1301 1302 result = usb_lock_device_for_reset(us->pusb_dev, us->pusb_intf); 1303 if (result < 0)
··· 47 #include <linux/errno.h> 48 #include <linux/slab.h> 49 50 + #include <linux/usb/quirks.h> 51 + 52 #include <scsi/scsi.h> 53 #include <scsi/scsi_eh.h> 54 #include <scsi/scsi_device.h> ··· 1296 int usb_stor_port_reset(struct us_data *us) 1297 { 1298 int result; 1299 + 1300 + /*for these devices we must use the class specific method */ 1301 + if (us->pusb_dev->quirks & USB_QUIRK_RESET_MORPHS) 1302 + return -EPERM; 1303 1304 result = usb_lock_device_for_reset(us->pusb_dev, us->pusb_intf); 1305 if (result < 0)
+86 -2
drivers/usb/storage/unusual_devs.h
··· 1147 0 ), 1148 1149 /* Reported by Jan Dumon <j.dumon@option.com> 1150 - * This device (wrongly) has a vendor-specific device descriptor. 1151 - * The entry is needed so usb-storage can bind to it's mass-storage 1152 * interface as an interface driver */ 1153 UNUSUAL_DEV( 0x0af0, 0x7501, 0x0000, 0x0000, 1154 "Option", 1155 "GI 0431 SD-Card", 1156 US_SC_DEVICE, US_PR_DEVICE, NULL, 1157 0 ), 1158
··· 1147 0 ), 1148 1149 /* Reported by Jan Dumon <j.dumon@option.com> 1150 + * These devices (wrongly) have a vendor-specific device descriptor. 1151 + * These entries are needed so usb-storage can bind to their mass-storage 1152 * interface as an interface driver */ 1153 UNUSUAL_DEV( 0x0af0, 0x7501, 0x0000, 0x0000, 1154 "Option", 1155 "GI 0431 SD-Card", 1156 + US_SC_DEVICE, US_PR_DEVICE, NULL, 1157 + 0 ), 1158 + 1159 + UNUSUAL_DEV( 0x0af0, 0x7701, 0x0000, 0x0000, 1160 + "Option", 1161 + "GI 0451 SD-Card", 1162 + US_SC_DEVICE, US_PR_DEVICE, NULL, 1163 + 0 ), 1164 + 1165 + UNUSUAL_DEV( 0x0af0, 0x7706, 0x0000, 0x0000, 1166 + "Option", 1167 + "GI 0451 SD-Card", 1168 + US_SC_DEVICE, US_PR_DEVICE, NULL, 1169 + 0 ), 1170 + 1171 + UNUSUAL_DEV( 0x0af0, 0x7901, 0x0000, 0x0000, 1172 + "Option", 1173 + "GI 0452 SD-Card", 1174 + US_SC_DEVICE, US_PR_DEVICE, NULL, 1175 + 0 ), 1176 + 1177 + UNUSUAL_DEV( 0x0af0, 0x7A01, 0x0000, 0x0000, 1178 + "Option", 1179 + "GI 0461 SD-Card", 1180 + US_SC_DEVICE, US_PR_DEVICE, NULL, 1181 + 0 ), 1182 + 1183 + UNUSUAL_DEV( 0x0af0, 0x7A05, 0x0000, 0x0000, 1184 + "Option", 1185 + "GI 0461 SD-Card", 1186 + US_SC_DEVICE, US_PR_DEVICE, NULL, 1187 + 0 ), 1188 + 1189 + UNUSUAL_DEV( 0x0af0, 0x8300, 0x0000, 0x0000, 1190 + "Option", 1191 + "GI 033x SD-Card", 1192 + US_SC_DEVICE, US_PR_DEVICE, NULL, 1193 + 0 ), 1194 + 1195 + UNUSUAL_DEV( 0x0af0, 0x8302, 0x0000, 0x0000, 1196 + "Option", 1197 + "GI 033x SD-Card", 1198 + US_SC_DEVICE, US_PR_DEVICE, NULL, 1199 + 0 ), 1200 + 1201 + UNUSUAL_DEV( 0x0af0, 0x8304, 0x0000, 0x0000, 1202 + "Option", 1203 + "GI 033x SD-Card", 1204 + US_SC_DEVICE, US_PR_DEVICE, NULL, 1205 + 0 ), 1206 + 1207 + UNUSUAL_DEV( 0x0af0, 0xc100, 0x0000, 0x0000, 1208 + "Option", 1209 + "GI 070x SD-Card", 1210 + US_SC_DEVICE, US_PR_DEVICE, NULL, 1211 + 0 ), 1212 + 1213 + UNUSUAL_DEV( 0x0af0, 0xd057, 0x0000, 0x0000, 1214 + "Option", 1215 + "GI 1505 SD-Card", 1216 + US_SC_DEVICE, US_PR_DEVICE, NULL, 1217 + 0 ), 1218 + 1219 + UNUSUAL_DEV( 0x0af0, 0xd058, 0x0000, 0x0000, 1220 + "Option", 1221 + "GI 1509 SD-Card", 1222 + US_SC_DEVICE, US_PR_DEVICE, NULL, 1223 + 0 ), 1224 + 1225 + UNUSUAL_DEV( 0x0af0, 0xd157, 0x0000, 0x0000, 1226 + "Option", 1227 + "GI 1515 SD-Card", 1228 + US_SC_DEVICE, US_PR_DEVICE, NULL, 1229 + 0 ), 1230 + 1231 + UNUSUAL_DEV( 0x0af0, 0xd257, 0x0000, 0x0000, 1232 + "Option", 1233 + "GI 1215 SD-Card", 1234 + US_SC_DEVICE, US_PR_DEVICE, NULL, 1235 + 0 ), 1236 + 1237 + UNUSUAL_DEV( 0x0af0, 0xd357, 0x0000, 0x0000, 1238 + "Option", 1239 + "GI 1505 SD-Card", 1240 US_SC_DEVICE, US_PR_DEVICE, NULL, 1241 0 ), 1242
+1 -1
drivers/usb/usb-skeleton.c
··· 28 #define USB_SKEL_PRODUCT_ID 0xfff0 29 30 /* table of devices that work with this driver */ 31 - static struct usb_device_id skel_table[] = { 32 { USB_DEVICE(USB_SKEL_VENDOR_ID, USB_SKEL_PRODUCT_ID) }, 33 { } /* Terminating entry */ 34 };
··· 28 #define USB_SKEL_PRODUCT_ID 0xfff0 29 30 /* table of devices that work with this driver */ 31 + static const struct usb_device_id skel_table[] = { 32 { USB_DEVICE(USB_SKEL_VENDOR_ID, USB_SKEL_PRODUCT_ID) }, 33 { } /* Terminating entry */ 34 };
+1 -1
drivers/usb/wusbcore/cbaf.c
··· 641 kzfree(cbaf); 642 } 643 644 - static struct usb_device_id cbaf_id_table[] = { 645 { USB_INTERFACE_INFO(0xef, 0x03, 0x01), }, 646 { }, 647 };
··· 641 kzfree(cbaf); 642 } 643 644 + static const struct usb_device_id cbaf_id_table[] = { 645 { USB_INTERFACE_INFO(0xef, 0x03, 0x01), }, 646 { }, 647 };
+1 -1
drivers/usb/wusbcore/devconnect.c
··· 868 * reference that we'll drop. 869 * 870 * First we need to determine if the device is a WUSB device (else we 871 - * ignore it). For that we use the speed setting (USB_SPEED_VARIABLE) 872 * [FIXME: maybe we'd need something more definitive]. If so, we track 873 * it's usb_busd and from there, the WUSB HC. 874 *
··· 868 * reference that we'll drop. 869 * 870 * First we need to determine if the device is a WUSB device (else we 871 + * ignore it). For that we use the speed setting (USB_SPEED_WIRELESS) 872 * [FIXME: maybe we'd need something more definitive]. If so, we track 873 * it's usb_busd and from there, the WUSB HC. 874 *
+1 -1
drivers/usb/wusbcore/mmc.c
··· 263 { 264 int result = 0; 265 266 - if (memcmp(chid, &wusb_ckhdid_zero, sizeof(chid)) == 0) 267 chid = NULL; 268 269 mutex_lock(&wusbhc->mutex);
··· 263 { 264 int result = 0; 265 266 + if (memcmp(chid, &wusb_ckhdid_zero, sizeof(*chid)) == 0) 267 chid = NULL; 268 269 mutex_lock(&wusbhc->mutex);
+6 -1
include/linux/tty_flip.h
··· 2 #define _LINUX_TTY_FLIP_H 3 4 extern int tty_buffer_request_room(struct tty_struct *tty, size_t size); 5 - extern int tty_insert_flip_string(struct tty_struct *tty, const unsigned char *chars, size_t size); 6 extern int tty_insert_flip_string_flags(struct tty_struct *tty, const unsigned char *chars, const char *flags, size_t size); 7 extern int tty_prepare_flip_string(struct tty_struct *tty, unsigned char **chars, size_t size); 8 extern int tty_prepare_flip_string_flags(struct tty_struct *tty, unsigned char **chars, char **flags, size_t size); 9 void tty_schedule_flip(struct tty_struct *tty); ··· 18 return 1; 19 } 20 return tty_insert_flip_string_flags(tty, &ch, &flag, 1); 21 } 22 23 #endif /* _LINUX_TTY_FLIP_H */
··· 2 #define _LINUX_TTY_FLIP_H 3 4 extern int tty_buffer_request_room(struct tty_struct *tty, size_t size); 5 extern int tty_insert_flip_string_flags(struct tty_struct *tty, const unsigned char *chars, const char *flags, size_t size); 6 + extern int tty_insert_flip_string_fixed_flag(struct tty_struct *tty, const unsigned char *chars, char flag, size_t size); 7 extern int tty_prepare_flip_string(struct tty_struct *tty, unsigned char **chars, size_t size); 8 extern int tty_prepare_flip_string_flags(struct tty_struct *tty, unsigned char **chars, char **flags, size_t size); 9 void tty_schedule_flip(struct tty_struct *tty); ··· 18 return 1; 19 } 20 return tty_insert_flip_string_flags(tty, &ch, &flag, 1); 21 + } 22 + 23 + static inline int tty_insert_flip_string(struct tty_struct *tty, const unsigned char *chars, size_t size) 24 + { 25 + return tty_insert_flip_string_fixed_flag(tty, chars, TTY_NORMAL, size); 26 } 27 28 #endif /* _LINUX_TTY_FLIP_H */
+20 -33
include/linux/usb.h
··· 122 * number from the USB core by calling usb_register_dev(). 123 * @condition: binding state of the interface: not bound, binding 124 * (in probe()), bound to a driver, or unbinding (in disconnect()) 125 - * @is_active: flag set when the interface is bound and not suspended. 126 * @sysfs_files_created: sysfs attributes exist 127 * @ep_devs_created: endpoint child pseudo-devices exist 128 * @unregistering: flag set when the interface is being unregistered ··· 134 * @dev: driver model's view of this device 135 * @usb_dev: if an interface is bound to the USB major, this will point 136 * to the sysfs representation for that device. 137 - * @pm_usage_cnt: PM usage counter for this interface; autosuspend is not 138 - * allowed unless the counter is 0. 139 * @reset_ws: Used for scheduling resets from atomic context. 140 * @reset_running: set to 1 if the interface is currently running a 141 * queued reset so that usb_cancel_queued_reset() doesn't try to ··· 182 int minor; /* minor number this interface is 183 * bound to */ 184 enum usb_interface_condition condition; /* state of binding */ 185 - unsigned is_active:1; /* the interface is not suspended */ 186 unsigned sysfs_files_created:1; /* the sysfs attributes exist */ 187 unsigned ep_devs_created:1; /* endpoint "devices" exist */ 188 unsigned unregistering:1; /* unregistration is in progress */ ··· 398 * @portnum: parent port number (origin 1) 399 * @level: number of USB hub ancestors 400 * @can_submit: URBs may be submitted 401 - * @discon_suspended: disconnected while suspended 402 * @persist_enabled: USB_PERSIST enabled for this device 403 * @have_langid: whether string_langid is valid 404 * @authorized: policy has said we can use it; ··· 417 * @usbfs_dentry: usbfs dentry entry for the device 418 * @maxchild: number of ports if hub 419 * @children: child devices - USB devices that are attached to this hub 420 - * @pm_usage_cnt: usage counter for autosuspend 421 * @quirks: quirks of the whole device 422 * @urbnum: number of URBs submitted for the whole device 423 * @active_duration: total time device is not suspended 424 - * @autosuspend: for delayed autosuspends 425 - * @autoresume: for autoresumes requested while in_interrupt 426 - * @pm_mutex: protects PM operations 427 * @last_busy: time of last use 428 * @autosuspend_delay: in jiffies 429 * @connect_time: time device was first connected 430 * @do_remote_wakeup: remote wakeup should be enabled 431 * @reset_resume: needs reset instead of resume 432 * @autosuspend_disabled: autosuspend disabled by the user 433 - * @skip_sys_resume: skip the next system resume 434 * @wusb_dev: if this is a Wireless USB device, link to the WUSB 435 * specific data for the device. 436 * @slot_id: Slot ID assigned by xHCI ··· 466 u8 level; 467 468 unsigned can_submit:1; 469 - unsigned discon_suspended:1; 470 unsigned persist_enabled:1; 471 unsigned have_langid:1; 472 unsigned authorized:1; ··· 489 int maxchild; 490 struct usb_device *children[USB_MAXCHILDREN]; 491 492 - int pm_usage_cnt; 493 u32 quirks; 494 atomic_t urbnum; 495 496 unsigned long active_duration; 497 498 #ifdef CONFIG_PM 499 - struct delayed_work autosuspend; 500 - struct work_struct autoresume; 501 - struct mutex pm_mutex; 502 - 503 unsigned long last_busy; 504 int autosuspend_delay; 505 unsigned long connect_time; ··· 502 unsigned do_remote_wakeup:1; 503 unsigned reset_resume:1; 504 unsigned autosuspend_disabled:1; 505 - unsigned skip_sys_resume:1; 506 #endif 507 struct wusb_dev *wusb_dev; 508 int slot_id; ··· 526 527 /* USB autosuspend and autoresume */ 528 #ifdef CONFIG_USB_SUSPEND 529 extern int usb_autopm_get_interface(struct usb_interface *intf); 530 extern void usb_autopm_put_interface(struct usb_interface *intf); 531 extern int usb_autopm_get_interface_async(struct usb_interface *intf); 532 extern void usb_autopm_put_interface_async(struct usb_interface *intf); 533 - 534 - static inline void usb_autopm_get_interface_no_resume( 535 - struct usb_interface *intf) 536 - { 537 - atomic_inc(&intf->pm_usage_cnt); 538 - } 539 - static inline void usb_autopm_put_interface_no_suspend( 540 - struct usb_interface *intf) 541 - { 542 - atomic_dec(&intf->pm_usage_cnt); 543 - } 544 545 static inline void usb_mark_last_busy(struct usb_device *udev) 546 { ··· 542 } 543 544 #else 545 546 static inline int usb_autopm_get_interface(struct usb_interface *intf) 547 { return 0; } ··· 1566 extern void usb_unregister_notify(struct notifier_block *nb); 1567 1568 #ifdef DEBUG 1569 - #define dbg(format, arg...) printk(KERN_DEBUG "%s: " format "\n" , \ 1570 - __FILE__ , ## arg) 1571 #else 1572 - #define dbg(format, arg...) do {} while (0) 1573 #endif 1574 1575 - #define err(format, arg...) printk(KERN_ERR KBUILD_MODNAME ": " \ 1576 - format "\n" , ## arg) 1577 1578 /* debugfs stuff */ 1579 extern struct dentry *usb_debug_root;
··· 122 * number from the USB core by calling usb_register_dev(). 123 * @condition: binding state of the interface: not bound, binding 124 * (in probe()), bound to a driver, or unbinding (in disconnect()) 125 * @sysfs_files_created: sysfs attributes exist 126 * @ep_devs_created: endpoint child pseudo-devices exist 127 * @unregistering: flag set when the interface is being unregistered ··· 135 * @dev: driver model's view of this device 136 * @usb_dev: if an interface is bound to the USB major, this will point 137 * to the sysfs representation for that device. 138 + * @pm_usage_cnt: PM usage counter for this interface 139 * @reset_ws: Used for scheduling resets from atomic context. 140 * @reset_running: set to 1 if the interface is currently running a 141 * queued reset so that usb_cancel_queued_reset() doesn't try to ··· 184 int minor; /* minor number this interface is 185 * bound to */ 186 enum usb_interface_condition condition; /* state of binding */ 187 unsigned sysfs_files_created:1; /* the sysfs attributes exist */ 188 unsigned ep_devs_created:1; /* endpoint "devices" exist */ 189 unsigned unregistering:1; /* unregistration is in progress */ ··· 401 * @portnum: parent port number (origin 1) 402 * @level: number of USB hub ancestors 403 * @can_submit: URBs may be submitted 404 * @persist_enabled: USB_PERSIST enabled for this device 405 * @have_langid: whether string_langid is valid 406 * @authorized: policy has said we can use it; ··· 421 * @usbfs_dentry: usbfs dentry entry for the device 422 * @maxchild: number of ports if hub 423 * @children: child devices - USB devices that are attached to this hub 424 * @quirks: quirks of the whole device 425 * @urbnum: number of URBs submitted for the whole device 426 * @active_duration: total time device is not suspended 427 * @last_busy: time of last use 428 * @autosuspend_delay: in jiffies 429 * @connect_time: time device was first connected 430 * @do_remote_wakeup: remote wakeup should be enabled 431 * @reset_resume: needs reset instead of resume 432 * @autosuspend_disabled: autosuspend disabled by the user 433 * @wusb_dev: if this is a Wireless USB device, link to the WUSB 434 * specific data for the device. 435 * @slot_id: Slot ID assigned by xHCI ··· 475 u8 level; 476 477 unsigned can_submit:1; 478 unsigned persist_enabled:1; 479 unsigned have_langid:1; 480 unsigned authorized:1; ··· 499 int maxchild; 500 struct usb_device *children[USB_MAXCHILDREN]; 501 502 u32 quirks; 503 atomic_t urbnum; 504 505 unsigned long active_duration; 506 507 #ifdef CONFIG_PM 508 unsigned long last_busy; 509 int autosuspend_delay; 510 unsigned long connect_time; ··· 517 unsigned do_remote_wakeup:1; 518 unsigned reset_resume:1; 519 unsigned autosuspend_disabled:1; 520 #endif 521 struct wusb_dev *wusb_dev; 522 int slot_id; ··· 542 543 /* USB autosuspend and autoresume */ 544 #ifdef CONFIG_USB_SUSPEND 545 + extern int usb_enable_autosuspend(struct usb_device *udev); 546 + extern int usb_disable_autosuspend(struct usb_device *udev); 547 + 548 extern int usb_autopm_get_interface(struct usb_interface *intf); 549 extern void usb_autopm_put_interface(struct usb_interface *intf); 550 extern int usb_autopm_get_interface_async(struct usb_interface *intf); 551 extern void usb_autopm_put_interface_async(struct usb_interface *intf); 552 + extern void usb_autopm_get_interface_no_resume(struct usb_interface *intf); 553 + extern void usb_autopm_put_interface_no_suspend(struct usb_interface *intf); 554 555 static inline void usb_mark_last_busy(struct usb_device *udev) 556 { ··· 564 } 565 566 #else 567 + 568 + static inline int usb_enable_autosuspend(struct usb_device *udev) 569 + { return 0; } 570 + static inline int usb_disable_autosuspend(struct usb_device *udev) 571 + { return 0; } 572 573 static inline int usb_autopm_get_interface(struct usb_interface *intf) 574 { return 0; } ··· 1583 extern void usb_unregister_notify(struct notifier_block *nb); 1584 1585 #ifdef DEBUG 1586 + #define dbg(format, arg...) \ 1587 + printk(KERN_DEBUG "%s: " format "\n", __FILE__, ##arg) 1588 #else 1589 + #define dbg(format, arg...) \ 1590 + do { \ 1591 + if (0) \ 1592 + printk(KERN_DEBUG "%s: " format "\n", __FILE__, ##arg); \ 1593 + } while (0) 1594 #endif 1595 1596 + #define err(format, arg...) \ 1597 + printk(KERN_ERR KBUILD_MODNAME ": " format "\n", ##arg) 1598 1599 /* debugfs stuff */ 1600 extern struct dentry *usb_debug_root;
-1
include/linux/usb/Kbuild
··· 5 header-y += midi.h 6 header-y += g_printer.h 7 header-y += tmc.h 8 - header-y += vstusb.h
··· 5 header-y += midi.h 6 header-y += g_printer.h 7 header-y += tmc.h
+1
include/linux/usb/atmel_usba_udc.h
··· 15 16 struct usba_platform_data { 17 int vbus_pin; 18 int num_ep; 19 struct usba_ep_data ep[0]; 20 };
··· 15 16 struct usba_platform_data { 17 int vbus_pin; 18 + int vbus_pin_inverted; 19 int num_ep; 20 struct usba_ep_data ep[0]; 21 };
+1 -1
include/linux/usb/ch9.h
··· 775 USB_SPEED_UNKNOWN = 0, /* enumerating */ 776 USB_SPEED_LOW, USB_SPEED_FULL, /* usb 1.1 */ 777 USB_SPEED_HIGH, /* usb 2.0 */ 778 - USB_SPEED_VARIABLE, /* wireless (usb 2.5) */ 779 USB_SPEED_SUPER, /* usb 3.0 */ 780 }; 781
··· 775 USB_SPEED_UNKNOWN = 0, /* enumerating */ 776 USB_SPEED_LOW, USB_SPEED_FULL, /* usb 1.1 */ 777 USB_SPEED_HIGH, /* usb 2.0 */ 778 + USB_SPEED_WIRELESS, /* wireless (usb 2.5) */ 779 USB_SPEED_SUPER, /* usb 3.0 */ 780 }; 781
+13 -10
include/linux/usb/musb.h
··· 30 struct musb_hdrc_config { 31 /* MUSB configuration-specific details */ 32 unsigned multipoint:1; /* multipoint device */ 33 - unsigned dyn_fifo:1; /* supports dynamic fifo sizing */ 34 - unsigned soft_con:1; /* soft connect required */ 35 - unsigned utm_16:1; /* utm data witdh is 16 bits */ 36 unsigned big_endian:1; /* true if CPU uses big-endian */ 37 unsigned mult_bulk_tx:1; /* Tx ep required for multbulk pkts */ 38 unsigned mult_bulk_rx:1; /* Rx ep required for multbulk pkts */ 39 unsigned high_iso_tx:1; /* Tx ep required for HB iso */ 40 unsigned high_iso_rx:1; /* Rx ep required for HD iso */ 41 - unsigned dma:1; /* supports DMA */ 42 - unsigned vendor_req:1; /* vendor registers required */ 43 44 u8 num_eps; /* number of endpoints _with_ ep0 */ 45 - u8 dma_channels; /* number of dma channels */ 46 u8 dyn_fifo_size; /* dynamic size in bytes */ 47 - u8 vendor_ctrl; /* vendor control reg width */ 48 - u8 vendor_stat; /* vendor status reg witdh */ 49 - u8 dma_req_chan; /* bitmask for required dma channels */ 50 u8 ram_bits; /* ram address size */ 51 52 - struct musb_hdrc_eps_bits *eps_bits; 53 #ifdef CONFIG_BLACKFIN 54 /* A GPIO controlling VRSEL in Blackfin */ 55 unsigned int gpio_vrsel; ··· 75 76 /* (HOST or OTG) msec/2 after VBUS on till power good */ 77 u8 potpgt; 78 79 /* Power the device on or off */ 80 int (*set_power)(int state);
··· 30 struct musb_hdrc_config { 31 /* MUSB configuration-specific details */ 32 unsigned multipoint:1; /* multipoint device */ 33 + unsigned dyn_fifo:1 __deprecated; /* supports dynamic fifo sizing */ 34 + unsigned soft_con:1 __deprecated; /* soft connect required */ 35 + unsigned utm_16:1 __deprecated; /* utm data witdh is 16 bits */ 36 unsigned big_endian:1; /* true if CPU uses big-endian */ 37 unsigned mult_bulk_tx:1; /* Tx ep required for multbulk pkts */ 38 unsigned mult_bulk_rx:1; /* Rx ep required for multbulk pkts */ 39 unsigned high_iso_tx:1; /* Tx ep required for HB iso */ 40 unsigned high_iso_rx:1; /* Rx ep required for HD iso */ 41 + unsigned dma:1 __deprecated; /* supports DMA */ 42 + unsigned vendor_req:1 __deprecated; /* vendor registers required */ 43 44 u8 num_eps; /* number of endpoints _with_ ep0 */ 45 + u8 dma_channels __deprecated; /* number of dma channels */ 46 u8 dyn_fifo_size; /* dynamic size in bytes */ 47 + u8 vendor_ctrl __deprecated; /* vendor control reg width */ 48 + u8 vendor_stat __deprecated; /* vendor status reg witdh */ 49 + u8 dma_req_chan __deprecated; /* bitmask for required dma channels */ 50 u8 ram_bits; /* ram address size */ 51 52 + struct musb_hdrc_eps_bits *eps_bits __deprecated; 53 #ifdef CONFIG_BLACKFIN 54 /* A GPIO controlling VRSEL in Blackfin */ 55 unsigned int gpio_vrsel; ··· 75 76 /* (HOST or OTG) msec/2 after VBUS on till power good */ 77 u8 potpgt; 78 + 79 + /* (HOST or OTG) program PHY for external Vbus */ 80 + unsigned extvbus:1; 81 82 /* Power the device on or off */ 83 int (*set_power)(int state);
+25
include/linux/usb/otg.h
··· 9 #ifndef __LINUX_USB_OTG_H 10 #define __LINUX_USB_OTG_H 11 12 /* OTG defines lots of enumeration states before device reset */ 13 enum usb_otg_state { 14 OTG_STATE_UNDEFINED = 0, ··· 33 OTG_STATE_A_PERIPHERAL, 34 OTG_STATE_A_WAIT_VFALL, 35 OTG_STATE_A_VBUS_ERR, 36 }; 37 38 #define USB_OTG_PULLUP_ID (1 << 0) ··· 79 80 struct otg_io_access_ops *io_ops; 81 void __iomem *io_priv; 82 83 /* to pass extra port status to the root hub */ 84 u16 port_status; ··· 226 return otg->start_srp(otg); 227 } 228 229 230 /* for OTG controller drivers (and maybe other stuff) */ 231 extern int usb_bus_start_enum(struct usb_bus *bus, unsigned port_num);
··· 9 #ifndef __LINUX_USB_OTG_H 10 #define __LINUX_USB_OTG_H 11 12 + #include <linux/notifier.h> 13 + 14 /* OTG defines lots of enumeration states before device reset */ 15 enum usb_otg_state { 16 OTG_STATE_UNDEFINED = 0, ··· 31 OTG_STATE_A_PERIPHERAL, 32 OTG_STATE_A_WAIT_VFALL, 33 OTG_STATE_A_VBUS_ERR, 34 + }; 35 + 36 + enum usb_xceiv_events { 37 + USB_EVENT_NONE, /* no events or cable disconnected */ 38 + USB_EVENT_VBUS, /* vbus valid event */ 39 + USB_EVENT_ID, /* id was grounded */ 40 + USB_EVENT_CHARGER, /* usb dedicated charger */ 41 + USB_EVENT_ENUMERATED, /* gadget driver enumerated */ 42 }; 43 44 #define USB_OTG_PULLUP_ID (1 << 0) ··· 69 70 struct otg_io_access_ops *io_ops; 71 void __iomem *io_priv; 72 + 73 + /* for notification of usb_xceiv_events */ 74 + struct blocking_notifier_head notifier; 75 76 /* to pass extra port status to the root hub */ 77 u16 port_status; ··· 213 return otg->start_srp(otg); 214 } 215 216 + /* notifiers */ 217 + static inline int 218 + otg_register_notifier(struct otg_transceiver *otg, struct notifier_block *nb) 219 + { 220 + return blocking_notifier_chain_register(&otg->notifier, nb); 221 + } 222 + 223 + static inline void 224 + otg_unregister_notifier(struct otg_transceiver *otg, struct notifier_block *nb) 225 + { 226 + blocking_notifier_chain_unregister(&otg->notifier, nb); 227 + } 228 229 /* for OTG controller drivers (and maybe other stuff) */ 230 extern int usb_bus_start_enum(struct usb_bus *bus, unsigned port_num);
+3
include/linux/usb/quirks.h
··· 19 /* device can't handle its Configuration or Interface strings */ 20 #define USB_QUIRK_CONFIG_INTF_STRINGS 0x00000008 21 22 #endif /* __LINUX_USB_QUIRKS_H */
··· 19 /* device can't handle its Configuration or Interface strings */ 20 #define USB_QUIRK_CONFIG_INTF_STRINGS 0x00000008 21 22 + /*device will morph if reset, don't use reset for handling errors */ 23 + #define USB_QUIRK_RESET_MORPHS 0x00000010 24 + 25 #endif /* __LINUX_USB_QUIRKS_H */
+5 -8
include/linux/usb/serial.h
··· 351 352 /* Use our own dbg macro */ 353 #undef dbg 354 - #define dbg(format, arg...) \ 355 - do { \ 356 - if (debug) \ 357 - printk(KERN_DEBUG "%s: " format "\n" , __FILE__ , \ 358 - ## arg); \ 359 - } while (0) 360 - 361 - 362 363 #endif /* __LINUX_USB_SERIAL_H */ 364
··· 351 352 /* Use our own dbg macro */ 353 #undef dbg 354 + #define dbg(format, arg...) \ 355 + do { \ 356 + if (debug) \ 357 + printk(KERN_DEBUG "%s: " format "\n", __FILE__, ##arg); \ 358 + } while (0) 359 360 #endif /* __LINUX_USB_SERIAL_H */ 361
-71
include/linux/usb/vstusb.h
··· 1 - /***************************************************************************** 2 - * File: drivers/usb/misc/vstusb.h 3 - * 4 - * Purpose: Support for the bulk USB Vernier Spectrophotometers 5 - * 6 - * Author: EQware Engineering, Inc. 7 - * Oregon City, OR, USA 97045 8 - * 9 - * Copyright: 2007, 2008 10 - * Vernier Software & Technology 11 - * Beaverton, OR, USA 97005 12 - * 13 - * Web: www.vernier.com 14 - * 15 - * This program is free software; you can redistribute it and/or modify 16 - * it under the terms of the GNU General Public License version 2 as 17 - * published by the Free Software Foundation. 18 - * 19 - *****************************************************************************/ 20 - /***************************************************************************** 21 - * 22 - * The vstusb module is a standard usb 'client' driver running on top of the 23 - * standard usb host controller stack. 24 - * 25 - * In general, vstusb supports standard bulk usb pipes. It supports multiple 26 - * devices and multiple pipes per device. 27 - * 28 - * The vstusb driver supports two interfaces: 29 - * 1 - ioctl SEND_PIPE/RECV_PIPE - a general bulk write/read msg 30 - * interface to any pipe with timeout support; 31 - * 2 - standard read/write with ioctl config - offers standard read/write 32 - * interface with ioctl configured pipes and timeouts. 33 - * 34 - * Both interfaces can be signal from other process and will abort its i/o 35 - * operation. 36 - * 37 - * A timeout of 0 means NO timeout. The user can still terminate the read via 38 - * signal. 39 - * 40 - * If using multiple threads with this driver, the user should ensure that 41 - * any reads, writes, or ioctls are complete before closing the device. 42 - * Changing read/write timeouts or pipes takes effect on next read/write. 43 - * 44 - *****************************************************************************/ 45 - 46 - struct vstusb_args { 47 - union { 48 - /* this struct is used for IOCTL_VSTUSB_SEND_PIPE, * 49 - * IOCTL_VSTUSB_RECV_PIPE, and read()/write() fops */ 50 - struct { 51 - void __user *buffer; 52 - size_t count; 53 - unsigned int timeout_ms; 54 - int pipe; 55 - }; 56 - 57 - /* this one is used for IOCTL_VSTUSB_CONFIG_RW */ 58 - struct { 59 - int rd_pipe; 60 - int rd_timeout_ms; 61 - int wr_pipe; 62 - int wr_timeout_ms; 63 - }; 64 - }; 65 - }; 66 - 67 - #define VST_IOC_MAGIC 'L' 68 - #define VST_IOC_FIRST 0x20 69 - #define IOCTL_VSTUSB_SEND_PIPE _IO(VST_IOC_MAGIC, VST_IOC_FIRST) 70 - #define IOCTL_VSTUSB_RECV_PIPE _IO(VST_IOC_MAGIC, VST_IOC_FIRST + 1) 71 - #define IOCTL_VSTUSB_CONFIG_RW _IO(VST_IOC_MAGIC, VST_IOC_FIRST + 2)
···