aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-04-25 15:40:57 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-25 15:40:57 -0400
commit37b05b17985ecc43a33e2a8cbdaa220115de4703 (patch)
tree8213bf790182711677018ed322a9ccf61470242e
parentce1d5b23a8d1e19866ab82bdec0dc41fde5273d8 (diff)
parent4953d141dc5db748475001cfbfdcc42e66cf900e (diff)
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: (120 commits) usb: don't update devnum for wusb devices wusb: make ep0_reinit available for modules wusb: devices dont use a set address wusb: teach choose_address() about wireless devices wusb: add link wusb-usb device wusb: add authenticathed bit to usb_dev USB: remove unnecessary type casting of urb->context usb serial: more fixes and groundwork for tty changes USB: replace remaining __FUNCTION__ occurrences USB: usbfs: export the URB_NO_INTERRUPT flag to userspace USB: fix compile problems in ehci-hcd USB: ehci: qh_completions cleanup and bugfix USB: cdc-acm: signedness fix USB: add documentation about callbacks USB: don't explicitly reenable root-hub status interrupts USB: OHCI: turn off RD when remote wakeup is disabled USB: HCDs use the do_remote_wakeup flag USB: g_file_storage: ignore bulk-out data after invalid CBW USB: serial: remove endpoints setting checks from core and header USB: serial: remove unneeded number endpoints settings ...
-rw-r--r--Documentation/usb/anchors.txt50
-rw-r--r--Documentation/usb/callbacks.txt132
-rw-r--r--Documentation/usb/persist.txt43
-rw-r--r--Documentation/usb/usb-serial.txt7
-rw-r--r--drivers/input/joystick/xpad.c20
-rw-r--r--drivers/usb/atm/cxacru.c2
-rw-r--r--drivers/usb/atm/ueagle-atm.c6
-rw-r--r--drivers/usb/atm/usbatm.c27
-rw-r--r--drivers/usb/atm/usbatm.h2
-rw-r--r--drivers/usb/class/cdc-acm.c98
-rw-r--r--drivers/usb/class/cdc-acm.h7
-rw-r--r--drivers/usb/core/Kconfig42
-rw-r--r--drivers/usb/core/config.c17
-rw-r--r--drivers/usb/core/devio.c73
-rw-r--r--drivers/usb/core/driver.c52
-rw-r--r--drivers/usb/core/hcd-pci.c15
-rw-r--r--drivers/usb/core/hcd.c25
-rw-r--r--drivers/usb/core/hcd.h9
-rw-r--r--drivers/usb/core/hub.c396
-rw-r--r--drivers/usb/core/hub.h9
-rw-r--r--drivers/usb/core/inode.c4
-rw-r--r--drivers/usb/core/message.c17
-rw-r--r--drivers/usb/core/quirks.c14
-rw-r--r--drivers/usb/core/sysfs.c22
-rw-r--r--drivers/usb/core/urb.c26
-rw-r--r--drivers/usb/core/usb.h2
-rw-r--r--drivers/usb/gadget/Kconfig18
-rw-r--r--drivers/usb/gadget/amd5536udc.c10
-rw-r--r--drivers/usb/gadget/at91_udc.c9
-rw-r--r--drivers/usb/gadget/dummy_hcd.c98
-rw-r--r--drivers/usb/gadget/epautoconf.c12
-rw-r--r--drivers/usb/gadget/ether.c18
-rw-r--r--drivers/usb/gadget/file_storage.c36
-rw-r--r--drivers/usb/gadget/fsl_usb2_udc.c4
-rw-r--r--drivers/usb/gadget/fsl_usb2_udc.h2
-rw-r--r--drivers/usb/gadget/gmidi.c2
-rw-r--r--drivers/usb/gadget/goku_udc.c20
-rw-r--r--drivers/usb/gadget/inode.c18
-rw-r--r--drivers/usb/gadget/lh7a40x_udc.c132
-rw-r--r--drivers/usb/gadget/m66592-udc.h2
-rw-r--r--drivers/usb/gadget/net2280.h2
-rw-r--r--drivers/usb/gadget/omap_udc.c20
-rw-r--r--drivers/usb/gadget/printer.c92
-rw-r--r--drivers/usb/gadget/pxa2xx_udc.c26
-rw-r--r--drivers/usb/gadget/rndis.c148
-rw-r--r--drivers/usb/gadget/serial.c3
-rw-r--r--drivers/usb/host/Kconfig10
-rw-r--r--drivers/usb/host/ehci-au1xxx.c5
-rw-r--r--drivers/usb/host/ehci-dbg.c4
-rw-r--r--drivers/usb/host/ehci-fsl.c9
-rw-r--r--drivers/usb/host/ehci-hcd.c113
-rw-r--r--drivers/usb/host/ehci-hub.c34
-rw-r--r--drivers/usb/host/ehci-ixp4xx.c3
-rw-r--r--drivers/usb/host/ehci-pci.c9
-rw-r--r--drivers/usb/host/ehci-ppc-soc.c5
-rw-r--r--drivers/usb/host/ehci-ps3.c1
-rw-r--r--drivers/usb/host/ehci-q.c104
-rw-r--r--drivers/usb/host/ehci-sched.c46
-rw-r--r--drivers/usb/host/isp116x-hcd.c14
-rw-r--r--drivers/usb/host/ohci-at91.c2
-rw-r--r--drivers/usb/host/ohci-au1xxx.c1
-rw-r--r--drivers/usb/host/ohci-dbg.c2
-rw-r--r--drivers/usb/host/ohci-ep93xx.c5
-rw-r--r--drivers/usb/host/ohci-hub.c128
-rw-r--r--drivers/usb/host/ohci-lh7a404.c1
-rw-r--r--drivers/usb/host/ohci-omap.c8
-rw-r--r--drivers/usb/host/ohci-pci.c47
-rw-r--r--drivers/usb/host/ohci-pnx4008.c1
-rw-r--r--drivers/usb/host/ohci-pnx8550.c1
-rw-r--r--drivers/usb/host/ohci-ppc-of.c1
-rw-r--r--drivers/usb/host/ohci-ppc-soc.c1
-rw-r--r--drivers/usb/host/ohci-ps3.c2
-rw-r--r--drivers/usb/host/ohci-pxa27x.c6
-rw-r--r--drivers/usb/host/ohci-s3c2410.c1
-rw-r--r--drivers/usb/host/ohci-sa1111.c1
-rw-r--r--drivers/usb/host/ohci-sh.c1
-rw-r--r--drivers/usb/host/ohci-sm501.c16
-rw-r--r--drivers/usb/host/ohci-ssb.c37
-rw-r--r--drivers/usb/host/pci-quirks.c6
-rw-r--r--drivers/usb/host/r8a66597-hcd.c256
-rw-r--r--drivers/usb/host/r8a66597.h51
-rw-r--r--drivers/usb/host/sl811-hcd.c12
-rw-r--r--drivers/usb/host/u132-hcd.c5124
-rw-r--r--drivers/usb/host/uhci-hcd.c35
-rw-r--r--drivers/usb/host/uhci-q.c2
-rw-r--r--drivers/usb/image/Kconfig4
-rw-r--r--drivers/usb/image/microtek.c3
-rw-r--r--drivers/usb/image/microtek.h1
-rw-r--r--drivers/usb/misc/Kconfig20
-rw-r--r--drivers/usb/misc/adutux.c120
-rw-r--r--drivers/usb/misc/appledisplay.c6
-rw-r--r--drivers/usb/misc/auerswald.c135
-rw-r--r--drivers/usb/misc/emi26.c30
-rw-r--r--drivers/usb/misc/emi62.c32
-rw-r--r--drivers/usb/misc/ftdi-elan.c2
-rw-r--r--drivers/usb/misc/iowarrior.c10
-rw-r--r--drivers/usb/misc/ldusb.c10
-rw-r--r--drivers/usb/misc/legousbtower.c92
-rw-r--r--drivers/usb/misc/phidgetkit.c6
-rw-r--r--drivers/usb/misc/phidgetmotorcontrol.c2
-rw-r--r--drivers/usb/misc/phidgetservo.c6
-rw-r--r--drivers/usb/misc/usblcd.c8
-rw-r--r--drivers/usb/misc/usbtest.c13
-rw-r--r--drivers/usb/mon/Makefile2
-rw-r--r--drivers/usb/mon/mon_bin.c9
-rw-r--r--drivers/usb/mon/mon_main.c3
-rw-r--r--drivers/usb/mon/mon_stat.c3
-rw-r--r--drivers/usb/serial/Kconfig76
-rw-r--r--drivers/usb/serial/Makefile3
-rw-r--r--drivers/usb/serial/aircable.c52
-rw-r--r--drivers/usb/serial/airprime.c37
-rw-r--r--drivers/usb/serial/ark3116.c10
-rw-r--r--drivers/usb/serial/belkin_sa.c23
-rw-r--r--drivers/usb/serial/ch341.c3
-rw-r--r--drivers/usb/serial/console.c10
-rw-r--r--drivers/usb/serial/cp2101.c114
-rw-r--r--drivers/usb/serial/cyberjack.c112
-rw-r--r--drivers/usb/serial/cypress_m8.c579
-rw-r--r--drivers/usb/serial/digi_acceleport.c50
-rw-r--r--drivers/usb/serial/empeg.c59
-rw-r--r--drivers/usb/serial/ezusb.c8
-rw-r--r--drivers/usb/serial/ftdi_sio.c171
-rw-r--r--drivers/usb/serial/funsoft.c3
-rw-r--r--drivers/usb/serial/garmin_gps.c115
-rw-r--r--drivers/usb/serial/generic.c56
-rw-r--r--drivers/usb/serial/hp4x.c3
-rw-r--r--drivers/usb/serial/io_edgeport.c326
-rw-r--r--drivers/usb/serial/io_tables.h12
-rw-r--r--drivers/usb/serial/io_ti.c398
-rw-r--r--drivers/usb/serial/ipaq.c53
-rw-r--r--drivers/usb/serial/ipw.c51
-rw-r--r--drivers/usb/serial/ir-usb.c53
-rw-r--r--drivers/usb/serial/iuu_phoenix.c165
-rw-r--r--drivers/usb/serial/keyspan.c281
-rw-r--r--drivers/usb/serial/keyspan.h16
-rw-r--r--drivers/usb/serial/keyspan_pda.c42
-rw-r--r--drivers/usb/serial/kl5kusb105.c124
-rw-r--r--drivers/usb/serial/kobil_sct.c75
-rw-r--r--drivers/usb/serial/mct_u232.c41
-rw-r--r--drivers/usb/serial/mos7720.c122
-rw-r--r--drivers/usb/serial/mos7840.c164
-rw-r--r--drivers/usb/serial/navman.c31
-rw-r--r--drivers/usb/serial/omninet.c42
-rw-r--r--drivers/usb/serial/option.c92
-rw-r--r--drivers/usb/serial/oti6858.c121
-rw-r--r--drivers/usb/serial/pl2303.c117
-rw-r--r--drivers/usb/serial/safe_serial.c60
-rw-r--r--drivers/usb/serial/sierra.c129
-rw-r--r--drivers/usb/serial/spcp8x5.c1072
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.c211
-rw-r--r--drivers/usb/serial/usb-serial.c107
-rw-r--r--drivers/usb/serial/usb_debug.c3
-rw-r--r--drivers/usb/serial/visor.c103
-rw-r--r--drivers/usb/serial/whiteheat.c118
-rw-r--r--drivers/usb/storage/Kconfig39
-rw-r--r--drivers/usb/storage/Makefile1
-rw-r--r--drivers/usb/storage/cypress_atacb.c200
-rw-r--r--drivers/usb/storage/cypress_atacb.h25
-rw-r--r--drivers/usb/storage/libusual.c14
-rw-r--r--drivers/usb/storage/scsiglue.c26
-rw-r--r--drivers/usb/storage/transport.c23
-rw-r--r--drivers/usb/storage/unusual_devs.h8
-rw-r--r--drivers/usb/storage/usb.c26
-rw-r--r--drivers/usb/usb-skeleton.c8
-rw-r--r--include/linux/usb.h196
-rw-r--r--include/linux/usb/audio.h2
-rw-r--r--include/linux/usb/cdc.h4
-rw-r--r--include/linux/usb/ch9.h17
-rw-r--r--include/linux/usb/g_printer.h4
-rw-r--r--include/linux/usb/gadget.h2
-rw-r--r--include/linux/usb/gadgetfs.h16
-rw-r--r--include/linux/usb/input.h8
-rw-r--r--include/linux/usb/iowarrior.h6
-rw-r--r--include/linux/usb/isp116x.h6
-rw-r--r--include/linux/usb/midi.h2
-rw-r--r--include/linux/usb/net2280.h9
-rw-r--r--include/linux/usb/otg.h6
-rw-r--r--include/linux/usb/quirks.h5
-rw-r--r--include/linux/usb/rndis_host.h9
-rw-r--r--include/linux/usb/serial.h21
-rw-r--r--include/linux/usb/sl811.h5
-rw-r--r--include/linux/usb/usbnet.h8
-rw-r--r--include/linux/usb_usual.h1
-rw-r--r--include/linux/usbdevice_fs.h7
-rwxr-xr-xscripts/checkpatch.pl7
185 files changed, 8195 insertions, 6540 deletions
diff --git a/Documentation/usb/anchors.txt b/Documentation/usb/anchors.txt
new file mode 100644
index 00000000000..7304bcf5a30
--- /dev/null
+++ b/Documentation/usb/anchors.txt
@@ -0,0 +1,50 @@
1What is anchor?
2===============
3
4A USB driver needs to support some callbacks requiring
5a driver to cease all IO to an interface. To do so, a
6driver has to keep track of the URBs it has submitted
7to know they've all completed or to call usb_kill_urb
8for them. The anchor is a data structure takes care of
9keeping track of URBs and provides methods to deal with
10multiple URBs.
11
12Allocation and Initialisation
13=============================
14
15There's no API to allocate an anchor. It is simply declared
16as struct usb_anchor. init_usb_anchor() must be called to
17initialise the data structure.
18
19Deallocation
20============
21
22Once it has no more URBs associated with it, the anchor can be
23freed with normal memory management operations.
24
25Association and disassociation of URBs with anchors
26===================================================
27
28An association of URBs to an anchor is made by an explicit
29call to usb_anchor_urb(). The association is maintained until
30an URB is finished by (successfull) completion. Thus disassociation
31is automatic. A function is provided to forcibly finish (kill)
32all URBs associated with an anchor.
33Furthermore, disassociation can be made with usb_unanchor_urb()
34
35Operations on multitudes of URBs
36================================
37
38usb_kill_anchored_urbs()
39------------------------
40
41This function kills all URBs associated with an anchor. The URBs
42are called in the reverse temporal order they were submitted.
43This way no data can be reordered.
44
45usb_wait_anchor_empty_timeout()
46-------------------------------
47
48This function waits for all URBs associated with an anchor to finish
49or a timeout, whichever comes first. Its return value will tell you
50whether the timeout was reached.
diff --git a/Documentation/usb/callbacks.txt b/Documentation/usb/callbacks.txt
new file mode 100644
index 00000000000..7c812411945
--- /dev/null
+++ b/Documentation/usb/callbacks.txt
@@ -0,0 +1,132 @@
1What callbacks will usbcore do?
2===============================
3
4Usbcore will call into a driver through callbacks defined in the driver
5structure and through the completion handler of URBs a driver submits.
6Only the former are in the scope of this document. These two kinds of
7callbacks are completely independent of each other. Information on the
8completion callback can be found in Documentation/usb/URB.txt.
9
10The callbacks defined in the driver structure are:
11
121. Hotplugging callbacks:
13
14 * @probe: Called to see if the driver is willing to manage a particular
15 * interface on a device.
16 * @disconnect: Called when the interface is no longer accessible, usually
17 * because its device has been (or is being) disconnected or the
18 * driver module is being unloaded.
19
202. Odd backdoor through usbfs:
21
22 * @ioctl: Used for drivers that want to talk to userspace through
23 * the "usbfs" filesystem. This lets devices provide ways to
24 * expose information to user space regardless of where they
25 * do (or don't) show up otherwise in the filesystem.
26
273. Power management (PM) callbacks:
28
29 * @suspend: Called when the device is going to be suspended.
30 * @resume: Called when the device is being resumed.
31 * @reset_resume: Called when the suspended device has been reset instead
32 * of being resumed.
33
344. Device level operations:
35
36 * @pre_reset: Called when the device is about to be reset.
37 * @post_reset: Called after the device has been reset
38
39The ioctl interface (2) should be used only if you have a very good
40reason. Sysfs is preferred these days. The PM callbacks are covered
41separately in Documentation/usb/power-management.txt.
42
43Calling conventions
44===================
45
46All callbacks are mutually exclusive. There's no need for locking
47against other USB callbacks. All callbacks are called from a task
48context. You may sleep. However, it is important that all sleeps have a
49small fixed upper limit in time. In particular you must not call out to
50user space and await results.
51
52Hotplugging callbacks
53=====================
54
55These callbacks are intended to associate and disassociate a driver with
56an interface. A driver's bond to an interface is exclusive.
57
58The probe() callback
59--------------------
60
61int (*probe) (struct usb_interface *intf,
62 const struct usb_device_id *id);
63
64Accept or decline an interface. If you accept the device return 0,
65otherwise -ENODEV or -ENXIO. Other error codes should be used only if a
66genuine error occurred during initialisation which prevented a driver
67from accepting a device that would else have been accepted.
68You are strongly encouraged to use usbcore'sfacility,
69usb_set_intfdata(), to associate a data structure with an interface, so
70that you know which internal state and identity you associate with a
71particular interface. The device will not be suspended and you may do IO
72to the interface you are called for and endpoint 0 of the device. Device
73initialisation that doesn't take too long is a good idea here.
74
75The disconnect() callback
76-------------------------
77
78void (*disconnect) (struct usb_interface *intf);
79
80This callback is a signal to break any connection with an interface.
81You are not allowed any IO to a device after returning from this
82callback. You also may not do any other operation that may interfere
83with another driver bound the interface, eg. a power management
84operation.
85If you are called due to a physical disconnection, all your URBs will be
86killed by usbcore. Note that in this case disconnect will be called some
87time after the physical disconnection. Thus your driver must be prepared
88to deal with failing IO even prior to the callback.
89
90Device level callbacks
91======================
92
93pre_reset
94---------
95
96int (*pre_reset)(struct usb_interface *intf);
97
98Another driver or user space is triggering a reset on the device which
99contains the interface passed as an argument. Cease IO and save any
100device state you need to restore.
101
102If you need to allocate memory here, use GFP_NOIO or GFP_ATOMIC, if you
103are in atomic context.
104
105post_reset
106----------
107
108int (*post_reset)(struct usb_interface *intf);
109
110The reset has completed. Restore any saved device state and begin
111using the device again.
112
113If you need to allocate memory here, use GFP_NOIO or GFP_ATOMIC, if you
114are in atomic context.
115
116Call sequences
117==============
118
119No callbacks other than probe will be invoked for an interface
120that isn't bound to your driver.
121
122Probe will never be called for an interface bound to a driver.
123Hence following a successful probe, disconnect will be called
124before there is another probe for the same interface.
125
126Once your driver is bound to an interface, disconnect can be
127called at any time except in between pre_reset and post_reset.
128pre_reset is always followed by post_reset, even if the reset
129failed or the device has been unplugged.
130
131suspend is always followed by one of: resume, reset_resume, or
132disconnect.
diff --git a/Documentation/usb/persist.txt b/Documentation/usb/persist.txt
index df54d645cbb..d56cb1a1155 100644
--- a/Documentation/usb/persist.txt
+++ b/Documentation/usb/persist.txt
@@ -2,7 +2,7 @@
2 2
3 Alan Stern <stern@rowland.harvard.edu> 3 Alan Stern <stern@rowland.harvard.edu>
4 4
5 September 2, 2006 (Updated May 29, 2007) 5 September 2, 2006 (Updated February 25, 2008)
6 6
7 7
8 What is the problem? 8 What is the problem?
@@ -65,9 +65,10 @@ much better.)
65 65
66 What is the solution? 66 What is the solution?
67 67
68Setting CONFIG_USB_PERSIST will cause the kernel to work around these 68The kernel includes a feature called USB-persist. It tries to work
69issues. It enables a mode in which the core USB device data 69around these issues by allowing the core USB device data structures to
70structures are allowed to persist across a power-session disruption. 70persist across a power-session disruption.
71
71It works like this. If the kernel sees that a USB host controller is 72It works like this. If the kernel sees that a USB host controller is
72not in the expected state during resume (i.e., if the controller was 73not in the expected state during resume (i.e., if the controller was
73reset or otherwise had lost power) then it applies a persistence check 74reset or otherwise had lost power) then it applies a persistence check
@@ -80,28 +81,30 @@ re-enumeration shows that the device now attached to that port has the
80same descriptors as before, including the Vendor and Product IDs, then 81same descriptors as before, including the Vendor and Product IDs, then
81the kernel continues to use the same device structure. In effect, the 82the kernel continues to use the same device structure. In effect, the
82kernel treats the device as though it had merely been reset instead of 83kernel treats the device as though it had merely been reset instead of
83unplugged. 84unplugged. The same thing happens if the host controller is in the
85expected state but a USB device was unplugged and then replugged.
84 86
85If no device is now attached to the port, or if the descriptors are 87If no device is now attached to the port, or if the descriptors are
86different from what the kernel remembers, then the treatment is what 88different from what the kernel remembers, then the treatment is what
87you would expect. The kernel destroys the old device structure and 89you would expect. The kernel destroys the old device structure and
88behaves as though the old device had been unplugged and a new device 90behaves as though the old device had been unplugged and a new device
89plugged in, just as it would without the CONFIG_USB_PERSIST option. 91plugged in.
90 92
91The end result is that the USB device remains available and usable. 93The end result is that the USB device remains available and usable.
92Filesystem mounts and memory mappings are unaffected, and the world is 94Filesystem mounts and memory mappings are unaffected, and the world is
93now a good and happy place. 95now a good and happy place.
94 96
95Note that even when CONFIG_USB_PERSIST is set, the "persist" feature 97Note that the "USB-persist" feature will be applied only to those
96will be applied only to those devices for which it is enabled. You 98devices for which it is enabled. You can enable the feature by doing
97can enable the feature by doing (as root): 99(as root):
98 100
99 echo 1 >/sys/bus/usb/devices/.../power/persist 101 echo 1 >/sys/bus/usb/devices/.../power/persist
100 102
101where the "..." should be filled in the with the device's ID. Disable 103where the "..." should be filled in the with the device's ID. Disable
102the feature by writing 0 instead of 1. For hubs the feature is 104the feature by writing 0 instead of 1. For hubs the feature is
103automatically and permanently enabled, so you only have to worry about 105automatically and permanently enabled and the power/persist file
104setting it for devices where it really matters. 106doesn't even exist, so you only have to worry about setting it for
107devices where it really matters.
105 108
106 109
107 Is this the best solution? 110 Is this the best solution?
@@ -112,19 +115,19 @@ centralized Logical Volume Manager. Such a solution would allow you
112to plug in a USB flash device, create a persistent volume associated 115to plug in a USB flash device, create a persistent volume associated
113with it, unplug the flash device, plug it back in later, and still 116with it, unplug the flash device, plug it back in later, and still
114have the same persistent volume associated with the device. As such 117have the same persistent volume associated with the device. As such
115it would be more far-reaching than CONFIG_USB_PERSIST. 118it would be more far-reaching than USB-persist.
116 119
117On the other hand, writing a persistent volume manager would be a big 120On the other hand, writing a persistent volume manager would be a big
118job and using it would require significant input from the user. This 121job and using it would require significant input from the user. This
119solution is much quicker and easier -- and it exists now, a giant 122solution is much quicker and easier -- and it exists now, a giant
120point in its favor! 123point in its favor!
121 124
122Furthermore, the USB_PERSIST option applies to _all_ USB devices, not 125Furthermore, the USB-persist feature applies to _all_ USB devices, not
123just mass-storage devices. It might turn out to be equally useful for 126just mass-storage devices. It might turn out to be equally useful for
124other device types, such as network interfaces. 127other device types, such as network interfaces.
125 128
126 129
127 WARNING: Using CONFIG_USB_PERSIST can be dangerous!! 130 WARNING: USB-persist can be dangerous!!
128 131
129When recovering an interrupted power session the kernel does its best 132When recovering an interrupted power session the kernel does its best
130to make sure the USB device hasn't been changed; that is, the same 133to make sure the USB device hasn't been changed; that is, the same
@@ -133,10 +136,10 @@ aren't guaranteed to be 100% accurate.
133 136
134If you replace one USB device with another of the same type (same 137If you replace one USB device with another of the same type (same
135manufacturer, same IDs, and so on) there's an excellent chance the 138manufacturer, same IDs, and so on) there's an excellent chance the
136kernel won't detect the change. Serial numbers and other strings are 139kernel won't detect the change. The serial number string and other
137not compared. In many cases it wouldn't help if they were, because 140descriptors are compared with the kernel's stored values, but this
138manufacturers frequently omit serial numbers entirely in their 141might not help since manufacturers frequently omit serial numbers
139devices. 142entirely in their devices.
140 143
141Furthermore it's quite possible to leave a USB device exactly the same 144Furthermore it's quite possible to leave a USB device exactly the same
142while changing its media. If you replace the flash memory card in a 145while changing its media. If you replace the flash memory card in a
@@ -152,5 +155,5 @@ but yourself.
152YOU HAVE BEEN WARNED! USE AT YOUR OWN RISK! 155YOU HAVE BEEN WARNED! USE AT YOUR OWN RISK!
153 156
154That having been said, most of the time there shouldn't be any trouble 157That having been said, most of the time there shouldn't be any trouble
155at all. The "persist" feature can be extremely useful. Make the most 158at all. The USB-persist feature can be extremely useful. Make the
156of it. 159most of it.
diff --git a/Documentation/usb/usb-serial.txt b/Documentation/usb/usb-serial.txt
index 8b077e43eee..ff2c1ff57ba 100644
--- a/Documentation/usb/usb-serial.txt
+++ b/Documentation/usb/usb-serial.txt
@@ -192,12 +192,9 @@ Keyspan USA-series Serial Adapters
192 192
193FTDI Single Port Serial Driver 193FTDI Single Port Serial Driver
194 194
195 This is a single port DB-25 serial adapter. More information about this 195 This is a single port DB-25 serial adapter.
196 device and the Linux driver can be found at:
197 http://reality.sgi.com/bryder_wellington/ftdi_sio/
198 196
199 For any questions or problems with this driver, please contact Bill Ryder 197 For any questions or problems with this driver, please contact Bill Ryder.
200 at bryder@sgi.com
201 198
202 199
203ZyXEL omni.net lcd plus ISDN TA 200ZyXEL omni.net lcd plus ISDN TA
diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index 52ddb04644a..4b07bdadb81 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -405,9 +405,11 @@ static void xpad360w_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned cha
405static void xpad_irq_in(struct urb *urb) 405static void xpad_irq_in(struct urb *urb)
406{ 406{
407 struct usb_xpad *xpad = urb->context; 407 struct usb_xpad *xpad = urb->context;
408 int retval; 408 int retval, status;
409 409
410 switch (urb->status) { 410 status = urb->status;
411
412 switch (status) {
411 case 0: 413 case 0:
412 /* success */ 414 /* success */
413 break; 415 break;
@@ -416,11 +418,11 @@ static void xpad_irq_in(struct urb *urb)
416 case -ESHUTDOWN: 418 case -ESHUTDOWN:
417 /* this urb is terminated, clean up */ 419 /* this urb is terminated, clean up */
418 dbg("%s - urb shutting down with status: %d", 420 dbg("%s - urb shutting down with status: %d",
419 __FUNCTION__, urb->status); 421 __FUNCTION__, status);
420 return; 422 return;
421 default: 423 default:
422 dbg("%s - nonzero urb status received: %d", 424 dbg("%s - nonzero urb status received: %d",
423 __FUNCTION__, urb->status); 425 __FUNCTION__, status);
424 goto exit; 426 goto exit;
425 } 427 }
426 428
@@ -445,9 +447,11 @@ exit:
445#if defined(CONFIG_JOYSTICK_XPAD_FF) || defined(CONFIG_JOYSTICK_XPAD_LEDS) 447#if defined(CONFIG_JOYSTICK_XPAD_FF) || defined(CONFIG_JOYSTICK_XPAD_LEDS)
446static void xpad_irq_out(struct urb *urb) 448static void xpad_irq_out(struct urb *urb)
447{ 449{
448 int retval; 450 int retval, status;
449 451
450 switch (urb->status) { 452 status = urb->status;
453
454 switch (status) {
451 case 0: 455 case 0:
452 /* success */ 456 /* success */
453 break; 457 break;
@@ -456,11 +460,11 @@ static void xpad_irq_out(struct urb *urb)
456 case -ESHUTDOWN: 460 case -ESHUTDOWN:
457 /* this urb is terminated, clean up */ 461 /* this urb is terminated, clean up */
458 dbg("%s - urb shutting down with status: %d", 462 dbg("%s - urb shutting down with status: %d",
459 __FUNCTION__, urb->status); 463 __FUNCTION__, status);
460 return; 464 return;
461 default: 465 default:
462 dbg("%s - nonzero urb status received: %d", 466 dbg("%s - nonzero urb status received: %d",
463 __FUNCTION__, urb->status); 467 __FUNCTION__, status);
464 goto exit; 468 goto exit;
465 } 469 }
466 470
diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
index a51eeedc18d..d470c72b737 100644
--- a/drivers/usb/atm/cxacru.c
+++ b/drivers/usb/atm/cxacru.c
@@ -444,7 +444,7 @@ CXACRU_ALL_FILES(INIT);
444/* the following three functions are stolen from drivers/usb/core/message.c */ 444/* the following three functions are stolen from drivers/usb/core/message.c */
445static void cxacru_blocking_completion(struct urb *urb) 445static void cxacru_blocking_completion(struct urb *urb)
446{ 446{
447 complete((struct completion *)urb->context); 447 complete(urb->context);
448} 448}
449 449
450static void cxacru_timeout_kill(unsigned long data) 450static void cxacru_timeout_kill(unsigned long data)
diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c
index c5ec1a55eee..abb7d7410e6 100644
--- a/drivers/usb/atm/ueagle-atm.c
+++ b/drivers/usb/atm/ueagle-atm.c
@@ -83,7 +83,7 @@
83 if (debug >= 1) \ 83 if (debug >= 1) \
84 dev_dbg(&(usb_dev)->dev, \ 84 dev_dbg(&(usb_dev)->dev, \
85 "[ueagle-atm dbg] %s: " format, \ 85 "[ueagle-atm dbg] %s: " format, \
86 __FUNCTION__, ##args); \ 86 __func__, ##args); \
87 } while (0) 87 } while (0)
88 88
89#define uea_vdbg(usb_dev, format, args...) \ 89#define uea_vdbg(usb_dev, format, args...) \
@@ -94,10 +94,10 @@
94 } while (0) 94 } while (0)
95 95
96#define uea_enters(usb_dev) \ 96#define uea_enters(usb_dev) \
97 uea_vdbg(usb_dev, "entering %s\n", __FUNCTION__) 97 uea_vdbg(usb_dev, "entering %s\n", __func__)
98 98
99#define uea_leaves(usb_dev) \ 99#define uea_leaves(usb_dev) \
100 uea_vdbg(usb_dev, "leaving %s\n", __FUNCTION__) 100 uea_vdbg(usb_dev, "leaving %s\n", __func__)
101 101
102#define uea_err(usb_dev, format,args...) \ 102#define uea_err(usb_dev, format,args...) \
103 dev_err(&(usb_dev)->dev ,"[UEAGLE-ATM] " format , ##args) 103 dev_err(&(usb_dev)->dev ,"[UEAGLE-ATM] " format , ##args)
diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
index e717f5b1cae..07228721caf 100644
--- a/drivers/usb/atm/usbatm.c
+++ b/drivers/usb/atm/usbatm.c
@@ -80,6 +80,7 @@
80#include <linux/stat.h> 80#include <linux/stat.h>
81#include <linux/timer.h> 81#include <linux/timer.h>
82#include <linux/wait.h> 82#include <linux/wait.h>
83#include <linux/kthread.h>
83 84
84#ifdef VERBOSE_DEBUG 85#ifdef VERBOSE_DEBUG
85static int usbatm_print_packet(const unsigned char *data, int len); 86static int usbatm_print_packet(const unsigned char *data, int len);
@@ -1014,10 +1015,7 @@ static int usbatm_do_heavy_init(void *arg)
1014 struct usbatm_data *instance = arg; 1015 struct usbatm_data *instance = arg;
1015 int ret; 1016 int ret;
1016 1017
1017 daemonize(instance->driver->driver_name);
1018 allow_signal(SIGTERM); 1018 allow_signal(SIGTERM);
1019 instance->thread_pid = current->pid;
1020
1021 complete(&instance->thread_started); 1019 complete(&instance->thread_started);
1022 1020
1023 ret = instance->driver->heavy_init(instance, instance->usb_intf); 1021 ret = instance->driver->heavy_init(instance, instance->usb_intf);
@@ -1026,7 +1024,7 @@ static int usbatm_do_heavy_init(void *arg)
1026 ret = usbatm_atm_init(instance); 1024 ret = usbatm_atm_init(instance);
1027 1025
1028 mutex_lock(&instance->serialize); 1026 mutex_lock(&instance->serialize);
1029 instance->thread_pid = -1; 1027 instance->thread = NULL;
1030 mutex_unlock(&instance->serialize); 1028 mutex_unlock(&instance->serialize);
1031 1029
1032 complete_and_exit(&instance->thread_exited, ret); 1030 complete_and_exit(&instance->thread_exited, ret);
@@ -1034,13 +1032,18 @@ static int usbatm_do_heavy_init(void *arg)
1034 1032
1035static int usbatm_heavy_init(struct usbatm_data *instance) 1033static int usbatm_heavy_init(struct usbatm_data *instance)
1036{ 1034{
1037 int ret = kernel_thread(usbatm_do_heavy_init, instance, CLONE_FS | CLONE_FILES); 1035 struct task_struct *t;
1038 1036
1039 if (ret < 0) { 1037 t = kthread_create(usbatm_do_heavy_init, instance,
1040 usb_err(instance, "%s: failed to create kernel_thread (%d)!\n", __func__, ret); 1038 instance->driver->driver_name);
1041 return ret; 1039 if (IS_ERR(t)) {
1040 usb_err(instance, "%s: failed to create kernel_thread (%ld)!\n",
1041 __func__, PTR_ERR(t));
1042 return PTR_ERR(t);
1042 } 1043 }
1043 1044
1045 instance->thread = t;
1046 wake_up_process(t);
1044 wait_for_completion(&instance->thread_started); 1047 wait_for_completion(&instance->thread_started);
1045 1048
1046 return 0; 1049 return 0;
@@ -1124,7 +1127,7 @@ int usbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id,
1124 kref_init(&instance->refcount); /* dropped in usbatm_usb_disconnect */ 1127 kref_init(&instance->refcount); /* dropped in usbatm_usb_disconnect */
1125 mutex_init(&instance->serialize); 1128 mutex_init(&instance->serialize);
1126 1129
1127 instance->thread_pid = -1; 1130 instance->thread = NULL;
1128 init_completion(&instance->thread_started); 1131 init_completion(&instance->thread_started);
1129 init_completion(&instance->thread_exited); 1132 init_completion(&instance->thread_exited);
1130 1133
@@ -1287,8 +1290,8 @@ void usbatm_usb_disconnect(struct usb_interface *intf)
1287 1290
1288 mutex_lock(&instance->serialize); 1291 mutex_lock(&instance->serialize);
1289 instance->disconnected = 1; 1292 instance->disconnected = 1;
1290 if (instance->thread_pid >= 0) 1293 if (instance->thread != NULL)
1291 kill_proc(instance->thread_pid, SIGTERM, 1); 1294 send_sig(SIGTERM, instance->thread, 1);
1292 mutex_unlock(&instance->serialize); 1295 mutex_unlock(&instance->serialize);
1293 1296
1294 wait_for_completion(&instance->thread_exited); 1297 wait_for_completion(&instance->thread_exited);
diff --git a/drivers/usb/atm/usbatm.h b/drivers/usb/atm/usbatm.h
index fc6c2be5999..e6887c6cf3c 100644
--- a/drivers/usb/atm/usbatm.h
+++ b/drivers/usb/atm/usbatm.h
@@ -175,7 +175,7 @@ struct usbatm_data {
175 int disconnected; 175 int disconnected;
176 176
177 /* heavy init */ 177 /* heavy init */
178 int thread_pid; 178 struct task_struct *thread;
179 struct completion thread_started; 179 struct completion thread_started;
180 struct completion thread_exited; 180 struct completion thread_exited;
181 181
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 0147ea39340..7b572e75e73 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -31,6 +31,7 @@
31 * v0.23 - use softirq for rx processing, as needed by tty layer 31 * v0.23 - use softirq for rx processing, as needed by tty layer
32 * v0.24 - change probe method to evaluate CDC union descriptor 32 * v0.24 - change probe method to evaluate CDC union descriptor
33 * v0.25 - downstream tasks paralelized to maximize throughput 33 * v0.25 - downstream tasks paralelized to maximize throughput
34 * v0.26 - multiple write urbs, writesize increased
34 */ 35 */
35 36
36/* 37/*
@@ -72,7 +73,7 @@
72/* 73/*
73 * Version Information 74 * Version Information
74 */ 75 */
75#define DRIVER_VERSION "v0.25" 76#define DRIVER_VERSION "v0.26"
76#define DRIVER_AUTHOR "Armin Fuerst, Pavel Machek, Johannes Erdfelt, Vojtech Pavlik, David Kubicek" 77#define DRIVER_AUTHOR "Armin Fuerst, Pavel Machek, Johannes Erdfelt, Vojtech Pavlik, David Kubicek"
77#define DRIVER_DESC "USB Abstract Control Model driver for USB modems and ISDN adapters" 78#define DRIVER_DESC "USB Abstract Control Model driver for USB modems and ISDN adapters"
78 79
@@ -118,7 +119,7 @@ static int acm_wb_alloc(struct acm *acm)
118 int i, wbn; 119 int i, wbn;
119 struct acm_wb *wb; 120 struct acm_wb *wb;
120 121
121 wbn = acm->write_current; 122 wbn = 0;
122 i = 0; 123 i = 0;
123 for (;;) { 124 for (;;) {
124 wb = &acm->wb[wbn]; 125 wb = &acm->wb[wbn];
@@ -132,11 +133,6 @@ static int acm_wb_alloc(struct acm *acm)
132 } 133 }
133} 134}
134 135
135static void acm_wb_free(struct acm *acm, int wbn)
136{
137 acm->wb[wbn].use = 0;
138}
139
140static int acm_wb_is_avail(struct acm *acm) 136static int acm_wb_is_avail(struct acm *acm)
141{ 137{
142 int i, n; 138 int i, n;
@@ -156,26 +152,22 @@ static inline int acm_wb_is_used(struct acm *acm, int wbn)
156/* 152/*
157 * Finish write. 153 * Finish write.
158 */ 154 */
159static void acm_write_done(struct acm *acm) 155static void acm_write_done(struct acm *acm, struct acm_wb *wb)
160{ 156{
161 unsigned long flags; 157 unsigned long flags;
162 int wbn;
163 158
164 spin_lock_irqsave(&acm->write_lock, flags); 159 spin_lock_irqsave(&acm->write_lock, flags);
165 acm->write_ready = 1; 160 acm->write_ready = 1;
166 wbn = acm->write_current; 161 wb->use = 0;
167 acm_wb_free(acm, wbn);
168 acm->write_current = (wbn + 1) % ACM_NW;
169 spin_unlock_irqrestore(&acm->write_lock, flags); 162 spin_unlock_irqrestore(&acm->write_lock, flags);
170} 163}
171 164
172/* 165/*
173 * Poke write. 166 * Poke write.
174 */ 167 */
175static int acm_write_start(struct acm *acm) 168static int acm_write_start(struct acm *acm, int wbn)
176{ 169{
177 unsigned long flags; 170 unsigned long flags;
178 int wbn;
179 struct acm_wb *wb; 171 struct acm_wb *wb;
180 int rc; 172 int rc;
181 173
@@ -190,24 +182,24 @@ static int acm_write_start(struct acm *acm)
190 return 0; /* A white lie */ 182 return 0; /* A white lie */
191 } 183 }
192 184
193 wbn = acm->write_current;
194 if (!acm_wb_is_used(acm, wbn)) { 185 if (!acm_wb_is_used(acm, wbn)) {
195 spin_unlock_irqrestore(&acm->write_lock, flags); 186 spin_unlock_irqrestore(&acm->write_lock, flags);
196 return 0; 187 return 0;
197 } 188 }
198 wb = &acm->wb[wbn]; 189 wb = &acm->wb[wbn];
199 190
200 acm->write_ready = 0; 191 if(acm_wb_is_avail(acm) <= 1)
192 acm->write_ready = 0;
201 spin_unlock_irqrestore(&acm->write_lock, flags); 193 spin_unlock_irqrestore(&acm->write_lock, flags);
202 194
203 acm->writeurb->transfer_buffer = wb->buf; 195 wb->urb->transfer_buffer = wb->buf;
204 acm->writeurb->transfer_dma = wb->dmah; 196 wb->urb->transfer_dma = wb->dmah;
205 acm->writeurb->transfer_buffer_length = wb->len; 197 wb->urb->transfer_buffer_length = wb->len;
206 acm->writeurb->dev = acm->dev; 198 wb->urb->dev = acm->dev;
207 199
208 if ((rc = usb_submit_urb(acm->writeurb, GFP_ATOMIC)) < 0) { 200 if ((rc = usb_submit_urb(wb->urb, GFP_ATOMIC)) < 0) {
209 dbg("usb_submit_urb(write bulk) failed: %d", rc); 201 dbg("usb_submit_urb(write bulk) failed: %d", rc);
210 acm_write_done(acm); 202 acm_write_done(acm, wb);
211 } 203 }
212 return rc; 204 return rc;
213} 205}
@@ -268,10 +260,10 @@ static void acm_ctrl_irq(struct urb *urb)
268 case -ENOENT: 260 case -ENOENT:
269 case -ESHUTDOWN: 261 case -ESHUTDOWN:
270 /* this urb is terminated, clean up */ 262 /* this urb is terminated, clean up */
271 dbg("%s - urb shutting down with status: %d", __FUNCTION__, status); 263 dbg("%s - urb shutting down with status: %d", __func__, status);
272 return; 264 return;
273 default: 265 default:
274 dbg("%s - nonzero urb status received: %d", __FUNCTION__, status); 266 dbg("%s - nonzero urb status received: %d", __func__, status);
275 goto exit; 267 goto exit;
276 } 268 }
277 269
@@ -315,7 +307,7 @@ exit:
315 retval = usb_submit_urb (urb, GFP_ATOMIC); 307 retval = usb_submit_urb (urb, GFP_ATOMIC);
316 if (retval) 308 if (retval)
317 err ("%s - usb_submit_urb failed with result %d", 309 err ("%s - usb_submit_urb failed with result %d",
318 __FUNCTION__, retval); 310 __func__, retval);
319} 311}
320 312
321/* data interface returns incoming bytes, or we got unthrottled */ 313/* data interface returns incoming bytes, or we got unthrottled */
@@ -450,12 +442,13 @@ urbs:
450/* data interface wrote those outgoing bytes */ 442/* data interface wrote those outgoing bytes */
451static void acm_write_bulk(struct urb *urb) 443static void acm_write_bulk(struct urb *urb)
452{ 444{
453 struct acm *acm = (struct acm *)urb->context; 445 struct acm *acm;
446 struct acm_wb *wb = urb->context;
454 447
455 dbg("Entering acm_write_bulk with status %d", urb->status); 448 dbg("Entering acm_write_bulk with status %d", urb->status);
456 449
457 acm_write_done(acm); 450 acm = wb->instance;
458 acm_write_start(acm); 451 acm_write_done(acm, wb);
459 if (ACM_READY(acm)) 452 if (ACM_READY(acm))
460 schedule_work(&acm->work); 453 schedule_work(&acm->work);
461} 454}
@@ -489,6 +482,7 @@ static int acm_tty_open(struct tty_struct *tty, struct file *filp)
489 else 482 else
490 rv = 0; 483 rv = 0;
491 484
485 set_bit(TTY_NO_WRITE_SPLIT, &tty->flags);
492 tty->driver_data = acm; 486 tty->driver_data = acm;
493 acm->tty = tty; 487 acm->tty = tty;
494 488
@@ -556,7 +550,8 @@ static void acm_tty_unregister(struct acm *acm)
556 usb_put_intf(acm->control); 550 usb_put_intf(acm->control);
557 acm_table[acm->minor] = NULL; 551 acm_table[acm->minor] = NULL;
558 usb_free_urb(acm->ctrlurb); 552 usb_free_urb(acm->ctrlurb);
559 usb_free_urb(acm->writeurb); 553 for (i = 0; i < ACM_NW; i++)
554 usb_free_urb(acm->wb[i].urb);
560 for (i = 0; i < nr; i++) 555 for (i = 0; i < nr; i++)
561 usb_free_urb(acm->ru[i].urb); 556 usb_free_urb(acm->ru[i].urb);
562 kfree(acm->country_codes); 557 kfree(acm->country_codes);
@@ -577,7 +572,8 @@ static void acm_tty_close(struct tty_struct *tty, struct file *filp)
577 if (acm->dev) { 572 if (acm->dev) {
578 acm_set_control(acm, acm->ctrlout = 0); 573 acm_set_control(acm, acm->ctrlout = 0);
579 usb_kill_urb(acm->ctrlurb); 574 usb_kill_urb(acm->ctrlurb);
580 usb_kill_urb(acm->writeurb); 575 for (i = 0; i < ACM_NW; i++)
576 usb_kill_urb(acm->wb[i].urb);
581 for (i = 0; i < nr; i++) 577 for (i = 0; i < nr; i++)
582 usb_kill_urb(acm->ru[i].urb); 578 usb_kill_urb(acm->ru[i].urb);
583 usb_autopm_put_interface(acm->control); 579 usb_autopm_put_interface(acm->control);
@@ -605,7 +601,6 @@ static int acm_tty_write(struct tty_struct *tty, const unsigned char *buf, int c
605 spin_lock_irqsave(&acm->write_lock, flags); 601 spin_lock_irqsave(&acm->write_lock, flags);
606 if ((wbn = acm_wb_alloc(acm)) < 0) { 602 if ((wbn = acm_wb_alloc(acm)) < 0) {
607 spin_unlock_irqrestore(&acm->write_lock, flags); 603 spin_unlock_irqrestore(&acm->write_lock, flags);
608 acm_write_start(acm);
609 return 0; 604 return 0;
610 } 605 }
611 wb = &acm->wb[wbn]; 606 wb = &acm->wb[wbn];
@@ -616,7 +611,7 @@ static int acm_tty_write(struct tty_struct *tty, const unsigned char *buf, int c
616 wb->len = count; 611 wb->len = count;
617 spin_unlock_irqrestore(&acm->write_lock, flags); 612 spin_unlock_irqrestore(&acm->write_lock, flags);
618 613
619 if ((stat = acm_write_start(acm)) < 0) 614 if ((stat = acm_write_start(acm, wbn)) < 0)
620 return stat; 615 return stat;
621 return count; 616 return count;
622} 617}
@@ -809,7 +804,7 @@ static int acm_probe (struct usb_interface *intf,
809{ 804{
810 struct usb_cdc_union_desc *union_header = NULL; 805 struct usb_cdc_union_desc *union_header = NULL;
811 struct usb_cdc_country_functional_desc *cfd = NULL; 806 struct usb_cdc_country_functional_desc *cfd = NULL;
812 char *buffer = intf->altsetting->extra; 807 unsigned char *buffer = intf->altsetting->extra;
813 int buflen = intf->altsetting->extralen; 808 int buflen = intf->altsetting->extralen;
814 struct usb_interface *control_interface; 809 struct usb_interface *control_interface;
815 struct usb_interface *data_interface; 810 struct usb_interface *data_interface;
@@ -886,9 +881,13 @@ static int acm_probe (struct usb_interface *intf,
886 if ((call_management_function & 3) != 3) 881 if ((call_management_function & 3) != 3)
887 err("This device cannot do calls on its own. It is no modem."); 882 err("This device cannot do calls on its own. It is no modem.");
888 break; 883 break;
889
890 default: 884 default:
891 err("Ignoring extra header, type %d, length %d", buffer[2], buffer[0]); 885 /* there are LOTS more CDC descriptors that
886 * could legitimately be found here.
887 */
888 dev_dbg(&intf->dev, "Ignoring descriptor: "
889 "type %02x, length %d\n",
890 buffer[2], buffer[0]);
892 break; 891 break;
893 } 892 }
894next_desc: 893next_desc:
@@ -976,7 +975,7 @@ skip_normal_probe:
976 975
977 ctrlsize = le16_to_cpu(epctrl->wMaxPacketSize); 976 ctrlsize = le16_to_cpu(epctrl->wMaxPacketSize);
978 readsize = le16_to_cpu(epread->wMaxPacketSize)* ( quirks == SINGLE_RX_URB ? 1 : 2); 977 readsize = le16_to_cpu(epread->wMaxPacketSize)* ( quirks == SINGLE_RX_URB ? 1 : 2);
979 acm->writesize = le16_to_cpu(epwrite->wMaxPacketSize); 978 acm->writesize = le16_to_cpu(epwrite->wMaxPacketSize) * 20;
980 acm->control = control_interface; 979 acm->control = control_interface;
981 acm->data = data_interface; 980 acm->data = data_interface;
982 acm->minor = minor; 981 acm->minor = minor;
@@ -1031,10 +1030,19 @@ skip_normal_probe:
1031 goto alloc_fail7; 1030 goto alloc_fail7;
1032 } 1031 }
1033 } 1032 }
1034 acm->writeurb = usb_alloc_urb(0, GFP_KERNEL); 1033 for(i = 0; i < ACM_NW; i++)
1035 if (!acm->writeurb) { 1034 {
1036 dev_dbg(&intf->dev, "out of memory (writeurb kmalloc)\n"); 1035 struct acm_wb *snd = &(acm->wb[i]);
1037 goto alloc_fail7; 1036
1037 if (!(snd->urb = usb_alloc_urb(0, GFP_KERNEL))) {
1038 dev_dbg(&intf->dev, "out of memory (write urbs usb_alloc_urb)");
1039 goto alloc_fail7;
1040 }
1041
1042 usb_fill_bulk_urb(snd->urb, usb_dev, usb_sndbulkpipe(usb_dev, epwrite->bEndpointAddress),
1043 NULL, acm->writesize, acm_write_bulk, snd);
1044 snd->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
1045 snd->instance = acm;
1038 } 1046 }
1039 1047
1040 usb_set_intfdata (intf, acm); 1048 usb_set_intfdata (intf, acm);
@@ -1070,10 +1078,6 @@ skip_countries:
1070 acm->ctrlurb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 1078 acm->ctrlurb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
1071 acm->ctrlurb->transfer_dma = acm->ctrl_dma; 1079 acm->ctrlurb->transfer_dma = acm->ctrl_dma;
1072 1080
1073 usb_fill_bulk_urb(acm->writeurb, usb_dev, usb_sndbulkpipe(usb_dev, epwrite->bEndpointAddress),
1074 NULL, acm->writesize, acm_write_bulk, acm);
1075 acm->writeurb->transfer_flags |= URB_NO_FSBR | URB_NO_TRANSFER_DMA_MAP;
1076
1077 dev_info(&intf->dev, "ttyACM%d: USB ACM device\n", minor); 1081 dev_info(&intf->dev, "ttyACM%d: USB ACM device\n", minor);
1078 1082
1079 acm_set_control(acm, acm->ctrlout); 1083 acm_set_control(acm, acm->ctrlout);
@@ -1091,7 +1095,8 @@ skip_countries:
1091 1095
1092 return 0; 1096 return 0;
1093alloc_fail8: 1097alloc_fail8:
1094 usb_free_urb(acm->writeurb); 1098 for (i = 0; i < ACM_NW; i++)
1099 usb_free_urb(acm->wb[i].urb);
1095alloc_fail7: 1100alloc_fail7:
1096 for (i = 0; i < num_rx_buf; i++) 1101 for (i = 0; i < num_rx_buf; i++)
1097 usb_buffer_free(usb_dev, acm->readsize, acm->rb[i].base, acm->rb[i].dma); 1102 usb_buffer_free(usb_dev, acm->readsize, acm->rb[i].base, acm->rb[i].dma);
@@ -1115,7 +1120,8 @@ static void stop_data_traffic(struct acm *acm)
1115 tasklet_disable(&acm->urb_task); 1120 tasklet_disable(&acm->urb_task);
1116 1121
1117 usb_kill_urb(acm->ctrlurb); 1122 usb_kill_urb(acm->ctrlurb);
1118 usb_kill_urb(acm->writeurb); 1123 for(i = 0; i < ACM_NW; i++)
1124 usb_kill_urb(acm->wb[i].urb);
1119 for (i = 0; i < acm->rx_buflimit; i++) 1125 for (i = 0; i < acm->rx_buflimit; i++)
1120 usb_kill_urb(acm->ru[i].urb); 1126 usb_kill_urb(acm->ru[i].urb);
1121 1127
diff --git a/drivers/usb/class/cdc-acm.h b/drivers/usb/class/cdc-acm.h
index 8df6a57dcf9..046e064b033 100644
--- a/drivers/usb/class/cdc-acm.h
+++ b/drivers/usb/class/cdc-acm.h
@@ -59,7 +59,7 @@
59 * when processing onlcr, so we only need 2 buffers. These values must be 59 * when processing onlcr, so we only need 2 buffers. These values must be
60 * powers of 2. 60 * powers of 2.
61 */ 61 */
62#define ACM_NW 2 62#define ACM_NW 16
63#define ACM_NR 16 63#define ACM_NR 16
64 64
65struct acm_wb { 65struct acm_wb {
@@ -67,6 +67,8 @@ struct acm_wb {
67 dma_addr_t dmah; 67 dma_addr_t dmah;
68 int len; 68 int len;
69 int use; 69 int use;
70 struct urb *urb;
71 struct acm *instance;
70}; 72};
71 73
72struct acm_rb { 74struct acm_rb {
@@ -88,7 +90,7 @@ struct acm {
88 struct usb_interface *control; /* control interface */ 90 struct usb_interface *control; /* control interface */
89 struct usb_interface *data; /* data interface */ 91 struct usb_interface *data; /* data interface */
90 struct tty_struct *tty; /* the corresponding tty */ 92 struct tty_struct *tty; /* the corresponding tty */
91 struct urb *ctrlurb, *writeurb; /* urbs */ 93 struct urb *ctrlurb; /* urbs */
92 u8 *ctrl_buffer; /* buffers of urbs */ 94 u8 *ctrl_buffer; /* buffers of urbs */
93 dma_addr_t ctrl_dma; /* dma handles of buffers */ 95 dma_addr_t ctrl_dma; /* dma handles of buffers */
94 u8 *country_codes; /* country codes from device */ 96 u8 *country_codes; /* country codes from device */
@@ -103,7 +105,6 @@ struct acm {
103 struct list_head spare_read_urbs; 105 struct list_head spare_read_urbs;
104 struct list_head spare_read_bufs; 106 struct list_head spare_read_bufs;
105 struct list_head filled_read_bufs; 107 struct list_head filled_read_bufs;
106 int write_current; /* current write buffer */
107 int write_used; /* number of non-empty write buffers */ 108 int write_used; /* number of non-empty write buffers */
108 int write_ready; /* write urb is not running */ 109 int write_ready; /* write urb is not running */
109 spinlock_t write_lock; 110 spinlock_t write_lock;
diff --git a/drivers/usb/core/Kconfig b/drivers/usb/core/Kconfig
index a2b0aa48b8e..cc9f397e839 100644
--- a/drivers/usb/core/Kconfig
+++ b/drivers/usb/core/Kconfig
@@ -76,8 +76,8 @@ config USB_DEVICE_CLASS
76 NAME="bus/usb/$env{BUSNUM}/$env{DEVNUM}", MODE="0644" 76 NAME="bus/usb/$env{BUSNUM}/$env{DEVNUM}", MODE="0644"
77 77
78config USB_DYNAMIC_MINORS 78config USB_DYNAMIC_MINORS
79 bool "Dynamic USB minor allocation (EXPERIMENTAL)" 79 bool "Dynamic USB minor allocation"
80 depends on USB && EXPERIMENTAL 80 depends on USB
81 help 81 help
82 If you say Y here, the USB subsystem will use dynamic minor 82 If you say Y here, the USB subsystem will use dynamic minor
83 allocation for any device that uses the USB major number. 83 allocation for any device that uses the USB major number.
@@ -102,31 +102,6 @@ config USB_SUSPEND
102 102
103 If you are unsure about this, say N here. 103 If you are unsure about this, say N here.
104 104
105config USB_PERSIST
106 bool "USB device persistence during system suspend (DANGEROUS)"
107 depends on USB && PM && EXPERIMENTAL
108 default n
109 help
110
111 If you say Y here and enable the "power/persist" attribute
112 for a USB device, the device's data structures will remain
113 persistent across system suspend, even if the USB bus loses
114 power. (This includes hibernation, also known as swsusp or
115 suspend-to-disk.) The devices will reappear as if by magic
116 when the system wakes up, with no need to unmount USB
117 filesystems, rmmod host-controller drivers, or do anything
118 else.
119
120 WARNING: This option can be dangerous!
121
122 If a USB device is replaced by another of the same type while
123 the system is asleep, there's a good chance the kernel won't
124 detect the change. Likewise if the media in a USB storage
125 device is replaced. When this happens it's almost certain to
126 cause data corruption and maybe even crash your system.
127
128 If you are unsure, say N here.
129
130config USB_OTG 105config USB_OTG
131 bool 106 bool
132 depends on USB && EXPERIMENTAL 107 depends on USB && EXPERIMENTAL
@@ -136,14 +111,16 @@ config USB_OTG
136 111
137config USB_OTG_WHITELIST 112config USB_OTG_WHITELIST
138 bool "Rely on OTG Targeted Peripherals List" 113 bool "Rely on OTG Targeted Peripherals List"
139 depends on USB_OTG 114 depends on USB_OTG || EMBEDDED
140 default y 115 default y if USB_OTG
116 default n if EMBEDDED
141 help 117 help
142 If you say Y here, the "otg_whitelist.h" file will be used as a 118 If you say Y here, the "otg_whitelist.h" file will be used as a
143 product whitelist, so USB peripherals not listed there will be 119 product whitelist, so USB peripherals not listed there will be
144 rejected during enumeration. This behavior is required by the 120 rejected during enumeration. This behavior is required by the
145 USB OTG specification for all devices not on your product's 121 USB OTG specification for all devices not on your product's
146 "Targeted Peripherals List". 122 "Targeted Peripherals List". "Embedded Hosts" are likewise
123 allowed to support only a limited number of peripherals.
147 124
148 Otherwise, peripherals not listed there will only generate a 125 Otherwise, peripherals not listed there will only generate a
149 warning and enumeration will continue. That's more like what 126 warning and enumeration will continue. That's more like what
@@ -152,9 +129,10 @@ config USB_OTG_WHITELIST
152 129
153config USB_OTG_BLACKLIST_HUB 130config USB_OTG_BLACKLIST_HUB
154 bool "Disable external hubs" 131 bool "Disable external hubs"
155 depends on USB_OTG 132 depends on USB_OTG || EMBEDDED
156 help 133 help
157 If you say Y here, then Linux will refuse to enumerate 134 If you say Y here, then Linux will refuse to enumerate
158 external hubs. OTG hosts are allowed to reduce hardware 135 external hubs. OTG hosts are allowed to reduce hardware
159 and software costs by not supporting external hubs. 136 and software costs by not supporting external hubs. So
137 are "Emedded Hosts" that don't offer OTG support.
160 138
diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
index a92122a216b..568244c99bd 100644
--- a/drivers/usb/core/config.c
+++ b/drivers/usb/core/config.c
@@ -145,6 +145,23 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum,
145 endpoint->desc.wMaxPacketSize = cpu_to_le16(8); 145 endpoint->desc.wMaxPacketSize = cpu_to_le16(8);
146 } 146 }
147 147
148 /*
149 * Some buggy high speed devices have bulk endpoints using
150 * maxpacket sizes other than 512. High speed HCDs may not
151 * be able to handle that particular bug, so let's warn...
152 */
153 if (to_usb_device(ddev)->speed == USB_SPEED_HIGH
154 && usb_endpoint_xfer_bulk(d)) {
155 unsigned maxp;
156
157 maxp = le16_to_cpu(endpoint->desc.wMaxPacketSize) & 0x07ff;
158 if (maxp != 512)
159 dev_warn(ddev, "config %d interface %d altsetting %d "
160 "bulk endpoint 0x%X has invalid maxpacket %d\n",
161 cfgno, inum, asnum, d->bEndpointAddress,
162 maxp);
163 }
164
148 /* Skip over any Class Specific or Vendor Specific descriptors; 165 /* Skip over any Class Specific or Vendor Specific descriptors;
149 * find the next endpoint or interface descriptor */ 166 * find the next endpoint or interface descriptor */
150 endpoint->extra = buffer; 167 endpoint->extra = buffer;
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index ae94176c64e..de17738f3ac 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -647,6 +647,7 @@ static int proc_control(struct dev_state *ps, void __user *arg)
647 struct usbdevfs_ctrltransfer ctrl; 647 struct usbdevfs_ctrltransfer ctrl;
648 unsigned int tmo; 648 unsigned int tmo;
649 unsigned char *tbuf; 649 unsigned char *tbuf;
650 unsigned wLength;
650 int i, j, ret; 651 int i, j, ret;
651 652
652 if (copy_from_user(&ctrl, arg, sizeof(ctrl))) 653 if (copy_from_user(&ctrl, arg, sizeof(ctrl)))
@@ -654,7 +655,8 @@ static int proc_control(struct dev_state *ps, void __user *arg)
654 ret = check_ctrlrecip(ps, ctrl.bRequestType, ctrl.wIndex); 655 ret = check_ctrlrecip(ps, ctrl.bRequestType, ctrl.wIndex);
655 if (ret) 656 if (ret)
656 return ret; 657 return ret;
657 if (ctrl.wLength > PAGE_SIZE) 658 wLength = ctrl.wLength; /* To suppress 64k PAGE_SIZE warning */
659 if (wLength > PAGE_SIZE)
658 return -EINVAL; 660 return -EINVAL;
659 tbuf = (unsigned char *)__get_free_page(GFP_KERNEL); 661 tbuf = (unsigned char *)__get_free_page(GFP_KERNEL);
660 if (!tbuf) 662 if (!tbuf)
@@ -946,8 +948,11 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
946 int ret, ifnum = -1; 948 int ret, ifnum = -1;
947 int is_in; 949 int is_in;
948 950
949 if (uurb->flags & ~(USBDEVFS_URB_ISO_ASAP|USBDEVFS_URB_SHORT_NOT_OK| 951 if (uurb->flags & ~(USBDEVFS_URB_ISO_ASAP |
950 URB_NO_FSBR|URB_ZERO_PACKET)) 952 USBDEVFS_URB_SHORT_NOT_OK |
953 USBDEVFS_URB_NO_FSBR |
954 USBDEVFS_URB_ZERO_PACKET |
955 USBDEVFS_URB_NO_INTERRUPT))
951 return -EINVAL; 956 return -EINVAL;
952 if (!uurb->buffer) 957 if (!uurb->buffer)
953 return -EINVAL; 958 return -EINVAL;
@@ -1102,8 +1107,24 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
1102 as->urb->pipe = (uurb->type << 30) | 1107 as->urb->pipe = (uurb->type << 30) |
1103 __create_pipe(ps->dev, uurb->endpoint & 0xf) | 1108 __create_pipe(ps->dev, uurb->endpoint & 0xf) |
1104 (uurb->endpoint & USB_DIR_IN); 1109 (uurb->endpoint & USB_DIR_IN);
1105 as->urb->transfer_flags = uurb->flags | 1110
1106 (is_in ? URB_DIR_IN : URB_DIR_OUT); 1111 /* This tedious sequence is necessary because the URB_* flags
1112 * are internal to the kernel and subject to change, whereas
1113 * the USBDEVFS_URB_* flags are a user API and must not be changed.
1114 */
1115 u = (is_in ? URB_DIR_IN : URB_DIR_OUT);
1116 if (uurb->flags & USBDEVFS_URB_ISO_ASAP)
1117 u |= URB_ISO_ASAP;
1118 if (uurb->flags & USBDEVFS_URB_SHORT_NOT_OK)
1119 u |= URB_SHORT_NOT_OK;
1120 if (uurb->flags & USBDEVFS_URB_NO_FSBR)
1121 u |= URB_NO_FSBR;
1122 if (uurb->flags & USBDEVFS_URB_ZERO_PACKET)
1123 u |= URB_ZERO_PACKET;
1124 if (uurb->flags & USBDEVFS_URB_NO_INTERRUPT)
1125 u |= URB_NO_INTERRUPT;
1126 as->urb->transfer_flags = u;
1127
1107 as->urb->transfer_buffer_length = uurb->buffer_length; 1128 as->urb->transfer_buffer_length = uurb->buffer_length;
1108 as->urb->setup_packet = (unsigned char *)dr; 1129 as->urb->setup_packet = (unsigned char *)dr;
1109 as->urb->start_frame = uurb->start_frame; 1130 as->urb->start_frame = uurb->start_frame;
@@ -1509,60 +1530,60 @@ static int usbdev_ioctl(struct inode *inode, struct file *file,
1509 1530
1510 switch (cmd) { 1531 switch (cmd) {
1511 case USBDEVFS_CONTROL: 1532 case USBDEVFS_CONTROL:
1512 snoop(&dev->dev, "%s: CONTROL\n", __FUNCTION__); 1533 snoop(&dev->dev, "%s: CONTROL\n", __func__);
1513 ret = proc_control(ps, p); 1534 ret = proc_control(ps, p);
1514 if (ret >= 0) 1535 if (ret >= 0)
1515 inode->i_mtime = CURRENT_TIME; 1536 inode->i_mtime = CURRENT_TIME;
1516 break; 1537 break;
1517 1538
1518 case USBDEVFS_BULK: 1539 case USBDEVFS_BULK:
1519 snoop(&dev->dev, "%s: BULK\n", __FUNCTION__); 1540 snoop(&dev->dev, "%s: BULK\n", __func__);
1520 ret = proc_bulk(ps, p); 1541 ret = proc_bulk(ps, p);
1521 if (ret >= 0) 1542 if (ret >= 0)
1522 inode->i_mtime = CURRENT_TIME; 1543 inode->i_mtime = CURRENT_TIME;
1523 break; 1544 break;
1524 1545
1525 case USBDEVFS_RESETEP: 1546 case USBDEVFS_RESETEP:
1526 snoop(&dev->dev, "%s: RESETEP\n", __FUNCTION__); 1547 snoop(&dev->dev, "%s: RESETEP\n", __func__);
1527 ret = proc_resetep(ps, p); 1548 ret = proc_resetep(ps, p);
1528 if (ret >= 0) 1549 if (ret >= 0)
1529 inode->i_mtime = CURRENT_TIME; 1550 inode->i_mtime = CURRENT_TIME;
1530 break; 1551 break;
1531 1552
1532 case USBDEVFS_RESET: 1553 case USBDEVFS_RESET:
1533 snoop(&dev->dev, "%s: RESET\n", __FUNCTION__); 1554 snoop(&dev->dev, "%s: RESET\n", __func__);
1534 ret = proc_resetdevice(ps); 1555 ret = proc_resetdevice(ps);
1535 break; 1556 break;
1536 1557
1537 case USBDEVFS_CLEAR_HALT: 1558 case USBDEVFS_CLEAR_HALT:
1538 snoop(&dev->dev, "%s: CLEAR_HALT\n", __FUNCTION__); 1559 snoop(&dev->dev, "%s: CLEAR_HALT\n", __func__);
1539 ret = proc_clearhalt(ps, p); 1560 ret = proc_clearhalt(ps, p);
1540 if (ret >= 0) 1561 if (ret >= 0)
1541 inode->i_mtime = CURRENT_TIME; 1562 inode->i_mtime = CURRENT_TIME;
1542 break; 1563 break;
1543 1564
1544 case USBDEVFS_GETDRIVER: 1565 case USBDEVFS_GETDRIVER:
1545 snoop(&dev->dev, "%s: GETDRIVER\n", __FUNCTION__); 1566 snoop(&dev->dev, "%s: GETDRIVER\n", __func__);
1546 ret = proc_getdriver(ps, p); 1567 ret = proc_getdriver(ps, p);
1547 break; 1568 break;
1548 1569
1549 case USBDEVFS_CONNECTINFO: 1570 case USBDEVFS_CONNECTINFO:
1550 snoop(&dev->dev, "%s: CONNECTINFO\n", __FUNCTION__); 1571 snoop(&dev->dev, "%s: CONNECTINFO\n", __func__);
1551 ret = proc_connectinfo(ps, p); 1572 ret = proc_connectinfo(ps, p);
1552 break; 1573 break;
1553 1574
1554 case USBDEVFS_SETINTERFACE: 1575 case USBDEVFS_SETINTERFACE:
1555 snoop(&dev->dev, "%s: SETINTERFACE\n", __FUNCTION__); 1576 snoop(&dev->dev, "%s: SETINTERFACE\n", __func__);
1556 ret = proc_setintf(ps, p); 1577 ret = proc_setintf(ps, p);
1557 break; 1578 break;
1558 1579
1559 case USBDEVFS_SETCONFIGURATION: 1580 case USBDEVFS_SETCONFIGURATION:
1560 snoop(&dev->dev, "%s: SETCONFIGURATION\n", __FUNCTION__); 1581 snoop(&dev->dev, "%s: SETCONFIGURATION\n", __func__);
1561 ret = proc_setconfig(ps, p); 1582 ret = proc_setconfig(ps, p);
1562 break; 1583 break;
1563 1584
1564 case USBDEVFS_SUBMITURB: 1585 case USBDEVFS_SUBMITURB:
1565 snoop(&dev->dev, "%s: SUBMITURB\n", __FUNCTION__); 1586 snoop(&dev->dev, "%s: SUBMITURB\n", __func__);
1566 ret = proc_submiturb(ps, p); 1587 ret = proc_submiturb(ps, p);
1567 if (ret >= 0) 1588 if (ret >= 0)
1568 inode->i_mtime = CURRENT_TIME; 1589 inode->i_mtime = CURRENT_TIME;
@@ -1571,60 +1592,60 @@ static int usbdev_ioctl(struct inode *inode, struct file *file,
1571#ifdef CONFIG_COMPAT 1592#ifdef CONFIG_COMPAT
1572 1593
1573 case USBDEVFS_SUBMITURB32: 1594 case USBDEVFS_SUBMITURB32:
1574 snoop(&dev->dev, "%s: SUBMITURB32\n", __FUNCTION__); 1595 snoop(&dev->dev, "%s: SUBMITURB32\n", __func__);
1575 ret = proc_submiturb_compat(ps, p); 1596 ret = proc_submiturb_compat(ps, p);
1576 if (ret >= 0) 1597 if (ret >= 0)
1577 inode->i_mtime = CURRENT_TIME; 1598 inode->i_mtime = CURRENT_TIME;
1578 break; 1599 break;
1579 1600
1580 case USBDEVFS_REAPURB32: 1601 case USBDEVFS_REAPURB32:
1581 snoop(&dev->dev, "%s: REAPURB32\n", __FUNCTION__); 1602 snoop(&dev->dev, "%s: REAPURB32\n", __func__);
1582 ret = proc_reapurb_compat(ps, p); 1603 ret = proc_reapurb_compat(ps, p);
1583 break; 1604 break;
1584 1605
1585 case USBDEVFS_REAPURBNDELAY32: 1606 case USBDEVFS_REAPURBNDELAY32:
1586 snoop(&dev->dev, "%s: REAPURBDELAY32\n", __FUNCTION__); 1607 snoop(&dev->dev, "%s: REAPURBDELAY32\n", __func__);
1587 ret = proc_reapurbnonblock_compat(ps, p); 1608 ret = proc_reapurbnonblock_compat(ps, p);
1588 break; 1609 break;
1589 1610
1590 case USBDEVFS_IOCTL32: 1611 case USBDEVFS_IOCTL32:
1591 snoop(&dev->dev, "%s: IOCTL\n", __FUNCTION__); 1612 snoop(&dev->dev, "%s: IOCTL\n", __func__);
1592 ret = proc_ioctl_compat(ps, ptr_to_compat(p)); 1613 ret = proc_ioctl_compat(ps, ptr_to_compat(p));
1593 break; 1614 break;
1594#endif 1615#endif
1595 1616
1596 case USBDEVFS_DISCARDURB: 1617 case USBDEVFS_DISCARDURB:
1597 snoop(&dev->dev, "%s: DISCARDURB\n", __FUNCTION__); 1618 snoop(&dev->dev, "%s: DISCARDURB\n", __func__);
1598 ret = proc_unlinkurb(ps, p); 1619 ret = proc_unlinkurb(ps, p);
1599 break; 1620 break;
1600 1621
1601 case USBDEVFS_REAPURB: 1622 case USBDEVFS_REAPURB:
1602 snoop(&dev->dev, "%s: REAPURB\n", __FUNCTION__); 1623 snoop(&dev->dev, "%s: REAPURB\n", __func__);
1603 ret = proc_reapurb(ps, p); 1624 ret = proc_reapurb(ps, p);
1604 break; 1625 break;
1605 1626
1606 case USBDEVFS_REAPURBNDELAY: 1627 case USBDEVFS_REAPURBNDELAY:
1607 snoop(&dev->dev, "%s: REAPURBDELAY\n", __FUNCTION__); 1628 snoop(&dev->dev, "%s: REAPURBDELAY\n", __func__);
1608 ret = proc_reapurbnonblock(ps, p); 1629 ret = proc_reapurbnonblock(ps, p);
1609 break; 1630 break;
1610 1631
1611 case USBDEVFS_DISCSIGNAL: 1632 case USBDEVFS_DISCSIGNAL:
1612 snoop(&dev->dev, "%s: DISCSIGNAL\n", __FUNCTION__); 1633 snoop(&dev->dev, "%s: DISCSIGNAL\n", __func__);
1613 ret = proc_disconnectsignal(ps, p); 1634 ret = proc_disconnectsignal(ps, p);
1614 break; 1635 break;
1615 1636
1616 case USBDEVFS_CLAIMINTERFACE: 1637 case USBDEVFS_CLAIMINTERFACE:
1617 snoop(&dev->dev, "%s: CLAIMINTERFACE\n", __FUNCTION__); 1638 snoop(&dev->dev, "%s: CLAIMINTERFACE\n", __func__);
1618 ret = proc_claiminterface(ps, p); 1639 ret = proc_claiminterface(ps, p);
1619 break; 1640 break;
1620 1641
1621 case USBDEVFS_RELEASEINTERFACE: 1642 case USBDEVFS_RELEASEINTERFACE:
1622 snoop(&dev->dev, "%s: RELEASEINTERFACE\n", __FUNCTION__); 1643 snoop(&dev->dev, "%s: RELEASEINTERFACE\n", __func__);
1623 ret = proc_releaseinterface(ps, p); 1644 ret = proc_releaseinterface(ps, p);
1624 break; 1645 break;
1625 1646
1626 case USBDEVFS_IOCTL: 1647 case USBDEVFS_IOCTL:
1627 snoop(&dev->dev, "%s: IOCTL\n", __FUNCTION__); 1648 snoop(&dev->dev, "%s: IOCTL\n", __func__);
1628 ret = proc_ioctl_default(ps, p); 1649 ret = proc_ioctl_default(ps, p);
1629 break; 1650 break;
1630 } 1651 }
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index 801b6f142fa..1e56f1cfa6d 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -157,7 +157,7 @@ static int usb_probe_device(struct device *dev)
157 struct usb_device *udev; 157 struct usb_device *udev;
158 int error = -ENODEV; 158 int error = -ENODEV;
159 159
160 dev_dbg(dev, "%s\n", __FUNCTION__); 160 dev_dbg(dev, "%s\n", __func__);
161 161
162 if (!is_usb_device(dev)) /* Sanity check */ 162 if (!is_usb_device(dev)) /* Sanity check */
163 return error; 163 return error;
@@ -194,7 +194,7 @@ static int usb_probe_interface(struct device *dev)
194 const struct usb_device_id *id; 194 const struct usb_device_id *id;
195 int error = -ENODEV; 195 int error = -ENODEV;
196 196
197 dev_dbg(dev, "%s\n", __FUNCTION__); 197 dev_dbg(dev, "%s\n", __func__);
198 198
199 if (is_usb_device(dev)) /* Sanity check */ 199 if (is_usb_device(dev)) /* Sanity check */
200 return error; 200 return error;
@@ -211,7 +211,7 @@ static int usb_probe_interface(struct device *dev)
211 if (!id) 211 if (!id)
212 id = usb_match_dynamic_id(intf, driver); 212 id = usb_match_dynamic_id(intf, driver);
213 if (id) { 213 if (id) {
214 dev_dbg(dev, "%s - got id\n", __FUNCTION__); 214 dev_dbg(dev, "%s - got id\n", __func__);
215 215
216 error = usb_autoresume_device(udev); 216 error = usb_autoresume_device(udev);
217 if (error) 217 if (error)
@@ -793,9 +793,7 @@ static int usb_suspend_device(struct usb_device *udev, pm_message_t msg)
793 status = udriver->suspend(udev, msg); 793 status = udriver->suspend(udev, msg);
794 794
795 done: 795 done:
796 dev_vdbg(&udev->dev, "%s: status %d\n", __FUNCTION__, status); 796 dev_vdbg(&udev->dev, "%s: status %d\n", __func__, status);
797 if (status == 0)
798 udev->dev.power.power_state.event = msg.event;
799 return status; 797 return status;
800} 798}
801 799
@@ -823,11 +821,9 @@ static int usb_resume_device(struct usb_device *udev)
823 status = udriver->resume(udev); 821 status = udriver->resume(udev);
824 822
825 done: 823 done:
826 dev_vdbg(&udev->dev, "%s: status %d\n", __FUNCTION__, status); 824 dev_vdbg(&udev->dev, "%s: status %d\n", __func__, status);
827 if (status == 0) { 825 if (status == 0)
828 udev->autoresume_disabled = 0; 826 udev->autoresume_disabled = 0;
829 udev->dev.power.power_state.event = PM_EVENT_ON;
830 }
831 return status; 827 return status;
832} 828}
833 829
@@ -864,7 +860,7 @@ static int usb_suspend_interface(struct usb_interface *intf, pm_message_t msg)
864 } 860 }
865 861
866 done: 862 done:
867 dev_vdbg(&intf->dev, "%s: status %d\n", __FUNCTION__, status); 863 dev_vdbg(&intf->dev, "%s: status %d\n", __func__, status);
868 return status; 864 return status;
869} 865}
870 866
@@ -914,7 +910,7 @@ static int usb_resume_interface(struct usb_interface *intf, int reset_resume)
914 } 910 }
915 911
916done: 912done:
917 dev_vdbg(&intf->dev, "%s: status %d\n", __FUNCTION__, status); 913 dev_vdbg(&intf->dev, "%s: status %d\n", __func__, status);
918 if (status == 0) 914 if (status == 0)
919 mark_active(intf); 915 mark_active(intf);
920 916
@@ -936,7 +932,6 @@ static int autosuspend_check(struct usb_device *udev, int reschedule)
936 * is disabled. Also fail if any interfaces require remote wakeup 932 * is disabled. Also fail if any interfaces require remote wakeup
937 * but it isn't available. 933 * but it isn't available.
938 */ 934 */
939 udev->do_remote_wakeup = device_may_wakeup(&udev->dev);
940 if (udev->pm_usage_cnt > 0) 935 if (udev->pm_usage_cnt > 0)
941 return -EBUSY; 936 return -EBUSY;
942 if (udev->autosuspend_delay < 0 || udev->autosuspend_disabled) 937 if (udev->autosuspend_delay < 0 || udev->autosuspend_disabled)
@@ -1098,7 +1093,7 @@ static int usb_suspend_both(struct usb_device *udev, pm_message_t msg)
1098 } 1093 }
1099 1094
1100 done: 1095 done:
1101 dev_vdbg(&udev->dev, "%s: status %d\n", __FUNCTION__, status); 1096 dev_vdbg(&udev->dev, "%s: status %d\n", __func__, status);
1102 return status; 1097 return status;
1103} 1098}
1104 1099
@@ -1180,8 +1175,7 @@ static int usb_resume_both(struct usb_device *udev)
1180 } 1175 }
1181 } else { 1176 } else {
1182 1177
1183 /* Needed for setting udev->dev.power.power_state.event, 1178 /* Needed for reset-resume */
1184 * for possible debugging message, and for reset_resume. */
1185 status = usb_resume_device(udev); 1179 status = usb_resume_device(udev);
1186 } 1180 }
1187 1181
@@ -1193,8 +1187,9 @@ static int usb_resume_both(struct usb_device *udev)
1193 } 1187 }
1194 1188
1195 done: 1189 done:
1196 dev_vdbg(&udev->dev, "%s: status %d\n", __FUNCTION__, status); 1190 dev_vdbg(&udev->dev, "%s: status %d\n", __func__, status);
1197 udev->reset_resume = 0; 1191 if (!status)
1192 udev->reset_resume = 0;
1198 return status; 1193 return status;
1199} 1194}
1200 1195
@@ -1262,7 +1257,7 @@ void usb_autosuspend_device(struct usb_device *udev)
1262 1257
1263 status = usb_autopm_do_device(udev, -1); 1258 status = usb_autopm_do_device(udev, -1);
1264 dev_vdbg(&udev->dev, "%s: cnt %d\n", 1259 dev_vdbg(&udev->dev, "%s: cnt %d\n",
1265 __FUNCTION__, udev->pm_usage_cnt); 1260 __func__, udev->pm_usage_cnt);
1266} 1261}
1267 1262
1268/** 1263/**
@@ -1282,7 +1277,7 @@ void usb_try_autosuspend_device(struct usb_device *udev)
1282{ 1277{
1283 usb_autopm_do_device(udev, 0); 1278 usb_autopm_do_device(udev, 0);
1284 dev_vdbg(&udev->dev, "%s: cnt %d\n", 1279 dev_vdbg(&udev->dev, "%s: cnt %d\n",
1285 __FUNCTION__, udev->pm_usage_cnt); 1280 __func__, udev->pm_usage_cnt);
1286} 1281}
1287 1282
1288/** 1283/**
@@ -1310,7 +1305,7 @@ int usb_autoresume_device(struct usb_device *udev)
1310 1305
1311 status = usb_autopm_do_device(udev, 1); 1306 status = usb_autopm_do_device(udev, 1);
1312 dev_vdbg(&udev->dev, "%s: status %d cnt %d\n", 1307 dev_vdbg(&udev->dev, "%s: status %d cnt %d\n",
1313 __FUNCTION__, status, udev->pm_usage_cnt); 1308 __func__, status, udev->pm_usage_cnt);
1314 return status; 1309 return status;
1315} 1310}
1316 1311
@@ -1382,7 +1377,7 @@ void usb_autopm_put_interface(struct usb_interface *intf)
1382 1377
1383 status = usb_autopm_do_interface(intf, -1); 1378 status = usb_autopm_do_interface(intf, -1);
1384 dev_vdbg(&intf->dev, "%s: status %d cnt %d\n", 1379 dev_vdbg(&intf->dev, "%s: status %d cnt %d\n",
1385 __FUNCTION__, status, intf->pm_usage_cnt); 1380 __func__, status, intf->pm_usage_cnt);
1386} 1381}
1387EXPORT_SYMBOL_GPL(usb_autopm_put_interface); 1382EXPORT_SYMBOL_GPL(usb_autopm_put_interface);
1388 1383
@@ -1426,7 +1421,7 @@ int usb_autopm_get_interface(struct usb_interface *intf)
1426 1421
1427 status = usb_autopm_do_interface(intf, 1); 1422 status = usb_autopm_do_interface(intf, 1);
1428 dev_vdbg(&intf->dev, "%s: status %d cnt %d\n", 1423 dev_vdbg(&intf->dev, "%s: status %d cnt %d\n",
1429 __FUNCTION__, status, intf->pm_usage_cnt); 1424 __func__, status, intf->pm_usage_cnt);
1430 return status; 1425 return status;
1431} 1426}
1432EXPORT_SYMBOL_GPL(usb_autopm_get_interface); 1427EXPORT_SYMBOL_GPL(usb_autopm_get_interface);
@@ -1448,7 +1443,7 @@ int usb_autopm_set_interface(struct usb_interface *intf)
1448 1443
1449 status = usb_autopm_do_interface(intf, 0); 1444 status = usb_autopm_do_interface(intf, 0);
1450 dev_vdbg(&intf->dev, "%s: status %d cnt %d\n", 1445 dev_vdbg(&intf->dev, "%s: status %d cnt %d\n",
1451 __FUNCTION__, status, intf->pm_usage_cnt); 1446 __func__, status, intf->pm_usage_cnt);
1452 return status; 1447 return status;
1453} 1448}
1454EXPORT_SYMBOL_GPL(usb_autopm_set_interface); 1449EXPORT_SYMBOL_GPL(usb_autopm_set_interface);
@@ -1523,9 +1518,14 @@ static int usb_suspend(struct device *dev, pm_message_t message)
1523 udev = to_usb_device(dev); 1518 udev = to_usb_device(dev);
1524 1519
1525 /* If udev is already suspended, we can skip this suspend and 1520 /* If udev is already suspended, we can skip this suspend and
1526 * we should also skip the upcoming system resume. */ 1521 * we should also skip the upcoming system resume. High-speed
1522 * root hubs are an exception; they need to resume whenever the
1523 * system wakes up in order for USB-PERSIST port handover to work
1524 * properly.
1525 */
1527 if (udev->state == USB_STATE_SUSPENDED) { 1526 if (udev->state == USB_STATE_SUSPENDED) {
1528 udev->skip_sys_resume = 1; 1527 if (udev->parent || udev->speed != USB_SPEED_HIGH)
1528 udev->skip_sys_resume = 1;
1529 return 0; 1529 return 0;
1530 } 1530 }
1531 1531
diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c
index 84760ddbc33..5b87ae7f0a6 100644
--- a/drivers/usb/core/hcd-pci.c
+++ b/drivers/usb/core/hcd-pci.c
@@ -73,7 +73,6 @@ int usb_hcd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
73 if (pci_enable_device(dev) < 0) 73 if (pci_enable_device(dev) < 0)
74 return -ENODEV; 74 return -ENODEV;
75 dev->current_state = PCI_D0; 75 dev->current_state = PCI_D0;
76 dev->dev.power.power_state = PMSG_ON;
77 76
78 if (!dev->irq) { 77 if (!dev->irq) {
79 dev_err(&dev->dev, 78 dev_err(&dev->dev,
@@ -216,9 +215,9 @@ int usb_hcd_pci_suspend(struct pci_dev *dev, pm_message_t message)
216 hcd->state == HC_STATE_HALT)) 215 hcd->state == HC_STATE_HALT))
217 return -EBUSY; 216 return -EBUSY;
218 217
219 if (hcd->driver->suspend) { 218 if (hcd->driver->pci_suspend) {
220 retval = hcd->driver->suspend(hcd, message); 219 retval = hcd->driver->pci_suspend(hcd, message);
221 suspend_report_result(hcd->driver->suspend, retval); 220 suspend_report_result(hcd->driver->pci_suspend, retval);
222 if (retval) 221 if (retval)
223 goto done; 222 goto done;
224 } 223 }
@@ -302,8 +301,6 @@ int usb_hcd_pci_suspend(struct pci_dev *dev, pm_message_t message)
302 301
303done: 302done:
304 if (retval == 0) { 303 if (retval == 0) {
305 dev->dev.power.power_state = PMSG_SUSPEND;
306
307#ifdef CONFIG_PPC_PMAC 304#ifdef CONFIG_PPC_PMAC
308 /* Disable ASIC clocks for USB */ 305 /* Disable ASIC clocks for USB */
309 if (machine_is(powermac)) { 306 if (machine_is(powermac)) {
@@ -406,12 +403,10 @@ int usb_hcd_pci_resume(struct pci_dev *dev)
406 pci_set_master(dev); 403 pci_set_master(dev);
407 pci_restore_state(dev); 404 pci_restore_state(dev);
408 405
409 dev->dev.power.power_state = PMSG_ON;
410
411 clear_bit(HCD_FLAG_SAW_IRQ, &hcd->flags); 406 clear_bit(HCD_FLAG_SAW_IRQ, &hcd->flags);
412 407
413 if (hcd->driver->resume) { 408 if (hcd->driver->pci_resume) {
414 retval = hcd->driver->resume(hcd); 409 retval = hcd->driver->pci_resume(hcd);
415 if (retval) { 410 if (retval) {
416 dev_err(hcd->self.controller, 411 dev_err(hcd->self.controller,
417 "PCI post-resume error %d!\n", retval); 412 "PCI post-resume error %d!\n", retval);
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index e52ed1663b3..bf10e9c4195 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -129,7 +129,7 @@ static const u8 usb2_rh_dev_descriptor [18] = {
129 129
130 0x09, /* __u8 bDeviceClass; HUB_CLASSCODE */ 130 0x09, /* __u8 bDeviceClass; HUB_CLASSCODE */
131 0x00, /* __u8 bDeviceSubClass; */ 131 0x00, /* __u8 bDeviceSubClass; */
132 0x01, /* __u8 bDeviceProtocol; [ usb 2.0 single TT ]*/ 132 0x00, /* __u8 bDeviceProtocol; [ usb 2.0 no TT ] */
133 0x40, /* __u8 bMaxPacketSize0; 64 Bytes */ 133 0x40, /* __u8 bMaxPacketSize0; 64 Bytes */
134 134
135 0x6b, 0x1d, /* __le16 idVendor; Linux Foundation */ 135 0x6b, 0x1d, /* __le16 idVendor; Linux Foundation */
@@ -291,7 +291,6 @@ static int ascii2utf (char *s, u8 *utf, int utfmax)
291 * rh_string - provides manufacturer, product and serial strings for root hub 291 * rh_string - provides manufacturer, product and serial strings for root hub
292 * @id: the string ID number (1: serial number, 2: product, 3: vendor) 292 * @id: the string ID number (1: serial number, 2: product, 3: vendor)
293 * @hcd: the host controller for this root hub 293 * @hcd: the host controller for this root hub
294 * @type: string describing our driver
295 * @data: return packet in UTF-16 LE 294 * @data: return packet in UTF-16 LE
296 * @len: length of the return packet 295 * @len: length of the return packet
297 * 296 *
@@ -355,9 +354,10 @@ static int rh_call_control (struct usb_hcd *hcd, struct urb *urb)
355 __attribute__((aligned(4))); 354 __attribute__((aligned(4)));
356 const u8 *bufp = tbuf; 355 const u8 *bufp = tbuf;
357 int len = 0; 356 int len = 0;
358 int patch_wakeup = 0;
359 int status; 357 int status;
360 int n; 358 int n;
359 u8 patch_wakeup = 0;
360 u8 patch_protocol = 0;
361 361
362 might_sleep(); 362 might_sleep();
363 363
@@ -434,6 +434,8 @@ static int rh_call_control (struct usb_hcd *hcd, struct urb *urb)
434 else 434 else
435 goto error; 435 goto error;
436 len = 18; 436 len = 18;
437 if (hcd->has_tt)
438 patch_protocol = 1;
437 break; 439 break;
438 case USB_DT_CONFIG << 8: 440 case USB_DT_CONFIG << 8:
439 if (hcd->driver->flags & HCD_USB2) { 441 if (hcd->driver->flags & HCD_USB2) {
@@ -528,6 +530,13 @@ error:
528 bmAttributes)) 530 bmAttributes))
529 ((struct usb_config_descriptor *)ubuf)->bmAttributes 531 ((struct usb_config_descriptor *)ubuf)->bmAttributes
530 |= USB_CONFIG_ATT_WAKEUP; 532 |= USB_CONFIG_ATT_WAKEUP;
533
534 /* report whether RH hardware has an integrated TT */
535 if (patch_protocol &&
536 len > offsetof(struct usb_device_descriptor,
537 bDeviceProtocol))
538 ((struct usb_device_descriptor *) ubuf)->
539 bDeviceProtocol = 1;
531 } 540 }
532 541
533 /* any errors get returned through the urb completion */ 542 /* any errors get returned through the urb completion */
@@ -915,15 +924,6 @@ static int register_root_hub(struct usb_hcd *hcd)
915 return retval; 924 return retval;
916} 925}
917 926
918void usb_enable_root_hub_irq (struct usb_bus *bus)
919{
920 struct usb_hcd *hcd;
921
922 hcd = container_of (bus, struct usb_hcd, self);
923 if (hcd->driver->hub_irq_enable && hcd->state != HC_STATE_HALT)
924 hcd->driver->hub_irq_enable (hcd);
925}
926
927 927
928/*-------------------------------------------------------------------------*/ 928/*-------------------------------------------------------------------------*/
929 929
@@ -1677,7 +1677,6 @@ EXPORT_SYMBOL_GPL(usb_bus_start_enum);
1677 * usb_hcd_irq - hook IRQs to HCD framework (bus glue) 1677 * usb_hcd_irq - hook IRQs to HCD framework (bus glue)
1678 * @irq: the IRQ being raised 1678 * @irq: the IRQ being raised
1679 * @__hcd: pointer to the HCD whose IRQ is being signaled 1679 * @__hcd: pointer to the HCD whose IRQ is being signaled
1680 * @r: saved hardware registers
1681 * 1680 *
1682 * If the controller isn't HALTed, calls the driver's irq handler. 1681 * If the controller isn't HALTed, calls the driver's irq handler.
1683 * Checks whether the controller is now dead. 1682 * Checks whether the controller is now dead.
diff --git a/drivers/usb/core/hcd.h b/drivers/usb/core/hcd.h
index 2d1c3d5e47b..1e4b81e9eb5 100644
--- a/drivers/usb/core/hcd.h
+++ b/drivers/usb/core/hcd.h
@@ -28,7 +28,7 @@
28/* 28/*
29 * USB Packet IDs (PIDs) 29 * USB Packet IDs (PIDs)
30 */ 30 */
31#define USB_PID_UNDEF_0 0xf0 31#define USB_PID_EXT 0xf0 /* USB 2.0 LPM ECN */
32#define USB_PID_OUT 0xe1 32#define USB_PID_OUT 0xe1
33#define USB_PID_ACK 0xd2 33#define USB_PID_ACK 0xd2
34#define USB_PID_DATA0 0xc3 34#define USB_PID_DATA0 0xc3
@@ -99,6 +99,7 @@ struct usb_hcd {
99 unsigned poll_pending:1; /* status has changed? */ 99 unsigned poll_pending:1; /* status has changed? */
100 unsigned wireless:1; /* Wireless USB HCD */ 100 unsigned wireless:1; /* Wireless USB HCD */
101 unsigned authorized_default:1; 101 unsigned authorized_default:1;
102 unsigned has_tt:1; /* Integrated TT in root hub */
102 103
103 int irq; /* irq allocated */ 104 int irq; /* irq allocated */
104 void __iomem *regs; /* device memory/io */ 105 void __iomem *regs; /* device memory/io */
@@ -177,10 +178,10 @@ struct hc_driver {
177 * a whole, not just the root hub; they're for PCI bus glue. 178 * a whole, not just the root hub; they're for PCI bus glue.
178 */ 179 */
179 /* called after suspending the hub, before entering D3 etc */ 180 /* called after suspending the hub, before entering D3 etc */
180 int (*suspend) (struct usb_hcd *hcd, pm_message_t message); 181 int (*pci_suspend) (struct usb_hcd *hcd, pm_message_t message);
181 182
182 /* called after entering D0 (etc), before resuming the hub */ 183 /* called after entering D0 (etc), before resuming the hub */
183 int (*resume) (struct usb_hcd *hcd); 184 int (*pci_resume) (struct usb_hcd *hcd);
184 185
185 /* cleanly make HCD stop writing memory and doing I/O */ 186 /* cleanly make HCD stop writing memory and doing I/O */
186 void (*stop) (struct usb_hcd *hcd); 187 void (*stop) (struct usb_hcd *hcd);
@@ -209,8 +210,6 @@ struct hc_driver {
209 int (*bus_suspend)(struct usb_hcd *); 210 int (*bus_suspend)(struct usb_hcd *);
210 int (*bus_resume)(struct usb_hcd *); 211 int (*bus_resume)(struct usb_hcd *);
211 int (*start_port_reset)(struct usb_hcd *, unsigned port_num); 212 int (*start_port_reset)(struct usb_hcd *, unsigned port_num);
212 void (*hub_irq_enable)(struct usb_hcd *);
213 /* Needed only if port-change IRQs are level-triggered */
214 213
215 /* force handover of high-speed port to full-speed companion */ 214 /* force handover of high-speed port to full-speed companion */
216 void (*relinquish_port)(struct usb_hcd *, int); 215 void (*relinquish_port)(struct usb_hcd *, int);
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 57aeca160f3..eb57fcc701d 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -30,12 +30,6 @@
30#include "hcd.h" 30#include "hcd.h"
31#include "hub.h" 31#include "hub.h"
32 32
33#ifdef CONFIG_USB_PERSIST
34#define USB_PERSIST 1
35#else
36#define USB_PERSIST 0
37#endif
38
39/* if we are in debug mode, always announce new devices */ 33/* if we are in debug mode, always announce new devices */
40#ifdef DEBUG 34#ifdef DEBUG
41#ifndef CONFIG_USB_ANNOUNCE_NEW_DEVICES 35#ifndef CONFIG_USB_ANNOUNCE_NEW_DEVICES
@@ -333,6 +327,27 @@ static int get_port_status(struct usb_device *hdev, int port1,
333 return status; 327 return status;
334} 328}
335 329
330static int hub_port_status(struct usb_hub *hub, int port1,
331 u16 *status, u16 *change)
332{
333 int ret;
334
335 mutex_lock(&hub->status_mutex);
336 ret = get_port_status(hub->hdev, port1, &hub->status->port);
337 if (ret < 4) {
338 dev_err(hub->intfdev,
339 "%s failed (err = %d)\n", __func__, ret);
340 if (ret >= 0)
341 ret = -EIO;
342 } else {
343 *status = le16_to_cpu(hub->status->port.wPortStatus);
344 *change = le16_to_cpu(hub->status->port.wPortChange);
345 ret = 0;
346 }
347 mutex_unlock(&hub->status_mutex);
348 return ret;
349}
350
336static void kick_khubd(struct usb_hub *hub) 351static void kick_khubd(struct usb_hub *hub)
337{ 352{
338 unsigned long flags; 353 unsigned long flags;
@@ -560,7 +575,7 @@ static int hub_hub_status(struct usb_hub *hub,
560 ret = get_hub_status(hub->hdev, &hub->status->hub); 575 ret = get_hub_status(hub->hdev, &hub->status->hub);
561 if (ret < 0) 576 if (ret < 0)
562 dev_err (hub->intfdev, 577 dev_err (hub->intfdev,
563 "%s failed (err = %d)\n", __FUNCTION__, ret); 578 "%s failed (err = %d)\n", __func__, ret);
564 else { 579 else {
565 *status = le16_to_cpu(hub->status->hub.wHubStatus); 580 *status = le16_to_cpu(hub->status->hub.wHubStatus);
566 *change = le16_to_cpu(hub->status->hub.wHubChange); 581 *change = le16_to_cpu(hub->status->hub.wHubChange);
@@ -610,9 +625,8 @@ static void hub_port_logical_disconnect(struct usb_hub *hub, int port1)
610} 625}
611 626
612/* caller has locked the hub device */ 627/* caller has locked the hub device */
613static int hub_pre_reset(struct usb_interface *intf) 628static void hub_stop(struct usb_hub *hub)
614{ 629{
615 struct usb_hub *hub = usb_get_intfdata(intf);
616 struct usb_device *hdev = hub->hdev; 630 struct usb_device *hdev = hub->hdev;
617 int i; 631 int i;
618 632
@@ -622,6 +636,89 @@ static int hub_pre_reset(struct usb_interface *intf)
622 usb_disconnect(&hdev->children[i]); 636 usb_disconnect(&hdev->children[i]);
623 } 637 }
624 hub_quiesce(hub); 638 hub_quiesce(hub);
639}
640
641#define HUB_RESET 1
642#define HUB_RESUME 2
643#define HUB_RESET_RESUME 3
644
645#ifdef CONFIG_PM
646
647static void hub_restart(struct usb_hub *hub, int type)
648{
649 struct usb_device *hdev = hub->hdev;
650 int port1;
651
652 /* Check each of the children to see if they require
653 * USB-PERSIST handling or disconnection. Also check
654 * each unoccupied port to make sure it is still disabled.
655 */
656 for (port1 = 1; port1 <= hdev->maxchild; ++port1) {
657 struct usb_device *udev = hdev->children[port1-1];
658 int status = 0;
659 u16 portstatus, portchange;
660
661 if (!udev || udev->state == USB_STATE_NOTATTACHED) {
662 if (type != HUB_RESET) {
663 status = hub_port_status(hub, port1,
664 &portstatus, &portchange);
665 if (status == 0 && (portstatus &
666 USB_PORT_STAT_ENABLE))
667 clear_port_feature(hdev, port1,
668 USB_PORT_FEAT_ENABLE);
669 }
670 continue;
671 }
672
673 /* Was the power session lost while we were suspended? */
674 switch (type) {
675 case HUB_RESET_RESUME:
676 portstatus = 0;
677 portchange = USB_PORT_STAT_C_CONNECTION;
678 break;
679
680 case HUB_RESET:
681 case HUB_RESUME:
682 status = hub_port_status(hub, port1,
683 &portstatus, &portchange);
684 break;
685 }
686
687 /* For "USB_PERSIST"-enabled children we must
688 * mark the child device for reset-resume and
689 * turn off the various status changes to prevent
690 * khubd from disconnecting it later.
691 */
692 if (udev->persist_enabled && status == 0 &&
693 !(portstatus & USB_PORT_STAT_ENABLE)) {
694 if (portchange & USB_PORT_STAT_C_ENABLE)
695 clear_port_feature(hub->hdev, port1,
696 USB_PORT_FEAT_C_ENABLE);
697 if (portchange & USB_PORT_STAT_C_CONNECTION)
698 clear_port_feature(hub->hdev, port1,
699 USB_PORT_FEAT_C_CONNECTION);
700 udev->reset_resume = 1;
701 }
702
703 /* Otherwise for a reset_resume we must disconnect the child,
704 * but as we may not lock the child device here
705 * we have to do a "logical" disconnect.
706 */
707 else if (type == HUB_RESET_RESUME)
708 hub_port_logical_disconnect(hub, port1);
709 }
710
711 hub_activate(hub);
712}
713
714#endif /* CONFIG_PM */
715
716/* caller has locked the hub device */
717static int hub_pre_reset(struct usb_interface *intf)
718{
719 struct usb_hub *hub = usb_get_intfdata(intf);
720
721 hub_stop(hub);
625 return 0; 722 return 0;
626} 723}
627 724
@@ -910,7 +1007,7 @@ static void hub_disconnect(struct usb_interface *intf)
910 1007
911 /* Disconnect all children and quiesce the hub */ 1008 /* Disconnect all children and quiesce the hub */
912 hub->error = 0; 1009 hub->error = 0;
913 hub_pre_reset(intf); 1010 hub_stop(hub);
914 1011
915 usb_set_intfdata (intf, NULL); 1012 usb_set_intfdata (intf, NULL);
916 1013
@@ -1098,21 +1195,42 @@ void usb_set_device_state(struct usb_device *udev,
1098 spin_unlock_irqrestore(&device_state_lock, flags); 1195 spin_unlock_irqrestore(&device_state_lock, flags);
1099} 1196}
1100 1197
1198/*
1199 * WUSB devices are simple: they have no hubs behind, so the mapping
1200 * device <-> virtual port number becomes 1:1. Why? to simplify the
1201 * life of the device connection logic in
1202 * drivers/usb/wusbcore/devconnect.c. When we do the initial secret
1203 * handshake we need to assign a temporary address in the unauthorized
1204 * space. For simplicity we use the first virtual port number found to
1205 * be free [drivers/usb/wusbcore/devconnect.c:wusbhc_devconnect_ack()]
1206 * and that becomes it's address [X < 128] or its unauthorized address
1207 * [X | 0x80].
1208 *
1209 * We add 1 as an offset to the one-based USB-stack port number
1210 * (zero-based wusb virtual port index) for two reasons: (a) dev addr
1211 * 0 is reserved by USB for default address; (b) Linux's USB stack
1212 * uses always #1 for the root hub of the controller. So USB stack's
1213 * port #1, which is wusb virtual-port #0 has address #2.
1214 */
1101static void choose_address(struct usb_device *udev) 1215static void choose_address(struct usb_device *udev)
1102{ 1216{
1103 int devnum; 1217 int devnum;
1104 struct usb_bus *bus = udev->bus; 1218 struct usb_bus *bus = udev->bus;
1105 1219
1106 /* If khubd ever becomes multithreaded, this will need a lock */ 1220 /* If khubd ever becomes multithreaded, this will need a lock */
1107 1221 if (udev->wusb) {
1108 /* Try to allocate the next devnum beginning at bus->devnum_next. */ 1222 devnum = udev->portnum + 1;
1109 devnum = find_next_zero_bit(bus->devmap.devicemap, 128, 1223 BUG_ON(test_bit(devnum, bus->devmap.devicemap));
1110 bus->devnum_next); 1224 } else {
1111 if (devnum >= 128) 1225 /* Try to allocate the next devnum beginning at
1112 devnum = find_next_zero_bit(bus->devmap.devicemap, 128, 1); 1226 * bus->devnum_next. */
1113 1227 devnum = find_next_zero_bit(bus->devmap.devicemap, 128,
1114 bus->devnum_next = ( devnum >= 127 ? 1 : devnum + 1); 1228 bus->devnum_next);
1115 1229 if (devnum >= 128)
1230 devnum = find_next_zero_bit(bus->devmap.devicemap,
1231 128, 1);
1232 bus->devnum_next = ( devnum >= 127 ? 1 : devnum + 1);
1233 }
1116 if (devnum < 128) { 1234 if (devnum < 128) {
1117 set_bit(devnum, bus->devmap.devicemap); 1235 set_bit(devnum, bus->devmap.devicemap);
1118 udev->devnum = devnum; 1236 udev->devnum = devnum;
@@ -1127,6 +1245,13 @@ static void release_address(struct usb_device *udev)
1127 } 1245 }
1128} 1246}
1129 1247
1248static void update_address(struct usb_device *udev, int devnum)
1249{
1250 /* The address for a WUSB device is managed by wusbcore. */
1251 if (!udev->wusb)
1252 udev->devnum = devnum;
1253}
1254
1130#ifdef CONFIG_USB_SUSPEND 1255#ifdef CONFIG_USB_SUSPEND
1131 1256
1132static void usb_stop_pm(struct usb_device *udev) 1257static void usb_stop_pm(struct usb_device *udev)
@@ -1173,7 +1298,7 @@ void usb_disconnect(struct usb_device **pdev)
1173 int i; 1298 int i;
1174 1299
1175 if (!udev) { 1300 if (!udev) {
1176 pr_debug ("%s nodev\n", __FUNCTION__); 1301 pr_debug ("%s nodev\n", __func__);
1177 return; 1302 return;
1178 } 1303 }
1179 1304
@@ -1510,28 +1635,6 @@ out_authorized:
1510} 1635}
1511 1636
1512 1637
1513static int hub_port_status(struct usb_hub *hub, int port1,
1514 u16 *status, u16 *change)
1515{
1516 int ret;
1517
1518 mutex_lock(&hub->status_mutex);
1519 ret = get_port_status(hub->hdev, port1, &hub->status->port);
1520 if (ret < 4) {
1521 dev_err (hub->intfdev,
1522 "%s failed (err = %d)\n", __FUNCTION__, ret);
1523 if (ret >= 0)
1524 ret = -EIO;
1525 } else {
1526 *status = le16_to_cpu(hub->status->port.wPortStatus);
1527 *change = le16_to_cpu(hub->status->port.wPortChange);
1528 ret = 0;
1529 }
1530 mutex_unlock(&hub->status_mutex);
1531 return ret;
1532}
1533
1534
1535/* Returns 1 if @hub is a WUSB root hub, 0 otherwise */ 1638/* Returns 1 if @hub is a WUSB root hub, 0 otherwise */
1536static unsigned hub_is_wusb(struct usb_hub *hub) 1639static unsigned hub_is_wusb(struct usb_hub *hub)
1537{ 1640{
@@ -1637,7 +1740,7 @@ static int hub_port_reset(struct usb_hub *hub, int port1,
1637 case 0: 1740 case 0:
1638 /* TRSTRCY = 10 ms; plus some extra */ 1741 /* TRSTRCY = 10 ms; plus some extra */
1639 msleep(10 + 40); 1742 msleep(10 + 40);
1640 udev->devnum = 0; /* Device now at address 0 */ 1743 update_address(udev, 0);
1641 /* FALL THROUGH */ 1744 /* FALL THROUGH */
1642 case -ENOTCONN: 1745 case -ENOTCONN:
1643 case -ENODEV: 1746 case -ENODEV:
@@ -1842,9 +1945,8 @@ static int finish_port_resume(struct usb_device *udev)
1842 * the host and the device is the same as it was when the device 1945 * the host and the device is the same as it was when the device
1843 * suspended. 1946 * suspended.
1844 * 1947 *
1845 * If CONFIG_USB_PERSIST and @udev->reset_resume are both set then this 1948 * If @udev->reset_resume is set then this routine won't check that the
1846 * routine won't check that the port is still enabled. Furthermore, 1949 * port is still enabled. Furthermore, finish_port_resume() above will
1847 * if @udev->reset_resume is set then finish_port_resume() above will
1848 * reset @udev. The end result is that a broken power session can be 1950 * reset @udev. The end result is that a broken power session can be
1849 * recovered and @udev will appear to persist across a loss of VBUS power. 1951 * recovered and @udev will appear to persist across a loss of VBUS power.
1850 * 1952 *
@@ -1856,8 +1958,8 @@ static int finish_port_resume(struct usb_device *udev)
1856 * to it will be lost. Using the USB_PERSIST facility, the device can be 1958 * to it will be lost. Using the USB_PERSIST facility, the device can be
1857 * made to appear as if it had not disconnected. 1959 * made to appear as if it had not disconnected.
1858 * 1960 *
1859 * This facility is inherently dangerous. Although usb_reset_device() 1961 * This facility can be dangerous. Although usb_reset_device() makes
1860 * makes every effort to insure that the same device is present after the 1962 * every effort to insure that the same device is present after the
1861 * reset as before, it cannot provide a 100% guarantee. Furthermore it's 1963 * reset as before, it cannot provide a 100% guarantee. Furthermore it's
1862 * quite possible for a device to remain unaltered but its media to be 1964 * quite possible for a device to remain unaltered but its media to be
1863 * changed. If the user replaces a flash memory card while the system is 1965 * changed. If the user replaces a flash memory card while the system is
@@ -1902,7 +2004,7 @@ int usb_port_resume(struct usb_device *udev)
1902 status = hub_port_status(hub, port1, &portstatus, &portchange); 2004 status = hub_port_status(hub, port1, &portstatus, &portchange);
1903 2005
1904 SuspendCleared: 2006 SuspendCleared:
1905 if (USB_PERSIST && udev->reset_resume) 2007 if (udev->reset_resume)
1906 want_flags = USB_PORT_STAT_POWER 2008 want_flags = USB_PORT_STAT_POWER
1907 | USB_PORT_STAT_CONNECTION; 2009 | USB_PORT_STAT_CONNECTION;
1908 else 2010 else
@@ -1927,8 +2029,6 @@ int usb_port_resume(struct usb_device *udev)
1927 } 2029 }
1928 2030
1929 clear_bit(port1, hub->busy_bits); 2031 clear_bit(port1, hub->busy_bits);
1930 if (!hub->hdev->parent && !hub->busy_bits[0])
1931 usb_enable_root_hub_irq(hub->hdev->bus);
1932 2032
1933 if (status == 0) 2033 if (status == 0)
1934 status = finish_port_resume(udev); 2034 status = finish_port_resume(udev);
@@ -2000,7 +2100,7 @@ static int hub_suspend(struct usb_interface *intf, pm_message_t msg)
2000 } 2100 }
2001 } 2101 }
2002 2102
2003 dev_dbg(&intf->dev, "%s\n", __FUNCTION__); 2103 dev_dbg(&intf->dev, "%s\n", __func__);
2004 2104
2005 /* stop khubd and related activity */ 2105 /* stop khubd and related activity */
2006 hub_quiesce(hub); 2106 hub_quiesce(hub);
@@ -2009,49 +2109,20 @@ static int hub_suspend(struct usb_interface *intf, pm_message_t msg)
2009 2109
2010static int hub_resume(struct usb_interface *intf) 2110static int hub_resume(struct usb_interface *intf)
2011{ 2111{
2012 struct usb_hub *hub = usb_get_intfdata (intf); 2112 struct usb_hub *hub = usb_get_intfdata(intf);
2013
2014 dev_dbg(&intf->dev, "%s\n", __FUNCTION__);
2015 2113
2016 /* tell khubd to look for changes on this hub */ 2114 dev_dbg(&intf->dev, "%s\n", __func__);
2017 hub_activate(hub); 2115 hub_restart(hub, HUB_RESUME);
2018 return 0; 2116 return 0;
2019} 2117}
2020 2118
2021static int hub_reset_resume(struct usb_interface *intf) 2119static int hub_reset_resume(struct usb_interface *intf)
2022{ 2120{
2023 struct usb_hub *hub = usb_get_intfdata(intf); 2121 struct usb_hub *hub = usb_get_intfdata(intf);
2024 struct usb_device *hdev = hub->hdev;
2025 int port1;
2026 2122
2123 dev_dbg(&intf->dev, "%s\n", __func__);
2027 hub_power_on(hub); 2124 hub_power_on(hub);
2028 2125 hub_restart(hub, HUB_RESET_RESUME);
2029 for (port1 = 1; port1 <= hdev->maxchild; ++port1) {
2030 struct usb_device *child = hdev->children[port1-1];
2031
2032 if (child) {
2033
2034 /* For "USB_PERSIST"-enabled children we must
2035 * mark the child device for reset-resume and
2036 * turn off the connect-change status to prevent
2037 * khubd from disconnecting it later.
2038 */
2039 if (USB_PERSIST && child->persist_enabled) {
2040 child->reset_resume = 1;
2041 clear_port_feature(hdev, port1,
2042 USB_PORT_FEAT_C_CONNECTION);
2043
2044 /* Otherwise we must disconnect the child,
2045 * but as we may not lock the child device here
2046 * we have to do a "logical" disconnect.
2047 */
2048 } else {
2049 hub_port_logical_disconnect(hub, port1);
2050 }
2051 }
2052 }
2053
2054 hub_activate(hub);
2055 return 0; 2126 return 0;
2056} 2127}
2057 2128
@@ -2061,10 +2132,10 @@ static int hub_reset_resume(struct usb_interface *intf)
2061 * 2132 *
2062 * The USB host controller driver calls this function when its root hub 2133 * The USB host controller driver calls this function when its root hub
2063 * is resumed and Vbus power has been interrupted or the controller 2134 * is resumed and Vbus power has been interrupted or the controller
2064 * has been reset. The routine marks @rhdev as having lost power. When 2135 * has been reset. The routine marks @rhdev as having lost power.
2065 * the hub driver is resumed it will take notice; if CONFIG_USB_PERSIST 2136 * When the hub driver is resumed it will take notice and carry out
2066 * is enabled then it will carry out power-session recovery, otherwise 2137 * power-session recovery for all the "USB-PERSIST"-enabled child devices;
2067 * it will disconnect all the child devices. 2138 * the others will be disconnected.
2068 */ 2139 */
2069void usb_root_hub_lost_power(struct usb_device *rhdev) 2140void usb_root_hub_lost_power(struct usb_device *rhdev)
2070{ 2141{
@@ -2147,12 +2218,13 @@ static int hub_port_debounce(struct usb_hub *hub, int port1)
2147 return portstatus; 2218 return portstatus;
2148} 2219}
2149 2220
2150static void ep0_reinit(struct usb_device *udev) 2221void usb_ep0_reinit(struct usb_device *udev)
2151{ 2222{
2152 usb_disable_endpoint(udev, 0 + USB_DIR_IN); 2223 usb_disable_endpoint(udev, 0 + USB_DIR_IN);
2153 usb_disable_endpoint(udev, 0 + USB_DIR_OUT); 2224 usb_disable_endpoint(udev, 0 + USB_DIR_OUT);
2154 usb_enable_endpoint(udev, &udev->ep0); 2225 usb_enable_endpoint(udev, &udev->ep0);
2155} 2226}
2227EXPORT_SYMBOL_GPL(usb_ep0_reinit);
2156 2228
2157#define usb_sndaddr0pipe() (PIPE_CONTROL << 30) 2229#define usb_sndaddr0pipe() (PIPE_CONTROL << 30)
2158#define usb_rcvaddr0pipe() ((PIPE_CONTROL << 30) | USB_DIR_IN) 2230#define usb_rcvaddr0pipe() ((PIPE_CONTROL << 30) | USB_DIR_IN)
@@ -2171,9 +2243,10 @@ static int hub_set_address(struct usb_device *udev, int devnum)
2171 USB_REQ_SET_ADDRESS, 0, devnum, 0, 2243 USB_REQ_SET_ADDRESS, 0, devnum, 0,
2172 NULL, 0, USB_CTRL_SET_TIMEOUT); 2244 NULL, 0, USB_CTRL_SET_TIMEOUT);
2173 if (retval == 0) { 2245 if (retval == 0) {
2174 udev->devnum = devnum; /* Device now using proper address */ 2246 /* Device now using proper address. */
2247 update_address(udev, devnum);
2175 usb_set_device_state(udev, USB_STATE_ADDRESS); 2248 usb_set_device_state(udev, USB_STATE_ADDRESS);
2176 ep0_reinit(udev); 2249 usb_ep0_reinit(udev);
2177 } 2250 }
2178 return retval; 2251 return retval;
2179} 2252}
@@ -2355,26 +2428,33 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
2355#undef GET_DESCRIPTOR_BUFSIZE 2428#undef GET_DESCRIPTOR_BUFSIZE
2356 } 2429 }
2357 2430
2358 for (j = 0; j < SET_ADDRESS_TRIES; ++j) { 2431 /*
2359 retval = hub_set_address(udev, devnum); 2432 * If device is WUSB, we already assigned an
2360 if (retval >= 0) 2433 * unauthorized address in the Connect Ack sequence;
2434 * authorization will assign the final address.
2435 */
2436 if (udev->wusb == 0) {
2437 for (j = 0; j < SET_ADDRESS_TRIES; ++j) {
2438 retval = hub_set_address(udev, devnum);
2439 if (retval >= 0)
2440 break;
2441 msleep(200);
2442 }
2443 if (retval < 0) {
2444 dev_err(&udev->dev,
2445 "device not accepting address %d, error %d\n",
2446 devnum, retval);
2447 goto fail;
2448 }
2449
2450 /* cope with hardware quirkiness:
2451 * - let SET_ADDRESS settle, some device hardware wants it
2452 * - read ep0 maxpacket even for high and low speed,
2453 */
2454 msleep(10);
2455 if (USE_NEW_SCHEME(retry_counter))
2361 break; 2456 break;
2362 msleep(200); 2457 }
2363 }
2364 if (retval < 0) {
2365 dev_err(&udev->dev,
2366 "device not accepting address %d, error %d\n",
2367 devnum, retval);
2368 goto fail;
2369 }
2370
2371 /* cope with hardware quirkiness:
2372 * - let SET_ADDRESS settle, some device hardware wants it
2373 * - read ep0 maxpacket even for high and low speed,
2374 */
2375 msleep(10);
2376 if (USE_NEW_SCHEME(retry_counter))
2377 break;
2378 2458
2379 retval = usb_get_device_descriptor(udev, 8); 2459 retval = usb_get_device_descriptor(udev, 8);
2380 if (retval < 8) { 2460 if (retval < 8) {
@@ -2391,7 +2471,7 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
2391 if (retval) 2471 if (retval)
2392 goto fail; 2472 goto fail;
2393 2473
2394 i = udev->descriptor.bMaxPacketSize0 == 0xff? 2474 i = udev->descriptor.bMaxPacketSize0 == 0xff? /* wusb device? */
2395 512 : udev->descriptor.bMaxPacketSize0; 2475 512 : udev->descriptor.bMaxPacketSize0;
2396 if (le16_to_cpu(udev->ep0.desc.wMaxPacketSize) != i) { 2476 if (le16_to_cpu(udev->ep0.desc.wMaxPacketSize) != i) {
2397 if (udev->speed != USB_SPEED_FULL || 2477 if (udev->speed != USB_SPEED_FULL ||
@@ -2402,7 +2482,7 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
2402 } 2482 }
2403 dev_dbg(&udev->dev, "ep0 maxpacket = %d\n", i); 2483 dev_dbg(&udev->dev, "ep0 maxpacket = %d\n", i);
2404 udev->ep0.desc.wMaxPacketSize = cpu_to_le16(i); 2484 udev->ep0.desc.wMaxPacketSize = cpu_to_le16(i);
2405 ep0_reinit(udev); 2485 usb_ep0_reinit(udev);
2406 } 2486 }
2407 2487
2408 retval = usb_get_device_descriptor(udev, USB_DT_DEVICE_SIZE); 2488 retval = usb_get_device_descriptor(udev, USB_DT_DEVICE_SIZE);
@@ -2419,7 +2499,7 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
2419fail: 2499fail:
2420 if (retval) { 2500 if (retval) {
2421 hub_port_disable(hub, port1, 0); 2501 hub_port_disable(hub, port1, 0);
2422 udev->devnum = devnum; /* for disconnect processing */ 2502 update_address(udev, devnum); /* for disconnect processing */
2423 } 2503 }
2424 mutex_unlock(&usb_address0_mutex); 2504 mutex_unlock(&usb_address0_mutex);
2425 return retval; 2505 return retval;
@@ -2568,6 +2648,7 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
2568 udev->speed = USB_SPEED_UNKNOWN; 2648 udev->speed = USB_SPEED_UNKNOWN;
2569 udev->bus_mA = hub->mA_per_port; 2649 udev->bus_mA = hub->mA_per_port;
2570 udev->level = hdev->level + 1; 2650 udev->level = hdev->level + 1;
2651 udev->wusb = hub_is_wusb(hub);
2571 2652
2572 /* set the address */ 2653 /* set the address */
2573 choose_address(udev); 2654 choose_address(udev);
@@ -2657,12 +2738,13 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
2657loop_disable: 2738loop_disable:
2658 hub_port_disable(hub, port1, 1); 2739 hub_port_disable(hub, port1, 1);
2659loop: 2740loop:
2660 ep0_reinit(udev); 2741 usb_ep0_reinit(udev);
2661 release_address(udev); 2742 release_address(udev);
2662 usb_put_dev(udev); 2743 usb_put_dev(udev);
2663 if ((status == -ENOTCONN) || (status == -ENOTSUPP)) 2744 if ((status == -ENOTCONN) || (status == -ENOTSUPP))
2664 break; 2745 break;
2665 } 2746 }
2747 dev_err(hub_dev, "unable to enumerate USB device on port %d\n", port1);
2666 2748
2667done: 2749done:
2668 hub_port_disable(hub, port1, 1); 2750 hub_port_disable(hub, port1, 1);
@@ -2726,7 +2808,7 @@ static void hub_events(void)
2726 /* If the hub has died, clean up after it */ 2808 /* If the hub has died, clean up after it */
2727 if (hdev->state == USB_STATE_NOTATTACHED) { 2809 if (hdev->state == USB_STATE_NOTATTACHED) {
2728 hub->error = -ENODEV; 2810 hub->error = -ENODEV;
2729 hub_pre_reset(intf); 2811 hub_stop(hub);
2730 goto loop; 2812 goto loop;
2731 } 2813 }
2732 2814
@@ -2872,11 +2954,6 @@ static void hub_events(void)
2872 2954
2873 hub->activating = 0; 2955 hub->activating = 0;
2874 2956
2875 /* If this is a root hub, tell the HCD it's okay to
2876 * re-enable port-change interrupts now. */
2877 if (!hdev->parent && !hub->busy_bits[0])
2878 usb_enable_root_hub_irq(hdev->bus);
2879
2880loop_autopm: 2957loop_autopm:
2881 /* Allow autosuspend if we're not going to run again */ 2958 /* Allow autosuspend if we're not going to run again */
2882 if (list_empty(&hub->event_list)) 2959 if (list_empty(&hub->event_list))
@@ -2890,7 +2967,13 @@ loop:
2890 2967
2891static int hub_thread(void *__unused) 2968static int hub_thread(void *__unused)
2892{ 2969{
2970 /* khubd needs to be freezable to avoid intefering with USB-PERSIST
2971 * port handover. Otherwise it might see that a full-speed device
2972 * was gone before the EHCI controller had handed its port over to
2973 * the companion full-speed controller.
2974 */
2893 set_freezable(); 2975 set_freezable();
2976
2894 do { 2977 do {
2895 hub_events(); 2978 hub_events();
2896 wait_event_freezable(khubd_wait, 2979 wait_event_freezable(khubd_wait,
@@ -2959,16 +3042,36 @@ void usb_hub_cleanup(void)
2959 usb_deregister(&hub_driver); 3042 usb_deregister(&hub_driver);
2960} /* usb_hub_cleanup() */ 3043} /* usb_hub_cleanup() */
2961 3044
2962static int config_descriptors_changed(struct usb_device *udev) 3045static int descriptors_changed(struct usb_device *udev,
3046 struct usb_device_descriptor *old_device_descriptor)
2963{ 3047{
2964 unsigned index; 3048 int changed = 0;
2965 unsigned len = 0; 3049 unsigned index;
2966 struct usb_config_descriptor *buf; 3050 unsigned serial_len = 0;
3051 unsigned len;
3052 unsigned old_length;
3053 int length;
3054 char *buf;
3055
3056 if (memcmp(&udev->descriptor, old_device_descriptor,
3057 sizeof(*old_device_descriptor)) != 0)
3058 return 1;
2967 3059
3060 /* Since the idVendor, idProduct, and bcdDevice values in the
3061 * device descriptor haven't changed, we will assume the
3062 * Manufacturer and Product strings haven't changed either.
3063 * But the SerialNumber string could be different (e.g., a
3064 * different flash card of the same brand).
3065 */
3066 if (udev->serial)
3067 serial_len = strlen(udev->serial) + 1;
3068
3069 len = serial_len;
2968 for (index = 0; index < udev->descriptor.bNumConfigurations; index++) { 3070 for (index = 0; index < udev->descriptor.bNumConfigurations; index++) {
2969 if (len < le16_to_cpu(udev->config[index].desc.wTotalLength)) 3071 old_length = le16_to_cpu(udev->config[index].desc.wTotalLength);
2970 len = le16_to_cpu(udev->config[index].desc.wTotalLength); 3072 len = max(len, old_length);
2971 } 3073 }
3074
2972 buf = kmalloc(len, GFP_NOIO); 3075 buf = kmalloc(len, GFP_NOIO);
2973 if (buf == NULL) { 3076 if (buf == NULL) {
2974 dev_err(&udev->dev, "no mem to re-read configs after reset\n"); 3077 dev_err(&udev->dev, "no mem to re-read configs after reset\n");
@@ -2976,25 +3079,41 @@ static int config_descriptors_changed(struct usb_device *udev)
2976 return 1; 3079 return 1;
2977 } 3080 }
2978 for (index = 0; index < udev->descriptor.bNumConfigurations; index++) { 3081 for (index = 0; index < udev->descriptor.bNumConfigurations; index++) {
2979 int length; 3082 old_length = le16_to_cpu(udev->config[index].desc.wTotalLength);
2980 int old_length = le16_to_cpu(udev->config[index].desc.wTotalLength);
2981
2982 length = usb_get_descriptor(udev, USB_DT_CONFIG, index, buf, 3083 length = usb_get_descriptor(udev, USB_DT_CONFIG, index, buf,
2983 old_length); 3084 old_length);
2984 if (length < old_length) { 3085 if (length != old_length) {
2985 dev_dbg(&udev->dev, "config index %d, error %d\n", 3086 dev_dbg(&udev->dev, "config index %d, error %d\n",
2986 index, length); 3087 index, length);
3088 changed = 1;
2987 break; 3089 break;
2988 } 3090 }
2989 if (memcmp (buf, udev->rawdescriptors[index], old_length) 3091 if (memcmp (buf, udev->rawdescriptors[index], old_length)
2990 != 0) { 3092 != 0) {
2991 dev_dbg(&udev->dev, "config index %d changed (#%d)\n", 3093 dev_dbg(&udev->dev, "config index %d changed (#%d)\n",
2992 index, buf->bConfigurationValue); 3094 index,
3095 ((struct usb_config_descriptor *) buf)->
3096 bConfigurationValue);
3097 changed = 1;
2993 break; 3098 break;
2994 } 3099 }
2995 } 3100 }
3101
3102 if (!changed && serial_len) {
3103 length = usb_string(udev, udev->descriptor.iSerialNumber,
3104 buf, serial_len);
3105 if (length + 1 != serial_len) {
3106 dev_dbg(&udev->dev, "serial string error %d\n",
3107 length);
3108 changed = 1;
3109 } else if (memcmp(buf, udev->serial, length) != 0) {
3110 dev_dbg(&udev->dev, "serial string changed\n");
3111 changed = 1;
3112 }
3113 }
3114
2996 kfree(buf); 3115 kfree(buf);
2997 return index != udev->descriptor.bNumConfigurations; 3116 return changed;
2998} 3117}
2999 3118
3000/** 3119/**
@@ -3044,7 +3163,7 @@ int usb_reset_device(struct usb_device *udev)
3044 3163
3045 if (!parent_hdev) { 3164 if (!parent_hdev) {
3046 /* this requires hcd-specific logic; see OHCI hc_restart() */ 3165 /* this requires hcd-specific logic; see OHCI hc_restart() */
3047 dev_dbg(&udev->dev, "%s for root hub!\n", __FUNCTION__); 3166 dev_dbg(&udev->dev, "%s for root hub!\n", __func__);
3048 return -EISDIR; 3167 return -EISDIR;
3049 } 3168 }
3050 parent_hub = hdev_to_hub(parent_hdev); 3169 parent_hub = hdev_to_hub(parent_hdev);
@@ -3054,21 +3173,18 @@ int usb_reset_device(struct usb_device *udev)
3054 3173
3055 /* ep0 maxpacket size may change; let the HCD know about it. 3174 /* ep0 maxpacket size may change; let the HCD know about it.
3056 * Other endpoints will be handled by re-enumeration. */ 3175 * Other endpoints will be handled by re-enumeration. */
3057 ep0_reinit(udev); 3176 usb_ep0_reinit(udev);
3058 ret = hub_port_init(parent_hub, udev, port1, i); 3177 ret = hub_port_init(parent_hub, udev, port1, i);
3059 if (ret >= 0 || ret == -ENOTCONN || ret == -ENODEV) 3178 if (ret >= 0 || ret == -ENOTCONN || ret == -ENODEV)
3060 break; 3179 break;
3061 } 3180 }
3062 clear_bit(port1, parent_hub->busy_bits); 3181 clear_bit(port1, parent_hub->busy_bits);
3063 if (!parent_hdev->parent && !parent_hub->busy_bits[0])
3064 usb_enable_root_hub_irq(parent_hdev->bus);
3065 3182
3066 if (ret < 0) 3183 if (ret < 0)
3067 goto re_enumerate; 3184 goto re_enumerate;
3068 3185
3069 /* Device might have changed firmware (DFU or similar) */ 3186 /* Device might have changed firmware (DFU or similar) */
3070 if (memcmp(&udev->descriptor, &descriptor, sizeof descriptor) 3187 if (descriptors_changed(udev, &descriptor)) {
3071 || config_descriptors_changed (udev)) {
3072 dev_info(&udev->dev, "device firmware changed\n"); 3188 dev_info(&udev->dev, "device firmware changed\n");
3073 udev->descriptor = descriptor; /* for disconnect() calls */ 3189 udev->descriptor = descriptor; /* for disconnect() calls */
3074 goto re_enumerate; 3190 goto re_enumerate;
diff --git a/drivers/usb/core/hub.h b/drivers/usb/core/hub.h
index 1551aed65e0..2a116ce53c9 100644
--- a/drivers/usb/core/hub.h
+++ b/drivers/usb/core/hub.h
@@ -41,9 +41,10 @@
41 */ 41 */
42#define USB_PORT_FEAT_CONNECTION 0 42#define USB_PORT_FEAT_CONNECTION 0
43#define USB_PORT_FEAT_ENABLE 1 43#define USB_PORT_FEAT_ENABLE 1
44#define USB_PORT_FEAT_SUSPEND 2 44#define USB_PORT_FEAT_SUSPEND 2 /* L2 suspend */
45#define USB_PORT_FEAT_OVER_CURRENT 3 45#define USB_PORT_FEAT_OVER_CURRENT 3
46#define USB_PORT_FEAT_RESET 4 46#define USB_PORT_FEAT_RESET 4
47#define USB_PORT_FEAT_L1 5 /* L1 suspend */
47#define USB_PORT_FEAT_POWER 8 48#define USB_PORT_FEAT_POWER 8
48#define USB_PORT_FEAT_LOWSPEED 9 49#define USB_PORT_FEAT_LOWSPEED 9
49#define USB_PORT_FEAT_HIGHSPEED 10 50#define USB_PORT_FEAT_HIGHSPEED 10
@@ -54,6 +55,7 @@
54#define USB_PORT_FEAT_C_RESET 20 55#define USB_PORT_FEAT_C_RESET 20
55#define USB_PORT_FEAT_TEST 21 56#define USB_PORT_FEAT_TEST 21
56#define USB_PORT_FEAT_INDICATOR 22 57#define USB_PORT_FEAT_INDICATOR 22
58#define USB_PORT_FEAT_C_PORT_L1 23
57 59
58/* 60/*
59 * Hub Status and Hub Change results 61 * Hub Status and Hub Change results
@@ -73,7 +75,8 @@ struct usb_port_status {
73#define USB_PORT_STAT_SUSPEND 0x0004 75#define USB_PORT_STAT_SUSPEND 0x0004
74#define USB_PORT_STAT_OVERCURRENT 0x0008 76#define USB_PORT_STAT_OVERCURRENT 0x0008
75#define USB_PORT_STAT_RESET 0x0010 77#define USB_PORT_STAT_RESET 0x0010
76/* bits 5 to 7 are reserved */ 78#define USB_PORT_STAT_L1 0x0020
79/* bits 6 to 7 are reserved */
77#define USB_PORT_STAT_POWER 0x0100 80#define USB_PORT_STAT_POWER 0x0100
78#define USB_PORT_STAT_LOW_SPEED 0x0200 81#define USB_PORT_STAT_LOW_SPEED 0x0200
79#define USB_PORT_STAT_HIGH_SPEED 0x0400 82#define USB_PORT_STAT_HIGH_SPEED 0x0400
@@ -91,6 +94,7 @@ struct usb_port_status {
91#define USB_PORT_STAT_C_SUSPEND 0x0004 94#define USB_PORT_STAT_C_SUSPEND 0x0004
92#define USB_PORT_STAT_C_OVERCURRENT 0x0008 95#define USB_PORT_STAT_C_OVERCURRENT 0x0008
93#define USB_PORT_STAT_C_RESET 0x0010 96#define USB_PORT_STAT_C_RESET 0x0010
97#define USB_PORT_STAT_C_L1 0x0020
94 98
95/* 99/*
96 * wHubCharacteristics (masks) 100 * wHubCharacteristics (masks)
@@ -191,5 +195,6 @@ struct usb_tt_clear {
191}; 195};
192 196
193extern void usb_hub_tt_clear_buffer(struct usb_device *dev, int pipe); 197extern void usb_hub_tt_clear_buffer(struct usb_device *dev, int pipe);
198extern void usb_ep0_reinit(struct usb_device *);
194 199
195#endif /* __LINUX_HUB_H */ 200#endif /* __LINUX_HUB_H */
diff --git a/drivers/usb/core/inode.c b/drivers/usb/core/inode.c
index 83a373e9cc3..8607846e3c3 100644
--- a/drivers/usb/core/inode.c
+++ b/drivers/usb/core/inode.c
@@ -463,13 +463,13 @@ static int usbfs_fill_super(struct super_block *sb, void *data, int silent)
463 inode = usbfs_get_inode(sb, S_IFDIR | 0755, 0); 463 inode = usbfs_get_inode(sb, S_IFDIR | 0755, 0);
464 464
465 if (!inode) { 465 if (!inode) {
466 dbg("%s: could not get inode!",__FUNCTION__); 466 dbg("%s: could not get inode!",__func__);
467 return -ENOMEM; 467 return -ENOMEM;
468 } 468 }
469 469
470 root = d_alloc_root(inode); 470 root = d_alloc_root(inode);
471 if (!root) { 471 if (!root) {
472 dbg("%s: could not get root dentry!",__FUNCTION__); 472 dbg("%s: could not get root dentry!",__func__);
473 iput(inode); 473 iput(inode);
474 return -ENOMEM; 474 return -ENOMEM;
475 } 475 }
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index c311f67b7f0..e819e5359d5 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -312,7 +312,7 @@ static void sg_complete(struct urb *urb)
312 retval != -EBUSY) 312 retval != -EBUSY)
313 dev_err(&io->dev->dev, 313 dev_err(&io->dev->dev,
314 "%s, unlink --> %d\n", 314 "%s, unlink --> %d\n",
315 __FUNCTION__, retval); 315 __func__, retval);
316 } else if (urb == io->urbs [i]) 316 } else if (urb == io->urbs [i])
317 found = 1; 317 found = 1;
318 } 318 }
@@ -550,7 +550,7 @@ void usb_sg_wait(struct usb_sg_request *io)
550 io->urbs[i]->dev = NULL; 550 io->urbs[i]->dev = NULL;
551 io->urbs[i]->status = retval; 551 io->urbs[i]->status = retval;
552 dev_dbg(&io->dev->dev, "%s, submit --> %d\n", 552 dev_dbg(&io->dev->dev, "%s, submit --> %d\n",
553 __FUNCTION__, retval); 553 __func__, retval);
554 usb_sg_cancel(io); 554 usb_sg_cancel(io);
555 } 555 }
556 spin_lock_irq(&io->lock); 556 spin_lock_irq(&io->lock);
@@ -600,7 +600,7 @@ void usb_sg_cancel(struct usb_sg_request *io)
600 retval = usb_unlink_urb(io->urbs [i]); 600 retval = usb_unlink_urb(io->urbs [i]);
601 if (retval != -EINPROGRESS && retval != -EBUSY) 601 if (retval != -EINPROGRESS && retval != -EBUSY)
602 dev_warn(&io->dev->dev, "%s, unlink --> %d\n", 602 dev_warn(&io->dev->dev, "%s, unlink --> %d\n",
603 __FUNCTION__, retval); 603 __func__, retval);
604 } 604 }
605 spin_lock(&io->lock); 605 spin_lock(&io->lock);
606 } 606 }
@@ -784,7 +784,7 @@ int usb_string(struct usb_device *dev, int index, char *buf, size_t size)
784 if (size <= 0 || !buf || !index) 784 if (size <= 0 || !buf || !index)
785 return -EINVAL; 785 return -EINVAL;
786 buf[0] = 0; 786 buf[0] = 0;
787 tbuf = kmalloc(256, GFP_KERNEL); 787 tbuf = kmalloc(256, GFP_NOIO);
788 if (!tbuf) 788 if (!tbuf)
789 return -ENOMEM; 789 return -ENOMEM;
790 790
@@ -1068,7 +1068,7 @@ void usb_disable_device(struct usb_device *dev, int skip_ep0)
1068{ 1068{
1069 int i; 1069 int i;
1070 1070
1071 dev_dbg(&dev->dev, "%s nuking %s URBs\n", __FUNCTION__, 1071 dev_dbg(&dev->dev, "%s nuking %s URBs\n", __func__,
1072 skip_ep0 ? "non-ep0" : "all"); 1072 skip_ep0 ? "non-ep0" : "all");
1073 for (i = skip_ep0; i < 16; ++i) { 1073 for (i = skip_ep0; i < 16; ++i) {
1074 usb_disable_endpoint(dev, i); 1074 usb_disable_endpoint(dev, i);
@@ -1089,8 +1089,8 @@ void usb_disable_device(struct usb_device *dev, int skip_ep0)
1089 continue; 1089 continue;
1090 dev_dbg(&dev->dev, "unregistering interface %s\n", 1090 dev_dbg(&dev->dev, "unregistering interface %s\n",
1091 interface->dev.bus_id); 1091 interface->dev.bus_id);
1092 usb_remove_sysfs_intf_files(interface);
1093 device_del(&interface->dev); 1092 device_del(&interface->dev);
1093 usb_remove_sysfs_intf_files(interface);
1094 } 1094 }
1095 1095
1096 /* Now that the interfaces are unbound, nobody should 1096 /* Now that the interfaces are unbound, nobody should
@@ -1231,7 +1231,7 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate)
1231 */ 1231 */
1232 1232
1233 /* prevent submissions using previous endpoint settings */ 1233 /* prevent submissions using previous endpoint settings */
1234 if (iface->cur_altsetting != alt && device_is_registered(&iface->dev)) 1234 if (iface->cur_altsetting != alt)
1235 usb_remove_sysfs_intf_files(iface); 1235 usb_remove_sysfs_intf_files(iface);
1236 usb_disable_interface(dev, iface); 1236 usb_disable_interface(dev, iface);
1237 1237
@@ -1330,8 +1330,7 @@ int usb_reset_configuration(struct usb_device *dev)
1330 struct usb_interface *intf = config->interface[i]; 1330 struct usb_interface *intf = config->interface[i];
1331 struct usb_host_interface *alt; 1331 struct usb_host_interface *alt;
1332 1332
1333 if (device_is_registered(&intf->dev)) 1333 usb_remove_sysfs_intf_files(intf);
1334 usb_remove_sysfs_intf_files(intf);
1335 alt = usb_altnum_to_altsetting(intf, 0); 1334 alt = usb_altnum_to_altsetting(intf, 0);
1336 1335
1337 /* No altsetting 0? We'll assume the first altsetting. 1336 /* No altsetting 0? We'll assume the first altsetting.
diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
index dfc5418ea10..2e201939029 100644
--- a/drivers/usb/core/quirks.c
+++ b/drivers/usb/core/quirks.c
@@ -97,4 +97,18 @@ void usb_detect_quirks(struct usb_device *udev)
97 if (udev->descriptor.bDeviceClass != USB_CLASS_HUB) 97 if (udev->descriptor.bDeviceClass != USB_CLASS_HUB)
98 udev->autosuspend_disabled = 1; 98 udev->autosuspend_disabled = 1;
99#endif 99#endif
100
101 /* For the present, all devices default to USB-PERSIST enabled */
102#if 0 /* was: #ifdef CONFIG_PM */
103 /* Hubs are automatically enabled for USB-PERSIST */
104 if (udev->descriptor.bDeviceClass == USB_CLASS_HUB)
105 udev->persist_enabled = 1;
106
107#else
108 /* In the absence of PM, we can safely enable USB-PERSIST
109 * for all devices. It will affect things like hub resets
110 * and EMF-related port disables.
111 */
112 udev->persist_enabled = 1;
113#endif /* CONFIG_PM */
100} 114}
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
index a37ccbd1e00..5b20a60de8b 100644
--- a/drivers/usb/core/sysfs.c
+++ b/drivers/usb/core/sysfs.c
@@ -180,11 +180,9 @@ show_urbnum(struct device *dev, struct device_attribute *attr, char *buf)
180static DEVICE_ATTR(urbnum, S_IRUGO, show_urbnum, NULL); 180static DEVICE_ATTR(urbnum, S_IRUGO, show_urbnum, NULL);
181 181
182 182
183#if defined(CONFIG_USB_PERSIST) || defined(CONFIG_USB_SUSPEND) 183#ifdef CONFIG_PM
184static const char power_group[] = "power";
185#endif
186 184
187#ifdef CONFIG_USB_PERSIST 185static const char power_group[] = "power";
188 186
189static ssize_t 187static ssize_t
190show_persist(struct device *dev, struct device_attribute *attr, char *buf) 188show_persist(struct device *dev, struct device_attribute *attr, char *buf)
@@ -222,12 +220,13 @@ static int add_persist_attributes(struct device *dev)
222 if (is_usb_device(dev)) { 220 if (is_usb_device(dev)) {
223 struct usb_device *udev = to_usb_device(dev); 221 struct usb_device *udev = to_usb_device(dev);
224 222
225 /* Hubs are automatically enabled for USB_PERSIST */ 223 /* Hubs are automatically enabled for USB_PERSIST,
226 if (udev->descriptor.bDeviceClass == USB_CLASS_HUB) 224 * no point in creating the attribute file.
227 udev->persist_enabled = 1; 225 */
228 rc = sysfs_add_file_to_group(&dev->kobj, 226 if (udev->descriptor.bDeviceClass != USB_CLASS_HUB)
229 &dev_attr_persist.attr, 227 rc = sysfs_add_file_to_group(&dev->kobj,
230 power_group); 228 &dev_attr_persist.attr,
229 power_group);
231 } 230 }
232 return rc; 231 return rc;
233} 232}
@@ -238,13 +237,12 @@ static void remove_persist_attributes(struct device *dev)
238 &dev_attr_persist.attr, 237 &dev_attr_persist.attr,
239 power_group); 238 power_group);
240} 239}
241
242#else 240#else
243 241
244#define add_persist_attributes(dev) 0 242#define add_persist_attributes(dev) 0
245#define remove_persist_attributes(dev) do {} while (0) 243#define remove_persist_attributes(dev) do {} while (0)
246 244
247#endif /* CONFIG_USB_PERSIST */ 245#endif /* CONFIG_PM */
248 246
249#ifdef CONFIG_USB_SUSPEND 247#ifdef CONFIG_USB_SUSPEND
250 248
diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c
index 9d7e63292c0..c0b1ae25ae2 100644
--- a/drivers/usb/core/urb.c
+++ b/drivers/usb/core/urb.c
@@ -334,7 +334,7 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
334 dev_dbg(&dev->dev, 334 dev_dbg(&dev->dev,
335 "bogus endpoint ep%d%s in %s (bad maxpacket %d)\n", 335 "bogus endpoint ep%d%s in %s (bad maxpacket %d)\n",
336 usb_endpoint_num(&ep->desc), is_out ? "out" : "in", 336 usb_endpoint_num(&ep->desc), is_out ? "out" : "in",
337 __FUNCTION__, max); 337 __func__, max);
338 return -EMSGSIZE; 338 return -EMSGSIZE;
339 } 339 }
340 340
@@ -590,6 +590,30 @@ void usb_kill_anchored_urbs(struct usb_anchor *anchor)
590EXPORT_SYMBOL_GPL(usb_kill_anchored_urbs); 590EXPORT_SYMBOL_GPL(usb_kill_anchored_urbs);
591 591
592/** 592/**
593 * usb_unlink_anchored_urbs - asynchronously cancel transfer requests en masse
594 * @anchor: anchor the requests are bound to
595 *
596 * this allows all outstanding URBs to be unlinked starting
597 * from the back of the queue. This function is asynchronous.
598 * The unlinking is just tiggered. It may happen after this
599 * function has returned.
600 */
601void usb_unlink_anchored_urbs(struct usb_anchor *anchor)
602{
603 struct urb *victim;
604
605 spin_lock_irq(&anchor->lock);
606 while (!list_empty(&anchor->urb_list)) {
607 victim = list_entry(anchor->urb_list.prev, struct urb,
608 anchor_list);
609 /* this will unanchor the URB */
610 usb_unlink_urb(victim);
611 }
612 spin_unlock_irq(&anchor->lock);
613}
614EXPORT_SYMBOL_GPL(usb_unlink_anchored_urbs);
615
616/**
593 * usb_wait_anchor_empty_timeout - wait for an anchor to be unused 617 * usb_wait_anchor_empty_timeout - wait for an anchor to be unused
594 * @anchor: the anchor you want to become unused 618 * @anchor: the anchor you want to become unused
595 * @timeout: how long you are willing to wait in milliseconds 619 * @timeout: how long you are willing to wait in milliseconds
diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h
index 2375194a9d4..1bf8ccb9c58 100644
--- a/drivers/usb/core/usb.h
+++ b/drivers/usb/core/usb.h
@@ -114,13 +114,11 @@ static inline int is_usb_device_driver(struct device_driver *drv)
114static inline void mark_active(struct usb_interface *f) 114static inline void mark_active(struct usb_interface *f)
115{ 115{
116 f->is_active = 1; 116 f->is_active = 1;
117 f->dev.power.power_state.event = PM_EVENT_ON;
118} 117}
119 118
120static inline void mark_quiesced(struct usb_interface *f) 119static inline void mark_quiesced(struct usb_interface *f)
121{ 120{
122 f->is_active = 0; 121 f->is_active = 0;
123 f->dev.power.power_state.event = PM_EVENT_SUSPEND;
124} 122}
125 123
126static inline int is_active(const struct usb_interface *f) 124static inline int is_active(const struct usb_interface *f)
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index d681bb27fa5..f7b54651dd4 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -44,8 +44,8 @@ menuconfig USB_GADGET
44if USB_GADGET 44if USB_GADGET
45 45
46config USB_GADGET_DEBUG 46config USB_GADGET_DEBUG
47 boolean "Debugging messages" 47 boolean "Debugging messages (DEVELOPMENT)"
48 depends on USB_GADGET && DEBUG_KERNEL && EXPERIMENTAL 48 depends on USB_GADGET && DEBUG_KERNEL
49 help 49 help
50 Many controller and gadget drivers will print some debugging 50 Many controller and gadget drivers will print some debugging
51 messages if you use this option to ask for those messages. 51 messages if you use this option to ask for those messages.
@@ -58,7 +58,7 @@ config USB_GADGET_DEBUG
58 production build. 58 production build.
59 59
60config USB_GADGET_DEBUG_FILES 60config USB_GADGET_DEBUG_FILES
61 boolean "Debugging information files" 61 boolean "Debugging information files (DEVELOPMENT)"
62 depends on USB_GADGET && PROC_FS 62 depends on USB_GADGET && PROC_FS
63 help 63 help
64 Some of the drivers in the "gadget" framework can expose 64 Some of the drivers in the "gadget" framework can expose
@@ -69,7 +69,7 @@ config USB_GADGET_DEBUG_FILES
69 here. If in doubt, or to conserve kernel memory, say "N". 69 here. If in doubt, or to conserve kernel memory, say "N".
70 70
71config USB_GADGET_DEBUG_FS 71config USB_GADGET_DEBUG_FS
72 boolean "Debugging information files in debugfs" 72 boolean "Debugging information files in debugfs (DEVELOPMENT)"
73 depends on USB_GADGET && DEBUG_FS 73 depends on USB_GADGET && DEBUG_FS
74 help 74 help
75 Some of the drivers in the "gadget" framework can expose 75 Some of the drivers in the "gadget" framework can expose
@@ -337,7 +337,7 @@ config USB_AT91
337 337
338config USB_GADGET_DUMMY_HCD 338config USB_GADGET_DUMMY_HCD
339 boolean "Dummy HCD (DEVELOPMENT)" 339 boolean "Dummy HCD (DEVELOPMENT)"
340 depends on (USB=y || (USB=m && USB_GADGET=m)) && EXPERIMENTAL 340 depends on USB=y || (USB=m && USB_GADGET=m)
341 select USB_GADGET_DUALSPEED 341 select USB_GADGET_DUALSPEED
342 help 342 help
343 This host controller driver emulates USB, looping all data transfer 343 This host controller driver emulates USB, looping all data transfer
@@ -404,7 +404,6 @@ choice
404 404
405config USB_ZERO 405config USB_ZERO
406 tristate "Gadget Zero (DEVELOPMENT)" 406 tristate "Gadget Zero (DEVELOPMENT)"
407 depends on EXPERIMENTAL
408 help 407 help
409 Gadget Zero is a two-configuration device. It either sinks and 408 Gadget Zero is a two-configuration device. It either sinks and
410 sources bulk data; or it loops back a configurable number of 409 sources bulk data; or it loops back a configurable number of
@@ -468,8 +467,8 @@ config USB_ETH
468 dynamically linked module called "g_ether". 467 dynamically linked module called "g_ether".
469 468
470config USB_ETH_RNDIS 469config USB_ETH_RNDIS
471 bool "RNDIS support (EXPERIMENTAL)" 470 bool "RNDIS support"
472 depends on USB_ETH && EXPERIMENTAL 471 depends on USB_ETH
473 default y 472 default y
474 help 473 help
475 Microsoft Windows XP bundles the "Remote NDIS" (RNDIS) protocol, 474 Microsoft Windows XP bundles the "Remote NDIS" (RNDIS) protocol,
@@ -495,6 +494,9 @@ config USB_GADGETFS
495 All endpoints, transfer speeds, and transfer types supported by 494 All endpoints, transfer speeds, and transfer types supported by
496 the hardware are available, through read() and write() calls. 495 the hardware are available, through read() and write() calls.
497 496
497 Currently, this option is still labelled as EXPERIMENTAL because
498 of existing race conditions in the underlying in-kernel AIO core.
499
498 Say "y" to link the driver statically, or "m" to build a 500 Say "y" to link the driver statically, or "m" to build a
499 dynamically linked module called "gadgetfs". 501 dynamically linked module called "gadgetfs".
500 502
diff --git a/drivers/usb/gadget/amd5536udc.c b/drivers/usb/gadget/amd5536udc.c
index b663f23f264..fc6f3483be4 100644
--- a/drivers/usb/gadget/amd5536udc.c
+++ b/drivers/usb/gadget/amd5536udc.c
@@ -3248,6 +3248,8 @@ static int udc_pci_probe(
3248 3248
3249 /* pci setup */ 3249 /* pci setup */
3250 if (pci_enable_device(pdev) < 0) { 3250 if (pci_enable_device(pdev) < 0) {
3251 kfree(dev);
3252 dev = 0;
3251 retval = -ENODEV; 3253 retval = -ENODEV;
3252 goto finished; 3254 goto finished;
3253 } 3255 }
@@ -3259,6 +3261,8 @@ static int udc_pci_probe(
3259 3261
3260 if (!request_mem_region(resource, len, name)) { 3262 if (!request_mem_region(resource, len, name)) {
3261 dev_dbg(&pdev->dev, "pci device used already\n"); 3263 dev_dbg(&pdev->dev, "pci device used already\n");
3264 kfree(dev);
3265 dev = 0;
3262 retval = -EBUSY; 3266 retval = -EBUSY;
3263 goto finished; 3267 goto finished;
3264 } 3268 }
@@ -3267,18 +3271,24 @@ static int udc_pci_probe(
3267 dev->virt_addr = ioremap_nocache(resource, len); 3271 dev->virt_addr = ioremap_nocache(resource, len);
3268 if (dev->virt_addr == NULL) { 3272 if (dev->virt_addr == NULL) {
3269 dev_dbg(&pdev->dev, "start address cannot be mapped\n"); 3273 dev_dbg(&pdev->dev, "start address cannot be mapped\n");
3274 kfree(dev);
3275 dev = 0;
3270 retval = -EFAULT; 3276 retval = -EFAULT;
3271 goto finished; 3277 goto finished;
3272 } 3278 }
3273 3279
3274 if (!pdev->irq) { 3280 if (!pdev->irq) {
3275 dev_err(&dev->pdev->dev, "irq not set\n"); 3281 dev_err(&dev->pdev->dev, "irq not set\n");
3282 kfree(dev);
3283 dev = 0;
3276 retval = -ENODEV; 3284 retval = -ENODEV;
3277 goto finished; 3285 goto finished;
3278 } 3286 }
3279 3287
3280 if (request_irq(pdev->irq, udc_irq, IRQF_SHARED, name, dev) != 0) { 3288 if (request_irq(pdev->irq, udc_irq, IRQF_SHARED, name, dev) != 0) {
3281 dev_dbg(&dev->pdev->dev, "request_irq(%d) fail\n", pdev->irq); 3289 dev_dbg(&dev->pdev->dev, "request_irq(%d) fail\n", pdev->irq);
3290 kfree(dev);
3291 dev = 0;
3282 retval = -EBUSY; 3292 retval = -EBUSY;
3283 goto finished; 3293 goto finished;
3284 } 3294 }
diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c
index fd15ced899d..9b913afb2e6 100644
--- a/drivers/usb/gadget/at91_udc.c
+++ b/drivers/usb/gadget/at91_udc.c
@@ -389,6 +389,7 @@ static int write_fifo(struct at91_ep *ep, struct at91_request *req)
389 u32 csr = __raw_readl(creg); 389 u32 csr = __raw_readl(creg);
390 u8 __iomem *dreg = ep->creg + (AT91_UDP_FDR(0) - AT91_UDP_CSR(0)); 390 u8 __iomem *dreg = ep->creg + (AT91_UDP_FDR(0) - AT91_UDP_CSR(0));
391 unsigned total, count, is_last; 391 unsigned total, count, is_last;
392 u8 *buf;
392 393
393 /* 394 /*
394 * TODO: allow for writing two packets to the fifo ... that'll 395 * TODO: allow for writing two packets to the fifo ... that'll
@@ -413,6 +414,8 @@ static int write_fifo(struct at91_ep *ep, struct at91_request *req)
413 return 0; 414 return 0;
414 } 415 }
415 416
417 buf = req->req.buf + req->req.actual;
418 prefetch(buf);
416 total = req->req.length - req->req.actual; 419 total = req->req.length - req->req.actual;
417 if (ep->ep.maxpacket < total) { 420 if (ep->ep.maxpacket < total) {
418 count = ep->ep.maxpacket; 421 count = ep->ep.maxpacket;
@@ -435,7 +438,7 @@ static int write_fifo(struct at91_ep *ep, struct at91_request *req)
435 * recover when the actual bytecount matters (e.g. for USB Test 438 * recover when the actual bytecount matters (e.g. for USB Test
436 * and Measurement Class devices). 439 * and Measurement Class devices).
437 */ 440 */
438 __raw_writesb(dreg, req->req.buf + req->req.actual, count); 441 __raw_writesb(dreg, buf, count);
439 csr &= ~SET_FX; 442 csr &= ~SET_FX;
440 csr |= CLR_FX | AT91_UDP_TXPKTRDY; 443 csr |= CLR_FX | AT91_UDP_TXPKTRDY;
441 __raw_writel(csr, creg); 444 __raw_writel(csr, creg);
@@ -457,7 +460,7 @@ static void nuke(struct at91_ep *ep, int status)
457 if (list_empty(&ep->queue)) 460 if (list_empty(&ep->queue))
458 return; 461 return;
459 462
460 VDBG("%s %s\n", __FUNCTION__, ep->ep.name); 463 VDBG("%s %s\n", __func__, ep->ep.name);
461 while (!list_empty(&ep->queue)) { 464 while (!list_empty(&ep->queue)) {
462 req = list_entry(ep->queue.next, struct at91_request, queue); 465 req = list_entry(ep->queue.next, struct at91_request, queue);
463 done(ep, req, status); 466 done(ep, req, status);
@@ -792,7 +795,7 @@ static int at91_wakeup(struct usb_gadget *gadget)
792 int status = -EINVAL; 795 int status = -EINVAL;
793 unsigned long flags; 796 unsigned long flags;
794 797
795 DBG("%s\n", __FUNCTION__ ); 798 DBG("%s\n", __func__ );
796 local_irq_save(flags); 799 local_irq_save(flags);
797 800
798 if (!udc->clocked || !udc->suspended) 801 if (!udc->clocked || !udc->suspended)
diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c
index cbe44535c0f..66293105d13 100644
--- a/drivers/usb/gadget/dummy_hcd.c
+++ b/drivers/usb/gadget/dummy_hcd.c
@@ -365,16 +365,14 @@ dummy_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
365 case USB_SPEED_HIGH: 365 case USB_SPEED_HIGH:
366 if (max == 512) 366 if (max == 512)
367 break; 367 break;
368 /* conserve return statements */ 368 goto done;
369 default: 369 case USB_SPEED_FULL:
370 switch (max) { 370 if (max == 8 || max == 16 || max == 32 || max == 64)
371 case 8: case 16: case 32: case 64:
372 /* we'll fake any legal size */ 371 /* we'll fake any legal size */
373 break; 372 break;
374 default: 373 /* save a return statement */
375 case USB_SPEED_LOW: 374 default:
376 goto done; 375 goto done;
377 }
378 } 376 }
379 break; 377 break;
380 case USB_ENDPOINT_XFER_INT: 378 case USB_ENDPOINT_XFER_INT:
@@ -894,13 +892,12 @@ static int dummy_udc_suspend (struct platform_device *pdev, pm_message_t state)
894{ 892{
895 struct dummy *dum = platform_get_drvdata(pdev); 893 struct dummy *dum = platform_get_drvdata(pdev);
896 894
897 dev_dbg (&pdev->dev, "%s\n", __FUNCTION__); 895 dev_dbg (&pdev->dev, "%s\n", __func__);
898 spin_lock_irq (&dum->lock); 896 spin_lock_irq (&dum->lock);
899 dum->udc_suspended = 1; 897 dum->udc_suspended = 1;
900 set_link_state (dum); 898 set_link_state (dum);
901 spin_unlock_irq (&dum->lock); 899 spin_unlock_irq (&dum->lock);
902 900
903 pdev->dev.power.power_state = state;
904 usb_hcd_poll_rh_status (dummy_to_hcd (dum)); 901 usb_hcd_poll_rh_status (dummy_to_hcd (dum));
905 return 0; 902 return 0;
906} 903}
@@ -909,13 +906,12 @@ static int dummy_udc_resume (struct platform_device *pdev)
909{ 906{
910 struct dummy *dum = platform_get_drvdata(pdev); 907 struct dummy *dum = platform_get_drvdata(pdev);
911 908
912 dev_dbg (&pdev->dev, "%s\n", __FUNCTION__); 909 dev_dbg (&pdev->dev, "%s\n", __func__);
913 spin_lock_irq (&dum->lock); 910 spin_lock_irq (&dum->lock);
914 dum->udc_suspended = 0; 911 dum->udc_suspended = 0;
915 set_link_state (dum); 912 set_link_state (dum);
916 spin_unlock_irq (&dum->lock); 913 spin_unlock_irq (&dum->lock);
917 914
918 pdev->dev.power.power_state = PMSG_ON;
919 usb_hcd_poll_rh_status (dummy_to_hcd (dum)); 915 usb_hcd_poll_rh_status (dummy_to_hcd (dum));
920 return 0; 916 return 0;
921} 917}
@@ -1711,7 +1707,7 @@ static int dummy_bus_suspend (struct usb_hcd *hcd)
1711{ 1707{
1712 struct dummy *dum = hcd_to_dummy (hcd); 1708 struct dummy *dum = hcd_to_dummy (hcd);
1713 1709
1714 dev_dbg (&hcd->self.root_hub->dev, "%s\n", __FUNCTION__); 1710 dev_dbg (&hcd->self.root_hub->dev, "%s\n", __func__);
1715 1711
1716 spin_lock_irq (&dum->lock); 1712 spin_lock_irq (&dum->lock);
1717 dum->rh_state = DUMMY_RH_SUSPENDED; 1713 dum->rh_state = DUMMY_RH_SUSPENDED;
@@ -1726,7 +1722,7 @@ static int dummy_bus_resume (struct usb_hcd *hcd)
1726 struct dummy *dum = hcd_to_dummy (hcd); 1722 struct dummy *dum = hcd_to_dummy (hcd);
1727 int rc = 0; 1723 int rc = 0;
1728 1724
1729 dev_dbg (&hcd->self.root_hub->dev, "%s\n", __FUNCTION__); 1725 dev_dbg (&hcd->self.root_hub->dev, "%s\n", __func__);
1730 1726
1731 spin_lock_irq (&dum->lock); 1727 spin_lock_irq (&dum->lock);
1732 if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) { 1728 if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) {
@@ -1900,7 +1896,7 @@ static int dummy_hcd_suspend (struct platform_device *pdev, pm_message_t state)
1900 struct dummy *dum; 1896 struct dummy *dum;
1901 int rc = 0; 1897 int rc = 0;
1902 1898
1903 dev_dbg (&pdev->dev, "%s\n", __FUNCTION__); 1899 dev_dbg (&pdev->dev, "%s\n", __func__);
1904 1900
1905 hcd = platform_get_drvdata (pdev); 1901 hcd = platform_get_drvdata (pdev);
1906 dum = hcd_to_dummy (hcd); 1902 dum = hcd_to_dummy (hcd);
@@ -1916,7 +1912,7 @@ static int dummy_hcd_resume (struct platform_device *pdev)
1916{ 1912{
1917 struct usb_hcd *hcd; 1913 struct usb_hcd *hcd;
1918 1914
1919 dev_dbg (&pdev->dev, "%s\n", __FUNCTION__); 1915 dev_dbg (&pdev->dev, "%s\n", __func__);
1920 1916
1921 hcd = platform_get_drvdata (pdev); 1917 hcd = platform_get_drvdata (pdev);
1922 set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); 1918 set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
@@ -1937,69 +1933,57 @@ static struct platform_driver dummy_hcd_driver = {
1937 1933
1938/*-------------------------------------------------------------------------*/ 1934/*-------------------------------------------------------------------------*/
1939 1935
1940/* These don't need to do anything because the pdev structures are 1936static struct platform_device *the_udc_pdev;
1941 * statically allocated. */ 1937static struct platform_device *the_hcd_pdev;
1942static void
1943dummy_udc_release (struct device *dev) {}
1944
1945static void
1946dummy_hcd_release (struct device *dev) {}
1947
1948static struct platform_device the_udc_pdev = {
1949 .name = (char *) gadget_name,
1950 .id = -1,
1951 .dev = {
1952 .release = dummy_udc_release,
1953 },
1954};
1955
1956static struct platform_device the_hcd_pdev = {
1957 .name = (char *) driver_name,
1958 .id = -1,
1959 .dev = {
1960 .release = dummy_hcd_release,
1961 },
1962};
1963 1938
1964static int __init init (void) 1939static int __init init (void)
1965{ 1940{
1966 int retval; 1941 int retval = -ENOMEM;
1967 1942
1968 if (usb_disabled ()) 1943 if (usb_disabled ())
1969 return -ENODEV; 1944 return -ENODEV;
1970 1945
1971 retval = platform_driver_register (&dummy_hcd_driver); 1946 the_hcd_pdev = platform_device_alloc(driver_name, -1);
1972 if (retval < 0) 1947 if (!the_hcd_pdev)
1973 return retval; 1948 return retval;
1949 the_udc_pdev = platform_device_alloc(gadget_name, -1);
1950 if (!the_udc_pdev)
1951 goto err_alloc_udc;
1974 1952
1975 retval = platform_driver_register (&dummy_udc_driver); 1953 retval = platform_driver_register(&dummy_hcd_driver);
1954 if (retval < 0)
1955 goto err_register_hcd_driver;
1956 retval = platform_driver_register(&dummy_udc_driver);
1976 if (retval < 0) 1957 if (retval < 0)
1977 goto err_register_udc_driver; 1958 goto err_register_udc_driver;
1978 1959
1979 retval = platform_device_register (&the_hcd_pdev); 1960 retval = platform_device_add(the_hcd_pdev);
1980 if (retval < 0) 1961 if (retval < 0)
1981 goto err_register_hcd; 1962 goto err_add_hcd;
1982 1963 retval = platform_device_add(the_udc_pdev);
1983 retval = platform_device_register (&the_udc_pdev);
1984 if (retval < 0) 1964 if (retval < 0)
1985 goto err_register_udc; 1965 goto err_add_udc;
1986 return retval; 1966 return retval;
1987 1967
1988err_register_udc: 1968err_add_udc:
1989 platform_device_unregister (&the_hcd_pdev); 1969 platform_device_del(the_hcd_pdev);
1990err_register_hcd: 1970err_add_hcd:
1991 platform_driver_unregister (&dummy_udc_driver); 1971 platform_driver_unregister(&dummy_udc_driver);
1992err_register_udc_driver: 1972err_register_udc_driver:
1993 platform_driver_unregister (&dummy_hcd_driver); 1973 platform_driver_unregister(&dummy_hcd_driver);
1974err_register_hcd_driver:
1975 platform_device_put(the_udc_pdev);
1976err_alloc_udc:
1977 platform_device_put(the_hcd_pdev);
1994 return retval; 1978 return retval;
1995} 1979}
1996module_init (init); 1980module_init (init);
1997 1981
1998static void __exit cleanup (void) 1982static void __exit cleanup (void)
1999{ 1983{
2000 platform_device_unregister (&the_udc_pdev); 1984 platform_device_unregister(the_udc_pdev);
2001 platform_device_unregister (&the_hcd_pdev); 1985 platform_device_unregister(the_hcd_pdev);
2002 platform_driver_unregister (&dummy_udc_driver); 1986 platform_driver_unregister(&dummy_udc_driver);
2003 platform_driver_unregister (&dummy_hcd_driver); 1987 platform_driver_unregister(&dummy_hcd_driver);
2004} 1988}
2005module_exit (cleanup); 1989module_exit (cleanup);
diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c
index f9d07108bc3..8bdad221fa9 100644
--- a/drivers/usb/gadget/epautoconf.c
+++ b/drivers/usb/gadget/epautoconf.c
@@ -34,12 +34,12 @@
34 34
35 35
36/* we must assign addresses for configurable endpoints (like net2280) */ 36/* we must assign addresses for configurable endpoints (like net2280) */
37static __devinitdata unsigned epnum; 37static __initdata unsigned epnum;
38 38
39// #define MANY_ENDPOINTS 39// #define MANY_ENDPOINTS
40#ifdef MANY_ENDPOINTS 40#ifdef MANY_ENDPOINTS
41/* more than 15 configurable endpoints */ 41/* more than 15 configurable endpoints */
42static __devinitdata unsigned in_epnum; 42static __initdata unsigned in_epnum;
43#endif 43#endif
44 44
45 45
@@ -59,7 +59,7 @@ static __devinitdata unsigned in_epnum;
59 * NOTE: each endpoint is unidirectional, as specified by its USB 59 * NOTE: each endpoint is unidirectional, as specified by its USB
60 * descriptor; and isn't specific to a configuration or altsetting. 60 * descriptor; and isn't specific to a configuration or altsetting.
61 */ 61 */
62static int __devinit 62static int __init
63ep_matches ( 63ep_matches (
64 struct usb_gadget *gadget, 64 struct usb_gadget *gadget,
65 struct usb_ep *ep, 65 struct usb_ep *ep,
@@ -186,7 +186,7 @@ ep_matches (
186 return 1; 186 return 1;
187} 187}
188 188
189static struct usb_ep * __devinit 189static struct usb_ep * __init
190find_ep (struct usb_gadget *gadget, const char *name) 190find_ep (struct usb_gadget *gadget, const char *name)
191{ 191{
192 struct usb_ep *ep; 192 struct usb_ep *ep;
@@ -228,7 +228,7 @@ find_ep (struct usb_gadget *gadget, const char *name)
228 * 228 *
229 * On failure, this returns a null endpoint descriptor. 229 * On failure, this returns a null endpoint descriptor.
230 */ 230 */
231struct usb_ep * __devinit usb_ep_autoconfig ( 231struct usb_ep * __init usb_ep_autoconfig (
232 struct usb_gadget *gadget, 232 struct usb_gadget *gadget,
233 struct usb_endpoint_descriptor *desc 233 struct usb_endpoint_descriptor *desc
234) 234)
@@ -295,7 +295,7 @@ struct usb_ep * __devinit usb_ep_autoconfig (
295 * state such as ep->driver_data and the record of assigned endpoints 295 * state such as ep->driver_data and the record of assigned endpoints
296 * used by usb_ep_autoconfig(). 296 * used by usb_ep_autoconfig().
297 */ 297 */
298void __devinit usb_ep_autoconfig_reset (struct usb_gadget *gadget) 298void __init usb_ep_autoconfig_reset (struct usb_gadget *gadget)
299{ 299{
300 struct usb_ep *ep; 300 struct usb_ep *ep;
301 301
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index e9987230814..bb93bdd7659 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -1102,7 +1102,7 @@ static void eth_reset_config (struct eth_dev *dev)
1102 if (dev->config == 0) 1102 if (dev->config == 0)
1103 return; 1103 return;
1104 1104
1105 DEBUG (dev, "%s\n", __FUNCTION__); 1105 DEBUG (dev, "%s\n", __func__);
1106 1106
1107 netif_stop_queue (dev->net); 1107 netif_stop_queue (dev->net);
1108 netif_carrier_off (dev->net); 1108 netif_carrier_off (dev->net);
@@ -1263,7 +1263,7 @@ static void issue_start_status (struct eth_dev *dev)
1263 struct usb_cdc_notification *event; 1263 struct usb_cdc_notification *event;
1264 int value; 1264 int value;
1265 1265
1266 DEBUG (dev, "%s, flush old status first\n", __FUNCTION__); 1266 DEBUG (dev, "%s, flush old status first\n", __func__);
1267 1267
1268 /* flush old status 1268 /* flush old status
1269 * 1269 *
@@ -1329,7 +1329,7 @@ static void rndis_command_complete (struct usb_ep *ep, struct usb_request *req)
1329 spin_lock(&dev->lock); 1329 spin_lock(&dev->lock);
1330 status = rndis_msg_parser (dev->rndis_config, (u8 *) req->buf); 1330 status = rndis_msg_parser (dev->rndis_config, (u8 *) req->buf);
1331 if (status < 0) 1331 if (status < 0)
1332 ERROR(dev, "%s: rndis parse error %d\n", __FUNCTION__, status); 1332 ERROR(dev, "%s: rndis parse error %d\n", __func__, status);
1333 spin_unlock(&dev->lock); 1333 spin_unlock(&dev->lock);
1334} 1334}
1335 1335
@@ -2113,7 +2113,7 @@ static int rndis_control_ack (struct net_device *net)
2113 2113
2114static void eth_start (struct eth_dev *dev, gfp_t gfp_flags) 2114static void eth_start (struct eth_dev *dev, gfp_t gfp_flags)
2115{ 2115{
2116 DEBUG (dev, "%s\n", __FUNCTION__); 2116 DEBUG (dev, "%s\n", __func__);
2117 2117
2118 /* fill the rx queue */ 2118 /* fill the rx queue */
2119 rx_fill (dev, gfp_flags); 2119 rx_fill (dev, gfp_flags);
@@ -2133,7 +2133,7 @@ static int eth_open (struct net_device *net)
2133{ 2133{
2134 struct eth_dev *dev = netdev_priv(net); 2134 struct eth_dev *dev = netdev_priv(net);
2135 2135
2136 DEBUG (dev, "%s\n", __FUNCTION__); 2136 DEBUG (dev, "%s\n", __func__);
2137 if (netif_carrier_ok (dev->net)) 2137 if (netif_carrier_ok (dev->net))
2138 eth_start (dev, GFP_KERNEL); 2138 eth_start (dev, GFP_KERNEL);
2139 return 0; 2139 return 0;
@@ -2143,7 +2143,7 @@ static int eth_stop (struct net_device *net)
2143{ 2143{
2144 struct eth_dev *dev = netdev_priv(net); 2144 struct eth_dev *dev = netdev_priv(net);
2145 2145
2146 VDEBUG (dev, "%s\n", __FUNCTION__); 2146 VDEBUG (dev, "%s\n", __func__);
2147 netif_stop_queue (net); 2147 netif_stop_queue (net);
2148 2148
2149 DEBUG (dev, "stop stats: rx/tx %ld/%ld, errs %ld/%ld\n", 2149 DEBUG (dev, "stop stats: rx/tx %ld/%ld, errs %ld/%ld\n",
@@ -2229,7 +2229,7 @@ eth_unbind (struct usb_gadget *gadget)
2229 set_gadget_data (gadget, NULL); 2229 set_gadget_data (gadget, NULL);
2230} 2230}
2231 2231
2232static u8 __devinit nibble (unsigned char c) 2232static u8 __init nibble (unsigned char c)
2233{ 2233{
2234 if (likely (isdigit (c))) 2234 if (likely (isdigit (c)))
2235 return c - '0'; 2235 return c - '0';
@@ -2239,7 +2239,7 @@ static u8 __devinit nibble (unsigned char c)
2239 return 0; 2239 return 0;
2240} 2240}
2241 2241
2242static int __devinit get_ether_addr(const char *str, u8 *dev_addr) 2242static int __init get_ether_addr(const char *str, u8 *dev_addr)
2243{ 2243{
2244 if (str) { 2244 if (str) {
2245 unsigned i; 2245 unsigned i;
@@ -2260,7 +2260,7 @@ static int __devinit get_ether_addr(const char *str, u8 *dev_addr)
2260 return 1; 2260 return 1;
2261} 2261}
2262 2262
2263static int __devinit 2263static int __init
2264eth_bind (struct usb_gadget *gadget) 2264eth_bind (struct usb_gadget *gadget)
2265{ 2265{
2266 struct eth_dev *dev; 2266 struct eth_dev *dev;
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c
index 017a196d041..bf3f946fd45 100644
--- a/drivers/usb/gadget/file_storage.c
+++ b/drivers/usb/gadget/file_storage.c
@@ -644,7 +644,7 @@ struct fsg_dev {
644 644
645 unsigned long atomic_bitflags; 645 unsigned long atomic_bitflags;
646#define REGISTERED 0 646#define REGISTERED 0
647#define CLEAR_BULK_HALTS 1 647#define IGNORE_BULK_OUT 1
648#define SUSPENDED 2 648#define SUSPENDED 2
649 649
650 struct usb_ep *bulk_in; 650 struct usb_ep *bulk_in;
@@ -1104,7 +1104,7 @@ static void ep0_complete(struct usb_ep *ep, struct usb_request *req)
1104 if (req->actual > 0) 1104 if (req->actual > 0)
1105 dump_msg(fsg, fsg->ep0req_name, req->buf, req->actual); 1105 dump_msg(fsg, fsg->ep0req_name, req->buf, req->actual);
1106 if (req->status || req->actual != req->length) 1106 if (req->status || req->actual != req->length)
1107 DBG(fsg, "%s --> %d, %u/%u\n", __FUNCTION__, 1107 DBG(fsg, "%s --> %d, %u/%u\n", __func__,
1108 req->status, req->actual, req->length); 1108 req->status, req->actual, req->length);
1109 if (req->status == -ECONNRESET) // Request was cancelled 1109 if (req->status == -ECONNRESET) // Request was cancelled
1110 usb_ep_fifo_flush(ep); 1110 usb_ep_fifo_flush(ep);
@@ -1125,7 +1125,7 @@ static void bulk_in_complete(struct usb_ep *ep, struct usb_request *req)
1125 struct fsg_buffhd *bh = req->context; 1125 struct fsg_buffhd *bh = req->context;
1126 1126
1127 if (req->status || req->actual != req->length) 1127 if (req->status || req->actual != req->length)
1128 DBG(fsg, "%s --> %d, %u/%u\n", __FUNCTION__, 1128 DBG(fsg, "%s --> %d, %u/%u\n", __func__,
1129 req->status, req->actual, req->length); 1129 req->status, req->actual, req->length);
1130 if (req->status == -ECONNRESET) // Request was cancelled 1130 if (req->status == -ECONNRESET) // Request was cancelled
1131 usb_ep_fifo_flush(ep); 1131 usb_ep_fifo_flush(ep);
@@ -1146,7 +1146,7 @@ static void bulk_out_complete(struct usb_ep *ep, struct usb_request *req)
1146 1146
1147 dump_msg(fsg, "bulk-out", req->buf, req->actual); 1147 dump_msg(fsg, "bulk-out", req->buf, req->actual);
1148 if (req->status || req->actual != bh->bulk_out_intended_length) 1148 if (req->status || req->actual != bh->bulk_out_intended_length)
1149 DBG(fsg, "%s --> %d, %u/%u\n", __FUNCTION__, 1149 DBG(fsg, "%s --> %d, %u/%u\n", __func__,
1150 req->status, req->actual, 1150 req->status, req->actual,
1151 bh->bulk_out_intended_length); 1151 bh->bulk_out_intended_length);
1152 if (req->status == -ECONNRESET) // Request was cancelled 1152 if (req->status == -ECONNRESET) // Request was cancelled
@@ -1169,7 +1169,7 @@ static void intr_in_complete(struct usb_ep *ep, struct usb_request *req)
1169 struct fsg_buffhd *bh = req->context; 1169 struct fsg_buffhd *bh = req->context;
1170 1170
1171 if (req->status || req->actual != req->length) 1171 if (req->status || req->actual != req->length)
1172 DBG(fsg, "%s --> %d, %u/%u\n", __FUNCTION__, 1172 DBG(fsg, "%s --> %d, %u/%u\n", __func__,
1173 req->status, req->actual, req->length); 1173 req->status, req->actual, req->length);
1174 if (req->status == -ECONNRESET) // Request was cancelled 1174 if (req->status == -ECONNRESET) // Request was cancelled
1175 usb_ep_fifo_flush(ep); 1175 usb_ep_fifo_flush(ep);
@@ -2936,8 +2936,8 @@ static int received_cbw(struct fsg_dev *fsg, struct fsg_buffhd *bh)
2936 struct usb_request *req = bh->outreq; 2936 struct usb_request *req = bh->outreq;
2937 struct bulk_cb_wrap *cbw = req->buf; 2937 struct bulk_cb_wrap *cbw = req->buf;
2938 2938
2939 /* Was this a real packet? */ 2939 /* Was this a real packet? Should it be ignored? */
2940 if (req->status) 2940 if (req->status || test_bit(IGNORE_BULK_OUT, &fsg->atomic_bitflags))
2941 return -EINVAL; 2941 return -EINVAL;
2942 2942
2943 /* Is the CBW valid? */ 2943 /* Is the CBW valid? */
@@ -2948,13 +2948,17 @@ static int received_cbw(struct fsg_dev *fsg, struct fsg_buffhd *bh)
2948 req->actual, 2948 req->actual,
2949 le32_to_cpu(cbw->Signature)); 2949 le32_to_cpu(cbw->Signature));
2950 2950
2951 /* The Bulk-only spec says we MUST stall the bulk pipes! 2951 /* The Bulk-only spec says we MUST stall the IN endpoint
2952 * If we want to avoid stalls, set a flag so that we will 2952 * (6.6.1), so it's unavoidable. It also says we must
2953 * clear the endpoint halts at the next reset. */ 2953 * retain this state until the next reset, but there's
2954 if (!mod_data.can_stall) 2954 * no way to tell the controller driver it should ignore
2955 set_bit(CLEAR_BULK_HALTS, &fsg->atomic_bitflags); 2955 * Clear-Feature(HALT) requests.
2956 fsg_set_halt(fsg, fsg->bulk_out); 2956 *
2957 * We aren't required to halt the OUT endpoint; instead
2958 * we can simply accept and discard any data received
2959 * until the next reset. */
2957 halt_bulk_in_endpoint(fsg); 2960 halt_bulk_in_endpoint(fsg);
2961 set_bit(IGNORE_BULK_OUT, &fsg->atomic_bitflags);
2958 return -EINVAL; 2962 return -EINVAL;
2959 } 2963 }
2960 2964
@@ -3140,6 +3144,7 @@ reset:
3140 goto reset; 3144 goto reset;
3141 fsg->bulk_out_enabled = 1; 3145 fsg->bulk_out_enabled = 1;
3142 fsg->bulk_out_maxpacket = le16_to_cpu(d->wMaxPacketSize); 3146 fsg->bulk_out_maxpacket = le16_to_cpu(d->wMaxPacketSize);
3147 clear_bit(IGNORE_BULK_OUT, &fsg->atomic_bitflags);
3143 3148
3144 if (transport_is_cbi()) { 3149 if (transport_is_cbi()) {
3145 d = ep_desc(fsg->gadget, &fs_intr_in_desc, &hs_intr_in_desc); 3150 d = ep_desc(fsg->gadget, &fs_intr_in_desc, &hs_intr_in_desc);
@@ -3321,11 +3326,8 @@ static void handle_exception(struct fsg_dev *fsg)
3321 /* In case we were forced against our will to halt a 3326 /* In case we were forced against our will to halt a
3322 * bulk endpoint, clear the halt now. (The SuperH UDC 3327 * bulk endpoint, clear the halt now. (The SuperH UDC
3323 * requires this.) */ 3328 * requires this.) */
3324 if (test_and_clear_bit(CLEAR_BULK_HALTS, 3329 if (test_and_clear_bit(IGNORE_BULK_OUT, &fsg->atomic_bitflags))
3325 &fsg->atomic_bitflags)) {
3326 usb_ep_clear_halt(fsg->bulk_in); 3330 usb_ep_clear_halt(fsg->bulk_in);
3327 usb_ep_clear_halt(fsg->bulk_out);
3328 }
3329 3331
3330 if (transport_is_bbb()) { 3332 if (transport_is_bbb()) {
3331 if (fsg->ep0_req_tag == exception_req_tag) 3333 if (fsg->ep0_req_tag == exception_req_tag)
diff --git a/drivers/usb/gadget/fsl_usb2_udc.c b/drivers/usb/gadget/fsl_usb2_udc.c
index 254012ad2b9..651b8270139 100644
--- a/drivers/usb/gadget/fsl_usb2_udc.c
+++ b/drivers/usb/gadget/fsl_usb2_udc.c
@@ -773,11 +773,11 @@ fsl_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
773 /* catch various bogus parameters */ 773 /* catch various bogus parameters */
774 if (!_req || !req->req.complete || !req->req.buf 774 if (!_req || !req->req.complete || !req->req.buf
775 || !list_empty(&req->queue)) { 775 || !list_empty(&req->queue)) {
776 VDBG("%s, bad params\n", __FUNCTION__); 776 VDBG("%s, bad params\n", __func__);
777 return -EINVAL; 777 return -EINVAL;
778 } 778 }
779 if (unlikely(!_ep || !ep->desc)) { 779 if (unlikely(!_ep || !ep->desc)) {
780 VDBG("%s, bad ep\n", __FUNCTION__); 780 VDBG("%s, bad ep\n", __func__);
781 return -EINVAL; 781 return -EINVAL;
782 } 782 }
783 if (ep->desc->bmAttributes == USB_ENDPOINT_XFER_ISOC) { 783 if (ep->desc->bmAttributes == USB_ENDPOINT_XFER_ISOC) {
diff --git a/drivers/usb/gadget/fsl_usb2_udc.h b/drivers/usb/gadget/fsl_usb2_udc.h
index 9fb0b1ec852..98b1483ef6a 100644
--- a/drivers/usb/gadget/fsl_usb2_udc.h
+++ b/drivers/usb/gadget/fsl_usb2_udc.h
@@ -512,7 +512,7 @@ struct fsl_udc {
512 512
513#ifdef DEBUG 513#ifdef DEBUG
514#define DBG(fmt, args...) printk(KERN_DEBUG "[%s] " fmt "\n", \ 514#define DBG(fmt, args...) printk(KERN_DEBUG "[%s] " fmt "\n", \
515 __FUNCTION__, ## args) 515 __func__, ## args)
516#else 516#else
517#define DBG(fmt, args...) do{}while(0) 517#define DBG(fmt, args...) do{}while(0)
518#endif 518#endif
diff --git a/drivers/usb/gadget/gmidi.c b/drivers/usb/gadget/gmidi.c
index 5b42ccd0035..ff3a8513e64 100644
--- a/drivers/usb/gadget/gmidi.c
+++ b/drivers/usb/gadget/gmidi.c
@@ -1149,7 +1149,7 @@ fail:
1149/* 1149/*
1150 * Creates an output endpoint, and initializes output ports. 1150 * Creates an output endpoint, and initializes output ports.
1151 */ 1151 */
1152static int __devinit gmidi_bind(struct usb_gadget *gadget) 1152static int __init gmidi_bind(struct usb_gadget *gadget)
1153{ 1153{
1154 struct gmidi_device *dev; 1154 struct gmidi_device *dev;
1155 struct usb_ep *in_ep, *out_ep; 1155 struct usb_ep *in_ep, *out_ep;
diff --git a/drivers/usb/gadget/goku_udc.c b/drivers/usb/gadget/goku_udc.c
index d3e702576de..64a592cbbe7 100644
--- a/drivers/usb/gadget/goku_udc.c
+++ b/drivers/usb/gadget/goku_udc.c
@@ -692,7 +692,7 @@ static void abort_dma(struct goku_ep *ep, int status)
692 req->req.actual = (curr - req->req.dma) + 1; 692 req->req.actual = (curr - req->req.dma) + 1;
693 req->req.status = status; 693 req->req.status = status;
694 694
695 VDBG(ep->dev, "%s %s %s %d/%d\n", __FUNCTION__, ep->ep.name, 695 VDBG(ep->dev, "%s %s %s %d/%d\n", __func__, ep->ep.name,
696 ep->is_in ? "IN" : "OUT", 696 ep->is_in ? "IN" : "OUT",
697 req->req.actual, req->req.length); 697 req->req.actual, req->req.length);
698 698
@@ -826,7 +826,7 @@ static int goku_dequeue(struct usb_ep *_ep, struct usb_request *_req)
826 if (dev->ep0state == EP0_SUSPEND) 826 if (dev->ep0state == EP0_SUSPEND)
827 return -EBUSY; 827 return -EBUSY;
828 828
829 VDBG(dev, "%s %s %s %s %p\n", __FUNCTION__, _ep->name, 829 VDBG(dev, "%s %s %s %s %p\n", __func__, _ep->name,
830 ep->is_in ? "IN" : "OUT", 830 ep->is_in ? "IN" : "OUT",
831 ep->dma ? "dma" : "pio", 831 ep->dma ? "dma" : "pio",
832 _req); 832 _req);
@@ -898,7 +898,7 @@ static int goku_set_halt(struct usb_ep *_ep, int value)
898 898
899 /* don't change EPxSTATUS_EP_INVALID to READY */ 899 /* don't change EPxSTATUS_EP_INVALID to READY */
900 } else if (!ep->desc) { 900 } else if (!ep->desc) {
901 DBG(ep->dev, "%s %s inactive?\n", __FUNCTION__, ep->ep.name); 901 DBG(ep->dev, "%s %s inactive?\n", __func__, ep->ep.name);
902 return -EINVAL; 902 return -EINVAL;
903 } 903 }
904 904
@@ -940,7 +940,7 @@ static int goku_fifo_status(struct usb_ep *_ep)
940 regs = ep->dev->regs; 940 regs = ep->dev->regs;
941 size = readl(&regs->EPxSizeLA[ep->num]) & DATASIZE; 941 size = readl(&regs->EPxSizeLA[ep->num]) & DATASIZE;
942 size += readl(&regs->EPxSizeLB[ep->num]) & DATASIZE; 942 size += readl(&regs->EPxSizeLB[ep->num]) & DATASIZE;
943 VDBG(ep->dev, "%s %s %u\n", __FUNCTION__, ep->ep.name, size); 943 VDBG(ep->dev, "%s %s %u\n", __func__, ep->ep.name, size);
944 return size; 944 return size;
945} 945}
946 946
@@ -953,11 +953,11 @@ static void goku_fifo_flush(struct usb_ep *_ep)
953 if (!_ep) 953 if (!_ep)
954 return; 954 return;
955 ep = container_of(_ep, struct goku_ep, ep); 955 ep = container_of(_ep, struct goku_ep, ep);
956 VDBG(ep->dev, "%s %s\n", __FUNCTION__, ep->ep.name); 956 VDBG(ep->dev, "%s %s\n", __func__, ep->ep.name);
957 957
958 /* don't change EPxSTATUS_EP_INVALID to READY */ 958 /* don't change EPxSTATUS_EP_INVALID to READY */
959 if (!ep->desc && ep->num != 0) { 959 if (!ep->desc && ep->num != 0) {
960 DBG(ep->dev, "%s %s inactive?\n", __FUNCTION__, ep->ep.name); 960 DBG(ep->dev, "%s %s inactive?\n", __func__, ep->ep.name);
961 return; 961 return;
962 } 962 }
963 963
@@ -1286,7 +1286,7 @@ static void ep0_start(struct goku_udc *dev)
1286 struct goku_udc_regs __iomem *regs = dev->regs; 1286 struct goku_udc_regs __iomem *regs = dev->regs;
1287 unsigned i; 1287 unsigned i;
1288 1288
1289 VDBG(dev, "%s\n", __FUNCTION__); 1289 VDBG(dev, "%s\n", __func__);
1290 1290
1291 udc_reset(dev); 1291 udc_reset(dev);
1292 udc_reinit (dev); 1292 udc_reinit (dev);
@@ -1322,7 +1322,7 @@ static void udc_enable(struct goku_udc *dev)
1322 if (readl(&dev->regs->power_detect) & PW_DETECT) 1322 if (readl(&dev->regs->power_detect) & PW_DETECT)
1323 ep0_start(dev); 1323 ep0_start(dev);
1324 else { 1324 else {
1325 DBG(dev, "%s\n", __FUNCTION__); 1325 DBG(dev, "%s\n", __func__);
1326 dev->int_enable = INT_PWRDETECT; 1326 dev->int_enable = INT_PWRDETECT;
1327 writel(dev->int_enable, &dev->regs->int_enable); 1327 writel(dev->int_enable, &dev->regs->int_enable);
1328 } 1328 }
@@ -1387,7 +1387,7 @@ stop_activity(struct goku_udc *dev, struct usb_gadget_driver *driver)
1387{ 1387{
1388 unsigned i; 1388 unsigned i;
1389 1389
1390 DBG (dev, "%s\n", __FUNCTION__); 1390 DBG (dev, "%s\n", __func__);
1391 1391
1392 if (dev->gadget.speed == USB_SPEED_UNKNOWN) 1392 if (dev->gadget.speed == USB_SPEED_UNKNOWN)
1393 driver = NULL; 1393 driver = NULL;
@@ -1726,7 +1726,7 @@ static void goku_remove(struct pci_dev *pdev)
1726{ 1726{
1727 struct goku_udc *dev = pci_get_drvdata(pdev); 1727 struct goku_udc *dev = pci_get_drvdata(pdev);
1728 1728
1729 DBG(dev, "%s\n", __FUNCTION__); 1729 DBG(dev, "%s\n", __func__);
1730 1730
1731 BUG_ON(dev->driver); 1731 BUG_ON(dev->driver);
1732 1732
diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c
index 0a6feafc8d2..69b0a2754f2 100644
--- a/drivers/usb/gadget/inode.c
+++ b/drivers/usb/gadget/inode.c
@@ -1107,13 +1107,13 @@ scan:
1107 1107
1108 switch (state) { 1108 switch (state) {
1109 default: 1109 default:
1110 DBG (dev, "fail %s, state %d\n", __FUNCTION__, state); 1110 DBG (dev, "fail %s, state %d\n", __func__, state);
1111 retval = -ESRCH; 1111 retval = -ESRCH;
1112 break; 1112 break;
1113 case STATE_DEV_UNCONNECTED: 1113 case STATE_DEV_UNCONNECTED:
1114 case STATE_DEV_CONNECTED: 1114 case STATE_DEV_CONNECTED:
1115 spin_unlock_irq (&dev->lock); 1115 spin_unlock_irq (&dev->lock);
1116 DBG (dev, "%s wait\n", __FUNCTION__); 1116 DBG (dev, "%s wait\n", __func__);
1117 1117
1118 /* wait for events */ 1118 /* wait for events */
1119 retval = wait_event_interruptible (dev->wait, 1119 retval = wait_event_interruptible (dev->wait,
@@ -1222,7 +1222,7 @@ ep0_write (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
1222 DBG(dev, "bogus ep0out stall!\n"); 1222 DBG(dev, "bogus ep0out stall!\n");
1223 } 1223 }
1224 } else 1224 } else
1225 DBG (dev, "fail %s, state %d\n", __FUNCTION__, dev->state); 1225 DBG (dev, "fail %s, state %d\n", __func__, dev->state);
1226 1226
1227 spin_unlock_irq (&dev->lock); 1227 spin_unlock_irq (&dev->lock);
1228 return retval; 1228 return retval;
@@ -1233,7 +1233,7 @@ ep0_fasync (int f, struct file *fd, int on)
1233{ 1233{
1234 struct dev_data *dev = fd->private_data; 1234 struct dev_data *dev = fd->private_data;
1235 // caller must F_SETOWN before signal delivery happens 1235 // caller must F_SETOWN before signal delivery happens
1236 VDEBUG (dev, "%s %s\n", __FUNCTION__, on ? "on" : "off"); 1236 VDEBUG (dev, "%s %s\n", __func__, on ? "on" : "off");
1237 return fasync_helper (f, fd, on, &dev->fasync); 1237 return fasync_helper (f, fd, on, &dev->fasync);
1238} 1238}
1239 1239
@@ -1575,7 +1575,7 @@ static void destroy_ep_files (struct dev_data *dev)
1575{ 1575{
1576 struct list_head *entry, *tmp; 1576 struct list_head *entry, *tmp;
1577 1577
1578 DBG (dev, "%s %d\n", __FUNCTION__, dev->state); 1578 DBG (dev, "%s %d\n", __func__, dev->state);
1579 1579
1580 /* dev->state must prevent interference */ 1580 /* dev->state must prevent interference */
1581restart: 1581restart:
@@ -1662,7 +1662,7 @@ enomem1:
1662 put_dev (dev); 1662 put_dev (dev);
1663 kfree (data); 1663 kfree (data);
1664enomem0: 1664enomem0:
1665 DBG (dev, "%s enomem\n", __FUNCTION__); 1665 DBG (dev, "%s enomem\n", __func__);
1666 destroy_ep_files (dev); 1666 destroy_ep_files (dev);
1667 return -ENOMEM; 1667 return -ENOMEM;
1668} 1668}
@@ -1672,7 +1672,7 @@ gadgetfs_unbind (struct usb_gadget *gadget)
1672{ 1672{
1673 struct dev_data *dev = get_gadget_data (gadget); 1673 struct dev_data *dev = get_gadget_data (gadget);
1674 1674
1675 DBG (dev, "%s\n", __FUNCTION__); 1675 DBG (dev, "%s\n", __func__);
1676 1676
1677 spin_lock_irq (&dev->lock); 1677 spin_lock_irq (&dev->lock);
1678 dev->state = STATE_DEV_UNBOUND; 1678 dev->state = STATE_DEV_UNBOUND;
@@ -1685,7 +1685,7 @@ gadgetfs_unbind (struct usb_gadget *gadget)
1685 /* we've already been disconnected ... no i/o is active */ 1685 /* we've already been disconnected ... no i/o is active */
1686 if (dev->req) 1686 if (dev->req)
1687 usb_ep_free_request (gadget->ep0, dev->req); 1687 usb_ep_free_request (gadget->ep0, dev->req);
1688 DBG (dev, "%s done\n", __FUNCTION__); 1688 DBG (dev, "%s done\n", __func__);
1689 put_dev (dev); 1689 put_dev (dev);
1690} 1690}
1691 1691
@@ -1933,7 +1933,7 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
1933 1933
1934fail: 1934fail:
1935 spin_unlock_irq (&dev->lock); 1935 spin_unlock_irq (&dev->lock);
1936 pr_debug ("%s: %s fail %Zd, %p\n", shortname, __FUNCTION__, value, dev); 1936 pr_debug ("%s: %s fail %Zd, %p\n", shortname, __func__, value, dev);
1937 kfree (dev->buf); 1937 kfree (dev->buf);
1938 dev->buf = NULL; 1938 dev->buf = NULL;
1939 return value; 1939 return value;
diff --git a/drivers/usb/gadget/lh7a40x_udc.c b/drivers/usb/gadget/lh7a40x_udc.c
index 078f7246767..825abd2621b 100644
--- a/drivers/usb/gadget/lh7a40x_udc.c
+++ b/drivers/usb/gadget/lh7a40x_udc.c
@@ -253,7 +253,7 @@ udc_proc_read(char *page, char **start, off_t off, int count,
253 */ 253 */
254static void udc_disable(struct lh7a40x_udc *dev) 254static void udc_disable(struct lh7a40x_udc *dev)
255{ 255{
256 DEBUG("%s, %p\n", __FUNCTION__, dev); 256 DEBUG("%s, %p\n", __func__, dev);
257 257
258 udc_set_address(dev, 0); 258 udc_set_address(dev, 0);
259 259
@@ -285,7 +285,7 @@ static void udc_reinit(struct lh7a40x_udc *dev)
285{ 285{
286 u32 i; 286 u32 i;
287 287
288 DEBUG("%s, %p\n", __FUNCTION__, dev); 288 DEBUG("%s, %p\n", __func__, dev);
289 289
290 /* device/ep0 records init */ 290 /* device/ep0 records init */
291 INIT_LIST_HEAD(&dev->gadget.ep_list); 291 INIT_LIST_HEAD(&dev->gadget.ep_list);
@@ -318,7 +318,7 @@ static void udc_enable(struct lh7a40x_udc *dev)
318{ 318{
319 int ep; 319 int ep;
320 320
321 DEBUG("%s, %p\n", __FUNCTION__, dev); 321 DEBUG("%s, %p\n", __func__, dev);
322 322
323 dev->gadget.speed = USB_SPEED_UNKNOWN; 323 dev->gadget.speed = USB_SPEED_UNKNOWN;
324 324
@@ -412,7 +412,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
412 struct lh7a40x_udc *dev = the_controller; 412 struct lh7a40x_udc *dev = the_controller;
413 int retval; 413 int retval;
414 414
415 DEBUG("%s: %s\n", __FUNCTION__, driver->driver.name); 415 DEBUG("%s: %s\n", __func__, driver->driver.name);
416 416
417 if (!driver 417 if (!driver
418 || driver->speed != USB_SPEED_FULL 418 || driver->speed != USB_SPEED_FULL
@@ -521,7 +521,7 @@ static int write_fifo(struct lh7a40x_ep *ep, struct lh7a40x_request *req)
521 is_short = unlikely(max < ep_maxpacket(ep)); 521 is_short = unlikely(max < ep_maxpacket(ep));
522 } 522 }
523 523
524 DEBUG("%s: wrote %s %d bytes%s%s %d left %p\n", __FUNCTION__, 524 DEBUG("%s: wrote %s %d bytes%s%s %d left %p\n", __func__,
525 ep->ep.name, count, 525 ep->ep.name, count,
526 is_last ? "/L" : "", is_short ? "/S" : "", 526 is_last ? "/L" : "", is_short ? "/S" : "",
527 req->req.length - req->req.actual, req); 527 req->req.length - req->req.actual, req);
@@ -555,7 +555,7 @@ static int read_fifo(struct lh7a40x_ep *ep, struct lh7a40x_request *req)
555 /* make sure there's a packet in the FIFO. */ 555 /* make sure there's a packet in the FIFO. */
556 csr = usb_read(ep->csr1); 556 csr = usb_read(ep->csr1);
557 if (!(csr & USB_OUT_CSR1_OUT_PKT_RDY)) { 557 if (!(csr & USB_OUT_CSR1_OUT_PKT_RDY)) {
558 DEBUG("%s: Packet NOT ready!\n", __FUNCTION__); 558 DEBUG("%s: Packet NOT ready!\n", __func__);
559 return -EINVAL; 559 return -EINVAL;
560 } 560 }
561 561
@@ -614,7 +614,7 @@ static void done(struct lh7a40x_ep *ep, struct lh7a40x_request *req, int status)
614 unsigned int stopped = ep->stopped; 614 unsigned int stopped = ep->stopped;
615 u32 index; 615 u32 index;
616 616
617 DEBUG("%s, %p\n", __FUNCTION__, ep); 617 DEBUG("%s, %p\n", __func__, ep);
618 list_del_init(&req->queue); 618 list_del_init(&req->queue);
619 619
620 if (likely(req->req.status == -EINPROGRESS)) 620 if (likely(req->req.status == -EINPROGRESS))
@@ -644,7 +644,7 @@ static void done(struct lh7a40x_ep *ep, struct lh7a40x_request *req, int status)
644/** Enable EP interrupt */ 644/** Enable EP interrupt */
645static void pio_irq_enable(int ep) 645static void pio_irq_enable(int ep)
646{ 646{
647 DEBUG("%s: %d\n", __FUNCTION__, ep); 647 DEBUG("%s: %d\n", __func__, ep);
648 648
649 switch (ep) { 649 switch (ep) {
650 case 1: 650 case 1:
@@ -665,7 +665,7 @@ static void pio_irq_enable(int ep)
665/** Disable EP interrupt */ 665/** Disable EP interrupt */
666static void pio_irq_disable(int ep) 666static void pio_irq_disable(int ep)
667{ 667{
668 DEBUG("%s: %d\n", __FUNCTION__, ep); 668 DEBUG("%s: %d\n", __func__, ep);
669 669
670 switch (ep) { 670 switch (ep) {
671 case 1: 671 case 1:
@@ -690,7 +690,7 @@ void nuke(struct lh7a40x_ep *ep, int status)
690{ 690{
691 struct lh7a40x_request *req; 691 struct lh7a40x_request *req;
692 692
693 DEBUG("%s, %p\n", __FUNCTION__, ep); 693 DEBUG("%s, %p\n", __func__, ep);
694 694
695 /* Flush FIFO */ 695 /* Flush FIFO */
696 flush(ep); 696 flush(ep);
@@ -734,7 +734,7 @@ static void flush_all(struct lh7a40x_udc *dev)
734 */ 734 */
735static void flush(struct lh7a40x_ep *ep) 735static void flush(struct lh7a40x_ep *ep)
736{ 736{
737 DEBUG("%s, %p\n", __FUNCTION__, ep); 737 DEBUG("%s, %p\n", __func__, ep);
738 738
739 switch (ep->ep_type) { 739 switch (ep->ep_type) {
740 case ep_control: 740 case ep_control:
@@ -766,7 +766,7 @@ static void lh7a40x_in_epn(struct lh7a40x_udc *dev, u32 ep_idx, u32 intr)
766 usb_set_index(ep_idx); 766 usb_set_index(ep_idx);
767 767
768 csr = usb_read(ep->csr1); 768 csr = usb_read(ep->csr1);
769 DEBUG("%s: %d, csr %x\n", __FUNCTION__, ep_idx, csr); 769 DEBUG("%s: %d, csr %x\n", __func__, ep_idx, csr);
770 770
771 if (csr & USB_IN_CSR1_SENT_STALL) { 771 if (csr & USB_IN_CSR1_SENT_STALL) {
772 DEBUG("USB_IN_CSR1_SENT_STALL\n"); 772 DEBUG("USB_IN_CSR1_SENT_STALL\n");
@@ -776,7 +776,7 @@ static void lh7a40x_in_epn(struct lh7a40x_udc *dev, u32 ep_idx, u32 intr)
776 } 776 }
777 777
778 if (!ep->desc) { 778 if (!ep->desc) {
779 DEBUG("%s: NO EP DESC\n", __FUNCTION__); 779 DEBUG("%s: NO EP DESC\n", __func__);
780 return; 780 return;
781 } 781 }
782 782
@@ -802,7 +802,7 @@ static void lh7a40x_out_epn(struct lh7a40x_udc *dev, u32 ep_idx, u32 intr)
802 struct lh7a40x_ep *ep = &dev->ep[ep_idx]; 802 struct lh7a40x_ep *ep = &dev->ep[ep_idx];
803 struct lh7a40x_request *req; 803 struct lh7a40x_request *req;
804 804
805 DEBUG("%s: %d\n", __FUNCTION__, ep_idx); 805 DEBUG("%s: %d\n", __func__, ep_idx);
806 806
807 usb_set_index(ep_idx); 807 usb_set_index(ep_idx);
808 808
@@ -814,11 +814,11 @@ static void lh7a40x_out_epn(struct lh7a40x_udc *dev, u32 ep_idx, u32 intr)
814 usb_read(ep-> 814 usb_read(ep->
815 csr1)) & (USB_OUT_CSR1_OUT_PKT_RDY | 815 csr1)) & (USB_OUT_CSR1_OUT_PKT_RDY |
816 USB_OUT_CSR1_SENT_STALL)) { 816 USB_OUT_CSR1_SENT_STALL)) {
817 DEBUG("%s: %x\n", __FUNCTION__, csr); 817 DEBUG("%s: %x\n", __func__, csr);
818 818
819 if (csr & USB_OUT_CSR1_SENT_STALL) { 819 if (csr & USB_OUT_CSR1_SENT_STALL) {
820 DEBUG("%s: stall sent, flush fifo\n", 820 DEBUG("%s: stall sent, flush fifo\n",
821 __FUNCTION__); 821 __func__);
822 /* usb_set(USB_OUT_CSR1_FIFO_FLUSH, ep->csr1); */ 822 /* usb_set(USB_OUT_CSR1_FIFO_FLUSH, ep->csr1); */
823 flush(ep); 823 flush(ep);
824 } else if (csr & USB_OUT_CSR1_OUT_PKT_RDY) { 824 } else if (csr & USB_OUT_CSR1_OUT_PKT_RDY) {
@@ -832,7 +832,7 @@ static void lh7a40x_out_epn(struct lh7a40x_udc *dev, u32 ep_idx, u32 intr)
832 832
833 if (!req) { 833 if (!req) {
834 printk("%s: NULL REQ %d\n", 834 printk("%s: NULL REQ %d\n",
835 __FUNCTION__, ep_idx); 835 __func__, ep_idx);
836 flush(ep); 836 flush(ep);
837 break; 837 break;
838 } else { 838 } else {
@@ -844,7 +844,7 @@ static void lh7a40x_out_epn(struct lh7a40x_udc *dev, u32 ep_idx, u32 intr)
844 844
845 } else { 845 } else {
846 /* Throw packet away.. */ 846 /* Throw packet away.. */
847 printk("%s: No descriptor?!?\n", __FUNCTION__); 847 printk("%s: No descriptor?!?\n", __func__);
848 flush(ep); 848 flush(ep);
849 } 849 }
850} 850}
@@ -886,7 +886,7 @@ static void lh7a40x_reset_intr(struct lh7a40x_udc *dev)
886#if 0 /* def CONFIG_ARCH_LH7A404 */ 886#if 0 /* def CONFIG_ARCH_LH7A404 */
887 /* Does not work always... */ 887 /* Does not work always... */
888 888
889 DEBUG("%s: %d\n", __FUNCTION__, dev->usb_address); 889 DEBUG("%s: %d\n", __func__, dev->usb_address);
890 890
891 if (!dev->usb_address) { 891 if (!dev->usb_address) {
892 /*usb_set(USB_RESET_IO, USB_RESET); 892 /*usb_set(USB_RESET_IO, USB_RESET);
@@ -936,7 +936,7 @@ static irqreturn_t lh7a40x_udc_irq(int irq, void *_dev)
936 if (!intr_out && !intr_in && !intr_int) 936 if (!intr_out && !intr_in && !intr_int)
937 break; 937 break;
938 938
939 DEBUG("%s (on state %s)\n", __FUNCTION__, 939 DEBUG("%s (on state %s)\n", __func__,
940 state_names[dev->ep0state]); 940 state_names[dev->ep0state]);
941 DEBUG("intr_out = %x\n", intr_out); 941 DEBUG("intr_out = %x\n", intr_out);
942 DEBUG("intr_in = %x\n", intr_in); 942 DEBUG("intr_in = %x\n", intr_in);
@@ -1016,14 +1016,14 @@ static int lh7a40x_ep_enable(struct usb_ep *_ep,
1016 struct lh7a40x_udc *dev; 1016 struct lh7a40x_udc *dev;
1017 unsigned long flags; 1017 unsigned long flags;
1018 1018
1019 DEBUG("%s, %p\n", __FUNCTION__, _ep); 1019 DEBUG("%s, %p\n", __func__, _ep);
1020 1020
1021 ep = container_of(_ep, struct lh7a40x_ep, ep); 1021 ep = container_of(_ep, struct lh7a40x_ep, ep);
1022 if (!_ep || !desc || ep->desc || _ep->name == ep0name 1022 if (!_ep || !desc || ep->desc || _ep->name == ep0name
1023 || desc->bDescriptorType != USB_DT_ENDPOINT 1023 || desc->bDescriptorType != USB_DT_ENDPOINT
1024 || ep->bEndpointAddress != desc->bEndpointAddress 1024 || ep->bEndpointAddress != desc->bEndpointAddress
1025 || ep_maxpacket(ep) < le16_to_cpu(desc->wMaxPacketSize)) { 1025 || ep_maxpacket(ep) < le16_to_cpu(desc->wMaxPacketSize)) {
1026 DEBUG("%s, bad ep or descriptor\n", __FUNCTION__); 1026 DEBUG("%s, bad ep or descriptor\n", __func__);
1027 return -EINVAL; 1027 return -EINVAL;
1028 } 1028 }
1029 1029
@@ -1031,7 +1031,7 @@ static int lh7a40x_ep_enable(struct usb_ep *_ep,
1031 if (ep->bmAttributes != desc->bmAttributes 1031 if (ep->bmAttributes != desc->bmAttributes
1032 && ep->bmAttributes != USB_ENDPOINT_XFER_BULK 1032 && ep->bmAttributes != USB_ENDPOINT_XFER_BULK
1033 && desc->bmAttributes != USB_ENDPOINT_XFER_INT) { 1033 && desc->bmAttributes != USB_ENDPOINT_XFER_INT) {
1034 DEBUG("%s, %s type mismatch\n", __FUNCTION__, _ep->name); 1034 DEBUG("%s, %s type mismatch\n", __func__, _ep->name);
1035 return -EINVAL; 1035 return -EINVAL;
1036 } 1036 }
1037 1037
@@ -1039,13 +1039,13 @@ static int lh7a40x_ep_enable(struct usb_ep *_ep,
1039 if ((desc->bmAttributes == USB_ENDPOINT_XFER_BULK 1039 if ((desc->bmAttributes == USB_ENDPOINT_XFER_BULK
1040 && le16_to_cpu(desc->wMaxPacketSize) != ep_maxpacket(ep)) 1040 && le16_to_cpu(desc->wMaxPacketSize) != ep_maxpacket(ep))
1041 || !desc->wMaxPacketSize) { 1041 || !desc->wMaxPacketSize) {
1042 DEBUG("%s, bad %s maxpacket\n", __FUNCTION__, _ep->name); 1042 DEBUG("%s, bad %s maxpacket\n", __func__, _ep->name);
1043 return -ERANGE; 1043 return -ERANGE;
1044 } 1044 }
1045 1045
1046 dev = ep->dev; 1046 dev = ep->dev;
1047 if (!dev->driver || dev->gadget.speed == USB_SPEED_UNKNOWN) { 1047 if (!dev->driver || dev->gadget.speed == USB_SPEED_UNKNOWN) {
1048 DEBUG("%s, bogus device state\n", __FUNCTION__); 1048 DEBUG("%s, bogus device state\n", __func__);
1049 return -ESHUTDOWN; 1049 return -ESHUTDOWN;
1050 } 1050 }
1051 1051
@@ -1061,7 +1061,7 @@ static int lh7a40x_ep_enable(struct usb_ep *_ep,
1061 /* Reset halt state (does flush) */ 1061 /* Reset halt state (does flush) */
1062 lh7a40x_set_halt(_ep, 0); 1062 lh7a40x_set_halt(_ep, 0);
1063 1063
1064 DEBUG("%s: enabled %s\n", __FUNCTION__, _ep->name); 1064 DEBUG("%s: enabled %s\n", __func__, _ep->name);
1065 return 0; 1065 return 0;
1066} 1066}
1067 1067
@@ -1073,11 +1073,11 @@ static int lh7a40x_ep_disable(struct usb_ep *_ep)
1073 struct lh7a40x_ep *ep; 1073 struct lh7a40x_ep *ep;
1074 unsigned long flags; 1074 unsigned long flags;
1075 1075
1076 DEBUG("%s, %p\n", __FUNCTION__, _ep); 1076 DEBUG("%s, %p\n", __func__, _ep);
1077 1077
1078 ep = container_of(_ep, struct lh7a40x_ep, ep); 1078 ep = container_of(_ep, struct lh7a40x_ep, ep);
1079 if (!_ep || !ep->desc) { 1079 if (!_ep || !ep->desc) {
1080 DEBUG("%s, %s not enabled\n", __FUNCTION__, 1080 DEBUG("%s, %s not enabled\n", __func__,
1081 _ep ? ep->ep.name : NULL); 1081 _ep ? ep->ep.name : NULL);
1082 return -EINVAL; 1082 return -EINVAL;
1083 } 1083 }
@@ -1097,7 +1097,7 @@ static int lh7a40x_ep_disable(struct usb_ep *_ep)
1097 1097
1098 spin_unlock_irqrestore(&ep->dev->lock, flags); 1098 spin_unlock_irqrestore(&ep->dev->lock, flags);
1099 1099
1100 DEBUG("%s: disabled %s\n", __FUNCTION__, _ep->name); 1100 DEBUG("%s: disabled %s\n", __func__, _ep->name);
1101 return 0; 1101 return 0;
1102} 1102}
1103 1103
@@ -1106,7 +1106,7 @@ static struct usb_request *lh7a40x_alloc_request(struct usb_ep *ep,
1106{ 1106{
1107 struct lh7a40x_request *req; 1107 struct lh7a40x_request *req;
1108 1108
1109 DEBUG("%s, %p\n", __FUNCTION__, ep); 1109 DEBUG("%s, %p\n", __func__, ep);
1110 1110
1111 req = kzalloc(sizeof(*req), gfp_flags); 1111 req = kzalloc(sizeof(*req), gfp_flags);
1112 if (!req) 1112 if (!req)
@@ -1121,7 +1121,7 @@ static void lh7a40x_free_request(struct usb_ep *ep, struct usb_request *_req)
1121{ 1121{
1122 struct lh7a40x_request *req; 1122 struct lh7a40x_request *req;
1123 1123
1124 DEBUG("%s, %p\n", __FUNCTION__, ep); 1124 DEBUG("%s, %p\n", __func__, ep);
1125 1125
1126 req = container_of(_req, struct lh7a40x_request, req); 1126 req = container_of(_req, struct lh7a40x_request, req);
1127 WARN_ON(!list_empty(&req->queue)); 1127 WARN_ON(!list_empty(&req->queue));
@@ -1140,25 +1140,25 @@ static int lh7a40x_queue(struct usb_ep *_ep, struct usb_request *_req,
1140 struct lh7a40x_udc *dev; 1140 struct lh7a40x_udc *dev;
1141 unsigned long flags; 1141 unsigned long flags;
1142 1142
1143 DEBUG("\n\n\n%s, %p\n", __FUNCTION__, _ep); 1143 DEBUG("\n\n\n%s, %p\n", __func__, _ep);
1144 1144
1145 req = container_of(_req, struct lh7a40x_request, req); 1145 req = container_of(_req, struct lh7a40x_request, req);
1146 if (unlikely 1146 if (unlikely
1147 (!_req || !_req->complete || !_req->buf 1147 (!_req || !_req->complete || !_req->buf
1148 || !list_empty(&req->queue))) { 1148 || !list_empty(&req->queue))) {
1149 DEBUG("%s, bad params\n", __FUNCTION__); 1149 DEBUG("%s, bad params\n", __func__);
1150 return -EINVAL; 1150 return -EINVAL;
1151 } 1151 }
1152 1152
1153 ep = container_of(_ep, struct lh7a40x_ep, ep); 1153 ep = container_of(_ep, struct lh7a40x_ep, ep);
1154 if (unlikely(!_ep || (!ep->desc && ep->ep.name != ep0name))) { 1154 if (unlikely(!_ep || (!ep->desc && ep->ep.name != ep0name))) {
1155 DEBUG("%s, bad ep\n", __FUNCTION__); 1155 DEBUG("%s, bad ep\n", __func__);
1156 return -EINVAL; 1156 return -EINVAL;
1157 } 1157 }
1158 1158
1159 dev = ep->dev; 1159 dev = ep->dev;
1160 if (unlikely(!dev->driver || dev->gadget.speed == USB_SPEED_UNKNOWN)) { 1160 if (unlikely(!dev->driver || dev->gadget.speed == USB_SPEED_UNKNOWN)) {
1161 DEBUG("%s, bogus device state %p\n", __FUNCTION__, dev->driver); 1161 DEBUG("%s, bogus device state %p\n", __func__, dev->driver);
1162 return -ESHUTDOWN; 1162 return -ESHUTDOWN;
1163 } 1163 }
1164 1164
@@ -1218,7 +1218,7 @@ static int lh7a40x_dequeue(struct usb_ep *_ep, struct usb_request *_req)
1218 struct lh7a40x_request *req; 1218 struct lh7a40x_request *req;
1219 unsigned long flags; 1219 unsigned long flags;
1220 1220
1221 DEBUG("%s, %p\n", __FUNCTION__, _ep); 1221 DEBUG("%s, %p\n", __func__, _ep);
1222 1222
1223 ep = container_of(_ep, struct lh7a40x_ep, ep); 1223 ep = container_of(_ep, struct lh7a40x_ep, ep);
1224 if (!_ep || ep->ep.name == ep0name) 1224 if (!_ep || ep->ep.name == ep0name)
@@ -1253,13 +1253,13 @@ static int lh7a40x_set_halt(struct usb_ep *_ep, int value)
1253 1253
1254 ep = container_of(_ep, struct lh7a40x_ep, ep); 1254 ep = container_of(_ep, struct lh7a40x_ep, ep);
1255 if (unlikely(!_ep || (!ep->desc && ep->ep.name != ep0name))) { 1255 if (unlikely(!_ep || (!ep->desc && ep->ep.name != ep0name))) {
1256 DEBUG("%s, bad ep\n", __FUNCTION__); 1256 DEBUG("%s, bad ep\n", __func__);
1257 return -EINVAL; 1257 return -EINVAL;
1258 } 1258 }
1259 1259
1260 usb_set_index(ep_index(ep)); 1260 usb_set_index(ep_index(ep));
1261 1261
1262 DEBUG("%s, ep %d, val %d\n", __FUNCTION__, ep_index(ep), value); 1262 DEBUG("%s, ep %d, val %d\n", __func__, ep_index(ep), value);
1263 1263
1264 spin_lock_irqsave(&ep->dev->lock, flags); 1264 spin_lock_irqsave(&ep->dev->lock, flags);
1265 1265
@@ -1325,11 +1325,11 @@ static int lh7a40x_fifo_status(struct usb_ep *_ep)
1325 1325
1326 ep = container_of(_ep, struct lh7a40x_ep, ep); 1326 ep = container_of(_ep, struct lh7a40x_ep, ep);
1327 if (!_ep) { 1327 if (!_ep) {
1328 DEBUG("%s, bad ep\n", __FUNCTION__); 1328 DEBUG("%s, bad ep\n", __func__);
1329 return -ENODEV; 1329 return -ENODEV;
1330 } 1330 }
1331 1331
1332 DEBUG("%s, %d\n", __FUNCTION__, ep_index(ep)); 1332 DEBUG("%s, %d\n", __func__, ep_index(ep));
1333 1333
1334 /* LPD can't report unclaimed bytes from IN fifos */ 1334 /* LPD can't report unclaimed bytes from IN fifos */
1335 if (ep_is_in(ep)) 1335 if (ep_is_in(ep))
@@ -1355,7 +1355,7 @@ static void lh7a40x_fifo_flush(struct usb_ep *_ep)
1355 1355
1356 ep = container_of(_ep, struct lh7a40x_ep, ep); 1356 ep = container_of(_ep, struct lh7a40x_ep, ep);
1357 if (unlikely(!_ep || (!ep->desc && ep->ep.name != ep0name))) { 1357 if (unlikely(!_ep || (!ep->desc && ep->ep.name != ep0name))) {
1358 DEBUG("%s, bad ep\n", __FUNCTION__); 1358 DEBUG("%s, bad ep\n", __func__);
1359 return; 1359 return;
1360 } 1360 }
1361 1361
@@ -1376,7 +1376,7 @@ static int write_fifo_ep0(struct lh7a40x_ep *ep, struct lh7a40x_request *req)
1376 1376
1377 max = ep_maxpacket(ep); 1377 max = ep_maxpacket(ep);
1378 1378
1379 DEBUG_EP0("%s\n", __FUNCTION__); 1379 DEBUG_EP0("%s\n", __func__);
1380 1380
1381 count = write_packet(ep, req, max); 1381 count = write_packet(ep, req, max);
1382 1382
@@ -1390,7 +1390,7 @@ static int write_fifo_ep0(struct lh7a40x_ep *ep, struct lh7a40x_request *req)
1390 is_last = 1; 1390 is_last = 1;
1391 } 1391 }
1392 1392
1393 DEBUG_EP0("%s: wrote %s %d bytes%s %d left %p\n", __FUNCTION__, 1393 DEBUG_EP0("%s: wrote %s %d bytes%s %d left %p\n", __func__,
1394 ep->ep.name, count, 1394 ep->ep.name, count,
1395 is_last ? "/L" : "", req->req.length - req->req.actual, req); 1395 is_last ? "/L" : "", req->req.length - req->req.actual, req);
1396 1396
@@ -1434,7 +1434,7 @@ static int read_fifo_ep0(struct lh7a40x_ep *ep, struct lh7a40x_request *req)
1434 unsigned bufferspace, count, is_short; 1434 unsigned bufferspace, count, is_short;
1435 volatile u32 *fifo = (volatile u32 *)ep->fifo; 1435 volatile u32 *fifo = (volatile u32 *)ep->fifo;
1436 1436
1437 DEBUG_EP0("%s\n", __FUNCTION__); 1437 DEBUG_EP0("%s\n", __func__);
1438 1438
1439 csr = usb_read(USB_EP0_CSR); 1439 csr = usb_read(USB_EP0_CSR);
1440 if (!(csr & USB_OUT_CSR1_OUT_PKT_RDY)) 1440 if (!(csr & USB_OUT_CSR1_OUT_PKT_RDY))
@@ -1492,7 +1492,7 @@ static int read_fifo_ep0(struct lh7a40x_ep *ep, struct lh7a40x_request *req)
1492 */ 1492 */
1493static void udc_set_address(struct lh7a40x_udc *dev, unsigned char address) 1493static void udc_set_address(struct lh7a40x_udc *dev, unsigned char address)
1494{ 1494{
1495 DEBUG_EP0("%s: %d\n", __FUNCTION__, address); 1495 DEBUG_EP0("%s: %d\n", __func__, address);
1496 /* c.f. 15.1.2.2 Table 15-4 address will be used after DATA_END is set */ 1496 /* c.f. 15.1.2.2 Table 15-4 address will be used after DATA_END is set */
1497 dev->usb_address = address; 1497 dev->usb_address = address;
1498 usb_set((address & USB_FA_FUNCTION_ADDR), USB_FA); 1498 usb_set((address & USB_FA_FUNCTION_ADDR), USB_FA);
@@ -1514,7 +1514,7 @@ static void lh7a40x_ep0_out(struct lh7a40x_udc *dev, u32 csr)
1514 struct lh7a40x_ep *ep = &dev->ep[0]; 1514 struct lh7a40x_ep *ep = &dev->ep[0];
1515 int ret; 1515 int ret;
1516 1516
1517 DEBUG_EP0("%s: %x\n", __FUNCTION__, csr); 1517 DEBUG_EP0("%s: %x\n", __func__, csr);
1518 1518
1519 if (list_empty(&ep->queue)) 1519 if (list_empty(&ep->queue))
1520 req = 0; 1520 req = 0;
@@ -1533,13 +1533,13 @@ static void lh7a40x_ep0_out(struct lh7a40x_udc *dev, u32 csr)
1533 if (ret) { 1533 if (ret) {
1534 /* Done! */ 1534 /* Done! */
1535 DEBUG_EP0("%s: finished, waiting for status\n", 1535 DEBUG_EP0("%s: finished, waiting for status\n",
1536 __FUNCTION__); 1536 __func__);
1537 1537
1538 usb_set((EP0_CLR_OUT | EP0_DATA_END), USB_EP0_CSR); 1538 usb_set((EP0_CLR_OUT | EP0_DATA_END), USB_EP0_CSR);
1539 dev->ep0state = WAIT_FOR_SETUP; 1539 dev->ep0state = WAIT_FOR_SETUP;
1540 } else { 1540 } else {
1541 /* Not done yet.. */ 1541 /* Not done yet.. */
1542 DEBUG_EP0("%s: not finished\n", __FUNCTION__); 1542 DEBUG_EP0("%s: not finished\n", __func__);
1543 usb_set(EP0_CLR_OUT, USB_EP0_CSR); 1543 usb_set(EP0_CLR_OUT, USB_EP0_CSR);
1544 } 1544 }
1545 } else { 1545 } else {
@@ -1556,7 +1556,7 @@ static int lh7a40x_ep0_in(struct lh7a40x_udc *dev, u32 csr)
1556 struct lh7a40x_ep *ep = &dev->ep[0]; 1556 struct lh7a40x_ep *ep = &dev->ep[0];
1557 int ret, need_zlp = 0; 1557 int ret, need_zlp = 0;
1558 1558
1559 DEBUG_EP0("%s: %x\n", __FUNCTION__, csr); 1559 DEBUG_EP0("%s: %x\n", __func__, csr);
1560 1560
1561 if (list_empty(&ep->queue)) 1561 if (list_empty(&ep->queue))
1562 req = 0; 1562 req = 0;
@@ -1564,7 +1564,7 @@ static int lh7a40x_ep0_in(struct lh7a40x_udc *dev, u32 csr)
1564 req = list_entry(ep->queue.next, struct lh7a40x_request, queue); 1564 req = list_entry(ep->queue.next, struct lh7a40x_request, queue);
1565 1565
1566 if (!req) { 1566 if (!req) {
1567 DEBUG_EP0("%s: NULL REQ\n", __FUNCTION__); 1567 DEBUG_EP0("%s: NULL REQ\n", __func__);
1568 return 0; 1568 return 0;
1569 } 1569 }
1570 1570
@@ -1585,17 +1585,17 @@ static int lh7a40x_ep0_in(struct lh7a40x_udc *dev, u32 csr)
1585 1585
1586 if (ret == 1 && !need_zlp) { 1586 if (ret == 1 && !need_zlp) {
1587 /* Last packet */ 1587 /* Last packet */
1588 DEBUG_EP0("%s: finished, waiting for status\n", __FUNCTION__); 1588 DEBUG_EP0("%s: finished, waiting for status\n", __func__);
1589 1589
1590 usb_set((EP0_IN_PKT_RDY | EP0_DATA_END), USB_EP0_CSR); 1590 usb_set((EP0_IN_PKT_RDY | EP0_DATA_END), USB_EP0_CSR);
1591 dev->ep0state = WAIT_FOR_SETUP; 1591 dev->ep0state = WAIT_FOR_SETUP;
1592 } else { 1592 } else {
1593 DEBUG_EP0("%s: not finished\n", __FUNCTION__); 1593 DEBUG_EP0("%s: not finished\n", __func__);
1594 usb_set(EP0_IN_PKT_RDY, USB_EP0_CSR); 1594 usb_set(EP0_IN_PKT_RDY, USB_EP0_CSR);
1595 } 1595 }
1596 1596
1597 if (need_zlp) { 1597 if (need_zlp) {
1598 DEBUG_EP0("%s: Need ZLP!\n", __FUNCTION__); 1598 DEBUG_EP0("%s: Need ZLP!\n", __func__);
1599 usb_set(EP0_IN_PKT_RDY, USB_EP0_CSR); 1599 usb_set(EP0_IN_PKT_RDY, USB_EP0_CSR);
1600 dev->ep0state = DATA_STATE_NEED_ZLP; 1600 dev->ep0state = DATA_STATE_NEED_ZLP;
1601 } 1601 }
@@ -1694,7 +1694,7 @@ static void lh7a40x_ep0_setup(struct lh7a40x_udc *dev, u32 csr)
1694 struct usb_ctrlrequest ctrl; 1694 struct usb_ctrlrequest ctrl;
1695 int i, bytes, is_in; 1695 int i, bytes, is_in;
1696 1696
1697 DEBUG_SETUP("%s: %x\n", __FUNCTION__, csr); 1697 DEBUG_SETUP("%s: %x\n", __func__, csr);
1698 1698
1699 /* Nuke all previous transfers */ 1699 /* Nuke all previous transfers */
1700 nuke(ep, -EPROTO); 1700 nuke(ep, -EPROTO);
@@ -1799,7 +1799,7 @@ static void lh7a40x_ep0_setup(struct lh7a40x_udc *dev, u32 csr)
1799 */ 1799 */
1800static void lh7a40x_ep0_in_zlp(struct lh7a40x_udc *dev, u32 csr) 1800static void lh7a40x_ep0_in_zlp(struct lh7a40x_udc *dev, u32 csr)
1801{ 1801{
1802 DEBUG_EP0("%s: %x\n", __FUNCTION__, csr); 1802 DEBUG_EP0("%s: %x\n", __func__, csr);
1803 1803
1804 /* c.f. Table 15-14 */ 1804 /* c.f. Table 15-14 */
1805 usb_set((EP0_IN_PKT_RDY | EP0_DATA_END), USB_EP0_CSR); 1805 usb_set((EP0_IN_PKT_RDY | EP0_DATA_END), USB_EP0_CSR);
@@ -1818,7 +1818,7 @@ static void lh7a40x_handle_ep0(struct lh7a40x_udc *dev, u32 intr)
1818 usb_set_index(0); 1818 usb_set_index(0);
1819 csr = usb_read(USB_EP0_CSR); 1819 csr = usb_read(USB_EP0_CSR);
1820 1820
1821 DEBUG_EP0("%s: csr = %x\n", __FUNCTION__, csr); 1821 DEBUG_EP0("%s: csr = %x\n", __func__, csr);
1822 1822
1823 /* 1823 /*
1824 * For overview of what we should be doing see c.f. Chapter 18.1.2.4 1824 * For overview of what we should be doing see c.f. Chapter 18.1.2.4
@@ -1832,7 +1832,7 @@ static void lh7a40x_handle_ep0(struct lh7a40x_udc *dev, u32 intr)
1832 * - clear the SENT_STALL bit 1832 * - clear the SENT_STALL bit
1833 */ 1833 */
1834 if (csr & EP0_SENT_STALL) { 1834 if (csr & EP0_SENT_STALL) {
1835 DEBUG_EP0("%s: EP0_SENT_STALL is set: %x\n", __FUNCTION__, csr); 1835 DEBUG_EP0("%s: EP0_SENT_STALL is set: %x\n", __func__, csr);
1836 usb_clear((EP0_SENT_STALL | EP0_SEND_STALL), USB_EP0_CSR); 1836 usb_clear((EP0_SENT_STALL | EP0_SEND_STALL), USB_EP0_CSR);
1837 nuke(ep, -ECONNABORTED); 1837 nuke(ep, -ECONNABORTED);
1838 dev->ep0state = WAIT_FOR_SETUP; 1838 dev->ep0state = WAIT_FOR_SETUP;
@@ -1849,7 +1849,7 @@ static void lh7a40x_handle_ep0(struct lh7a40x_udc *dev, u32 intr)
1849 */ 1849 */
1850 if (!(csr & (EP0_IN_PKT_RDY | EP0_OUT_PKT_RDY))) { 1850 if (!(csr & (EP0_IN_PKT_RDY | EP0_OUT_PKT_RDY))) {
1851 DEBUG_EP0("%s: IN_PKT_RDY and OUT_PKT_RDY are clear\n", 1851 DEBUG_EP0("%s: IN_PKT_RDY and OUT_PKT_RDY are clear\n",
1852 __FUNCTION__); 1852 __func__);
1853 1853
1854 switch (dev->ep0state) { 1854 switch (dev->ep0state) {
1855 case DATA_STATE_XMIT: 1855 case DATA_STATE_XMIT:
@@ -1877,7 +1877,7 @@ static void lh7a40x_handle_ep0(struct lh7a40x_udc *dev, u32 intr)
1877 * - set SERVICED_SETUP_END_BIT 1877 * - set SERVICED_SETUP_END_BIT
1878 */ 1878 */
1879 if (csr & EP0_SETUP_END) { 1879 if (csr & EP0_SETUP_END) {
1880 DEBUG_EP0("%s: EP0_SETUP_END is set: %x\n", __FUNCTION__, csr); 1880 DEBUG_EP0("%s: EP0_SETUP_END is set: %x\n", __func__, csr);
1881 1881
1882 usb_set(EP0_CLR_SETUP_END, USB_EP0_CSR); 1882 usb_set(EP0_CLR_SETUP_END, USB_EP0_CSR);
1883 1883
@@ -1896,7 +1896,7 @@ static void lh7a40x_handle_ep0(struct lh7a40x_udc *dev, u32 intr)
1896 */ 1896 */
1897 if (csr & EP0_OUT_PKT_RDY) { 1897 if (csr & EP0_OUT_PKT_RDY) {
1898 1898
1899 DEBUG_EP0("%s: EP0_OUT_PKT_RDY is set: %x\n", __FUNCTION__, 1899 DEBUG_EP0("%s: EP0_OUT_PKT_RDY is set: %x\n", __func__,
1900 csr); 1900 csr);
1901 1901
1902 switch (dev->ep0state) { 1902 switch (dev->ep0state) {
@@ -1926,7 +1926,7 @@ static void lh7a40x_ep0_kick(struct lh7a40x_udc *dev, struct lh7a40x_ep *ep)
1926 usb_set_index(0); 1926 usb_set_index(0);
1927 csr = usb_read(USB_EP0_CSR); 1927 csr = usb_read(USB_EP0_CSR);
1928 1928
1929 DEBUG_EP0("%s: %x\n", __FUNCTION__, csr); 1929 DEBUG_EP0("%s: %x\n", __func__, csr);
1930 1930
1931 /* Clear "out packet ready" */ 1931 /* Clear "out packet ready" */
1932 usb_set(EP0_CLR_OUT, USB_EP0_CSR); 1932 usb_set(EP0_CLR_OUT, USB_EP0_CSR);
@@ -1949,7 +1949,7 @@ static int lh7a40x_udc_get_frame(struct usb_gadget *_gadget)
1949{ 1949{
1950 u32 frame1 = usb_read(USB_FRM_NUM1); /* Least significant 8 bits */ 1950 u32 frame1 = usb_read(USB_FRM_NUM1); /* Least significant 8 bits */
1951 u32 frame2 = usb_read(USB_FRM_NUM2); /* Most significant 3 bits */ 1951 u32 frame2 = usb_read(USB_FRM_NUM2); /* Most significant 3 bits */
1952 DEBUG("%s, %p\n", __FUNCTION__, _gadget); 1952 DEBUG("%s, %p\n", __func__, _gadget);
1953 return ((frame2 & 0x07) << 8) | (frame1 & 0xff); 1953 return ((frame2 & 0x07) << 8) | (frame1 & 0xff);
1954} 1954}
1955 1955
@@ -1970,7 +1970,7 @@ static const struct usb_gadget_ops lh7a40x_udc_ops = {
1970 1970
1971static void nop_release(struct device *dev) 1971static void nop_release(struct device *dev)
1972{ 1972{
1973 DEBUG("%s %s\n", __FUNCTION__, dev->bus_id); 1973 DEBUG("%s %s\n", __func__, dev->bus_id);
1974} 1974}
1975 1975
1976static struct lh7a40x_udc memory = { 1976static struct lh7a40x_udc memory = {
@@ -2065,7 +2065,7 @@ static int lh7a40x_udc_probe(struct platform_device *pdev)
2065 struct lh7a40x_udc *dev = &memory; 2065 struct lh7a40x_udc *dev = &memory;
2066 int retval; 2066 int retval;
2067 2067
2068 DEBUG("%s: %p\n", __FUNCTION__, pdev); 2068 DEBUG("%s: %p\n", __func__, pdev);
2069 2069
2070 spin_lock_init(&dev->lock); 2070 spin_lock_init(&dev->lock);
2071 dev->dev = &pdev->dev; 2071 dev->dev = &pdev->dev;
@@ -2098,7 +2098,7 @@ static int lh7a40x_udc_remove(struct platform_device *pdev)
2098{ 2098{
2099 struct lh7a40x_udc *dev = platform_get_drvdata(pdev); 2099 struct lh7a40x_udc *dev = platform_get_drvdata(pdev);
2100 2100
2101 DEBUG("%s: %p\n", __FUNCTION__, pdev); 2101 DEBUG("%s: %p\n", __func__, pdev);
2102 2102
2103 if (dev->driver) 2103 if (dev->driver)
2104 return -EBUSY; 2104 return -EBUSY;
@@ -2131,7 +2131,7 @@ static struct platform_driver udc_driver = {
2131 2131
2132static int __init udc_init(void) 2132static int __init udc_init(void)
2133{ 2133{
2134 DEBUG("%s: %s version %s\n", __FUNCTION__, driver_name, DRIVER_VERSION); 2134 DEBUG("%s: %s version %s\n", __func__, driver_name, DRIVER_VERSION);
2135 return platform_driver_register(&udc_driver); 2135 return platform_driver_register(&udc_driver);
2136} 2136}
2137 2137
diff --git a/drivers/usb/gadget/m66592-udc.h b/drivers/usb/gadget/m66592-udc.h
index 17b792b7f6b..be0a4c1f80a 100644
--- a/drivers/usb/gadget/m66592-udc.h
+++ b/drivers/usb/gadget/m66592-udc.h
@@ -486,10 +486,10 @@ struct m66592 {
486 486
487 struct usb_request *ep0_req; /* for internal request */ 487 struct usb_request *ep0_req; /* for internal request */
488 u16 ep0_data; /* for internal request */ 488 u16 ep0_data; /* for internal request */
489 u16 old_vbus;
489 490
490 struct timer_list timer; 491 struct timer_list timer;
491 492
492 u16 old_vbus;
493 int scount; 493 int scount;
494 494
495 int old_dvsq; 495 int old_dvsq;
diff --git a/drivers/usb/gadget/net2280.h b/drivers/usb/gadget/net2280.h
index 44ca139983d..1f2af398a9a 100644
--- a/drivers/usb/gadget/net2280.h
+++ b/drivers/usb/gadget/net2280.h
@@ -299,7 +299,7 @@ static inline void assert_out_naking (struct net2280_ep *ep, const char *where)
299 &ep->regs->ep_rsp); 299 &ep->regs->ep_rsp);
300 } 300 }
301} 301}
302#define ASSERT_OUT_NAKING(ep) assert_out_naking(ep,__FUNCTION__) 302#define ASSERT_OUT_NAKING(ep) assert_out_naking(ep,__func__)
303#else 303#else
304#define ASSERT_OUT_NAKING(ep) do {} while (0) 304#define ASSERT_OUT_NAKING(ep) do {} while (0)
305#endif 305#endif
diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c
index ee1e9a314cd..95f7662376f 100644
--- a/drivers/usb/gadget/omap_udc.c
+++ b/drivers/usb/gadget/omap_udc.c
@@ -163,7 +163,7 @@ static int omap_ep_enable(struct usb_ep *_ep,
163 || ep->bEndpointAddress != desc->bEndpointAddress 163 || ep->bEndpointAddress != desc->bEndpointAddress
164 || ep->maxpacket < le16_to_cpu 164 || ep->maxpacket < le16_to_cpu
165 (desc->wMaxPacketSize)) { 165 (desc->wMaxPacketSize)) {
166 DBG("%s, bad ep or descriptor\n", __FUNCTION__); 166 DBG("%s, bad ep or descriptor\n", __func__);
167 return -EINVAL; 167 return -EINVAL;
168 } 168 }
169 maxp = le16_to_cpu (desc->wMaxPacketSize); 169 maxp = le16_to_cpu (desc->wMaxPacketSize);
@@ -171,7 +171,7 @@ static int omap_ep_enable(struct usb_ep *_ep,
171 && maxp != ep->maxpacket) 171 && maxp != ep->maxpacket)
172 || le16_to_cpu(desc->wMaxPacketSize) > ep->maxpacket 172 || le16_to_cpu(desc->wMaxPacketSize) > ep->maxpacket
173 || !desc->wMaxPacketSize) { 173 || !desc->wMaxPacketSize) {
174 DBG("%s, bad %s maxpacket\n", __FUNCTION__, _ep->name); 174 DBG("%s, bad %s maxpacket\n", __func__, _ep->name);
175 return -ERANGE; 175 return -ERANGE;
176 } 176 }
177 177
@@ -194,13 +194,13 @@ static int omap_ep_enable(struct usb_ep *_ep,
194 if (ep->bmAttributes != desc->bmAttributes 194 if (ep->bmAttributes != desc->bmAttributes
195 && ep->bmAttributes != USB_ENDPOINT_XFER_BULK 195 && ep->bmAttributes != USB_ENDPOINT_XFER_BULK
196 && desc->bmAttributes != USB_ENDPOINT_XFER_INT) { 196 && desc->bmAttributes != USB_ENDPOINT_XFER_INT) {
197 DBG("%s, %s type mismatch\n", __FUNCTION__, _ep->name); 197 DBG("%s, %s type mismatch\n", __func__, _ep->name);
198 return -EINVAL; 198 return -EINVAL;
199 } 199 }
200 200
201 udc = ep->udc; 201 udc = ep->udc;
202 if (!udc->driver || udc->gadget.speed == USB_SPEED_UNKNOWN) { 202 if (!udc->driver || udc->gadget.speed == USB_SPEED_UNKNOWN) {
203 DBG("%s, bogus device state\n", __FUNCTION__); 203 DBG("%s, bogus device state\n", __func__);
204 return -ESHUTDOWN; 204 return -ESHUTDOWN;
205 } 205 }
206 206
@@ -249,7 +249,7 @@ static int omap_ep_disable(struct usb_ep *_ep)
249 unsigned long flags; 249 unsigned long flags;
250 250
251 if (!_ep || !ep->desc) { 251 if (!_ep || !ep->desc) {
252 DBG("%s, %s not enabled\n", __FUNCTION__, 252 DBG("%s, %s not enabled\n", __func__,
253 _ep ? ep->ep.name : NULL); 253 _ep ? ep->ep.name : NULL);
254 return -EINVAL; 254 return -EINVAL;
255 } 255 }
@@ -936,11 +936,11 @@ omap_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
936 /* catch various bogus parameters */ 936 /* catch various bogus parameters */
937 if (!_req || !req->req.complete || !req->req.buf 937 if (!_req || !req->req.complete || !req->req.buf
938 || !list_empty(&req->queue)) { 938 || !list_empty(&req->queue)) {
939 DBG("%s, bad params\n", __FUNCTION__); 939 DBG("%s, bad params\n", __func__);
940 return -EINVAL; 940 return -EINVAL;
941 } 941 }
942 if (!_ep || (!ep->desc && ep->bEndpointAddress)) { 942 if (!_ep || (!ep->desc && ep->bEndpointAddress)) {
943 DBG("%s, bad ep\n", __FUNCTION__); 943 DBG("%s, bad ep\n", __func__);
944 return -EINVAL; 944 return -EINVAL;
945 } 945 }
946 if (ep->bmAttributes == USB_ENDPOINT_XFER_ISOC) { 946 if (ep->bmAttributes == USB_ENDPOINT_XFER_ISOC) {
@@ -959,7 +959,7 @@ omap_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
959 && (ep->bEndpointAddress & USB_DIR_IN) == 0 959 && (ep->bEndpointAddress & USB_DIR_IN) == 0
960 && !cpu_class_is_omap2() 960 && !cpu_class_is_omap2()
961 && (req->req.length % ep->ep.maxpacket) != 0) { 961 && (req->req.length % ep->ep.maxpacket) != 0) {
962 DBG("%s, no partial packet OUT reads\n", __FUNCTION__); 962 DBG("%s, no partial packet OUT reads\n", __func__);
963 return -EMSGSIZE; 963 return -EMSGSIZE;
964 } 964 }
965 965
@@ -1265,8 +1265,6 @@ static int can_pullup(struct omap_udc *udc)
1265 1265
1266static void pullup_enable(struct omap_udc *udc) 1266static void pullup_enable(struct omap_udc *udc)
1267{ 1267{
1268 udc->gadget.dev.parent->power.power_state = PMSG_ON;
1269 udc->gadget.dev.power.power_state = PMSG_ON;
1270 UDC_SYSCON1_REG |= UDC_PULLUP_EN; 1268 UDC_SYSCON1_REG |= UDC_PULLUP_EN;
1271 if (!gadget_is_otg(&udc->gadget) && !cpu_is_omap15xx()) 1269 if (!gadget_is_otg(&udc->gadget) && !cpu_is_omap15xx())
1272 OTG_CTRL_REG |= OTG_BSESSVLD; 1270 OTG_CTRL_REG |= OTG_BSESSVLD;
@@ -3061,8 +3059,6 @@ static int omap_udc_suspend(struct platform_device *dev, pm_message_t message)
3061 omap_pullup(&udc->gadget, 0); 3059 omap_pullup(&udc->gadget, 0);
3062 } 3060 }
3063 3061
3064 udc->gadget.dev.power.power_state = PMSG_SUSPEND;
3065 udc->gadget.dev.parent->power.power_state = PMSG_SUSPEND;
3066 return 0; 3062 return 0;
3067} 3063}
3068 3064
diff --git a/drivers/usb/gadget/printer.c b/drivers/usb/gadget/printer.c
index 2c32bd08ee7..76be75e3ab8 100644
--- a/drivers/usb/gadget/printer.c
+++ b/drivers/usb/gadget/printer.c
@@ -390,9 +390,12 @@ static void rx_complete(struct usb_ep *ep, struct usb_request *req)
390 390
391 /* normal completion */ 391 /* normal completion */
392 case 0: 392 case 0:
393 list_add_tail(&req->list, &dev->rx_buffers); 393 if (req->actual > 0) {
394 wake_up_interruptible(&dev->rx_wait); 394 list_add_tail(&req->list, &dev->rx_buffers);
395 DBG(dev, "G_Printer : rx length %d\n", req->actual); 395 DBG(dev, "G_Printer : rx length %d\n", req->actual);
396 } else {
397 list_add(&req->list, &dev->rx_reqs);
398 }
396 break; 399 break;
397 400
398 /* software-driven interface shutdown */ 401 /* software-driven interface shutdown */
@@ -417,6 +420,8 @@ static void rx_complete(struct usb_ep *ep, struct usb_request *req)
417 list_add(&req->list, &dev->rx_reqs); 420 list_add(&req->list, &dev->rx_reqs);
418 break; 421 break;
419 } 422 }
423
424 wake_up_interruptible(&dev->rx_wait);
420 spin_unlock_irqrestore(&dev->lock, flags); 425 spin_unlock_irqrestore(&dev->lock, flags);
421} 426}
422 427
@@ -494,6 +499,39 @@ printer_close(struct inode *inode, struct file *fd)
494 return 0; 499 return 0;
495} 500}
496 501
502/* This function must be called with interrupts turned off. */
503static void
504setup_rx_reqs(struct printer_dev *dev)
505{
506 struct usb_request *req;
507
508 while (likely(!list_empty(&dev->rx_reqs))) {
509 int error;
510
511 req = container_of(dev->rx_reqs.next,
512 struct usb_request, list);
513 list_del_init(&req->list);
514
515 /* The USB Host sends us whatever amount of data it wants to
516 * so we always set the length field to the full USB_BUFSIZE.
517 * If the amount of data is more than the read() caller asked
518 * for it will be stored in the request buffer until it is
519 * asked for by read().
520 */
521 req->length = USB_BUFSIZE;
522 req->complete = rx_complete;
523
524 error = usb_ep_queue(dev->out_ep, req, GFP_ATOMIC);
525 if (error) {
526 DBG(dev, "rx submit --> %d\n", error);
527 list_add(&req->list, &dev->rx_reqs);
528 break;
529 } else {
530 list_add(&req->list, &dev->rx_reqs_active);
531 }
532 }
533}
534
497static ssize_t 535static ssize_t
498printer_read(struct file *fd, char __user *buf, size_t len, loff_t *ptr) 536printer_read(struct file *fd, char __user *buf, size_t len, loff_t *ptr)
499{ 537{
@@ -522,31 +560,7 @@ printer_read(struct file *fd, char __user *buf, size_t len, loff_t *ptr)
522 */ 560 */
523 dev->reset_printer = 0; 561 dev->reset_printer = 0;
524 562
525 while (likely(!list_empty(&dev->rx_reqs))) { 563 setup_rx_reqs(dev);
526 int error;
527
528 req = container_of(dev->rx_reqs.next,
529 struct usb_request, list);
530 list_del_init(&req->list);
531
532 /* The USB Host sends us whatever amount of data it wants to
533 * so we always set the length field to the full USB_BUFSIZE.
534 * If the amount of data is more than the read() caller asked
535 * for it will be stored in the request buffer until it is
536 * asked for by read().
537 */
538 req->length = USB_BUFSIZE;
539 req->complete = rx_complete;
540
541 error = usb_ep_queue(dev->out_ep, req, GFP_ATOMIC);
542 if (error) {
543 DBG(dev, "rx submit --> %d\n", error);
544 list_add(&req->list, &dev->rx_reqs);
545 break;
546 } else {
547 list_add(&req->list, &dev->rx_reqs_active);
548 }
549 }
550 564
551 bytes_copied = 0; 565 bytes_copied = 0;
552 current_rx_req = dev->current_rx_req; 566 current_rx_req = dev->current_rx_req;
@@ -615,9 +629,9 @@ printer_read(struct file *fd, char __user *buf, size_t len, loff_t *ptr)
615 629
616 spin_lock_irqsave(&dev->lock, flags); 630 spin_lock_irqsave(&dev->lock, flags);
617 631
618 /* We've disconnected or reset free the req and buffer */ 632 /* We've disconnected or reset so return. */
619 if (dev->reset_printer) { 633 if (dev->reset_printer) {
620 printer_req_free(dev->out_ep, current_rx_req); 634 list_add(&current_rx_req->list, &dev->rx_reqs);
621 spin_unlock_irqrestore(&dev->lock, flags); 635 spin_unlock_irqrestore(&dev->lock, flags);
622 spin_unlock(&dev->lock_printer_io); 636 spin_unlock(&dev->lock_printer_io);
623 return -EAGAIN; 637 return -EAGAIN;
@@ -735,7 +749,7 @@ printer_write(struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
735 749
736 /* We've disconnected or reset so free the req and buffer */ 750 /* We've disconnected or reset so free the req and buffer */
737 if (dev->reset_printer) { 751 if (dev->reset_printer) {
738 printer_req_free(dev->in_ep, req); 752 list_add(&req->list, &dev->tx_reqs);
739 spin_unlock_irqrestore(&dev->lock, flags); 753 spin_unlock_irqrestore(&dev->lock, flags);
740 spin_unlock(&dev->lock_printer_io); 754 spin_unlock(&dev->lock_printer_io);
741 return -EAGAIN; 755 return -EAGAIN;
@@ -791,6 +805,12 @@ printer_poll(struct file *fd, poll_table *wait)
791 unsigned long flags; 805 unsigned long flags;
792 int status = 0; 806 int status = 0;
793 807
808 spin_lock(&dev->lock_printer_io);
809 spin_lock_irqsave(&dev->lock, flags);
810 setup_rx_reqs(dev);
811 spin_unlock_irqrestore(&dev->lock, flags);
812 spin_unlock(&dev->lock_printer_io);
813
794 poll_wait(fd, &dev->rx_wait, wait); 814 poll_wait(fd, &dev->rx_wait, wait);
795 poll_wait(fd, &dev->tx_wait, wait); 815 poll_wait(fd, &dev->tx_wait, wait);
796 816
@@ -798,7 +818,8 @@ printer_poll(struct file *fd, poll_table *wait)
798 if (likely(!list_empty(&dev->tx_reqs))) 818 if (likely(!list_empty(&dev->tx_reqs)))
799 status |= POLLOUT | POLLWRNORM; 819 status |= POLLOUT | POLLWRNORM;
800 820
801 if (likely(!list_empty(&dev->rx_buffers))) 821 if (likely(dev->current_rx_bytes) ||
822 likely(!list_empty(&dev->rx_buffers)))
802 status |= POLLIN | POLLRDNORM; 823 status |= POLLIN | POLLRDNORM;
803 824
804 spin_unlock_irqrestore(&dev->lock, flags); 825 spin_unlock_irqrestore(&dev->lock, flags);
@@ -894,7 +915,7 @@ static void printer_reset_interface(struct printer_dev *dev)
894 if (dev->interface < 0) 915 if (dev->interface < 0)
895 return; 916 return;
896 917
897 DBG(dev, "%s\n", __FUNCTION__); 918 DBG(dev, "%s\n", __func__);
898 919
899 if (dev->in) 920 if (dev->in)
900 usb_ep_disable(dev->in_ep); 921 usb_ep_disable(dev->in_ep);
@@ -1084,6 +1105,7 @@ static void printer_soft_reset(struct printer_dev *dev)
1084 if (usb_ep_enable(dev->out_ep, dev->out)) 1105 if (usb_ep_enable(dev->out_ep, dev->out))
1085 DBG(dev, "Failed to enable USB out_ep\n"); 1106 DBG(dev, "Failed to enable USB out_ep\n");
1086 1107
1108 wake_up_interruptible(&dev->rx_wait);
1087 wake_up_interruptible(&dev->tx_wait); 1109 wake_up_interruptible(&dev->tx_wait);
1088 wake_up_interruptible(&dev->tx_flush_wait); 1110 wake_up_interruptible(&dev->tx_flush_wait);
1089} 1111}
@@ -1262,7 +1284,7 @@ printer_disconnect(struct usb_gadget *gadget)
1262 struct printer_dev *dev = get_gadget_data(gadget); 1284 struct printer_dev *dev = get_gadget_data(gadget);
1263 unsigned long flags; 1285 unsigned long flags;
1264 1286
1265 DBG(dev, "%s\n", __FUNCTION__); 1287 DBG(dev, "%s\n", __func__);
1266 1288
1267 spin_lock_irqsave(&dev->lock, flags); 1289 spin_lock_irqsave(&dev->lock, flags);
1268 1290
@@ -1278,7 +1300,7 @@ printer_unbind(struct usb_gadget *gadget)
1278 struct usb_request *req; 1300 struct usb_request *req;
1279 1301
1280 1302
1281 DBG(dev, "%s\n", __FUNCTION__); 1303 DBG(dev, "%s\n", __func__);
1282 1304
1283 /* Remove sysfs files */ 1305 /* Remove sysfs files */
1284 device_destroy(usb_gadget_class, g_printer_devno); 1306 device_destroy(usb_gadget_class, g_printer_devno);
diff --git a/drivers/usb/gadget/pxa2xx_udc.c b/drivers/usb/gadget/pxa2xx_udc.c
index c00cd8b9d3d..08f699b1fc5 100644
--- a/drivers/usb/gadget/pxa2xx_udc.c
+++ b/drivers/usb/gadget/pxa2xx_udc.c
@@ -235,7 +235,7 @@ static int pxa2xx_ep_enable (struct usb_ep *_ep,
235 || ep->bEndpointAddress != desc->bEndpointAddress 235 || ep->bEndpointAddress != desc->bEndpointAddress
236 || ep->fifo_size < le16_to_cpu 236 || ep->fifo_size < le16_to_cpu
237 (desc->wMaxPacketSize)) { 237 (desc->wMaxPacketSize)) {
238 DMSG("%s, bad ep or descriptor\n", __FUNCTION__); 238 DMSG("%s, bad ep or descriptor\n", __func__);
239 return -EINVAL; 239 return -EINVAL;
240 } 240 }
241 241
@@ -243,7 +243,7 @@ static int pxa2xx_ep_enable (struct usb_ep *_ep,
243 if (ep->bmAttributes != desc->bmAttributes 243 if (ep->bmAttributes != desc->bmAttributes
244 && ep->bmAttributes != USB_ENDPOINT_XFER_BULK 244 && ep->bmAttributes != USB_ENDPOINT_XFER_BULK
245 && desc->bmAttributes != USB_ENDPOINT_XFER_INT) { 245 && desc->bmAttributes != USB_ENDPOINT_XFER_INT) {
246 DMSG("%s, %s type mismatch\n", __FUNCTION__, _ep->name); 246 DMSG("%s, %s type mismatch\n", __func__, _ep->name);
247 return -EINVAL; 247 return -EINVAL;
248 } 248 }
249 249
@@ -252,13 +252,13 @@ static int pxa2xx_ep_enable (struct usb_ep *_ep,
252 && le16_to_cpu (desc->wMaxPacketSize) 252 && le16_to_cpu (desc->wMaxPacketSize)
253 != BULK_FIFO_SIZE) 253 != BULK_FIFO_SIZE)
254 || !desc->wMaxPacketSize) { 254 || !desc->wMaxPacketSize) {
255 DMSG("%s, bad %s maxpacket\n", __FUNCTION__, _ep->name); 255 DMSG("%s, bad %s maxpacket\n", __func__, _ep->name);
256 return -ERANGE; 256 return -ERANGE;
257 } 257 }
258 258
259 dev = ep->dev; 259 dev = ep->dev;
260 if (!dev->driver || dev->gadget.speed == USB_SPEED_UNKNOWN) { 260 if (!dev->driver || dev->gadget.speed == USB_SPEED_UNKNOWN) {
261 DMSG("%s, bogus device state\n", __FUNCTION__); 261 DMSG("%s, bogus device state\n", __func__);
262 return -ESHUTDOWN; 262 return -ESHUTDOWN;
263 } 263 }
264 264
@@ -283,7 +283,7 @@ static int pxa2xx_ep_disable (struct usb_ep *_ep)
283 283
284 ep = container_of (_ep, struct pxa2xx_ep, ep); 284 ep = container_of (_ep, struct pxa2xx_ep, ep);
285 if (!_ep || !ep->desc) { 285 if (!_ep || !ep->desc) {
286 DMSG("%s, %s not enabled\n", __FUNCTION__, 286 DMSG("%s, %s not enabled\n", __func__,
287 _ep ? ep->ep.name : NULL); 287 _ep ? ep->ep.name : NULL);
288 return -EINVAL; 288 return -EINVAL;
289 } 289 }
@@ -461,7 +461,7 @@ void ep0start(struct pxa2xx_udc *dev, u32 flags, const char *tag)
461 USIR0 = USIR0_IR0; 461 USIR0 = USIR0_IR0;
462 dev->req_pending = 0; 462 dev->req_pending = 0;
463 DBG(DBG_VERY_NOISY, "%s %s, %02x/%02x\n", 463 DBG(DBG_VERY_NOISY, "%s %s, %02x/%02x\n",
464 __FUNCTION__, tag, UDCCS0, flags); 464 __func__, tag, UDCCS0, flags);
465} 465}
466 466
467static int 467static int
@@ -651,20 +651,20 @@ pxa2xx_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
651 req = container_of(_req, struct pxa2xx_request, req); 651 req = container_of(_req, struct pxa2xx_request, req);
652 if (unlikely (!_req || !_req->complete || !_req->buf 652 if (unlikely (!_req || !_req->complete || !_req->buf
653 || !list_empty(&req->queue))) { 653 || !list_empty(&req->queue))) {
654 DMSG("%s, bad params\n", __FUNCTION__); 654 DMSG("%s, bad params\n", __func__);
655 return -EINVAL; 655 return -EINVAL;
656 } 656 }
657 657
658 ep = container_of(_ep, struct pxa2xx_ep, ep); 658 ep = container_of(_ep, struct pxa2xx_ep, ep);
659 if (unlikely (!_ep || (!ep->desc && ep->ep.name != ep0name))) { 659 if (unlikely (!_ep || (!ep->desc && ep->ep.name != ep0name))) {
660 DMSG("%s, bad ep\n", __FUNCTION__); 660 DMSG("%s, bad ep\n", __func__);
661 return -EINVAL; 661 return -EINVAL;
662 } 662 }
663 663
664 dev = ep->dev; 664 dev = ep->dev;
665 if (unlikely (!dev->driver 665 if (unlikely (!dev->driver
666 || dev->gadget.speed == USB_SPEED_UNKNOWN)) { 666 || dev->gadget.speed == USB_SPEED_UNKNOWN)) {
667 DMSG("%s, bogus device state\n", __FUNCTION__); 667 DMSG("%s, bogus device state\n", __func__);
668 return -ESHUTDOWN; 668 return -ESHUTDOWN;
669 } 669 }
670 670
@@ -807,7 +807,7 @@ static int pxa2xx_ep_set_halt(struct usb_ep *_ep, int value)
807 if (unlikely (!_ep 807 if (unlikely (!_ep
808 || (!ep->desc && ep->ep.name != ep0name)) 808 || (!ep->desc && ep->ep.name != ep0name))
809 || ep->bmAttributes == USB_ENDPOINT_XFER_ISOC) { 809 || ep->bmAttributes == USB_ENDPOINT_XFER_ISOC) {
810 DMSG("%s, bad ep\n", __FUNCTION__); 810 DMSG("%s, bad ep\n", __func__);
811 return -EINVAL; 811 return -EINVAL;
812 } 812 }
813 if (value == 0) { 813 if (value == 0) {
@@ -859,7 +859,7 @@ static int pxa2xx_ep_fifo_status(struct usb_ep *_ep)
859 859
860 ep = container_of(_ep, struct pxa2xx_ep, ep); 860 ep = container_of(_ep, struct pxa2xx_ep, ep);
861 if (!_ep) { 861 if (!_ep) {
862 DMSG("%s, bad ep\n", __FUNCTION__); 862 DMSG("%s, bad ep\n", __func__);
863 return -ENODEV; 863 return -ENODEV;
864 } 864 }
865 /* pxa can't report unclaimed bytes from IN fifos */ 865 /* pxa can't report unclaimed bytes from IN fifos */
@@ -878,7 +878,7 @@ static void pxa2xx_ep_fifo_flush(struct usb_ep *_ep)
878 878
879 ep = container_of(_ep, struct pxa2xx_ep, ep); 879 ep = container_of(_ep, struct pxa2xx_ep, ep);
880 if (!_ep || ep->ep.name == ep0name || !list_empty(&ep->queue)) { 880 if (!_ep || ep->ep.name == ep0name || !list_empty(&ep->queue)) {
881 DMSG("%s, bad ep\n", __FUNCTION__); 881 DMSG("%s, bad ep\n", __func__);
882 return; 882 return;
883 } 883 }
884 884
@@ -1813,7 +1813,7 @@ pxa2xx_udc_irq(int irq, void *_dev)
1813 1813
1814static void nop_release (struct device *dev) 1814static void nop_release (struct device *dev)
1815{ 1815{
1816 DMSG("%s %s\n", __FUNCTION__, dev->bus_id); 1816 DMSG("%s %s\n", __func__, dev->bus_id);
1817} 1817}
1818 1818
1819/* this uses load-time allocation and initialization (instead of 1819/* this uses load-time allocation and initialization (instead of
diff --git a/drivers/usb/gadget/rndis.c b/drivers/usb/gadget/rndis.c
index 3d036647431..bd58dd504f6 100644
--- a/drivers/usb/gadget/rndis.c
+++ b/drivers/usb/gadget/rndis.c
@@ -204,7 +204,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
204 204
205 /* mandatory */ 205 /* mandatory */
206 case OID_GEN_SUPPORTED_LIST: 206 case OID_GEN_SUPPORTED_LIST:
207 DBG("%s: OID_GEN_SUPPORTED_LIST\n", __FUNCTION__); 207 DBG("%s: OID_GEN_SUPPORTED_LIST\n", __func__);
208 length = sizeof (oid_supported_list); 208 length = sizeof (oid_supported_list);
209 count = length / sizeof (u32); 209 count = length / sizeof (u32);
210 for (i = 0; i < count; i++) 210 for (i = 0; i < count; i++)
@@ -214,7 +214,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
214 214
215 /* mandatory */ 215 /* mandatory */
216 case OID_GEN_HARDWARE_STATUS: 216 case OID_GEN_HARDWARE_STATUS:
217 DBG("%s: OID_GEN_HARDWARE_STATUS\n", __FUNCTION__); 217 DBG("%s: OID_GEN_HARDWARE_STATUS\n", __func__);
218 /* Bogus question! 218 /* Bogus question!
219 * Hardware must be ready to receive high level protocols. 219 * Hardware must be ready to receive high level protocols.
220 * BTW: 220 * BTW:
@@ -227,14 +227,14 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
227 227
228 /* mandatory */ 228 /* mandatory */
229 case OID_GEN_MEDIA_SUPPORTED: 229 case OID_GEN_MEDIA_SUPPORTED:
230 DBG("%s: OID_GEN_MEDIA_SUPPORTED\n", __FUNCTION__); 230 DBG("%s: OID_GEN_MEDIA_SUPPORTED\n", __func__);
231 *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr].medium); 231 *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr].medium);
232 retval = 0; 232 retval = 0;
233 break; 233 break;
234 234
235 /* mandatory */ 235 /* mandatory */
236 case OID_GEN_MEDIA_IN_USE: 236 case OID_GEN_MEDIA_IN_USE:
237 DBG("%s: OID_GEN_MEDIA_IN_USE\n", __FUNCTION__); 237 DBG("%s: OID_GEN_MEDIA_IN_USE\n", __func__);
238 /* one medium, one transport... (maybe you do it better) */ 238 /* one medium, one transport... (maybe you do it better) */
239 *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr].medium); 239 *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr].medium);
240 retval = 0; 240 retval = 0;
@@ -242,7 +242,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
242 242
243 /* mandatory */ 243 /* mandatory */
244 case OID_GEN_MAXIMUM_FRAME_SIZE: 244 case OID_GEN_MAXIMUM_FRAME_SIZE:
245 DBG("%s: OID_GEN_MAXIMUM_FRAME_SIZE\n", __FUNCTION__); 245 DBG("%s: OID_GEN_MAXIMUM_FRAME_SIZE\n", __func__);
246 if (rndis_per_dev_params [configNr].dev) { 246 if (rndis_per_dev_params [configNr].dev) {
247 *outbuf = cpu_to_le32 ( 247 *outbuf = cpu_to_le32 (
248 rndis_per_dev_params [configNr].dev->mtu); 248 rndis_per_dev_params [configNr].dev->mtu);
@@ -253,7 +253,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
253 /* mandatory */ 253 /* mandatory */
254 case OID_GEN_LINK_SPEED: 254 case OID_GEN_LINK_SPEED:
255 if (rndis_debug > 1) 255 if (rndis_debug > 1)
256 DBG("%s: OID_GEN_LINK_SPEED\n", __FUNCTION__); 256 DBG("%s: OID_GEN_LINK_SPEED\n", __func__);
257 if (rndis_per_dev_params [configNr].media_state 257 if (rndis_per_dev_params [configNr].media_state
258 == NDIS_MEDIA_STATE_DISCONNECTED) 258 == NDIS_MEDIA_STATE_DISCONNECTED)
259 *outbuf = __constant_cpu_to_le32 (0); 259 *outbuf = __constant_cpu_to_le32 (0);
@@ -265,7 +265,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
265 265
266 /* mandatory */ 266 /* mandatory */
267 case OID_GEN_TRANSMIT_BLOCK_SIZE: 267 case OID_GEN_TRANSMIT_BLOCK_SIZE:
268 DBG("%s: OID_GEN_TRANSMIT_BLOCK_SIZE\n", __FUNCTION__); 268 DBG("%s: OID_GEN_TRANSMIT_BLOCK_SIZE\n", __func__);
269 if (rndis_per_dev_params [configNr].dev) { 269 if (rndis_per_dev_params [configNr].dev) {
270 *outbuf = cpu_to_le32 ( 270 *outbuf = cpu_to_le32 (
271 rndis_per_dev_params [configNr].dev->mtu); 271 rndis_per_dev_params [configNr].dev->mtu);
@@ -275,7 +275,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
275 275
276 /* mandatory */ 276 /* mandatory */
277 case OID_GEN_RECEIVE_BLOCK_SIZE: 277 case OID_GEN_RECEIVE_BLOCK_SIZE:
278 DBG("%s: OID_GEN_RECEIVE_BLOCK_SIZE\n", __FUNCTION__); 278 DBG("%s: OID_GEN_RECEIVE_BLOCK_SIZE\n", __func__);
279 if (rndis_per_dev_params [configNr].dev) { 279 if (rndis_per_dev_params [configNr].dev) {
280 *outbuf = cpu_to_le32 ( 280 *outbuf = cpu_to_le32 (
281 rndis_per_dev_params [configNr].dev->mtu); 281 rndis_per_dev_params [configNr].dev->mtu);
@@ -285,7 +285,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
285 285
286 /* mandatory */ 286 /* mandatory */
287 case OID_GEN_VENDOR_ID: 287 case OID_GEN_VENDOR_ID:
288 DBG("%s: OID_GEN_VENDOR_ID\n", __FUNCTION__); 288 DBG("%s: OID_GEN_VENDOR_ID\n", __func__);
289 *outbuf = cpu_to_le32 ( 289 *outbuf = cpu_to_le32 (
290 rndis_per_dev_params [configNr].vendorID); 290 rndis_per_dev_params [configNr].vendorID);
291 retval = 0; 291 retval = 0;
@@ -293,7 +293,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
293 293
294 /* mandatory */ 294 /* mandatory */
295 case OID_GEN_VENDOR_DESCRIPTION: 295 case OID_GEN_VENDOR_DESCRIPTION:
296 DBG("%s: OID_GEN_VENDOR_DESCRIPTION\n", __FUNCTION__); 296 DBG("%s: OID_GEN_VENDOR_DESCRIPTION\n", __func__);
297 length = strlen (rndis_per_dev_params [configNr].vendorDescr); 297 length = strlen (rndis_per_dev_params [configNr].vendorDescr);
298 memcpy (outbuf, 298 memcpy (outbuf,
299 rndis_per_dev_params [configNr].vendorDescr, length); 299 rndis_per_dev_params [configNr].vendorDescr, length);
@@ -301,7 +301,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
301 break; 301 break;
302 302
303 case OID_GEN_VENDOR_DRIVER_VERSION: 303 case OID_GEN_VENDOR_DRIVER_VERSION:
304 DBG("%s: OID_GEN_VENDOR_DRIVER_VERSION\n", __FUNCTION__); 304 DBG("%s: OID_GEN_VENDOR_DRIVER_VERSION\n", __func__);
305 /* Created as LE */ 305 /* Created as LE */
306 *outbuf = rndis_driver_version; 306 *outbuf = rndis_driver_version;
307 retval = 0; 307 retval = 0;
@@ -309,14 +309,14 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
309 309
310 /* mandatory */ 310 /* mandatory */
311 case OID_GEN_CURRENT_PACKET_FILTER: 311 case OID_GEN_CURRENT_PACKET_FILTER:
312 DBG("%s: OID_GEN_CURRENT_PACKET_FILTER\n", __FUNCTION__); 312 DBG("%s: OID_GEN_CURRENT_PACKET_FILTER\n", __func__);
313 *outbuf = cpu_to_le32 (*rndis_per_dev_params[configNr].filter); 313 *outbuf = cpu_to_le32 (*rndis_per_dev_params[configNr].filter);
314 retval = 0; 314 retval = 0;
315 break; 315 break;
316 316
317 /* mandatory */ 317 /* mandatory */
318 case OID_GEN_MAXIMUM_TOTAL_SIZE: 318 case OID_GEN_MAXIMUM_TOTAL_SIZE:
319 DBG("%s: OID_GEN_MAXIMUM_TOTAL_SIZE\n", __FUNCTION__); 319 DBG("%s: OID_GEN_MAXIMUM_TOTAL_SIZE\n", __func__);
320 *outbuf = __constant_cpu_to_le32(RNDIS_MAX_TOTAL_SIZE); 320 *outbuf = __constant_cpu_to_le32(RNDIS_MAX_TOTAL_SIZE);
321 retval = 0; 321 retval = 0;
322 break; 322 break;
@@ -324,14 +324,14 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
324 /* mandatory */ 324 /* mandatory */
325 case OID_GEN_MEDIA_CONNECT_STATUS: 325 case OID_GEN_MEDIA_CONNECT_STATUS:
326 if (rndis_debug > 1) 326 if (rndis_debug > 1)
327 DBG("%s: OID_GEN_MEDIA_CONNECT_STATUS\n", __FUNCTION__); 327 DBG("%s: OID_GEN_MEDIA_CONNECT_STATUS\n", __func__);
328 *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr] 328 *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr]
329 .media_state); 329 .media_state);
330 retval = 0; 330 retval = 0;
331 break; 331 break;
332 332
333 case OID_GEN_PHYSICAL_MEDIUM: 333 case OID_GEN_PHYSICAL_MEDIUM:
334 DBG("%s: OID_GEN_PHYSICAL_MEDIUM\n", __FUNCTION__); 334 DBG("%s: OID_GEN_PHYSICAL_MEDIUM\n", __func__);
335 *outbuf = __constant_cpu_to_le32 (0); 335 *outbuf = __constant_cpu_to_le32 (0);
336 retval = 0; 336 retval = 0;
337 break; 337 break;
@@ -341,7 +341,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
341 * versions emit undefined RNDIS messages. DOCUMENT ALL THESE! 341 * versions emit undefined RNDIS messages. DOCUMENT ALL THESE!
342 */ 342 */
343 case OID_GEN_MAC_OPTIONS: /* from WinME */ 343 case OID_GEN_MAC_OPTIONS: /* from WinME */
344 DBG("%s: OID_GEN_MAC_OPTIONS\n", __FUNCTION__); 344 DBG("%s: OID_GEN_MAC_OPTIONS\n", __func__);
345 *outbuf = __constant_cpu_to_le32( 345 *outbuf = __constant_cpu_to_le32(
346 NDIS_MAC_OPTION_RECEIVE_SERIALIZED 346 NDIS_MAC_OPTION_RECEIVE_SERIALIZED
347 | NDIS_MAC_OPTION_FULL_DUPLEX); 347 | NDIS_MAC_OPTION_FULL_DUPLEX);
@@ -353,7 +353,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
353 /* mandatory */ 353 /* mandatory */
354 case OID_GEN_XMIT_OK: 354 case OID_GEN_XMIT_OK:
355 if (rndis_debug > 1) 355 if (rndis_debug > 1)
356 DBG("%s: OID_GEN_XMIT_OK\n", __FUNCTION__); 356 DBG("%s: OID_GEN_XMIT_OK\n", __func__);
357 if (rndis_per_dev_params [configNr].stats) { 357 if (rndis_per_dev_params [configNr].stats) {
358 *outbuf = cpu_to_le32 ( 358 *outbuf = cpu_to_le32 (
359 rndis_per_dev_params [configNr].stats->tx_packets - 359 rndis_per_dev_params [configNr].stats->tx_packets -
@@ -366,7 +366,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
366 /* mandatory */ 366 /* mandatory */
367 case OID_GEN_RCV_OK: 367 case OID_GEN_RCV_OK:
368 if (rndis_debug > 1) 368 if (rndis_debug > 1)
369 DBG("%s: OID_GEN_RCV_OK\n", __FUNCTION__); 369 DBG("%s: OID_GEN_RCV_OK\n", __func__);
370 if (rndis_per_dev_params [configNr].stats) { 370 if (rndis_per_dev_params [configNr].stats) {
371 *outbuf = cpu_to_le32 ( 371 *outbuf = cpu_to_le32 (
372 rndis_per_dev_params [configNr].stats->rx_packets - 372 rndis_per_dev_params [configNr].stats->rx_packets -
@@ -379,7 +379,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
379 /* mandatory */ 379 /* mandatory */
380 case OID_GEN_XMIT_ERROR: 380 case OID_GEN_XMIT_ERROR:
381 if (rndis_debug > 1) 381 if (rndis_debug > 1)
382 DBG("%s: OID_GEN_XMIT_ERROR\n", __FUNCTION__); 382 DBG("%s: OID_GEN_XMIT_ERROR\n", __func__);
383 if (rndis_per_dev_params [configNr].stats) { 383 if (rndis_per_dev_params [configNr].stats) {
384 *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr] 384 *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr]
385 .stats->tx_errors); 385 .stats->tx_errors);
@@ -390,7 +390,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
390 /* mandatory */ 390 /* mandatory */
391 case OID_GEN_RCV_ERROR: 391 case OID_GEN_RCV_ERROR:
392 if (rndis_debug > 1) 392 if (rndis_debug > 1)
393 DBG("%s: OID_GEN_RCV_ERROR\n", __FUNCTION__); 393 DBG("%s: OID_GEN_RCV_ERROR\n", __func__);
394 if (rndis_per_dev_params [configNr].stats) { 394 if (rndis_per_dev_params [configNr].stats) {
395 *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr] 395 *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr]
396 .stats->rx_errors); 396 .stats->rx_errors);
@@ -400,7 +400,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
400 400
401 /* mandatory */ 401 /* mandatory */
402 case OID_GEN_RCV_NO_BUFFER: 402 case OID_GEN_RCV_NO_BUFFER:
403 DBG("%s: OID_GEN_RCV_NO_BUFFER\n", __FUNCTION__); 403 DBG("%s: OID_GEN_RCV_NO_BUFFER\n", __func__);
404 if (rndis_per_dev_params [configNr].stats) { 404 if (rndis_per_dev_params [configNr].stats) {
405 *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr] 405 *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr]
406 .stats->rx_dropped); 406 .stats->rx_dropped);
@@ -410,7 +410,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
410 410
411#ifdef RNDIS_OPTIONAL_STATS 411#ifdef RNDIS_OPTIONAL_STATS
412 case OID_GEN_DIRECTED_BYTES_XMIT: 412 case OID_GEN_DIRECTED_BYTES_XMIT:
413 DBG("%s: OID_GEN_DIRECTED_BYTES_XMIT\n", __FUNCTION__); 413 DBG("%s: OID_GEN_DIRECTED_BYTES_XMIT\n", __func__);
414 /* 414 /*
415 * Aunt Tilly's size of shoes 415 * Aunt Tilly's size of shoes
416 * minus antarctica count of penguins 416 * minus antarctica count of penguins
@@ -430,7 +430,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
430 break; 430 break;
431 431
432 case OID_GEN_DIRECTED_FRAMES_XMIT: 432 case OID_GEN_DIRECTED_FRAMES_XMIT:
433 DBG("%s: OID_GEN_DIRECTED_FRAMES_XMIT\n", __FUNCTION__); 433 DBG("%s: OID_GEN_DIRECTED_FRAMES_XMIT\n", __func__);
434 /* dito */ 434 /* dito */
435 if (rndis_per_dev_params [configNr].stats) { 435 if (rndis_per_dev_params [configNr].stats) {
436 *outbuf = cpu_to_le32 ( 436 *outbuf = cpu_to_le32 (
@@ -446,7 +446,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
446 break; 446 break;
447 447
448 case OID_GEN_MULTICAST_BYTES_XMIT: 448 case OID_GEN_MULTICAST_BYTES_XMIT:
449 DBG("%s: OID_GEN_MULTICAST_BYTES_XMIT\n", __FUNCTION__); 449 DBG("%s: OID_GEN_MULTICAST_BYTES_XMIT\n", __func__);
450 if (rndis_per_dev_params [configNr].stats) { 450 if (rndis_per_dev_params [configNr].stats) {
451 *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr] 451 *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr]
452 .stats->multicast*1234); 452 .stats->multicast*1234);
@@ -455,7 +455,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
455 break; 455 break;
456 456
457 case OID_GEN_MULTICAST_FRAMES_XMIT: 457 case OID_GEN_MULTICAST_FRAMES_XMIT:
458 DBG("%s: OID_GEN_MULTICAST_FRAMES_XMIT\n", __FUNCTION__); 458 DBG("%s: OID_GEN_MULTICAST_FRAMES_XMIT\n", __func__);
459 if (rndis_per_dev_params [configNr].stats) { 459 if (rndis_per_dev_params [configNr].stats) {
460 *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr] 460 *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr]
461 .stats->multicast); 461 .stats->multicast);
@@ -464,7 +464,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
464 break; 464 break;
465 465
466 case OID_GEN_BROADCAST_BYTES_XMIT: 466 case OID_GEN_BROADCAST_BYTES_XMIT:
467 DBG("%s: OID_GEN_BROADCAST_BYTES_XMIT\n", __FUNCTION__); 467 DBG("%s: OID_GEN_BROADCAST_BYTES_XMIT\n", __func__);
468 if (rndis_per_dev_params [configNr].stats) { 468 if (rndis_per_dev_params [configNr].stats) {
469 *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr] 469 *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr]
470 .stats->tx_packets/42*255); 470 .stats->tx_packets/42*255);
@@ -473,7 +473,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
473 break; 473 break;
474 474
475 case OID_GEN_BROADCAST_FRAMES_XMIT: 475 case OID_GEN_BROADCAST_FRAMES_XMIT:
476 DBG("%s: OID_GEN_BROADCAST_FRAMES_XMIT\n", __FUNCTION__); 476 DBG("%s: OID_GEN_BROADCAST_FRAMES_XMIT\n", __func__);
477 if (rndis_per_dev_params [configNr].stats) { 477 if (rndis_per_dev_params [configNr].stats) {
478 *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr] 478 *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr]
479 .stats->tx_packets/42); 479 .stats->tx_packets/42);
@@ -482,19 +482,19 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
482 break; 482 break;
483 483
484 case OID_GEN_DIRECTED_BYTES_RCV: 484 case OID_GEN_DIRECTED_BYTES_RCV:
485 DBG("%s: OID_GEN_DIRECTED_BYTES_RCV\n", __FUNCTION__); 485 DBG("%s: OID_GEN_DIRECTED_BYTES_RCV\n", __func__);
486 *outbuf = __constant_cpu_to_le32 (0); 486 *outbuf = __constant_cpu_to_le32 (0);
487 retval = 0; 487 retval = 0;
488 break; 488 break;
489 489
490 case OID_GEN_DIRECTED_FRAMES_RCV: 490 case OID_GEN_DIRECTED_FRAMES_RCV:
491 DBG("%s: OID_GEN_DIRECTED_FRAMES_RCV\n", __FUNCTION__); 491 DBG("%s: OID_GEN_DIRECTED_FRAMES_RCV\n", __func__);
492 *outbuf = __constant_cpu_to_le32 (0); 492 *outbuf = __constant_cpu_to_le32 (0);
493 retval = 0; 493 retval = 0;
494 break; 494 break;
495 495
496 case OID_GEN_MULTICAST_BYTES_RCV: 496 case OID_GEN_MULTICAST_BYTES_RCV:
497 DBG("%s: OID_GEN_MULTICAST_BYTES_RCV\n", __FUNCTION__); 497 DBG("%s: OID_GEN_MULTICAST_BYTES_RCV\n", __func__);
498 if (rndis_per_dev_params [configNr].stats) { 498 if (rndis_per_dev_params [configNr].stats) {
499 *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr] 499 *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr]
500 .stats->multicast * 1111); 500 .stats->multicast * 1111);
@@ -503,7 +503,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
503 break; 503 break;
504 504
505 case OID_GEN_MULTICAST_FRAMES_RCV: 505 case OID_GEN_MULTICAST_FRAMES_RCV:
506 DBG("%s: OID_GEN_MULTICAST_FRAMES_RCV\n", __FUNCTION__); 506 DBG("%s: OID_GEN_MULTICAST_FRAMES_RCV\n", __func__);
507 if (rndis_per_dev_params [configNr].stats) { 507 if (rndis_per_dev_params [configNr].stats) {
508 *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr] 508 *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr]
509 .stats->multicast); 509 .stats->multicast);
@@ -512,7 +512,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
512 break; 512 break;
513 513
514 case OID_GEN_BROADCAST_BYTES_RCV: 514 case OID_GEN_BROADCAST_BYTES_RCV:
515 DBG("%s: OID_GEN_BROADCAST_BYTES_RCV\n", __FUNCTION__); 515 DBG("%s: OID_GEN_BROADCAST_BYTES_RCV\n", __func__);
516 if (rndis_per_dev_params [configNr].stats) { 516 if (rndis_per_dev_params [configNr].stats) {
517 *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr] 517 *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr]
518 .stats->rx_packets/42*255); 518 .stats->rx_packets/42*255);
@@ -521,7 +521,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
521 break; 521 break;
522 522
523 case OID_GEN_BROADCAST_FRAMES_RCV: 523 case OID_GEN_BROADCAST_FRAMES_RCV:
524 DBG("%s: OID_GEN_BROADCAST_FRAMES_RCV\n", __FUNCTION__); 524 DBG("%s: OID_GEN_BROADCAST_FRAMES_RCV\n", __func__);
525 if (rndis_per_dev_params [configNr].stats) { 525 if (rndis_per_dev_params [configNr].stats) {
526 *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr] 526 *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr]
527 .stats->rx_packets/42); 527 .stats->rx_packets/42);
@@ -530,7 +530,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
530 break; 530 break;
531 531
532 case OID_GEN_RCV_CRC_ERROR: 532 case OID_GEN_RCV_CRC_ERROR:
533 DBG("%s: OID_GEN_RCV_CRC_ERROR\n", __FUNCTION__); 533 DBG("%s: OID_GEN_RCV_CRC_ERROR\n", __func__);
534 if (rndis_per_dev_params [configNr].stats) { 534 if (rndis_per_dev_params [configNr].stats) {
535 *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr] 535 *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr]
536 .stats->rx_crc_errors); 536 .stats->rx_crc_errors);
@@ -539,7 +539,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
539 break; 539 break;
540 540
541 case OID_GEN_TRANSMIT_QUEUE_LENGTH: 541 case OID_GEN_TRANSMIT_QUEUE_LENGTH:
542 DBG("%s: OID_GEN_TRANSMIT_QUEUE_LENGTH\n", __FUNCTION__); 542 DBG("%s: OID_GEN_TRANSMIT_QUEUE_LENGTH\n", __func__);
543 *outbuf = __constant_cpu_to_le32 (0); 543 *outbuf = __constant_cpu_to_le32 (0);
544 retval = 0; 544 retval = 0;
545 break; 545 break;
@@ -549,7 +549,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
549 549
550 /* mandatory */ 550 /* mandatory */
551 case OID_802_3_PERMANENT_ADDRESS: 551 case OID_802_3_PERMANENT_ADDRESS:
552 DBG("%s: OID_802_3_PERMANENT_ADDRESS\n", __FUNCTION__); 552 DBG("%s: OID_802_3_PERMANENT_ADDRESS\n", __func__);
553 if (rndis_per_dev_params [configNr].dev) { 553 if (rndis_per_dev_params [configNr].dev) {
554 length = ETH_ALEN; 554 length = ETH_ALEN;
555 memcpy (outbuf, 555 memcpy (outbuf,
@@ -561,7 +561,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
561 561
562 /* mandatory */ 562 /* mandatory */
563 case OID_802_3_CURRENT_ADDRESS: 563 case OID_802_3_CURRENT_ADDRESS:
564 DBG("%s: OID_802_3_CURRENT_ADDRESS\n", __FUNCTION__); 564 DBG("%s: OID_802_3_CURRENT_ADDRESS\n", __func__);
565 if (rndis_per_dev_params [configNr].dev) { 565 if (rndis_per_dev_params [configNr].dev) {
566 length = ETH_ALEN; 566 length = ETH_ALEN;
567 memcpy (outbuf, 567 memcpy (outbuf,
@@ -573,7 +573,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
573 573
574 /* mandatory */ 574 /* mandatory */
575 case OID_802_3_MULTICAST_LIST: 575 case OID_802_3_MULTICAST_LIST:
576 DBG("%s: OID_802_3_MULTICAST_LIST\n", __FUNCTION__); 576 DBG("%s: OID_802_3_MULTICAST_LIST\n", __func__);
577 /* Multicast base address only */ 577 /* Multicast base address only */
578 *outbuf = __constant_cpu_to_le32 (0xE0000000); 578 *outbuf = __constant_cpu_to_le32 (0xE0000000);
579 retval = 0; 579 retval = 0;
@@ -581,21 +581,21 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
581 581
582 /* mandatory */ 582 /* mandatory */
583 case OID_802_3_MAXIMUM_LIST_SIZE: 583 case OID_802_3_MAXIMUM_LIST_SIZE:
584 DBG("%s: OID_802_3_MAXIMUM_LIST_SIZE\n", __FUNCTION__); 584 DBG("%s: OID_802_3_MAXIMUM_LIST_SIZE\n", __func__);
585 /* Multicast base address only */ 585 /* Multicast base address only */
586 *outbuf = __constant_cpu_to_le32 (1); 586 *outbuf = __constant_cpu_to_le32 (1);
587 retval = 0; 587 retval = 0;
588 break; 588 break;
589 589
590 case OID_802_3_MAC_OPTIONS: 590 case OID_802_3_MAC_OPTIONS:
591 DBG("%s: OID_802_3_MAC_OPTIONS\n", __FUNCTION__); 591 DBG("%s: OID_802_3_MAC_OPTIONS\n", __func__);
592 break; 592 break;
593 593
594 /* ieee802.3 statistics OIDs (table 4-4) */ 594 /* ieee802.3 statistics OIDs (table 4-4) */
595 595
596 /* mandatory */ 596 /* mandatory */
597 case OID_802_3_RCV_ERROR_ALIGNMENT: 597 case OID_802_3_RCV_ERROR_ALIGNMENT:
598 DBG("%s: OID_802_3_RCV_ERROR_ALIGNMENT\n", __FUNCTION__); 598 DBG("%s: OID_802_3_RCV_ERROR_ALIGNMENT\n", __func__);
599 if (rndis_per_dev_params [configNr].stats) { 599 if (rndis_per_dev_params [configNr].stats) {
600 *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr] 600 *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr]
601 .stats->rx_frame_errors); 601 .stats->rx_frame_errors);
@@ -605,51 +605,51 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
605 605
606 /* mandatory */ 606 /* mandatory */
607 case OID_802_3_XMIT_ONE_COLLISION: 607 case OID_802_3_XMIT_ONE_COLLISION:
608 DBG("%s: OID_802_3_XMIT_ONE_COLLISION\n", __FUNCTION__); 608 DBG("%s: OID_802_3_XMIT_ONE_COLLISION\n", __func__);
609 *outbuf = __constant_cpu_to_le32 (0); 609 *outbuf = __constant_cpu_to_le32 (0);
610 retval = 0; 610 retval = 0;
611 break; 611 break;
612 612
613 /* mandatory */ 613 /* mandatory */
614 case OID_802_3_XMIT_MORE_COLLISIONS: 614 case OID_802_3_XMIT_MORE_COLLISIONS:
615 DBG("%s: OID_802_3_XMIT_MORE_COLLISIONS\n", __FUNCTION__); 615 DBG("%s: OID_802_3_XMIT_MORE_COLLISIONS\n", __func__);
616 *outbuf = __constant_cpu_to_le32 (0); 616 *outbuf = __constant_cpu_to_le32 (0);
617 retval = 0; 617 retval = 0;
618 break; 618 break;
619 619
620#ifdef RNDIS_OPTIONAL_STATS 620#ifdef RNDIS_OPTIONAL_STATS
621 case OID_802_3_XMIT_DEFERRED: 621 case OID_802_3_XMIT_DEFERRED:
622 DBG("%s: OID_802_3_XMIT_DEFERRED\n", __FUNCTION__); 622 DBG("%s: OID_802_3_XMIT_DEFERRED\n", __func__);
623 /* TODO */ 623 /* TODO */
624 break; 624 break;
625 625
626 case OID_802_3_XMIT_MAX_COLLISIONS: 626 case OID_802_3_XMIT_MAX_COLLISIONS:
627 DBG("%s: OID_802_3_XMIT_MAX_COLLISIONS\n", __FUNCTION__); 627 DBG("%s: OID_802_3_XMIT_MAX_COLLISIONS\n", __func__);
628 /* TODO */ 628 /* TODO */
629 break; 629 break;
630 630
631 case OID_802_3_RCV_OVERRUN: 631 case OID_802_3_RCV_OVERRUN:
632 DBG("%s: OID_802_3_RCV_OVERRUN\n", __FUNCTION__); 632 DBG("%s: OID_802_3_RCV_OVERRUN\n", __func__);
633 /* TODO */ 633 /* TODO */
634 break; 634 break;
635 635
636 case OID_802_3_XMIT_UNDERRUN: 636 case OID_802_3_XMIT_UNDERRUN:
637 DBG("%s: OID_802_3_XMIT_UNDERRUN\n", __FUNCTION__); 637 DBG("%s: OID_802_3_XMIT_UNDERRUN\n", __func__);
638 /* TODO */ 638 /* TODO */
639 break; 639 break;
640 640
641 case OID_802_3_XMIT_HEARTBEAT_FAILURE: 641 case OID_802_3_XMIT_HEARTBEAT_FAILURE:
642 DBG("%s: OID_802_3_XMIT_HEARTBEAT_FAILURE\n", __FUNCTION__); 642 DBG("%s: OID_802_3_XMIT_HEARTBEAT_FAILURE\n", __func__);
643 /* TODO */ 643 /* TODO */
644 break; 644 break;
645 645
646 case OID_802_3_XMIT_TIMES_CRS_LOST: 646 case OID_802_3_XMIT_TIMES_CRS_LOST:
647 DBG("%s: OID_802_3_XMIT_TIMES_CRS_LOST\n", __FUNCTION__); 647 DBG("%s: OID_802_3_XMIT_TIMES_CRS_LOST\n", __func__);
648 /* TODO */ 648 /* TODO */
649 break; 649 break;
650 650
651 case OID_802_3_XMIT_LATE_COLLISIONS: 651 case OID_802_3_XMIT_LATE_COLLISIONS:
652 DBG("%s: OID_802_3_XMIT_LATE_COLLISIONS\n", __FUNCTION__); 652 DBG("%s: OID_802_3_XMIT_LATE_COLLISIONS\n", __func__);
653 /* TODO */ 653 /* TODO */
654 break; 654 break;
655#endif /* RNDIS_OPTIONAL_STATS */ 655#endif /* RNDIS_OPTIONAL_STATS */
@@ -657,7 +657,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
657#ifdef RNDIS_PM 657#ifdef RNDIS_PM
658 /* power management OIDs (table 4-5) */ 658 /* power management OIDs (table 4-5) */
659 case OID_PNP_CAPABILITIES: 659 case OID_PNP_CAPABILITIES:
660 DBG("%s: OID_PNP_CAPABILITIES\n", __FUNCTION__); 660 DBG("%s: OID_PNP_CAPABILITIES\n", __func__);
661 661
662 /* for now, no wakeup capabilities */ 662 /* for now, no wakeup capabilities */
663 length = sizeof (struct NDIS_PNP_CAPABILITIES); 663 length = sizeof (struct NDIS_PNP_CAPABILITIES);
@@ -665,7 +665,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
665 retval = 0; 665 retval = 0;
666 break; 666 break;
667 case OID_PNP_QUERY_POWER: 667 case OID_PNP_QUERY_POWER:
668 DBG("%s: OID_PNP_QUERY_POWER D%d\n", __FUNCTION__, 668 DBG("%s: OID_PNP_QUERY_POWER D%d\n", __func__,
669 le32_to_cpu(get_unaligned((__le32 *)buf)) - 1); 669 le32_to_cpu(get_unaligned((__le32 *)buf)) - 1);
670 /* only suspend is a real power state, and 670 /* only suspend is a real power state, and
671 * it can't be entered by OID_PNP_SET_POWER... 671 * it can't be entered by OID_PNP_SET_POWER...
@@ -677,7 +677,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
677 677
678 default: 678 default:
679 pr_warning("%s: query unknown OID 0x%08X\n", 679 pr_warning("%s: query unknown OID 0x%08X\n",
680 __FUNCTION__, OID); 680 __func__, OID);
681 } 681 }
682 if (retval < 0) 682 if (retval < 0)
683 length = 0; 683 length = 0;
@@ -729,7 +729,7 @@ static int gen_ndis_set_resp (u8 configNr, u32 OID, u8 *buf, u32 buf_len,
729 *params->filter = (u16) le32_to_cpu(get_unaligned( 729 *params->filter = (u16) le32_to_cpu(get_unaligned(
730 (__le32 *)buf)); 730 (__le32 *)buf));
731 DBG("%s: OID_GEN_CURRENT_PACKET_FILTER %08x\n", 731 DBG("%s: OID_GEN_CURRENT_PACKET_FILTER %08x\n",
732 __FUNCTION__, *params->filter); 732 __func__, *params->filter);
733 733
734 /* this call has a significant side effect: it's 734 /* this call has a significant side effect: it's
735 * what makes the packet flow start and stop, like 735 * what makes the packet flow start and stop, like
@@ -753,7 +753,7 @@ update_linkstate:
753 753
754 case OID_802_3_MULTICAST_LIST: 754 case OID_802_3_MULTICAST_LIST:
755 /* I think we can ignore this */ 755 /* I think we can ignore this */
756 DBG("%s: OID_802_3_MULTICAST_LIST\n", __FUNCTION__); 756 DBG("%s: OID_802_3_MULTICAST_LIST\n", __func__);
757 retval = 0; 757 retval = 0;
758 break; 758 break;
759#if 0 759#if 0
@@ -762,7 +762,7 @@ update_linkstate:
762 struct rndis_config_parameter *param; 762 struct rndis_config_parameter *param;
763 param = (struct rndis_config_parameter *) buf; 763 param = (struct rndis_config_parameter *) buf;
764 DBG("%s: OID_GEN_RNDIS_CONFIG_PARAMETER '%*s'\n", 764 DBG("%s: OID_GEN_RNDIS_CONFIG_PARAMETER '%*s'\n",
765 __FUNCTION__, 765 __func__,
766 min(cpu_to_le32(param->ParameterNameLength),80), 766 min(cpu_to_le32(param->ParameterNameLength),80),
767 buf + param->ParameterNameOffset); 767 buf + param->ParameterNameOffset);
768 retval = 0; 768 retval = 0;
@@ -778,7 +778,7 @@ update_linkstate:
778 * FIXME ... then things go batty; Windows wedges itself. 778 * FIXME ... then things go batty; Windows wedges itself.
779 */ 779 */
780 i = le32_to_cpu(get_unaligned((__le32 *)buf)); 780 i = le32_to_cpu(get_unaligned((__le32 *)buf));
781 DBG("%s: OID_PNP_SET_POWER D%d\n", __FUNCTION__, i - 1); 781 DBG("%s: OID_PNP_SET_POWER D%d\n", __func__, i - 1);
782 switch (i) { 782 switch (i) {
783 case NdisDeviceStateD0: 783 case NdisDeviceStateD0:
784 *params->filter = params->saved_filter; 784 *params->filter = params->saved_filter;
@@ -802,7 +802,7 @@ update_linkstate:
802 802
803 default: 803 default:
804 pr_warning("%s: set unknown OID 0x%08X, size %d\n", 804 pr_warning("%s: set unknown OID 0x%08X, size %d\n",
805 __FUNCTION__, OID, buf_len); 805 __func__, OID, buf_len);
806 } 806 }
807 807
808 return retval; 808 return retval;
@@ -855,7 +855,7 @@ static int rndis_query_response (int configNr, rndis_query_msg_type *buf)
855 rndis_query_cmplt_type *resp; 855 rndis_query_cmplt_type *resp;
856 rndis_resp_t *r; 856 rndis_resp_t *r;
857 857
858 // DBG("%s: OID = %08X\n", __FUNCTION__, cpu_to_le32(buf->OID)); 858 // DBG("%s: OID = %08X\n", __func__, cpu_to_le32(buf->OID));
859 if (!rndis_per_dev_params [configNr].dev) return -ENOTSUPP; 859 if (!rndis_per_dev_params [configNr].dev) return -ENOTSUPP;
860 860
861 /* 861 /*
@@ -908,9 +908,9 @@ static int rndis_set_response (int configNr, rndis_set_msg_type *buf)
908 BufOffset = le32_to_cpu (buf->InformationBufferOffset); 908 BufOffset = le32_to_cpu (buf->InformationBufferOffset);
909 909
910#ifdef VERBOSE 910#ifdef VERBOSE
911 DBG("%s: Length: %d\n", __FUNCTION__, BufLength); 911 DBG("%s: Length: %d\n", __func__, BufLength);
912 DBG("%s: Offset: %d\n", __FUNCTION__, BufOffset); 912 DBG("%s: Offset: %d\n", __func__, BufOffset);
913 DBG("%s: InfoBuffer: ", __FUNCTION__); 913 DBG("%s: InfoBuffer: ", __func__);
914 914
915 for (i = 0; i < BufLength; i++) { 915 for (i = 0; i < BufLength; i++) {
916 DBG("%02x ", *(((u8 *) buf) + i + 8 + BufOffset)); 916 DBG("%02x ", *(((u8 *) buf) + i + 8 + BufOffset));
@@ -1080,14 +1080,14 @@ int rndis_msg_parser (u8 configNr, u8 *buf)
1080 switch (MsgType) { 1080 switch (MsgType) {
1081 case REMOTE_NDIS_INITIALIZE_MSG: 1081 case REMOTE_NDIS_INITIALIZE_MSG:
1082 DBG("%s: REMOTE_NDIS_INITIALIZE_MSG\n", 1082 DBG("%s: REMOTE_NDIS_INITIALIZE_MSG\n",
1083 __FUNCTION__ ); 1083 __func__ );
1084 params->state = RNDIS_INITIALIZED; 1084 params->state = RNDIS_INITIALIZED;
1085 return rndis_init_response (configNr, 1085 return rndis_init_response (configNr,
1086 (rndis_init_msg_type *) buf); 1086 (rndis_init_msg_type *) buf);
1087 1087
1088 case REMOTE_NDIS_HALT_MSG: 1088 case REMOTE_NDIS_HALT_MSG:
1089 DBG("%s: REMOTE_NDIS_HALT_MSG\n", 1089 DBG("%s: REMOTE_NDIS_HALT_MSG\n",
1090 __FUNCTION__ ); 1090 __func__ );
1091 params->state = RNDIS_UNINITIALIZED; 1091 params->state = RNDIS_UNINITIALIZED;
1092 if (params->dev) { 1092 if (params->dev) {
1093 netif_carrier_off (params->dev); 1093 netif_carrier_off (params->dev);
@@ -1105,7 +1105,7 @@ int rndis_msg_parser (u8 configNr, u8 *buf)
1105 1105
1106 case REMOTE_NDIS_RESET_MSG: 1106 case REMOTE_NDIS_RESET_MSG:
1107 DBG("%s: REMOTE_NDIS_RESET_MSG\n", 1107 DBG("%s: REMOTE_NDIS_RESET_MSG\n",
1108 __FUNCTION__ ); 1108 __func__ );
1109 return rndis_reset_response (configNr, 1109 return rndis_reset_response (configNr,
1110 (rndis_reset_msg_type *) buf); 1110 (rndis_reset_msg_type *) buf);
1111 1111
@@ -1113,7 +1113,7 @@ int rndis_msg_parser (u8 configNr, u8 *buf)
1113 /* For USB: host does this every 5 seconds */ 1113 /* For USB: host does this every 5 seconds */
1114 if (rndis_debug > 1) 1114 if (rndis_debug > 1)
1115 DBG("%s: REMOTE_NDIS_KEEPALIVE_MSG\n", 1115 DBG("%s: REMOTE_NDIS_KEEPALIVE_MSG\n",
1116 __FUNCTION__ ); 1116 __func__ );
1117 return rndis_keepalive_response (configNr, 1117 return rndis_keepalive_response (configNr,
1118 (rndis_keepalive_msg_type *) 1118 (rndis_keepalive_msg_type *)
1119 buf); 1119 buf);
@@ -1124,7 +1124,7 @@ int rndis_msg_parser (u8 configNr, u8 *buf)
1124 * suspending itself. 1124 * suspending itself.
1125 */ 1125 */
1126 pr_warning("%s: unknown RNDIS message 0x%08X len %d\n", 1126 pr_warning("%s: unknown RNDIS message 0x%08X len %d\n",
1127 __FUNCTION__ , MsgType, MsgLength); 1127 __func__ , MsgType, MsgLength);
1128 { 1128 {
1129 unsigned i; 1129 unsigned i;
1130 for (i = 0; i < MsgLength; i += 16) { 1130 for (i = 0; i < MsgLength; i += 16) {
@@ -1159,7 +1159,7 @@ int rndis_register (int (* rndis_control_ack) (struct net_device *))
1159 if (!rndis_per_dev_params [i].used) { 1159 if (!rndis_per_dev_params [i].used) {
1160 rndis_per_dev_params [i].used = 1; 1160 rndis_per_dev_params [i].used = 1;
1161 rndis_per_dev_params [i].ack = rndis_control_ack; 1161 rndis_per_dev_params [i].ack = rndis_control_ack;
1162 DBG("%s: configNr = %d\n", __FUNCTION__, i); 1162 DBG("%s: configNr = %d\n", __func__, i);
1163 return i; 1163 return i;
1164 } 1164 }
1165 } 1165 }
@@ -1170,7 +1170,7 @@ int rndis_register (int (* rndis_control_ack) (struct net_device *))
1170 1170
1171void rndis_deregister (int configNr) 1171void rndis_deregister (int configNr)
1172{ 1172{
1173 DBG("%s: \n", __FUNCTION__ ); 1173 DBG("%s: \n", __func__ );
1174 1174
1175 if (configNr >= RNDIS_MAX_CONFIGS) return; 1175 if (configNr >= RNDIS_MAX_CONFIGS) return;
1176 rndis_per_dev_params [configNr].used = 0; 1176 rndis_per_dev_params [configNr].used = 0;
@@ -1182,7 +1182,7 @@ int rndis_set_param_dev (u8 configNr, struct net_device *dev,
1182 struct net_device_stats *stats, 1182 struct net_device_stats *stats,
1183 u16 *cdc_filter) 1183 u16 *cdc_filter)
1184{ 1184{
1185 DBG("%s:\n", __FUNCTION__ ); 1185 DBG("%s:\n", __func__ );
1186 if (!dev || !stats) return -1; 1186 if (!dev || !stats) return -1;
1187 if (configNr >= RNDIS_MAX_CONFIGS) return -1; 1187 if (configNr >= RNDIS_MAX_CONFIGS) return -1;
1188 1188
@@ -1195,7 +1195,7 @@ int rndis_set_param_dev (u8 configNr, struct net_device *dev,
1195 1195
1196int rndis_set_param_vendor (u8 configNr, u32 vendorID, const char *vendorDescr) 1196int rndis_set_param_vendor (u8 configNr, u32 vendorID, const char *vendorDescr)
1197{ 1197{
1198 DBG("%s:\n", __FUNCTION__ ); 1198 DBG("%s:\n", __func__ );
1199 if (!vendorDescr) return -1; 1199 if (!vendorDescr) return -1;
1200 if (configNr >= RNDIS_MAX_CONFIGS) return -1; 1200 if (configNr >= RNDIS_MAX_CONFIGS) return -1;
1201 1201
@@ -1207,7 +1207,7 @@ int rndis_set_param_vendor (u8 configNr, u32 vendorID, const char *vendorDescr)
1207 1207
1208int rndis_set_param_medium (u8 configNr, u32 medium, u32 speed) 1208int rndis_set_param_medium (u8 configNr, u32 medium, u32 speed)
1209{ 1209{
1210 DBG("%s: %u %u\n", __FUNCTION__, medium, speed); 1210 DBG("%s: %u %u\n", __func__, medium, speed);
1211 if (configNr >= RNDIS_MAX_CONFIGS) return -1; 1211 if (configNr >= RNDIS_MAX_CONFIGS) return -1;
1212 1212
1213 rndis_per_dev_params [configNr].medium = medium; 1213 rndis_per_dev_params [configNr].medium = medium;
@@ -1403,7 +1403,7 @@ static struct proc_dir_entry *rndis_connect_state [RNDIS_MAX_CONFIGS];
1403#endif /* CONFIG_USB_GADGET_DEBUG_FILES */ 1403#endif /* CONFIG_USB_GADGET_DEBUG_FILES */
1404 1404
1405 1405
1406int __devinit rndis_init (void) 1406int __init rndis_init (void)
1407{ 1407{
1408 u8 i; 1408 u8 i;
1409 1409
@@ -1415,7 +1415,7 @@ int __devinit rndis_init (void)
1415 if (!(rndis_connect_state [i] 1415 if (!(rndis_connect_state [i]
1416 = create_proc_entry (name, 0660, NULL))) 1416 = create_proc_entry (name, 0660, NULL)))
1417 { 1417 {
1418 DBG("%s :remove entries", __FUNCTION__); 1418 DBG("%s :remove entries", __func__);
1419 while (i) { 1419 while (i) {
1420 sprintf (name, NAME_TEMPLATE, --i); 1420 sprintf (name, NAME_TEMPLATE, --i);
1421 remove_proc_entry (name, NULL); 1421 remove_proc_entry (name, NULL);
diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c
index f5c3896b1d9..433b3f44f42 100644
--- a/drivers/usb/gadget/serial.c
+++ b/drivers/usb/gadget/serial.c
@@ -2163,8 +2163,7 @@ static void gs_free_ports(struct gs_dev *dev)
2163 port->port_dev = NULL; 2163 port->port_dev = NULL;
2164 wake_up_interruptible(&port->port_write_wait); 2164 wake_up_interruptible(&port->port_write_wait);
2165 if (port->port_tty) { 2165 if (port->port_tty) {
2166 wake_up_interruptible(&port->port_tty->read_wait); 2166 tty_hangup(port->port_tty);
2167 wake_up_interruptible(&port->port_tty->write_wait);
2168 } 2167 }
2169 spin_unlock_irqrestore(&port->port_lock, flags); 2168 spin_unlock_irqrestore(&port->port_lock, flags);
2170 } else { 2169 } else {
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index bf8be2a41a4..0b87480dd71 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -30,8 +30,8 @@ config USB_EHCI_HCD
30 module will be called ehci-hcd. 30 module will be called ehci-hcd.
31 31
32config USB_EHCI_ROOT_HUB_TT 32config USB_EHCI_ROOT_HUB_TT
33 bool "Root Hub Transaction Translators (EXPERIMENTAL)" 33 bool "Root Hub Transaction Translators"
34 depends on USB_EHCI_HCD && EXPERIMENTAL 34 depends on USB_EHCI_HCD
35 ---help--- 35 ---help---
36 Some EHCI chips have vendor-specific extensions to integrate 36 Some EHCI chips have vendor-specific extensions to integrate
37 transaction translators, so that no OHCI or UHCI companion 37 transaction translators, so that no OHCI or UHCI companion
@@ -260,3 +260,9 @@ config USB_R8A66597_HCD
260 To compile this driver as a module, choose M here: the 260 To compile this driver as a module, choose M here: the
261 module will be called r8a66597-hcd. 261 module will be called r8a66597-hcd.
262 262
263config SUPERH_ON_CHIP_R8A66597
264 boolean "Enable SuperH on-chip USB like the R8A66597"
265 depends on USB_R8A66597_HCD && CPU_SUBTYPE_SH7366
266 help
267 Renesas SuperH processor has USB like the R8A66597.
268 This driver supported processor is SH7366.
diff --git a/drivers/usb/host/ehci-au1xxx.c b/drivers/usb/host/ehci-au1xxx.c
index da7532d38bf..8b5f991e949 100644
--- a/drivers/usb/host/ehci-au1xxx.c
+++ b/drivers/usb/host/ehci-au1xxx.c
@@ -237,6 +237,7 @@ static int ehci_hcd_au1xxx_drv_probe(struct platform_device *pdev)
237 if (usb_disabled()) 237 if (usb_disabled())
238 return -ENODEV; 238 return -ENODEV;
239 239
240 /* FIXME we only want one one probe() not two */
240 ret = usb_ehci_au1xxx_probe(&ehci_au1xxx_hc_driver, &hcd, pdev); 241 ret = usb_ehci_au1xxx_probe(&ehci_au1xxx_hc_driver, &hcd, pdev);
241 return ret; 242 return ret;
242} 243}
@@ -245,6 +246,7 @@ static int ehci_hcd_au1xxx_drv_remove(struct platform_device *pdev)
245{ 246{
246 struct usb_hcd *hcd = platform_get_drvdata(pdev); 247 struct usb_hcd *hcd = platform_get_drvdata(pdev);
247 248
249 /* FIXME we only want one one remove() not two */
248 usb_ehci_au1xxx_remove(hcd, pdev); 250 usb_ehci_au1xxx_remove(hcd, pdev);
249 return 0; 251 return 0;
250} 252}
@@ -265,7 +267,7 @@ static int ehci_hcd_au1xxx_drv_resume(struct device *dev)
265 return 0; 267 return 0;
266} 268}
267*/ 269*/
268MODULE_ALIAS("au1xxx-ehci"); 270MODULE_ALIAS("platform:au1xxx-ehci");
269static struct platform_driver ehci_hcd_au1xxx_driver = { 271static struct platform_driver ehci_hcd_au1xxx_driver = {
270 .probe = ehci_hcd_au1xxx_drv_probe, 272 .probe = ehci_hcd_au1xxx_drv_probe,
271 .remove = ehci_hcd_au1xxx_drv_remove, 273 .remove = ehci_hcd_au1xxx_drv_remove,
@@ -274,6 +276,5 @@ static struct platform_driver ehci_hcd_au1xxx_driver = {
274 /*.resume = ehci_hcd_au1xxx_drv_resume, */ 276 /*.resume = ehci_hcd_au1xxx_drv_resume, */
275 .driver = { 277 .driver = {
276 .name = "au1xxx-ehci", 278 .name = "au1xxx-ehci",
277 .bus = &platform_bus_type
278 } 279 }
279}; 280};
diff --git a/drivers/usb/host/ehci-dbg.c b/drivers/usb/host/ehci-dbg.c
index 64ebfc5548a..4af90df8e7d 100644
--- a/drivers/usb/host/ehci-dbg.c
+++ b/drivers/usb/host/ehci-dbg.c
@@ -27,7 +27,7 @@
27#define ehci_warn(ehci, fmt, args...) \ 27#define ehci_warn(ehci, fmt, args...) \
28 dev_warn (ehci_to_hcd(ehci)->self.controller , fmt , ## args ) 28 dev_warn (ehci_to_hcd(ehci)->self.controller , fmt , ## args )
29 29
30#ifdef EHCI_VERBOSE_DEBUG 30#ifdef VERBOSE_DEBUG
31# define vdbg dbg 31# define vdbg dbg
32# define ehci_vdbg ehci_dbg 32# define ehci_vdbg ehci_dbg
33#else 33#else
@@ -670,7 +670,7 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf)
670 670
671 spin_lock_irqsave (&ehci->lock, flags); 671 spin_lock_irqsave (&ehci->lock, flags);
672 672
673 if (buf->bus->controller->power.power_state.event) { 673 if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) {
674 size = scnprintf (next, size, 674 size = scnprintf (next, size,
675 "bus %s, device %s (driver " DRIVER_VERSION ")\n" 675 "bus %s, device %s (driver " DRIVER_VERSION ")\n"
676 "%s\n" 676 "%s\n"
diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index adb0defa163..6d9bed6c1f4 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -1,5 +1,4 @@
1/* 1/*
2 * (C) Copyright David Brownell 2000-2002
3 * Copyright (c) 2005 MontaVista Software 2 * Copyright (c) 2005 MontaVista Software
4 * 3 *
5 * This program is free software; you can redistribute it and/or modify it 4 * This program is free software; you can redistribute it and/or modify it
@@ -28,7 +27,6 @@
28/* FIXME: Power Management is un-ported so temporarily disable it */ 27/* FIXME: Power Management is un-ported so temporarily disable it */
29#undef CONFIG_PM 28#undef CONFIG_PM
30 29
31/* PCI-based HCs are common, but plenty of non-PCI HCs are used too */
32 30
33/* configure so an HC device and id are always provided */ 31/* configure so an HC device and id are always provided */
34/* always called with process context; sleeping is OK */ 32/* always called with process context; sleeping is OK */
@@ -331,6 +329,7 @@ static int ehci_fsl_drv_probe(struct platform_device *pdev)
331 if (usb_disabled()) 329 if (usb_disabled())
332 return -ENODEV; 330 return -ENODEV;
333 331
332 /* FIXME we only want one one probe() not two */
334 return usb_hcd_fsl_probe(&ehci_fsl_hc_driver, pdev); 333 return usb_hcd_fsl_probe(&ehci_fsl_hc_driver, pdev);
335} 334}
336 335
@@ -338,12 +337,12 @@ static int ehci_fsl_drv_remove(struct platform_device *pdev)
338{ 337{
339 struct usb_hcd *hcd = platform_get_drvdata(pdev); 338 struct usb_hcd *hcd = platform_get_drvdata(pdev);
340 339
340 /* FIXME we only want one one remove() not two */
341 usb_hcd_fsl_remove(hcd, pdev); 341 usb_hcd_fsl_remove(hcd, pdev);
342
343 return 0; 342 return 0;
344} 343}
345 344
346MODULE_ALIAS("fsl-ehci"); 345MODULE_ALIAS("platform:fsl-ehci");
347 346
348static struct platform_driver ehci_fsl_driver = { 347static struct platform_driver ehci_fsl_driver = {
349 .probe = ehci_fsl_drv_probe, 348 .probe = ehci_fsl_drv_probe,
@@ -351,5 +350,5 @@ static struct platform_driver ehci_fsl_driver = {
351 .shutdown = usb_hcd_platform_shutdown, 350 .shutdown = usb_hcd_platform_shutdown,
352 .driver = { 351 .driver = {
353 .name = "fsl-ehci", 352 .name = "fsl-ehci",
354 }, 353 },
355}; 354};
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 85074cb36f3..369a8a5ea7b 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -57,35 +57,6 @@
57 * Special thanks to Intel and VIA for providing host controllers to 57 * Special thanks to Intel and VIA for providing host controllers to
58 * test this driver on, and Cypress (including In-System Design) for 58 * test this driver on, and Cypress (including In-System Design) for
59 * providing early devices for those host controllers to talk to! 59 * providing early devices for those host controllers to talk to!
60 *
61 * HISTORY:
62 *
63 * 2004-05-10 Root hub and PCI suspend/resume support; remote wakeup. (db)
64 * 2004-02-24 Replace pci_* with generic dma_* API calls (dsaxena@plexity.net)
65 * 2003-12-29 Rewritten high speed iso transfer support (by Michal Sojka,
66 * <sojkam@centrum.cz>, updates by DB).
67 *
68 * 2002-11-29 Correct handling for hw async_next register.
69 * 2002-08-06 Handling for bulk and interrupt transfers is mostly shared;
70 * only scheduling is different, no arbitrary limitations.
71 * 2002-07-25 Sanity check PCI reads, mostly for better cardbus support,
72 * clean up HC run state handshaking.
73 * 2002-05-24 Preliminary FS/LS interrupts, using scheduling shortcuts
74 * 2002-05-11 Clear TT errors for FS/LS ctrl/bulk. Fill in some other
75 * missing pieces: enabling 64bit dma, handoff from BIOS/SMM.
76 * 2002-05-07 Some error path cleanups to report better errors; wmb();
77 * use non-CVS version id; better iso bandwidth claim.
78 * 2002-04-19 Control/bulk/interrupt submit no longer uses giveback() on
79 * errors in submit path. Bugfixes to interrupt scheduling/processing.
80 * 2002-03-05 Initial high-speed ISO support; reduce ITD memory; shift
81 * more checking to generic hcd framework (db). Make it work with
82 * Philips EHCI; reduce PCI traffic; shorten IRQ path (Rory Bolt).
83 * 2002-01-14 Minor cleanup; version synch.
84 * 2002-01-08 Fix roothub handoff of FS/LS to companion controllers.
85 * 2002-01-04 Control/Bulk queuing behaves.
86 *
87 * 2001-12-12 Initial patch version for Linux 2.5.1 kernel.
88 * 2001-June Works with usb-storage and NEC EHCI on 2.4
89 */ 60 */
90 61
91#define DRIVER_VERSION "10 Dec 2004" 62#define DRIVER_VERSION "10 Dec 2004"
@@ -95,7 +66,7 @@
95static const char hcd_name [] = "ehci_hcd"; 66static const char hcd_name [] = "ehci_hcd";
96 67
97 68
98#undef EHCI_VERBOSE_DEBUG 69#undef VERBOSE_DEBUG
99#undef EHCI_URB_TRACE 70#undef EHCI_URB_TRACE
100 71
101#ifdef DEBUG 72#ifdef DEBUG
@@ -174,6 +145,16 @@ static int handshake (struct ehci_hcd *ehci, void __iomem *ptr,
174 return -ETIMEDOUT; 145 return -ETIMEDOUT;
175} 146}
176 147
148static int handshake_on_error_set_halt(struct ehci_hcd *ehci, void __iomem *ptr,
149 u32 mask, u32 done, int usec)
150{
151 int error = handshake(ehci, ptr, mask, done, usec);
152 if (error)
153 ehci_to_hcd(ehci)->state = HC_STATE_HALT;
154
155 return error;
156}
157
177/* force HC to halt state from unknown (EHCI spec section 2.3) */ 158/* force HC to halt state from unknown (EHCI spec section 2.3) */
178static int ehci_halt (struct ehci_hcd *ehci) 159static int ehci_halt (struct ehci_hcd *ehci)
179{ 160{
@@ -246,11 +227,9 @@ static void ehci_quiesce (struct ehci_hcd *ehci)
246 /* wait for any schedule enables/disables to take effect */ 227 /* wait for any schedule enables/disables to take effect */
247 temp = ehci_readl(ehci, &ehci->regs->command) << 10; 228 temp = ehci_readl(ehci, &ehci->regs->command) << 10;
248 temp &= STS_ASS | STS_PSS; 229 temp &= STS_ASS | STS_PSS;
249 if (handshake (ehci, &ehci->regs->status, STS_ASS | STS_PSS, 230 if (handshake_on_error_set_halt(ehci, &ehci->regs->status,
250 temp, 16 * 125) != 0) { 231 STS_ASS | STS_PSS, temp, 16 * 125))
251 ehci_to_hcd(ehci)->state = HC_STATE_HALT;
252 return; 232 return;
253 }
254 233
255 /* then disable anything that's still active */ 234 /* then disable anything that's still active */
256 temp = ehci_readl(ehci, &ehci->regs->command); 235 temp = ehci_readl(ehci, &ehci->regs->command);
@@ -258,11 +237,8 @@ static void ehci_quiesce (struct ehci_hcd *ehci)
258 ehci_writel(ehci, temp, &ehci->regs->command); 237 ehci_writel(ehci, temp, &ehci->regs->command);
259 238
260 /* hardware can take 16 microframes to turn off ... */ 239 /* hardware can take 16 microframes to turn off ... */
261 if (handshake (ehci, &ehci->regs->status, STS_ASS | STS_PSS, 240 handshake_on_error_set_halt(ehci, &ehci->regs->status,
262 0, 16 * 125) != 0) { 241 STS_ASS | STS_PSS, 0, 16 * 125);
263 ehci_to_hcd(ehci)->state = HC_STATE_HALT;
264 return;
265 }
266} 242}
267 243
268/*-------------------------------------------------------------------------*/ 244/*-------------------------------------------------------------------------*/
@@ -355,17 +331,13 @@ static void ehci_turn_off_all_ports(struct ehci_hcd *ehci)
355 &ehci->regs->port_status[port]); 331 &ehci->regs->port_status[port]);
356} 332}
357 333
358/* ehci_shutdown kick in for silicon on any bus (not just pci, etc). 334/*
359 * This forcibly disables dma and IRQs, helping kexec and other cases 335 * Halt HC, turn off all ports, and let the BIOS use the companion controllers.
360 * where the next system software may expect clean state. 336 * Should be called with ehci->lock held.
361 */ 337 */
362static void 338static void ehci_silence_controller(struct ehci_hcd *ehci)
363ehci_shutdown (struct usb_hcd *hcd)
364{ 339{
365 struct ehci_hcd *ehci; 340 ehci_halt(ehci);
366
367 ehci = hcd_to_ehci (hcd);
368 (void) ehci_halt (ehci);
369 ehci_turn_off_all_ports(ehci); 341 ehci_turn_off_all_ports(ehci);
370 342
371 /* make BIOS/etc use companion controller during reboot */ 343 /* make BIOS/etc use companion controller during reboot */
@@ -375,6 +347,22 @@ ehci_shutdown (struct usb_hcd *hcd)
375 ehci_readl(ehci, &ehci->regs->configured_flag); 347 ehci_readl(ehci, &ehci->regs->configured_flag);
376} 348}
377 349
350/* ehci_shutdown kick in for silicon on any bus (not just pci, etc).
351 * This forcibly disables dma and IRQs, helping kexec and other cases
352 * where the next system software may expect clean state.
353 */
354static void ehci_shutdown(struct usb_hcd *hcd)
355{
356 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
357
358 del_timer_sync(&ehci->watchdog);
359 del_timer_sync(&ehci->iaa_watchdog);
360
361 spin_lock_irq(&ehci->lock);
362 ehci_silence_controller(ehci);
363 spin_unlock_irq(&ehci->lock);
364}
365
378static void ehci_port_power (struct ehci_hcd *ehci, int is_on) 366static void ehci_port_power (struct ehci_hcd *ehci, int is_on)
379{ 367{
380 unsigned port; 368 unsigned port;
@@ -425,15 +413,15 @@ static void ehci_work (struct ehci_hcd *ehci)
425 timer_action (ehci, TIMER_IO_WATCHDOG); 413 timer_action (ehci, TIMER_IO_WATCHDOG);
426} 414}
427 415
416/*
417 * Called when the ehci_hcd module is removed.
418 */
428static void ehci_stop (struct usb_hcd *hcd) 419static void ehci_stop (struct usb_hcd *hcd)
429{ 420{
430 struct ehci_hcd *ehci = hcd_to_ehci (hcd); 421 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
431 422
432 ehci_dbg (ehci, "stop\n"); 423 ehci_dbg (ehci, "stop\n");
433 424
434 /* Turn off port power on all root hub ports. */
435 ehci_port_power (ehci, 0);
436
437 /* no more interrupts ... */ 425 /* no more interrupts ... */
438 del_timer_sync (&ehci->watchdog); 426 del_timer_sync (&ehci->watchdog);
439 del_timer_sync(&ehci->iaa_watchdog); 427 del_timer_sync(&ehci->iaa_watchdog);
@@ -442,13 +430,10 @@ static void ehci_stop (struct usb_hcd *hcd)
442 if (HC_IS_RUNNING (hcd->state)) 430 if (HC_IS_RUNNING (hcd->state))
443 ehci_quiesce (ehci); 431 ehci_quiesce (ehci);
444 432
433 ehci_silence_controller(ehci);
445 ehci_reset (ehci); 434 ehci_reset (ehci);
446 ehci_writel(ehci, 0, &ehci->regs->intr_enable);
447 spin_unlock_irq(&ehci->lock); 435 spin_unlock_irq(&ehci->lock);
448 436
449 /* let companion controllers work when we aren't */
450 ehci_writel(ehci, 0, &ehci->regs->configured_flag);
451
452 remove_companion_file(ehci); 437 remove_companion_file(ehci);
453 remove_debug_files (ehci); 438 remove_debug_files (ehci);
454 439
@@ -676,7 +661,7 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd)
676 cmd = ehci_readl(ehci, &ehci->regs->command); 661 cmd = ehci_readl(ehci, &ehci->regs->command);
677 bh = 0; 662 bh = 0;
678 663
679#ifdef EHCI_VERBOSE_DEBUG 664#ifdef VERBOSE_DEBUG
680 /* unrequested/ignored: Frame List Rollover */ 665 /* unrequested/ignored: Frame List Rollover */
681 dbg_status (ehci, "irq", status); 666 dbg_status (ehci, "irq", status);
682#endif 667#endif
@@ -710,6 +695,8 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd)
710 /* remote wakeup [4.3.1] */ 695 /* remote wakeup [4.3.1] */
711 if (status & STS_PCD) { 696 if (status & STS_PCD) {
712 unsigned i = HCS_N_PORTS (ehci->hcs_params); 697 unsigned i = HCS_N_PORTS (ehci->hcs_params);
698
699 /* kick root hub later */
713 pcd_status = status; 700 pcd_status = status;
714 701
715 /* resume root hub? */ 702 /* resume root hub? */
@@ -738,8 +725,6 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd)
738 725
739 /* PCI errors [4.15.2.4] */ 726 /* PCI errors [4.15.2.4] */
740 if (unlikely ((status & STS_FATAL) != 0)) { 727 if (unlikely ((status & STS_FATAL) != 0)) {
741 /* bogus "fatal" IRQs appear on some chips... why? */
742 status = ehci_readl(ehci, &ehci->regs->status);
743 dbg_cmd (ehci, "fatal", ehci_readl(ehci, 728 dbg_cmd (ehci, "fatal", ehci_readl(ehci,
744 &ehci->regs->command)); 729 &ehci->regs->command));
745 dbg_status (ehci, "fatal", status); 730 dbg_status (ehci, "fatal", status);
@@ -758,7 +743,7 @@ dead:
758 if (bh) 743 if (bh)
759 ehci_work (ehci); 744 ehci_work (ehci);
760 spin_unlock (&ehci->lock); 745 spin_unlock (&ehci->lock);
761 if (pcd_status & STS_PCD) 746 if (pcd_status)
762 usb_hcd_poll_rh_status(hcd); 747 usb_hcd_poll_rh_status(hcd);
763 return IRQ_HANDLED; 748 return IRQ_HANDLED;
764} 749}
@@ -788,8 +773,14 @@ static int ehci_urb_enqueue (
788 INIT_LIST_HEAD (&qtd_list); 773 INIT_LIST_HEAD (&qtd_list);
789 774
790 switch (usb_pipetype (urb->pipe)) { 775 switch (usb_pipetype (urb->pipe)) {
791 // case PIPE_CONTROL: 776 case PIPE_CONTROL:
792 // case PIPE_BULK: 777 /* qh_completions() code doesn't handle all the fault cases
778 * in multi-TD control transfers. Even 1KB is rare anyway.
779 */
780 if (urb->transfer_buffer_length > (16 * 1024))
781 return -EMSGSIZE;
782 /* FALLTHROUGH */
783 /* case PIPE_BULK: */
793 default: 784 default:
794 if (!qh_urb_transaction (ehci, urb, &qtd_list, mem_flags)) 785 if (!qh_urb_transaction (ehci, urb, &qtd_list, mem_flags))
795 return -ENOMEM; 786 return -ENOMEM;
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
index 4e065e556e4..efffef64f59 100644
--- a/drivers/usb/host/ehci-hub.c
+++ b/drivers/usb/host/ehci-hub.c
@@ -28,7 +28,9 @@
28 28
29/*-------------------------------------------------------------------------*/ 29/*-------------------------------------------------------------------------*/
30 30
31#ifdef CONFIG_USB_PERSIST 31#define PORT_WAKE_BITS (PORT_WKOC_E|PORT_WKDISC_E|PORT_WKCONN_E)
32
33#ifdef CONFIG_PM
32 34
33static int ehci_hub_control( 35static int ehci_hub_control(
34 struct usb_hcd *hcd, 36 struct usb_hcd *hcd,
@@ -104,15 +106,6 @@ static void ehci_handover_companion_ports(struct ehci_hcd *ehci)
104 ehci->owned_ports = 0; 106 ehci->owned_ports = 0;
105} 107}
106 108
107#else /* CONFIG_USB_PERSIST */
108
109static inline void ehci_handover_companion_ports(struct ehci_hcd *ehci)
110{ }
111
112#endif
113
114#ifdef CONFIG_PM
115
116static int ehci_bus_suspend (struct usb_hcd *hcd) 109static int ehci_bus_suspend (struct usb_hcd *hcd)
117{ 110{
118 struct ehci_hcd *ehci = hcd_to_ehci (hcd); 111 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
@@ -158,10 +151,10 @@ static int ehci_bus_suspend (struct usb_hcd *hcd)
158 } 151 }
159 152
160 /* enable remote wakeup on all ports */ 153 /* enable remote wakeup on all ports */
161 if (device_may_wakeup(&hcd->self.root_hub->dev)) 154 if (hcd->self.root_hub->do_remote_wakeup)
162 t2 |= PORT_WKOC_E|PORT_WKDISC_E|PORT_WKCONN_E; 155 t2 |= PORT_WAKE_BITS;
163 else 156 else
164 t2 &= ~(PORT_WKOC_E|PORT_WKDISC_E|PORT_WKCONN_E); 157 t2 &= ~PORT_WAKE_BITS;
165 158
166 if (t1 != t2) { 159 if (t1 != t2) {
167 ehci_vdbg (ehci, "port %d, %08x -> %08x\n", 160 ehci_vdbg (ehci, "port %d, %08x -> %08x\n",
@@ -183,7 +176,7 @@ static int ehci_bus_suspend (struct usb_hcd *hcd)
183 176
184 /* allow remote wakeup */ 177 /* allow remote wakeup */
185 mask = INTR_MASK; 178 mask = INTR_MASK;
186 if (!device_may_wakeup(&hcd->self.root_hub->dev)) 179 if (!hcd->self.root_hub->do_remote_wakeup)
187 mask &= ~STS_PCD; 180 mask &= ~STS_PCD;
188 ehci_writel(ehci, mask, &ehci->regs->intr_enable); 181 ehci_writel(ehci, mask, &ehci->regs->intr_enable);
189 ehci_readl(ehci, &ehci->regs->intr_enable); 182 ehci_readl(ehci, &ehci->regs->intr_enable);
@@ -241,8 +234,7 @@ static int ehci_bus_resume (struct usb_hcd *hcd)
241 i = HCS_N_PORTS (ehci->hcs_params); 234 i = HCS_N_PORTS (ehci->hcs_params);
242 while (i--) { 235 while (i--) {
243 temp = ehci_readl(ehci, &ehci->regs->port_status [i]); 236 temp = ehci_readl(ehci, &ehci->regs->port_status [i]);
244 temp &= ~(PORT_RWC_BITS 237 temp &= ~(PORT_RWC_BITS | PORT_WAKE_BITS);
245 | PORT_WKOC_E | PORT_WKDISC_E | PORT_WKCONN_E);
246 if (test_bit(i, &ehci->bus_suspended) && 238 if (test_bit(i, &ehci->bus_suspended) &&
247 (temp & PORT_SUSPEND)) { 239 (temp & PORT_SUSPEND)) {
248 ehci->reset_done [i] = jiffies + msecs_to_jiffies (20); 240 ehci->reset_done [i] = jiffies + msecs_to_jiffies (20);
@@ -281,9 +273,7 @@ static int ehci_bus_resume (struct usb_hcd *hcd)
281 ehci_writel(ehci, INTR_MASK, &ehci->regs->intr_enable); 273 ehci_writel(ehci, INTR_MASK, &ehci->regs->intr_enable);
282 274
283 spin_unlock_irq (&ehci->lock); 275 spin_unlock_irq (&ehci->lock);
284 276 ehci_handover_companion_ports(ehci);
285 if (!power_okay)
286 ehci_handover_companion_ports(ehci);
287 return 0; 277 return 0;
288} 278}
289 279
@@ -545,8 +535,6 @@ ehci_hub_descriptor (
545 535
546/*-------------------------------------------------------------------------*/ 536/*-------------------------------------------------------------------------*/
547 537
548#define PORT_WAKE_BITS (PORT_WKOC_E|PORT_WKDISC_E|PORT_WKCONN_E)
549
550static int ehci_hub_control ( 538static int ehci_hub_control (
551 struct usb_hcd *hcd, 539 struct usb_hcd *hcd,
552 u16 typeReq, 540 u16 typeReq,
@@ -778,7 +766,7 @@ static int ehci_hub_control (
778 if (temp & PORT_POWER) 766 if (temp & PORT_POWER)
779 status |= 1 << USB_PORT_FEAT_POWER; 767 status |= 1 << USB_PORT_FEAT_POWER;
780 768
781#ifndef EHCI_VERBOSE_DEBUG 769#ifndef VERBOSE_DEBUG
782 if (status & ~0xffff) /* only if wPortChange is interesting */ 770 if (status & ~0xffff) /* only if wPortChange is interesting */
783#endif 771#endif
784 dbg_port (ehci, "GetStatus", wIndex + 1, temp); 772 dbg_port (ehci, "GetStatus", wIndex + 1, temp);
@@ -812,8 +800,6 @@ static int ehci_hub_control (
812 if ((temp & PORT_PE) == 0 800 if ((temp & PORT_PE) == 0
813 || (temp & PORT_RESET) != 0) 801 || (temp & PORT_RESET) != 0)
814 goto error; 802 goto error;
815 if (device_may_wakeup(&hcd->self.root_hub->dev))
816 temp |= PORT_WAKE_BITS;
817 ehci_writel(ehci, temp | PORT_SUSPEND, status_reg); 803 ehci_writel(ehci, temp | PORT_SUSPEND, status_reg);
818 break; 804 break;
819 case USB_PORT_FEAT_POWER: 805 case USB_PORT_FEAT_POWER:
diff --git a/drivers/usb/host/ehci-ixp4xx.c b/drivers/usb/host/ehci-ixp4xx.c
index 3041d8f055f..601c8795a85 100644
--- a/drivers/usb/host/ehci-ixp4xx.c
+++ b/drivers/usb/host/ehci-ixp4xx.c
@@ -140,13 +140,12 @@ static int ixp4xx_ehci_remove(struct platform_device *pdev)
140 return 0; 140 return 0;
141} 141}
142 142
143MODULE_ALIAS("ixp4xx-ehci"); 143MODULE_ALIAS("platform:ixp4xx-ehci");
144 144
145static struct platform_driver ixp4xx_ehci_driver = { 145static struct platform_driver ixp4xx_ehci_driver = {
146 .probe = ixp4xx_ehci_probe, 146 .probe = ixp4xx_ehci_probe,
147 .remove = ixp4xx_ehci_remove, 147 .remove = ixp4xx_ehci_remove,
148 .driver = { 148 .driver = {
149 .name = "ixp4xx-ehci", 149 .name = "ixp4xx-ehci",
150 .bus = &platform_bus_type
151 }, 150 },
152}; 151};
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
index 72ccd56e36d..5bb7f6bb13f 100644
--- a/drivers/usb/host/ehci-pci.c
+++ b/drivers/usb/host/ehci-pci.c
@@ -130,6 +130,7 @@ static int ehci_pci_setup(struct usb_hcd *hcd)
130 case PCI_VENDOR_ID_TDI: 130 case PCI_VENDOR_ID_TDI:
131 if (pdev->device == PCI_DEVICE_ID_TDI_EHCI) { 131 if (pdev->device == PCI_DEVICE_ID_TDI_EHCI) {
132 ehci->is_tdi_rh_tt = 1; 132 ehci->is_tdi_rh_tt = 1;
133 hcd->has_tt = 1;
133 tdi_reset(ehci); 134 tdi_reset(ehci);
134 } 135 }
135 break; 136 break;
@@ -221,6 +222,7 @@ static int ehci_pci_setup(struct usb_hcd *hcd)
221 ehci_warn(ehci, "selective suspend/wakeup unavailable\n"); 222 ehci_warn(ehci, "selective suspend/wakeup unavailable\n");
222#endif 223#endif
223 224
225 ehci_port_power(ehci, 1);
224 retval = ehci_pci_reinit(ehci, pdev); 226 retval = ehci_pci_reinit(ehci, pdev);
225done: 227done:
226 return retval; 228 return retval;
@@ -299,7 +301,7 @@ static int ehci_pci_resume(struct usb_hcd *hcd)
299 if (ehci_readl(ehci, &ehci->regs->configured_flag) == FLAG_CF) { 301 if (ehci_readl(ehci, &ehci->regs->configured_flag) == FLAG_CF) {
300 int mask = INTR_MASK; 302 int mask = INTR_MASK;
301 303
302 if (!device_may_wakeup(&hcd->self.root_hub->dev)) 304 if (!hcd->self.root_hub->do_remote_wakeup)
303 mask &= ~STS_PCD; 305 mask &= ~STS_PCD;
304 ehci_writel(ehci, mask, &ehci->regs->intr_enable); 306 ehci_writel(ehci, mask, &ehci->regs->intr_enable);
305 ehci_readl(ehci, &ehci->regs->intr_enable); 307 ehci_readl(ehci, &ehci->regs->intr_enable);
@@ -329,7 +331,6 @@ static int ehci_pci_resume(struct usb_hcd *hcd)
329 331
330 /* here we "know" root ports should always stay powered */ 332 /* here we "know" root ports should always stay powered */
331 ehci_port_power(ehci, 1); 333 ehci_port_power(ehci, 1);
332 ehci_handover_companion_ports(ehci);
333 334
334 hcd->state = HC_STATE_SUSPENDED; 335 hcd->state = HC_STATE_SUSPENDED;
335 return 0; 336 return 0;
@@ -353,8 +354,8 @@ static const struct hc_driver ehci_pci_hc_driver = {
353 .reset = ehci_pci_setup, 354 .reset = ehci_pci_setup,
354 .start = ehci_run, 355 .start = ehci_run,
355#ifdef CONFIG_PM 356#ifdef CONFIG_PM
356 .suspend = ehci_pci_suspend, 357 .pci_suspend = ehci_pci_suspend,
357 .resume = ehci_pci_resume, 358 .pci_resume = ehci_pci_resume,
358#endif 359#endif
359 .stop = ehci_stop, 360 .stop = ehci_stop,
360 .shutdown = ehci_shutdown, 361 .shutdown = ehci_shutdown,
diff --git a/drivers/usb/host/ehci-ppc-soc.c b/drivers/usb/host/ehci-ppc-soc.c
index a3249078c80..6c76036783a 100644
--- a/drivers/usb/host/ehci-ppc-soc.c
+++ b/drivers/usb/host/ehci-ppc-soc.c
@@ -175,6 +175,7 @@ static int ehci_hcd_ppc_soc_drv_probe(struct platform_device *pdev)
175 if (usb_disabled()) 175 if (usb_disabled())
176 return -ENODEV; 176 return -ENODEV;
177 177
178 /* FIXME we only want one one probe() not two */
178 ret = usb_ehci_ppc_soc_probe(&ehci_ppc_soc_hc_driver, &hcd, pdev); 179 ret = usb_ehci_ppc_soc_probe(&ehci_ppc_soc_hc_driver, &hcd, pdev);
179 return ret; 180 return ret;
180} 181}
@@ -183,17 +184,17 @@ static int ehci_hcd_ppc_soc_drv_remove(struct platform_device *pdev)
183{ 184{
184 struct usb_hcd *hcd = platform_get_drvdata(pdev); 185 struct usb_hcd *hcd = platform_get_drvdata(pdev);
185 186
187 /* FIXME we only want one one remove() not two */
186 usb_ehci_ppc_soc_remove(hcd, pdev); 188 usb_ehci_ppc_soc_remove(hcd, pdev);
187 return 0; 189 return 0;
188} 190}
189 191
190MODULE_ALIAS("ppc-soc-ehci"); 192MODULE_ALIAS("platform:ppc-soc-ehci");
191static struct platform_driver ehci_ppc_soc_driver = { 193static struct platform_driver ehci_ppc_soc_driver = {
192 .probe = ehci_hcd_ppc_soc_drv_probe, 194 .probe = ehci_hcd_ppc_soc_drv_probe,
193 .remove = ehci_hcd_ppc_soc_drv_remove, 195 .remove = ehci_hcd_ppc_soc_drv_remove,
194 .shutdown = usb_hcd_platform_shutdown, 196 .shutdown = usb_hcd_platform_shutdown,
195 .driver = { 197 .driver = {
196 .name = "ppc-soc-ehci", 198 .name = "ppc-soc-ehci",
197 .bus = &platform_bus_type
198 } 199 }
199}; 200};
diff --git a/drivers/usb/host/ehci-ps3.c b/drivers/usb/host/ehci-ps3.c
index bbda58eb881..69782221bcf 100644
--- a/drivers/usb/host/ehci-ps3.c
+++ b/drivers/usb/host/ehci-ps3.c
@@ -125,7 +125,6 @@ static int ps3_ehci_probe(struct ps3_system_bus_device *dev)
125 goto fail_irq; 125 goto fail_irq;
126 } 126 }
127 127
128 dev->core.power.power_state = PMSG_ON;
129 dev->core.dma_mask = &dummy_mask; /* FIXME: for improper usb code */ 128 dev->core.dma_mask = &dummy_mask; /* FIXME: for improper usb code */
130 129
131 hcd = usb_create_hcd(&ps3_ehci_hc_driver, &dev->core, dev->core.bus_id); 130 hcd = usb_create_hcd(&ps3_ehci_hc_driver, &dev->core, dev->core.bus_id);
diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c
index 2e49de820b1..5ae689139dd 100644
--- a/drivers/usb/host/ehci-q.c
+++ b/drivers/usb/host/ehci-q.c
@@ -242,7 +242,8 @@ __acquires(ehci->lock)
242 if (unlikely(urb->unlinked)) { 242 if (unlikely(urb->unlinked)) {
243 COUNT(ehci->stats.unlink); 243 COUNT(ehci->stats.unlink);
244 } else { 244 } else {
245 if (likely(status == -EINPROGRESS)) 245 /* report non-error and short read status as zero */
246 if (status == -EINPROGRESS || status == -EREMOTEIO)
246 status = 0; 247 status = 0;
247 COUNT(ehci->stats.complete); 248 COUNT(ehci->stats.complete);
248 } 249 }
@@ -250,7 +251,7 @@ __acquires(ehci->lock)
250#ifdef EHCI_URB_TRACE 251#ifdef EHCI_URB_TRACE
251 ehci_dbg (ehci, 252 ehci_dbg (ehci,
252 "%s %s urb %p ep%d%s status %d len %d/%d\n", 253 "%s %s urb %p ep%d%s status %d len %d/%d\n",
253 __FUNCTION__, urb->dev->devpath, urb, 254 __func__, urb->dev->devpath, urb,
254 usb_pipeendpoint (urb->pipe), 255 usb_pipeendpoint (urb->pipe),
255 usb_pipein (urb->pipe) ? "in" : "out", 256 usb_pipein (urb->pipe) ? "in" : "out",
256 status, 257 status,
@@ -283,7 +284,6 @@ qh_completions (struct ehci_hcd *ehci, struct ehci_qh *qh)
283 int last_status = -EINPROGRESS; 284 int last_status = -EINPROGRESS;
284 int stopped; 285 int stopped;
285 unsigned count = 0; 286 unsigned count = 0;
286 int do_status = 0;
287 u8 state; 287 u8 state;
288 u32 halt = HALT_BIT(ehci); 288 u32 halt = HALT_BIT(ehci);
289 289
@@ -309,7 +309,6 @@ qh_completions (struct ehci_hcd *ehci, struct ehci_qh *qh)
309 struct ehci_qtd *qtd; 309 struct ehci_qtd *qtd;
310 struct urb *urb; 310 struct urb *urb;
311 u32 token = 0; 311 u32 token = 0;
312 int qtd_status;
313 312
314 qtd = list_entry (entry, struct ehci_qtd, qtd_list); 313 qtd = list_entry (entry, struct ehci_qtd, qtd_list);
315 urb = qtd->urb; 314 urb = qtd->urb;
@@ -336,11 +335,20 @@ qh_completions (struct ehci_hcd *ehci, struct ehci_qh *qh)
336 /* always clean up qtds the hc de-activated */ 335 /* always clean up qtds the hc de-activated */
337 if ((token & QTD_STS_ACTIVE) == 0) { 336 if ((token & QTD_STS_ACTIVE) == 0) {
338 337
338 /* on STALL, error, and short reads this urb must
339 * complete and all its qtds must be recycled.
340 */
339 if ((token & QTD_STS_HALT) != 0) { 341 if ((token & QTD_STS_HALT) != 0) {
340 stopped = 1; 342 stopped = 1;
341 343
342 /* magic dummy for some short reads; qh won't advance. 344 /* magic dummy for some short reads; qh won't advance.
343 * that silicon quirk can kick in with this dummy too. 345 * that silicon quirk can kick in with this dummy too.
346 *
347 * other short reads won't stop the queue, including
348 * control transfers (status stage handles that) or
349 * most other single-qtd reads ... the queue stops if
350 * URB_SHORT_NOT_OK was set so the driver submitting
351 * the urbs could clean it up.
344 */ 352 */
345 } else if (IS_SHORT_READ (token) 353 } else if (IS_SHORT_READ (token)
346 && !(qtd->hw_alt_next 354 && !(qtd->hw_alt_next
@@ -354,28 +362,21 @@ qh_completions (struct ehci_hcd *ehci, struct ehci_qh *qh)
354 && HC_IS_RUNNING (ehci_to_hcd(ehci)->state))) { 362 && HC_IS_RUNNING (ehci_to_hcd(ehci)->state))) {
355 break; 363 break;
356 364
365 /* scan the whole queue for unlinks whenever it stops */
357 } else { 366 } else {
358 stopped = 1; 367 stopped = 1;
359 368
360 if (unlikely (!HC_IS_RUNNING (ehci_to_hcd(ehci)->state))) 369 /* cancel everything if we halt, suspend, etc */
370 if (!HC_IS_RUNNING(ehci_to_hcd(ehci)->state))
361 last_status = -ESHUTDOWN; 371 last_status = -ESHUTDOWN;
362 372
363 /* ignore active urbs unless some previous qtd 373 /* this qtd is active; skip it unless a previous qtd
364 * for the urb faulted (including short read) or 374 * for its urb faulted, or its urb was canceled.
365 * its urb was canceled. we may patch qh or qtds.
366 */ 375 */
367 if (likely(last_status == -EINPROGRESS && 376 else if (last_status == -EINPROGRESS && !urb->unlinked)
368 !urb->unlinked))
369 continue;
370
371 /* issue status after short control reads */
372 if (unlikely (do_status != 0)
373 && QTD_PID (token) == 0 /* OUT */) {
374 do_status = 0;
375 continue; 377 continue;
376 }
377 378
378 /* token in overlay may be most current */ 379 /* qh unlinked; token in overlay may be most current */
379 if (state == QH_STATE_IDLE 380 if (state == QH_STATE_IDLE
380 && cpu_to_hc32(ehci, qtd->qtd_dma) 381 && cpu_to_hc32(ehci, qtd->qtd_dma)
381 == qh->hw_current) 382 == qh->hw_current)
@@ -392,21 +393,32 @@ halt:
392 } 393 }
393 } 394 }
394 395
395 /* remove it from the queue */ 396 /* unless we already know the urb's status, collect qtd status
396 qtd_status = qtd_copy_status(ehci, urb, qtd->length, token); 397 * and update count of bytes transferred. in common short read
397 if (unlikely(qtd_status == -EREMOTEIO)) { 398 * cases with only one data qtd (including control transfers),
398 do_status = (!urb->unlinked && 399 * queue processing won't halt. but with two or more qtds (for
399 usb_pipecontrol(urb->pipe)); 400 * example, with a 32 KB transfer), when the first qtd gets a
400 qtd_status = 0; 401 * short read the second must be removed by hand.
402 */
403 if (last_status == -EINPROGRESS) {
404 last_status = qtd_copy_status(ehci, urb,
405 qtd->length, token);
406 if (last_status == -EREMOTEIO
407 && (qtd->hw_alt_next
408 & EHCI_LIST_END(ehci)))
409 last_status = -EINPROGRESS;
401 } 410 }
402 if (likely(last_status == -EINPROGRESS))
403 last_status = qtd_status;
404 411
412 /* if we're removing something not at the queue head,
413 * patch the hardware queue pointer.
414 */
405 if (stopped && qtd->qtd_list.prev != &qh->qtd_list) { 415 if (stopped && qtd->qtd_list.prev != &qh->qtd_list) {
406 last = list_entry (qtd->qtd_list.prev, 416 last = list_entry (qtd->qtd_list.prev,
407 struct ehci_qtd, qtd_list); 417 struct ehci_qtd, qtd_list);
408 last->hw_next = qtd->hw_next; 418 last->hw_next = qtd->hw_next;
409 } 419 }
420
421 /* remove qtd; it's recycled after possible urb completion */
410 list_del (&qtd->qtd_list); 422 list_del (&qtd->qtd_list);
411 last = qtd; 423 last = qtd;
412 } 424 }
@@ -431,7 +443,15 @@ halt:
431 qh_refresh(ehci, qh); 443 qh_refresh(ehci, qh);
432 break; 444 break;
433 case QH_STATE_LINKED: 445 case QH_STATE_LINKED:
434 /* should be rare for periodic transfers, 446 /* We won't refresh a QH that's linked (after the HC
447 * stopped the queue). That avoids a race:
448 * - HC reads first part of QH;
449 * - CPU updates that first part and the token;
450 * - HC reads rest of that QH, including token
451 * Result: HC gets an inconsistent image, and then
452 * DMAs to/from the wrong memory (corrupting it).
453 *
454 * That should be rare for interrupt transfers,
435 * except maybe high bandwidth ... 455 * except maybe high bandwidth ...
436 */ 456 */
437 if ((cpu_to_hc32(ehci, QH_SMASK) 457 if ((cpu_to_hc32(ehci, QH_SMASK)
@@ -549,6 +569,12 @@ qh_urb_transaction (
549 this_qtd_len = qtd_fill(ehci, qtd, buf, len, token, maxpacket); 569 this_qtd_len = qtd_fill(ehci, qtd, buf, len, token, maxpacket);
550 len -= this_qtd_len; 570 len -= this_qtd_len;
551 buf += this_qtd_len; 571 buf += this_qtd_len;
572
573 /*
574 * short reads advance to a "magic" dummy instead of the next
575 * qtd ... that forces the queue to stop, for manual cleanup.
576 * (this will usually be overridden later.)
577 */
552 if (is_input) 578 if (is_input)
553 qtd->hw_alt_next = ehci->async->hw_alt_next; 579 qtd->hw_alt_next = ehci->async->hw_alt_next;
554 580
@@ -568,8 +594,10 @@ qh_urb_transaction (
568 list_add_tail (&qtd->qtd_list, head); 594 list_add_tail (&qtd->qtd_list, head);
569 } 595 }
570 596
571 /* unless the bulk/interrupt caller wants a chance to clean 597 /*
572 * up after short reads, hc should advance qh past this urb 598 * unless the caller requires manual cleanup after short reads,
599 * have the alt_next mechanism keep the queue running after the
600 * last data qtd (the only one, for control and most other cases).
573 */ 601 */
574 if (likely ((urb->transfer_flags & URB_SHORT_NOT_OK) == 0 602 if (likely ((urb->transfer_flags & URB_SHORT_NOT_OK) == 0
575 || usb_pipecontrol (urb->pipe))) 603 || usb_pipecontrol (urb->pipe)))
@@ -657,6 +685,14 @@ qh_make (
657 type = usb_pipetype (urb->pipe); 685 type = usb_pipetype (urb->pipe);
658 maxp = usb_maxpacket (urb->dev, urb->pipe, !is_input); 686 maxp = usb_maxpacket (urb->dev, urb->pipe, !is_input);
659 687
688 /* 1024 byte maxpacket is a hardware ceiling. High bandwidth
689 * acts like up to 3KB, but is built from smaller packets.
690 */
691 if (max_packet(maxp) > 1024) {
692 ehci_dbg(ehci, "bogus qh maxpacket %d\n", max_packet(maxp));
693 goto done;
694 }
695
660 /* Compute interrupt scheduling parameters just once, and save. 696 /* Compute interrupt scheduling parameters just once, and save.
661 * - allowing for high bandwidth, how many nsec/uframe are used? 697 * - allowing for high bandwidth, how many nsec/uframe are used?
662 * - split transactions need a second CSPLIT uframe; same question 698 * - split transactions need a second CSPLIT uframe; same question
@@ -757,7 +793,13 @@ qh_make (
757 info2 |= (EHCI_TUNE_MULT_HS << 30); 793 info2 |= (EHCI_TUNE_MULT_HS << 30);
758 } else if (type == PIPE_BULK) { 794 } else if (type == PIPE_BULK) {
759 info1 |= (EHCI_TUNE_RL_HS << 28); 795 info1 |= (EHCI_TUNE_RL_HS << 28);
760 info1 |= 512 << 16; /* usb2 fixed maxpacket */ 796 /* The USB spec says that high speed bulk endpoints
797 * always use 512 byte maxpacket. But some device
798 * vendors decided to ignore that, and MSFT is happy
799 * to help them do so. So now people expect to use
800 * such nonconformant devices with Linux too; sigh.
801 */
802 info1 |= max_packet(maxp) << 16;
761 info2 |= (EHCI_TUNE_MULT_HS << 30); 803 info2 |= (EHCI_TUNE_MULT_HS << 30);
762 } else { /* PIPE_INTERRUPT */ 804 } else { /* PIPE_INTERRUPT */
763 info1 |= max_packet (maxp) << 16; 805 info1 |= max_packet (maxp) << 16;
@@ -932,7 +974,7 @@ submit_async (
932#ifdef EHCI_URB_TRACE 974#ifdef EHCI_URB_TRACE
933 ehci_dbg (ehci, 975 ehci_dbg (ehci,
934 "%s %s urb %p ep%d%s len %d, qtd %p [qh %p]\n", 976 "%s %s urb %p ep%d%s len %d, qtd %p [qh %p]\n",
935 __FUNCTION__, urb->dev->devpath, urb, 977 __func__, urb->dev->devpath, urb,
936 epnum & 0x0f, (epnum & USB_DIR_IN) ? "in" : "out", 978 epnum & 0x0f, (epnum & USB_DIR_IN) ? "in" : "out",
937 urb->transfer_buffer_length, 979 urb->transfer_buffer_length,
938 qtd, urb->ep->hcpriv); 980 qtd, urb->ep->hcpriv);
diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c
index 8a8e08a51ba..be575e46eac 100644
--- a/drivers/usb/host/ehci-sched.c
+++ b/drivers/usb/host/ehci-sched.c
@@ -440,11 +440,10 @@ static int enable_periodic (struct ehci_hcd *ehci)
440 /* did clearing PSE did take effect yet? 440 /* did clearing PSE did take effect yet?
441 * takes effect only at frame boundaries... 441 * takes effect only at frame boundaries...
442 */ 442 */
443 status = handshake(ehci, &ehci->regs->status, STS_PSS, 0, 9 * 125); 443 status = handshake_on_error_set_halt(ehci, &ehci->regs->status,
444 if (status != 0) { 444 STS_PSS, 0, 9 * 125);
445 ehci_to_hcd(ehci)->state = HC_STATE_HALT; 445 if (status)
446 return status; 446 return status;
447 }
448 447
449 cmd = ehci_readl(ehci, &ehci->regs->command) | CMD_PSE; 448 cmd = ehci_readl(ehci, &ehci->regs->command) | CMD_PSE;
450 ehci_writel(ehci, cmd, &ehci->regs->command); 449 ehci_writel(ehci, cmd, &ehci->regs->command);
@@ -465,11 +464,10 @@ static int disable_periodic (struct ehci_hcd *ehci)
465 /* did setting PSE not take effect yet? 464 /* did setting PSE not take effect yet?
466 * takes effect only at frame boundaries... 465 * takes effect only at frame boundaries...
467 */ 466 */
468 status = handshake(ehci, &ehci->regs->status, STS_PSS, STS_PSS, 9 * 125); 467 status = handshake_on_error_set_halt(ehci, &ehci->regs->status,
469 if (status != 0) { 468 STS_PSS, STS_PSS, 9 * 125);
470 ehci_to_hcd(ehci)->state = HC_STATE_HALT; 469 if (status)
471 return status; 470 return status;
472 }
473 471
474 cmd = ehci_readl(ehci, &ehci->regs->command) & ~CMD_PSE; 472 cmd = ehci_readl(ehci, &ehci->regs->command) & ~CMD_PSE;
475 ehci_writel(ehci, cmd, &ehci->regs->command); 473 ehci_writel(ehci, cmd, &ehci->regs->command);
@@ -1183,21 +1181,18 @@ itd_urb_transaction (
1183 struct ehci_itd, itd_list); 1181 struct ehci_itd, itd_list);
1184 list_del (&itd->itd_list); 1182 list_del (&itd->itd_list);
1185 itd_dma = itd->itd_dma; 1183 itd_dma = itd->itd_dma;
1186 } else 1184 } else {
1187 itd = NULL;
1188
1189 if (!itd) {
1190 spin_unlock_irqrestore (&ehci->lock, flags); 1185 spin_unlock_irqrestore (&ehci->lock, flags);
1191 itd = dma_pool_alloc (ehci->itd_pool, mem_flags, 1186 itd = dma_pool_alloc (ehci->itd_pool, mem_flags,
1192 &itd_dma); 1187 &itd_dma);
1193 spin_lock_irqsave (&ehci->lock, flags); 1188 spin_lock_irqsave (&ehci->lock, flags);
1189 if (!itd) {
1190 iso_sched_free(stream, sched);
1191 spin_unlock_irqrestore(&ehci->lock, flags);
1192 return -ENOMEM;
1193 }
1194 } 1194 }
1195 1195
1196 if (unlikely (NULL == itd)) {
1197 iso_sched_free (stream, sched);
1198 spin_unlock_irqrestore (&ehci->lock, flags);
1199 return -ENOMEM;
1200 }
1201 memset (itd, 0, sizeof *itd); 1196 memset (itd, 0, sizeof *itd);
1202 itd->itd_dma = itd_dma; 1197 itd->itd_dma = itd_dma;
1203 list_add (&itd->itd_list, &sched->td_list); 1198 list_add (&itd->itd_list, &sched->td_list);
@@ -1682,7 +1677,7 @@ static int itd_submit (struct ehci_hcd *ehci, struct urb *urb,
1682#ifdef EHCI_URB_TRACE 1677#ifdef EHCI_URB_TRACE
1683 ehci_dbg (ehci, 1678 ehci_dbg (ehci,
1684 "%s %s urb %p ep%d%s len %d, %d pkts %d uframes [%p]\n", 1679 "%s %s urb %p ep%d%s len %d, %d pkts %d uframes [%p]\n",
1685 __FUNCTION__, urb->dev->devpath, urb, 1680 __func__, urb->dev->devpath, urb,
1686 usb_pipeendpoint (urb->pipe), 1681 usb_pipeendpoint (urb->pipe),
1687 usb_pipein (urb->pipe) ? "in" : "out", 1682 usb_pipein (urb->pipe) ? "in" : "out",
1688 urb->transfer_buffer_length, 1683 urb->transfer_buffer_length,
@@ -1816,21 +1811,18 @@ sitd_urb_transaction (
1816 struct ehci_sitd, sitd_list); 1811 struct ehci_sitd, sitd_list);
1817 list_del (&sitd->sitd_list); 1812 list_del (&sitd->sitd_list);
1818 sitd_dma = sitd->sitd_dma; 1813 sitd_dma = sitd->sitd_dma;
1819 } else 1814 } else {
1820 sitd = NULL;
1821
1822 if (!sitd) {
1823 spin_unlock_irqrestore (&ehci->lock, flags); 1815 spin_unlock_irqrestore (&ehci->lock, flags);
1824 sitd = dma_pool_alloc (ehci->sitd_pool, mem_flags, 1816 sitd = dma_pool_alloc (ehci->sitd_pool, mem_flags,
1825 &sitd_dma); 1817 &sitd_dma);
1826 spin_lock_irqsave (&ehci->lock, flags); 1818 spin_lock_irqsave (&ehci->lock, flags);
1819 if (!sitd) {
1820 iso_sched_free(stream, iso_sched);
1821 spin_unlock_irqrestore(&ehci->lock, flags);
1822 return -ENOMEM;
1823 }
1827 } 1824 }
1828 1825
1829 if (!sitd) {
1830 iso_sched_free (stream, iso_sched);
1831 spin_unlock_irqrestore (&ehci->lock, flags);
1832 return -ENOMEM;
1833 }
1834 memset (sitd, 0, sizeof *sitd); 1826 memset (sitd, 0, sizeof *sitd);
1835 sitd->sitd_dma = sitd_dma; 1827 sitd->sitd_dma = sitd_dma;
1836 list_add (&sitd->sitd_list, &iso_sched->td_list); 1828 list_add (&sitd->sitd_list, &iso_sched->td_list);
diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c
index 203a3359a64..20b9a0d0742 100644
--- a/drivers/usb/host/isp116x-hcd.c
+++ b/drivers/usb/host/isp116x-hcd.c
@@ -1400,7 +1400,7 @@ static int isp116x_bus_suspend(struct usb_hcd *hcd)
1400 spin_unlock_irqrestore(&isp116x->lock, flags); 1400 spin_unlock_irqrestore(&isp116x->lock, flags);
1401 val &= (~HCCONTROL_HCFS & ~HCCONTROL_RWE); 1401 val &= (~HCCONTROL_HCFS & ~HCCONTROL_RWE);
1402 val |= HCCONTROL_USB_SUSPEND; 1402 val |= HCCONTROL_USB_SUSPEND;
1403 if (device_may_wakeup(&hcd->self.root_hub->dev)) 1403 if (hcd->self.root_hub->do_remote_wakeup)
1404 val |= HCCONTROL_RWE; 1404 val |= HCCONTROL_RWE;
1405 /* Wait for usb transfers to finish */ 1405 /* Wait for usb transfers to finish */
1406 msleep(2); 1406 msleep(2);
@@ -1442,11 +1442,6 @@ static int isp116x_bus_resume(struct usb_hcd *hcd)
1442 break; 1442 break;
1443 case HCCONTROL_USB_OPER: 1443 case HCCONTROL_USB_OPER:
1444 spin_unlock_irq(&isp116x->lock); 1444 spin_unlock_irq(&isp116x->lock);
1445 /* Without setting power_state here the
1446 SUSPENDED state won't be removed from
1447 sysfs/usbN/power.state as a response to remote
1448 wakeup. Maybe in the future. */
1449 hcd->self.root_hub->dev.power.power_state = PMSG_ON;
1450 return 0; 1445 return 0;
1451 default: 1446 default:
1452 /* HCCONTROL_USB_RESET: this may happen, when during 1447 /* HCCONTROL_USB_RESET: this may happen, when during
@@ -1460,7 +1455,6 @@ static int isp116x_bus_resume(struct usb_hcd *hcd)
1460 if ((isp116x->rhdesca & RH_A_NDP) == 2) 1455 if ((isp116x->rhdesca & RH_A_NDP) == 2)
1461 isp116x_hub_control(hcd, SetPortFeature, 1456 isp116x_hub_control(hcd, SetPortFeature,
1462 USB_PORT_FEAT_POWER, 2, NULL, 0); 1457 USB_PORT_FEAT_POWER, 2, NULL, 0);
1463 hcd->self.root_hub->dev.power.power_state = PMSG_ON;
1464 return 0; 1458 return 0;
1465 } 1459 }
1466 1460
@@ -1486,8 +1480,6 @@ static int isp116x_bus_resume(struct usb_hcd *hcd)
1486 isp116x_write_reg32(isp116x, HCCONTROL, 1480 isp116x_write_reg32(isp116x, HCCONTROL,
1487 (val & ~HCCONTROL_HCFS) | HCCONTROL_USB_OPER); 1481 (val & ~HCCONTROL_HCFS) | HCCONTROL_USB_OPER);
1488 spin_unlock_irq(&isp116x->lock); 1482 spin_unlock_irq(&isp116x->lock);
1489 /* see analogous comment above */
1490 hcd->self.root_hub->dev.power.power_state = PMSG_ON;
1491 hcd->state = HC_STATE_RUNNING; 1483 hcd->state = HC_STATE_RUNNING;
1492 1484
1493 return 0; 1485 return 0;
@@ -1663,7 +1655,6 @@ static int __devinit isp116x_probe(struct platform_device *pdev)
1663static int isp116x_suspend(struct platform_device *dev, pm_message_t state) 1655static int isp116x_suspend(struct platform_device *dev, pm_message_t state)
1664{ 1656{
1665 VDBG("%s: state %x\n", __func__, state.event); 1657 VDBG("%s: state %x\n", __func__, state.event);
1666 dev->dev.power.power_state = state;
1667 return 0; 1658 return 0;
1668} 1659}
1669 1660
@@ -1672,8 +1663,7 @@ static int isp116x_suspend(struct platform_device *dev, pm_message_t state)
1672*/ 1663*/
1673static int isp116x_resume(struct platform_device *dev) 1664static int isp116x_resume(struct platform_device *dev)
1674{ 1665{
1675 VDBG("%s: state %x\n", __func__, dev->power.power_state.event); 1666 VDBG("%s\n", __func__);
1676 dev->dev.power.power_state = PMSG_ON;
1677 return 0; 1667 return 0;
1678} 1668}
1679 1669
diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index d72dc07dda0..c96db1153dc 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -261,7 +261,6 @@ static const struct hc_driver ohci_at91_hc_driver = {
261 */ 261 */
262 .hub_status_data = ohci_hub_status_data, 262 .hub_status_data = ohci_hub_status_data,
263 .hub_control = ohci_hub_control, 263 .hub_control = ohci_hub_control,
264 .hub_irq_enable = ohci_rhsc_enable,
265#ifdef CONFIG_PM 264#ifdef CONFIG_PM
266 .bus_suspend = ohci_bus_suspend, 265 .bus_suspend = ohci_bus_suspend,
267 .bus_resume = ohci_bus_resume, 266 .bus_resume = ohci_bus_resume,
@@ -348,6 +347,7 @@ static int ohci_hcd_at91_drv_resume(struct platform_device *pdev)
348 if (!clocked) 347 if (!clocked)
349 at91_start_clock(); 348 at91_start_clock();
350 349
350 ohci_finish_controller_resume(hcd);
351 return 0; 351 return 0;
352} 352}
353#else 353#else
diff --git a/drivers/usb/host/ohci-au1xxx.c b/drivers/usb/host/ohci-au1xxx.c
index f90fe0c7373..1b9abdba920 100644
--- a/drivers/usb/host/ohci-au1xxx.c
+++ b/drivers/usb/host/ohci-au1xxx.c
@@ -288,7 +288,6 @@ static const struct hc_driver ohci_au1xxx_hc_driver = {
288 */ 288 */
289 .hub_status_data = ohci_hub_status_data, 289 .hub_status_data = ohci_hub_status_data,
290 .hub_control = ohci_hub_control, 290 .hub_control = ohci_hub_control,
291 .hub_irq_enable = ohci_rhsc_enable,
292#ifdef CONFIG_PM 291#ifdef CONFIG_PM
293 .bus_suspend = ohci_bus_suspend, 292 .bus_suspend = ohci_bus_suspend,
294 .bus_resume = ohci_bus_resume, 293 .bus_resume = ohci_bus_resume,
diff --git a/drivers/usb/host/ohci-dbg.c b/drivers/usb/host/ohci-dbg.c
index a22c30aa745..e06bfaebec5 100644
--- a/drivers/usb/host/ohci-dbg.c
+++ b/drivers/usb/host/ohci-dbg.c
@@ -655,7 +655,7 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf)
655 hcd->product_desc, 655 hcd->product_desc,
656 hcd_name); 656 hcd_name);
657 657
658 if (bus->controller->power.power_state.event) { 658 if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) {
659 size -= scnprintf (next, size, 659 size -= scnprintf (next, size,
660 "SUSPENDED (no register access)\n"); 660 "SUSPENDED (no register access)\n");
661 goto done; 661 goto done;
diff --git a/drivers/usb/host/ohci-ep93xx.c b/drivers/usb/host/ohci-ep93xx.c
index 156e93a9d0d..06aadfb0ec2 100644
--- a/drivers/usb/host/ohci-ep93xx.c
+++ b/drivers/usb/host/ohci-ep93xx.c
@@ -135,7 +135,6 @@ static struct hc_driver ohci_ep93xx_hc_driver = {
135 .get_frame_number = ohci_get_frame, 135 .get_frame_number = ohci_get_frame,
136 .hub_status_data = ohci_hub_status_data, 136 .hub_status_data = ohci_hub_status_data,
137 .hub_control = ohci_hub_control, 137 .hub_control = ohci_hub_control,
138 .hub_irq_enable = ohci_rhsc_enable,
139#ifdef CONFIG_PM 138#ifdef CONFIG_PM
140 .bus_suspend = ohci_bus_suspend, 139 .bus_suspend = ohci_bus_suspend,
141 .bus_resume = ohci_bus_resume, 140 .bus_resume = ohci_bus_resume,
@@ -177,7 +176,6 @@ static int ohci_hcd_ep93xx_drv_suspend(struct platform_device *pdev, pm_message_
177 176
178 ep93xx_stop_hc(&pdev->dev); 177 ep93xx_stop_hc(&pdev->dev);
179 hcd->state = HC_STATE_SUSPENDED; 178 hcd->state = HC_STATE_SUSPENDED;
180 pdev->dev.power.power_state = PMSG_SUSPEND;
181 179
182 return 0; 180 return 0;
183} 181}
@@ -193,9 +191,8 @@ static int ohci_hcd_ep93xx_drv_resume(struct platform_device *pdev)
193 ohci->next_statechange = jiffies; 191 ohci->next_statechange = jiffies;
194 192
195 ep93xx_start_hc(&pdev->dev); 193 ep93xx_start_hc(&pdev->dev);
196 pdev->dev.power.power_state = PMSG_ON;
197 usb_hcd_resume_root_hub(hcd);
198 194
195 ohci_finish_controller_resume(hcd);
199 return 0; 196 return 0;
200} 197}
201#endif 198#endif
diff --git a/drivers/usb/host/ohci-hub.c b/drivers/usb/host/ohci-hub.c
index 48e4b11f4d3..5be3bb3e6a9 100644
--- a/drivers/usb/host/ohci-hub.c
+++ b/drivers/usb/host/ohci-hub.c
@@ -36,18 +36,6 @@
36 36
37/*-------------------------------------------------------------------------*/ 37/*-------------------------------------------------------------------------*/
38 38
39/* hcd->hub_irq_enable() */
40static void ohci_rhsc_enable (struct usb_hcd *hcd)
41{
42 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
43
44 spin_lock_irq(&ohci->lock);
45 if (!ohci->autostop)
46 del_timer(&hcd->rh_timer); /* Prevent next poll */
47 ohci_writel(ohci, OHCI_INTR_RHSC, &ohci->regs->intrenable);
48 spin_unlock_irq(&ohci->lock);
49}
50
51#define OHCI_SCHED_ENABLES \ 39#define OHCI_SCHED_ENABLES \
52 (OHCI_CTRL_CLE|OHCI_CTRL_BLE|OHCI_CTRL_PLE|OHCI_CTRL_IE) 40 (OHCI_CTRL_CLE|OHCI_CTRL_BLE|OHCI_CTRL_PLE|OHCI_CTRL_IE)
53 41
@@ -103,11 +91,11 @@ __acquires(ohci->lock)
103 finish_unlinks (ohci, ohci_frame_no(ohci)); 91 finish_unlinks (ohci, ohci_frame_no(ohci));
104 92
105 /* maybe resume can wake root hub */ 93 /* maybe resume can wake root hub */
106 if (device_may_wakeup(&ohci_to_hcd(ohci)->self.root_hub->dev) || 94 if (ohci_to_hcd(ohci)->self.root_hub->do_remote_wakeup || autostop) {
107 autostop)
108 ohci->hc_control |= OHCI_CTRL_RWE; 95 ohci->hc_control |= OHCI_CTRL_RWE;
109 else { 96 } else {
110 ohci_writel (ohci, OHCI_INTR_RHSC, &ohci->regs->intrdisable); 97 ohci_writel(ohci, OHCI_INTR_RHSC | OHCI_INTR_RD,
98 &ohci->regs->intrdisable);
111 ohci->hc_control &= ~OHCI_CTRL_RWE; 99 ohci->hc_control &= ~OHCI_CTRL_RWE;
112 } 100 }
113 101
@@ -326,23 +314,76 @@ static int ohci_bus_resume (struct usb_hcd *hcd)
326 return rc; 314 return rc;
327} 315}
328 316
317/* Carry out the final steps of resuming the controller device */
318static void ohci_finish_controller_resume(struct usb_hcd *hcd)
319{
320 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
321 int port;
322 bool need_reinit = false;
323
324 /* See if the controller is already running or has been reset */
325 ohci->hc_control = ohci_readl(ohci, &ohci->regs->control);
326 if (ohci->hc_control & (OHCI_CTRL_IR | OHCI_SCHED_ENABLES)) {
327 need_reinit = true;
328 } else {
329 switch (ohci->hc_control & OHCI_CTRL_HCFS) {
330 case OHCI_USB_OPER:
331 case OHCI_USB_RESET:
332 need_reinit = true;
333 }
334 }
335
336 /* If needed, reinitialize and suspend the root hub */
337 if (need_reinit) {
338 spin_lock_irq(&ohci->lock);
339 hcd->state = HC_STATE_RESUMING;
340 ohci_rh_resume(ohci);
341 hcd->state = HC_STATE_QUIESCING;
342 ohci_rh_suspend(ohci, 0);
343 hcd->state = HC_STATE_SUSPENDED;
344 spin_unlock_irq(&ohci->lock);
345 }
346
347 /* Normally just turn on port power and enable interrupts */
348 else {
349 ohci_dbg(ohci, "powerup ports\n");
350 for (port = 0; port < ohci->num_ports; port++)
351 ohci_writel(ohci, RH_PS_PPS,
352 &ohci->regs->roothub.portstatus[port]);
353
354 ohci_writel(ohci, OHCI_INTR_MIE, &ohci->regs->intrenable);
355 ohci_readl(ohci, &ohci->regs->intrenable);
356 msleep(20);
357 }
358}
359
329/* Carry out polling-, autostop-, and autoresume-related state changes */ 360/* Carry out polling-, autostop-, and autoresume-related state changes */
330static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed, 361static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed,
331 int any_connected) 362 int any_connected)
332{ 363{
333 int poll_rh = 1; 364 int poll_rh = 1;
365 int rhsc;
334 366
367 rhsc = ohci_readl(ohci, &ohci->regs->intrenable) & OHCI_INTR_RHSC;
335 switch (ohci->hc_control & OHCI_CTRL_HCFS) { 368 switch (ohci->hc_control & OHCI_CTRL_HCFS) {
336 369
337 case OHCI_USB_OPER: 370 case OHCI_USB_OPER:
338 /* keep on polling until we know a device is connected 371 /* If no status changes are pending, enable status-change
339 * and RHSC is enabled */ 372 * interrupts.
373 */
374 if (!rhsc && !changed) {
375 rhsc = OHCI_INTR_RHSC;
376 ohci_writel(ohci, rhsc, &ohci->regs->intrenable);
377 }
378
379 /* Keep on polling until we know a device is connected
380 * and RHSC is enabled, or until we autostop.
381 */
340 if (!ohci->autostop) { 382 if (!ohci->autostop) {
341 if (any_connected || 383 if (any_connected ||
342 !device_may_wakeup(&ohci_to_hcd(ohci) 384 !device_may_wakeup(&ohci_to_hcd(ohci)
343 ->self.root_hub->dev)) { 385 ->self.root_hub->dev)) {
344 if (ohci_readl(ohci, &ohci->regs->intrenable) & 386 if (rhsc)
345 OHCI_INTR_RHSC)
346 poll_rh = 0; 387 poll_rh = 0;
347 } else { 388 } else {
348 ohci->autostop = 1; 389 ohci->autostop = 1;
@@ -355,12 +396,13 @@ static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed,
355 ohci->autostop = 0; 396 ohci->autostop = 0;
356 ohci->next_statechange = jiffies + 397 ohci->next_statechange = jiffies +
357 STATECHANGE_DELAY; 398 STATECHANGE_DELAY;
358 } else if (time_after_eq(jiffies, 399 } else if (rhsc && time_after_eq(jiffies,
359 ohci->next_statechange) 400 ohci->next_statechange)
360 && !ohci->ed_rm_list 401 && !ohci->ed_rm_list
361 && !(ohci->hc_control & 402 && !(ohci->hc_control &
362 OHCI_SCHED_ENABLES)) { 403 OHCI_SCHED_ENABLES)) {
363 ohci_rh_suspend(ohci, 1); 404 ohci_rh_suspend(ohci, 1);
405 poll_rh = 0;
364 } 406 }
365 } 407 }
366 break; 408 break;
@@ -374,6 +416,12 @@ static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed,
374 else 416 else
375 usb_hcd_resume_root_hub(ohci_to_hcd(ohci)); 417 usb_hcd_resume_root_hub(ohci_to_hcd(ohci));
376 } else { 418 } else {
419 if (!rhsc && (ohci->autostop ||
420 ohci_to_hcd(ohci)->self.root_hub->
421 do_remote_wakeup))
422 ohci_writel(ohci, OHCI_INTR_RHSC,
423 &ohci->regs->intrenable);
424
377 /* everything is idle, no need for polling */ 425 /* everything is idle, no need for polling */
378 poll_rh = 0; 426 poll_rh = 0;
379 } 427 }
@@ -395,12 +443,16 @@ static inline int ohci_rh_resume(struct ohci_hcd *ohci)
395static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed, 443static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed,
396 int any_connected) 444 int any_connected)
397{ 445{
398 int poll_rh = 1; 446 /* If RHSC is enabled, don't poll */
399
400 /* keep on polling until RHSC is enabled */
401 if (ohci_readl(ohci, &ohci->regs->intrenable) & OHCI_INTR_RHSC) 447 if (ohci_readl(ohci, &ohci->regs->intrenable) & OHCI_INTR_RHSC)
402 poll_rh = 0; 448 return 0;
403 return poll_rh; 449
450 /* If no status changes are pending, enable status-change interrupts */
451 if (!changed) {
452 ohci_writel(ohci, OHCI_INTR_RHSC, &ohci->regs->intrenable);
453 return 0;
454 }
455 return 1;
404} 456}
405 457
406#endif /* CONFIG_PM */ 458#endif /* CONFIG_PM */
@@ -564,14 +616,18 @@ static inline int root_port_reset (struct ohci_hcd *ohci, unsigned port)
564 u32 temp; 616 u32 temp;
565 u16 now = ohci_readl(ohci, &ohci->regs->fmnumber); 617 u16 now = ohci_readl(ohci, &ohci->regs->fmnumber);
566 u16 reset_done = now + PORT_RESET_MSEC; 618 u16 reset_done = now + PORT_RESET_MSEC;
619 int limit_1 = DIV_ROUND_UP(PORT_RESET_MSEC, PORT_RESET_HW_MSEC);
567 620
568 /* build a "continuous enough" reset signal, with up to 621 /* build a "continuous enough" reset signal, with up to
569 * 3msec gap between pulses. scheduler HZ==100 must work; 622 * 3msec gap between pulses. scheduler HZ==100 must work;
570 * this might need to be deadline-scheduled. 623 * this might need to be deadline-scheduled.
571 */ 624 */
572 do { 625 do {
626 int limit_2;
627
573 /* spin until any current reset finishes */ 628 /* spin until any current reset finishes */
574 for (;;) { 629 limit_2 = PORT_RESET_HW_MSEC * 2;
630 while (--limit_2 >= 0) {
575 temp = ohci_readl (ohci, portstat); 631 temp = ohci_readl (ohci, portstat);
576 /* handle e.g. CardBus eject */ 632 /* handle e.g. CardBus eject */
577 if (temp == ~(u32)0) 633 if (temp == ~(u32)0)
@@ -581,6 +637,17 @@ static inline int root_port_reset (struct ohci_hcd *ohci, unsigned port)
581 udelay (500); 637 udelay (500);
582 } 638 }
583 639
640 /* timeout (a hardware error) has been observed when
641 * EHCI sets CF while this driver is resetting a port;
642 * presumably other disconnect paths might do it too.
643 */
644 if (limit_2 < 0) {
645 ohci_dbg(ohci,
646 "port[%d] reset timeout, stat %08x\n",
647 port, temp);
648 break;
649 }
650
584 if (!(temp & RH_PS_CCS)) 651 if (!(temp & RH_PS_CCS))
585 break; 652 break;
586 if (temp & RH_PS_PRSC) 653 if (temp & RH_PS_PRSC)
@@ -590,8 +657,11 @@ static inline int root_port_reset (struct ohci_hcd *ohci, unsigned port)
590 ohci_writel (ohci, RH_PS_PRS, portstat); 657 ohci_writel (ohci, RH_PS_PRS, portstat);
591 msleep(PORT_RESET_HW_MSEC); 658 msleep(PORT_RESET_HW_MSEC);
592 now = ohci_readl(ohci, &ohci->regs->fmnumber); 659 now = ohci_readl(ohci, &ohci->regs->fmnumber);
593 } while (tick_before(now, reset_done)); 660 } while (tick_before(now, reset_done) && --limit_1 >= 0);
594 /* caller synchronizes using PRSC */ 661
662 /* caller synchronizes using PRSC ... and handles PRS
663 * still being set when this returns.
664 */
595 665
596 return 0; 666 return 0;
597} 667}
diff --git a/drivers/usb/host/ohci-lh7a404.c b/drivers/usb/host/ohci-lh7a404.c
index 13c12ed2225..96d14fa1d83 100644
--- a/drivers/usb/host/ohci-lh7a404.c
+++ b/drivers/usb/host/ohci-lh7a404.c
@@ -193,7 +193,6 @@ static const struct hc_driver ohci_lh7a404_hc_driver = {
193 */ 193 */
194 .hub_status_data = ohci_hub_status_data, 194 .hub_status_data = ohci_hub_status_data,
195 .hub_control = ohci_hub_control, 195 .hub_control = ohci_hub_control,
196 .hub_irq_enable = ohci_rhsc_enable,
197#ifdef CONFIG_PM 196#ifdef CONFIG_PM
198 .bus_suspend = ohci_bus_suspend, 197 .bus_suspend = ohci_bus_suspend,
199 .bus_resume = ohci_bus_resume, 198 .bus_resume = ohci_bus_resume,
diff --git a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c
index 7bfca1ed1b5..6859fb5f1d6 100644
--- a/drivers/usb/host/ohci-omap.c
+++ b/drivers/usb/host/ohci-omap.c
@@ -466,7 +466,6 @@ static const struct hc_driver ohci_omap_hc_driver = {
466 */ 466 */
467 .hub_status_data = ohci_hub_status_data, 467 .hub_status_data = ohci_hub_status_data,
468 .hub_control = ohci_hub_control, 468 .hub_control = ohci_hub_control,
469 .hub_irq_enable = ohci_rhsc_enable,
470#ifdef CONFIG_PM 469#ifdef CONFIG_PM
471 .bus_suspend = ohci_bus_suspend, 470 .bus_suspend = ohci_bus_suspend,
472 .bus_resume = ohci_bus_resume, 471 .bus_resume = ohci_bus_resume,
@@ -505,21 +504,20 @@ static int ohci_omap_suspend(struct platform_device *dev, pm_message_t message)
505 504
506 omap_ohci_clock_power(0); 505 omap_ohci_clock_power(0);
507 ohci_to_hcd(ohci)->state = HC_STATE_SUSPENDED; 506 ohci_to_hcd(ohci)->state = HC_STATE_SUSPENDED;
508 dev->dev.power.power_state = PMSG_SUSPEND;
509 return 0; 507 return 0;
510} 508}
511 509
512static int ohci_omap_resume(struct platform_device *dev) 510static int ohci_omap_resume(struct platform_device *dev)
513{ 511{
514 struct ohci_hcd *ohci = hcd_to_ohci(platform_get_drvdata(dev)); 512 struct usb_hcd *hcd = platform_get_drvdata(dev);
513 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
515 514
516 if (time_before(jiffies, ohci->next_statechange)) 515 if (time_before(jiffies, ohci->next_statechange))
517 msleep(5); 516 msleep(5);
518 ohci->next_statechange = jiffies; 517 ohci->next_statechange = jiffies;
519 518
520 omap_ohci_clock_power(1); 519 omap_ohci_clock_power(1);
521 dev->dev.power.power_state = PMSG_ON; 520 ohci_finish_controller_resume(hcd);
522 usb_hcd_resume_root_hub(platform_get_drvdata(dev));
523 return 0; 521 return 0;
524} 522}
525 523
diff --git a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c
index d0360f65ebd..3bf175d95a2 100644
--- a/drivers/usb/host/ohci-pci.c
+++ b/drivers/usb/host/ohci-pci.c
@@ -238,42 +238,6 @@ static int __devinit ohci_pci_start (struct usb_hcd *hcd)
238 return ret; 238 return ret;
239} 239}
240 240
241#if defined(CONFIG_USB_PERSIST) && (defined(CONFIG_USB_EHCI_HCD) || \
242 defined(CONFIG_USB_EHCI_HCD_MODULE))
243
244/* Following a power loss, we must prepare to regain control of the ports
245 * we used to own. This means turning on the port power before ehci-hcd
246 * tries to switch ownership.
247 *
248 * This isn't a 100% perfect solution. On most systems the OHCI controllers
249 * lie at lower PCI addresses than the EHCI controller, so they will be
250 * discovered (and hence resumed) first. But there is no guarantee things
251 * will always work this way. If the EHCI controller is resumed first and
252 * the OHCI ports are unpowered, then the handover will fail.
253 */
254static void prepare_for_handover(struct usb_hcd *hcd)
255{
256 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
257 int port;
258
259 /* Here we "know" root ports should always stay powered */
260 ohci_dbg(ohci, "powerup ports\n");
261 for (port = 0; port < ohci->num_ports; port++)
262 ohci_writel(ohci, RH_PS_PPS,
263 &ohci->regs->roothub.portstatus[port]);
264
265 /* Flush those writes */
266 ohci_readl(ohci, &ohci->regs->control);
267 msleep(20);
268}
269
270#else
271
272static inline void prepare_for_handover(struct usb_hcd *hcd)
273{ }
274
275#endif /* CONFIG_USB_PERSIST etc. */
276
277#ifdef CONFIG_PM 241#ifdef CONFIG_PM
278 242
279static int ohci_pci_suspend (struct usb_hcd *hcd, pm_message_t message) 243static int ohci_pci_suspend (struct usb_hcd *hcd, pm_message_t message)
@@ -313,10 +277,7 @@ static int ohci_pci_suspend (struct usb_hcd *hcd, pm_message_t message)
313static int ohci_pci_resume (struct usb_hcd *hcd) 277static int ohci_pci_resume (struct usb_hcd *hcd)
314{ 278{
315 set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); 279 set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
316 280 ohci_finish_controller_resume(hcd);
317 /* FIXME: we should try to detect loss of VBUS power here */
318 prepare_for_handover(hcd);
319
320 return 0; 281 return 0;
321} 282}
322 283
@@ -345,9 +306,8 @@ static const struct hc_driver ohci_pci_hc_driver = {
345 .shutdown = ohci_shutdown, 306 .shutdown = ohci_shutdown,
346 307
347#ifdef CONFIG_PM 308#ifdef CONFIG_PM
348 /* these suspend/resume entries are for upstream PCI glue ONLY */ 309 .pci_suspend = ohci_pci_suspend,
349 .suspend = ohci_pci_suspend, 310 .pci_resume = ohci_pci_resume,
350 .resume = ohci_pci_resume,
351#endif 311#endif
352 312
353 /* 313 /*
@@ -367,7 +327,6 @@ static const struct hc_driver ohci_pci_hc_driver = {
367 */ 327 */
368 .hub_status_data = ohci_hub_status_data, 328 .hub_status_data = ohci_hub_status_data,
369 .hub_control = ohci_hub_control, 329 .hub_control = ohci_hub_control,
370 .hub_irq_enable = ohci_rhsc_enable,
371#ifdef CONFIG_PM 330#ifdef CONFIG_PM
372 .bus_suspend = ohci_bus_suspend, 331 .bus_suspend = ohci_bus_suspend,
373 .bus_resume = ohci_bus_resume, 332 .bus_resume = ohci_bus_resume,
diff --git a/drivers/usb/host/ohci-pnx4008.c b/drivers/usb/host/ohci-pnx4008.c
index 28b458f20cc..664f07ee873 100644
--- a/drivers/usb/host/ohci-pnx4008.c
+++ b/drivers/usb/host/ohci-pnx4008.c
@@ -280,7 +280,6 @@ static const struct hc_driver ohci_pnx4008_hc_driver = {
280 */ 280 */
281 .hub_status_data = ohci_hub_status_data, 281 .hub_status_data = ohci_hub_status_data,
282 .hub_control = ohci_hub_control, 282 .hub_control = ohci_hub_control,
283 .hub_irq_enable = ohci_rhsc_enable,
284#ifdef CONFIG_PM 283#ifdef CONFIG_PM
285 .bus_suspend = ohci_bus_suspend, 284 .bus_suspend = ohci_bus_suspend,
286 .bus_resume = ohci_bus_resume, 285 .bus_resume = ohci_bus_resume,
diff --git a/drivers/usb/host/ohci-pnx8550.c b/drivers/usb/host/ohci-pnx8550.c
index 605d59cba28..28467e288a9 100644
--- a/drivers/usb/host/ohci-pnx8550.c
+++ b/drivers/usb/host/ohci-pnx8550.c
@@ -201,7 +201,6 @@ static const struct hc_driver ohci_pnx8550_hc_driver = {
201 */ 201 */
202 .hub_status_data = ohci_hub_status_data, 202 .hub_status_data = ohci_hub_status_data,
203 .hub_control = ohci_hub_control, 203 .hub_control = ohci_hub_control,
204 .hub_irq_enable = ohci_rhsc_enable,
205#ifdef CONFIG_PM 204#ifdef CONFIG_PM
206 .bus_suspend = ohci_bus_suspend, 205 .bus_suspend = ohci_bus_suspend,
207 .bus_resume = ohci_bus_resume, 206 .bus_resume = ohci_bus_resume,
diff --git a/drivers/usb/host/ohci-ppc-of.c b/drivers/usb/host/ohci-ppc-of.c
index a6725279122..50e55db1363 100644
--- a/drivers/usb/host/ohci-ppc-of.c
+++ b/drivers/usb/host/ohci-ppc-of.c
@@ -72,7 +72,6 @@ static const struct hc_driver ohci_ppc_of_hc_driver = {
72 */ 72 */
73 .hub_status_data = ohci_hub_status_data, 73 .hub_status_data = ohci_hub_status_data,
74 .hub_control = ohci_hub_control, 74 .hub_control = ohci_hub_control,
75 .hub_irq_enable = ohci_rhsc_enable,
76#ifdef CONFIG_PM 75#ifdef CONFIG_PM
77 .bus_suspend = ohci_bus_suspend, 76 .bus_suspend = ohci_bus_suspend,
78 .bus_resume = ohci_bus_resume, 77 .bus_resume = ohci_bus_resume,
diff --git a/drivers/usb/host/ohci-ppc-soc.c b/drivers/usb/host/ohci-ppc-soc.c
index 523c3012557..cd3398b675b 100644
--- a/drivers/usb/host/ohci-ppc-soc.c
+++ b/drivers/usb/host/ohci-ppc-soc.c
@@ -172,7 +172,6 @@ static const struct hc_driver ohci_ppc_soc_hc_driver = {
172 */ 172 */
173 .hub_status_data = ohci_hub_status_data, 173 .hub_status_data = ohci_hub_status_data,
174 .hub_control = ohci_hub_control, 174 .hub_control = ohci_hub_control,
175 .hub_irq_enable = ohci_rhsc_enable,
176#ifdef CONFIG_PM 175#ifdef CONFIG_PM
177 .bus_suspend = ohci_bus_suspend, 176 .bus_suspend = ohci_bus_suspend,
178 .bus_resume = ohci_bus_resume, 177 .bus_resume = ohci_bus_resume,
diff --git a/drivers/usb/host/ohci-ps3.c b/drivers/usb/host/ohci-ps3.c
index 01a0caeaa6b..bfdeb0d22d0 100644
--- a/drivers/usb/host/ohci-ps3.c
+++ b/drivers/usb/host/ohci-ps3.c
@@ -68,7 +68,6 @@ static const struct hc_driver ps3_ohci_hc_driver = {
68 .get_frame_number = ohci_get_frame, 68 .get_frame_number = ohci_get_frame,
69 .hub_status_data = ohci_hub_status_data, 69 .hub_status_data = ohci_hub_status_data,
70 .hub_control = ohci_hub_control, 70 .hub_control = ohci_hub_control,
71 .hub_irq_enable = ohci_rhsc_enable,
72 .start_port_reset = ohci_start_port_reset, 71 .start_port_reset = ohci_start_port_reset,
73#if defined(CONFIG_PM) 72#if defined(CONFIG_PM)
74 .bus_suspend = ohci_bus_suspend, 73 .bus_suspend = ohci_bus_suspend,
@@ -127,7 +126,6 @@ static int ps3_ohci_probe(struct ps3_system_bus_device *dev)
127 goto fail_irq; 126 goto fail_irq;
128 } 127 }
129 128
130 dev->core.power.power_state = PMSG_ON;
131 dev->core.dma_mask = &dummy_mask; /* FIXME: for improper usb code */ 129 dev->core.dma_mask = &dummy_mask; /* FIXME: for improper usb code */
132 130
133 hcd = usb_create_hcd(&ps3_ohci_hc_driver, &dev->core, dev->core.bus_id); 131 hcd = usb_create_hcd(&ps3_ohci_hc_driver, &dev->core, dev->core.bus_id);
diff --git a/drivers/usb/host/ohci-pxa27x.c b/drivers/usb/host/ohci-pxa27x.c
index 8ad9b3b604b..70b0d4b459e 100644
--- a/drivers/usb/host/ohci-pxa27x.c
+++ b/drivers/usb/host/ohci-pxa27x.c
@@ -298,7 +298,6 @@ static const struct hc_driver ohci_pxa27x_hc_driver = {
298 */ 298 */
299 .hub_status_data = ohci_hub_status_data, 299 .hub_status_data = ohci_hub_status_data,
300 .hub_control = ohci_hub_control, 300 .hub_control = ohci_hub_control,
301 .hub_irq_enable = ohci_rhsc_enable,
302#ifdef CONFIG_PM 301#ifdef CONFIG_PM
303 .bus_suspend = ohci_bus_suspend, 302 .bus_suspend = ohci_bus_suspend,
304 .bus_resume = ohci_bus_resume, 303 .bus_resume = ohci_bus_resume,
@@ -339,7 +338,6 @@ static int ohci_hcd_pxa27x_drv_suspend(struct platform_device *pdev, pm_message_
339 338
340 pxa27x_stop_hc(&pdev->dev); 339 pxa27x_stop_hc(&pdev->dev);
341 hcd->state = HC_STATE_SUSPENDED; 340 hcd->state = HC_STATE_SUSPENDED;
342 pdev->dev.power.power_state = PMSG_SUSPEND;
343 341
344 return 0; 342 return 0;
345} 343}
@@ -357,9 +355,7 @@ static int ohci_hcd_pxa27x_drv_resume(struct platform_device *pdev)
357 if ((status = pxa27x_start_hc(&pdev->dev)) < 0) 355 if ((status = pxa27x_start_hc(&pdev->dev)) < 0)
358 return status; 356 return status;
359 357
360 pdev->dev.power.power_state = PMSG_ON; 358 ohci_finish_controller_resume(hcd);
361 usb_hcd_resume_root_hub(hcd);
362
363 return 0; 359 return 0;
364} 360}
365#endif 361#endif
diff --git a/drivers/usb/host/ohci-s3c2410.c b/drivers/usb/host/ohci-s3c2410.c
index ead4772f0f2..a73d2ff322e 100644
--- a/drivers/usb/host/ohci-s3c2410.c
+++ b/drivers/usb/host/ohci-s3c2410.c
@@ -466,7 +466,6 @@ static const struct hc_driver ohci_s3c2410_hc_driver = {
466 */ 466 */
467 .hub_status_data = ohci_s3c2410_hub_status_data, 467 .hub_status_data = ohci_s3c2410_hub_status_data,
468 .hub_control = ohci_s3c2410_hub_control, 468 .hub_control = ohci_s3c2410_hub_control,
469 .hub_irq_enable = ohci_rhsc_enable,
470#ifdef CONFIG_PM 469#ifdef CONFIG_PM
471 .bus_suspend = ohci_bus_suspend, 470 .bus_suspend = ohci_bus_suspend,
472 .bus_resume = ohci_bus_resume, 471 .bus_resume = ohci_bus_resume,
diff --git a/drivers/usb/host/ohci-sa1111.c b/drivers/usb/host/ohci-sa1111.c
index 0f48f2d9922..99438c65981 100644
--- a/drivers/usb/host/ohci-sa1111.c
+++ b/drivers/usb/host/ohci-sa1111.c
@@ -231,7 +231,6 @@ static const struct hc_driver ohci_sa1111_hc_driver = {
231 */ 231 */
232 .hub_status_data = ohci_hub_status_data, 232 .hub_status_data = ohci_hub_status_data,
233 .hub_control = ohci_hub_control, 233 .hub_control = ohci_hub_control,
234 .hub_irq_enable = ohci_rhsc_enable,
235#ifdef CONFIG_PM 234#ifdef CONFIG_PM
236 .bus_suspend = ohci_bus_suspend, 235 .bus_suspend = ohci_bus_suspend,
237 .bus_resume = ohci_bus_resume, 236 .bus_resume = ohci_bus_resume,
diff --git a/drivers/usb/host/ohci-sh.c b/drivers/usb/host/ohci-sh.c
index e7ee607278f..60f03cc7ec4 100644
--- a/drivers/usb/host/ohci-sh.c
+++ b/drivers/usb/host/ohci-sh.c
@@ -68,7 +68,6 @@ static const struct hc_driver ohci_sh_hc_driver = {
68 */ 68 */
69 .hub_status_data = ohci_hub_status_data, 69 .hub_status_data = ohci_hub_status_data,
70 .hub_control = ohci_hub_control, 70 .hub_control = ohci_hub_control,
71 .hub_irq_enable = ohci_rhsc_enable,
72#ifdef CONFIG_PM 71#ifdef CONFIG_PM
73 .bus_suspend = ohci_bus_suspend, 72 .bus_suspend = ohci_bus_suspend,
74 .bus_resume = ohci_bus_resume, 73 .bus_resume = ohci_bus_resume,
diff --git a/drivers/usb/host/ohci-sm501.c b/drivers/usb/host/ohci-sm501.c
index 4ea92762fb2..77204f001b9 100644
--- a/drivers/usb/host/ohci-sm501.c
+++ b/drivers/usb/host/ohci-sm501.c
@@ -75,7 +75,6 @@ static const struct hc_driver ohci_sm501_hc_driver = {
75 */ 75 */
76 .hub_status_data = ohci_hub_status_data, 76 .hub_status_data = ohci_hub_status_data,
77 .hub_control = ohci_hub_control, 77 .hub_control = ohci_hub_control,
78 .hub_irq_enable = ohci_rhsc_enable,
79#ifdef CONFIG_PM 78#ifdef CONFIG_PM
80 .bus_suspend = ohci_bus_suspend, 79 .bus_suspend = ohci_bus_suspend,
81 .bus_resume = ohci_bus_resume, 80 .bus_resume = ohci_bus_resume,
@@ -199,7 +198,8 @@ static int ohci_hcd_sm501_drv_remove(struct platform_device *pdev)
199 usb_put_hcd(hcd); 198 usb_put_hcd(hcd);
200 dma_release_declared_memory(&pdev->dev); 199 dma_release_declared_memory(&pdev->dev);
201 mem = platform_get_resource(pdev, IORESOURCE_MEM, 1); 200 mem = platform_get_resource(pdev, IORESOURCE_MEM, 1);
202 release_mem_region(mem->start, mem->end - mem->start + 1); 201 if (mem)
202 release_mem_region(mem->start, mem->end - mem->start + 1);
203 203
204 /* mask interrupts and disable power */ 204 /* mask interrupts and disable power */
205 205
@@ -224,24 +224,26 @@ static int ohci_sm501_suspend(struct platform_device *pdev, pm_message_t msg)
224 224
225 sm501_unit_power(dev->parent, SM501_GATE_USB_HOST, 0); 225 sm501_unit_power(dev->parent, SM501_GATE_USB_HOST, 0);
226 ohci_to_hcd(ohci)->state = HC_STATE_SUSPENDED; 226 ohci_to_hcd(ohci)->state = HC_STATE_SUSPENDED;
227 dev->power.power_state = PMSG_SUSPEND;
228 return 0; 227 return 0;
229} 228}
230 229
231static int ohci_sm501_resume(struct platform_device *pdev) 230static int ohci_sm501_resume(struct platform_device *pdev)
232{ 231{
233 struct device *dev = &pdev->dev; 232 struct device *dev = &pdev->dev;
234 struct ohci_hcd *ohci = hcd_to_ohci(platform_get_drvdata(pdev)); 233 struct usb_hcd *hcd = platform_get_drvdata(pdev);
234 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
235 235
236 if (time_before(jiffies, ohci->next_statechange)) 236 if (time_before(jiffies, ohci->next_statechange))
237 msleep(5); 237 msleep(5);
238 ohci->next_statechange = jiffies; 238 ohci->next_statechange = jiffies;
239 239
240 sm501_unit_power(dev->parent, SM501_GATE_USB_HOST, 1); 240 sm501_unit_power(dev->parent, SM501_GATE_USB_HOST, 1);
241 dev->power.power_state = PMSG_ON; 241 ohci_finish_controller_resume(hcd);
242 usb_hcd_resume_root_hub(platform_get_drvdata(pdev));
243 return 0; 242 return 0;
244} 243}
244#else
245#define ohci_sm501_suspend NULL
246#define ohci_sm501_resume NULL
245#endif 247#endif
246 248
247/*-------------------------------------------------------------------------*/ 249/*-------------------------------------------------------------------------*/
@@ -253,10 +255,8 @@ static struct platform_driver ohci_hcd_sm501_driver = {
253 .probe = ohci_hcd_sm501_drv_probe, 255 .probe = ohci_hcd_sm501_drv_probe,
254 .remove = ohci_hcd_sm501_drv_remove, 256 .remove = ohci_hcd_sm501_drv_remove,
255 .shutdown = usb_hcd_platform_shutdown, 257 .shutdown = usb_hcd_platform_shutdown,
256#ifdef CONFIG_PM
257 .suspend = ohci_sm501_suspend, 258 .suspend = ohci_sm501_suspend,
258 .resume = ohci_sm501_resume, 259 .resume = ohci_sm501_resume,
259#endif
260 .driver = { 260 .driver = {
261 .owner = THIS_MODULE, 261 .owner = THIS_MODULE,
262 .name = "sm501-usb", 262 .name = "sm501-usb",
diff --git a/drivers/usb/host/ohci-ssb.c b/drivers/usb/host/ohci-ssb.c
index 6e9c2d6db88..c4265caec78 100644
--- a/drivers/usb/host/ohci-ssb.c
+++ b/drivers/usb/host/ohci-ssb.c
@@ -60,36 +60,6 @@ static int ssb_ohci_start(struct usb_hcd *hcd)
60 return err; 60 return err;
61} 61}
62 62
63#ifdef CONFIG_PM
64static int ssb_ohci_hcd_suspend(struct usb_hcd *hcd, pm_message_t message)
65{
66 struct ssb_ohci_device *ohcidev = hcd_to_ssb_ohci(hcd);
67 struct ohci_hcd *ohci = &ohcidev->ohci;
68 unsigned long flags;
69
70 spin_lock_irqsave(&ohci->lock, flags);
71
72 ohci_writel(ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable);
73 ohci_readl(ohci, &ohci->regs->intrdisable); /* commit write */
74
75 /* make sure snapshot being resumed re-enumerates everything */
76 if (message.event == PM_EVENT_PRETHAW)
77 ohci_usb_reset(ohci);
78
79 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
80
81 spin_unlock_irqrestore(&ohci->lock, flags);
82 return 0;
83}
84
85static int ssb_ohci_hcd_resume(struct usb_hcd *hcd)
86{
87 set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
88 usb_hcd_resume_root_hub(hcd);
89 return 0;
90}
91#endif /* CONFIG_PM */
92
93static const struct hc_driver ssb_ohci_hc_driver = { 63static const struct hc_driver ssb_ohci_hc_driver = {
94 .description = "ssb-usb-ohci", 64 .description = "ssb-usb-ohci",
95 .product_desc = "SSB OHCI Controller", 65 .product_desc = "SSB OHCI Controller",
@@ -103,11 +73,6 @@ static const struct hc_driver ssb_ohci_hc_driver = {
103 .stop = ohci_stop, 73 .stop = ohci_stop,
104 .shutdown = ohci_shutdown, 74 .shutdown = ohci_shutdown,
105 75
106#ifdef CONFIG_PM
107 .suspend = ssb_ohci_hcd_suspend,
108 .resume = ssb_ohci_hcd_resume,
109#endif
110
111 .urb_enqueue = ohci_urb_enqueue, 76 .urb_enqueue = ohci_urb_enqueue,
112 .urb_dequeue = ohci_urb_dequeue, 77 .urb_dequeue = ohci_urb_dequeue,
113 .endpoint_disable = ohci_endpoint_disable, 78 .endpoint_disable = ohci_endpoint_disable,
@@ -116,7 +81,6 @@ static const struct hc_driver ssb_ohci_hc_driver = {
116 81
117 .hub_status_data = ohci_hub_status_data, 82 .hub_status_data = ohci_hub_status_data,
118 .hub_control = ohci_hub_control, 83 .hub_control = ohci_hub_control,
119 .hub_irq_enable = ohci_rhsc_enable,
120#ifdef CONFIG_PM 84#ifdef CONFIG_PM
121 .bus_suspend = ohci_bus_suspend, 85 .bus_suspend = ohci_bus_suspend,
122 .bus_resume = ohci_bus_resume, 86 .bus_resume = ohci_bus_resume,
@@ -224,6 +188,7 @@ static int ssb_ohci_resume(struct ssb_device *dev)
224 188
225 ssb_device_enable(dev, ohcidev->enable_flags); 189 ssb_device_enable(dev, ohcidev->enable_flags);
226 190
191 ohci_finish_controller_resume(hcd);
227 return 0; 192 return 0;
228} 193}
229 194
diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c
index 0ee694f043c..ae6e70edd74 100644
--- a/drivers/usb/host/pci-quirks.c
+++ b/drivers/usb/host/pci-quirks.c
@@ -106,7 +106,7 @@ int uhci_check_and_reset_hc(struct pci_dev *pdev, unsigned long base)
106 pci_read_config_word(pdev, UHCI_USBLEGSUP, &legsup); 106 pci_read_config_word(pdev, UHCI_USBLEGSUP, &legsup);
107 if (legsup & ~(UHCI_USBLEGSUP_RO | UHCI_USBLEGSUP_RWC)) { 107 if (legsup & ~(UHCI_USBLEGSUP_RO | UHCI_USBLEGSUP_RWC)) {
108 dev_dbg(&pdev->dev, "%s: legsup = 0x%04x\n", 108 dev_dbg(&pdev->dev, "%s: legsup = 0x%04x\n",
109 __FUNCTION__, legsup); 109 __func__, legsup);
110 goto reset_needed; 110 goto reset_needed;
111 } 111 }
112 112
@@ -114,14 +114,14 @@ int uhci_check_and_reset_hc(struct pci_dev *pdev, unsigned long base)
114 if ((cmd & UHCI_USBCMD_RUN) || !(cmd & UHCI_USBCMD_CONFIGURE) || 114 if ((cmd & UHCI_USBCMD_RUN) || !(cmd & UHCI_USBCMD_CONFIGURE) ||
115 !(cmd & UHCI_USBCMD_EGSM)) { 115 !(cmd & UHCI_USBCMD_EGSM)) {
116 dev_dbg(&pdev->dev, "%s: cmd = 0x%04x\n", 116 dev_dbg(&pdev->dev, "%s: cmd = 0x%04x\n",
117 __FUNCTION__, cmd); 117 __func__, cmd);
118 goto reset_needed; 118 goto reset_needed;
119 } 119 }
120 120
121 intr = inw(base + UHCI_USBINTR); 121 intr = inw(base + UHCI_USBINTR);
122 if (intr & (~UHCI_USBINTR_RESUME)) { 122 if (intr & (~UHCI_USBINTR_RESUME)) {
123 dev_dbg(&pdev->dev, "%s: intr = 0x%04x\n", 123 dev_dbg(&pdev->dev, "%s: intr = 0x%04x\n",
124 __FUNCTION__, intr); 124 __func__, intr);
125 goto reset_needed; 125 goto reset_needed;
126 } 126 }
127 return 0; 127 return 0;
diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c
index 9f80e528557..f4fa93dabdd 100644
--- a/drivers/usb/host/r8a66597-hcd.c
+++ b/drivers/usb/host/r8a66597-hcd.c
@@ -46,15 +46,17 @@ MODULE_LICENSE("GPL");
46MODULE_AUTHOR("Yoshihiro Shimoda"); 46MODULE_AUTHOR("Yoshihiro Shimoda");
47MODULE_ALIAS("platform:r8a66597_hcd"); 47MODULE_ALIAS("platform:r8a66597_hcd");
48 48
49#define DRIVER_VERSION "29 May 2007" 49#define DRIVER_VERSION "10 Apr 2008"
50 50
51static const char hcd_name[] = "r8a66597_hcd"; 51static const char hcd_name[] = "r8a66597_hcd";
52 52
53/* module parameters */ 53/* module parameters */
54#if !defined(CONFIG_SUPERH_ON_CHIP_R8A66597)
54static unsigned short clock = XTAL12; 55static unsigned short clock = XTAL12;
55module_param(clock, ushort, 0644); 56module_param(clock, ushort, 0644);
56MODULE_PARM_DESC(clock, "input clock: 48MHz=32768, 24MHz=16384, 12MHz=0 " 57MODULE_PARM_DESC(clock, "input clock: 48MHz=32768, 24MHz=16384, 12MHz=0 "
57 "(default=0)"); 58 "(default=0)");
59#endif
58 60
59static unsigned short vif = LDRV; 61static unsigned short vif = LDRV;
60module_param(vif, ushort, 0644); 62module_param(vif, ushort, 0644);
@@ -106,11 +108,22 @@ static void set_devadd_reg(struct r8a66597 *r8a66597, u8 r8a66597_address,
106 r8a66597_write(r8a66597, val, devadd_reg); 108 r8a66597_write(r8a66597, val, devadd_reg);
107} 109}
108 110
109static int enable_controller(struct r8a66597 *r8a66597) 111static int r8a66597_clock_enable(struct r8a66597 *r8a66597)
110{ 112{
111 u16 tmp; 113 u16 tmp;
112 int i = 0; 114 int i = 0;
113 115
116#if defined(CONFIG_SUPERH_ON_CHIP_R8A66597)
117 do {
118 r8a66597_write(r8a66597, SCKE, SYSCFG0);
119 tmp = r8a66597_read(r8a66597, SYSCFG0);
120 if (i++ > 1000) {
121 err("register access fail.");
122 return -ENXIO;
123 }
124 } while ((tmp & SCKE) != SCKE);
125 r8a66597_write(r8a66597, 0x04, 0x02);
126#else
114 do { 127 do {
115 r8a66597_write(r8a66597, USBE, SYSCFG0); 128 r8a66597_write(r8a66597, USBE, SYSCFG0);
116 tmp = r8a66597_read(r8a66597, SYSCFG0); 129 tmp = r8a66597_read(r8a66597, SYSCFG0);
@@ -132,13 +145,63 @@ static int enable_controller(struct r8a66597 *r8a66597)
132 return -ENXIO; 145 return -ENXIO;
133 } 146 }
134 } while ((tmp & SCKE) != SCKE); 147 } while ((tmp & SCKE) != SCKE);
148#endif /* #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) */
149
150 return 0;
151}
152
153static void r8a66597_clock_disable(struct r8a66597 *r8a66597)
154{
155 r8a66597_bclr(r8a66597, SCKE, SYSCFG0);
156 udelay(1);
157#if !defined(CONFIG_SUPERH_ON_CHIP_R8A66597)
158 r8a66597_bclr(r8a66597, PLLC, SYSCFG0);
159 r8a66597_bclr(r8a66597, XCKE, SYSCFG0);
160 r8a66597_bclr(r8a66597, USBE, SYSCFG0);
161#endif
162}
163
164static void r8a66597_enable_port(struct r8a66597 *r8a66597, int port)
165{
166 u16 val;
167
168 val = port ? DRPD : DCFM | DRPD;
169 r8a66597_bset(r8a66597, val, get_syscfg_reg(port));
170 r8a66597_bset(r8a66597, HSE, get_syscfg_reg(port));
171
172 r8a66597_write(r8a66597, BURST | CPU_ADR_RD_WR, get_dmacfg_reg(port));
173 r8a66597_bclr(r8a66597, DTCHE, get_intenb_reg(port));
174 r8a66597_bset(r8a66597, ATTCHE, get_intenb_reg(port));
175}
135 176
136 r8a66597_bset(r8a66597, DCFM | DRPD, SYSCFG0); 177static void r8a66597_disable_port(struct r8a66597 *r8a66597, int port)
137 r8a66597_bset(r8a66597, DRPD, SYSCFG1); 178{
179 u16 val, tmp;
180
181 r8a66597_write(r8a66597, 0, get_intenb_reg(port));
182 r8a66597_write(r8a66597, 0, get_intsts_reg(port));
183
184 r8a66597_port_power(r8a66597, port, 0);
185
186 do {
187 tmp = r8a66597_read(r8a66597, SOFCFG) & EDGESTS;
188 udelay(640);
189 } while (tmp == EDGESTS);
190
191 val = port ? DRPD : DCFM | DRPD;
192 r8a66597_bclr(r8a66597, val, get_syscfg_reg(port));
193 r8a66597_bclr(r8a66597, HSE, get_syscfg_reg(port));
194}
195
196static int enable_controller(struct r8a66597 *r8a66597)
197{
198 int ret, port;
199
200 ret = r8a66597_clock_enable(r8a66597);
201 if (ret < 0)
202 return ret;
138 203
139 r8a66597_bset(r8a66597, vif & LDRV, PINCFG); 204 r8a66597_bset(r8a66597, vif & LDRV, PINCFG);
140 r8a66597_bset(r8a66597, HSE, SYSCFG0);
141 r8a66597_bset(r8a66597, HSE, SYSCFG1);
142 r8a66597_bset(r8a66597, USBE, SYSCFG0); 205 r8a66597_bset(r8a66597, USBE, SYSCFG0);
143 206
144 r8a66597_bset(r8a66597, BEMPE | NRDYE | BRDYE, INTENB0); 207 r8a66597_bset(r8a66597, BEMPE | NRDYE | BRDYE, INTENB0);
@@ -146,53 +209,30 @@ static int enable_controller(struct r8a66597 *r8a66597)
146 r8a66597_bset(r8a66597, BRDY0, BRDYENB); 209 r8a66597_bset(r8a66597, BRDY0, BRDYENB);
147 r8a66597_bset(r8a66597, BEMP0, BEMPENB); 210 r8a66597_bset(r8a66597, BEMP0, BEMPENB);
148 211
149 r8a66597_write(r8a66597, BURST | CPU_ADR_RD_WR, DMA0CFG);
150 r8a66597_write(r8a66597, BURST | CPU_ADR_RD_WR, DMA1CFG);
151
152 r8a66597_bset(r8a66597, endian & BIGEND, CFIFOSEL); 212 r8a66597_bset(r8a66597, endian & BIGEND, CFIFOSEL);
153 r8a66597_bset(r8a66597, endian & BIGEND, D0FIFOSEL); 213 r8a66597_bset(r8a66597, endian & BIGEND, D0FIFOSEL);
154 r8a66597_bset(r8a66597, endian & BIGEND, D1FIFOSEL); 214 r8a66597_bset(r8a66597, endian & BIGEND, D1FIFOSEL);
155
156 r8a66597_bset(r8a66597, TRNENSEL, SOFCFG); 215 r8a66597_bset(r8a66597, TRNENSEL, SOFCFG);
157 216
158 r8a66597_bset(r8a66597, SIGNE | SACKE, INTENB1); 217 r8a66597_bset(r8a66597, SIGNE | SACKE, INTENB1);
159 r8a66597_bclr(r8a66597, DTCHE, INTENB1); 218
160 r8a66597_bset(r8a66597, ATTCHE, INTENB1); 219 for (port = 0; port < R8A66597_MAX_ROOT_HUB; port++)
161 r8a66597_bclr(r8a66597, DTCHE, INTENB2); 220 r8a66597_enable_port(r8a66597, port);
162 r8a66597_bset(r8a66597, ATTCHE, INTENB2);
163 221
164 return 0; 222 return 0;
165} 223}
166 224
167static void disable_controller(struct r8a66597 *r8a66597) 225static void disable_controller(struct r8a66597 *r8a66597)
168{ 226{
169 u16 tmp; 227 int port;
170 228
171 r8a66597_write(r8a66597, 0, INTENB0); 229 r8a66597_write(r8a66597, 0, INTENB0);
172 r8a66597_write(r8a66597, 0, INTENB1);
173 r8a66597_write(r8a66597, 0, INTENB2);
174 r8a66597_write(r8a66597, 0, INTSTS0); 230 r8a66597_write(r8a66597, 0, INTSTS0);
175 r8a66597_write(r8a66597, 0, INTSTS1);
176 r8a66597_write(r8a66597, 0, INTSTS2);
177
178 r8a66597_port_power(r8a66597, 0, 0);
179 r8a66597_port_power(r8a66597, 1, 0);
180
181 do {
182 tmp = r8a66597_read(r8a66597, SOFCFG) & EDGESTS;
183 udelay(640);
184 } while (tmp == EDGESTS);
185 231
186 r8a66597_bclr(r8a66597, DCFM | DRPD, SYSCFG0); 232 for (port = 0; port < R8A66597_MAX_ROOT_HUB; port++)
187 r8a66597_bclr(r8a66597, DRPD, SYSCFG1); 233 r8a66597_disable_port(r8a66597, port);
188 r8a66597_bclr(r8a66597, HSE, SYSCFG0);
189 r8a66597_bclr(r8a66597, HSE, SYSCFG1);
190 234
191 r8a66597_bclr(r8a66597, SCKE, SYSCFG0); 235 r8a66597_clock_disable(r8a66597);
192 udelay(1);
193 r8a66597_bclr(r8a66597, PLLC, SYSCFG0);
194 r8a66597_bclr(r8a66597, XCKE, SYSCFG0);
195 r8a66597_bclr(r8a66597, USBE, SYSCFG0);
196} 236}
197 237
198static int get_parent_r8a66597_address(struct r8a66597 *r8a66597, 238static int get_parent_r8a66597_address(struct r8a66597 *r8a66597,
@@ -577,13 +617,9 @@ static void pipe_buffer_setting(struct r8a66597 *r8a66597,
577 PIPEBUF); 617 PIPEBUF);
578 r8a66597_write(r8a66597, make_devsel(info->address) | info->maxpacket, 618 r8a66597_write(r8a66597, make_devsel(info->address) | info->maxpacket,
579 PIPEMAXP); 619 PIPEMAXP);
580 if (info->interval)
581 info->interval--;
582 r8a66597_write(r8a66597, info->interval, PIPEPERI); 620 r8a66597_write(r8a66597, info->interval, PIPEPERI);
583} 621}
584 622
585
586
587/* this function must be called with interrupt disabled */ 623/* this function must be called with interrupt disabled */
588static void pipe_setting(struct r8a66597 *r8a66597, struct r8a66597_td *td) 624static void pipe_setting(struct r8a66597 *r8a66597, struct r8a66597_td *td)
589{ 625{
@@ -715,6 +751,7 @@ static void enable_r8a66597_pipe_dma(struct r8a66597 *r8a66597,
715 struct r8a66597_pipe *pipe, 751 struct r8a66597_pipe *pipe,
716 struct urb *urb) 752 struct urb *urb)
717{ 753{
754#if !defined(CONFIG_SUPERH_ON_CHIP_R8A66597)
718 int i; 755 int i;
719 struct r8a66597_pipe_info *info = &pipe->info; 756 struct r8a66597_pipe_info *info = &pipe->info;
720 757
@@ -742,6 +779,7 @@ static void enable_r8a66597_pipe_dma(struct r8a66597 *r8a66597,
742 break; 779 break;
743 } 780 }
744 } 781 }
782#endif /* #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) */
745} 783}
746 784
747/* this function must be called with interrupt disabled */ 785/* this function must be called with interrupt disabled */
@@ -825,6 +863,25 @@ static void disable_r8a66597_pipe_all(struct r8a66597 *r8a66597,
825 dev->dma_map = 0; 863 dev->dma_map = 0;
826} 864}
827 865
866static unsigned long get_timer_interval(struct urb *urb, __u8 interval)
867{
868 __u8 i;
869 unsigned long time = 1;
870
871 if (usb_pipeisoc(urb->pipe))
872 return 0;
873
874 if (get_r8a66597_usb_speed(urb->dev->speed) == HSMODE) {
875 for (i = 0; i < (interval - 1); i++)
876 time *= 2;
877 time = time * 125 / 1000; /* uSOF -> msec */
878 } else {
879 time = interval;
880 }
881
882 return time;
883}
884
828/* this function must be called with interrupt disabled */ 885/* this function must be called with interrupt disabled */
829static void init_pipe_info(struct r8a66597 *r8a66597, struct urb *urb, 886static void init_pipe_info(struct r8a66597 *r8a66597, struct urb *urb,
830 struct usb_host_endpoint *hep, 887 struct usb_host_endpoint *hep,
@@ -840,7 +897,16 @@ static void init_pipe_info(struct r8a66597 *r8a66597, struct urb *urb,
840 & USB_ENDPOINT_XFERTYPE_MASK); 897 & USB_ENDPOINT_XFERTYPE_MASK);
841 info.bufnum = get_bufnum(info.pipenum); 898 info.bufnum = get_bufnum(info.pipenum);
842 info.buf_bsize = get_buf_bsize(info.pipenum); 899 info.buf_bsize = get_buf_bsize(info.pipenum);
843 info.interval = ep->bInterval; 900 if (info.type == R8A66597_BULK) {
901 info.interval = 0;
902 info.timer_interval = 0;
903 } else {
904 if (ep->bInterval > IITV)
905 info.interval = IITV;
906 else
907 info.interval = ep->bInterval ? ep->bInterval - 1 : 0;
908 info.timer_interval = get_timer_interval(urb, ep->bInterval);
909 }
844 if (ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK) 910 if (ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK)
845 info.dir_in = 1; 911 info.dir_in = 1;
846 else 912 else
@@ -876,10 +942,19 @@ static void pipe_irq_disable(struct r8a66597 *r8a66597, u16 pipenum)
876} 942}
877 943
878/* this function must be called with interrupt disabled */ 944/* this function must be called with interrupt disabled */
879static void r8a66597_usb_preconnect(struct r8a66597 *r8a66597, int port) 945static void r8a66597_check_syssts(struct r8a66597 *r8a66597, int port,
946 u16 syssts)
880{ 947{
881 r8a66597->root_hub[port].port |= (1 << USB_PORT_FEAT_CONNECTION) 948 if (syssts == SE0) {
882 | (1 << USB_PORT_FEAT_C_CONNECTION); 949 r8a66597_bset(r8a66597, ATTCHE, get_intenb_reg(port));
950 return;
951 }
952
953 if (syssts == FS_JSTS)
954 r8a66597_bset(r8a66597, HSE, get_syscfg_reg(port));
955 else if (syssts == LS_JSTS)
956 r8a66597_bclr(r8a66597, HSE, get_syscfg_reg(port));
957
883 r8a66597_write(r8a66597, ~DTCH, get_intsts_reg(port)); 958 r8a66597_write(r8a66597, ~DTCH, get_intsts_reg(port));
884 r8a66597_bset(r8a66597, DTCHE, get_intenb_reg(port)); 959 r8a66597_bset(r8a66597, DTCHE, get_intenb_reg(port));
885} 960}
@@ -960,9 +1035,9 @@ static void prepare_packet_read(struct r8a66597 *r8a66597,
960 r8a66597_write(r8a66597, TRCLR, 1035 r8a66597_write(r8a66597, TRCLR,
961 td->pipe->pipetre); 1036 td->pipe->pipetre);
962 r8a66597_write(r8a66597, 1037 r8a66597_write(r8a66597,
963 (urb->transfer_buffer_length 1038 DIV_ROUND_UP
964 + td->maxpacket - 1) 1039 (urb->transfer_buffer_length,
965 / td->maxpacket, 1040 td->maxpacket),
966 td->pipe->pipetrn); 1041 td->pipe->pipetrn);
967 r8a66597_bset(r8a66597, TRENB, 1042 r8a66597_bset(r8a66597, TRENB,
968 td->pipe->pipetre); 1043 td->pipe->pipetre);
@@ -1021,8 +1096,7 @@ static void prepare_status_packet(struct r8a66597 *r8a66597,
1021 r8a66597_mdfy(r8a66597, ISEL, ISEL | CURPIPE, CFIFOSEL); 1096 r8a66597_mdfy(r8a66597, ISEL, ISEL | CURPIPE, CFIFOSEL);
1022 r8a66597_reg_wait(r8a66597, CFIFOSEL, CURPIPE, 0); 1097 r8a66597_reg_wait(r8a66597, CFIFOSEL, CURPIPE, 0);
1023 r8a66597_write(r8a66597, ~BEMP0, BEMPSTS); 1098 r8a66597_write(r8a66597, ~BEMP0, BEMPSTS);
1024 r8a66597_write(r8a66597, BCLR, CFIFOCTR); 1099 r8a66597_write(r8a66597, BCLR | BVAL, CFIFOCTR);
1025 r8a66597_write(r8a66597, BVAL, CFIFOCTR);
1026 enable_irq_empty(r8a66597, 0); 1100 enable_irq_empty(r8a66597, 0);
1027 } else { 1101 } else {
1028 r8a66597_bclr(r8a66597, R8A66597_DIR, DCPCFG); 1102 r8a66597_bclr(r8a66597, R8A66597_DIR, DCPCFG);
@@ -1454,13 +1528,21 @@ static void irq_pipe_nrdy(struct r8a66597 *r8a66597)
1454 } 1528 }
1455} 1529}
1456 1530
1531static void r8a66597_root_hub_start_polling(struct r8a66597 *r8a66597)
1532{
1533 mod_timer(&r8a66597->rh_timer,
1534 jiffies + msecs_to_jiffies(R8A66597_RH_POLL_TIME));
1535}
1536
1457static void start_root_hub_sampling(struct r8a66597 *r8a66597, int port) 1537static void start_root_hub_sampling(struct r8a66597 *r8a66597, int port)
1458{ 1538{
1459 struct r8a66597_root_hub *rh = &r8a66597->root_hub[port]; 1539 struct r8a66597_root_hub *rh = &r8a66597->root_hub[port];
1460 1540
1461 rh->old_syssts = r8a66597_read(r8a66597, get_syssts_reg(port)) & LNST; 1541 rh->old_syssts = r8a66597_read(r8a66597, get_syssts_reg(port)) & LNST;
1462 rh->scount = R8A66597_MAX_SAMPLING; 1542 rh->scount = R8A66597_MAX_SAMPLING;
1463 mod_timer(&r8a66597->rh_timer, jiffies + msecs_to_jiffies(50)); 1543 r8a66597->root_hub[port].port |= (1 << USB_PORT_FEAT_CONNECTION)
1544 | (1 << USB_PORT_FEAT_C_CONNECTION);
1545 r8a66597_root_hub_start_polling(r8a66597);
1464} 1546}
1465 1547
1466static irqreturn_t r8a66597_irq(struct usb_hcd *hcd) 1548static irqreturn_t r8a66597_irq(struct usb_hcd *hcd)
@@ -1547,41 +1629,55 @@ static void r8a66597_root_hub_control(struct r8a66597 *r8a66597, int port)
1547 if ((tmp & USBRST) == USBRST) { 1629 if ((tmp & USBRST) == USBRST) {
1548 r8a66597_mdfy(r8a66597, UACT, USBRST | UACT, 1630 r8a66597_mdfy(r8a66597, UACT, USBRST | UACT,
1549 dvstctr_reg); 1631 dvstctr_reg);
1550 mod_timer(&r8a66597->rh_timer, 1632 r8a66597_root_hub_start_polling(r8a66597);
1551 jiffies + msecs_to_jiffies(50));
1552 } else 1633 } else
1553 r8a66597_usb_connect(r8a66597, port); 1634 r8a66597_usb_connect(r8a66597, port);
1554 } 1635 }
1555 1636
1637 if (!(rh->port & (1 << USB_PORT_FEAT_CONNECTION))) {
1638 r8a66597_write(r8a66597, ~ATTCH, get_intsts_reg(port));
1639 r8a66597_bset(r8a66597, ATTCHE, get_intenb_reg(port));
1640 }
1641
1556 if (rh->scount > 0) { 1642 if (rh->scount > 0) {
1557 tmp = r8a66597_read(r8a66597, get_syssts_reg(port)) & LNST; 1643 tmp = r8a66597_read(r8a66597, get_syssts_reg(port)) & LNST;
1558 if (tmp == rh->old_syssts) { 1644 if (tmp == rh->old_syssts) {
1559 rh->scount--; 1645 rh->scount--;
1560 if (rh->scount == 0) { 1646 if (rh->scount == 0)
1561 if (tmp == FS_JSTS) { 1647 r8a66597_check_syssts(r8a66597, port, tmp);
1562 r8a66597_bset(r8a66597, HSE, 1648 else
1563 get_syscfg_reg(port)); 1649 r8a66597_root_hub_start_polling(r8a66597);
1564 r8a66597_usb_preconnect(r8a66597, port);
1565 } else if (tmp == LS_JSTS) {
1566 r8a66597_bclr(r8a66597, HSE,
1567 get_syscfg_reg(port));
1568 r8a66597_usb_preconnect(r8a66597, port);
1569 } else if (tmp == SE0)
1570 r8a66597_bset(r8a66597, ATTCHE,
1571 get_intenb_reg(port));
1572 } else {
1573 mod_timer(&r8a66597->rh_timer,
1574 jiffies + msecs_to_jiffies(50));
1575 }
1576 } else { 1650 } else {
1577 rh->scount = R8A66597_MAX_SAMPLING; 1651 rh->scount = R8A66597_MAX_SAMPLING;
1578 rh->old_syssts = tmp; 1652 rh->old_syssts = tmp;
1579 mod_timer(&r8a66597->rh_timer, 1653 r8a66597_root_hub_start_polling(r8a66597);
1580 jiffies + msecs_to_jiffies(50));
1581 } 1654 }
1582 } 1655 }
1583} 1656}
1584 1657
1658static void r8a66597_interval_timer(unsigned long _r8a66597)
1659{
1660 struct r8a66597 *r8a66597 = (struct r8a66597 *)_r8a66597;
1661 unsigned long flags;
1662 u16 pipenum;
1663 struct r8a66597_td *td;
1664
1665 spin_lock_irqsave(&r8a66597->lock, flags);
1666
1667 for (pipenum = 0; pipenum < R8A66597_MAX_NUM_PIPE; pipenum++) {
1668 if (!(r8a66597->interval_map & (1 << pipenum)))
1669 continue;
1670 if (timer_pending(&r8a66597->interval_timer[pipenum]))
1671 continue;
1672
1673 td = r8a66597_get_td(r8a66597, pipenum);
1674 if (td)
1675 start_transfer(r8a66597, td);
1676 }
1677
1678 spin_unlock_irqrestore(&r8a66597->lock, flags);
1679}
1680
1585static void r8a66597_td_timer(unsigned long _r8a66597) 1681static void r8a66597_td_timer(unsigned long _r8a66597)
1586{ 1682{
1587 struct r8a66597 *r8a66597 = (struct r8a66597 *)_r8a66597; 1683 struct r8a66597 *r8a66597 = (struct r8a66597 *)_r8a66597;
@@ -1763,10 +1859,17 @@ static int r8a66597_urb_enqueue(struct usb_hcd *hcd,
1763 urb->hcpriv = td; 1859 urb->hcpriv = td;
1764 1860
1765 if (request) { 1861 if (request) {
1766 ret = start_transfer(r8a66597, td); 1862 if (td->pipe->info.timer_interval) {
1767 if (ret < 0) { 1863 r8a66597->interval_map |= 1 << td->pipenum;
1768 list_del(&td->queue); 1864 mod_timer(&r8a66597->interval_timer[td->pipenum],
1769 kfree(td); 1865 jiffies + msecs_to_jiffies(
1866 td->pipe->info.timer_interval));
1867 } else {
1868 ret = start_transfer(r8a66597, td);
1869 if (ret < 0) {
1870 list_del(&td->queue);
1871 kfree(td);
1872 }
1770 } 1873 }
1771 } else 1874 } else
1772 set_td_timer(r8a66597, td); 1875 set_td_timer(r8a66597, td);
@@ -2107,13 +2210,11 @@ static struct hc_driver r8a66597_hc_driver = {
2107#if defined(CONFIG_PM) 2210#if defined(CONFIG_PM)
2108static int r8a66597_suspend(struct platform_device *pdev, pm_message_t state) 2211static int r8a66597_suspend(struct platform_device *pdev, pm_message_t state)
2109{ 2212{
2110 pdev->dev.power.power_state = state;
2111 return 0; 2213 return 0;
2112} 2214}
2113 2215
2114static int r8a66597_resume(struct platform_device *pdev) 2216static int r8a66597_resume(struct platform_device *pdev)
2115{ 2217{
2116 pdev->dev.power.power_state = PMSG_ON;
2117 return 0; 2218 return 0;
2118} 2219}
2119#else /* if defined(CONFIG_PM) */ 2220#else /* if defined(CONFIG_PM) */
@@ -2194,6 +2295,9 @@ static int __init r8a66597_probe(struct platform_device *pdev)
2194 init_timer(&r8a66597->td_timer[i]); 2295 init_timer(&r8a66597->td_timer[i]);
2195 r8a66597->td_timer[i].function = r8a66597_td_timer; 2296 r8a66597->td_timer[i].function = r8a66597_td_timer;
2196 r8a66597->td_timer[i].data = (unsigned long)r8a66597; 2297 r8a66597->td_timer[i].data = (unsigned long)r8a66597;
2298 setup_timer(&r8a66597->interval_timer[i],
2299 r8a66597_interval_timer,
2300 (unsigned long)r8a66597);
2197 } 2301 }
2198 INIT_LIST_HEAD(&r8a66597->child_device); 2302 INIT_LIST_HEAD(&r8a66597->child_device);
2199 2303
diff --git a/drivers/usb/host/r8a66597.h b/drivers/usb/host/r8a66597.h
index 57388252b69..84ee0141731 100644
--- a/drivers/usb/host/r8a66597.h
+++ b/drivers/usb/host/r8a66597.h
@@ -187,7 +187,11 @@
187#define REW 0x4000 /* b14: Buffer rewind */ 187#define REW 0x4000 /* b14: Buffer rewind */
188#define DCLRM 0x2000 /* b13: DMA buffer clear mode */ 188#define DCLRM 0x2000 /* b13: DMA buffer clear mode */
189#define DREQE 0x1000 /* b12: DREQ output enable */ 189#define DREQE 0x1000 /* b12: DREQ output enable */
190#if defined(CONFIG_SUPERH_ON_CHIP_R8A66597)
191#define MBW 0x0800
192#else
190#define MBW 0x0400 /* b10: Maximum bit width for FIFO access */ 193#define MBW 0x0400 /* b10: Maximum bit width for FIFO access */
194#endif
191#define MBW_8 0x0000 /* 8bit */ 195#define MBW_8 0x0000 /* 8bit */
192#define MBW_16 0x0400 /* 16bit */ 196#define MBW_16 0x0400 /* 16bit */
193#define BIGEND 0x0100 /* b8: Big endian mode */ 197#define BIGEND 0x0100 /* b8: Big endian mode */
@@ -395,8 +399,13 @@
395#define R8A66597_MAX_NUM_PIPE 10 399#define R8A66597_MAX_NUM_PIPE 10
396#define R8A66597_BUF_BSIZE 8 400#define R8A66597_BUF_BSIZE 8
397#define R8A66597_MAX_DEVICE 10 401#define R8A66597_MAX_DEVICE 10
402#if defined(CONFIG_SUPERH_ON_CHIP_R8A66597)
403#define R8A66597_MAX_ROOT_HUB 1
404#else
398#define R8A66597_MAX_ROOT_HUB 2 405#define R8A66597_MAX_ROOT_HUB 2
399#define R8A66597_MAX_SAMPLING 10 406#endif
407#define R8A66597_MAX_SAMPLING 5
408#define R8A66597_RH_POLL_TIME 10
400#define R8A66597_MAX_DMA_CHANNEL 2 409#define R8A66597_MAX_DMA_CHANNEL 2
401#define R8A66597_PIPE_NO_DMA R8A66597_MAX_DMA_CHANNEL 410#define R8A66597_PIPE_NO_DMA R8A66597_MAX_DMA_CHANNEL
402#define check_bulk_or_isoc(pipenum) ((pipenum >= 1 && pipenum <= 5)) 411#define check_bulk_or_isoc(pipenum) ((pipenum >= 1 && pipenum <= 5))
@@ -404,6 +413,7 @@
404#define make_devsel(addr) (addr << 12) 413#define make_devsel(addr) (addr << 12)
405 414
406struct r8a66597_pipe_info { 415struct r8a66597_pipe_info {
416 unsigned long timer_interval;
407 u16 pipenum; 417 u16 pipenum;
408 u16 address; /* R8A66597 HCD usb address */ 418 u16 address; /* R8A66597 HCD usb address */
409 u16 epnum; 419 u16 epnum;
@@ -478,9 +488,11 @@ struct r8a66597 {
478 488
479 struct timer_list rh_timer; 489 struct timer_list rh_timer;
480 struct timer_list td_timer[R8A66597_MAX_NUM_PIPE]; 490 struct timer_list td_timer[R8A66597_MAX_NUM_PIPE];
491 struct timer_list interval_timer[R8A66597_MAX_NUM_PIPE];
481 492
482 unsigned short address_map; 493 unsigned short address_map;
483 unsigned short timeout_map; 494 unsigned short timeout_map;
495 unsigned short interval_map;
484 unsigned char pipe_cnt[R8A66597_MAX_NUM_PIPE]; 496 unsigned char pipe_cnt[R8A66597_MAX_NUM_PIPE];
485 unsigned char dma_map; 497 unsigned char dma_map;
486 498
@@ -526,8 +538,21 @@ static inline void r8a66597_read_fifo(struct r8a66597 *r8a66597,
526 unsigned long offset, u16 *buf, 538 unsigned long offset, u16 *buf,
527 int len) 539 int len)
528{ 540{
541#if defined(CONFIG_SUPERH_ON_CHIP_R8A66597)
542 unsigned long fifoaddr = r8a66597->reg + offset;
543 unsigned long count;
544
545 count = len / 4;
546 insl(fifoaddr, buf, count);
547
548 if (len & 0x00000003) {
549 unsigned long tmp = inl(fifoaddr);
550 memcpy((unsigned char *)buf + count * 4, &tmp, len & 0x03);
551 }
552#else
529 len = (len + 1) / 2; 553 len = (len + 1) / 2;
530 insw(r8a66597->reg + offset, buf, len); 554 insw(r8a66597->reg + offset, buf, len);
555#endif
531} 556}
532 557
533static inline void r8a66597_write(struct r8a66597 *r8a66597, u16 val, 558static inline void r8a66597_write(struct r8a66597 *r8a66597, u16 val,
@@ -541,6 +566,24 @@ static inline void r8a66597_write_fifo(struct r8a66597 *r8a66597,
541 int len) 566 int len)
542{ 567{
543 unsigned long fifoaddr = r8a66597->reg + offset; 568 unsigned long fifoaddr = r8a66597->reg + offset;
569#if defined(CONFIG_SUPERH_ON_CHIP_R8A66597)
570 unsigned long count;
571 unsigned char *pb;
572 int i;
573
574 count = len / 4;
575 outsl(fifoaddr, buf, count);
576
577 if (len & 0x00000003) {
578 pb = (unsigned char *)buf + count * 4;
579 for (i = 0; i < (len & 0x00000003); i++) {
580 if (r8a66597_read(r8a66597, CFIFOSEL) & BIGEND)
581 outb(pb[i], fifoaddr + i);
582 else
583 outb(pb[i], fifoaddr + 3 - i);
584 }
585 }
586#else
544 int odd = len & 0x0001; 587 int odd = len & 0x0001;
545 588
546 len = len / 2; 589 len = len / 2;
@@ -549,6 +592,7 @@ static inline void r8a66597_write_fifo(struct r8a66597 *r8a66597,
549 buf = &buf[len]; 592 buf = &buf[len];
550 outb((unsigned char)*buf, fifoaddr); 593 outb((unsigned char)*buf, fifoaddr);
551 } 594 }
595#endif
552} 596}
553 597
554static inline void r8a66597_mdfy(struct r8a66597 *r8a66597, 598static inline void r8a66597_mdfy(struct r8a66597 *r8a66597,
@@ -581,6 +625,11 @@ static inline unsigned long get_dvstctr_reg(int port)
581 return port == 0 ? DVSTCTR0 : DVSTCTR1; 625 return port == 0 ? DVSTCTR0 : DVSTCTR1;
582} 626}
583 627
628static inline unsigned long get_dmacfg_reg(int port)
629{
630 return port == 0 ? DMA0CFG : DMA1CFG;
631}
632
584static inline unsigned long get_intenb_reg(int port) 633static inline unsigned long get_intenb_reg(int port)
585{ 634{
586 return port == 0 ? INTENB1 : INTENB2; 635 return port == 0 ? INTENB1 : INTENB2;
diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c
index 629bca0ebe8..274276cf862 100644
--- a/drivers/usb/host/sl811-hcd.c
+++ b/drivers/usb/host/sl811-hcd.c
@@ -94,12 +94,10 @@ static void port_power(struct sl811 *sl811, int is_on)
94 94
95 sl811->port1 = (1 << USB_PORT_FEAT_POWER); 95 sl811->port1 = (1 << USB_PORT_FEAT_POWER);
96 sl811->irq_enable = SL11H_INTMASK_INSRMV; 96 sl811->irq_enable = SL11H_INTMASK_INSRMV;
97 hcd->self.controller->power.power_state = PMSG_ON;
98 } else { 97 } else {
99 sl811->port1 = 0; 98 sl811->port1 = 0;
100 sl811->irq_enable = 0; 99 sl811->irq_enable = 0;
101 hcd->state = HC_STATE_HALT; 100 hcd->state = HC_STATE_HALT;
102 hcd->self.controller->power.power_state = PMSG_SUSPEND;
103 } 101 }
104 sl811->ctrl1 = 0; 102 sl811->ctrl1 = 0;
105 sl811_write(sl811, SL11H_IRQ_ENABLE, 0); 103 sl811_write(sl811, SL11H_IRQ_ENABLE, 0);
@@ -1337,7 +1335,7 @@ static int
1337sl811h_bus_suspend(struct usb_hcd *hcd) 1335sl811h_bus_suspend(struct usb_hcd *hcd)
1338{ 1336{
1339 // SOFs off 1337 // SOFs off
1340 DBG("%s\n", __FUNCTION__); 1338 DBG("%s\n", __func__);
1341 return 0; 1339 return 0;
1342} 1340}
1343 1341
@@ -1345,7 +1343,7 @@ static int
1345sl811h_bus_resume(struct usb_hcd *hcd) 1343sl811h_bus_resume(struct usb_hcd *hcd)
1346{ 1344{
1347 // SOFs on 1345 // SOFs on
1348 DBG("%s\n", __FUNCTION__); 1346 DBG("%s\n", __func__);
1349 return 0; 1347 return 0;
1350} 1348}
1351 1349
@@ -1772,8 +1770,6 @@ sl811h_suspend(struct platform_device *dev, pm_message_t state)
1772 port_power(sl811, 0); 1770 port_power(sl811, 0);
1773 break; 1771 break;
1774 } 1772 }
1775 if (retval == 0)
1776 dev->dev.power.power_state = state;
1777 return retval; 1773 return retval;
1778} 1774}
1779 1775
@@ -1786,15 +1782,13 @@ sl811h_resume(struct platform_device *dev)
1786 /* with no "check to see if VBUS is still powered" board hook, 1782 /* with no "check to see if VBUS is still powered" board hook,
1787 * let's assume it'd only be powered to enable remote wakeup. 1783 * let's assume it'd only be powered to enable remote wakeup.
1788 */ 1784 */
1789 if (dev->dev.power.power_state.event == PM_EVENT_SUSPEND 1785 if (!sl811->port1 || !device_can_wakeup(&hcd->self.root_hub->dev)) {
1790 || !device_can_wakeup(&hcd->self.root_hub->dev)) {
1791 sl811->port1 = 0; 1786 sl811->port1 = 0;
1792 port_power(sl811, 1); 1787 port_power(sl811, 1);
1793 usb_root_hub_lost_power(hcd->self.root_hub); 1788 usb_root_hub_lost_power(hcd->self.root_hub);
1794 return 0; 1789 return 0;
1795 } 1790 }
1796 1791
1797 dev->dev.power.power_state = PMSG_ON;
1798 return sl811h_bus_resume(hcd); 1792 return sl811h_bus_resume(hcd);
1799} 1793}
1800 1794
diff --git a/drivers/usb/host/u132-hcd.c b/drivers/usb/host/u132-hcd.c
index 8e117a795e9..f29307405bb 100644
--- a/drivers/usb/host/u132-hcd.c
+++ b/drivers/usb/host/u132-hcd.c
@@ -67,7 +67,7 @@
67#include "ohci.h" 67#include "ohci.h"
68#define OHCI_CONTROL_INIT OHCI_CTRL_CBSR 68#define OHCI_CONTROL_INIT OHCI_CTRL_CBSR
69#define OHCI_INTR_INIT (OHCI_INTR_MIE | OHCI_INTR_UE | OHCI_INTR_RD | \ 69#define OHCI_INTR_INIT (OHCI_INTR_MIE | OHCI_INTR_UE | OHCI_INTR_RD | \
70 OHCI_INTR_WDH) 70 OHCI_INTR_WDH)
71MODULE_AUTHOR("Tony Olech - Elan Digital Systems Limited"); 71MODULE_AUTHOR("Tony Olech - Elan Digital Systems Limited");
72MODULE_DESCRIPTION("U132 USB Host Controller Driver"); 72MODULE_DESCRIPTION("U132 USB Host Controller Driver");
73MODULE_LICENSE("GPL"); 73MODULE_LICENSE("GPL");
@@ -77,15 +77,15 @@ INT_MODULE_PARM(testing, 0);
77static int distrust_firmware = 1; 77static int distrust_firmware = 1;
78module_param(distrust_firmware, bool, 0); 78module_param(distrust_firmware, bool, 0);
79MODULE_PARM_DESC(distrust_firmware, "true to distrust firmware power/overcurren" 79MODULE_PARM_DESC(distrust_firmware, "true to distrust firmware power/overcurren"
80 "t setup"); 80 "t setup");
81static DECLARE_WAIT_QUEUE_HEAD(u132_hcd_wait); 81static DECLARE_WAIT_QUEUE_HEAD(u132_hcd_wait);
82/* 82/*
83* u132_module_lock exists to protect access to global variables 83* u132_module_lock exists to protect access to global variables
84* 84*
85*/ 85*/
86static struct mutex u132_module_lock; 86static struct mutex u132_module_lock;
87static int u132_exiting = 0; 87static int u132_exiting;
88static int u132_instances = 0; 88static int u132_instances;
89static struct list_head u132_static_list; 89static struct list_head u132_static_list;
90/* 90/*
91* end of the global variables protected by u132_module_lock 91* end of the global variables protected by u132_module_lock
@@ -97,115 +97,115 @@ static struct workqueue_struct *workqueue;
97#define MAX_U132_ENDPS 100 97#define MAX_U132_ENDPS 100
98#define MAX_U132_RINGS 4 98#define MAX_U132_RINGS 4
99static const char *cc_to_text[16] = { 99static const char *cc_to_text[16] = {
100 "No Error ", 100 "No Error ",
101 "CRC Error ", 101 "CRC Error ",
102 "Bit Stuff ", 102 "Bit Stuff ",
103 "Data Togg ", 103 "Data Togg ",
104 "Stall ", 104 "Stall ",
105 "DevNotResp ", 105 "DevNotResp ",
106 "PIDCheck ", 106 "PIDCheck ",
107 "UnExpPID ", 107 "UnExpPID ",
108 "DataOver ", 108 "DataOver ",
109 "DataUnder ", 109 "DataUnder ",
110 "(for hw) ", 110 "(for hw) ",
111 "(for hw) ", 111 "(for hw) ",
112 "BufferOver ", 112 "BufferOver ",
113 "BuffUnder ", 113 "BuffUnder ",
114 "(for HCD) ", 114 "(for HCD) ",
115 "(for HCD) " 115 "(for HCD) "
116}; 116};
117struct u132_port { 117struct u132_port {
118 struct u132 *u132; 118 struct u132 *u132;
119 int reset; 119 int reset;
120 int enable; 120 int enable;
121 int power; 121 int power;
122 int Status; 122 int Status;
123}; 123};
124struct u132_addr { 124struct u132_addr {
125 u8 address; 125 u8 address;
126}; 126};
127struct u132_udev { 127struct u132_udev {
128 struct kref kref; 128 struct kref kref;
129 struct usb_device *usb_device; 129 struct usb_device *usb_device;
130 u8 enumeration; 130 u8 enumeration;
131 u8 udev_number; 131 u8 udev_number;
132 u8 usb_addr; 132 u8 usb_addr;
133 u8 portnumber; 133 u8 portnumber;
134 u8 endp_number_in[16]; 134 u8 endp_number_in[16];
135 u8 endp_number_out[16]; 135 u8 endp_number_out[16];
136}; 136};
137#define ENDP_QUEUE_SHIFT 3 137#define ENDP_QUEUE_SHIFT 3
138#define ENDP_QUEUE_SIZE (1<<ENDP_QUEUE_SHIFT) 138#define ENDP_QUEUE_SIZE (1<<ENDP_QUEUE_SHIFT)
139#define ENDP_QUEUE_MASK (ENDP_QUEUE_SIZE-1) 139#define ENDP_QUEUE_MASK (ENDP_QUEUE_SIZE-1)
140struct u132_urbq { 140struct u132_urbq {
141 struct list_head urb_more; 141 struct list_head urb_more;
142 struct urb *urb; 142 struct urb *urb;
143}; 143};
144struct u132_spin { 144struct u132_spin {
145 spinlock_t slock; 145 spinlock_t slock;
146}; 146};
147struct u132_endp { 147struct u132_endp {
148 struct kref kref; 148 struct kref kref;
149 u8 udev_number; 149 u8 udev_number;
150 u8 endp_number; 150 u8 endp_number;
151 u8 usb_addr; 151 u8 usb_addr;
152 u8 usb_endp; 152 u8 usb_endp;
153 struct u132 *u132; 153 struct u132 *u132;
154 struct list_head endp_ring; 154 struct list_head endp_ring;
155 struct u132_ring *ring; 155 struct u132_ring *ring;
156 unsigned toggle_bits:2; 156 unsigned toggle_bits:2;
157 unsigned active:1; 157 unsigned active:1;
158 unsigned delayed:1; 158 unsigned delayed:1;
159 unsigned input:1; 159 unsigned input:1;
160 unsigned output:1; 160 unsigned output:1;
161 unsigned pipetype:2; 161 unsigned pipetype:2;
162 unsigned dequeueing:1; 162 unsigned dequeueing:1;
163 unsigned edset_flush:1; 163 unsigned edset_flush:1;
164 unsigned spare_bits:14; 164 unsigned spare_bits:14;
165 unsigned long jiffies; 165 unsigned long jiffies;
166 struct usb_host_endpoint *hep; 166 struct usb_host_endpoint *hep;
167 struct u132_spin queue_lock; 167 struct u132_spin queue_lock;
168 u16 queue_size; 168 u16 queue_size;
169 u16 queue_last; 169 u16 queue_last;
170 u16 queue_next; 170 u16 queue_next;
171 struct urb *urb_list[ENDP_QUEUE_SIZE]; 171 struct urb *urb_list[ENDP_QUEUE_SIZE];
172 struct list_head urb_more; 172 struct list_head urb_more;
173 struct delayed_work scheduler; 173 struct delayed_work scheduler;
174}; 174};
175struct u132_ring { 175struct u132_ring {
176 unsigned in_use:1; 176 unsigned in_use:1;
177 unsigned length:7; 177 unsigned length:7;
178 u8 number; 178 u8 number;
179 struct u132 *u132; 179 struct u132 *u132;
180 struct u132_endp *curr_endp; 180 struct u132_endp *curr_endp;
181 struct delayed_work scheduler; 181 struct delayed_work scheduler;
182}; 182};
183struct u132 { 183struct u132 {
184 struct kref kref; 184 struct kref kref;
185 struct list_head u132_list; 185 struct list_head u132_list;
186 struct mutex sw_lock; 186 struct mutex sw_lock;
187 struct semaphore scheduler_lock; 187 struct mutex scheduler_lock;
188 struct u132_platform_data *board; 188 struct u132_platform_data *board;
189 struct platform_device *platform_dev; 189 struct platform_device *platform_dev;
190 struct u132_ring ring[MAX_U132_RINGS]; 190 struct u132_ring ring[MAX_U132_RINGS];
191 int sequence_num; 191 int sequence_num;
192 int going; 192 int going;
193 int power; 193 int power;
194 int reset; 194 int reset;
195 int num_ports; 195 int num_ports;
196 u32 hc_control; 196 u32 hc_control;
197 u32 hc_fminterval; 197 u32 hc_fminterval;
198 u32 hc_roothub_status; 198 u32 hc_roothub_status;
199 u32 hc_roothub_a; 199 u32 hc_roothub_a;
200 u32 hc_roothub_portstatus[MAX_ROOT_PORTS]; 200 u32 hc_roothub_portstatus[MAX_ROOT_PORTS];
201 int flags; 201 int flags;
202 unsigned long next_statechange; 202 unsigned long next_statechange;
203 struct delayed_work monitor; 203 struct delayed_work monitor;
204 int num_endpoints; 204 int num_endpoints;
205 struct u132_addr addr[MAX_U132_ADDRS]; 205 struct u132_addr addr[MAX_U132_ADDRS];
206 struct u132_udev udev[MAX_U132_UDEVS]; 206 struct u132_udev udev[MAX_U132_UDEVS];
207 struct u132_port port[MAX_U132_PORTS]; 207 struct u132_port port[MAX_U132_PORTS];
208 struct u132_endp *endp[MAX_U132_ENDPS]; 208 struct u132_endp *endp[MAX_U132_ENDPS];
209}; 209};
210 210
211/* 211/*
@@ -213,34 +213,34 @@ struct u132 {
213* Does anyone have a better way????? 213* Does anyone have a better way?????
214*/ 214*/
215#define ftdi_read_pcimem(pdev, member, data) usb_ftdi_elan_read_pcimem(pdev, \ 215#define ftdi_read_pcimem(pdev, member, data) usb_ftdi_elan_read_pcimem(pdev, \
216 offsetof(struct ohci_regs, member), 0, data); 216 offsetof(struct ohci_regs, member), 0, data);
217#define ftdi_write_pcimem(pdev, member, data) usb_ftdi_elan_write_pcimem(pdev, \ 217#define ftdi_write_pcimem(pdev, member, data) usb_ftdi_elan_write_pcimem(pdev, \
218 offsetof(struct ohci_regs, member), 0, data); 218 offsetof(struct ohci_regs, member), 0, data);
219#define u132_read_pcimem(u132, member, data) \ 219#define u132_read_pcimem(u132, member, data) \
220 usb_ftdi_elan_read_pcimem(u132->platform_dev, offsetof(struct \ 220 usb_ftdi_elan_read_pcimem(u132->platform_dev, offsetof(struct \
221 ohci_regs, member), 0, data); 221 ohci_regs, member), 0, data);
222#define u132_write_pcimem(u132, member, data) \ 222#define u132_write_pcimem(u132, member, data) \
223 usb_ftdi_elan_write_pcimem(u132->platform_dev, offsetof(struct \ 223 usb_ftdi_elan_write_pcimem(u132->platform_dev, offsetof(struct \
224 ohci_regs, member), 0, data); 224 ohci_regs, member), 0, data);
225static inline struct u132 *udev_to_u132(struct u132_udev *udev) 225static inline struct u132 *udev_to_u132(struct u132_udev *udev)
226{ 226{
227 u8 udev_number = udev->udev_number; 227 u8 udev_number = udev->udev_number;
228 return container_of(udev, struct u132, udev[udev_number]); 228 return container_of(udev, struct u132, udev[udev_number]);
229} 229}
230 230
231static inline struct u132 *hcd_to_u132(struct usb_hcd *hcd) 231static inline struct u132 *hcd_to_u132(struct usb_hcd *hcd)
232{ 232{
233 return (struct u132 *)(hcd->hcd_priv); 233 return (struct u132 *)(hcd->hcd_priv);
234} 234}
235 235
236static inline struct usb_hcd *u132_to_hcd(struct u132 *u132) 236static inline struct usb_hcd *u132_to_hcd(struct u132 *u132)
237{ 237{
238 return container_of((void *)u132, struct usb_hcd, hcd_priv); 238 return container_of((void *)u132, struct usb_hcd, hcd_priv);
239} 239}
240 240
241static inline void u132_disable(struct u132 *u132) 241static inline void u132_disable(struct u132 *u132)
242{ 242{
243 u132_to_hcd(u132)->state = HC_STATE_HALT; 243 u132_to_hcd(u132)->state = HC_STATE_HALT;
244} 244}
245 245
246 246
@@ -250,147 +250,147 @@ static inline void u132_disable(struct u132 *u132)
250#include "../misc/usb_u132.h" 250#include "../misc/usb_u132.h"
251static const char hcd_name[] = "u132_hcd"; 251static const char hcd_name[] = "u132_hcd";
252#define PORT_C_MASK ((USB_PORT_STAT_C_CONNECTION | USB_PORT_STAT_C_ENABLE | \ 252#define PORT_C_MASK ((USB_PORT_STAT_C_CONNECTION | USB_PORT_STAT_C_ENABLE | \
253 USB_PORT_STAT_C_SUSPEND | USB_PORT_STAT_C_OVERCURRENT | \ 253 USB_PORT_STAT_C_SUSPEND | USB_PORT_STAT_C_OVERCURRENT | \
254 USB_PORT_STAT_C_RESET) << 16) 254 USB_PORT_STAT_C_RESET) << 16)
255static void u132_hcd_delete(struct kref *kref) 255static void u132_hcd_delete(struct kref *kref)
256{ 256{
257 struct u132 *u132 = kref_to_u132(kref); 257 struct u132 *u132 = kref_to_u132(kref);
258 struct platform_device *pdev = u132->platform_dev; 258 struct platform_device *pdev = u132->platform_dev;
259 struct usb_hcd *hcd = u132_to_hcd(u132); 259 struct usb_hcd *hcd = u132_to_hcd(u132);
260 u132->going += 1; 260 u132->going += 1;
261 mutex_lock(&u132_module_lock); 261 mutex_lock(&u132_module_lock);
262 list_del_init(&u132->u132_list); 262 list_del_init(&u132->u132_list);
263 u132_instances -= 1; 263 u132_instances -= 1;
264 mutex_unlock(&u132_module_lock); 264 mutex_unlock(&u132_module_lock);
265 dev_warn(&u132->platform_dev->dev, "FREEING the hcd=%p and thus the u13" 265 dev_warn(&u132->platform_dev->dev, "FREEING the hcd=%p and thus the u13"
266 "2=%p going=%d pdev=%p\n", hcd, u132, u132->going, pdev); 266 "2=%p going=%d pdev=%p\n", hcd, u132, u132->going, pdev);
267 usb_put_hcd(hcd); 267 usb_put_hcd(hcd);
268} 268}
269 269
270static inline void u132_u132_put_kref(struct u132 *u132) 270static inline void u132_u132_put_kref(struct u132 *u132)
271{ 271{
272 kref_put(&u132->kref, u132_hcd_delete); 272 kref_put(&u132->kref, u132_hcd_delete);
273} 273}
274 274
275static inline void u132_u132_init_kref(struct u132 *u132) 275static inline void u132_u132_init_kref(struct u132 *u132)
276{ 276{
277 kref_init(&u132->kref); 277 kref_init(&u132->kref);
278} 278}
279 279
280static void u132_udev_delete(struct kref *kref) 280static void u132_udev_delete(struct kref *kref)
281{ 281{
282 struct u132_udev *udev = kref_to_u132_udev(kref); 282 struct u132_udev *udev = kref_to_u132_udev(kref);
283 udev->udev_number = 0; 283 udev->udev_number = 0;
284 udev->usb_device = NULL; 284 udev->usb_device = NULL;
285 udev->usb_addr = 0; 285 udev->usb_addr = 0;
286 udev->enumeration = 0; 286 udev->enumeration = 0;
287} 287}
288 288
289static inline void u132_udev_put_kref(struct u132 *u132, struct u132_udev *udev) 289static inline void u132_udev_put_kref(struct u132 *u132, struct u132_udev *udev)
290{ 290{
291 kref_put(&udev->kref, u132_udev_delete); 291 kref_put(&udev->kref, u132_udev_delete);
292} 292}
293 293
294static inline void u132_udev_get_kref(struct u132 *u132, struct u132_udev *udev) 294static inline void u132_udev_get_kref(struct u132 *u132, struct u132_udev *udev)
295{ 295{
296 kref_get(&udev->kref); 296 kref_get(&udev->kref);
297} 297}
298 298
299static inline void u132_udev_init_kref(struct u132 *u132, 299static inline void u132_udev_init_kref(struct u132 *u132,
300 struct u132_udev *udev) 300 struct u132_udev *udev)
301{ 301{
302 kref_init(&udev->kref); 302 kref_init(&udev->kref);
303} 303}
304 304
305static inline void u132_ring_put_kref(struct u132 *u132, struct u132_ring *ring) 305static inline void u132_ring_put_kref(struct u132 *u132, struct u132_ring *ring)
306{ 306{
307 kref_put(&u132->kref, u132_hcd_delete); 307 kref_put(&u132->kref, u132_hcd_delete);
308} 308}
309 309
310static void u132_ring_requeue_work(struct u132 *u132, struct u132_ring *ring, 310static void u132_ring_requeue_work(struct u132 *u132, struct u132_ring *ring,
311 unsigned int delta) 311 unsigned int delta)
312{ 312{
313 if (delta > 0) { 313 if (delta > 0) {
314 if (queue_delayed_work(workqueue, &ring->scheduler, delta)) 314 if (queue_delayed_work(workqueue, &ring->scheduler, delta))
315 return; 315 return;
316 } else if (queue_delayed_work(workqueue, &ring->scheduler, 0)) 316 } else if (queue_delayed_work(workqueue, &ring->scheduler, 0))
317 return; 317 return;
318 kref_put(&u132->kref, u132_hcd_delete); 318 kref_put(&u132->kref, u132_hcd_delete);
319 return; 319 return;
320} 320}
321 321
322static void u132_ring_queue_work(struct u132 *u132, struct u132_ring *ring, 322static void u132_ring_queue_work(struct u132 *u132, struct u132_ring *ring,
323 unsigned int delta) 323 unsigned int delta)
324{ 324{
325 kref_get(&u132->kref); 325 kref_get(&u132->kref);
326 u132_ring_requeue_work(u132, ring, delta); 326 u132_ring_requeue_work(u132, ring, delta);
327 return; 327 return;
328} 328}
329 329
330static void u132_ring_cancel_work(struct u132 *u132, struct u132_ring *ring) 330static void u132_ring_cancel_work(struct u132 *u132, struct u132_ring *ring)
331{ 331{
332 if (cancel_delayed_work(&ring->scheduler)) { 332 if (cancel_delayed_work(&ring->scheduler))
333 kref_put(&u132->kref, u132_hcd_delete); 333 kref_put(&u132->kref, u132_hcd_delete);
334 }
335} 334}
336 335
337static void u132_endp_delete(struct kref *kref) 336static void u132_endp_delete(struct kref *kref)
338{ 337{
339 struct u132_endp *endp = kref_to_u132_endp(kref); 338 struct u132_endp *endp = kref_to_u132_endp(kref);
340 struct u132 *u132 = endp->u132; 339 struct u132 *u132 = endp->u132;
341 u8 usb_addr = endp->usb_addr; 340 u8 usb_addr = endp->usb_addr;
342 u8 usb_endp = endp->usb_endp; 341 u8 usb_endp = endp->usb_endp;
343 u8 address = u132->addr[usb_addr].address; 342 u8 address = u132->addr[usb_addr].address;
344 struct u132_udev *udev = &u132->udev[address]; 343 struct u132_udev *udev = &u132->udev[address];
345 u8 endp_number = endp->endp_number; 344 u8 endp_number = endp->endp_number;
346 struct usb_host_endpoint *hep = endp->hep; 345 struct usb_host_endpoint *hep = endp->hep;
347 struct u132_ring *ring = endp->ring; 346 struct u132_ring *ring = endp->ring;
348 struct list_head *head = &endp->endp_ring; 347 struct list_head *head = &endp->endp_ring;
349 ring->length -= 1; 348 ring->length -= 1;
350 if (endp == ring->curr_endp) { 349 if (endp == ring->curr_endp) {
351 if (list_empty(head)) { 350 if (list_empty(head)) {
352 ring->curr_endp = NULL; 351 ring->curr_endp = NULL;
353 list_del(head); 352 list_del(head);
354 } else { 353 } else {
355 struct u132_endp *next_endp = list_entry(head->next, 354 struct u132_endp *next_endp = list_entry(head->next,
356 struct u132_endp, endp_ring); 355 struct u132_endp, endp_ring);
357 ring->curr_endp = next_endp; 356 ring->curr_endp = next_endp;
358 list_del(head); 357 list_del(head);
359 }} else 358 }
360 list_del(head); 359 } else
361 if (endp->input) { 360 list_del(head);
362 udev->endp_number_in[usb_endp] = 0; 361 if (endp->input) {
363 u132_udev_put_kref(u132, udev); 362 udev->endp_number_in[usb_endp] = 0;
364 } 363 u132_udev_put_kref(u132, udev);
365 if (endp->output) { 364 }
366 udev->endp_number_out[usb_endp] = 0; 365 if (endp->output) {
367 u132_udev_put_kref(u132, udev); 366 udev->endp_number_out[usb_endp] = 0;
368 } 367 u132_udev_put_kref(u132, udev);
369 u132->endp[endp_number - 1] = NULL; 368 }
370 hep->hcpriv = NULL; 369 u132->endp[endp_number - 1] = NULL;
371 kfree(endp); 370 hep->hcpriv = NULL;
372 u132_u132_put_kref(u132); 371 kfree(endp);
372 u132_u132_put_kref(u132);
373} 373}
374 374
375static inline void u132_endp_put_kref(struct u132 *u132, struct u132_endp *endp) 375static inline void u132_endp_put_kref(struct u132 *u132, struct u132_endp *endp)
376{ 376{
377 kref_put(&endp->kref, u132_endp_delete); 377 kref_put(&endp->kref, u132_endp_delete);
378} 378}
379 379
380static inline void u132_endp_get_kref(struct u132 *u132, struct u132_endp *endp) 380static inline void u132_endp_get_kref(struct u132 *u132, struct u132_endp *endp)
381{ 381{
382 kref_get(&endp->kref); 382 kref_get(&endp->kref);
383} 383}
384 384
385static inline void u132_endp_init_kref(struct u132 *u132, 385static inline void u132_endp_init_kref(struct u132 *u132,
386 struct u132_endp *endp) 386 struct u132_endp *endp)
387{ 387{
388 kref_init(&endp->kref); 388 kref_init(&endp->kref);
389 kref_get(&u132->kref); 389 kref_get(&u132->kref);
390} 390}
391 391
392static void u132_endp_queue_work(struct u132 *u132, struct u132_endp *endp, 392static void u132_endp_queue_work(struct u132 *u132, struct u132_endp *endp,
393 unsigned int delta) 393 unsigned int delta)
394{ 394{
395 if (queue_delayed_work(workqueue, &endp->scheduler, delta)) 395 if (queue_delayed_work(workqueue, &endp->scheduler, delta))
396 kref_get(&endp->kref); 396 kref_get(&endp->kref);
@@ -398,13 +398,13 @@ static void u132_endp_queue_work(struct u132 *u132, struct u132_endp *endp,
398 398
399static void u132_endp_cancel_work(struct u132 *u132, struct u132_endp *endp) 399static void u132_endp_cancel_work(struct u132 *u132, struct u132_endp *endp)
400{ 400{
401 if (cancel_delayed_work(&endp->scheduler)) 401 if (cancel_delayed_work(&endp->scheduler))
402 kref_put(&endp->kref, u132_endp_delete); 402 kref_put(&endp->kref, u132_endp_delete);
403} 403}
404 404
405static inline void u132_monitor_put_kref(struct u132 *u132) 405static inline void u132_monitor_put_kref(struct u132 *u132)
406{ 406{
407 kref_put(&u132->kref, u132_hcd_delete); 407 kref_put(&u132->kref, u132_hcd_delete);
408} 408}
409 409
410static void u132_monitor_queue_work(struct u132 *u132, unsigned int delta) 410static void u132_monitor_queue_work(struct u132 *u132, unsigned int delta)
@@ -421,200 +421,201 @@ static void u132_monitor_requeue_work(struct u132 *u132, unsigned int delta)
421 421
422static void u132_monitor_cancel_work(struct u132 *u132) 422static void u132_monitor_cancel_work(struct u132 *u132)
423{ 423{
424 if (cancel_delayed_work(&u132->monitor)) 424 if (cancel_delayed_work(&u132->monitor))
425 kref_put(&u132->kref, u132_hcd_delete); 425 kref_put(&u132->kref, u132_hcd_delete);
426} 426}
427 427
428static int read_roothub_info(struct u132 *u132) 428static int read_roothub_info(struct u132 *u132)
429{ 429{
430 u32 revision; 430 u32 revision;
431 int retval; 431 int retval;
432 retval = u132_read_pcimem(u132, revision, &revision); 432 retval = u132_read_pcimem(u132, revision, &revision);
433 if (retval) { 433 if (retval) {
434 dev_err(&u132->platform_dev->dev, "error %d accessing device co" 434 dev_err(&u132->platform_dev->dev, "error %d accessing device co"
435 "ntrol\n", retval); 435 "ntrol\n", retval);
436 return retval; 436 return retval;
437 } else if ((revision & 0xFF) == 0x10) { 437 } else if ((revision & 0xFF) == 0x10) {
438 } else if ((revision & 0xFF) == 0x11) { 438 } else if ((revision & 0xFF) == 0x11) {
439 } else { 439 } else {
440 dev_err(&u132->platform_dev->dev, "device revision is not valid" 440 dev_err(&u132->platform_dev->dev, "device revision is not valid"
441 " %08X\n", revision); 441 " %08X\n", revision);
442 return -ENODEV; 442 return -ENODEV;
443 } 443 }
444 retval = u132_read_pcimem(u132, control, &u132->hc_control); 444 retval = u132_read_pcimem(u132, control, &u132->hc_control);
445 if (retval) { 445 if (retval) {
446 dev_err(&u132->platform_dev->dev, "error %d accessing device co" 446 dev_err(&u132->platform_dev->dev, "error %d accessing device co"
447 "ntrol\n", retval); 447 "ntrol\n", retval);
448 return retval; 448 return retval;
449 } 449 }
450 retval = u132_read_pcimem(u132, roothub.status, 450 retval = u132_read_pcimem(u132, roothub.status,
451 &u132->hc_roothub_status); 451 &u132->hc_roothub_status);
452 if (retval) { 452 if (retval) {
453 dev_err(&u132->platform_dev->dev, "error %d accessing device re" 453 dev_err(&u132->platform_dev->dev, "error %d accessing device re"
454 "g roothub.status\n", retval); 454 "g roothub.status\n", retval);
455 return retval; 455 return retval;
456 } 456 }
457 retval = u132_read_pcimem(u132, roothub.a, &u132->hc_roothub_a); 457 retval = u132_read_pcimem(u132, roothub.a, &u132->hc_roothub_a);
458 if (retval) { 458 if (retval) {
459 dev_err(&u132->platform_dev->dev, "error %d accessing device re" 459 dev_err(&u132->platform_dev->dev, "error %d accessing device re"
460 "g roothub.a\n", retval); 460 "g roothub.a\n", retval);
461 return retval; 461 return retval;
462 } 462 }
463 { 463 {
464 int I = u132->num_ports; 464 int I = u132->num_ports;
465 int i = 0; 465 int i = 0;
466 while (I-- > 0) { 466 while (I-- > 0) {
467 retval = u132_read_pcimem(u132, roothub.portstatus[i], 467 retval = u132_read_pcimem(u132, roothub.portstatus[i],
468 &u132->hc_roothub_portstatus[i]); 468 &u132->hc_roothub_portstatus[i]);
469 if (retval) { 469 if (retval) {
470 dev_err(&u132->platform_dev->dev, "error %d acc" 470 dev_err(&u132->platform_dev->dev, "error %d acc"
471 "essing device roothub.portstatus[%d]\n" 471 "essing device roothub.portstatus[%d]\n"
472 , retval, i); 472 , retval, i);
473 return retval; 473 return retval;
474 } else 474 } else
475 i += 1; 475 i += 1;
476 } 476 }
477 } 477 }
478 return 0; 478 return 0;
479} 479}
480 480
481static void u132_hcd_monitor_work(struct work_struct *work) 481static void u132_hcd_monitor_work(struct work_struct *work)
482{ 482{
483 struct u132 *u132 = container_of(work, struct u132, monitor.work); 483 struct u132 *u132 = container_of(work, struct u132, monitor.work);
484 if (u132->going > 1) { 484 if (u132->going > 1) {
485 dev_err(&u132->platform_dev->dev, "device has been removed %d\n" 485 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
486 , u132->going); 486 , u132->going);
487 u132_monitor_put_kref(u132); 487 u132_monitor_put_kref(u132);
488 return; 488 return;
489 } else if (u132->going > 0) { 489 } else if (u132->going > 0) {
490 dev_err(&u132->platform_dev->dev, "device is being removed\n"); 490 dev_err(&u132->platform_dev->dev, "device is being removed\n");
491 u132_monitor_put_kref(u132); 491 u132_monitor_put_kref(u132);
492 return; 492 return;
493 } else { 493 } else {
494 int retval; 494 int retval;
495 mutex_lock(&u132->sw_lock); 495 mutex_lock(&u132->sw_lock);
496 retval = read_roothub_info(u132); 496 retval = read_roothub_info(u132);
497 if (retval) { 497 if (retval) {
498 struct usb_hcd *hcd = u132_to_hcd(u132); 498 struct usb_hcd *hcd = u132_to_hcd(u132);
499 u132_disable(u132); 499 u132_disable(u132);
500 u132->going = 1; 500 u132->going = 1;
501 mutex_unlock(&u132->sw_lock); 501 mutex_unlock(&u132->sw_lock);
502 usb_hc_died(hcd); 502 usb_hc_died(hcd);
503 ftdi_elan_gone_away(u132->platform_dev); 503 ftdi_elan_gone_away(u132->platform_dev);
504 u132_monitor_put_kref(u132); 504 u132_monitor_put_kref(u132);
505 return; 505 return;
506 } else { 506 } else {
507 u132_monitor_requeue_work(u132, 500); 507 u132_monitor_requeue_work(u132, 500);
508 mutex_unlock(&u132->sw_lock); 508 mutex_unlock(&u132->sw_lock);
509 return; 509 return;
510 } 510 }
511 } 511 }
512} 512}
513 513
514static void u132_hcd_giveback_urb(struct u132 *u132, struct u132_endp *endp, 514static void u132_hcd_giveback_urb(struct u132 *u132, struct u132_endp *endp,
515 struct urb *urb, int status) 515 struct urb *urb, int status)
516{ 516{
517 struct u132_ring *ring; 517 struct u132_ring *ring;
518 unsigned long irqs; 518 unsigned long irqs;
519 struct usb_hcd *hcd = u132_to_hcd(u132); 519 struct usb_hcd *hcd = u132_to_hcd(u132);
520 urb->error_count = 0; 520 urb->error_count = 0;
521 spin_lock_irqsave(&endp->queue_lock.slock, irqs); 521 spin_lock_irqsave(&endp->queue_lock.slock, irqs);
522 usb_hcd_unlink_urb_from_ep(hcd, urb); 522 usb_hcd_unlink_urb_from_ep(hcd, urb);
523 endp->queue_next += 1; 523 endp->queue_next += 1;
524 if (ENDP_QUEUE_SIZE > --endp->queue_size) { 524 if (ENDP_QUEUE_SIZE > --endp->queue_size) {
525 endp->active = 0; 525 endp->active = 0;
526 spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); 526 spin_unlock_irqrestore(&endp->queue_lock.slock, irqs);
527 } else { 527 } else {
528 struct list_head *next = endp->urb_more.next; 528 struct list_head *next = endp->urb_more.next;
529 struct u132_urbq *urbq = list_entry(next, struct u132_urbq, 529 struct u132_urbq *urbq = list_entry(next, struct u132_urbq,
530 urb_more); 530 urb_more);
531 list_del(next); 531 list_del(next);
532 endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = 532 endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] =
533 urbq->urb; 533 urbq->urb;
534 endp->active = 0; 534 endp->active = 0;
535 spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); 535 spin_unlock_irqrestore(&endp->queue_lock.slock, irqs);
536 kfree(urbq); 536 kfree(urbq);
537 } down(&u132->scheduler_lock); 537 }
538 ring = endp->ring; 538 mutex_lock(&u132->scheduler_lock);
539 ring->in_use = 0; 539 ring = endp->ring;
540 u132_ring_cancel_work(u132, ring); 540 ring->in_use = 0;
541 u132_ring_queue_work(u132, ring, 0); 541 u132_ring_cancel_work(u132, ring);
542 up(&u132->scheduler_lock); 542 u132_ring_queue_work(u132, ring, 0);
543 u132_endp_put_kref(u132, endp); 543 mutex_unlock(&u132->scheduler_lock);
544 u132_endp_put_kref(u132, endp);
544 usb_hcd_giveback_urb(hcd, urb, status); 545 usb_hcd_giveback_urb(hcd, urb, status);
545 return; 546 return;
546} 547}
547 548
548static void u132_hcd_forget_urb(struct u132 *u132, struct u132_endp *endp, 549static void u132_hcd_forget_urb(struct u132 *u132, struct u132_endp *endp,
549 struct urb *urb, int status) 550 struct urb *urb, int status)
550{ 551{
551 u132_endp_put_kref(u132, endp); 552 u132_endp_put_kref(u132, endp);
552} 553}
553 554
554static void u132_hcd_abandon_urb(struct u132 *u132, struct u132_endp *endp, 555static void u132_hcd_abandon_urb(struct u132 *u132, struct u132_endp *endp,
555 struct urb *urb, int status) 556 struct urb *urb, int status)
556{ 557{
557 unsigned long irqs; 558 unsigned long irqs;
558 struct usb_hcd *hcd = u132_to_hcd(u132); 559 struct usb_hcd *hcd = u132_to_hcd(u132);
559 urb->error_count = 0; 560 urb->error_count = 0;
560 spin_lock_irqsave(&endp->queue_lock.slock, irqs); 561 spin_lock_irqsave(&endp->queue_lock.slock, irqs);
561 usb_hcd_unlink_urb_from_ep(hcd, urb); 562 usb_hcd_unlink_urb_from_ep(hcd, urb);
562 endp->queue_next += 1; 563 endp->queue_next += 1;
563 if (ENDP_QUEUE_SIZE > --endp->queue_size) { 564 if (ENDP_QUEUE_SIZE > --endp->queue_size) {
564 endp->active = 0; 565 endp->active = 0;
565 spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); 566 spin_unlock_irqrestore(&endp->queue_lock.slock, irqs);
566 } else { 567 } else {
567 struct list_head *next = endp->urb_more.next; 568 struct list_head *next = endp->urb_more.next;
568 struct u132_urbq *urbq = list_entry(next, struct u132_urbq, 569 struct u132_urbq *urbq = list_entry(next, struct u132_urbq,
569 urb_more); 570 urb_more);
570 list_del(next); 571 list_del(next);
571 endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = 572 endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] =
572 urbq->urb; 573 urbq->urb;
573 endp->active = 0; 574 endp->active = 0;
574 spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); 575 spin_unlock_irqrestore(&endp->queue_lock.slock, irqs);
575 kfree(urbq); 576 kfree(urbq);
576 } usb_hcd_giveback_urb(hcd, urb, status); 577 } usb_hcd_giveback_urb(hcd, urb, status);
577 return; 578 return;
578} 579}
579 580
580static inline int edset_input(struct u132 *u132, struct u132_ring *ring, 581static inline int edset_input(struct u132 *u132, struct u132_ring *ring,
581 struct u132_endp *endp, struct urb *urb, u8 address, u8 toggle_bits, 582 struct u132_endp *endp, struct urb *urb, u8 address, u8 toggle_bits,
582 void (*callback) (void *endp, struct urb *urb, u8 *buf, int len, 583 void (*callback) (void *endp, struct urb *urb, u8 *buf, int len,
583 int toggle_bits, int error_count, int condition_code, int repeat_number, 584 int toggle_bits, int error_count, int condition_code, int repeat_number,
584 int halted, int skipped, int actual, int non_null)) 585 int halted, int skipped, int actual, int non_null))
585{ 586{
586 return usb_ftdi_elan_edset_input(u132->platform_dev, ring->number, endp, 587 return usb_ftdi_elan_edset_input(u132->platform_dev, ring->number, endp,
587 urb, address, endp->usb_endp, toggle_bits, callback); 588 urb, address, endp->usb_endp, toggle_bits, callback);
588} 589}
589 590
590static inline int edset_setup(struct u132 *u132, struct u132_ring *ring, 591static inline int edset_setup(struct u132 *u132, struct u132_ring *ring,
591 struct u132_endp *endp, struct urb *urb, u8 address, u8 toggle_bits, 592 struct u132_endp *endp, struct urb *urb, u8 address, u8 toggle_bits,
592 void (*callback) (void *endp, struct urb *urb, u8 *buf, int len, 593 void (*callback) (void *endp, struct urb *urb, u8 *buf, int len,
593 int toggle_bits, int error_count, int condition_code, int repeat_number, 594 int toggle_bits, int error_count, int condition_code, int repeat_number,
594 int halted, int skipped, int actual, int non_null)) 595 int halted, int skipped, int actual, int non_null))
595{ 596{
596 return usb_ftdi_elan_edset_setup(u132->platform_dev, ring->number, endp, 597 return usb_ftdi_elan_edset_setup(u132->platform_dev, ring->number, endp,
597 urb, address, endp->usb_endp, toggle_bits, callback); 598 urb, address, endp->usb_endp, toggle_bits, callback);
598} 599}
599 600
600static inline int edset_single(struct u132 *u132, struct u132_ring *ring, 601static inline int edset_single(struct u132 *u132, struct u132_ring *ring,
601 struct u132_endp *endp, struct urb *urb, u8 address, u8 toggle_bits, 602 struct u132_endp *endp, struct urb *urb, u8 address, u8 toggle_bits,
602 void (*callback) (void *endp, struct urb *urb, u8 *buf, int len, 603 void (*callback) (void *endp, struct urb *urb, u8 *buf, int len,
603 int toggle_bits, int error_count, int condition_code, int repeat_number, 604 int toggle_bits, int error_count, int condition_code, int repeat_number,
604 int halted, int skipped, int actual, int non_null)) 605 int halted, int skipped, int actual, int non_null))
605{ 606{
606 return usb_ftdi_elan_edset_single(u132->platform_dev, ring->number, 607 return usb_ftdi_elan_edset_single(u132->platform_dev, ring->number,
607 endp, urb, address, endp->usb_endp, toggle_bits, callback); 608 endp, urb, address, endp->usb_endp, toggle_bits, callback);
608} 609}
609 610
610static inline int edset_output(struct u132 *u132, struct u132_ring *ring, 611static inline int edset_output(struct u132 *u132, struct u132_ring *ring,
611 struct u132_endp *endp, struct urb *urb, u8 address, u8 toggle_bits, 612 struct u132_endp *endp, struct urb *urb, u8 address, u8 toggle_bits,
612 void (*callback) (void *endp, struct urb *urb, u8 *buf, int len, 613 void (*callback) (void *endp, struct urb *urb, u8 *buf, int len,
613 int toggle_bits, int error_count, int condition_code, int repeat_number, 614 int toggle_bits, int error_count, int condition_code, int repeat_number,
614 int halted, int skipped, int actual, int non_null)) 615 int halted, int skipped, int actual, int non_null))
615{ 616{
616 return usb_ftdi_elan_edset_output(u132->platform_dev, ring->number, 617 return usb_ftdi_elan_edset_output(u132->platform_dev, ring->number,
617 endp, urb, address, endp->usb_endp, toggle_bits, callback); 618 endp, urb, address, endp->usb_endp, toggle_bits, callback);
618} 619}
619 620
620 621
@@ -623,683 +624,678 @@ static inline int edset_output(struct u132 *u132, struct u132_ring *ring,
623* 624*
624*/ 625*/
625static void u132_hcd_interrupt_recv(void *data, struct urb *urb, u8 *buf, 626static void u132_hcd_interrupt_recv(void *data, struct urb *urb, u8 *buf,
626 int len, int toggle_bits, int error_count, int condition_code, 627 int len, int toggle_bits, int error_count, int condition_code,
627 int repeat_number, int halted, int skipped, int actual, int non_null) 628 int repeat_number, int halted, int skipped, int actual, int non_null)
628{ 629{
629 struct u132_endp *endp = data; 630 struct u132_endp *endp = data;
630 struct u132 *u132 = endp->u132; 631 struct u132 *u132 = endp->u132;
631 u8 address = u132->addr[endp->usb_addr].address; 632 u8 address = u132->addr[endp->usb_addr].address;
632 struct u132_udev *udev = &u132->udev[address]; 633 struct u132_udev *udev = &u132->udev[address];
633 down(&u132->scheduler_lock); 634 mutex_lock(&u132->scheduler_lock);
634 if (u132->going > 1) { 635 if (u132->going > 1) {
635 dev_err(&u132->platform_dev->dev, "device has been removed %d\n" 636 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
636 , u132->going); 637 , u132->going);
637 up(&u132->scheduler_lock); 638 mutex_unlock(&u132->scheduler_lock);
638 u132_hcd_forget_urb(u132, endp, urb, -ENODEV); 639 u132_hcd_forget_urb(u132, endp, urb, -ENODEV);
639 return; 640 return;
640 } else if (endp->dequeueing) { 641 } else if (endp->dequeueing) {
641 endp->dequeueing = 0; 642 endp->dequeueing = 0;
642 up(&u132->scheduler_lock); 643 mutex_unlock(&u132->scheduler_lock);
643 u132_hcd_giveback_urb(u132, endp, urb, -EINTR); 644 u132_hcd_giveback_urb(u132, endp, urb, -EINTR);
644 return; 645 return;
645 } else if (u132->going > 0) { 646 } else if (u132->going > 0) {
646 dev_err(&u132->platform_dev->dev, "device is being removed " 647 dev_err(&u132->platform_dev->dev, "device is being removed "
647 "urb=%p\n", urb); 648 "urb=%p\n", urb);
648 up(&u132->scheduler_lock); 649 mutex_unlock(&u132->scheduler_lock);
649 u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); 650 u132_hcd_giveback_urb(u132, endp, urb, -ENODEV);
650 return; 651 return;
651 } else if (!urb->unlinked) { 652 } else if (!urb->unlinked) {
652 struct u132_ring *ring = endp->ring; 653 struct u132_ring *ring = endp->ring;
653 u8 *u = urb->transfer_buffer + urb->actual_length; 654 u8 *u = urb->transfer_buffer + urb->actual_length;
654 u8 *b = buf; 655 u8 *b = buf;
655 int L = len; 656 int L = len;
656 while (L-- > 0) { 657
657 *u++ = *b++; 658 while (L-- > 0)
658 } 659 *u++ = *b++;
659 urb->actual_length += len; 660
660 if ((condition_code == TD_CC_NOERROR) && 661 urb->actual_length += len;
661 (urb->transfer_buffer_length > urb->actual_length)) { 662 if ((condition_code == TD_CC_NOERROR) &&
662 endp->toggle_bits = toggle_bits; 663 (urb->transfer_buffer_length > urb->actual_length)) {
663 usb_settoggle(udev->usb_device, endp->usb_endp, 0, 664 endp->toggle_bits = toggle_bits;
664 1 & toggle_bits); 665 usb_settoggle(udev->usb_device, endp->usb_endp, 0,
665 if (urb->actual_length > 0) { 666 1 & toggle_bits);
666 int retval; 667 if (urb->actual_length > 0) {
667 up(&u132->scheduler_lock); 668 int retval;
668 retval = edset_single(u132, ring, endp, urb, 669 mutex_unlock(&u132->scheduler_lock);
669 address, endp->toggle_bits, 670 retval = edset_single(u132, ring, endp, urb,
670 u132_hcd_interrupt_recv); 671 address, endp->toggle_bits,
671 if (retval == 0) { 672 u132_hcd_interrupt_recv);
672 } else 673 if (retval != 0)
673 u132_hcd_giveback_urb(u132, endp, urb, 674 u132_hcd_giveback_urb(u132, endp, urb,
674 retval); 675 retval);
675 } else { 676 } else {
676 ring->in_use = 0; 677 ring->in_use = 0;
677 endp->active = 0; 678 endp->active = 0;
678 endp->jiffies = jiffies + 679 endp->jiffies = jiffies +
679 msecs_to_jiffies(urb->interval); 680 msecs_to_jiffies(urb->interval);
680 u132_ring_cancel_work(u132, ring); 681 u132_ring_cancel_work(u132, ring);
681 u132_ring_queue_work(u132, ring, 0); 682 u132_ring_queue_work(u132, ring, 0);
682 up(&u132->scheduler_lock); 683 mutex_unlock(&u132->scheduler_lock);
683 u132_endp_put_kref(u132, endp); 684 u132_endp_put_kref(u132, endp);
684 } 685 }
685 return; 686 return;
686 } else if ((condition_code == TD_DATAUNDERRUN) && 687 } else if ((condition_code == TD_DATAUNDERRUN) &&
687 ((urb->transfer_flags & URB_SHORT_NOT_OK) == 0)) { 688 ((urb->transfer_flags & URB_SHORT_NOT_OK) == 0)) {
688 endp->toggle_bits = toggle_bits; 689 endp->toggle_bits = toggle_bits;
689 usb_settoggle(udev->usb_device, endp->usb_endp, 0, 690 usb_settoggle(udev->usb_device, endp->usb_endp, 0,
690 1 & toggle_bits); 691 1 & toggle_bits);
691 up(&u132->scheduler_lock); 692 mutex_unlock(&u132->scheduler_lock);
692 u132_hcd_giveback_urb(u132, endp, urb, 0); 693 u132_hcd_giveback_urb(u132, endp, urb, 0);
693 return; 694 return;
694 } else { 695 } else {
695 if (condition_code == TD_CC_NOERROR) { 696 if (condition_code == TD_CC_NOERROR) {
696 endp->toggle_bits = toggle_bits; 697 endp->toggle_bits = toggle_bits;
697 usb_settoggle(udev->usb_device, endp->usb_endp, 698 usb_settoggle(udev->usb_device, endp->usb_endp,
698 0, 1 & toggle_bits); 699 0, 1 & toggle_bits);
699 } else if (condition_code == TD_CC_STALL) { 700 } else if (condition_code == TD_CC_STALL) {
700 endp->toggle_bits = 0x2; 701 endp->toggle_bits = 0x2;
701 usb_settoggle(udev->usb_device, endp->usb_endp, 702 usb_settoggle(udev->usb_device, endp->usb_endp,
702 0, 0); 703 0, 0);
703 } else { 704 } else {
704 endp->toggle_bits = 0x2; 705 endp->toggle_bits = 0x2;
705 usb_settoggle(udev->usb_device, endp->usb_endp, 706 usb_settoggle(udev->usb_device, endp->usb_endp,
706 0, 0); 707 0, 0);
707 dev_err(&u132->platform_dev->dev, "urb=%p givin" 708 dev_err(&u132->platform_dev->dev, "urb=%p givin"
708 "g back INTERRUPT %s\n", urb, 709 "g back INTERRUPT %s\n", urb,
709 cc_to_text[condition_code]); 710 cc_to_text[condition_code]);
710 } 711 }
711 up(&u132->scheduler_lock); 712 mutex_unlock(&u132->scheduler_lock);
712 u132_hcd_giveback_urb(u132, endp, urb, 713 u132_hcd_giveback_urb(u132, endp, urb,
713 cc_to_error[condition_code]); 714 cc_to_error[condition_code]);
714 return; 715 return;
715 } 716 }
716 } else { 717 } else {
717 dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " 718 dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p "
718 "unlinked=%d\n", urb, urb->unlinked); 719 "unlinked=%d\n", urb, urb->unlinked);
719 up(&u132->scheduler_lock); 720 mutex_unlock(&u132->scheduler_lock);
720 u132_hcd_giveback_urb(u132, endp, urb, 0); 721 u132_hcd_giveback_urb(u132, endp, urb, 0);
721 return; 722 return;
722 } 723 }
723} 724}
724 725
725static void u132_hcd_bulk_output_sent(void *data, struct urb *urb, u8 *buf, 726static void u132_hcd_bulk_output_sent(void *data, struct urb *urb, u8 *buf,
726 int len, int toggle_bits, int error_count, int condition_code, 727 int len, int toggle_bits, int error_count, int condition_code,
727 int repeat_number, int halted, int skipped, int actual, int non_null) 728 int repeat_number, int halted, int skipped, int actual, int non_null)
728{ 729{
729 struct u132_endp *endp = data; 730 struct u132_endp *endp = data;
730 struct u132 *u132 = endp->u132; 731 struct u132 *u132 = endp->u132;
731 u8 address = u132->addr[endp->usb_addr].address; 732 u8 address = u132->addr[endp->usb_addr].address;
732 down(&u132->scheduler_lock); 733 mutex_lock(&u132->scheduler_lock);
733 if (u132->going > 1) { 734 if (u132->going > 1) {
734 dev_err(&u132->platform_dev->dev, "device has been removed %d\n" 735 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
735 , u132->going); 736 , u132->going);
736 up(&u132->scheduler_lock); 737 mutex_unlock(&u132->scheduler_lock);
737 u132_hcd_forget_urb(u132, endp, urb, -ENODEV); 738 u132_hcd_forget_urb(u132, endp, urb, -ENODEV);
738 return; 739 return;
739 } else if (endp->dequeueing) { 740 } else if (endp->dequeueing) {
740 endp->dequeueing = 0; 741 endp->dequeueing = 0;
741 up(&u132->scheduler_lock); 742 mutex_unlock(&u132->scheduler_lock);
742 u132_hcd_giveback_urb(u132, endp, urb, -EINTR); 743 u132_hcd_giveback_urb(u132, endp, urb, -EINTR);
743 return; 744 return;
744 } else if (u132->going > 0) { 745 } else if (u132->going > 0) {
745 dev_err(&u132->platform_dev->dev, "device is being removed " 746 dev_err(&u132->platform_dev->dev, "device is being removed "
746 "urb=%p\n", urb); 747 "urb=%p\n", urb);
747 up(&u132->scheduler_lock); 748 mutex_unlock(&u132->scheduler_lock);
748 u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); 749 u132_hcd_giveback_urb(u132, endp, urb, -ENODEV);
749 return; 750 return;
750 } else if (!urb->unlinked) { 751 } else if (!urb->unlinked) {
751 struct u132_ring *ring = endp->ring; 752 struct u132_ring *ring = endp->ring;
752 urb->actual_length += len; 753 urb->actual_length += len;
753 endp->toggle_bits = toggle_bits; 754 endp->toggle_bits = toggle_bits;
754 if (urb->transfer_buffer_length > urb->actual_length) { 755 if (urb->transfer_buffer_length > urb->actual_length) {
755 int retval; 756 int retval;
756 up(&u132->scheduler_lock); 757 mutex_unlock(&u132->scheduler_lock);
757 retval = edset_output(u132, ring, endp, urb, address, 758 retval = edset_output(u132, ring, endp, urb, address,
758 endp->toggle_bits, u132_hcd_bulk_output_sent); 759 endp->toggle_bits, u132_hcd_bulk_output_sent);
759 if (retval == 0) { 760 if (retval != 0)
760 } else 761 u132_hcd_giveback_urb(u132, endp, urb, retval);
761 u132_hcd_giveback_urb(u132, endp, urb, retval); 762 return;
762 return; 763 } else {
763 } else { 764 mutex_unlock(&u132->scheduler_lock);
764 up(&u132->scheduler_lock); 765 u132_hcd_giveback_urb(u132, endp, urb, 0);
765 u132_hcd_giveback_urb(u132, endp, urb, 0); 766 return;
766 return; 767 }
767 } 768 } else {
768 } else {
769 dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " 769 dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p "
770 "unlinked=%d\n", urb, urb->unlinked); 770 "unlinked=%d\n", urb, urb->unlinked);
771 up(&u132->scheduler_lock); 771 mutex_unlock(&u132->scheduler_lock);
772 u132_hcd_giveback_urb(u132, endp, urb, 0); 772 u132_hcd_giveback_urb(u132, endp, urb, 0);
773 return; 773 return;
774 } 774 }
775} 775}
776 776
777static void u132_hcd_bulk_input_recv(void *data, struct urb *urb, u8 *buf, 777static void u132_hcd_bulk_input_recv(void *data, struct urb *urb, u8 *buf,
778 int len, int toggle_bits, int error_count, int condition_code, 778 int len, int toggle_bits, int error_count, int condition_code,
779 int repeat_number, int halted, int skipped, int actual, int non_null) 779 int repeat_number, int halted, int skipped, int actual, int non_null)
780{ 780{
781 struct u132_endp *endp = data; 781 struct u132_endp *endp = data;
782 struct u132 *u132 = endp->u132; 782 struct u132 *u132 = endp->u132;
783 u8 address = u132->addr[endp->usb_addr].address; 783 u8 address = u132->addr[endp->usb_addr].address;
784 struct u132_udev *udev = &u132->udev[address]; 784 struct u132_udev *udev = &u132->udev[address];
785 down(&u132->scheduler_lock); 785 mutex_lock(&u132->scheduler_lock);
786 if (u132->going > 1) { 786 if (u132->going > 1) {
787 dev_err(&u132->platform_dev->dev, "device has been removed %d\n" 787 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
788 , u132->going); 788 , u132->going);
789 up(&u132->scheduler_lock); 789 mutex_unlock(&u132->scheduler_lock);
790 u132_hcd_forget_urb(u132, endp, urb, -ENODEV); 790 u132_hcd_forget_urb(u132, endp, urb, -ENODEV);
791 return; 791 return;
792 } else if (endp->dequeueing) { 792 } else if (endp->dequeueing) {
793 endp->dequeueing = 0; 793 endp->dequeueing = 0;
794 up(&u132->scheduler_lock); 794 mutex_unlock(&u132->scheduler_lock);
795 u132_hcd_giveback_urb(u132, endp, urb, -EINTR); 795 u132_hcd_giveback_urb(u132, endp, urb, -EINTR);
796 return; 796 return;
797 } else if (u132->going > 0) { 797 } else if (u132->going > 0) {
798 dev_err(&u132->platform_dev->dev, "device is being removed " 798 dev_err(&u132->platform_dev->dev, "device is being removed "
799 "urb=%p\n", urb); 799 "urb=%p\n", urb);
800 up(&u132->scheduler_lock); 800 mutex_unlock(&u132->scheduler_lock);
801 u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); 801 u132_hcd_giveback_urb(u132, endp, urb, -ENODEV);
802 return; 802 return;
803 } else if (!urb->unlinked) { 803 } else if (!urb->unlinked) {
804 struct u132_ring *ring = endp->ring; 804 struct u132_ring *ring = endp->ring;
805 u8 *u = urb->transfer_buffer + urb->actual_length; 805 u8 *u = urb->transfer_buffer + urb->actual_length;
806 u8 *b = buf; 806 u8 *b = buf;
807 int L = len; 807 int L = len;
808 while (L-- > 0) { 808
809 *u++ = *b++; 809 while (L-- > 0)
810 } 810 *u++ = *b++;
811 urb->actual_length += len; 811
812 if ((condition_code == TD_CC_NOERROR) && 812 urb->actual_length += len;
813 (urb->transfer_buffer_length > urb->actual_length)) { 813 if ((condition_code == TD_CC_NOERROR) &&
814 int retval; 814 (urb->transfer_buffer_length > urb->actual_length)) {
815 endp->toggle_bits = toggle_bits; 815 int retval;
816 usb_settoggle(udev->usb_device, endp->usb_endp, 0, 816 endp->toggle_bits = toggle_bits;
817 1 & toggle_bits); 817 usb_settoggle(udev->usb_device, endp->usb_endp, 0,
818 up(&u132->scheduler_lock); 818 1 & toggle_bits);
819 retval = usb_ftdi_elan_edset_input(u132->platform_dev, 819 mutex_unlock(&u132->scheduler_lock);
820 ring->number, endp, urb, address, 820 retval = usb_ftdi_elan_edset_input(u132->platform_dev,
821 endp->usb_endp, endp->toggle_bits, 821 ring->number, endp, urb, address,
822 u132_hcd_bulk_input_recv); 822 endp->usb_endp, endp->toggle_bits,
823 if (retval == 0) { 823 u132_hcd_bulk_input_recv);
824 } else 824 if (retval != 0)
825 u132_hcd_giveback_urb(u132, endp, urb, retval); 825 u132_hcd_giveback_urb(u132, endp, urb, retval);
826 return; 826 return;
827 } else if (condition_code == TD_CC_NOERROR) { 827 } else if (condition_code == TD_CC_NOERROR) {
828 endp->toggle_bits = toggle_bits; 828 endp->toggle_bits = toggle_bits;
829 usb_settoggle(udev->usb_device, endp->usb_endp, 0, 829 usb_settoggle(udev->usb_device, endp->usb_endp, 0,
830 1 & toggle_bits); 830 1 & toggle_bits);
831 up(&u132->scheduler_lock); 831 mutex_unlock(&u132->scheduler_lock);
832 u132_hcd_giveback_urb(u132, endp, urb, 832 u132_hcd_giveback_urb(u132, endp, urb,
833 cc_to_error[condition_code]); 833 cc_to_error[condition_code]);
834 return; 834 return;
835 } else if ((condition_code == TD_DATAUNDERRUN) && 835 } else if ((condition_code == TD_DATAUNDERRUN) &&
836 ((urb->transfer_flags & URB_SHORT_NOT_OK) == 0)) { 836 ((urb->transfer_flags & URB_SHORT_NOT_OK) == 0)) {
837 endp->toggle_bits = toggle_bits; 837 endp->toggle_bits = toggle_bits;
838 usb_settoggle(udev->usb_device, endp->usb_endp, 0, 838 usb_settoggle(udev->usb_device, endp->usb_endp, 0,
839 1 & toggle_bits); 839 1 & toggle_bits);
840 up(&u132->scheduler_lock); 840 mutex_unlock(&u132->scheduler_lock);
841 u132_hcd_giveback_urb(u132, endp, urb, 0); 841 u132_hcd_giveback_urb(u132, endp, urb, 0);
842 return; 842 return;
843 } else if (condition_code == TD_DATAUNDERRUN) { 843 } else if (condition_code == TD_DATAUNDERRUN) {
844 endp->toggle_bits = toggle_bits; 844 endp->toggle_bits = toggle_bits;
845 usb_settoggle(udev->usb_device, endp->usb_endp, 0, 845 usb_settoggle(udev->usb_device, endp->usb_endp, 0,
846 1 & toggle_bits); 846 1 & toggle_bits);
847 dev_warn(&u132->platform_dev->dev, "urb=%p(SHORT NOT OK" 847 dev_warn(&u132->platform_dev->dev, "urb=%p(SHORT NOT OK"
848 ") giving back BULK IN %s\n", urb, 848 ") giving back BULK IN %s\n", urb,
849 cc_to_text[condition_code]); 849 cc_to_text[condition_code]);
850 up(&u132->scheduler_lock); 850 mutex_unlock(&u132->scheduler_lock);
851 u132_hcd_giveback_urb(u132, endp, urb, 0); 851 u132_hcd_giveback_urb(u132, endp, urb, 0);
852 return; 852 return;
853 } else if (condition_code == TD_CC_STALL) { 853 } else if (condition_code == TD_CC_STALL) {
854 endp->toggle_bits = 0x2; 854 endp->toggle_bits = 0x2;
855 usb_settoggle(udev->usb_device, endp->usb_endp, 0, 0); 855 usb_settoggle(udev->usb_device, endp->usb_endp, 0, 0);
856 up(&u132->scheduler_lock); 856 mutex_unlock(&u132->scheduler_lock);
857 u132_hcd_giveback_urb(u132, endp, urb, 857 u132_hcd_giveback_urb(u132, endp, urb,
858 cc_to_error[condition_code]); 858 cc_to_error[condition_code]);
859 return; 859 return;
860 } else { 860 } else {
861 endp->toggle_bits = 0x2; 861 endp->toggle_bits = 0x2;
862 usb_settoggle(udev->usb_device, endp->usb_endp, 0, 0); 862 usb_settoggle(udev->usb_device, endp->usb_endp, 0, 0);
863 dev_err(&u132->platform_dev->dev, "urb=%p giving back B" 863 dev_err(&u132->platform_dev->dev, "urb=%p giving back B"
864 "ULK IN code=%d %s\n", urb, condition_code, 864 "ULK IN code=%d %s\n", urb, condition_code,
865 cc_to_text[condition_code]); 865 cc_to_text[condition_code]);
866 up(&u132->scheduler_lock); 866 mutex_unlock(&u132->scheduler_lock);
867 u132_hcd_giveback_urb(u132, endp, urb, 867 u132_hcd_giveback_urb(u132, endp, urb,
868 cc_to_error[condition_code]); 868 cc_to_error[condition_code]);
869 return; 869 return;
870 } 870 }
871 } else { 871 } else {
872 dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " 872 dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p "
873 "unlinked=%d\n", urb, urb->unlinked); 873 "unlinked=%d\n", urb, urb->unlinked);
874 up(&u132->scheduler_lock); 874 mutex_unlock(&u132->scheduler_lock);
875 u132_hcd_giveback_urb(u132, endp, urb, 0); 875 u132_hcd_giveback_urb(u132, endp, urb, 0);
876 return; 876 return;
877 } 877 }
878} 878}
879 879
880static void u132_hcd_configure_empty_sent(void *data, struct urb *urb, u8 *buf, 880static void u132_hcd_configure_empty_sent(void *data, struct urb *urb, u8 *buf,
881 int len, int toggle_bits, int error_count, int condition_code, 881 int len, int toggle_bits, int error_count, int condition_code,
882 int repeat_number, int halted, int skipped, int actual, int non_null) 882 int repeat_number, int halted, int skipped, int actual, int non_null)
883{ 883{
884 struct u132_endp *endp = data; 884 struct u132_endp *endp = data;
885 struct u132 *u132 = endp->u132; 885 struct u132 *u132 = endp->u132;
886 down(&u132->scheduler_lock); 886 mutex_lock(&u132->scheduler_lock);
887 if (u132->going > 1) { 887 if (u132->going > 1) {
888 dev_err(&u132->platform_dev->dev, "device has been removed %d\n" 888 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
889 , u132->going); 889 , u132->going);
890 up(&u132->scheduler_lock); 890 mutex_unlock(&u132->scheduler_lock);
891 u132_hcd_forget_urb(u132, endp, urb, -ENODEV); 891 u132_hcd_forget_urb(u132, endp, urb, -ENODEV);
892 return; 892 return;
893 } else if (endp->dequeueing) { 893 } else if (endp->dequeueing) {
894 endp->dequeueing = 0; 894 endp->dequeueing = 0;
895 up(&u132->scheduler_lock); 895 mutex_unlock(&u132->scheduler_lock);
896 u132_hcd_giveback_urb(u132, endp, urb, -EINTR); 896 u132_hcd_giveback_urb(u132, endp, urb, -EINTR);
897 return; 897 return;
898 } else if (u132->going > 0) { 898 } else if (u132->going > 0) {
899 dev_err(&u132->platform_dev->dev, "device is being removed " 899 dev_err(&u132->platform_dev->dev, "device is being removed "
900 "urb=%p\n", urb); 900 "urb=%p\n", urb);
901 up(&u132->scheduler_lock); 901 mutex_unlock(&u132->scheduler_lock);
902 u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); 902 u132_hcd_giveback_urb(u132, endp, urb, -ENODEV);
903 return; 903 return;
904 } else if (!urb->unlinked) { 904 } else if (!urb->unlinked) {
905 up(&u132->scheduler_lock); 905 mutex_unlock(&u132->scheduler_lock);
906 u132_hcd_giveback_urb(u132, endp, urb, 0); 906 u132_hcd_giveback_urb(u132, endp, urb, 0);
907 return; 907 return;
908 } else { 908 } else {
909 dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " 909 dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p "
910 "unlinked=%d\n", urb, urb->unlinked); 910 "unlinked=%d\n", urb, urb->unlinked);
911 up(&u132->scheduler_lock); 911 mutex_unlock(&u132->scheduler_lock);
912 u132_hcd_giveback_urb(u132, endp, urb, 0); 912 u132_hcd_giveback_urb(u132, endp, urb, 0);
913 return; 913 return;
914 } 914 }
915} 915}
916 916
917static void u132_hcd_configure_input_recv(void *data, struct urb *urb, u8 *buf, 917static void u132_hcd_configure_input_recv(void *data, struct urb *urb, u8 *buf,
918 int len, int toggle_bits, int error_count, int condition_code, 918 int len, int toggle_bits, int error_count, int condition_code,
919 int repeat_number, int halted, int skipped, int actual, int non_null) 919 int repeat_number, int halted, int skipped, int actual, int non_null)
920{ 920{
921 struct u132_endp *endp = data; 921 struct u132_endp *endp = data;
922 struct u132 *u132 = endp->u132; 922 struct u132 *u132 = endp->u132;
923 u8 address = u132->addr[endp->usb_addr].address; 923 u8 address = u132->addr[endp->usb_addr].address;
924 down(&u132->scheduler_lock); 924 mutex_lock(&u132->scheduler_lock);
925 if (u132->going > 1) { 925 if (u132->going > 1) {
926 dev_err(&u132->platform_dev->dev, "device has been removed %d\n" 926 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
927 , u132->going); 927 , u132->going);
928 up(&u132->scheduler_lock); 928 mutex_unlock(&u132->scheduler_lock);
929 u132_hcd_forget_urb(u132, endp, urb, -ENODEV); 929 u132_hcd_forget_urb(u132, endp, urb, -ENODEV);
930 return; 930 return;
931 } else if (endp->dequeueing) { 931 } else if (endp->dequeueing) {
932 endp->dequeueing = 0; 932 endp->dequeueing = 0;
933 up(&u132->scheduler_lock); 933 mutex_unlock(&u132->scheduler_lock);
934 u132_hcd_giveback_urb(u132, endp, urb, -EINTR); 934 u132_hcd_giveback_urb(u132, endp, urb, -EINTR);
935 return; 935 return;
936 } else if (u132->going > 0) { 936 } else if (u132->going > 0) {
937 dev_err(&u132->platform_dev->dev, "device is being removed " 937 dev_err(&u132->platform_dev->dev, "device is being removed "
938 "urb=%p\n", urb); 938 "urb=%p\n", urb);
939 up(&u132->scheduler_lock); 939 mutex_unlock(&u132->scheduler_lock);
940 u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); 940 u132_hcd_giveback_urb(u132, endp, urb, -ENODEV);
941 return; 941 return;
942 } else if (!urb->unlinked) { 942 } else if (!urb->unlinked) {
943 struct u132_ring *ring = endp->ring; 943 struct u132_ring *ring = endp->ring;
944 u8 *u = urb->transfer_buffer; 944 u8 *u = urb->transfer_buffer;
945 u8 *b = buf; 945 u8 *b = buf;
946 int L = len; 946 int L = len;
947 while (L-- > 0) { 947
948 *u++ = *b++; 948 while (L-- > 0)
949 } 949 *u++ = *b++;
950 urb->actual_length = len; 950
951 if ((condition_code == TD_CC_NOERROR) || ((condition_code == 951 urb->actual_length = len;
952 TD_DATAUNDERRUN) && ((urb->transfer_flags & 952 if ((condition_code == TD_CC_NOERROR) || ((condition_code ==
953 URB_SHORT_NOT_OK) == 0))) { 953 TD_DATAUNDERRUN) && ((urb->transfer_flags &
954 int retval; 954 URB_SHORT_NOT_OK) == 0))) {
955 up(&u132->scheduler_lock); 955 int retval;
956 retval = usb_ftdi_elan_edset_empty(u132->platform_dev, 956 mutex_unlock(&u132->scheduler_lock);
957 ring->number, endp, urb, address, 957 retval = usb_ftdi_elan_edset_empty(u132->platform_dev,
958 endp->usb_endp, 0x3, 958 ring->number, endp, urb, address,
959 u132_hcd_configure_empty_sent); 959 endp->usb_endp, 0x3,
960 if (retval == 0) { 960 u132_hcd_configure_empty_sent);
961 } else 961 if (retval != 0)
962 u132_hcd_giveback_urb(u132, endp, urb, retval); 962 u132_hcd_giveback_urb(u132, endp, urb, retval);
963 return; 963 return;
964 } else if (condition_code == TD_CC_STALL) { 964 } else if (condition_code == TD_CC_STALL) {
965 up(&u132->scheduler_lock); 965 mutex_unlock(&u132->scheduler_lock);
966 dev_warn(&u132->platform_dev->dev, "giving back SETUP I" 966 dev_warn(&u132->platform_dev->dev, "giving back SETUP I"
967 "NPUT STALL urb %p\n", urb); 967 "NPUT STALL urb %p\n", urb);
968 u132_hcd_giveback_urb(u132, endp, urb, 968 u132_hcd_giveback_urb(u132, endp, urb,
969 cc_to_error[condition_code]); 969 cc_to_error[condition_code]);
970 return; 970 return;
971 } else { 971 } else {
972 up(&u132->scheduler_lock); 972 mutex_unlock(&u132->scheduler_lock);
973 dev_err(&u132->platform_dev->dev, "giving back SETUP IN" 973 dev_err(&u132->platform_dev->dev, "giving back SETUP IN"
974 "PUT %s urb %p\n", cc_to_text[condition_code], 974 "PUT %s urb %p\n", cc_to_text[condition_code],
975 urb); 975 urb);
976 u132_hcd_giveback_urb(u132, endp, urb, 976 u132_hcd_giveback_urb(u132, endp, urb,
977 cc_to_error[condition_code]); 977 cc_to_error[condition_code]);
978 return; 978 return;
979 } 979 }
980 } else { 980 } else {
981 dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " 981 dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p "
982 "unlinked=%d\n", urb, urb->unlinked); 982 "unlinked=%d\n", urb, urb->unlinked);
983 up(&u132->scheduler_lock); 983 mutex_unlock(&u132->scheduler_lock);
984 u132_hcd_giveback_urb(u132, endp, urb, 0); 984 u132_hcd_giveback_urb(u132, endp, urb, 0);
985 return; 985 return;
986 } 986 }
987} 987}
988 988
989static void u132_hcd_configure_empty_recv(void *data, struct urb *urb, u8 *buf, 989static void u132_hcd_configure_empty_recv(void *data, struct urb *urb, u8 *buf,
990 int len, int toggle_bits, int error_count, int condition_code, 990 int len, int toggle_bits, int error_count, int condition_code,
991 int repeat_number, int halted, int skipped, int actual, int non_null) 991 int repeat_number, int halted, int skipped, int actual, int non_null)
992{ 992{
993 struct u132_endp *endp = data; 993 struct u132_endp *endp = data;
994 struct u132 *u132 = endp->u132; 994 struct u132 *u132 = endp->u132;
995 down(&u132->scheduler_lock); 995 mutex_lock(&u132->scheduler_lock);
996 if (u132->going > 1) { 996 if (u132->going > 1) {
997 dev_err(&u132->platform_dev->dev, "device has been removed %d\n" 997 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
998 , u132->going); 998 , u132->going);
999 up(&u132->scheduler_lock); 999 mutex_unlock(&u132->scheduler_lock);
1000 u132_hcd_forget_urb(u132, endp, urb, -ENODEV); 1000 u132_hcd_forget_urb(u132, endp, urb, -ENODEV);
1001 return; 1001 return;
1002 } else if (endp->dequeueing) { 1002 } else if (endp->dequeueing) {
1003 endp->dequeueing = 0; 1003 endp->dequeueing = 0;
1004 up(&u132->scheduler_lock); 1004 mutex_unlock(&u132->scheduler_lock);
1005 u132_hcd_giveback_urb(u132, endp, urb, -EINTR); 1005 u132_hcd_giveback_urb(u132, endp, urb, -EINTR);
1006 return; 1006 return;
1007 } else if (u132->going > 0) { 1007 } else if (u132->going > 0) {
1008 dev_err(&u132->platform_dev->dev, "device is being removed " 1008 dev_err(&u132->platform_dev->dev, "device is being removed "
1009 "urb=%p\n", urb); 1009 "urb=%p\n", urb);
1010 up(&u132->scheduler_lock); 1010 mutex_unlock(&u132->scheduler_lock);
1011 u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); 1011 u132_hcd_giveback_urb(u132, endp, urb, -ENODEV);
1012 return; 1012 return;
1013 } else if (!urb->unlinked) { 1013 } else if (!urb->unlinked) {
1014 up(&u132->scheduler_lock); 1014 mutex_unlock(&u132->scheduler_lock);
1015 u132_hcd_giveback_urb(u132, endp, urb, 0); 1015 u132_hcd_giveback_urb(u132, endp, urb, 0);
1016 return; 1016 return;
1017 } else { 1017 } else {
1018 dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " 1018 dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p "
1019 "unlinked=%d\n", urb, urb->unlinked); 1019 "unlinked=%d\n", urb, urb->unlinked);
1020 up(&u132->scheduler_lock); 1020 mutex_unlock(&u132->scheduler_lock);
1021 u132_hcd_giveback_urb(u132, endp, urb, 0); 1021 u132_hcd_giveback_urb(u132, endp, urb, 0);
1022 return; 1022 return;
1023 } 1023 }
1024} 1024}
1025 1025
1026static void u132_hcd_configure_setup_sent(void *data, struct urb *urb, u8 *buf, 1026static void u132_hcd_configure_setup_sent(void *data, struct urb *urb, u8 *buf,
1027 int len, int toggle_bits, int error_count, int condition_code, 1027 int len, int toggle_bits, int error_count, int condition_code,
1028 int repeat_number, int halted, int skipped, int actual, int non_null) 1028 int repeat_number, int halted, int skipped, int actual, int non_null)
1029{ 1029{
1030 struct u132_endp *endp = data; 1030 struct u132_endp *endp = data;
1031 struct u132 *u132 = endp->u132; 1031 struct u132 *u132 = endp->u132;
1032 u8 address = u132->addr[endp->usb_addr].address; 1032 u8 address = u132->addr[endp->usb_addr].address;
1033 down(&u132->scheduler_lock); 1033 mutex_lock(&u132->scheduler_lock);
1034 if (u132->going > 1) { 1034 if (u132->going > 1) {
1035 dev_err(&u132->platform_dev->dev, "device has been removed %d\n" 1035 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
1036 , u132->going); 1036 , u132->going);
1037 up(&u132->scheduler_lock); 1037 mutex_unlock(&u132->scheduler_lock);
1038 u132_hcd_forget_urb(u132, endp, urb, -ENODEV); 1038 u132_hcd_forget_urb(u132, endp, urb, -ENODEV);
1039 return; 1039 return;
1040 } else if (endp->dequeueing) { 1040 } else if (endp->dequeueing) {
1041 endp->dequeueing = 0; 1041 endp->dequeueing = 0;
1042 up(&u132->scheduler_lock); 1042 mutex_unlock(&u132->scheduler_lock);
1043 u132_hcd_giveback_urb(u132, endp, urb, -EINTR); 1043 u132_hcd_giveback_urb(u132, endp, urb, -EINTR);
1044 return; 1044 return;
1045 } else if (u132->going > 0) { 1045 } else if (u132->going > 0) {
1046 dev_err(&u132->platform_dev->dev, "device is being removed " 1046 dev_err(&u132->platform_dev->dev, "device is being removed "
1047 "urb=%p\n", urb); 1047 "urb=%p\n", urb);
1048 up(&u132->scheduler_lock); 1048 mutex_unlock(&u132->scheduler_lock);
1049 u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); 1049 u132_hcd_giveback_urb(u132, endp, urb, -ENODEV);
1050 return; 1050 return;
1051 } else if (!urb->unlinked) { 1051 } else if (!urb->unlinked) {
1052 if (usb_pipein(urb->pipe)) { 1052 if (usb_pipein(urb->pipe)) {
1053 int retval; 1053 int retval;
1054 struct u132_ring *ring = endp->ring; 1054 struct u132_ring *ring = endp->ring;
1055 up(&u132->scheduler_lock); 1055 mutex_unlock(&u132->scheduler_lock);
1056 retval = usb_ftdi_elan_edset_input(u132->platform_dev, 1056 retval = usb_ftdi_elan_edset_input(u132->platform_dev,
1057 ring->number, endp, urb, address, 1057 ring->number, endp, urb, address,
1058 endp->usb_endp, 0, 1058 endp->usb_endp, 0,
1059 u132_hcd_configure_input_recv); 1059 u132_hcd_configure_input_recv);
1060 if (retval == 0) { 1060 if (retval != 0)
1061 } else 1061 u132_hcd_giveback_urb(u132, endp, urb, retval);
1062 u132_hcd_giveback_urb(u132, endp, urb, retval); 1062 return;
1063 return; 1063 } else {
1064 } else { 1064 int retval;
1065 int retval; 1065 struct u132_ring *ring = endp->ring;
1066 struct u132_ring *ring = endp->ring; 1066 mutex_unlock(&u132->scheduler_lock);
1067 up(&u132->scheduler_lock); 1067 retval = usb_ftdi_elan_edset_input(u132->platform_dev,
1068 retval = usb_ftdi_elan_edset_input(u132->platform_dev, 1068 ring->number, endp, urb, address,
1069 ring->number, endp, urb, address, 1069 endp->usb_endp, 0,
1070 endp->usb_endp, 0, 1070 u132_hcd_configure_empty_recv);
1071 u132_hcd_configure_empty_recv); 1071 if (retval != 0)
1072 if (retval == 0) { 1072 u132_hcd_giveback_urb(u132, endp, urb, retval);
1073 } else 1073 return;
1074 u132_hcd_giveback_urb(u132, endp, urb, retval); 1074 }
1075 return; 1075 } else {
1076 }
1077 } else {
1078 dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " 1076 dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p "
1079 "unlinked=%d\n", urb, urb->unlinked); 1077 "unlinked=%d\n", urb, urb->unlinked);
1080 up(&u132->scheduler_lock); 1078 mutex_unlock(&u132->scheduler_lock);
1081 u132_hcd_giveback_urb(u132, endp, urb, 0); 1079 u132_hcd_giveback_urb(u132, endp, urb, 0);
1082 return; 1080 return;
1083 } 1081 }
1084} 1082}
1085 1083
1086static void u132_hcd_enumeration_empty_recv(void *data, struct urb *urb, 1084static void u132_hcd_enumeration_empty_recv(void *data, struct urb *urb,
1087 u8 *buf, int len, int toggle_bits, int error_count, int condition_code, 1085 u8 *buf, int len, int toggle_bits, int error_count, int condition_code,
1088 int repeat_number, int halted, int skipped, int actual, int non_null) 1086 int repeat_number, int halted, int skipped, int actual, int non_null)
1089{ 1087{
1090 struct u132_endp *endp = data; 1088 struct u132_endp *endp = data;
1091 struct u132 *u132 = endp->u132; 1089 struct u132 *u132 = endp->u132;
1092 u8 address = u132->addr[endp->usb_addr].address; 1090 u8 address = u132->addr[endp->usb_addr].address;
1093 struct u132_udev *udev = &u132->udev[address]; 1091 struct u132_udev *udev = &u132->udev[address];
1094 down(&u132->scheduler_lock); 1092 mutex_lock(&u132->scheduler_lock);
1095 if (u132->going > 1) { 1093 if (u132->going > 1) {
1096 dev_err(&u132->platform_dev->dev, "device has been removed %d\n" 1094 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
1097 , u132->going); 1095 , u132->going);
1098 up(&u132->scheduler_lock); 1096 mutex_unlock(&u132->scheduler_lock);
1099 u132_hcd_forget_urb(u132, endp, urb, -ENODEV); 1097 u132_hcd_forget_urb(u132, endp, urb, -ENODEV);
1100 return; 1098 return;
1101 } else if (endp->dequeueing) { 1099 } else if (endp->dequeueing) {
1102 endp->dequeueing = 0; 1100 endp->dequeueing = 0;
1103 up(&u132->scheduler_lock); 1101 mutex_unlock(&u132->scheduler_lock);
1104 u132_hcd_giveback_urb(u132, endp, urb, -EINTR); 1102 u132_hcd_giveback_urb(u132, endp, urb, -EINTR);
1105 return; 1103 return;
1106 } else if (u132->going > 0) { 1104 } else if (u132->going > 0) {
1107 dev_err(&u132->platform_dev->dev, "device is being removed " 1105 dev_err(&u132->platform_dev->dev, "device is being removed "
1108 "urb=%p\n", urb); 1106 "urb=%p\n", urb);
1109 up(&u132->scheduler_lock); 1107 mutex_unlock(&u132->scheduler_lock);
1110 u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); 1108 u132_hcd_giveback_urb(u132, endp, urb, -ENODEV);
1111 return; 1109 return;
1112 } else if (!urb->unlinked) { 1110 } else if (!urb->unlinked) {
1113 u132->addr[0].address = 0; 1111 u132->addr[0].address = 0;
1114 endp->usb_addr = udev->usb_addr; 1112 endp->usb_addr = udev->usb_addr;
1115 up(&u132->scheduler_lock); 1113 mutex_unlock(&u132->scheduler_lock);
1116 u132_hcd_giveback_urb(u132, endp, urb, 0); 1114 u132_hcd_giveback_urb(u132, endp, urb, 0);
1117 return; 1115 return;
1118 } else { 1116 } else {
1119 dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " 1117 dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p "
1120 "unlinked=%d\n", urb, urb->unlinked); 1118 "unlinked=%d\n", urb, urb->unlinked);
1121 up(&u132->scheduler_lock); 1119 mutex_unlock(&u132->scheduler_lock);
1122 u132_hcd_giveback_urb(u132, endp, urb, 0); 1120 u132_hcd_giveback_urb(u132, endp, urb, 0);
1123 return; 1121 return;
1124 } 1122 }
1125} 1123}
1126 1124
1127static void u132_hcd_enumeration_address_sent(void *data, struct urb *urb, 1125static void u132_hcd_enumeration_address_sent(void *data, struct urb *urb,
1128 u8 *buf, int len, int toggle_bits, int error_count, int condition_code, 1126 u8 *buf, int len, int toggle_bits, int error_count, int condition_code,
1129 int repeat_number, int halted, int skipped, int actual, int non_null) 1127 int repeat_number, int halted, int skipped, int actual, int non_null)
1130{ 1128{
1131 struct u132_endp *endp = data; 1129 struct u132_endp *endp = data;
1132 struct u132 *u132 = endp->u132; 1130 struct u132 *u132 = endp->u132;
1133 down(&u132->scheduler_lock); 1131 mutex_lock(&u132->scheduler_lock);
1134 if (u132->going > 1) { 1132 if (u132->going > 1) {
1135 dev_err(&u132->platform_dev->dev, "device has been removed %d\n" 1133 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
1136 , u132->going); 1134 , u132->going);
1137 up(&u132->scheduler_lock); 1135 mutex_unlock(&u132->scheduler_lock);
1138 u132_hcd_forget_urb(u132, endp, urb, -ENODEV); 1136 u132_hcd_forget_urb(u132, endp, urb, -ENODEV);
1139 return; 1137 return;
1140 } else if (endp->dequeueing) { 1138 } else if (endp->dequeueing) {
1141 endp->dequeueing = 0; 1139 endp->dequeueing = 0;
1142 up(&u132->scheduler_lock); 1140 mutex_unlock(&u132->scheduler_lock);
1143 u132_hcd_giveback_urb(u132, endp, urb, -EINTR); 1141 u132_hcd_giveback_urb(u132, endp, urb, -EINTR);
1144 return; 1142 return;
1145 } else if (u132->going > 0) { 1143 } else if (u132->going > 0) {
1146 dev_err(&u132->platform_dev->dev, "device is being removed " 1144 dev_err(&u132->platform_dev->dev, "device is being removed "
1147 "urb=%p\n", urb); 1145 "urb=%p\n", urb);
1148 up(&u132->scheduler_lock); 1146 mutex_unlock(&u132->scheduler_lock);
1149 u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); 1147 u132_hcd_giveback_urb(u132, endp, urb, -ENODEV);
1150 return; 1148 return;
1151 } else if (!urb->unlinked) { 1149 } else if (!urb->unlinked) {
1152 int retval; 1150 int retval;
1153 struct u132_ring *ring = endp->ring; 1151 struct u132_ring *ring = endp->ring;
1154 up(&u132->scheduler_lock); 1152 mutex_unlock(&u132->scheduler_lock);
1155 retval = usb_ftdi_elan_edset_input(u132->platform_dev, 1153 retval = usb_ftdi_elan_edset_input(u132->platform_dev,
1156 ring->number, endp, urb, 0, endp->usb_endp, 0, 1154 ring->number, endp, urb, 0, endp->usb_endp, 0,
1157 u132_hcd_enumeration_empty_recv); 1155 u132_hcd_enumeration_empty_recv);
1158 if (retval == 0) { 1156 if (retval != 0)
1159 } else 1157 u132_hcd_giveback_urb(u132, endp, urb, retval);
1160 u132_hcd_giveback_urb(u132, endp, urb, retval); 1158 return;
1161 return; 1159 } else {
1162 } else {
1163 dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " 1160 dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p "
1164 "unlinked=%d\n", urb, urb->unlinked); 1161 "unlinked=%d\n", urb, urb->unlinked);
1165 up(&u132->scheduler_lock); 1162 mutex_unlock(&u132->scheduler_lock);
1166 u132_hcd_giveback_urb(u132, endp, urb, 0); 1163 u132_hcd_giveback_urb(u132, endp, urb, 0);
1167 return; 1164 return;
1168 } 1165 }
1169} 1166}
1170 1167
1171static void u132_hcd_initial_empty_sent(void *data, struct urb *urb, u8 *buf, 1168static void u132_hcd_initial_empty_sent(void *data, struct urb *urb, u8 *buf,
1172 int len, int toggle_bits, int error_count, int condition_code, 1169 int len, int toggle_bits, int error_count, int condition_code,
1173 int repeat_number, int halted, int skipped, int actual, int non_null) 1170 int repeat_number, int halted, int skipped, int actual, int non_null)
1174{ 1171{
1175 struct u132_endp *endp = data; 1172 struct u132_endp *endp = data;
1176 struct u132 *u132 = endp->u132; 1173 struct u132 *u132 = endp->u132;
1177 down(&u132->scheduler_lock); 1174 mutex_lock(&u132->scheduler_lock);
1178 if (u132->going > 1) { 1175 if (u132->going > 1) {
1179 dev_err(&u132->platform_dev->dev, "device has been removed %d\n" 1176 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
1180 , u132->going); 1177 , u132->going);
1181 up(&u132->scheduler_lock); 1178 mutex_unlock(&u132->scheduler_lock);
1182 u132_hcd_forget_urb(u132, endp, urb, -ENODEV); 1179 u132_hcd_forget_urb(u132, endp, urb, -ENODEV);
1183 return; 1180 return;
1184 } else if (endp->dequeueing) { 1181 } else if (endp->dequeueing) {
1185 endp->dequeueing = 0; 1182 endp->dequeueing = 0;
1186 up(&u132->scheduler_lock); 1183 mutex_unlock(&u132->scheduler_lock);
1187 u132_hcd_giveback_urb(u132, endp, urb, -EINTR); 1184 u132_hcd_giveback_urb(u132, endp, urb, -EINTR);
1188 return; 1185 return;
1189 } else if (u132->going > 0) { 1186 } else if (u132->going > 0) {
1190 dev_err(&u132->platform_dev->dev, "device is being removed " 1187 dev_err(&u132->platform_dev->dev, "device is being removed "
1191 "urb=%p\n", urb); 1188 "urb=%p\n", urb);
1192 up(&u132->scheduler_lock); 1189 mutex_unlock(&u132->scheduler_lock);
1193 u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); 1190 u132_hcd_giveback_urb(u132, endp, urb, -ENODEV);
1194 return; 1191 return;
1195 } else if (!urb->unlinked) { 1192 } else if (!urb->unlinked) {
1196 up(&u132->scheduler_lock); 1193 mutex_unlock(&u132->scheduler_lock);
1197 u132_hcd_giveback_urb(u132, endp, urb, 0); 1194 u132_hcd_giveback_urb(u132, endp, urb, 0);
1198 return; 1195 return;
1199 } else { 1196 } else {
1200 dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " 1197 dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p "
1201 "unlinked=%d\n", urb, urb->unlinked); 1198 "unlinked=%d\n", urb, urb->unlinked);
1202 up(&u132->scheduler_lock); 1199 mutex_unlock(&u132->scheduler_lock);
1203 u132_hcd_giveback_urb(u132, endp, urb, 0); 1200 u132_hcd_giveback_urb(u132, endp, urb, 0);
1204 return; 1201 return;
1205 } 1202 }
1206} 1203}
1207 1204
1208static void u132_hcd_initial_input_recv(void *data, struct urb *urb, u8 *buf, 1205static void u132_hcd_initial_input_recv(void *data, struct urb *urb, u8 *buf,
1209 int len, int toggle_bits, int error_count, int condition_code, 1206 int len, int toggle_bits, int error_count, int condition_code,
1210 int repeat_number, int halted, int skipped, int actual, int non_null) 1207 int repeat_number, int halted, int skipped, int actual, int non_null)
1211{ 1208{
1212 struct u132_endp *endp = data; 1209 struct u132_endp *endp = data;
1213 struct u132 *u132 = endp->u132; 1210 struct u132 *u132 = endp->u132;
1214 u8 address = u132->addr[endp->usb_addr].address; 1211 u8 address = u132->addr[endp->usb_addr].address;
1215 down(&u132->scheduler_lock); 1212 mutex_lock(&u132->scheduler_lock);
1216 if (u132->going > 1) { 1213 if (u132->going > 1) {
1217 dev_err(&u132->platform_dev->dev, "device has been removed %d\n" 1214 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
1218 , u132->going); 1215 , u132->going);
1219 up(&u132->scheduler_lock); 1216 mutex_unlock(&u132->scheduler_lock);
1220 u132_hcd_forget_urb(u132, endp, urb, -ENODEV); 1217 u132_hcd_forget_urb(u132, endp, urb, -ENODEV);
1221 return; 1218 return;
1222 } else if (endp->dequeueing) { 1219 } else if (endp->dequeueing) {
1223 endp->dequeueing = 0; 1220 endp->dequeueing = 0;
1224 up(&u132->scheduler_lock); 1221 mutex_unlock(&u132->scheduler_lock);
1225 u132_hcd_giveback_urb(u132, endp, urb, -EINTR); 1222 u132_hcd_giveback_urb(u132, endp, urb, -EINTR);
1226 return; 1223 return;
1227 } else if (u132->going > 0) { 1224 } else if (u132->going > 0) {
1228 dev_err(&u132->platform_dev->dev, "device is being removed " 1225 dev_err(&u132->platform_dev->dev, "device is being removed "
1229 "urb=%p\n", urb); 1226 "urb=%p\n", urb);
1230 up(&u132->scheduler_lock); 1227 mutex_unlock(&u132->scheduler_lock);
1231 u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); 1228 u132_hcd_giveback_urb(u132, endp, urb, -ENODEV);
1232 return; 1229 return;
1233 } else if (!urb->unlinked) { 1230 } else if (!urb->unlinked) {
1234 int retval; 1231 int retval;
1235 struct u132_ring *ring = endp->ring; 1232 struct u132_ring *ring = endp->ring;
1236 u8 *u = urb->transfer_buffer; 1233 u8 *u = urb->transfer_buffer;
1237 u8 *b = buf; 1234 u8 *b = buf;
1238 int L = len; 1235 int L = len;
1239 while (L-- > 0) { 1236
1240 *u++ = *b++; 1237 while (L-- > 0)
1241 } 1238 *u++ = *b++;
1242 urb->actual_length = len; 1239
1243 up(&u132->scheduler_lock); 1240 urb->actual_length = len;
1244 retval = usb_ftdi_elan_edset_empty(u132->platform_dev, 1241 mutex_unlock(&u132->scheduler_lock);
1245 ring->number, endp, urb, address, endp->usb_endp, 0x3, 1242 retval = usb_ftdi_elan_edset_empty(u132->platform_dev,
1246 u132_hcd_initial_empty_sent); 1243 ring->number, endp, urb, address, endp->usb_endp, 0x3,
1247 if (retval == 0) { 1244 u132_hcd_initial_empty_sent);
1248 } else 1245 if (retval != 0)
1249 u132_hcd_giveback_urb(u132, endp, urb, retval); 1246 u132_hcd_giveback_urb(u132, endp, urb, retval);
1250 return; 1247 return;
1251 } else { 1248 } else {
1252 dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " 1249 dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p "
1253 "unlinked=%d\n", urb, urb->unlinked); 1250 "unlinked=%d\n", urb, urb->unlinked);
1254 up(&u132->scheduler_lock); 1251 mutex_unlock(&u132->scheduler_lock);
1255 u132_hcd_giveback_urb(u132, endp, urb, 0); 1252 u132_hcd_giveback_urb(u132, endp, urb, 0);
1256 return; 1253 return;
1257 } 1254 }
1258} 1255}
1259 1256
1260static void u132_hcd_initial_setup_sent(void *data, struct urb *urb, u8 *buf, 1257static void u132_hcd_initial_setup_sent(void *data, struct urb *urb, u8 *buf,
1261 int len, int toggle_bits, int error_count, int condition_code, 1258 int len, int toggle_bits, int error_count, int condition_code,
1262 int repeat_number, int halted, int skipped, int actual, int non_null) 1259 int repeat_number, int halted, int skipped, int actual, int non_null)
1263{ 1260{
1264 struct u132_endp *endp = data; 1261 struct u132_endp *endp = data;
1265 struct u132 *u132 = endp->u132; 1262 struct u132 *u132 = endp->u132;
1266 u8 address = u132->addr[endp->usb_addr].address; 1263 u8 address = u132->addr[endp->usb_addr].address;
1267 down(&u132->scheduler_lock); 1264 mutex_lock(&u132->scheduler_lock);
1268 if (u132->going > 1) { 1265 if (u132->going > 1) {
1269 dev_err(&u132->platform_dev->dev, "device has been removed %d\n" 1266 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
1270 , u132->going); 1267 , u132->going);
1271 up(&u132->scheduler_lock); 1268 mutex_unlock(&u132->scheduler_lock);
1272 u132_hcd_forget_urb(u132, endp, urb, -ENODEV); 1269 u132_hcd_forget_urb(u132, endp, urb, -ENODEV);
1273 return; 1270 return;
1274 } else if (endp->dequeueing) { 1271 } else if (endp->dequeueing) {
1275 endp->dequeueing = 0; 1272 endp->dequeueing = 0;
1276 up(&u132->scheduler_lock); 1273 mutex_unlock(&u132->scheduler_lock);
1277 u132_hcd_giveback_urb(u132, endp, urb, -EINTR); 1274 u132_hcd_giveback_urb(u132, endp, urb, -EINTR);
1278 return; 1275 return;
1279 } else if (u132->going > 0) { 1276 } else if (u132->going > 0) {
1280 dev_err(&u132->platform_dev->dev, "device is being removed " 1277 dev_err(&u132->platform_dev->dev, "device is being removed "
1281 "urb=%p\n", urb); 1278 "urb=%p\n", urb);
1282 up(&u132->scheduler_lock); 1279 mutex_unlock(&u132->scheduler_lock);
1283 u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); 1280 u132_hcd_giveback_urb(u132, endp, urb, -ENODEV);
1284 return; 1281 return;
1285 } else if (!urb->unlinked) { 1282 } else if (!urb->unlinked) {
1286 int retval; 1283 int retval;
1287 struct u132_ring *ring = endp->ring; 1284 struct u132_ring *ring = endp->ring;
1288 up(&u132->scheduler_lock); 1285 mutex_unlock(&u132->scheduler_lock);
1289 retval = usb_ftdi_elan_edset_input(u132->platform_dev, 1286 retval = usb_ftdi_elan_edset_input(u132->platform_dev,
1290 ring->number, endp, urb, address, endp->usb_endp, 0, 1287 ring->number, endp, urb, address, endp->usb_endp, 0,
1291 u132_hcd_initial_input_recv); 1288 u132_hcd_initial_input_recv);
1292 if (retval == 0) { 1289 if (retval != 0)
1293 } else 1290 u132_hcd_giveback_urb(u132, endp, urb, retval);
1294 u132_hcd_giveback_urb(u132, endp, urb, retval); 1291 return;
1295 return; 1292 } else {
1296 } else {
1297 dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " 1293 dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p "
1298 "unlinked=%d\n", urb, urb->unlinked); 1294 "unlinked=%d\n", urb, urb->unlinked);
1299 up(&u132->scheduler_lock); 1295 mutex_unlock(&u132->scheduler_lock);
1300 u132_hcd_giveback_urb(u132, endp, urb, 0); 1296 u132_hcd_giveback_urb(u132, endp, urb, 0);
1301 return; 1297 return;
1302 } 1298 }
1303} 1299}
1304 1300
1305/* 1301/*
@@ -1308,302 +1304,296 @@ static void u132_hcd_initial_setup_sent(void *data, struct urb *urb, u8 *buf,
1308*/ 1304*/
1309static void u132_hcd_ring_work_scheduler(struct work_struct *work) 1305static void u132_hcd_ring_work_scheduler(struct work_struct *work)
1310{ 1306{
1311 struct u132_ring *ring = 1307 struct u132_ring *ring =
1312 container_of(work, struct u132_ring, scheduler.work); 1308 container_of(work, struct u132_ring, scheduler.work);
1313 struct u132 *u132 = ring->u132; 1309 struct u132 *u132 = ring->u132;
1314 down(&u132->scheduler_lock); 1310 mutex_lock(&u132->scheduler_lock);
1315 if (ring->in_use) { 1311 if (ring->in_use) {
1316 up(&u132->scheduler_lock); 1312 mutex_unlock(&u132->scheduler_lock);
1317 u132_ring_put_kref(u132, ring); 1313 u132_ring_put_kref(u132, ring);
1318 return; 1314 return;
1319 } else if (ring->curr_endp) { 1315 } else if (ring->curr_endp) {
1320 struct u132_endp *last_endp = ring->curr_endp; 1316 struct u132_endp *last_endp = ring->curr_endp;
1321 struct list_head *scan; 1317 struct list_head *scan;
1322 struct list_head *head = &last_endp->endp_ring; 1318 struct list_head *head = &last_endp->endp_ring;
1323 unsigned long wakeup = 0; 1319 unsigned long wakeup = 0;
1324 list_for_each(scan, head) { 1320 list_for_each(scan, head) {
1325 struct u132_endp *endp = list_entry(scan, 1321 struct u132_endp *endp = list_entry(scan,
1326 struct u132_endp, endp_ring); 1322 struct u132_endp, endp_ring);
1327 if (endp->queue_next == endp->queue_last) { 1323 if (endp->queue_next == endp->queue_last) {
1328 } else if ((endp->delayed == 0) 1324 } else if ((endp->delayed == 0)
1329 || time_after_eq(jiffies, endp->jiffies)) { 1325 || time_after_eq(jiffies, endp->jiffies)) {
1330 ring->curr_endp = endp; 1326 ring->curr_endp = endp;
1331 u132_endp_cancel_work(u132, last_endp); 1327 u132_endp_cancel_work(u132, last_endp);
1332 u132_endp_queue_work(u132, last_endp, 0); 1328 u132_endp_queue_work(u132, last_endp, 0);
1333 up(&u132->scheduler_lock); 1329 mutex_unlock(&u132->scheduler_lock);
1334 u132_ring_put_kref(u132, ring); 1330 u132_ring_put_kref(u132, ring);
1335 return; 1331 return;
1336 } else { 1332 } else {
1337 unsigned long delta = endp->jiffies - jiffies; 1333 unsigned long delta = endp->jiffies - jiffies;
1338 if (delta > wakeup) 1334 if (delta > wakeup)
1339 wakeup = delta; 1335 wakeup = delta;
1340 } 1336 }
1341 } 1337 }
1342 if (last_endp->queue_next == last_endp->queue_last) { 1338 if (last_endp->queue_next == last_endp->queue_last) {
1343 } else if ((last_endp->delayed == 0) || time_after_eq(jiffies, 1339 } else if ((last_endp->delayed == 0) || time_after_eq(jiffies,
1344 last_endp->jiffies)) { 1340 last_endp->jiffies)) {
1345 u132_endp_cancel_work(u132, last_endp); 1341 u132_endp_cancel_work(u132, last_endp);
1346 u132_endp_queue_work(u132, last_endp, 0); 1342 u132_endp_queue_work(u132, last_endp, 0);
1347 up(&u132->scheduler_lock); 1343 mutex_unlock(&u132->scheduler_lock);
1348 u132_ring_put_kref(u132, ring); 1344 u132_ring_put_kref(u132, ring);
1349 return; 1345 return;
1350 } else { 1346 } else {
1351 unsigned long delta = last_endp->jiffies - jiffies; 1347 unsigned long delta = last_endp->jiffies - jiffies;
1352 if (delta > wakeup) 1348 if (delta > wakeup)
1353 wakeup = delta; 1349 wakeup = delta;
1354 } 1350 }
1355 if (wakeup > 0) { 1351 if (wakeup > 0) {
1356 u132_ring_requeue_work(u132, ring, wakeup); 1352 u132_ring_requeue_work(u132, ring, wakeup);
1357 up(&u132->scheduler_lock); 1353 mutex_unlock(&u132->scheduler_lock);
1358 return; 1354 return;
1359 } else { 1355 } else {
1360 up(&u132->scheduler_lock); 1356 mutex_unlock(&u132->scheduler_lock);
1361 u132_ring_put_kref(u132, ring); 1357 u132_ring_put_kref(u132, ring);
1362 return; 1358 return;
1363 } 1359 }
1364 } else { 1360 } else {
1365 up(&u132->scheduler_lock); 1361 mutex_unlock(&u132->scheduler_lock);
1366 u132_ring_put_kref(u132, ring); 1362 u132_ring_put_kref(u132, ring);
1367 return; 1363 return;
1368 } 1364 }
1369} 1365}
1370 1366
1371static void u132_hcd_endp_work_scheduler(struct work_struct *work) 1367static void u132_hcd_endp_work_scheduler(struct work_struct *work)
1372{ 1368{
1373 struct u132_ring *ring; 1369 struct u132_ring *ring;
1374 struct u132_endp *endp = 1370 struct u132_endp *endp =
1375 container_of(work, struct u132_endp, scheduler.work); 1371 container_of(work, struct u132_endp, scheduler.work);
1376 struct u132 *u132 = endp->u132; 1372 struct u132 *u132 = endp->u132;
1377 down(&u132->scheduler_lock); 1373 mutex_lock(&u132->scheduler_lock);
1378 ring = endp->ring; 1374 ring = endp->ring;
1379 if (endp->edset_flush) { 1375 if (endp->edset_flush) {
1380 endp->edset_flush = 0; 1376 endp->edset_flush = 0;
1381 if (endp->dequeueing) 1377 if (endp->dequeueing)
1382 usb_ftdi_elan_edset_flush(u132->platform_dev, 1378 usb_ftdi_elan_edset_flush(u132->platform_dev,
1383 ring->number, endp); 1379 ring->number, endp);
1384 up(&u132->scheduler_lock); 1380 mutex_unlock(&u132->scheduler_lock);
1385 u132_endp_put_kref(u132, endp); 1381 u132_endp_put_kref(u132, endp);
1386 return; 1382 return;
1387 } else if (endp->active) { 1383 } else if (endp->active) {
1388 up(&u132->scheduler_lock); 1384 mutex_unlock(&u132->scheduler_lock);
1389 u132_endp_put_kref(u132, endp); 1385 u132_endp_put_kref(u132, endp);
1390 return; 1386 return;
1391 } else if (ring->in_use) { 1387 } else if (ring->in_use) {
1392 up(&u132->scheduler_lock); 1388 mutex_unlock(&u132->scheduler_lock);
1393 u132_endp_put_kref(u132, endp); 1389 u132_endp_put_kref(u132, endp);
1394 return; 1390 return;
1395 } else if (endp->queue_next == endp->queue_last) { 1391 } else if (endp->queue_next == endp->queue_last) {
1396 up(&u132->scheduler_lock); 1392 mutex_unlock(&u132->scheduler_lock);
1397 u132_endp_put_kref(u132, endp); 1393 u132_endp_put_kref(u132, endp);
1398 return; 1394 return;
1399 } else if (endp->pipetype == PIPE_INTERRUPT) { 1395 } else if (endp->pipetype == PIPE_INTERRUPT) {
1400 u8 address = u132->addr[endp->usb_addr].address; 1396 u8 address = u132->addr[endp->usb_addr].address;
1401 if (ring->in_use) { 1397 if (ring->in_use) {
1402 up(&u132->scheduler_lock); 1398 mutex_unlock(&u132->scheduler_lock);
1403 u132_endp_put_kref(u132, endp); 1399 u132_endp_put_kref(u132, endp);
1404 return; 1400 return;
1405 } else { 1401 } else {
1406 int retval; 1402 int retval;
1407 struct urb *urb = endp->urb_list[ENDP_QUEUE_MASK & 1403 struct urb *urb = endp->urb_list[ENDP_QUEUE_MASK &
1408 endp->queue_next]; 1404 endp->queue_next];
1409 endp->active = 1; 1405 endp->active = 1;
1410 ring->curr_endp = endp; 1406 ring->curr_endp = endp;
1411 ring->in_use = 1; 1407 ring->in_use = 1;
1412 up(&u132->scheduler_lock); 1408 mutex_unlock(&u132->scheduler_lock);
1413 retval = edset_single(u132, ring, endp, urb, address, 1409 retval = edset_single(u132, ring, endp, urb, address,
1414 endp->toggle_bits, u132_hcd_interrupt_recv); 1410 endp->toggle_bits, u132_hcd_interrupt_recv);
1415 if (retval == 0) { 1411 if (retval != 0)
1416 } else 1412 u132_hcd_giveback_urb(u132, endp, urb, retval);
1417 u132_hcd_giveback_urb(u132, endp, urb, retval); 1413 return;
1418 return; 1414 }
1419 } 1415 } else if (endp->pipetype == PIPE_CONTROL) {
1420 } else if (endp->pipetype == PIPE_CONTROL) { 1416 u8 address = u132->addr[endp->usb_addr].address;
1421 u8 address = u132->addr[endp->usb_addr].address; 1417 if (ring->in_use) {
1422 if (ring->in_use) { 1418 mutex_unlock(&u132->scheduler_lock);
1423 up(&u132->scheduler_lock); 1419 u132_endp_put_kref(u132, endp);
1424 u132_endp_put_kref(u132, endp); 1420 return;
1425 return; 1421 } else if (address == 0) {
1426 } else if (address == 0) { 1422 int retval;
1427 int retval; 1423 struct urb *urb = endp->urb_list[ENDP_QUEUE_MASK &
1428 struct urb *urb = endp->urb_list[ENDP_QUEUE_MASK & 1424 endp->queue_next];
1429 endp->queue_next]; 1425 endp->active = 1;
1430 endp->active = 1; 1426 ring->curr_endp = endp;
1431 ring->curr_endp = endp; 1427 ring->in_use = 1;
1432 ring->in_use = 1; 1428 mutex_unlock(&u132->scheduler_lock);
1433 up(&u132->scheduler_lock); 1429 retval = edset_setup(u132, ring, endp, urb, address,
1434 retval = edset_setup(u132, ring, endp, urb, address, 1430 0x2, u132_hcd_initial_setup_sent);
1435 0x2, u132_hcd_initial_setup_sent); 1431 if (retval != 0)
1436 if (retval == 0) { 1432 u132_hcd_giveback_urb(u132, endp, urb, retval);
1437 } else 1433 return;
1438 u132_hcd_giveback_urb(u132, endp, urb, retval); 1434 } else if (endp->usb_addr == 0) {
1439 return; 1435 int retval;
1440 } else if (endp->usb_addr == 0) { 1436 struct urb *urb = endp->urb_list[ENDP_QUEUE_MASK &
1441 int retval; 1437 endp->queue_next];
1442 struct urb *urb = endp->urb_list[ENDP_QUEUE_MASK & 1438 endp->active = 1;
1443 endp->queue_next]; 1439 ring->curr_endp = endp;
1444 endp->active = 1; 1440 ring->in_use = 1;
1445 ring->curr_endp = endp; 1441 mutex_unlock(&u132->scheduler_lock);
1446 ring->in_use = 1; 1442 retval = edset_setup(u132, ring, endp, urb, 0, 0x2,
1447 up(&u132->scheduler_lock); 1443 u132_hcd_enumeration_address_sent);
1448 retval = edset_setup(u132, ring, endp, urb, 0, 0x2, 1444 if (retval != 0)
1449 u132_hcd_enumeration_address_sent); 1445 u132_hcd_giveback_urb(u132, endp, urb, retval);
1450 if (retval == 0) { 1446 return;
1451 } else 1447 } else {
1452 u132_hcd_giveback_urb(u132, endp, urb, retval); 1448 int retval;
1453 return; 1449 u8 address = u132->addr[endp->usb_addr].address;
1454 } else { 1450 struct urb *urb = endp->urb_list[ENDP_QUEUE_MASK &
1455 int retval; 1451 endp->queue_next];
1456 u8 address = u132->addr[endp->usb_addr].address; 1452 endp->active = 1;
1457 struct urb *urb = endp->urb_list[ENDP_QUEUE_MASK & 1453 ring->curr_endp = endp;
1458 endp->queue_next]; 1454 ring->in_use = 1;
1459 endp->active = 1; 1455 mutex_unlock(&u132->scheduler_lock);
1460 ring->curr_endp = endp; 1456 retval = edset_setup(u132, ring, endp, urb, address,
1461 ring->in_use = 1; 1457 0x2, u132_hcd_configure_setup_sent);
1462 up(&u132->scheduler_lock); 1458 if (retval != 0)
1463 retval = edset_setup(u132, ring, endp, urb, address, 1459 u132_hcd_giveback_urb(u132, endp, urb, retval);
1464 0x2, u132_hcd_configure_setup_sent); 1460 return;
1465 if (retval == 0) { 1461 }
1466 } else 1462 } else {
1467 u132_hcd_giveback_urb(u132, endp, urb, retval); 1463 if (endp->input) {
1468 return; 1464 u8 address = u132->addr[endp->usb_addr].address;
1469 } 1465 if (ring->in_use) {
1470 } else { 1466 mutex_unlock(&u132->scheduler_lock);
1471 if (endp->input) { 1467 u132_endp_put_kref(u132, endp);
1472 u8 address = u132->addr[endp->usb_addr].address; 1468 return;
1473 if (ring->in_use) { 1469 } else {
1474 up(&u132->scheduler_lock); 1470 int retval;
1475 u132_endp_put_kref(u132, endp); 1471 struct urb *urb = endp->urb_list[
1476 return; 1472 ENDP_QUEUE_MASK & endp->queue_next];
1477 } else { 1473 endp->active = 1;
1478 int retval; 1474 ring->curr_endp = endp;
1479 struct urb *urb = endp->urb_list[ 1475 ring->in_use = 1;
1480 ENDP_QUEUE_MASK & endp->queue_next]; 1476 mutex_unlock(&u132->scheduler_lock);
1481 endp->active = 1; 1477 retval = edset_input(u132, ring, endp, urb,
1482 ring->curr_endp = endp; 1478 address, endp->toggle_bits,
1483 ring->in_use = 1; 1479 u132_hcd_bulk_input_recv);
1484 up(&u132->scheduler_lock); 1480 if (retval == 0) {
1485 retval = edset_input(u132, ring, endp, urb, 1481 } else
1486 address, endp->toggle_bits, 1482 u132_hcd_giveback_urb(u132, endp, urb,
1487 u132_hcd_bulk_input_recv); 1483 retval);
1488 if (retval == 0) { 1484 return;
1489 } else 1485 }
1490 u132_hcd_giveback_urb(u132, endp, urb, 1486 } else { /* output pipe */
1491 retval); 1487 u8 address = u132->addr[endp->usb_addr].address;
1492 return; 1488 if (ring->in_use) {
1493 } 1489 mutex_unlock(&u132->scheduler_lock);
1494 } else { /* output pipe */ 1490 u132_endp_put_kref(u132, endp);
1495 u8 address = u132->addr[endp->usb_addr].address; 1491 return;
1496 if (ring->in_use) { 1492 } else {
1497 up(&u132->scheduler_lock); 1493 int retval;
1498 u132_endp_put_kref(u132, endp); 1494 struct urb *urb = endp->urb_list[
1499 return; 1495 ENDP_QUEUE_MASK & endp->queue_next];
1500 } else { 1496 endp->active = 1;
1501 int retval; 1497 ring->curr_endp = endp;
1502 struct urb *urb = endp->urb_list[ 1498 ring->in_use = 1;
1503 ENDP_QUEUE_MASK & endp->queue_next]; 1499 mutex_unlock(&u132->scheduler_lock);
1504 endp->active = 1; 1500 retval = edset_output(u132, ring, endp, urb,
1505 ring->curr_endp = endp; 1501 address, endp->toggle_bits,
1506 ring->in_use = 1; 1502 u132_hcd_bulk_output_sent);
1507 up(&u132->scheduler_lock); 1503 if (retval == 0) {
1508 retval = edset_output(u132, ring, endp, urb, 1504 } else
1509 address, endp->toggle_bits, 1505 u132_hcd_giveback_urb(u132, endp, urb,
1510 u132_hcd_bulk_output_sent); 1506 retval);
1511 if (retval == 0) { 1507 return;
1512 } else 1508 }
1513 u132_hcd_giveback_urb(u132, endp, urb, 1509 }
1514 retval); 1510 }
1515 return;
1516 }
1517 }
1518 }
1519} 1511}
1520#ifdef CONFIG_PM 1512#ifdef CONFIG_PM
1521 1513
1522static void port_power(struct u132 *u132, int pn, int is_on) 1514static void port_power(struct u132 *u132, int pn, int is_on)
1523{ 1515{
1524 u132->port[pn].power = is_on; 1516 u132->port[pn].power = is_on;
1525} 1517}
1526 1518
1527#endif 1519#endif
1528 1520
1529static void u132_power(struct u132 *u132, int is_on) 1521static void u132_power(struct u132 *u132, int is_on)
1530{ 1522{
1531 struct usb_hcd *hcd = u132_to_hcd(u132) 1523 struct usb_hcd *hcd = u132_to_hcd(u132)
1532 ; /* hub is inactive unless the port is powered */ 1524 ; /* hub is inactive unless the port is powered */
1533 if (is_on) { 1525 if (is_on) {
1534 if (u132->power) 1526 if (u132->power)
1535 return; 1527 return;
1536 u132->power = 1; 1528 u132->power = 1;
1537 hcd->self.controller->power.power_state = PMSG_ON; 1529 } else {
1538 } else { 1530 u132->power = 0;
1539 u132->power = 0; 1531 hcd->state = HC_STATE_HALT;
1540 hcd->state = HC_STATE_HALT; 1532 }
1541 hcd->self.controller->power.power_state = PMSG_SUSPEND;
1542 }
1543} 1533}
1544 1534
1545static int u132_periodic_reinit(struct u132 *u132) 1535static int u132_periodic_reinit(struct u132 *u132)
1546{ 1536{
1547 int retval; 1537 int retval;
1548 u32 fi = u132->hc_fminterval & 0x03fff; 1538 u32 fi = u132->hc_fminterval & 0x03fff;
1549 u32 fit; 1539 u32 fit;
1550 u32 fminterval; 1540 u32 fminterval;
1551 retval = u132_read_pcimem(u132, fminterval, &fminterval); 1541 retval = u132_read_pcimem(u132, fminterval, &fminterval);
1552 if (retval) 1542 if (retval)
1553 return retval; 1543 return retval;
1554 fit = fminterval & FIT; 1544 fit = fminterval & FIT;
1555 retval = u132_write_pcimem(u132, fminterval, 1545 retval = u132_write_pcimem(u132, fminterval,
1556 (fit ^ FIT) | u132->hc_fminterval); 1546 (fit ^ FIT) | u132->hc_fminterval);
1557 if (retval) 1547 if (retval)
1558 return retval; 1548 return retval;
1559 retval = u132_write_pcimem(u132, periodicstart, 1549 retval = u132_write_pcimem(u132, periodicstart,
1560 ((9 *fi) / 10) & 0x3fff); 1550 ((9 * fi) / 10) & 0x3fff);
1561 if (retval) 1551 if (retval)
1562 return retval; 1552 return retval;
1563 return 0; 1553 return 0;
1564} 1554}
1565 1555
1566static char *hcfs2string(int state) 1556static char *hcfs2string(int state)
1567{ 1557{
1568 switch (state) { 1558 switch (state) {
1569 case OHCI_USB_RESET: 1559 case OHCI_USB_RESET:
1570 return "reset"; 1560 return "reset";
1571 case OHCI_USB_RESUME: 1561 case OHCI_USB_RESUME:
1572 return "resume"; 1562 return "resume";
1573 case OHCI_USB_OPER: 1563 case OHCI_USB_OPER:
1574 return "operational"; 1564 return "operational";
1575 case OHCI_USB_SUSPEND: 1565 case OHCI_USB_SUSPEND:
1576 return "suspend"; 1566 return "suspend";
1577 } 1567 }
1578 return "?"; 1568 return "?";
1579} 1569}
1580 1570
1581static int u132_init(struct u132 *u132) 1571static int u132_init(struct u132 *u132)
1582{ 1572{
1583 int retval; 1573 int retval;
1584 u32 control; 1574 u32 control;
1585 u132_disable(u132); 1575 u132_disable(u132);
1586 u132->next_statechange = jiffies; 1576 u132->next_statechange = jiffies;
1587 retval = u132_write_pcimem(u132, intrdisable, OHCI_INTR_MIE); 1577 retval = u132_write_pcimem(u132, intrdisable, OHCI_INTR_MIE);
1588 if (retval) 1578 if (retval)
1589 return retval; 1579 return retval;
1590 retval = u132_read_pcimem(u132, control, &control); 1580 retval = u132_read_pcimem(u132, control, &control);
1591 if (retval) 1581 if (retval)
1592 return retval; 1582 return retval;
1593 if (u132->num_ports == 0) { 1583 if (u132->num_ports == 0) {
1594 u32 rh_a = -1; 1584 u32 rh_a = -1;
1595 retval = u132_read_pcimem(u132, roothub.a, &rh_a); 1585 retval = u132_read_pcimem(u132, roothub.a, &rh_a);
1596 if (retval) 1586 if (retval)
1597 return retval; 1587 return retval;
1598 u132->num_ports = rh_a & RH_A_NDP; 1588 u132->num_ports = rh_a & RH_A_NDP;
1599 retval = read_roothub_info(u132); 1589 retval = read_roothub_info(u132);
1600 if (retval) 1590 if (retval)
1601 return retval; 1591 return retval;
1602 } 1592 }
1603 if (u132->num_ports > MAX_U132_PORTS) { 1593 if (u132->num_ports > MAX_U132_PORTS)
1604 return -EINVAL; 1594 return -EINVAL;
1605 } 1595
1606 return 0; 1596 return 0;
1607} 1597}
1608 1598
1609 1599
@@ -1613,280 +1603,278 @@ static int u132_init(struct u132 *u132)
1613*/ 1603*/
1614static int u132_run(struct u132 *u132) 1604static int u132_run(struct u132 *u132)
1615{ 1605{
1616 int retval; 1606 int retval;
1617 u32 control; 1607 u32 control;
1618 u32 status; 1608 u32 status;
1619 u32 fminterval; 1609 u32 fminterval;
1620 u32 periodicstart; 1610 u32 periodicstart;
1621 u32 cmdstatus; 1611 u32 cmdstatus;
1622 u32 roothub_a; 1612 u32 roothub_a;
1623 int mask = OHCI_INTR_INIT; 1613 int mask = OHCI_INTR_INIT;
1624 int first = u132->hc_fminterval == 0; 1614 int first = u132->hc_fminterval == 0;
1625 int sleep_time = 0; 1615 int sleep_time = 0;
1626 int reset_timeout = 30; /* ... allow extra time */ 1616 int reset_timeout = 30; /* ... allow extra time */
1627 u132_disable(u132); 1617 u132_disable(u132);
1628 if (first) { 1618 if (first) {
1629 u32 temp; 1619 u32 temp;
1630 retval = u132_read_pcimem(u132, fminterval, &temp); 1620 retval = u132_read_pcimem(u132, fminterval, &temp);
1631 if (retval) 1621 if (retval)
1632 return retval; 1622 return retval;
1633 u132->hc_fminterval = temp & 0x3fff; 1623 u132->hc_fminterval = temp & 0x3fff;
1634 if (u132->hc_fminterval != FI) { 1624 u132->hc_fminterval |= FSMP(u132->hc_fminterval) << 16;
1635 } 1625 }
1636 u132->hc_fminterval |= FSMP(u132->hc_fminterval) << 16; 1626 retval = u132_read_pcimem(u132, control, &u132->hc_control);
1637 } 1627 if (retval)
1638 retval = u132_read_pcimem(u132, control, &u132->hc_control); 1628 return retval;
1639 if (retval) 1629 dev_info(&u132->platform_dev->dev, "resetting from state '%s', control "
1640 return retval; 1630 "= %08X\n", hcfs2string(u132->hc_control & OHCI_CTRL_HCFS),
1641 dev_info(&u132->platform_dev->dev, "resetting from state '%s', control " 1631 u132->hc_control);
1642 "= %08X\n", hcfs2string(u132->hc_control & OHCI_CTRL_HCFS), 1632 switch (u132->hc_control & OHCI_CTRL_HCFS) {
1643 u132->hc_control); 1633 case OHCI_USB_OPER:
1644 switch (u132->hc_control & OHCI_CTRL_HCFS) { 1634 sleep_time = 0;
1645 case OHCI_USB_OPER: 1635 break;
1646 sleep_time = 0; 1636 case OHCI_USB_SUSPEND:
1647 break; 1637 case OHCI_USB_RESUME:
1648 case OHCI_USB_SUSPEND: 1638 u132->hc_control &= OHCI_CTRL_RWC;
1649 case OHCI_USB_RESUME: 1639 u132->hc_control |= OHCI_USB_RESUME;
1650 u132->hc_control &= OHCI_CTRL_RWC; 1640 sleep_time = 10;
1651 u132->hc_control |= OHCI_USB_RESUME; 1641 break;
1652 sleep_time = 10; 1642 default:
1653 break; 1643 u132->hc_control &= OHCI_CTRL_RWC;
1654 default: 1644 u132->hc_control |= OHCI_USB_RESET;
1655 u132->hc_control &= OHCI_CTRL_RWC; 1645 sleep_time = 50;
1656 u132->hc_control |= OHCI_USB_RESET; 1646 break;
1657 sleep_time = 50; 1647 }
1658 break; 1648 retval = u132_write_pcimem(u132, control, u132->hc_control);
1659 } 1649 if (retval)
1660 retval = u132_write_pcimem(u132, control, u132->hc_control); 1650 return retval;
1661 if (retval) 1651 retval = u132_read_pcimem(u132, control, &control);
1662 return retval; 1652 if (retval)
1663 retval = u132_read_pcimem(u132, control, &control); 1653 return retval;
1664 if (retval) 1654 msleep(sleep_time);
1665 return retval; 1655 retval = u132_read_pcimem(u132, roothub.a, &roothub_a);
1666 msleep(sleep_time); 1656 if (retval)
1667 retval = u132_read_pcimem(u132, roothub.a, &roothub_a); 1657 return retval;
1668 if (retval) 1658 if (!(roothub_a & RH_A_NPS)) {
1669 return retval; 1659 int temp; /* power down each port */
1670 if (!(roothub_a & RH_A_NPS)) { 1660 for (temp = 0; temp < u132->num_ports; temp++) {
1671 int temp; /* power down each port */ 1661 retval = u132_write_pcimem(u132,
1672 for (temp = 0; temp < u132->num_ports; temp++) { 1662 roothub.portstatus[temp], RH_PS_LSDA);
1673 retval = u132_write_pcimem(u132, 1663 if (retval)
1674 roothub.portstatus[temp], RH_PS_LSDA); 1664 return retval;
1675 if (retval) 1665 }
1676 return retval; 1666 }
1677 } 1667 retval = u132_read_pcimem(u132, control, &control);
1678 } 1668 if (retval)
1679 retval = u132_read_pcimem(u132, control, &control); 1669 return retval;
1680 if (retval) 1670retry:
1681 return retval; 1671 retval = u132_read_pcimem(u132, cmdstatus, &status);
1682 retry:retval = u132_read_pcimem(u132, cmdstatus, &status); 1672 if (retval)
1683 if (retval) 1673 return retval;
1684 return retval; 1674 retval = u132_write_pcimem(u132, cmdstatus, OHCI_HCR);
1685 retval = u132_write_pcimem(u132, cmdstatus, OHCI_HCR); 1675 if (retval)
1686 if (retval) 1676 return retval;
1687 return retval; 1677extra: {
1688 extra:{ 1678 retval = u132_read_pcimem(u132, cmdstatus, &status);
1689 retval = u132_read_pcimem(u132, cmdstatus, &status); 1679 if (retval)
1690 if (retval) 1680 return retval;
1691 return retval; 1681 if (0 != (status & OHCI_HCR)) {
1692 if (0 != (status & OHCI_HCR)) { 1682 if (--reset_timeout == 0) {
1693 if (--reset_timeout == 0) { 1683 dev_err(&u132->platform_dev->dev, "USB HC reset"
1694 dev_err(&u132->platform_dev->dev, "USB HC reset" 1684 " timed out!\n");
1695 " timed out!\n"); 1685 return -ENODEV;
1696 return -ENODEV; 1686 } else {
1697 } else { 1687 msleep(5);
1698 msleep(5); 1688 goto extra;
1699 goto extra; 1689 }
1700 } 1690 }
1701 } 1691 }
1702 } 1692 if (u132->flags & OHCI_QUIRK_INITRESET) {
1703 if (u132->flags & OHCI_QUIRK_INITRESET) { 1693 retval = u132_write_pcimem(u132, control, u132->hc_control);
1704 retval = u132_write_pcimem(u132, control, u132->hc_control); 1694 if (retval)
1705 if (retval) 1695 return retval;
1706 return retval; 1696 retval = u132_read_pcimem(u132, control, &control);
1707 retval = u132_read_pcimem(u132, control, &control); 1697 if (retval)
1708 if (retval) 1698 return retval;
1709 return retval; 1699 }
1710 } 1700 retval = u132_write_pcimem(u132, ed_controlhead, 0x00000000);
1711 retval = u132_write_pcimem(u132, ed_controlhead, 0x00000000); 1701 if (retval)
1712 if (retval) 1702 return retval;
1713 return retval; 1703 retval = u132_write_pcimem(u132, ed_bulkhead, 0x11000000);
1714 retval = u132_write_pcimem(u132, ed_bulkhead, 0x11000000); 1704 if (retval)
1715 if (retval) 1705 return retval;
1716 return retval; 1706 retval = u132_write_pcimem(u132, hcca, 0x00000000);
1717 retval = u132_write_pcimem(u132, hcca, 0x00000000); 1707 if (retval)
1718 if (retval) 1708 return retval;
1719 return retval; 1709 retval = u132_periodic_reinit(u132);
1720 retval = u132_periodic_reinit(u132); 1710 if (retval)
1721 if (retval) 1711 return retval;
1722 return retval; 1712 retval = u132_read_pcimem(u132, fminterval, &fminterval);
1723 retval = u132_read_pcimem(u132, fminterval, &fminterval); 1713 if (retval)
1724 if (retval) 1714 return retval;
1725 return retval; 1715 retval = u132_read_pcimem(u132, periodicstart, &periodicstart);
1726 retval = u132_read_pcimem(u132, periodicstart, &periodicstart); 1716 if (retval)
1727 if (retval) 1717 return retval;
1728 return retval; 1718 if (0 == (fminterval & 0x3fff0000) || 0 == periodicstart) {
1729 if (0 == (fminterval & 0x3fff0000) || 0 == periodicstart) { 1719 if (!(u132->flags & OHCI_QUIRK_INITRESET)) {
1730 if (!(u132->flags & OHCI_QUIRK_INITRESET)) { 1720 u132->flags |= OHCI_QUIRK_INITRESET;
1731 u132->flags |= OHCI_QUIRK_INITRESET; 1721 goto retry;
1732 goto retry; 1722 } else
1733 } else 1723 dev_err(&u132->platform_dev->dev, "init err(%08x %04x)"
1734 dev_err(&u132->platform_dev->dev, "init err(%08x %04x)" 1724 "\n", fminterval, periodicstart);
1735 "\n", fminterval, periodicstart); 1725 } /* start controller operations */
1736 } /* start controller operations */ 1726 u132->hc_control &= OHCI_CTRL_RWC;
1737 u132->hc_control &= OHCI_CTRL_RWC; 1727 u132->hc_control |= OHCI_CONTROL_INIT | OHCI_CTRL_BLE | OHCI_USB_OPER;
1738 u132->hc_control |= OHCI_CONTROL_INIT | OHCI_CTRL_BLE | OHCI_USB_OPER; 1728 retval = u132_write_pcimem(u132, control, u132->hc_control);
1739 retval = u132_write_pcimem(u132, control, u132->hc_control); 1729 if (retval)
1740 if (retval) 1730 return retval;
1741 return retval; 1731 retval = u132_write_pcimem(u132, cmdstatus, OHCI_BLF);
1742 retval = u132_write_pcimem(u132, cmdstatus, OHCI_BLF); 1732 if (retval)
1743 if (retval) 1733 return retval;
1744 return retval; 1734 retval = u132_read_pcimem(u132, cmdstatus, &cmdstatus);
1745 retval = u132_read_pcimem(u132, cmdstatus, &cmdstatus); 1735 if (retval)
1746 if (retval) 1736 return retval;
1747 return retval; 1737 retval = u132_read_pcimem(u132, control, &control);
1748 retval = u132_read_pcimem(u132, control, &control); 1738 if (retval)
1749 if (retval) 1739 return retval;
1750 return retval; 1740 u132_to_hcd(u132)->state = HC_STATE_RUNNING;
1751 u132_to_hcd(u132)->state = HC_STATE_RUNNING; 1741 retval = u132_write_pcimem(u132, roothub.status, RH_HS_DRWE);
1752 retval = u132_write_pcimem(u132, roothub.status, RH_HS_DRWE); 1742 if (retval)
1753 if (retval) 1743 return retval;
1754 return retval; 1744 retval = u132_write_pcimem(u132, intrstatus, mask);
1755 retval = u132_write_pcimem(u132, intrstatus, mask); 1745 if (retval)
1756 if (retval) 1746 return retval;
1757 return retval; 1747 retval = u132_write_pcimem(u132, intrdisable,
1758 retval = u132_write_pcimem(u132, intrdisable, 1748 OHCI_INTR_MIE | OHCI_INTR_OC | OHCI_INTR_RHSC | OHCI_INTR_FNO |
1759 OHCI_INTR_MIE | OHCI_INTR_OC | OHCI_INTR_RHSC | OHCI_INTR_FNO | 1749 OHCI_INTR_UE | OHCI_INTR_RD | OHCI_INTR_SF | OHCI_INTR_WDH |
1760 OHCI_INTR_UE | OHCI_INTR_RD | OHCI_INTR_SF | OHCI_INTR_WDH | 1750 OHCI_INTR_SO);
1761 OHCI_INTR_SO); 1751 if (retval)
1762 if (retval) 1752 return retval; /* handle root hub init quirks ... */
1763 return retval; /* handle root hub init quirks ... */ 1753 retval = u132_read_pcimem(u132, roothub.a, &roothub_a);
1764 retval = u132_read_pcimem(u132, roothub.a, &roothub_a); 1754 if (retval)
1765 if (retval) 1755 return retval;
1766 return retval; 1756 roothub_a &= ~(RH_A_PSM | RH_A_OCPM);
1767 roothub_a &= ~(RH_A_PSM | RH_A_OCPM); 1757 if (u132->flags & OHCI_QUIRK_SUPERIO) {
1768 if (u132->flags & OHCI_QUIRK_SUPERIO) { 1758 roothub_a |= RH_A_NOCP;
1769 roothub_a |= RH_A_NOCP; 1759 roothub_a &= ~(RH_A_POTPGT | RH_A_NPS);
1770 roothub_a &= ~(RH_A_POTPGT | RH_A_NPS); 1760 retval = u132_write_pcimem(u132, roothub.a, roothub_a);
1771 retval = u132_write_pcimem(u132, roothub.a, roothub_a); 1761 if (retval)
1772 if (retval) 1762 return retval;
1773 return retval; 1763 } else if ((u132->flags & OHCI_QUIRK_AMD756) || distrust_firmware) {
1774 } else if ((u132->flags & OHCI_QUIRK_AMD756) || distrust_firmware) { 1764 roothub_a |= RH_A_NPS;
1775 roothub_a |= RH_A_NPS; 1765 retval = u132_write_pcimem(u132, roothub.a, roothub_a);
1776 retval = u132_write_pcimem(u132, roothub.a, roothub_a); 1766 if (retval)
1777 if (retval) 1767 return retval;
1778 return retval; 1768 }
1779 } 1769 retval = u132_write_pcimem(u132, roothub.status, RH_HS_LPSC);
1780 retval = u132_write_pcimem(u132, roothub.status, RH_HS_LPSC); 1770 if (retval)
1781 if (retval) 1771 return retval;
1782 return retval; 1772 retval = u132_write_pcimem(u132, roothub.b,
1783 retval = u132_write_pcimem(u132, roothub.b, 1773 (roothub_a & RH_A_NPS) ? 0 : RH_B_PPCM);
1784 (roothub_a & RH_A_NPS) ? 0 : RH_B_PPCM); 1774 if (retval)
1785 if (retval) 1775 return retval;
1786 return retval; 1776 retval = u132_read_pcimem(u132, control, &control);
1787 retval = u132_read_pcimem(u132, control, &control); 1777 if (retval)
1788 if (retval) 1778 return retval;
1789 return retval; 1779 mdelay((roothub_a >> 23) & 0x1fe);
1790 mdelay((roothub_a >> 23) & 0x1fe); 1780 u132_to_hcd(u132)->state = HC_STATE_RUNNING;
1791 u132_to_hcd(u132)->state = HC_STATE_RUNNING; 1781 return 0;
1792 return 0;
1793} 1782}
1794 1783
1795static void u132_hcd_stop(struct usb_hcd *hcd) 1784static void u132_hcd_stop(struct usb_hcd *hcd)
1796{ 1785{
1797 struct u132 *u132 = hcd_to_u132(hcd); 1786 struct u132 *u132 = hcd_to_u132(hcd);
1798 if (u132->going > 1) { 1787 if (u132->going > 1) {
1799 dev_err(&u132->platform_dev->dev, "u132 device %p(hcd=%p) has b" 1788 dev_err(&u132->platform_dev->dev, "u132 device %p(hcd=%p) has b"
1800 "een removed %d\n", u132, hcd, u132->going); 1789 "een removed %d\n", u132, hcd, u132->going);
1801 } else if (u132->going > 0) { 1790 } else if (u132->going > 0) {
1802 dev_err(&u132->platform_dev->dev, "device hcd=%p is being remov" 1791 dev_err(&u132->platform_dev->dev, "device hcd=%p is being remov"
1803 "ed\n", hcd); 1792 "ed\n", hcd);
1804 } else { 1793 } else {
1805 mutex_lock(&u132->sw_lock); 1794 mutex_lock(&u132->sw_lock);
1806 msleep(100); 1795 msleep(100);
1807 u132_power(u132, 0); 1796 u132_power(u132, 0);
1808 mutex_unlock(&u132->sw_lock); 1797 mutex_unlock(&u132->sw_lock);
1809 } 1798 }
1810} 1799}
1811 1800
1812static int u132_hcd_start(struct usb_hcd *hcd) 1801static int u132_hcd_start(struct usb_hcd *hcd)
1813{ 1802{
1814 struct u132 *u132 = hcd_to_u132(hcd); 1803 struct u132 *u132 = hcd_to_u132(hcd);
1815 if (u132->going > 1) { 1804 if (u132->going > 1) {
1816 dev_err(&u132->platform_dev->dev, "device has been removed %d\n" 1805 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
1817 , u132->going); 1806 , u132->going);
1818 return -ENODEV; 1807 return -ENODEV;
1819 } else if (u132->going > 0) { 1808 } else if (u132->going > 0) {
1820 dev_err(&u132->platform_dev->dev, "device is being removed\n"); 1809 dev_err(&u132->platform_dev->dev, "device is being removed\n");
1821 return -ESHUTDOWN; 1810 return -ESHUTDOWN;
1822 } else if (hcd->self.controller) { 1811 } else if (hcd->self.controller) {
1823 int retval; 1812 int retval;
1824 struct platform_device *pdev = 1813 struct platform_device *pdev =
1825 to_platform_device(hcd->self.controller); 1814 to_platform_device(hcd->self.controller);
1826 u16 vendor = ((struct u132_platform_data *) 1815 u16 vendor = ((struct u132_platform_data *)
1827 (pdev->dev.platform_data))->vendor; 1816 (pdev->dev.platform_data))->vendor;
1828 u16 device = ((struct u132_platform_data *) 1817 u16 device = ((struct u132_platform_data *)
1829 (pdev->dev.platform_data))->device; 1818 (pdev->dev.platform_data))->device;
1830 mutex_lock(&u132->sw_lock); 1819 mutex_lock(&u132->sw_lock);
1831 msleep(10); 1820 msleep(10);
1832 if (vendor == PCI_VENDOR_ID_AMD && device == 0x740c) { 1821 if (vendor == PCI_VENDOR_ID_AMD && device == 0x740c) {
1833 u132->flags = OHCI_QUIRK_AMD756; 1822 u132->flags = OHCI_QUIRK_AMD756;
1834 } else if (vendor == PCI_VENDOR_ID_OPTI && device == 0xc861) { 1823 } else if (vendor == PCI_VENDOR_ID_OPTI && device == 0xc861) {
1835 dev_err(&u132->platform_dev->dev, "WARNING: OPTi workar" 1824 dev_err(&u132->platform_dev->dev, "WARNING: OPTi workar"
1836 "ounds unavailable\n"); 1825 "ounds unavailable\n");
1837 } else if (vendor == PCI_VENDOR_ID_COMPAQ && device == 0xa0f8) 1826 } else if (vendor == PCI_VENDOR_ID_COMPAQ && device == 0xa0f8)
1838 u132->flags |= OHCI_QUIRK_ZFMICRO; 1827 u132->flags |= OHCI_QUIRK_ZFMICRO;
1839 retval = u132_run(u132); 1828 retval = u132_run(u132);
1840 if (retval) { 1829 if (retval) {
1841 u132_disable(u132); 1830 u132_disable(u132);
1842 u132->going = 1; 1831 u132->going = 1;
1843 } 1832 }
1844 msleep(100); 1833 msleep(100);
1845 mutex_unlock(&u132->sw_lock); 1834 mutex_unlock(&u132->sw_lock);
1846 return retval; 1835 return retval;
1847 } else { 1836 } else {
1848 dev_err(&u132->platform_dev->dev, "platform_device missing\n"); 1837 dev_err(&u132->platform_dev->dev, "platform_device missing\n");
1849 return -ENODEV; 1838 return -ENODEV;
1850 } 1839 }
1851} 1840}
1852 1841
1853static int u132_hcd_reset(struct usb_hcd *hcd) 1842static int u132_hcd_reset(struct usb_hcd *hcd)
1854{ 1843{
1855 struct u132 *u132 = hcd_to_u132(hcd); 1844 struct u132 *u132 = hcd_to_u132(hcd);
1856 if (u132->going > 1) { 1845 if (u132->going > 1) {
1857 dev_err(&u132->platform_dev->dev, "device has been removed %d\n" 1846 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
1858 , u132->going); 1847 , u132->going);
1859 return -ENODEV; 1848 return -ENODEV;
1860 } else if (u132->going > 0) { 1849 } else if (u132->going > 0) {
1861 dev_err(&u132->platform_dev->dev, "device is being removed\n"); 1850 dev_err(&u132->platform_dev->dev, "device is being removed\n");
1862 return -ESHUTDOWN; 1851 return -ESHUTDOWN;
1863 } else { 1852 } else {
1864 int retval; 1853 int retval;
1865 mutex_lock(&u132->sw_lock); 1854 mutex_lock(&u132->sw_lock);
1866 retval = u132_init(u132); 1855 retval = u132_init(u132);
1867 if (retval) { 1856 if (retval) {
1868 u132_disable(u132); 1857 u132_disable(u132);
1869 u132->going = 1; 1858 u132->going = 1;
1870 } 1859 }
1871 mutex_unlock(&u132->sw_lock); 1860 mutex_unlock(&u132->sw_lock);
1872 return retval; 1861 return retval;
1873 } 1862 }
1874} 1863}
1875 1864
1876static int create_endpoint_and_queue_int(struct u132 *u132, 1865static int create_endpoint_and_queue_int(struct u132 *u132,
1877 struct u132_udev *udev, struct urb *urb, 1866 struct u132_udev *udev, struct urb *urb,
1878 struct usb_device *usb_dev, u8 usb_addr, u8 usb_endp, u8 address, 1867 struct usb_device *usb_dev, u8 usb_addr, u8 usb_endp, u8 address,
1879 gfp_t mem_flags) 1868 gfp_t mem_flags)
1880{ 1869{
1881 struct u132_ring *ring; 1870 struct u132_ring *ring;
1882 unsigned long irqs; 1871 unsigned long irqs;
1883 int rc; 1872 int rc;
1884 u8 endp_number; 1873 u8 endp_number;
1885 struct u132_endp *endp = kmalloc(sizeof(struct u132_endp), mem_flags); 1874 struct u132_endp *endp = kmalloc(sizeof(struct u132_endp), mem_flags);
1886 1875
1887 if (!endp) { 1876 if (!endp)
1888 return -ENOMEM; 1877 return -ENOMEM;
1889 }
1890 1878
1891 spin_lock_init(&endp->queue_lock.slock); 1879 spin_lock_init(&endp->queue_lock.slock);
1892 spin_lock_irqsave(&endp->queue_lock.slock, irqs); 1880 spin_lock_irqsave(&endp->queue_lock.slock, irqs);
@@ -1899,94 +1887,93 @@ static int create_endpoint_and_queue_int(struct u132 *u132,
1899 1887
1900 endp_number = ++u132->num_endpoints; 1888 endp_number = ++u132->num_endpoints;
1901 urb->ep->hcpriv = u132->endp[endp_number - 1] = endp; 1889 urb->ep->hcpriv = u132->endp[endp_number - 1] = endp;
1902 INIT_DELAYED_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler); 1890 INIT_DELAYED_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler);
1903 INIT_LIST_HEAD(&endp->urb_more); 1891 INIT_LIST_HEAD(&endp->urb_more);
1904 ring = endp->ring = &u132->ring[0]; 1892 ring = endp->ring = &u132->ring[0];
1905 if (ring->curr_endp) { 1893 if (ring->curr_endp) {
1906 list_add_tail(&endp->endp_ring, &ring->curr_endp->endp_ring); 1894 list_add_tail(&endp->endp_ring, &ring->curr_endp->endp_ring);
1907 } else { 1895 } else {
1908 INIT_LIST_HEAD(&endp->endp_ring); 1896 INIT_LIST_HEAD(&endp->endp_ring);
1909 ring->curr_endp = endp; 1897 ring->curr_endp = endp;
1910 } 1898 }
1911 ring->length += 1; 1899 ring->length += 1;
1912 endp->dequeueing = 0; 1900 endp->dequeueing = 0;
1913 endp->edset_flush = 0; 1901 endp->edset_flush = 0;
1914 endp->active = 0; 1902 endp->active = 0;
1915 endp->delayed = 0; 1903 endp->delayed = 0;
1916 endp->endp_number = endp_number; 1904 endp->endp_number = endp_number;
1917 endp->u132 = u132; 1905 endp->u132 = u132;
1918 endp->hep = urb->ep; 1906 endp->hep = urb->ep;
1919 endp->pipetype = usb_pipetype(urb->pipe); 1907 endp->pipetype = usb_pipetype(urb->pipe);
1920 u132_endp_init_kref(u132, endp); 1908 u132_endp_init_kref(u132, endp);
1921 if (usb_pipein(urb->pipe)) { 1909 if (usb_pipein(urb->pipe)) {
1922 endp->toggle_bits = 0x2; 1910 endp->toggle_bits = 0x2;
1923 usb_settoggle(udev->usb_device, usb_endp, 0, 0); 1911 usb_settoggle(udev->usb_device, usb_endp, 0, 0);
1924 endp->input = 1; 1912 endp->input = 1;
1925 endp->output = 0; 1913 endp->output = 0;
1926 udev->endp_number_in[usb_endp] = endp_number; 1914 udev->endp_number_in[usb_endp] = endp_number;
1927 u132_udev_get_kref(u132, udev); 1915 u132_udev_get_kref(u132, udev);
1928 } else { 1916 } else {
1929 endp->toggle_bits = 0x2; 1917 endp->toggle_bits = 0x2;
1930 usb_settoggle(udev->usb_device, usb_endp, 1, 0); 1918 usb_settoggle(udev->usb_device, usb_endp, 1, 0);
1931 endp->input = 0; 1919 endp->input = 0;
1932 endp->output = 1; 1920 endp->output = 1;
1933 udev->endp_number_out[usb_endp] = endp_number; 1921 udev->endp_number_out[usb_endp] = endp_number;
1934 u132_udev_get_kref(u132, udev); 1922 u132_udev_get_kref(u132, udev);
1935 } 1923 }
1936 urb->hcpriv = u132; 1924 urb->hcpriv = u132;
1937 endp->delayed = 1; 1925 endp->delayed = 1;
1938 endp->jiffies = jiffies + msecs_to_jiffies(urb->interval); 1926 endp->jiffies = jiffies + msecs_to_jiffies(urb->interval);
1939 endp->udev_number = address; 1927 endp->udev_number = address;
1940 endp->usb_addr = usb_addr; 1928 endp->usb_addr = usb_addr;
1941 endp->usb_endp = usb_endp; 1929 endp->usb_endp = usb_endp;
1942 endp->queue_size = 1; 1930 endp->queue_size = 1;
1943 endp->queue_last = 0; 1931 endp->queue_last = 0;
1944 endp->queue_next = 0; 1932 endp->queue_next = 0;
1945 endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb; 1933 endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb;
1946 spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); 1934 spin_unlock_irqrestore(&endp->queue_lock.slock, irqs);
1947 u132_endp_queue_work(u132, endp, msecs_to_jiffies(urb->interval)); 1935 u132_endp_queue_work(u132, endp, msecs_to_jiffies(urb->interval));
1948 return 0; 1936 return 0;
1949} 1937}
1950 1938
1951static int queue_int_on_old_endpoint(struct u132 *u132, 1939static int queue_int_on_old_endpoint(struct u132 *u132,
1952 struct u132_udev *udev, struct urb *urb, 1940 struct u132_udev *udev, struct urb *urb,
1953 struct usb_device *usb_dev, struct u132_endp *endp, u8 usb_addr, 1941 struct usb_device *usb_dev, struct u132_endp *endp, u8 usb_addr,
1954 u8 usb_endp, u8 address) 1942 u8 usb_endp, u8 address)
1955{ 1943{
1956 urb->hcpriv = u132; 1944 urb->hcpriv = u132;
1957 endp->delayed = 1; 1945 endp->delayed = 1;
1958 endp->jiffies = jiffies + msecs_to_jiffies(urb->interval); 1946 endp->jiffies = jiffies + msecs_to_jiffies(urb->interval);
1959 if (endp->queue_size++ < ENDP_QUEUE_SIZE) { 1947 if (endp->queue_size++ < ENDP_QUEUE_SIZE) {
1960 endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb; 1948 endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb;
1961 } else { 1949 } else {
1962 struct u132_urbq *urbq = kmalloc(sizeof(struct u132_urbq), 1950 struct u132_urbq *urbq = kmalloc(sizeof(struct u132_urbq),
1963 GFP_ATOMIC); 1951 GFP_ATOMIC);
1964 if (urbq == NULL) { 1952 if (urbq == NULL) {
1965 endp->queue_size -= 1; 1953 endp->queue_size -= 1;
1966 return -ENOMEM; 1954 return -ENOMEM;
1967 } else { 1955 } else {
1968 list_add_tail(&urbq->urb_more, &endp->urb_more); 1956 list_add_tail(&urbq->urb_more, &endp->urb_more);
1969 urbq->urb = urb; 1957 urbq->urb = urb;
1970 } 1958 }
1971 } 1959 }
1972 return 0; 1960 return 0;
1973} 1961}
1974 1962
1975static int create_endpoint_and_queue_bulk(struct u132 *u132, 1963static int create_endpoint_and_queue_bulk(struct u132 *u132,
1976 struct u132_udev *udev, struct urb *urb, 1964 struct u132_udev *udev, struct urb *urb,
1977 struct usb_device *usb_dev, u8 usb_addr, u8 usb_endp, u8 address, 1965 struct usb_device *usb_dev, u8 usb_addr, u8 usb_endp, u8 address,
1978 gfp_t mem_flags) 1966 gfp_t mem_flags)
1979{ 1967{
1980 int ring_number; 1968 int ring_number;
1981 struct u132_ring *ring; 1969 struct u132_ring *ring;
1982 unsigned long irqs; 1970 unsigned long irqs;
1983 int rc; 1971 int rc;
1984 u8 endp_number; 1972 u8 endp_number;
1985 struct u132_endp *endp = kmalloc(sizeof(struct u132_endp), mem_flags); 1973 struct u132_endp *endp = kmalloc(sizeof(struct u132_endp), mem_flags);
1986 1974
1987 if (!endp) { 1975 if (!endp)
1988 return -ENOMEM; 1976 return -ENOMEM;
1989 }
1990 1977
1991 spin_lock_init(&endp->queue_lock.slock); 1978 spin_lock_init(&endp->queue_lock.slock);
1992 spin_lock_irqsave(&endp->queue_lock.slock, irqs); 1979 spin_lock_irqsave(&endp->queue_lock.slock, irqs);
@@ -1999,91 +1986,90 @@ static int create_endpoint_and_queue_bulk(struct u132 *u132,
1999 1986
2000 endp_number = ++u132->num_endpoints; 1987 endp_number = ++u132->num_endpoints;
2001 urb->ep->hcpriv = u132->endp[endp_number - 1] = endp; 1988 urb->ep->hcpriv = u132->endp[endp_number - 1] = endp;
2002 INIT_DELAYED_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler); 1989 INIT_DELAYED_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler);
2003 INIT_LIST_HEAD(&endp->urb_more); 1990 INIT_LIST_HEAD(&endp->urb_more);
2004 endp->dequeueing = 0; 1991 endp->dequeueing = 0;
2005 endp->edset_flush = 0; 1992 endp->edset_flush = 0;
2006 endp->active = 0; 1993 endp->active = 0;
2007 endp->delayed = 0; 1994 endp->delayed = 0;
2008 endp->endp_number = endp_number; 1995 endp->endp_number = endp_number;
2009 endp->u132 = u132; 1996 endp->u132 = u132;
2010 endp->hep = urb->ep; 1997 endp->hep = urb->ep;
2011 endp->pipetype = usb_pipetype(urb->pipe); 1998 endp->pipetype = usb_pipetype(urb->pipe);
2012 u132_endp_init_kref(u132, endp); 1999 u132_endp_init_kref(u132, endp);
2013 if (usb_pipein(urb->pipe)) { 2000 if (usb_pipein(urb->pipe)) {
2014 endp->toggle_bits = 0x2; 2001 endp->toggle_bits = 0x2;
2015 usb_settoggle(udev->usb_device, usb_endp, 0, 0); 2002 usb_settoggle(udev->usb_device, usb_endp, 0, 0);
2016 ring_number = 3; 2003 ring_number = 3;
2017 endp->input = 1; 2004 endp->input = 1;
2018 endp->output = 0; 2005 endp->output = 0;
2019 udev->endp_number_in[usb_endp] = endp_number; 2006 udev->endp_number_in[usb_endp] = endp_number;
2020 u132_udev_get_kref(u132, udev); 2007 u132_udev_get_kref(u132, udev);
2021 } else { 2008 } else {
2022 endp->toggle_bits = 0x2; 2009 endp->toggle_bits = 0x2;
2023 usb_settoggle(udev->usb_device, usb_endp, 1, 0); 2010 usb_settoggle(udev->usb_device, usb_endp, 1, 0);
2024 ring_number = 2; 2011 ring_number = 2;
2025 endp->input = 0; 2012 endp->input = 0;
2026 endp->output = 1; 2013 endp->output = 1;
2027 udev->endp_number_out[usb_endp] = endp_number; 2014 udev->endp_number_out[usb_endp] = endp_number;
2028 u132_udev_get_kref(u132, udev); 2015 u132_udev_get_kref(u132, udev);
2029 } 2016 }
2030 ring = endp->ring = &u132->ring[ring_number - 1]; 2017 ring = endp->ring = &u132->ring[ring_number - 1];
2031 if (ring->curr_endp) { 2018 if (ring->curr_endp) {
2032 list_add_tail(&endp->endp_ring, &ring->curr_endp->endp_ring); 2019 list_add_tail(&endp->endp_ring, &ring->curr_endp->endp_ring);
2033 } else { 2020 } else {
2034 INIT_LIST_HEAD(&endp->endp_ring); 2021 INIT_LIST_HEAD(&endp->endp_ring);
2035 ring->curr_endp = endp; 2022 ring->curr_endp = endp;
2036 } 2023 }
2037 ring->length += 1; 2024 ring->length += 1;
2038 urb->hcpriv = u132; 2025 urb->hcpriv = u132;
2039 endp->udev_number = address; 2026 endp->udev_number = address;
2040 endp->usb_addr = usb_addr; 2027 endp->usb_addr = usb_addr;
2041 endp->usb_endp = usb_endp; 2028 endp->usb_endp = usb_endp;
2042 endp->queue_size = 1; 2029 endp->queue_size = 1;
2043 endp->queue_last = 0; 2030 endp->queue_last = 0;
2044 endp->queue_next = 0; 2031 endp->queue_next = 0;
2045 endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb; 2032 endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb;
2046 spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); 2033 spin_unlock_irqrestore(&endp->queue_lock.slock, irqs);
2047 u132_endp_queue_work(u132, endp, 0); 2034 u132_endp_queue_work(u132, endp, 0);
2048 return 0; 2035 return 0;
2049} 2036}
2050 2037
2051static int queue_bulk_on_old_endpoint(struct u132 *u132, struct u132_udev *udev, 2038static int queue_bulk_on_old_endpoint(struct u132 *u132, struct u132_udev *udev,
2052 struct urb *urb, 2039 struct urb *urb,
2053 struct usb_device *usb_dev, struct u132_endp *endp, u8 usb_addr, 2040 struct usb_device *usb_dev, struct u132_endp *endp, u8 usb_addr,
2054 u8 usb_endp, u8 address) 2041 u8 usb_endp, u8 address)
2055{ 2042{
2056 urb->hcpriv = u132; 2043 urb->hcpriv = u132;
2057 if (endp->queue_size++ < ENDP_QUEUE_SIZE) { 2044 if (endp->queue_size++ < ENDP_QUEUE_SIZE) {
2058 endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb; 2045 endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb;
2059 } else { 2046 } else {
2060 struct u132_urbq *urbq = kmalloc(sizeof(struct u132_urbq), 2047 struct u132_urbq *urbq = kmalloc(sizeof(struct u132_urbq),
2061 GFP_ATOMIC); 2048 GFP_ATOMIC);
2062 if (urbq == NULL) { 2049 if (urbq == NULL) {
2063 endp->queue_size -= 1; 2050 endp->queue_size -= 1;
2064 return -ENOMEM; 2051 return -ENOMEM;
2065 } else { 2052 } else {
2066 list_add_tail(&urbq->urb_more, &endp->urb_more); 2053 list_add_tail(&urbq->urb_more, &endp->urb_more);
2067 urbq->urb = urb; 2054 urbq->urb = urb;
2068 } 2055 }
2069 } 2056 }
2070 return 0; 2057 return 0;
2071} 2058}
2072 2059
2073static int create_endpoint_and_queue_control(struct u132 *u132, 2060static int create_endpoint_and_queue_control(struct u132 *u132,
2074 struct urb *urb, 2061 struct urb *urb,
2075 struct usb_device *usb_dev, u8 usb_addr, u8 usb_endp, 2062 struct usb_device *usb_dev, u8 usb_addr, u8 usb_endp,
2076 gfp_t mem_flags) 2063 gfp_t mem_flags)
2077{ 2064{
2078 struct u132_ring *ring; 2065 struct u132_ring *ring;
2079 unsigned long irqs; 2066 unsigned long irqs;
2080 int rc; 2067 int rc;
2081 u8 endp_number; 2068 u8 endp_number;
2082 struct u132_endp *endp = kmalloc(sizeof(struct u132_endp), mem_flags); 2069 struct u132_endp *endp = kmalloc(sizeof(struct u132_endp), mem_flags);
2083 2070
2084 if (!endp) { 2071 if (!endp)
2085 return -ENOMEM; 2072 return -ENOMEM;
2086 }
2087 2073
2088 spin_lock_init(&endp->queue_lock.slock); 2074 spin_lock_init(&endp->queue_lock.slock);
2089 spin_lock_irqsave(&endp->queue_lock.slock, irqs); 2075 spin_lock_irqsave(&endp->queue_lock.slock, irqs);
@@ -2096,204 +2082,203 @@ static int create_endpoint_and_queue_control(struct u132 *u132,
2096 2082
2097 endp_number = ++u132->num_endpoints; 2083 endp_number = ++u132->num_endpoints;
2098 urb->ep->hcpriv = u132->endp[endp_number - 1] = endp; 2084 urb->ep->hcpriv = u132->endp[endp_number - 1] = endp;
2099 INIT_DELAYED_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler); 2085 INIT_DELAYED_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler);
2100 INIT_LIST_HEAD(&endp->urb_more); 2086 INIT_LIST_HEAD(&endp->urb_more);
2101 ring = endp->ring = &u132->ring[0]; 2087 ring = endp->ring = &u132->ring[0];
2102 if (ring->curr_endp) { 2088 if (ring->curr_endp) {
2103 list_add_tail(&endp->endp_ring, &ring->curr_endp->endp_ring); 2089 list_add_tail(&endp->endp_ring, &ring->curr_endp->endp_ring);
2104 } else { 2090 } else {
2105 INIT_LIST_HEAD(&endp->endp_ring); 2091 INIT_LIST_HEAD(&endp->endp_ring);
2106 ring->curr_endp = endp; 2092 ring->curr_endp = endp;
2107 } 2093 }
2108 ring->length += 1; 2094 ring->length += 1;
2109 endp->dequeueing = 0; 2095 endp->dequeueing = 0;
2110 endp->edset_flush = 0; 2096 endp->edset_flush = 0;
2111 endp->active = 0; 2097 endp->active = 0;
2112 endp->delayed = 0; 2098 endp->delayed = 0;
2113 endp->endp_number = endp_number; 2099 endp->endp_number = endp_number;
2114 endp->u132 = u132; 2100 endp->u132 = u132;
2115 endp->hep = urb->ep; 2101 endp->hep = urb->ep;
2116 u132_endp_init_kref(u132, endp); 2102 u132_endp_init_kref(u132, endp);
2117 u132_endp_get_kref(u132, endp); 2103 u132_endp_get_kref(u132, endp);
2118 if (usb_addr == 0) { 2104 if (usb_addr == 0) {
2119 u8 address = u132->addr[usb_addr].address; 2105 u8 address = u132->addr[usb_addr].address;
2120 struct u132_udev *udev = &u132->udev[address]; 2106 struct u132_udev *udev = &u132->udev[address];
2121 endp->udev_number = address; 2107 endp->udev_number = address;
2122 endp->usb_addr = usb_addr; 2108 endp->usb_addr = usb_addr;
2123 endp->usb_endp = usb_endp; 2109 endp->usb_endp = usb_endp;
2124 endp->input = 1; 2110 endp->input = 1;
2125 endp->output = 1; 2111 endp->output = 1;
2126 endp->pipetype = usb_pipetype(urb->pipe); 2112 endp->pipetype = usb_pipetype(urb->pipe);
2127 u132_udev_init_kref(u132, udev); 2113 u132_udev_init_kref(u132, udev);
2128 u132_udev_get_kref(u132, udev); 2114 u132_udev_get_kref(u132, udev);
2129 udev->endp_number_in[usb_endp] = endp_number; 2115 udev->endp_number_in[usb_endp] = endp_number;
2130 udev->endp_number_out[usb_endp] = endp_number; 2116 udev->endp_number_out[usb_endp] = endp_number;
2131 urb->hcpriv = u132; 2117 urb->hcpriv = u132;
2132 endp->queue_size = 1; 2118 endp->queue_size = 1;
2133 endp->queue_last = 0; 2119 endp->queue_last = 0;
2134 endp->queue_next = 0; 2120 endp->queue_next = 0;
2135 endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb; 2121 endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb;
2136 spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); 2122 spin_unlock_irqrestore(&endp->queue_lock.slock, irqs);
2137 u132_endp_queue_work(u132, endp, 0); 2123 u132_endp_queue_work(u132, endp, 0);
2138 return 0; 2124 return 0;
2139 } else { /*(usb_addr > 0) */ 2125 } else { /*(usb_addr > 0) */
2140 u8 address = u132->addr[usb_addr].address; 2126 u8 address = u132->addr[usb_addr].address;
2141 struct u132_udev *udev = &u132->udev[address]; 2127 struct u132_udev *udev = &u132->udev[address];
2142 endp->udev_number = address; 2128 endp->udev_number = address;
2143 endp->usb_addr = usb_addr; 2129 endp->usb_addr = usb_addr;
2144 endp->usb_endp = usb_endp; 2130 endp->usb_endp = usb_endp;
2145 endp->input = 1; 2131 endp->input = 1;
2146 endp->output = 1; 2132 endp->output = 1;
2147 endp->pipetype = usb_pipetype(urb->pipe); 2133 endp->pipetype = usb_pipetype(urb->pipe);
2148 u132_udev_get_kref(u132, udev); 2134 u132_udev_get_kref(u132, udev);
2149 udev->enumeration = 2; 2135 udev->enumeration = 2;
2150 udev->endp_number_in[usb_endp] = endp_number; 2136 udev->endp_number_in[usb_endp] = endp_number;
2151 udev->endp_number_out[usb_endp] = endp_number; 2137 udev->endp_number_out[usb_endp] = endp_number;
2152 urb->hcpriv = u132; 2138 urb->hcpriv = u132;
2153 endp->queue_size = 1; 2139 endp->queue_size = 1;
2154 endp->queue_last = 0; 2140 endp->queue_last = 0;
2155 endp->queue_next = 0; 2141 endp->queue_next = 0;
2156 endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb; 2142 endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb;
2157 spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); 2143 spin_unlock_irqrestore(&endp->queue_lock.slock, irqs);
2158 u132_endp_queue_work(u132, endp, 0); 2144 u132_endp_queue_work(u132, endp, 0);
2159 return 0; 2145 return 0;
2160 } 2146 }
2161} 2147}
2162 2148
2163static int queue_control_on_old_endpoint(struct u132 *u132, 2149static int queue_control_on_old_endpoint(struct u132 *u132,
2164 struct urb *urb, 2150 struct urb *urb,
2165 struct usb_device *usb_dev, struct u132_endp *endp, u8 usb_addr, 2151 struct usb_device *usb_dev, struct u132_endp *endp, u8 usb_addr,
2166 u8 usb_endp) 2152 u8 usb_endp)
2167{ 2153{
2168 if (usb_addr == 0) { 2154 if (usb_addr == 0) {
2169 if (usb_pipein(urb->pipe)) { 2155 if (usb_pipein(urb->pipe)) {
2170 urb->hcpriv = u132; 2156 urb->hcpriv = u132;
2171 if (endp->queue_size++ < ENDP_QUEUE_SIZE) { 2157 if (endp->queue_size++ < ENDP_QUEUE_SIZE) {
2172 endp->urb_list[ENDP_QUEUE_MASK & 2158 endp->urb_list[ENDP_QUEUE_MASK &
2173 endp->queue_last++] = urb; 2159 endp->queue_last++] = urb;
2174 } else { 2160 } else {
2175 struct u132_urbq *urbq = 2161 struct u132_urbq *urbq =
2176 kmalloc(sizeof(struct u132_urbq), 2162 kmalloc(sizeof(struct u132_urbq),
2177 GFP_ATOMIC); 2163 GFP_ATOMIC);
2178 if (urbq == NULL) { 2164 if (urbq == NULL) {
2179 endp->queue_size -= 1; 2165 endp->queue_size -= 1;
2180 return -ENOMEM; 2166 return -ENOMEM;
2181 } else { 2167 } else {
2182 list_add_tail(&urbq->urb_more, 2168 list_add_tail(&urbq->urb_more,
2183 &endp->urb_more); 2169 &endp->urb_more);
2184 urbq->urb = urb; 2170 urbq->urb = urb;
2185 } 2171 }
2186 } 2172 }
2187 return 0; 2173 return 0;
2188 } else { /* usb_pipeout(urb->pipe) */ 2174 } else { /* usb_pipeout(urb->pipe) */
2189 struct u132_addr *addr = &u132->addr[usb_dev->devnum]; 2175 struct u132_addr *addr = &u132->addr[usb_dev->devnum];
2190 int I = MAX_U132_UDEVS; 2176 int I = MAX_U132_UDEVS;
2191 int i = 0; 2177 int i = 0;
2192 while (--I > 0) { 2178 while (--I > 0) {
2193 struct u132_udev *udev = &u132->udev[++i]; 2179 struct u132_udev *udev = &u132->udev[++i];
2194 if (udev->usb_device) { 2180 if (udev->usb_device) {
2195 continue; 2181 continue;
2196 } else { 2182 } else {
2197 udev->enumeration = 1; 2183 udev->enumeration = 1;
2198 u132->addr[0].address = i; 2184 u132->addr[0].address = i;
2199 endp->udev_number = i; 2185 endp->udev_number = i;
2200 udev->udev_number = i; 2186 udev->udev_number = i;
2201 udev->usb_addr = usb_dev->devnum; 2187 udev->usb_addr = usb_dev->devnum;
2202 u132_udev_init_kref(u132, udev); 2188 u132_udev_init_kref(u132, udev);
2203 udev->endp_number_in[usb_endp] = 2189 udev->endp_number_in[usb_endp] =
2204 endp->endp_number; 2190 endp->endp_number;
2205 u132_udev_get_kref(u132, udev); 2191 u132_udev_get_kref(u132, udev);
2206 udev->endp_number_out[usb_endp] = 2192 udev->endp_number_out[usb_endp] =
2207 endp->endp_number; 2193 endp->endp_number;
2208 udev->usb_device = usb_dev; 2194 udev->usb_device = usb_dev;
2209 ((u8 *) (urb->setup_packet))[2] = 2195 ((u8 *) (urb->setup_packet))[2] =
2210 addr->address = i; 2196 addr->address = i;
2211 u132_udev_get_kref(u132, udev); 2197 u132_udev_get_kref(u132, udev);
2212 break; 2198 break;
2213 } 2199 }
2214 } 2200 }
2215 if (I == 0) { 2201 if (I == 0) {
2216 dev_err(&u132->platform_dev->dev, "run out of d" 2202 dev_err(&u132->platform_dev->dev, "run out of d"
2217 "evice space\n"); 2203 "evice space\n");
2218 return -EINVAL; 2204 return -EINVAL;
2219 } 2205 }
2220 urb->hcpriv = u132; 2206 urb->hcpriv = u132;
2221 if (endp->queue_size++ < ENDP_QUEUE_SIZE) { 2207 if (endp->queue_size++ < ENDP_QUEUE_SIZE) {
2222 endp->urb_list[ENDP_QUEUE_MASK & 2208 endp->urb_list[ENDP_QUEUE_MASK &
2223 endp->queue_last++] = urb; 2209 endp->queue_last++] = urb;
2224 } else { 2210 } else {
2225 struct u132_urbq *urbq = 2211 struct u132_urbq *urbq =
2226 kmalloc(sizeof(struct u132_urbq), 2212 kmalloc(sizeof(struct u132_urbq),
2227 GFP_ATOMIC); 2213 GFP_ATOMIC);
2228 if (urbq == NULL) { 2214 if (urbq == NULL) {
2229 endp->queue_size -= 1; 2215 endp->queue_size -= 1;
2230 return -ENOMEM; 2216 return -ENOMEM;
2231 } else { 2217 } else {
2232 list_add_tail(&urbq->urb_more, 2218 list_add_tail(&urbq->urb_more,
2233 &endp->urb_more); 2219 &endp->urb_more);
2234 urbq->urb = urb; 2220 urbq->urb = urb;
2235 } 2221 }
2236 } 2222 }
2237 return 0; 2223 return 0;
2238 } 2224 }
2239 } else { /*(usb_addr > 0) */ 2225 } else { /*(usb_addr > 0) */
2240 u8 address = u132->addr[usb_addr].address; 2226 u8 address = u132->addr[usb_addr].address;
2241 struct u132_udev *udev = &u132->udev[address]; 2227 struct u132_udev *udev = &u132->udev[address];
2242 urb->hcpriv = u132; 2228 urb->hcpriv = u132;
2243 if (udev->enumeration == 2) { 2229 if (udev->enumeration != 2)
2244 } else 2230 udev->enumeration = 2;
2245 udev->enumeration = 2; 2231 if (endp->queue_size++ < ENDP_QUEUE_SIZE) {
2246 if (endp->queue_size++ < ENDP_QUEUE_SIZE) { 2232 endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] =
2247 endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = 2233 urb;
2248 urb; 2234 } else {
2249 } else { 2235 struct u132_urbq *urbq =
2250 struct u132_urbq *urbq = 2236 kmalloc(sizeof(struct u132_urbq), GFP_ATOMIC);
2251 kmalloc(sizeof(struct u132_urbq), GFP_ATOMIC); 2237 if (urbq == NULL) {
2252 if (urbq == NULL) { 2238 endp->queue_size -= 1;
2253 endp->queue_size -= 1; 2239 return -ENOMEM;
2254 return -ENOMEM; 2240 } else {
2255 } else { 2241 list_add_tail(&urbq->urb_more, &endp->urb_more);
2256 list_add_tail(&urbq->urb_more, &endp->urb_more); 2242 urbq->urb = urb;
2257 urbq->urb = urb; 2243 }
2258 } 2244 }
2259 } 2245 return 0;
2260 return 0; 2246 }
2261 }
2262} 2247}
2263 2248
2264static int u132_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, 2249static int u132_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
2265 gfp_t mem_flags) 2250 gfp_t mem_flags)
2266{ 2251{
2267 struct u132 *u132 = hcd_to_u132(hcd); 2252 struct u132 *u132 = hcd_to_u132(hcd);
2268 if (irqs_disabled()) { 2253 if (irqs_disabled()) {
2269 if (__GFP_WAIT & mem_flags) { 2254 if (__GFP_WAIT & mem_flags) {
2270 printk(KERN_ERR "invalid context for function that migh" 2255 printk(KERN_ERR "invalid context for function that migh"
2271 "t sleep\n"); 2256 "t sleep\n");
2272 return -EINVAL; 2257 return -EINVAL;
2273 } 2258 }
2274 } 2259 }
2275 if (u132->going > 1) { 2260 if (u132->going > 1) {
2276 dev_err(&u132->platform_dev->dev, "device has been removed %d\n" 2261 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
2277 , u132->going); 2262 , u132->going);
2278 return -ENODEV; 2263 return -ENODEV;
2279 } else if (u132->going > 0) { 2264 } else if (u132->going > 0) {
2280 dev_err(&u132->platform_dev->dev, "device is being removed " 2265 dev_err(&u132->platform_dev->dev, "device is being removed "
2281 "urb=%p\n", urb); 2266 "urb=%p\n", urb);
2282 return -ESHUTDOWN; 2267 return -ESHUTDOWN;
2283 } else { 2268 } else {
2284 u8 usb_addr = usb_pipedevice(urb->pipe); 2269 u8 usb_addr = usb_pipedevice(urb->pipe);
2285 u8 usb_endp = usb_pipeendpoint(urb->pipe); 2270 u8 usb_endp = usb_pipeendpoint(urb->pipe);
2286 struct usb_device *usb_dev = urb->dev; 2271 struct usb_device *usb_dev = urb->dev;
2287 if (usb_pipetype(urb->pipe) == PIPE_INTERRUPT) { 2272 if (usb_pipetype(urb->pipe) == PIPE_INTERRUPT) {
2288 u8 address = u132->addr[usb_addr].address; 2273 u8 address = u132->addr[usb_addr].address;
2289 struct u132_udev *udev = &u132->udev[address]; 2274 struct u132_udev *udev = &u132->udev[address];
2290 struct u132_endp *endp = urb->ep->hcpriv; 2275 struct u132_endp *endp = urb->ep->hcpriv;
2291 urb->actual_length = 0; 2276 urb->actual_length = 0;
2292 if (endp) { 2277 if (endp) {
2293 unsigned long irqs; 2278 unsigned long irqs;
2294 int retval; 2279 int retval;
2295 spin_lock_irqsave(&endp->queue_lock.slock, 2280 spin_lock_irqsave(&endp->queue_lock.slock,
2296 irqs); 2281 irqs);
2297 retval = usb_hcd_link_urb_to_ep(hcd, urb); 2282 retval = usb_hcd_link_urb_to_ep(hcd, urb);
2298 if (retval == 0) { 2283 if (retval == 0) {
2299 retval = queue_int_on_old_endpoint( 2284 retval = queue_int_on_old_endpoint(
@@ -2303,39 +2288,39 @@ static int u132_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
2303 address); 2288 address);
2304 if (retval) 2289 if (retval)
2305 usb_hcd_unlink_urb_from_ep( 2290 usb_hcd_unlink_urb_from_ep(
2306 hcd, urb); 2291 hcd, urb);
2307 } 2292 }
2308 spin_unlock_irqrestore(&endp->queue_lock.slock, 2293 spin_unlock_irqrestore(&endp->queue_lock.slock,
2309 irqs); 2294 irqs);
2310 if (retval) { 2295 if (retval) {
2311 return retval; 2296 return retval;
2312 } else { 2297 } else {
2313 u132_endp_queue_work(u132, endp, 2298 u132_endp_queue_work(u132, endp,
2314 msecs_to_jiffies(urb->interval)) 2299 msecs_to_jiffies(urb->interval))
2315 ; 2300 ;
2316 return 0; 2301 return 0;
2317 } 2302 }
2318 } else if (u132->num_endpoints == MAX_U132_ENDPS) { 2303 } else if (u132->num_endpoints == MAX_U132_ENDPS) {
2319 return -EINVAL; 2304 return -EINVAL;
2320 } else { /*(endp == NULL) */ 2305 } else { /*(endp == NULL) */
2321 return create_endpoint_and_queue_int(u132, udev, 2306 return create_endpoint_and_queue_int(u132, udev,
2322 urb, usb_dev, usb_addr, 2307 urb, usb_dev, usb_addr,
2323 usb_endp, address, mem_flags); 2308 usb_endp, address, mem_flags);
2324 } 2309 }
2325 } else if (usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS) { 2310 } else if (usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS) {
2326 dev_err(&u132->platform_dev->dev, "the hardware does no" 2311 dev_err(&u132->platform_dev->dev, "the hardware does no"
2327 "t support PIPE_ISOCHRONOUS\n"); 2312 "t support PIPE_ISOCHRONOUS\n");
2328 return -EINVAL; 2313 return -EINVAL;
2329 } else if (usb_pipetype(urb->pipe) == PIPE_BULK) { 2314 } else if (usb_pipetype(urb->pipe) == PIPE_BULK) {
2330 u8 address = u132->addr[usb_addr].address; 2315 u8 address = u132->addr[usb_addr].address;
2331 struct u132_udev *udev = &u132->udev[address]; 2316 struct u132_udev *udev = &u132->udev[address];
2332 struct u132_endp *endp = urb->ep->hcpriv; 2317 struct u132_endp *endp = urb->ep->hcpriv;
2333 urb->actual_length = 0; 2318 urb->actual_length = 0;
2334 if (endp) { 2319 if (endp) {
2335 unsigned long irqs; 2320 unsigned long irqs;
2336 int retval; 2321 int retval;
2337 spin_lock_irqsave(&endp->queue_lock.slock, 2322 spin_lock_irqsave(&endp->queue_lock.slock,
2338 irqs); 2323 irqs);
2339 retval = usb_hcd_link_urb_to_ep(hcd, urb); 2324 retval = usb_hcd_link_urb_to_ep(hcd, urb);
2340 if (retval == 0) { 2325 if (retval == 0) {
2341 retval = queue_bulk_on_old_endpoint( 2326 retval = queue_bulk_on_old_endpoint(
@@ -2345,46 +2330,46 @@ static int u132_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
2345 address); 2330 address);
2346 if (retval) 2331 if (retval)
2347 usb_hcd_unlink_urb_from_ep( 2332 usb_hcd_unlink_urb_from_ep(
2348 hcd, urb); 2333 hcd, urb);
2334 }
2335 spin_unlock_irqrestore(&endp->queue_lock.slock,
2336 irqs);
2337 if (retval) {
2338 return retval;
2339 } else {
2340 u132_endp_queue_work(u132, endp, 0);
2341 return 0;
2349 } 2342 }
2350 spin_unlock_irqrestore(&endp->queue_lock.slock, 2343 } else if (u132->num_endpoints == MAX_U132_ENDPS) {
2351 irqs); 2344 return -EINVAL;
2352 if (retval) { 2345 } else
2353 return retval; 2346 return create_endpoint_and_queue_bulk(u132,
2354 } else {
2355 u132_endp_queue_work(u132, endp, 0);
2356 return 0;
2357 }
2358 } else if (u132->num_endpoints == MAX_U132_ENDPS) {
2359 return -EINVAL;
2360 } else
2361 return create_endpoint_and_queue_bulk(u132,
2362 udev, urb, usb_dev, usb_addr, 2347 udev, urb, usb_dev, usb_addr,
2363 usb_endp, address, mem_flags); 2348 usb_endp, address, mem_flags);
2364 } else { 2349 } else {
2365 struct u132_endp *endp = urb->ep->hcpriv; 2350 struct u132_endp *endp = urb->ep->hcpriv;
2366 u16 urb_size = 8; 2351 u16 urb_size = 8;
2367 u8 *b = urb->setup_packet; 2352 u8 *b = urb->setup_packet;
2368 int i = 0; 2353 int i = 0;
2369 char data[30 *3 + 4]; 2354 char data[30 * 3 + 4];
2370 char *d = data; 2355 char *d = data;
2371 int m = (sizeof(data) - 1) / 3; 2356 int m = (sizeof(data) - 1) / 3;
2372 int l = 0; 2357 int l = 0;
2373 data[0] = 0; 2358 data[0] = 0;
2374 while (urb_size-- > 0) { 2359 while (urb_size-- > 0) {
2375 if (i > m) { 2360 if (i > m) {
2376 } else if (i++ < m) { 2361 } else if (i++ < m) {
2377 int w = sprintf(d, " %02X", *b++); 2362 int w = sprintf(d, " %02X", *b++);
2378 d += w; 2363 d += w;
2379 l += w; 2364 l += w;
2380 } else 2365 } else
2381 d += sprintf(d, " .."); 2366 d += sprintf(d, " ..");
2382 } 2367 }
2383 if (endp) { 2368 if (endp) {
2384 unsigned long irqs; 2369 unsigned long irqs;
2385 int retval; 2370 int retval;
2386 spin_lock_irqsave(&endp->queue_lock.slock, 2371 spin_lock_irqsave(&endp->queue_lock.slock,
2387 irqs); 2372 irqs);
2388 retval = usb_hcd_link_urb_to_ep(hcd, urb); 2373 retval = usb_hcd_link_urb_to_ep(hcd, urb);
2389 if (retval == 0) { 2374 if (retval == 0) {
2390 retval = queue_control_on_old_endpoint( 2375 retval = queue_control_on_old_endpoint(
@@ -2395,267 +2380,267 @@ static int u132_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
2395 usb_hcd_unlink_urb_from_ep( 2380 usb_hcd_unlink_urb_from_ep(
2396 hcd, urb); 2381 hcd, urb);
2397 } 2382 }
2398 spin_unlock_irqrestore(&endp->queue_lock.slock, 2383 spin_unlock_irqrestore(&endp->queue_lock.slock,
2399 irqs); 2384 irqs);
2400 if (retval) { 2385 if (retval) {
2401 return retval; 2386 return retval;
2402 } else { 2387 } else {
2403 u132_endp_queue_work(u132, endp, 0); 2388 u132_endp_queue_work(u132, endp, 0);
2404 return 0; 2389 return 0;
2405 } 2390 }
2406 } else if (u132->num_endpoints == MAX_U132_ENDPS) { 2391 } else if (u132->num_endpoints == MAX_U132_ENDPS) {
2407 return -EINVAL; 2392 return -EINVAL;
2408 } else 2393 } else
2409 return create_endpoint_and_queue_control(u132, 2394 return create_endpoint_and_queue_control(u132,
2410 urb, usb_dev, usb_addr, usb_endp, 2395 urb, usb_dev, usb_addr, usb_endp,
2411 mem_flags); 2396 mem_flags);
2412 } 2397 }
2413 } 2398 }
2414} 2399}
2415 2400
2416static int dequeue_from_overflow_chain(struct u132 *u132, 2401static int dequeue_from_overflow_chain(struct u132 *u132,
2417 struct u132_endp *endp, struct urb *urb) 2402 struct u132_endp *endp, struct urb *urb)
2418{ 2403{
2419 struct list_head *scan; 2404 struct list_head *scan;
2420 struct list_head *head = &endp->urb_more; 2405 struct list_head *head = &endp->urb_more;
2421 list_for_each(scan, head) { 2406 list_for_each(scan, head) {
2422 struct u132_urbq *urbq = list_entry(scan, struct u132_urbq, 2407 struct u132_urbq *urbq = list_entry(scan, struct u132_urbq,
2423 urb_more); 2408 urb_more);
2424 if (urbq->urb == urb) { 2409 if (urbq->urb == urb) {
2425 struct usb_hcd *hcd = u132_to_hcd(u132); 2410 struct usb_hcd *hcd = u132_to_hcd(u132);
2426 list_del(scan); 2411 list_del(scan);
2427 endp->queue_size -= 1; 2412 endp->queue_size -= 1;
2428 urb->error_count = 0; 2413 urb->error_count = 0;
2429 usb_hcd_giveback_urb(hcd, urb, 0); 2414 usb_hcd_giveback_urb(hcd, urb, 0);
2430 return 0; 2415 return 0;
2431 } else 2416 } else
2432 continue; 2417 continue;
2433 } 2418 }
2434 dev_err(&u132->platform_dev->dev, "urb=%p not found in endp[%d]=%p ring" 2419 dev_err(&u132->platform_dev->dev, "urb=%p not found in endp[%d]=%p ring"
2435 "[%d] %c%c usb_endp=%d usb_addr=%d size=%d next=%04X last=%04X" 2420 "[%d] %c%c usb_endp=%d usb_addr=%d size=%d next=%04X last=%04X"
2436 "\n", urb, endp->endp_number, endp, endp->ring->number, 2421 "\n", urb, endp->endp_number, endp, endp->ring->number,
2437 endp->input ? 'I' : ' ', endp->output ? 'O' : ' ', 2422 endp->input ? 'I' : ' ', endp->output ? 'O' : ' ',
2438 endp->usb_endp, endp->usb_addr, endp->queue_size, 2423 endp->usb_endp, endp->usb_addr, endp->queue_size,
2439 endp->queue_next, endp->queue_last); 2424 endp->queue_next, endp->queue_last);
2440 return -EINVAL; 2425 return -EINVAL;
2441} 2426}
2442 2427
2443static int u132_endp_urb_dequeue(struct u132 *u132, struct u132_endp *endp, 2428static int u132_endp_urb_dequeue(struct u132 *u132, struct u132_endp *endp,
2444 struct urb *urb, int status) 2429 struct urb *urb, int status)
2445{ 2430{
2446 unsigned long irqs; 2431 unsigned long irqs;
2447 int rc; 2432 int rc;
2448 2433
2449 spin_lock_irqsave(&endp->queue_lock.slock, irqs); 2434 spin_lock_irqsave(&endp->queue_lock.slock, irqs);
2450 rc = usb_hcd_check_unlink_urb(u132_to_hcd(u132), urb, status); 2435 rc = usb_hcd_check_unlink_urb(u132_to_hcd(u132), urb, status);
2451 if (rc) { 2436 if (rc) {
2452 spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); 2437 spin_unlock_irqrestore(&endp->queue_lock.slock, irqs);
2453 return rc; 2438 return rc;
2454 } 2439 }
2455 if (endp->queue_size == 0) { 2440 if (endp->queue_size == 0) {
2456 dev_err(&u132->platform_dev->dev, "urb=%p not found in endp[%d]" 2441 dev_err(&u132->platform_dev->dev, "urb=%p not found in endp[%d]"
2457 "=%p ring[%d] %c%c usb_endp=%d usb_addr=%d\n", urb, 2442 "=%p ring[%d] %c%c usb_endp=%d usb_addr=%d\n", urb,
2458 endp->endp_number, endp, endp->ring->number, 2443 endp->endp_number, endp, endp->ring->number,
2459 endp->input ? 'I' : ' ', endp->output ? 'O' : ' ', 2444 endp->input ? 'I' : ' ', endp->output ? 'O' : ' ',
2460 endp->usb_endp, endp->usb_addr); 2445 endp->usb_endp, endp->usb_addr);
2461 spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); 2446 spin_unlock_irqrestore(&endp->queue_lock.slock, irqs);
2462 return -EINVAL; 2447 return -EINVAL;
2463 } 2448 }
2464 if (urb == endp->urb_list[ENDP_QUEUE_MASK & endp->queue_next]) { 2449 if (urb == endp->urb_list[ENDP_QUEUE_MASK & endp->queue_next]) {
2465 if (endp->active) { 2450 if (endp->active) {
2466 endp->dequeueing = 1; 2451 endp->dequeueing = 1;
2467 endp->edset_flush = 1; 2452 endp->edset_flush = 1;
2468 u132_endp_queue_work(u132, endp, 0); 2453 u132_endp_queue_work(u132, endp, 0);
2469 spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); 2454 spin_unlock_irqrestore(&endp->queue_lock.slock, irqs);
2470 return 0; 2455 return 0;
2471 } else { 2456 } else {
2472 spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); 2457 spin_unlock_irqrestore(&endp->queue_lock.slock, irqs);
2473 u132_hcd_abandon_urb(u132, endp, urb, status); 2458 u132_hcd_abandon_urb(u132, endp, urb, status);
2474 return 0; 2459 return 0;
2475 } 2460 }
2476 } else { 2461 } else {
2477 u16 queue_list = 0; 2462 u16 queue_list = 0;
2478 u16 queue_size = endp->queue_size; 2463 u16 queue_size = endp->queue_size;
2479 u16 queue_scan = endp->queue_next; 2464 u16 queue_scan = endp->queue_next;
2480 struct urb **urb_slot = NULL; 2465 struct urb **urb_slot = NULL;
2481 while (++queue_list < ENDP_QUEUE_SIZE && --queue_size > 0) { 2466 while (++queue_list < ENDP_QUEUE_SIZE && --queue_size > 0) {
2482 if (urb == endp->urb_list[ENDP_QUEUE_MASK & 2467 if (urb == endp->urb_list[ENDP_QUEUE_MASK &
2483 ++queue_scan]) { 2468 ++queue_scan]) {
2484 urb_slot = &endp->urb_list[ENDP_QUEUE_MASK & 2469 urb_slot = &endp->urb_list[ENDP_QUEUE_MASK &
2485 queue_scan]; 2470 queue_scan];
2486 break; 2471 break;
2487 } else 2472 } else
2488 continue; 2473 continue;
2489 } 2474 }
2490 while (++queue_list < ENDP_QUEUE_SIZE && --queue_size > 0) { 2475 while (++queue_list < ENDP_QUEUE_SIZE && --queue_size > 0) {
2491 *urb_slot = endp->urb_list[ENDP_QUEUE_MASK & 2476 *urb_slot = endp->urb_list[ENDP_QUEUE_MASK &
2492 ++queue_scan]; 2477 ++queue_scan];
2493 urb_slot = &endp->urb_list[ENDP_QUEUE_MASK & 2478 urb_slot = &endp->urb_list[ENDP_QUEUE_MASK &
2494 queue_scan]; 2479 queue_scan];
2495 } 2480 }
2496 if (urb_slot) { 2481 if (urb_slot) {
2497 struct usb_hcd *hcd = u132_to_hcd(u132); 2482 struct usb_hcd *hcd = u132_to_hcd(u132);
2498 2483
2499 usb_hcd_unlink_urb_from_ep(hcd, urb); 2484 usb_hcd_unlink_urb_from_ep(hcd, urb);
2500 endp->queue_size -= 1; 2485 endp->queue_size -= 1;
2501 if (list_empty(&endp->urb_more)) { 2486 if (list_empty(&endp->urb_more)) {
2502 spin_unlock_irqrestore(&endp->queue_lock.slock, 2487 spin_unlock_irqrestore(&endp->queue_lock.slock,
2503 irqs); 2488 irqs);
2504 } else { 2489 } else {
2505 struct list_head *next = endp->urb_more.next; 2490 struct list_head *next = endp->urb_more.next;
2506 struct u132_urbq *urbq = list_entry(next, 2491 struct u132_urbq *urbq = list_entry(next,
2507 struct u132_urbq, urb_more); 2492 struct u132_urbq, urb_more);
2508 list_del(next); 2493 list_del(next);
2509 *urb_slot = urbq->urb; 2494 *urb_slot = urbq->urb;
2510 spin_unlock_irqrestore(&endp->queue_lock.slock, 2495 spin_unlock_irqrestore(&endp->queue_lock.slock,
2511 irqs); 2496 irqs);
2512 kfree(urbq); 2497 kfree(urbq);
2513 } urb->error_count = 0; 2498 } urb->error_count = 0;
2514 usb_hcd_giveback_urb(hcd, urb, status); 2499 usb_hcd_giveback_urb(hcd, urb, status);
2515 return 0; 2500 return 0;
2516 } else if (list_empty(&endp->urb_more)) { 2501 } else if (list_empty(&endp->urb_more)) {
2517 dev_err(&u132->platform_dev->dev, "urb=%p not found in " 2502 dev_err(&u132->platform_dev->dev, "urb=%p not found in "
2518 "endp[%d]=%p ring[%d] %c%c usb_endp=%d usb_addr" 2503 "endp[%d]=%p ring[%d] %c%c usb_endp=%d usb_addr"
2519 "=%d size=%d next=%04X last=%04X\n", urb, 2504 "=%d size=%d next=%04X last=%04X\n", urb,
2520 endp->endp_number, endp, endp->ring->number, 2505 endp->endp_number, endp, endp->ring->number,
2521 endp->input ? 'I' : ' ', 2506 endp->input ? 'I' : ' ',
2522 endp->output ? 'O' : ' ', endp->usb_endp, 2507 endp->output ? 'O' : ' ', endp->usb_endp,
2523 endp->usb_addr, endp->queue_size, 2508 endp->usb_addr, endp->queue_size,
2524 endp->queue_next, endp->queue_last); 2509 endp->queue_next, endp->queue_last);
2525 spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); 2510 spin_unlock_irqrestore(&endp->queue_lock.slock, irqs);
2526 return -EINVAL; 2511 return -EINVAL;
2527 } else { 2512 } else {
2528 int retval; 2513 int retval;
2529 2514
2530 usb_hcd_unlink_urb_from_ep(u132_to_hcd(u132), urb); 2515 usb_hcd_unlink_urb_from_ep(u132_to_hcd(u132), urb);
2531 retval = dequeue_from_overflow_chain(u132, endp, 2516 retval = dequeue_from_overflow_chain(u132, endp,
2532 urb); 2517 urb);
2533 spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); 2518 spin_unlock_irqrestore(&endp->queue_lock.slock, irqs);
2534 return retval; 2519 return retval;
2535 } 2520 }
2536 } 2521 }
2537} 2522}
2538 2523
2539static int u132_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) 2524static int u132_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
2540{ 2525{
2541 struct u132 *u132 = hcd_to_u132(hcd); 2526 struct u132 *u132 = hcd_to_u132(hcd);
2542 if (u132->going > 2) { 2527 if (u132->going > 2) {
2543 dev_err(&u132->platform_dev->dev, "device has been removed %d\n" 2528 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
2544 , u132->going); 2529 , u132->going);
2545 return -ENODEV; 2530 return -ENODEV;
2546 } else { 2531 } else {
2547 u8 usb_addr = usb_pipedevice(urb->pipe); 2532 u8 usb_addr = usb_pipedevice(urb->pipe);
2548 u8 usb_endp = usb_pipeendpoint(urb->pipe); 2533 u8 usb_endp = usb_pipeendpoint(urb->pipe);
2549 u8 address = u132->addr[usb_addr].address; 2534 u8 address = u132->addr[usb_addr].address;
2550 struct u132_udev *udev = &u132->udev[address]; 2535 struct u132_udev *udev = &u132->udev[address];
2551 if (usb_pipein(urb->pipe)) { 2536 if (usb_pipein(urb->pipe)) {
2552 u8 endp_number = udev->endp_number_in[usb_endp]; 2537 u8 endp_number = udev->endp_number_in[usb_endp];
2553 struct u132_endp *endp = u132->endp[endp_number - 1]; 2538 struct u132_endp *endp = u132->endp[endp_number - 1];
2554 return u132_endp_urb_dequeue(u132, endp, urb, status); 2539 return u132_endp_urb_dequeue(u132, endp, urb, status);
2555 } else { 2540 } else {
2556 u8 endp_number = udev->endp_number_out[usb_endp]; 2541 u8 endp_number = udev->endp_number_out[usb_endp];
2557 struct u132_endp *endp = u132->endp[endp_number - 1]; 2542 struct u132_endp *endp = u132->endp[endp_number - 1];
2558 return u132_endp_urb_dequeue(u132, endp, urb, status); 2543 return u132_endp_urb_dequeue(u132, endp, urb, status);
2559 } 2544 }
2560 } 2545 }
2561} 2546}
2562 2547
2563static void u132_endpoint_disable(struct usb_hcd *hcd, 2548static void u132_endpoint_disable(struct usb_hcd *hcd,
2564 struct usb_host_endpoint *hep) 2549 struct usb_host_endpoint *hep)
2565{ 2550{
2566 struct u132 *u132 = hcd_to_u132(hcd); 2551 struct u132 *u132 = hcd_to_u132(hcd);
2567 if (u132->going > 2) { 2552 if (u132->going > 2) {
2568 dev_err(&u132->platform_dev->dev, "u132 device %p(hcd=%p hep=%p" 2553 dev_err(&u132->platform_dev->dev, "u132 device %p(hcd=%p hep=%p"
2569 ") has been removed %d\n", u132, hcd, hep, 2554 ") has been removed %d\n", u132, hcd, hep,
2570 u132->going); 2555 u132->going);
2571 } else { 2556 } else {
2572 struct u132_endp *endp = hep->hcpriv; 2557 struct u132_endp *endp = hep->hcpriv;
2573 if (endp) 2558 if (endp)
2574 u132_endp_put_kref(u132, endp); 2559 u132_endp_put_kref(u132, endp);
2575 } 2560 }
2576} 2561}
2577 2562
2578static int u132_get_frame(struct usb_hcd *hcd) 2563static int u132_get_frame(struct usb_hcd *hcd)
2579{ 2564{
2580 struct u132 *u132 = hcd_to_u132(hcd); 2565 struct u132 *u132 = hcd_to_u132(hcd);
2581 if (u132->going > 1) { 2566 if (u132->going > 1) {
2582 dev_err(&u132->platform_dev->dev, "device has been removed %d\n" 2567 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
2583 , u132->going); 2568 , u132->going);
2584 return -ENODEV; 2569 return -ENODEV;
2585 } else if (u132->going > 0) { 2570 } else if (u132->going > 0) {
2586 dev_err(&u132->platform_dev->dev, "device is being removed\n"); 2571 dev_err(&u132->platform_dev->dev, "device is being removed\n");
2587 return -ESHUTDOWN; 2572 return -ESHUTDOWN;
2588 } else { 2573 } else {
2589 int frame = 0; 2574 int frame = 0;
2590 dev_err(&u132->platform_dev->dev, "TODO: u132_get_frame\n"); 2575 dev_err(&u132->platform_dev->dev, "TODO: u132_get_frame\n");
2591 msleep(100); 2576 msleep(100);
2592 return frame; 2577 return frame;
2593 } 2578 }
2594} 2579}
2595 2580
2596static int u132_roothub_descriptor(struct u132 *u132, 2581static int u132_roothub_descriptor(struct u132 *u132,
2597 struct usb_hub_descriptor *desc) 2582 struct usb_hub_descriptor *desc)
2598{ 2583{
2599 int retval; 2584 int retval;
2600 u16 temp; 2585 u16 temp;
2601 u32 rh_a = -1; 2586 u32 rh_a = -1;
2602 u32 rh_b = -1; 2587 u32 rh_b = -1;
2603 retval = u132_read_pcimem(u132, roothub.a, &rh_a); 2588 retval = u132_read_pcimem(u132, roothub.a, &rh_a);
2604 if (retval) 2589 if (retval)
2605 return retval; 2590 return retval;
2606 desc->bDescriptorType = 0x29; 2591 desc->bDescriptorType = 0x29;
2607 desc->bPwrOn2PwrGood = (rh_a & RH_A_POTPGT) >> 24; 2592 desc->bPwrOn2PwrGood = (rh_a & RH_A_POTPGT) >> 24;
2608 desc->bHubContrCurrent = 0; 2593 desc->bHubContrCurrent = 0;
2609 desc->bNbrPorts = u132->num_ports; 2594 desc->bNbrPorts = u132->num_ports;
2610 temp = 1 + (u132->num_ports / 8); 2595 temp = 1 + (u132->num_ports / 8);
2611 desc->bDescLength = 7 + 2 *temp; 2596 desc->bDescLength = 7 + 2 * temp;
2612 temp = 0; 2597 temp = 0;
2613 if (rh_a & RH_A_NPS) 2598 if (rh_a & RH_A_NPS)
2614 temp |= 0x0002; 2599 temp |= 0x0002;
2615 if (rh_a & RH_A_PSM) 2600 if (rh_a & RH_A_PSM)
2616 temp |= 0x0001; 2601 temp |= 0x0001;
2617 if (rh_a & RH_A_NOCP) { 2602 if (rh_a & RH_A_NOCP)
2618 temp |= 0x0010; 2603 temp |= 0x0010;
2619 } else if (rh_a & RH_A_OCPM) 2604 else if (rh_a & RH_A_OCPM)
2620 temp |= 0x0008; 2605 temp |= 0x0008;
2621 desc->wHubCharacteristics = cpu_to_le16(temp); 2606 desc->wHubCharacteristics = cpu_to_le16(temp);
2622 retval = u132_read_pcimem(u132, roothub.b, &rh_b); 2607 retval = u132_read_pcimem(u132, roothub.b, &rh_b);
2623 if (retval) 2608 if (retval)
2624 return retval; 2609 return retval;
2625 memset(desc->bitmap, 0xff, sizeof(desc->bitmap)); 2610 memset(desc->bitmap, 0xff, sizeof(desc->bitmap));
2626 desc->bitmap[0] = rh_b & RH_B_DR; 2611 desc->bitmap[0] = rh_b & RH_B_DR;
2627 if (u132->num_ports > 7) { 2612 if (u132->num_ports > 7) {
2628 desc->bitmap[1] = (rh_b & RH_B_DR) >> 8; 2613 desc->bitmap[1] = (rh_b & RH_B_DR) >> 8;
2629 desc->bitmap[2] = 0xff; 2614 desc->bitmap[2] = 0xff;
2630 } else 2615 } else
2631 desc->bitmap[1] = 0xff; 2616 desc->bitmap[1] = 0xff;
2632 return 0; 2617 return 0;
2633} 2618}
2634 2619
2635static int u132_roothub_status(struct u132 *u132, __le32 *desc) 2620static int u132_roothub_status(struct u132 *u132, __le32 *desc)
2636{ 2621{
2637 u32 rh_status = -1; 2622 u32 rh_status = -1;
2638 int ret_status = u132_read_pcimem(u132, roothub.status, &rh_status); 2623 int ret_status = u132_read_pcimem(u132, roothub.status, &rh_status);
2639 *desc = cpu_to_le32(rh_status); 2624 *desc = cpu_to_le32(rh_status);
2640 return ret_status; 2625 return ret_status;
2641} 2626}
2642 2627
2643static int u132_roothub_portstatus(struct u132 *u132, __le32 *desc, u16 wIndex) 2628static int u132_roothub_portstatus(struct u132 *u132, __le32 *desc, u16 wIndex)
2644{ 2629{
2645 if (wIndex == 0 || wIndex > u132->num_ports) { 2630 if (wIndex == 0 || wIndex > u132->num_ports) {
2646 return -EINVAL; 2631 return -EINVAL;
2647 } else { 2632 } else {
2648 int port = wIndex - 1; 2633 int port = wIndex - 1;
2649 u32 rh_portstatus = -1; 2634 u32 rh_portstatus = -1;
2650 int ret_portstatus = u132_read_pcimem(u132, 2635 int ret_portstatus = u132_read_pcimem(u132,
2651 roothub.portstatus[port], &rh_portstatus); 2636 roothub.portstatus[port], &rh_portstatus);
2652 *desc = cpu_to_le32(rh_portstatus); 2637 *desc = cpu_to_le32(rh_portstatus);
2653 if (*(u16 *) (desc + 2)) { 2638 if (*(u16 *) (desc + 2)) {
2654 dev_info(&u132->platform_dev->dev, "Port %d Status Chan" 2639 dev_info(&u132->platform_dev->dev, "Port %d Status Chan"
2655 "ge = %08X\n", port, *desc); 2640 "ge = %08X\n", port, *desc);
2656 } 2641 }
2657 return ret_portstatus; 2642 return ret_portstatus;
2658 } 2643 }
2659} 2644}
2660 2645
2661 2646
@@ -2666,381 +2651,340 @@ static int u132_roothub_portstatus(struct u132 *u132, __le32 *desc, u16 wIndex)
2666#define tick_before(t1, t2) ((s16)(((s16)(t1))-((s16)(t2))) < 0) 2651#define tick_before(t1, t2) ((s16)(((s16)(t1))-((s16)(t2))) < 0)
2667static int u132_roothub_portreset(struct u132 *u132, int port_index) 2652static int u132_roothub_portreset(struct u132 *u132, int port_index)
2668{ 2653{
2669 int retval; 2654 int retval;
2670 u32 fmnumber; 2655 u32 fmnumber;
2671 u16 now; 2656 u16 now;
2672 u16 reset_done; 2657 u16 reset_done;
2673 retval = u132_read_pcimem(u132, fmnumber, &fmnumber); 2658 retval = u132_read_pcimem(u132, fmnumber, &fmnumber);
2674 if (retval) 2659 if (retval)
2675 return retval; 2660 return retval;
2676 now = fmnumber; 2661 now = fmnumber;
2677 reset_done = now + PORT_RESET_MSEC; 2662 reset_done = now + PORT_RESET_MSEC;
2678 do { 2663 do {
2679 u32 portstat; 2664 u32 portstat;
2680 do { 2665 do {
2681 retval = u132_read_pcimem(u132, 2666 retval = u132_read_pcimem(u132,
2682 roothub.portstatus[port_index], &portstat); 2667 roothub.portstatus[port_index], &portstat);
2683 if (retval) 2668 if (retval)
2684 return retval; 2669 return retval;
2685 if (RH_PS_PRS & portstat) { 2670 if (RH_PS_PRS & portstat)
2686 continue; 2671 continue;
2687 } else 2672 else
2688 break; 2673 break;
2689 } while (tick_before(now, reset_done)); 2674 } while (tick_before(now, reset_done));
2690 if (RH_PS_PRS & portstat) 2675 if (RH_PS_PRS & portstat)
2691 return -ENODEV; 2676 return -ENODEV;
2692 if (RH_PS_CCS & portstat) { 2677 if (RH_PS_CCS & portstat) {
2693 if (RH_PS_PRSC & portstat) { 2678 if (RH_PS_PRSC & portstat) {
2694 retval = u132_write_pcimem(u132, 2679 retval = u132_write_pcimem(u132,
2695 roothub.portstatus[port_index], 2680 roothub.portstatus[port_index],
2696 RH_PS_PRSC); 2681 RH_PS_PRSC);
2697 if (retval) 2682 if (retval)
2698 return retval; 2683 return retval;
2699 } 2684 }
2700 } else 2685 } else
2701 break; /* start the next reset, 2686 break; /* start the next reset,
2702 sleep till it's probably done */ 2687 sleep till it's probably done */
2703 retval = u132_write_pcimem(u132, roothub.portstatus[port_index], 2688 retval = u132_write_pcimem(u132, roothub.portstatus[port_index],
2704 RH_PS_PRS); 2689 RH_PS_PRS);
2705 if (retval) 2690 if (retval)
2706 return retval; 2691 return retval;
2707 msleep(PORT_RESET_HW_MSEC); 2692 msleep(PORT_RESET_HW_MSEC);
2708 retval = u132_read_pcimem(u132, fmnumber, &fmnumber); 2693 retval = u132_read_pcimem(u132, fmnumber, &fmnumber);
2709 if (retval) 2694 if (retval)
2710 return retval; 2695 return retval;
2711 now = fmnumber; 2696 now = fmnumber;
2712 } while (tick_before(now, reset_done)); 2697 } while (tick_before(now, reset_done));
2713 return 0; 2698 return 0;
2714} 2699}
2715 2700
2716static int u132_roothub_setportfeature(struct u132 *u132, u16 wValue, 2701static int u132_roothub_setportfeature(struct u132 *u132, u16 wValue,
2717 u16 wIndex) 2702 u16 wIndex)
2718{ 2703{
2719 if (wIndex == 0 || wIndex > u132->num_ports) { 2704 if (wIndex == 0 || wIndex > u132->num_ports) {
2720 return -EINVAL; 2705 return -EINVAL;
2721 } else { 2706 } else {
2722 int retval; 2707 int retval;
2723 int port_index = wIndex - 1; 2708 int port_index = wIndex - 1;
2724 struct u132_port *port = &u132->port[port_index]; 2709 struct u132_port *port = &u132->port[port_index];
2725 port->Status &= ~(1 << wValue); 2710 port->Status &= ~(1 << wValue);
2726 switch (wValue) { 2711 switch (wValue) {
2727 case USB_PORT_FEAT_SUSPEND: 2712 case USB_PORT_FEAT_SUSPEND:
2728 retval = u132_write_pcimem(u132, 2713 retval = u132_write_pcimem(u132,
2729 roothub.portstatus[port_index], RH_PS_PSS); 2714 roothub.portstatus[port_index], RH_PS_PSS);
2730 if (retval) 2715 if (retval)
2731 return retval; 2716 return retval;
2732 return 0; 2717 return 0;
2733 case USB_PORT_FEAT_POWER: 2718 case USB_PORT_FEAT_POWER:
2734 retval = u132_write_pcimem(u132, 2719 retval = u132_write_pcimem(u132,
2735 roothub.portstatus[port_index], RH_PS_PPS); 2720 roothub.portstatus[port_index], RH_PS_PPS);
2736 if (retval) 2721 if (retval)
2737 return retval; 2722 return retval;
2738 return 0; 2723 return 0;
2739 case USB_PORT_FEAT_RESET: 2724 case USB_PORT_FEAT_RESET:
2740 retval = u132_roothub_portreset(u132, port_index); 2725 retval = u132_roothub_portreset(u132, port_index);
2741 if (retval) 2726 if (retval)
2742 return retval; 2727 return retval;
2743 return 0; 2728 return 0;
2744 default: 2729 default:
2745 return -EPIPE; 2730 return -EPIPE;
2746 } 2731 }
2747 } 2732 }
2748} 2733}
2749 2734
2750static int u132_roothub_clearportfeature(struct u132 *u132, u16 wValue, 2735static int u132_roothub_clearportfeature(struct u132 *u132, u16 wValue,
2751 u16 wIndex) 2736 u16 wIndex)
2752{ 2737{
2753 if (wIndex == 0 || wIndex > u132->num_ports) { 2738 if (wIndex == 0 || wIndex > u132->num_ports) {
2754 return -EINVAL; 2739 return -EINVAL;
2755 } else { 2740 } else {
2756 int port_index = wIndex - 1; 2741 int port_index = wIndex - 1;
2757 u32 temp; 2742 u32 temp;
2758 int retval; 2743 int retval;
2759 struct u132_port *port = &u132->port[port_index]; 2744 struct u132_port *port = &u132->port[port_index];
2760 port->Status &= ~(1 << wValue); 2745 port->Status &= ~(1 << wValue);
2761 switch (wValue) { 2746 switch (wValue) {
2762 case USB_PORT_FEAT_ENABLE: 2747 case USB_PORT_FEAT_ENABLE:
2763 temp = RH_PS_CCS; 2748 temp = RH_PS_CCS;
2764 break; 2749 break;
2765 case USB_PORT_FEAT_C_ENABLE: 2750 case USB_PORT_FEAT_C_ENABLE:
2766 temp = RH_PS_PESC; 2751 temp = RH_PS_PESC;
2767 break; 2752 break;
2768 case USB_PORT_FEAT_SUSPEND: 2753 case USB_PORT_FEAT_SUSPEND:
2769 temp = RH_PS_POCI; 2754 temp = RH_PS_POCI;
2770 if ((u132->hc_control & OHCI_CTRL_HCFS) 2755 if ((u132->hc_control & OHCI_CTRL_HCFS)
2771 != OHCI_USB_OPER) { 2756 != OHCI_USB_OPER) {
2772 dev_err(&u132->platform_dev->dev, "TODO resume_" 2757 dev_err(&u132->platform_dev->dev, "TODO resume_"
2773 "root_hub\n"); 2758 "root_hub\n");
2774 } 2759 }
2775 break; 2760 break;
2776 case USB_PORT_FEAT_C_SUSPEND: 2761 case USB_PORT_FEAT_C_SUSPEND:
2777 temp = RH_PS_PSSC; 2762 temp = RH_PS_PSSC;
2778 break; 2763 break;
2779 case USB_PORT_FEAT_POWER: 2764 case USB_PORT_FEAT_POWER:
2780 temp = RH_PS_LSDA; 2765 temp = RH_PS_LSDA;
2781 break; 2766 break;
2782 case USB_PORT_FEAT_C_CONNECTION: 2767 case USB_PORT_FEAT_C_CONNECTION:
2783 temp = RH_PS_CSC; 2768 temp = RH_PS_CSC;
2784 break; 2769 break;
2785 case USB_PORT_FEAT_C_OVER_CURRENT: 2770 case USB_PORT_FEAT_C_OVER_CURRENT:
2786 temp = RH_PS_OCIC; 2771 temp = RH_PS_OCIC;
2787 break; 2772 break;
2788 case USB_PORT_FEAT_C_RESET: 2773 case USB_PORT_FEAT_C_RESET:
2789 temp = RH_PS_PRSC; 2774 temp = RH_PS_PRSC;
2790 break; 2775 break;
2791 default: 2776 default:
2792 return -EPIPE; 2777 return -EPIPE;
2793 } 2778 }
2794 retval = u132_write_pcimem(u132, roothub.portstatus[port_index], 2779 retval = u132_write_pcimem(u132, roothub.portstatus[port_index],
2795 temp); 2780 temp);
2796 if (retval) 2781 if (retval)
2797 return retval; 2782 return retval;
2798 return 0; 2783 return 0;
2799 } 2784 }
2800} 2785}
2801 2786
2802 2787
2803/* the virtual root hub timer IRQ checks for hub status*/ 2788/* the virtual root hub timer IRQ checks for hub status*/
2804static int u132_hub_status_data(struct usb_hcd *hcd, char *buf) 2789static int u132_hub_status_data(struct usb_hcd *hcd, char *buf)
2805{ 2790{
2806 struct u132 *u132 = hcd_to_u132(hcd); 2791 struct u132 *u132 = hcd_to_u132(hcd);
2807 if (u132->going > 1) { 2792 if (u132->going > 1) {
2808 dev_err(&u132->platform_dev->dev, "device hcd=%p has been remov" 2793 dev_err(&u132->platform_dev->dev, "device hcd=%p has been remov"
2809 "ed %d\n", hcd, u132->going); 2794 "ed %d\n", hcd, u132->going);
2810 return -ENODEV; 2795 return -ENODEV;
2811 } else if (u132->going > 0) { 2796 } else if (u132->going > 0) {
2812 dev_err(&u132->platform_dev->dev, "device hcd=%p is being remov" 2797 dev_err(&u132->platform_dev->dev, "device hcd=%p is being remov"
2813 "ed\n", hcd); 2798 "ed\n", hcd);
2814 return -ESHUTDOWN; 2799 return -ESHUTDOWN;
2815 } else { 2800 } else {
2816 int i, changed = 0, length = 1; 2801 int i, changed = 0, length = 1;
2817 if (u132->flags & OHCI_QUIRK_AMD756) { 2802 if (u132->flags & OHCI_QUIRK_AMD756) {
2818 if ((u132->hc_roothub_a & RH_A_NDP) > MAX_ROOT_PORTS) { 2803 if ((u132->hc_roothub_a & RH_A_NDP) > MAX_ROOT_PORTS) {
2819 dev_err(&u132->platform_dev->dev, "bogus NDP, r" 2804 dev_err(&u132->platform_dev->dev, "bogus NDP, r"
2820 "ereads as NDP=%d\n", 2805 "ereads as NDP=%d\n",
2821 u132->hc_roothub_a & RH_A_NDP); 2806 u132->hc_roothub_a & RH_A_NDP);
2822 goto done; 2807 goto done;
2823 } 2808 }
2824 } 2809 }
2825 if (u132->hc_roothub_status & (RH_HS_LPSC | RH_HS_OCIC)) { 2810 if (u132->hc_roothub_status & (RH_HS_LPSC | RH_HS_OCIC))
2826 buf[0] = changed = 1; 2811 buf[0] = changed = 1;
2827 } else 2812 else
2828 buf[0] = 0; 2813 buf[0] = 0;
2829 if (u132->num_ports > 7) { 2814 if (u132->num_ports > 7) {
2830 buf[1] = 0; 2815 buf[1] = 0;
2831 length++; 2816 length++;
2832 } 2817 }
2833 for (i = 0; i < u132->num_ports; i++) { 2818 for (i = 0; i < u132->num_ports; i++) {
2834 if (u132->hc_roothub_portstatus[i] & (RH_PS_CSC | 2819 if (u132->hc_roothub_portstatus[i] & (RH_PS_CSC |
2835 RH_PS_PESC | RH_PS_PSSC | RH_PS_OCIC | 2820 RH_PS_PESC | RH_PS_PSSC | RH_PS_OCIC |
2836 RH_PS_PRSC)) { 2821 RH_PS_PRSC)) {
2837 changed = 1; 2822 changed = 1;
2838 if (i < 7) { 2823 if (i < 7)
2839 buf[0] |= 1 << (i + 1); 2824 buf[0] |= 1 << (i + 1);
2840 } else 2825 else
2841 buf[1] |= 1 << (i - 7); 2826 buf[1] |= 1 << (i - 7);
2842 continue; 2827 continue;
2843 } 2828 }
2844 if (!(u132->hc_roothub_portstatus[i] & RH_PS_CCS)) { 2829 if (!(u132->hc_roothub_portstatus[i] & RH_PS_CCS))
2845 continue; 2830 continue;
2846 } 2831
2847 if ((u132->hc_roothub_portstatus[i] & RH_PS_PSS)) { 2832 if ((u132->hc_roothub_portstatus[i] & RH_PS_PSS))
2848 continue; 2833 continue;
2849 } 2834 }
2850 } 2835done:
2851 done:return changed ? length : 0; 2836 return changed ? length : 0;
2852 } 2837 }
2853} 2838}
2854 2839
2855static int u132_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, 2840static int u132_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
2856 u16 wIndex, char *buf, u16 wLength) 2841 u16 wIndex, char *buf, u16 wLength)
2857{ 2842{
2858 struct u132 *u132 = hcd_to_u132(hcd); 2843 struct u132 *u132 = hcd_to_u132(hcd);
2859 if (u132->going > 1) { 2844 if (u132->going > 1) {
2860 dev_err(&u132->platform_dev->dev, "device has been removed %d\n" 2845 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
2861 , u132->going); 2846 , u132->going);
2862 return -ENODEV; 2847 return -ENODEV;
2863 } else if (u132->going > 0) { 2848 } else if (u132->going > 0) {
2864 dev_err(&u132->platform_dev->dev, "device is being removed\n"); 2849 dev_err(&u132->platform_dev->dev, "device is being removed\n");
2865 return -ESHUTDOWN; 2850 return -ESHUTDOWN;
2866 } else { 2851 } else {
2867 int retval = 0; 2852 int retval = 0;
2868 mutex_lock(&u132->sw_lock); 2853 mutex_lock(&u132->sw_lock);
2869 switch (typeReq) { 2854 switch (typeReq) {
2870 case ClearHubFeature: 2855 case ClearHubFeature:
2871 switch (wValue) { 2856 switch (wValue) {
2872 case C_HUB_OVER_CURRENT: 2857 case C_HUB_OVER_CURRENT:
2873 case C_HUB_LOCAL_POWER: 2858 case C_HUB_LOCAL_POWER:
2874 break; 2859 break;
2875 default: 2860 default:
2876 goto stall; 2861 goto stall;
2877 } 2862 }
2878 break; 2863 break;
2879 case SetHubFeature: 2864 case SetHubFeature:
2880 switch (wValue) { 2865 switch (wValue) {
2881 case C_HUB_OVER_CURRENT: 2866 case C_HUB_OVER_CURRENT:
2882 case C_HUB_LOCAL_POWER: 2867 case C_HUB_LOCAL_POWER:
2883 break; 2868 break;
2884 default: 2869 default:
2885 goto stall; 2870 goto stall;
2886 } 2871 }
2887 break; 2872 break;
2888 case ClearPortFeature:{ 2873 case ClearPortFeature:{
2889 retval = u132_roothub_clearportfeature(u132, 2874 retval = u132_roothub_clearportfeature(u132,
2890 wValue, wIndex); 2875 wValue, wIndex);
2891 if (retval) 2876 if (retval)
2892 goto error; 2877 goto error;
2893 break; 2878 break;
2894 } 2879 }
2895 case GetHubDescriptor:{ 2880 case GetHubDescriptor:{
2896 retval = u132_roothub_descriptor(u132, 2881 retval = u132_roothub_descriptor(u132,
2897 (struct usb_hub_descriptor *)buf); 2882 (struct usb_hub_descriptor *)buf);
2898 if (retval) 2883 if (retval)
2899 goto error; 2884 goto error;
2900 break; 2885 break;
2901 } 2886 }
2902 case GetHubStatus:{ 2887 case GetHubStatus:{
2903 retval = u132_roothub_status(u132, 2888 retval = u132_roothub_status(u132,
2904 (__le32 *) buf); 2889 (__le32 *) buf);
2905 if (retval) 2890 if (retval)
2906 goto error; 2891 goto error;
2907 break; 2892 break;
2908 } 2893 }
2909 case GetPortStatus:{ 2894 case GetPortStatus:{
2910 retval = u132_roothub_portstatus(u132, 2895 retval = u132_roothub_portstatus(u132,
2911 (__le32 *) buf, wIndex); 2896 (__le32 *) buf, wIndex);
2912 if (retval) 2897 if (retval)
2913 goto error; 2898 goto error;
2914 break; 2899 break;
2915 } 2900 }
2916 case SetPortFeature:{ 2901 case SetPortFeature:{
2917 retval = u132_roothub_setportfeature(u132, 2902 retval = u132_roothub_setportfeature(u132,
2918 wValue, wIndex); 2903 wValue, wIndex);
2919 if (retval) 2904 if (retval)
2920 goto error; 2905 goto error;
2921 break; 2906 break;
2922 } 2907 }
2923 default: 2908 default:
2924 goto stall; 2909 goto stall;
2925 error:u132_disable(u132); 2910 error:
2926 u132->going = 1; 2911 u132_disable(u132);
2927 break; 2912 u132->going = 1;
2928 stall:retval = -EPIPE; 2913 break;
2929 break; 2914 stall:
2930 } 2915 retval = -EPIPE;
2931 mutex_unlock(&u132->sw_lock); 2916 break;
2932 return retval; 2917 }
2933 } 2918 mutex_unlock(&u132->sw_lock);
2919 return retval;
2920 }
2934} 2921}
2935 2922
2936static int u132_start_port_reset(struct usb_hcd *hcd, unsigned port_num) 2923static int u132_start_port_reset(struct usb_hcd *hcd, unsigned port_num)
2937{ 2924{
2938 struct u132 *u132 = hcd_to_u132(hcd); 2925 struct u132 *u132 = hcd_to_u132(hcd);
2939 if (u132->going > 1) { 2926 if (u132->going > 1) {
2940 dev_err(&u132->platform_dev->dev, "device has been removed %d\n" 2927 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
2941 , u132->going); 2928 , u132->going);
2942 return -ENODEV; 2929 return -ENODEV;
2943 } else if (u132->going > 0) { 2930 } else if (u132->going > 0) {
2944 dev_err(&u132->platform_dev->dev, "device is being removed\n"); 2931 dev_err(&u132->platform_dev->dev, "device is being removed\n");
2945 return -ESHUTDOWN; 2932 return -ESHUTDOWN;
2946 } else 2933 } else
2947 return 0; 2934 return 0;
2948}
2949
2950static void u132_hub_irq_enable(struct usb_hcd *hcd)
2951{
2952 struct u132 *u132 = hcd_to_u132(hcd);
2953 if (u132->going > 1) {
2954 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
2955 , u132->going);
2956 } else if (u132->going > 0)
2957 dev_err(&u132->platform_dev->dev, "device is being removed\n");
2958} 2935}
2959 2936
2960 2937
2961#ifdef CONFIG_PM 2938#ifdef CONFIG_PM
2962static int u132_hcd_suspend(struct usb_hcd *hcd, pm_message_t message)
2963{
2964 struct u132 *u132 = hcd_to_u132(hcd);
2965 if (u132->going > 1) {
2966 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
2967 , u132->going);
2968 return -ENODEV;
2969 } else if (u132->going > 0) {
2970 dev_err(&u132->platform_dev->dev, "device is being removed\n");
2971 return -ESHUTDOWN;
2972 } else
2973 return 0;
2974}
2975
2976static int u132_hcd_resume(struct usb_hcd *hcd)
2977{
2978 struct u132 *u132 = hcd_to_u132(hcd);
2979 if (u132->going > 1) {
2980 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
2981 , u132->going);
2982 return -ENODEV;
2983 } else if (u132->going > 0) {
2984 dev_err(&u132->platform_dev->dev, "device is being removed\n");
2985 return -ESHUTDOWN;
2986 } else
2987 return 0;
2988}
2989
2990static int u132_bus_suspend(struct usb_hcd *hcd) 2939static int u132_bus_suspend(struct usb_hcd *hcd)
2991{ 2940{
2992 struct u132 *u132 = hcd_to_u132(hcd); 2941 struct u132 *u132 = hcd_to_u132(hcd);
2993 if (u132->going > 1) { 2942 if (u132->going > 1) {
2994 dev_err(&u132->platform_dev->dev, "device has been removed %d\n" 2943 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
2995 , u132->going); 2944 , u132->going);
2996 return -ENODEV; 2945 return -ENODEV;
2997 } else if (u132->going > 0) { 2946 } else if (u132->going > 0) {
2998 dev_err(&u132->platform_dev->dev, "device is being removed\n"); 2947 dev_err(&u132->platform_dev->dev, "device is being removed\n");
2999 return -ESHUTDOWN; 2948 return -ESHUTDOWN;
3000 } else 2949 } else
3001 return 0; 2950 return 0;
3002} 2951}
3003 2952
3004static int u132_bus_resume(struct usb_hcd *hcd) 2953static int u132_bus_resume(struct usb_hcd *hcd)
3005{ 2954{
3006 struct u132 *u132 = hcd_to_u132(hcd); 2955 struct u132 *u132 = hcd_to_u132(hcd);
3007 if (u132->going > 1) { 2956 if (u132->going > 1) {
3008 dev_err(&u132->platform_dev->dev, "device has been removed %d\n" 2957 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
3009 , u132->going); 2958 , u132->going);
3010 return -ENODEV; 2959 return -ENODEV;
3011 } else if (u132->going > 0) { 2960 } else if (u132->going > 0) {
3012 dev_err(&u132->platform_dev->dev, "device is being removed\n"); 2961 dev_err(&u132->platform_dev->dev, "device is being removed\n");
3013 return -ESHUTDOWN; 2962 return -ESHUTDOWN;
3014 } else 2963 } else
3015 return 0; 2964 return 0;
3016} 2965}
3017 2966
3018#else 2967#else
3019#define u132_hcd_suspend NULL
3020#define u132_hcd_resume NULL
3021#define u132_bus_suspend NULL 2968#define u132_bus_suspend NULL
3022#define u132_bus_resume NULL 2969#define u132_bus_resume NULL
3023#endif 2970#endif
3024static struct hc_driver u132_hc_driver = { 2971static struct hc_driver u132_hc_driver = {
3025 .description = hcd_name, 2972 .description = hcd_name,
3026 .hcd_priv_size = sizeof(struct u132), 2973 .hcd_priv_size = sizeof(struct u132),
3027 .irq = NULL, 2974 .irq = NULL,
3028 .flags = HCD_USB11 | HCD_MEMORY, 2975 .flags = HCD_USB11 | HCD_MEMORY,
3029 .reset = u132_hcd_reset, 2976 .reset = u132_hcd_reset,
3030 .start = u132_hcd_start, 2977 .start = u132_hcd_start,
3031 .suspend = u132_hcd_suspend, 2978 .stop = u132_hcd_stop,
3032 .resume = u132_hcd_resume, 2979 .urb_enqueue = u132_urb_enqueue,
3033 .stop = u132_hcd_stop, 2980 .urb_dequeue = u132_urb_dequeue,
3034 .urb_enqueue = u132_urb_enqueue, 2981 .endpoint_disable = u132_endpoint_disable,
3035 .urb_dequeue = u132_urb_dequeue, 2982 .get_frame_number = u132_get_frame,
3036 .endpoint_disable = u132_endpoint_disable, 2983 .hub_status_data = u132_hub_status_data,
3037 .get_frame_number = u132_get_frame, 2984 .hub_control = u132_hub_control,
3038 .hub_status_data = u132_hub_status_data, 2985 .bus_suspend = u132_bus_suspend,
3039 .hub_control = u132_hub_control, 2986 .bus_resume = u132_bus_resume,
3040 .bus_suspend = u132_bus_suspend, 2987 .start_port_reset = u132_start_port_reset,
3041 .bus_resume = u132_bus_resume,
3042 .start_port_reset = u132_start_port_reset,
3043 .hub_irq_enable = u132_hub_irq_enable,
3044}; 2988};
3045 2989
3046/* 2990/*
@@ -3051,148 +2995,152 @@ static struct hc_driver u132_hc_driver = {
3051*/ 2995*/
3052static int __devexit u132_remove(struct platform_device *pdev) 2996static int __devexit u132_remove(struct platform_device *pdev)
3053{ 2997{
3054 struct usb_hcd *hcd = platform_get_drvdata(pdev); 2998 struct usb_hcd *hcd = platform_get_drvdata(pdev);
3055 if (hcd) { 2999 if (hcd) {
3056 struct u132 *u132 = hcd_to_u132(hcd); 3000 struct u132 *u132 = hcd_to_u132(hcd);
3057 if (u132->going++ > 1) { 3001 if (u132->going++ > 1) {
3058 dev_err(&u132->platform_dev->dev, "already being remove" 3002 dev_err(&u132->platform_dev->dev, "already being remove"
3059 "d\n"); 3003 "d\n");
3060 return -ENODEV; 3004 return -ENODEV;
3061 } else { 3005 } else {
3062 int rings = MAX_U132_RINGS; 3006 int rings = MAX_U132_RINGS;
3063 int endps = MAX_U132_ENDPS; 3007 int endps = MAX_U132_ENDPS;
3064 dev_err(&u132->platform_dev->dev, "removing device u132" 3008 dev_err(&u132->platform_dev->dev, "removing device u132"
3065 ".%d\n", u132->sequence_num); 3009 ".%d\n", u132->sequence_num);
3066 msleep(100); 3010 msleep(100);
3067 mutex_lock(&u132->sw_lock); 3011 mutex_lock(&u132->sw_lock);
3068 u132_monitor_cancel_work(u132); 3012 u132_monitor_cancel_work(u132);
3069 while (rings-- > 0) { 3013 while (rings-- > 0) {
3070 struct u132_ring *ring = &u132->ring[rings]; 3014 struct u132_ring *ring = &u132->ring[rings];
3071 u132_ring_cancel_work(u132, ring); 3015 u132_ring_cancel_work(u132, ring);
3072 } while (endps-- > 0) { 3016 } while (endps-- > 0) {
3073 struct u132_endp *endp = u132->endp[endps]; 3017 struct u132_endp *endp = u132->endp[endps];
3074 if (endp) 3018 if (endp)
3075 u132_endp_cancel_work(u132, endp); 3019 u132_endp_cancel_work(u132, endp);
3076 } 3020 }
3077 u132->going += 1; 3021 u132->going += 1;
3078 printk(KERN_INFO "removing device u132.%d\n", 3022 printk(KERN_INFO "removing device u132.%d\n",
3079 u132->sequence_num); 3023 u132->sequence_num);
3080 mutex_unlock(&u132->sw_lock); 3024 mutex_unlock(&u132->sw_lock);
3081 usb_remove_hcd(hcd); 3025 usb_remove_hcd(hcd);
3082 u132_u132_put_kref(u132); 3026 u132_u132_put_kref(u132);
3083 return 0; 3027 return 0;
3084 } 3028 }
3085 } else 3029 } else
3086 return 0; 3030 return 0;
3087} 3031}
3088 3032
3089static void u132_initialise(struct u132 *u132, struct platform_device *pdev) 3033static void u132_initialise(struct u132 *u132, struct platform_device *pdev)
3090{ 3034{
3091 int rings = MAX_U132_RINGS; 3035 int rings = MAX_U132_RINGS;
3092 int ports = MAX_U132_PORTS; 3036 int ports = MAX_U132_PORTS;
3093 int addrs = MAX_U132_ADDRS; 3037 int addrs = MAX_U132_ADDRS;
3094 int udevs = MAX_U132_UDEVS; 3038 int udevs = MAX_U132_UDEVS;
3095 int endps = MAX_U132_ENDPS; 3039 int endps = MAX_U132_ENDPS;
3096 u132->board = pdev->dev.platform_data; 3040 u132->board = pdev->dev.platform_data;
3097 u132->platform_dev = pdev; 3041 u132->platform_dev = pdev;
3098 u132->power = 0; 3042 u132->power = 0;
3099 u132->reset = 0; 3043 u132->reset = 0;
3100 mutex_init(&u132->sw_lock); 3044 mutex_init(&u132->sw_lock);
3101 init_MUTEX(&u132->scheduler_lock); 3045 mutex_init(&u132->scheduler_lock);
3102 while (rings-- > 0) { 3046 while (rings-- > 0) {
3103 struct u132_ring *ring = &u132->ring[rings]; 3047 struct u132_ring *ring = &u132->ring[rings];
3104 ring->u132 = u132; 3048 ring->u132 = u132;
3105 ring->number = rings + 1; 3049 ring->number = rings + 1;
3106 ring->length = 0; 3050 ring->length = 0;
3107 ring->curr_endp = NULL; 3051 ring->curr_endp = NULL;
3108 INIT_DELAYED_WORK(&ring->scheduler, 3052 INIT_DELAYED_WORK(&ring->scheduler,
3109 u132_hcd_ring_work_scheduler); 3053 u132_hcd_ring_work_scheduler);
3110 } mutex_lock(&u132->sw_lock); 3054 }
3111 INIT_DELAYED_WORK(&u132->monitor, u132_hcd_monitor_work); 3055 mutex_lock(&u132->sw_lock);
3112 while (ports-- > 0) { 3056 INIT_DELAYED_WORK(&u132->monitor, u132_hcd_monitor_work);
3113 struct u132_port *port = &u132->port[ports]; 3057 while (ports-- > 0) {
3114 port->u132 = u132; 3058 struct u132_port *port = &u132->port[ports];
3115 port->reset = 0; 3059 port->u132 = u132;
3116 port->enable = 0; 3060 port->reset = 0;
3117 port->power = 0; 3061 port->enable = 0;
3118 port->Status = 0; 3062 port->power = 0;
3119 } while (addrs-- > 0) { 3063 port->Status = 0;
3120 struct u132_addr *addr = &u132->addr[addrs]; 3064 }
3121 addr->address = 0; 3065 while (addrs-- > 0) {
3122 } while (udevs-- > 0) { 3066 struct u132_addr *addr = &u132->addr[addrs];
3123 struct u132_udev *udev = &u132->udev[udevs]; 3067 addr->address = 0;
3124 int i = ARRAY_SIZE(udev->endp_number_in); 3068 }
3125 int o = ARRAY_SIZE(udev->endp_number_out); 3069 while (udevs-- > 0) {
3126 udev->usb_device = NULL; 3070 struct u132_udev *udev = &u132->udev[udevs];
3127 udev->udev_number = 0; 3071 int i = ARRAY_SIZE(udev->endp_number_in);
3128 udev->usb_addr = 0; 3072 int o = ARRAY_SIZE(udev->endp_number_out);
3129 udev->portnumber = 0; 3073 udev->usb_device = NULL;
3130 while (i-- > 0) { 3074 udev->udev_number = 0;
3131 udev->endp_number_in[i] = 0; 3075 udev->usb_addr = 0;
3132 } 3076 udev->portnumber = 0;
3133 while (o-- > 0) { 3077 while (i-- > 0)
3134 udev->endp_number_out[o] = 0; 3078 udev->endp_number_in[i] = 0;
3135 } 3079
3136 } 3080 while (o-- > 0)
3137 while (endps-- > 0) { 3081 udev->endp_number_out[o] = 0;
3138 u132->endp[endps] = NULL; 3082
3139 } 3083 }
3140 mutex_unlock(&u132->sw_lock); 3084 while (endps-- > 0)
3141 return; 3085 u132->endp[endps] = NULL;
3086
3087 mutex_unlock(&u132->sw_lock);
3088 return;
3142} 3089}
3143 3090
3144static int __devinit u132_probe(struct platform_device *pdev) 3091static int __devinit u132_probe(struct platform_device *pdev)
3145{ 3092{
3146 struct usb_hcd *hcd; 3093 struct usb_hcd *hcd;
3147 int retval; 3094 int retval;
3148 u32 control; 3095 u32 control;
3149 u32 rh_a = -1; 3096 u32 rh_a = -1;
3150 u32 num_ports; 3097 u32 num_ports;
3151 msleep(100); 3098
3152 if (u132_exiting > 0) { 3099 msleep(100);
3153 return -ENODEV; 3100 if (u132_exiting > 0)
3154 } 3101 return -ENODEV;
3155 retval = ftdi_write_pcimem(pdev, intrdisable, OHCI_INTR_MIE); 3102
3156 if (retval) 3103 retval = ftdi_write_pcimem(pdev, intrdisable, OHCI_INTR_MIE);
3157 return retval; 3104 if (retval)
3158 retval = ftdi_read_pcimem(pdev, control, &control); 3105 return retval;
3159 if (retval) 3106 retval = ftdi_read_pcimem(pdev, control, &control);
3160 return retval; 3107 if (retval)
3161 retval = ftdi_read_pcimem(pdev, roothub.a, &rh_a); 3108 return retval;
3162 if (retval) 3109 retval = ftdi_read_pcimem(pdev, roothub.a, &rh_a);
3163 return retval; 3110 if (retval)
3164 num_ports = rh_a & RH_A_NDP; /* refuse to confuse usbcore */ 3111 return retval;
3165 if (pdev->dev.dma_mask) { 3112 num_ports = rh_a & RH_A_NDP; /* refuse to confuse usbcore */
3166 return -EINVAL; 3113 if (pdev->dev.dma_mask)
3167 } 3114 return -EINVAL;
3168 hcd = usb_create_hcd(&u132_hc_driver, &pdev->dev, pdev->dev.bus_id); 3115
3169 if (!hcd) { 3116 hcd = usb_create_hcd(&u132_hc_driver, &pdev->dev, pdev->dev.bus_id);
3170 printk(KERN_ERR "failed to create the usb hcd struct for U132\n" 3117 if (!hcd) {
3171 ); 3118 printk(KERN_ERR "failed to create the usb hcd struct for U132\n"
3172 ftdi_elan_gone_away(pdev); 3119 );
3173 return -ENOMEM; 3120 ftdi_elan_gone_away(pdev);
3174 } else { 3121 return -ENOMEM;
3175 int retval = 0; 3122 } else {
3176 struct u132 *u132 = hcd_to_u132(hcd); 3123 int retval = 0;
3177 hcd->rsrc_start = 0; 3124 struct u132 *u132 = hcd_to_u132(hcd);
3178 mutex_lock(&u132_module_lock); 3125 hcd->rsrc_start = 0;
3179 list_add_tail(&u132->u132_list, &u132_static_list); 3126 mutex_lock(&u132_module_lock);
3180 u132->sequence_num = ++u132_instances; 3127 list_add_tail(&u132->u132_list, &u132_static_list);
3181 mutex_unlock(&u132_module_lock); 3128 u132->sequence_num = ++u132_instances;
3182 u132_u132_init_kref(u132); 3129 mutex_unlock(&u132_module_lock);
3183 u132_initialise(u132, pdev); 3130 u132_u132_init_kref(u132);
3184 hcd->product_desc = "ELAN U132 Host Controller"; 3131 u132_initialise(u132, pdev);
3185 retval = usb_add_hcd(hcd, 0, 0); 3132 hcd->product_desc = "ELAN U132 Host Controller";
3186 if (retval != 0) { 3133 retval = usb_add_hcd(hcd, 0, 0);
3187 dev_err(&u132->platform_dev->dev, "init error %d\n", 3134 if (retval != 0) {
3188 retval); 3135 dev_err(&u132->platform_dev->dev, "init error %d\n",
3189 u132_u132_put_kref(u132); 3136 retval);
3190 return retval; 3137 u132_u132_put_kref(u132);
3191 } else { 3138 return retval;
3192 u132_monitor_queue_work(u132, 100); 3139 } else {
3193 return 0; 3140 u132_monitor_queue_work(u132, 100);
3194 } 3141 return 0;
3195 } 3142 }
3143 }
3196} 3144}
3197 3145
3198 3146
@@ -3203,61 +3151,58 @@ static int __devinit u132_probe(struct platform_device *pdev)
3203*/ 3151*/
3204static int u132_suspend(struct platform_device *pdev, pm_message_t state) 3152static int u132_suspend(struct platform_device *pdev, pm_message_t state)
3205{ 3153{
3206 struct usb_hcd *hcd = platform_get_drvdata(pdev); 3154 struct usb_hcd *hcd = platform_get_drvdata(pdev);
3207 struct u132 *u132 = hcd_to_u132(hcd); 3155 struct u132 *u132 = hcd_to_u132(hcd);
3208 if (u132->going > 1) { 3156 if (u132->going > 1) {
3209 dev_err(&u132->platform_dev->dev, "device has been removed %d\n" 3157 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
3210 , u132->going); 3158 , u132->going);
3211 return -ENODEV; 3159 return -ENODEV;
3212 } else if (u132->going > 0) { 3160 } else if (u132->going > 0) {
3213 dev_err(&u132->platform_dev->dev, "device is being removed\n"); 3161 dev_err(&u132->platform_dev->dev, "device is being removed\n");
3214 return -ESHUTDOWN; 3162 return -ESHUTDOWN;
3215 } else { 3163 } else {
3216 int retval = 0, ports; 3164 int retval = 0, ports;
3217 3165
3218 switch (state.event) { 3166 switch (state.event) {
3219 case PM_EVENT_FREEZE: 3167 case PM_EVENT_FREEZE:
3220 retval = u132_bus_suspend(hcd); 3168 retval = u132_bus_suspend(hcd);
3221 break; 3169 break;
3222 case PM_EVENT_SUSPEND: 3170 case PM_EVENT_SUSPEND:
3223 case PM_EVENT_HIBERNATE: 3171 case PM_EVENT_HIBERNATE:
3224 ports = MAX_U132_PORTS; 3172 ports = MAX_U132_PORTS;
3225 while (ports-- > 0) { 3173 while (ports-- > 0) {
3226 port_power(u132, ports, 0); 3174 port_power(u132, ports, 0);
3227 } 3175 }
3228 break; 3176 break;
3229 } 3177 }
3230 if (retval == 0) 3178 return retval;
3231 pdev->dev.power.power_state = state; 3179 }
3232 return retval;
3233 }
3234} 3180}
3235 3181
3236static int u132_resume(struct platform_device *pdev) 3182static int u132_resume(struct platform_device *pdev)
3237{ 3183{
3238 struct usb_hcd *hcd = platform_get_drvdata(pdev); 3184 struct usb_hcd *hcd = platform_get_drvdata(pdev);
3239 struct u132 *u132 = hcd_to_u132(hcd); 3185 struct u132 *u132 = hcd_to_u132(hcd);
3240 if (u132->going > 1) { 3186 if (u132->going > 1) {
3241 dev_err(&u132->platform_dev->dev, "device has been removed %d\n" 3187 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
3242 , u132->going); 3188 , u132->going);
3243 return -ENODEV; 3189 return -ENODEV;
3244 } else if (u132->going > 0) { 3190 } else if (u132->going > 0) {
3245 dev_err(&u132->platform_dev->dev, "device is being removed\n"); 3191 dev_err(&u132->platform_dev->dev, "device is being removed\n");
3246 return -ESHUTDOWN; 3192 return -ESHUTDOWN;
3247 } else { 3193 } else {
3248 int retval = 0; 3194 int retval = 0;
3249 if (pdev->dev.power.power_state.event == PM_EVENT_SUSPEND) { 3195 if (!u132->port[0].power) {
3250 int ports = MAX_U132_PORTS; 3196 int ports = MAX_U132_PORTS;
3251 while (ports-- > 0) { 3197 while (ports-- > 0) {
3252 port_power(u132, ports, 1); 3198 port_power(u132, ports, 1);
3253 } 3199 }
3254 retval = 0; 3200 retval = 0;
3255 } else { 3201 } else {
3256 pdev->dev.power.power_state = PMSG_ON; 3202 retval = u132_bus_resume(hcd);
3257 retval = u132_bus_resume(hcd); 3203 }
3258 } 3204 return retval;
3259 return retval; 3205 }
3260 }
3261} 3206}
3262 3207
3263#else 3208#else
@@ -3270,47 +3215,48 @@ static int u132_resume(struct platform_device *pdev)
3270* the platform_driver struct is static because it is per type of module 3215* the platform_driver struct is static because it is per type of module
3271*/ 3216*/
3272static struct platform_driver u132_platform_driver = { 3217static struct platform_driver u132_platform_driver = {
3273 .probe = u132_probe, 3218 .probe = u132_probe,
3274 .remove = __devexit_p(u132_remove), 3219 .remove = __devexit_p(u132_remove),
3275 .suspend = u132_suspend, 3220 .suspend = u132_suspend,
3276 .resume = u132_resume, 3221 .resume = u132_resume,
3277 .driver = { 3222 .driver = {
3278 .name = (char *)hcd_name, 3223 .name = (char *)hcd_name,
3279 .owner = THIS_MODULE, 3224 .owner = THIS_MODULE,
3280 }, 3225 },
3281}; 3226};
3282static int __init u132_hcd_init(void) 3227static int __init u132_hcd_init(void)
3283{ 3228{
3284 int retval; 3229 int retval;
3285 INIT_LIST_HEAD(&u132_static_list); 3230 INIT_LIST_HEAD(&u132_static_list);
3286 u132_instances = 0; 3231 u132_instances = 0;
3287 u132_exiting = 0; 3232 u132_exiting = 0;
3288 mutex_init(&u132_module_lock); 3233 mutex_init(&u132_module_lock);
3289 if (usb_disabled()) 3234 if (usb_disabled())
3290 return -ENODEV; 3235 return -ENODEV;
3291 printk(KERN_INFO "driver %s built at %s on %s\n", hcd_name, __TIME__, 3236 printk(KERN_INFO "driver %s built at %s on %s\n", hcd_name, __TIME__,
3292 __DATE__); 3237 __DATE__);
3293 workqueue = create_singlethread_workqueue("u132"); 3238 workqueue = create_singlethread_workqueue("u132");
3294 retval = platform_driver_register(&u132_platform_driver); 3239 retval = platform_driver_register(&u132_platform_driver);
3295 return retval; 3240 return retval;
3296} 3241}
3297 3242
3298 3243
3299module_init(u132_hcd_init); 3244module_init(u132_hcd_init);
3300static void __exit u132_hcd_exit(void) 3245static void __exit u132_hcd_exit(void)
3301{ 3246{
3302 struct u132 *u132; 3247 struct u132 *u132;
3303 struct u132 *temp; 3248 struct u132 *temp;
3304 mutex_lock(&u132_module_lock); 3249 mutex_lock(&u132_module_lock);
3305 u132_exiting += 1; 3250 u132_exiting += 1;
3306 mutex_unlock(&u132_module_lock); 3251 mutex_unlock(&u132_module_lock);
3307 list_for_each_entry_safe(u132, temp, &u132_static_list, u132_list) { 3252 list_for_each_entry_safe(u132, temp, &u132_static_list, u132_list) {
3308 platform_device_unregister(u132->platform_dev); 3253 platform_device_unregister(u132->platform_dev);
3309 } platform_driver_unregister(&u132_platform_driver); 3254 }
3310 printk(KERN_INFO "u132-hcd driver deregistered\n"); 3255 platform_driver_unregister(&u132_platform_driver);
3311 wait_event(u132_hcd_wait, u132_instances == 0); 3256 printk(KERN_INFO "u132-hcd driver deregistered\n");
3312 flush_workqueue(workqueue); 3257 wait_event(u132_hcd_wait, u132_instances == 0);
3313 destroy_workqueue(workqueue); 3258 flush_workqueue(workqueue);
3259 destroy_workqueue(workqueue);
3314} 3260}
3315 3261
3316 3262
diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c
index ec987897b8e..d3e0d8aa398 100644
--- a/drivers/usb/host/uhci-hcd.c
+++ b/drivers/usb/host/uhci-hcd.c
@@ -262,20 +262,12 @@ __acquires(uhci->lock)
262{ 262{
263 int auto_stop; 263 int auto_stop;
264 int int_enable, egsm_enable; 264 int int_enable, egsm_enable;
265 struct usb_device *rhdev = uhci_to_hcd(uhci)->self.root_hub;
265 266
266 auto_stop = (new_state == UHCI_RH_AUTO_STOPPED); 267 auto_stop = (new_state == UHCI_RH_AUTO_STOPPED);
267 dev_dbg(&uhci_to_hcd(uhci)->self.root_hub->dev, 268 dev_dbg(&rhdev->dev, "%s%s\n", __func__,
268 "%s%s\n", __FUNCTION__,
269 (auto_stop ? " (auto-stop)" : "")); 269 (auto_stop ? " (auto-stop)" : ""));
270 270
271 /* If we get a suspend request when we're already auto-stopped
272 * then there's nothing to do.
273 */
274 if (uhci->rh_state == UHCI_RH_AUTO_STOPPED) {
275 uhci->rh_state = new_state;
276 return;
277 }
278
279 /* Enable resume-detect interrupts if they work. 271 /* Enable resume-detect interrupts if they work.
280 * Then enter Global Suspend mode if _it_ works, still configured. 272 * Then enter Global Suspend mode if _it_ works, still configured.
281 */ 273 */
@@ -285,8 +277,10 @@ __acquires(uhci->lock)
285 if (remote_wakeup_is_broken(uhci)) 277 if (remote_wakeup_is_broken(uhci))
286 egsm_enable = 0; 278 egsm_enable = 0;
287 if (resume_detect_interrupts_are_broken(uhci) || !egsm_enable || 279 if (resume_detect_interrupts_are_broken(uhci) || !egsm_enable ||
288 !device_may_wakeup( 280#ifdef CONFIG_PM
289 &uhci_to_hcd(uhci)->self.root_hub->dev)) 281 (!auto_stop && !rhdev->do_remote_wakeup) ||
282#endif
283 (auto_stop && !device_may_wakeup(&rhdev->dev)))
290 uhci->working_RD = int_enable = 0; 284 uhci->working_RD = int_enable = 0;
291 285
292 outw(int_enable, uhci->io_addr + USBINTR); 286 outw(int_enable, uhci->io_addr + USBINTR);
@@ -308,8 +302,7 @@ __acquires(uhci->lock)
308 return; 302 return;
309 } 303 }
310 if (!(inw(uhci->io_addr + USBSTS) & USBSTS_HCH)) 304 if (!(inw(uhci->io_addr + USBSTS) & USBSTS_HCH))
311 dev_warn(&uhci_to_hcd(uhci)->self.root_hub->dev, 305 dev_warn(uhci_dev(uhci), "Controller not stopped yet!\n");
312 "Controller not stopped yet!\n");
313 306
314 uhci_get_current_frame_number(uhci); 307 uhci_get_current_frame_number(uhci);
315 308
@@ -342,7 +335,7 @@ __releases(uhci->lock)
342__acquires(uhci->lock) 335__acquires(uhci->lock)
343{ 336{
344 dev_dbg(&uhci_to_hcd(uhci)->self.root_hub->dev, 337 dev_dbg(&uhci_to_hcd(uhci)->self.root_hub->dev,
345 "%s%s\n", __FUNCTION__, 338 "%s%s\n", __func__,
346 uhci->rh_state == UHCI_RH_AUTO_STOPPED ? 339 uhci->rh_state == UHCI_RH_AUTO_STOPPED ?
347 " (auto-start)" : ""); 340 " (auto-start)" : "");
348 341
@@ -737,12 +730,12 @@ static int uhci_rh_resume(struct usb_hcd *hcd)
737 return rc; 730 return rc;
738} 731}
739 732
740static int uhci_suspend(struct usb_hcd *hcd, pm_message_t message) 733static int uhci_pci_suspend(struct usb_hcd *hcd, pm_message_t message)
741{ 734{
742 struct uhci_hcd *uhci = hcd_to_uhci(hcd); 735 struct uhci_hcd *uhci = hcd_to_uhci(hcd);
743 int rc = 0; 736 int rc = 0;
744 737
745 dev_dbg(uhci_dev(uhci), "%s\n", __FUNCTION__); 738 dev_dbg(uhci_dev(uhci), "%s\n", __func__);
746 739
747 spin_lock_irq(&uhci->lock); 740 spin_lock_irq(&uhci->lock);
748 if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags) || uhci->dead) 741 if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags) || uhci->dead)
@@ -774,11 +767,11 @@ done:
774 return rc; 767 return rc;
775} 768}
776 769
777static int uhci_resume(struct usb_hcd *hcd) 770static int uhci_pci_resume(struct usb_hcd *hcd)
778{ 771{
779 struct uhci_hcd *uhci = hcd_to_uhci(hcd); 772 struct uhci_hcd *uhci = hcd_to_uhci(hcd);
780 773
781 dev_dbg(uhci_dev(uhci), "%s\n", __FUNCTION__); 774 dev_dbg(uhci_dev(uhci), "%s\n", __func__);
782 775
783 /* Since we aren't in D3 any more, it's safe to set this flag 776 /* Since we aren't in D3 any more, it's safe to set this flag
784 * even if the controller was dead. 777 * even if the controller was dead.
@@ -872,8 +865,8 @@ static const struct hc_driver uhci_driver = {
872 .reset = uhci_init, 865 .reset = uhci_init,
873 .start = uhci_start, 866 .start = uhci_start,
874#ifdef CONFIG_PM 867#ifdef CONFIG_PM
875 .suspend = uhci_suspend, 868 .pci_suspend = uhci_pci_suspend,
876 .resume = uhci_resume, 869 .pci_resume = uhci_pci_resume,
877 .bus_suspend = uhci_rh_suspend, 870 .bus_suspend = uhci_rh_suspend,
878 .bus_resume = uhci_rh_resume, 871 .bus_resume = uhci_rh_resume,
879#endif 872#endif
diff --git a/drivers/usb/host/uhci-q.c b/drivers/usb/host/uhci-q.c
index 60379b17bbc..db645936eed 100644
--- a/drivers/usb/host/uhci-q.c
+++ b/drivers/usb/host/uhci-q.c
@@ -1171,7 +1171,7 @@ static int uhci_result_common(struct uhci_hcd *uhci, struct urb *urb)
1171 /* Some debugging code */ 1171 /* Some debugging code */
1172 dev_dbg(&urb->dev->dev, 1172 dev_dbg(&urb->dev->dev,
1173 "%s: failed with status %x\n", 1173 "%s: failed with status %x\n",
1174 __FUNCTION__, status); 1174 __func__, status);
1175 1175
1176 if (debug > 1 && errbuf) { 1176 if (debug > 1 && errbuf) {
1177 /* Print the chain for debugging */ 1177 /* Print the chain for debugging */
diff --git a/drivers/usb/image/Kconfig b/drivers/usb/image/Kconfig
index 7595dfb38e3..33350f9dd34 100644
--- a/drivers/usb/image/Kconfig
+++ b/drivers/usb/image/Kconfig
@@ -5,8 +5,8 @@ comment "USB Imaging devices"
5 depends on USB 5 depends on USB
6 6
7config USB_MDC800 7config USB_MDC800
8 tristate "USB Mustek MDC800 Digital Camera support (EXPERIMENTAL)" 8 tristate "USB Mustek MDC800 Digital Camera support"
9 depends on USB && EXPERIMENTAL 9 depends on USB
10 ---help--- 10 ---help---
11 Say Y here if you want to connect this type of still camera to 11 Say Y here if you want to connect this type of still camera to
12 your computer's USB port. This driver can be used with gphoto 0.4.3 12 your computer's USB port. This driver can be used with gphoto 0.4.3
diff --git a/drivers/usb/image/microtek.c b/drivers/usb/image/microtek.c
index bc207e3c21f..885867a86de 100644
--- a/drivers/usb/image/microtek.c
+++ b/drivers/usb/image/microtek.c
@@ -185,7 +185,7 @@ static struct usb_driver mts_usb_driver = {
185 printk( KERN_DEBUG MTS_NAME x ) 185 printk( KERN_DEBUG MTS_NAME x )
186 186
187#define MTS_DEBUG_GOT_HERE() \ 187#define MTS_DEBUG_GOT_HERE() \
188 MTS_DEBUG("got to %s:%d (%s)\n", __FILE__, (int)__LINE__, __PRETTY_FUNCTION__ ) 188 MTS_DEBUG("got to %s:%d (%s)\n", __FILE__, (int)__LINE__, __func__ )
189#define MTS_DEBUG_INT() \ 189#define MTS_DEBUG_INT() \
190 do { MTS_DEBUG_GOT_HERE(); \ 190 do { MTS_DEBUG_GOT_HERE(); \
191 MTS_DEBUG("transfer = 0x%x context = 0x%x\n",(int)transfer,(int)context ); \ 191 MTS_DEBUG("transfer = 0x%x context = 0x%x\n",(int)transfer,(int)context ); \
@@ -794,7 +794,6 @@ static int mts_usb_probe(struct usb_interface *intf,
794 794
795 new_desc->usb_dev = dev; 795 new_desc->usb_dev = dev;
796 new_desc->usb_intf = intf; 796 new_desc->usb_intf = intf;
797 init_MUTEX(&new_desc->lock);
798 797
799 /* endpoints */ 798 /* endpoints */
800 new_desc->ep_out = ep_out; 799 new_desc->ep_out = ep_out;
diff --git a/drivers/usb/image/microtek.h b/drivers/usb/image/microtek.h
index d5d62a93905..ccce318f20a 100644
--- a/drivers/usb/image/microtek.h
+++ b/drivers/usb/image/microtek.h
@@ -39,7 +39,6 @@ struct mts_desc {
39 u8 ep_image; 39 u8 ep_image;
40 40
41 struct Scsi_Host * host; 41 struct Scsi_Host * host;
42 struct semaphore lock;
43 42
44 struct urb *urb; 43 struct urb *urb;
45 struct mts_transfer_context context; 44 struct mts_transfer_context context;
diff --git a/drivers/usb/misc/Kconfig b/drivers/usb/misc/Kconfig
index 9c7eb6144d0..a53db1d4e07 100644
--- a/drivers/usb/misc/Kconfig
+++ b/drivers/usb/misc/Kconfig
@@ -33,8 +33,8 @@ config USB_EMI26
33 module will be called emi26. 33 module will be called emi26.
34 34
35config USB_ADUTUX 35config USB_ADUTUX
36 tristate "ADU devices from Ontrak Control Systems (EXPERIMENTAL)" 36 tristate "ADU devices from Ontrak Control Systems"
37 depends on USB && EXPERIMENTAL 37 depends on USB
38 help 38 help
39 Say Y if you want to use an ADU device from Ontrak Control 39 Say Y if you want to use an ADU device from Ontrak Control
40 Systems. 40 Systems.
@@ -43,8 +43,8 @@ config USB_ADUTUX
43 will be called adutux. 43 will be called adutux.
44 44
45config USB_AUERSWALD 45config USB_AUERSWALD
46 tristate "USB Auerswald ISDN support (EXPERIMENTAL)" 46 tristate "USB Auerswald ISDN support"
47 depends on USB && EXPERIMENTAL 47 depends on USB
48 help 48 help
49 Say Y here if you want to connect an Auerswald USB ISDN Device 49 Say Y here if you want to connect an Auerswald USB ISDN Device
50 to your computer's USB port. 50 to your computer's USB port.
@@ -53,8 +53,8 @@ config USB_AUERSWALD
53 module will be called auerswald. 53 module will be called auerswald.
54 54
55config USB_RIO500 55config USB_RIO500
56 tristate "USB Diamond Rio500 support (EXPERIMENTAL)" 56 tristate "USB Diamond Rio500 support"
57 depends on USB && EXPERIMENTAL 57 depends on USB
58 help 58 help
59 Say Y here if you want to connect a USB Rio500 mp3 player to your 59 Say Y here if you want to connect a USB Rio500 mp3 player to your
60 computer's USB port. Please read <file:Documentation/usb/rio.txt> 60 computer's USB port. Please read <file:Documentation/usb/rio.txt>
@@ -64,8 +64,8 @@ config USB_RIO500
64 module will be called rio500. 64 module will be called rio500.
65 65
66config USB_LEGOTOWER 66config USB_LEGOTOWER
67 tristate "USB Lego Infrared Tower support (EXPERIMENTAL)" 67 tristate "USB Lego Infrared Tower support"
68 depends on USB && EXPERIMENTAL 68 depends on USB
69 help 69 help
70 Say Y here if you want to connect a USB Lego Infrared Tower to your 70 Say Y here if you want to connect a USB Lego Infrared Tower to your
71 computer's USB port. 71 computer's USB port.
@@ -259,8 +259,8 @@ config USB_IOWARRIOR
259 module will be called iowarrior. 259 module will be called iowarrior.
260 260
261config USB_TEST 261config USB_TEST
262 tristate "USB testing driver (DEVELOPMENT)" 262 tristate "USB testing driver"
263 depends on USB && USB_DEVICEFS && EXPERIMENTAL 263 depends on USB && USB_DEVICEFS
264 help 264 help
265 This driver is for testing host controller software. It is used 265 This driver is for testing host controller software. It is used
266 with specialized device firmware for regression and stress testing, 266 with specialized device firmware for regression and stress testing,
diff --git a/drivers/usb/misc/adutux.c b/drivers/usb/misc/adutux.c
index 5a2c44e4c1f..965f6eaea6a 100644
--- a/drivers/usb/misc/adutux.c
+++ b/drivers/usb/misc/adutux.c
@@ -147,10 +147,10 @@ static void adu_abort_transfers(struct adu_device *dev)
147{ 147{
148 unsigned long flags; 148 unsigned long flags;
149 149
150 dbg(2," %s : enter", __FUNCTION__); 150 dbg(2," %s : enter", __func__);
151 151
152 if (dev->udev == NULL) { 152 if (dev->udev == NULL) {
153 dbg(1," %s : udev is null", __FUNCTION__); 153 dbg(1," %s : udev is null", __func__);
154 goto exit; 154 goto exit;
155 } 155 }
156 156
@@ -172,12 +172,12 @@ static void adu_abort_transfers(struct adu_device *dev)
172 spin_unlock_irqrestore(&dev->buflock, flags); 172 spin_unlock_irqrestore(&dev->buflock, flags);
173 173
174exit: 174exit:
175 dbg(2," %s : leave", __FUNCTION__); 175 dbg(2," %s : leave", __func__);
176} 176}
177 177
178static void adu_delete(struct adu_device *dev) 178static void adu_delete(struct adu_device *dev)
179{ 179{
180 dbg(2, "%s enter", __FUNCTION__); 180 dbg(2, "%s enter", __func__);
181 181
182 /* free data structures */ 182 /* free data structures */
183 usb_free_urb(dev->interrupt_in_urb); 183 usb_free_urb(dev->interrupt_in_urb);
@@ -188,7 +188,7 @@ static void adu_delete(struct adu_device *dev)
188 kfree(dev->interrupt_out_buffer); 188 kfree(dev->interrupt_out_buffer);
189 kfree(dev); 189 kfree(dev);
190 190
191 dbg(2, "%s : leave", __FUNCTION__); 191 dbg(2, "%s : leave", __func__);
192} 192}
193 193
194static void adu_interrupt_in_callback(struct urb *urb) 194static void adu_interrupt_in_callback(struct urb *urb)
@@ -196,8 +196,8 @@ static void adu_interrupt_in_callback(struct urb *urb)
196 struct adu_device *dev = urb->context; 196 struct adu_device *dev = urb->context;
197 int status = urb->status; 197 int status = urb->status;
198 198
199 dbg(4," %s : enter, status %d", __FUNCTION__, status); 199 dbg(4," %s : enter, status %d", __func__, status);
200 adu_debug_data(5, __FUNCTION__, urb->actual_length, 200 adu_debug_data(5, __func__, urb->actual_length,
201 urb->transfer_buffer); 201 urb->transfer_buffer);
202 202
203 spin_lock(&dev->buflock); 203 spin_lock(&dev->buflock);
@@ -206,7 +206,7 @@ static void adu_interrupt_in_callback(struct urb *urb)
206 if ((status != -ENOENT) && (status != -ECONNRESET) && 206 if ((status != -ENOENT) && (status != -ECONNRESET) &&
207 (status != -ESHUTDOWN)) { 207 (status != -ESHUTDOWN)) {
208 dbg(1," %s : nonzero status received: %d", 208 dbg(1," %s : nonzero status received: %d",
209 __FUNCTION__, status); 209 __func__, status);
210 } 210 }
211 goto exit; 211 goto exit;
212 } 212 }
@@ -220,10 +220,10 @@ static void adu_interrupt_in_callback(struct urb *urb)
220 dev->interrupt_in_buffer, urb->actual_length); 220 dev->interrupt_in_buffer, urb->actual_length);
221 221
222 dev->read_buffer_length += urb->actual_length; 222 dev->read_buffer_length += urb->actual_length;
223 dbg(2," %s reading %d ", __FUNCTION__, 223 dbg(2," %s reading %d ", __func__,
224 urb->actual_length); 224 urb->actual_length);
225 } else { 225 } else {
226 dbg(1," %s : read_buffer overflow", __FUNCTION__); 226 dbg(1," %s : read_buffer overflow", __func__);
227 } 227 }
228 } 228 }
229 229
@@ -232,9 +232,9 @@ exit:
232 spin_unlock(&dev->buflock); 232 spin_unlock(&dev->buflock);
233 /* always wake up so we recover from errors */ 233 /* always wake up so we recover from errors */
234 wake_up_interruptible(&dev->read_wait); 234 wake_up_interruptible(&dev->read_wait);
235 adu_debug_data(5, __FUNCTION__, urb->actual_length, 235 adu_debug_data(5, __func__, urb->actual_length,
236 urb->transfer_buffer); 236 urb->transfer_buffer);
237 dbg(4," %s : leave, status %d", __FUNCTION__, status); 237 dbg(4," %s : leave, status %d", __func__, status);
238} 238}
239 239
240static void adu_interrupt_out_callback(struct urb *urb) 240static void adu_interrupt_out_callback(struct urb *urb)
@@ -242,14 +242,14 @@ static void adu_interrupt_out_callback(struct urb *urb)
242 struct adu_device *dev = urb->context; 242 struct adu_device *dev = urb->context;
243 int status = urb->status; 243 int status = urb->status;
244 244
245 dbg(4," %s : enter, status %d", __FUNCTION__, status); 245 dbg(4," %s : enter, status %d", __func__, status);
246 adu_debug_data(5,__FUNCTION__, urb->actual_length, urb->transfer_buffer); 246 adu_debug_data(5,__func__, urb->actual_length, urb->transfer_buffer);
247 247
248 if (status != 0) { 248 if (status != 0) {
249 if ((status != -ENOENT) && 249 if ((status != -ENOENT) &&
250 (status != -ECONNRESET)) { 250 (status != -ECONNRESET)) {
251 dbg(1, " %s :nonzero status received: %d", 251 dbg(1, " %s :nonzero status received: %d",
252 __FUNCTION__, status); 252 __func__, status);
253 } 253 }
254 goto exit; 254 goto exit;
255 } 255 }
@@ -260,9 +260,9 @@ static void adu_interrupt_out_callback(struct urb *urb)
260 spin_unlock(&dev->buflock); 260 spin_unlock(&dev->buflock);
261exit: 261exit:
262 262
263 adu_debug_data(5, __FUNCTION__, urb->actual_length, 263 adu_debug_data(5, __func__, urb->actual_length,
264 urb->transfer_buffer); 264 urb->transfer_buffer);
265 dbg(4," %s : leave, status %d", __FUNCTION__, status); 265 dbg(4," %s : leave, status %d", __func__, status);
266} 266}
267 267
268static int adu_open(struct inode *inode, struct file *file) 268static int adu_open(struct inode *inode, struct file *file)
@@ -272,19 +272,19 @@ static int adu_open(struct inode *inode, struct file *file)
272 int subminor; 272 int subminor;
273 int retval; 273 int retval;
274 274
275 dbg(2,"%s : enter", __FUNCTION__); 275 dbg(2,"%s : enter", __func__);
276 276
277 subminor = iminor(inode); 277 subminor = iminor(inode);
278 278
279 if ((retval = mutex_lock_interruptible(&adutux_mutex))) { 279 if ((retval = mutex_lock_interruptible(&adutux_mutex))) {
280 dbg(2, "%s : mutex lock failed", __FUNCTION__); 280 dbg(2, "%s : mutex lock failed", __func__);
281 goto exit_no_lock; 281 goto exit_no_lock;
282 } 282 }
283 283
284 interface = usb_find_interface(&adu_driver, subminor); 284 interface = usb_find_interface(&adu_driver, subminor);
285 if (!interface) { 285 if (!interface) {
286 err("%s - error, can't find device for minor %d", 286 err("%s - error, can't find device for minor %d",
287 __FUNCTION__, subminor); 287 __func__, subminor);
288 retval = -ENODEV; 288 retval = -ENODEV;
289 goto exit_no_device; 289 goto exit_no_device;
290 } 290 }
@@ -302,7 +302,7 @@ static int adu_open(struct inode *inode, struct file *file)
302 } 302 }
303 303
304 ++dev->open_count; 304 ++dev->open_count;
305 dbg(2,"%s : open count %d", __FUNCTION__, dev->open_count); 305 dbg(2,"%s : open count %d", __func__, dev->open_count);
306 306
307 /* save device in the file's private structure */ 307 /* save device in the file's private structure */
308 file->private_data = dev; 308 file->private_data = dev;
@@ -332,23 +332,23 @@ static int adu_open(struct inode *inode, struct file *file)
332exit_no_device: 332exit_no_device:
333 mutex_unlock(&adutux_mutex); 333 mutex_unlock(&adutux_mutex);
334exit_no_lock: 334exit_no_lock:
335 dbg(2,"%s : leave, return value %d ", __FUNCTION__, retval); 335 dbg(2,"%s : leave, return value %d ", __func__, retval);
336 return retval; 336 return retval;
337} 337}
338 338
339static void adu_release_internal(struct adu_device *dev) 339static void adu_release_internal(struct adu_device *dev)
340{ 340{
341 dbg(2," %s : enter", __FUNCTION__); 341 dbg(2," %s : enter", __func__);
342 342
343 /* decrement our usage count for the device */ 343 /* decrement our usage count for the device */
344 --dev->open_count; 344 --dev->open_count;
345 dbg(2," %s : open count %d", __FUNCTION__, dev->open_count); 345 dbg(2," %s : open count %d", __func__, dev->open_count);
346 if (dev->open_count <= 0) { 346 if (dev->open_count <= 0) {
347 adu_abort_transfers(dev); 347 adu_abort_transfers(dev);
348 dev->open_count = 0; 348 dev->open_count = 0;
349 } 349 }
350 350
351 dbg(2," %s : leave", __FUNCTION__); 351 dbg(2," %s : leave", __func__);
352} 352}
353 353
354static int adu_release(struct inode *inode, struct file *file) 354static int adu_release(struct inode *inode, struct file *file)
@@ -356,17 +356,17 @@ static int adu_release(struct inode *inode, struct file *file)
356 struct adu_device *dev; 356 struct adu_device *dev;
357 int retval = 0; 357 int retval = 0;
358 358
359 dbg(2," %s : enter", __FUNCTION__); 359 dbg(2," %s : enter", __func__);
360 360
361 if (file == NULL) { 361 if (file == NULL) {
362 dbg(1," %s : file is NULL", __FUNCTION__); 362 dbg(1," %s : file is NULL", __func__);
363 retval = -ENODEV; 363 retval = -ENODEV;
364 goto exit; 364 goto exit;
365 } 365 }
366 366
367 dev = file->private_data; 367 dev = file->private_data;
368 if (dev == NULL) { 368 if (dev == NULL) {
369 dbg(1," %s : object is NULL", __FUNCTION__); 369 dbg(1," %s : object is NULL", __func__);
370 retval = -ENODEV; 370 retval = -ENODEV;
371 goto exit; 371 goto exit;
372 } 372 }
@@ -374,7 +374,7 @@ static int adu_release(struct inode *inode, struct file *file)
374 mutex_lock(&adutux_mutex); /* not interruptible */ 374 mutex_lock(&adutux_mutex); /* not interruptible */
375 375
376 if (dev->open_count <= 0) { 376 if (dev->open_count <= 0) {
377 dbg(1," %s : device not opened", __FUNCTION__); 377 dbg(1," %s : device not opened", __func__);
378 retval = -ENODEV; 378 retval = -ENODEV;
379 goto exit; 379 goto exit;
380 } 380 }
@@ -388,7 +388,7 @@ static int adu_release(struct inode *inode, struct file *file)
388 388
389exit: 389exit:
390 mutex_unlock(&adutux_mutex); 390 mutex_unlock(&adutux_mutex);
391 dbg(2," %s : leave, return value %d", __FUNCTION__, retval); 391 dbg(2," %s : leave, return value %d", __func__, retval);
392 return retval; 392 return retval;
393} 393}
394 394
@@ -405,10 +405,10 @@ static ssize_t adu_read(struct file *file, __user char *buffer, size_t count,
405 unsigned long flags; 405 unsigned long flags;
406 DECLARE_WAITQUEUE(wait, current); 406 DECLARE_WAITQUEUE(wait, current);
407 407
408 dbg(2," %s : enter, count = %Zd, file=%p", __FUNCTION__, count, file); 408 dbg(2," %s : enter, count = %Zd, file=%p", __func__, count, file);
409 409
410 dev = file->private_data; 410 dev = file->private_data;
411 dbg(2," %s : dev=%p", __FUNCTION__, dev); 411 dbg(2," %s : dev=%p", __func__, dev);
412 412
413 if (mutex_lock_interruptible(&dev->mtx)) 413 if (mutex_lock_interruptible(&dev->mtx))
414 return -ERESTARTSYS; 414 return -ERESTARTSYS;
@@ -422,16 +422,16 @@ static ssize_t adu_read(struct file *file, __user char *buffer, size_t count,
422 422
423 /* verify that some data was requested */ 423 /* verify that some data was requested */
424 if (count == 0) { 424 if (count == 0) {
425 dbg(1," %s : read request of 0 bytes", __FUNCTION__); 425 dbg(1," %s : read request of 0 bytes", __func__);
426 goto exit; 426 goto exit;
427 } 427 }
428 428
429 timeout = COMMAND_TIMEOUT; 429 timeout = COMMAND_TIMEOUT;
430 dbg(2," %s : about to start looping", __FUNCTION__); 430 dbg(2," %s : about to start looping", __func__);
431 while (bytes_to_read) { 431 while (bytes_to_read) {
432 int data_in_secondary = dev->secondary_tail - dev->secondary_head; 432 int data_in_secondary = dev->secondary_tail - dev->secondary_head;
433 dbg(2," %s : while, data_in_secondary=%d, status=%d", 433 dbg(2," %s : while, data_in_secondary=%d, status=%d",
434 __FUNCTION__, data_in_secondary, 434 __func__, data_in_secondary,
435 dev->interrupt_in_urb->status); 435 dev->interrupt_in_urb->status);
436 436
437 if (data_in_secondary) { 437 if (data_in_secondary) {
@@ -456,7 +456,7 @@ static ssize_t adu_read(struct file *file, __user char *buffer, size_t count,
456 /* we secure access to the primary */ 456 /* we secure access to the primary */
457 char *tmp; 457 char *tmp;
458 dbg(2," %s : swap, read_buffer_length = %d", 458 dbg(2," %s : swap, read_buffer_length = %d",
459 __FUNCTION__, dev->read_buffer_length); 459 __func__, dev->read_buffer_length);
460 tmp = dev->read_buffer_secondary; 460 tmp = dev->read_buffer_secondary;
461 dev->read_buffer_secondary = dev->read_buffer_primary; 461 dev->read_buffer_secondary = dev->read_buffer_primary;
462 dev->read_buffer_primary = tmp; 462 dev->read_buffer_primary = tmp;
@@ -471,10 +471,10 @@ static ssize_t adu_read(struct file *file, __user char *buffer, size_t count,
471 if (!dev->read_urb_finished) { 471 if (!dev->read_urb_finished) {
472 /* somebody is doing IO */ 472 /* somebody is doing IO */
473 spin_unlock_irqrestore(&dev->buflock, flags); 473 spin_unlock_irqrestore(&dev->buflock, flags);
474 dbg(2," %s : submitted already", __FUNCTION__); 474 dbg(2," %s : submitted already", __func__);
475 } else { 475 } else {
476 /* we must initiate input */ 476 /* we must initiate input */
477 dbg(2," %s : initiate input", __FUNCTION__); 477 dbg(2," %s : initiate input", __func__);
478 dev->read_urb_finished = 0; 478 dev->read_urb_finished = 0;
479 spin_unlock_irqrestore(&dev->buflock, flags); 479 spin_unlock_irqrestore(&dev->buflock, flags);
480 480
@@ -492,7 +492,7 @@ static ssize_t adu_read(struct file *file, __user char *buffer, size_t count,
492 if (retval == -ENOMEM) { 492 if (retval == -ENOMEM) {
493 retval = bytes_read ? bytes_read : -ENOMEM; 493 retval = bytes_read ? bytes_read : -ENOMEM;
494 } 494 }
495 dbg(2," %s : submit failed", __FUNCTION__); 495 dbg(2," %s : submit failed", __func__);
496 goto exit; 496 goto exit;
497 } 497 }
498 } 498 }
@@ -511,13 +511,13 @@ static ssize_t adu_read(struct file *file, __user char *buffer, size_t count,
511 remove_wait_queue(&dev->read_wait, &wait); 511 remove_wait_queue(&dev->read_wait, &wait);
512 512
513 if (timeout <= 0) { 513 if (timeout <= 0) {
514 dbg(2," %s : timeout", __FUNCTION__); 514 dbg(2," %s : timeout", __func__);
515 retval = bytes_read ? bytes_read : -ETIMEDOUT; 515 retval = bytes_read ? bytes_read : -ETIMEDOUT;
516 goto exit; 516 goto exit;
517 } 517 }
518 518
519 if (signal_pending(current)) { 519 if (signal_pending(current)) {
520 dbg(2," %s : signal pending", __FUNCTION__); 520 dbg(2," %s : signal pending", __func__);
521 retval = bytes_read ? bytes_read : -EINTR; 521 retval = bytes_read ? bytes_read : -EINTR;
522 goto exit; 522 goto exit;
523 } 523 }
@@ -550,7 +550,7 @@ exit:
550 /* unlock the device */ 550 /* unlock the device */
551 mutex_unlock(&dev->mtx); 551 mutex_unlock(&dev->mtx);
552 552
553 dbg(2," %s : leave, return value %d", __FUNCTION__, retval); 553 dbg(2," %s : leave, return value %d", __func__, retval);
554 return retval; 554 return retval;
555} 555}
556 556
@@ -565,7 +565,7 @@ static ssize_t adu_write(struct file *file, const __user char *buffer,
565 unsigned long flags; 565 unsigned long flags;
566 int retval; 566 int retval;
567 567
568 dbg(2," %s : enter, count = %Zd", __FUNCTION__, count); 568 dbg(2," %s : enter, count = %Zd", __func__, count);
569 569
570 dev = file->private_data; 570 dev = file->private_data;
571 571
@@ -582,7 +582,7 @@ static ssize_t adu_write(struct file *file, const __user char *buffer,
582 582
583 /* verify that we actually have some data to write */ 583 /* verify that we actually have some data to write */
584 if (count == 0) { 584 if (count == 0) {
585 dbg(1," %s : write request of 0 bytes", __FUNCTION__); 585 dbg(1," %s : write request of 0 bytes", __func__);
586 goto exit; 586 goto exit;
587 } 587 }
588 588
@@ -595,13 +595,13 @@ static ssize_t adu_write(struct file *file, const __user char *buffer,
595 595
596 mutex_unlock(&dev->mtx); 596 mutex_unlock(&dev->mtx);
597 if (signal_pending(current)) { 597 if (signal_pending(current)) {
598 dbg(1," %s : interrupted", __FUNCTION__); 598 dbg(1," %s : interrupted", __func__);
599 set_current_state(TASK_RUNNING); 599 set_current_state(TASK_RUNNING);
600 retval = -EINTR; 600 retval = -EINTR;
601 goto exit_onqueue; 601 goto exit_onqueue;
602 } 602 }
603 if (schedule_timeout(COMMAND_TIMEOUT) == 0) { 603 if (schedule_timeout(COMMAND_TIMEOUT) == 0) {
604 dbg(1, "%s - command timed out.", __FUNCTION__); 604 dbg(1, "%s - command timed out.", __func__);
605 retval = -ETIMEDOUT; 605 retval = -ETIMEDOUT;
606 goto exit_onqueue; 606 goto exit_onqueue;
607 } 607 }
@@ -612,18 +612,18 @@ static ssize_t adu_write(struct file *file, const __user char *buffer,
612 goto exit_nolock; 612 goto exit_nolock;
613 } 613 }
614 614
615 dbg(4," %s : in progress, count = %Zd", __FUNCTION__, count); 615 dbg(4," %s : in progress, count = %Zd", __func__, count);
616 } else { 616 } else {
617 spin_unlock_irqrestore(&dev->buflock, flags); 617 spin_unlock_irqrestore(&dev->buflock, flags);
618 set_current_state(TASK_RUNNING); 618 set_current_state(TASK_RUNNING);
619 remove_wait_queue(&dev->write_wait, &waita); 619 remove_wait_queue(&dev->write_wait, &waita);
620 dbg(4," %s : sending, count = %Zd", __FUNCTION__, count); 620 dbg(4," %s : sending, count = %Zd", __func__, count);
621 621
622 /* write the data into interrupt_out_buffer from userspace */ 622 /* write the data into interrupt_out_buffer from userspace */
623 buffer_size = le16_to_cpu(dev->interrupt_out_endpoint->wMaxPacketSize); 623 buffer_size = le16_to_cpu(dev->interrupt_out_endpoint->wMaxPacketSize);
624 bytes_to_write = count > buffer_size ? buffer_size : count; 624 bytes_to_write = count > buffer_size ? buffer_size : count;
625 dbg(4," %s : buffer_size = %Zd, count = %Zd, bytes_to_write = %Zd", 625 dbg(4," %s : buffer_size = %Zd, count = %Zd, bytes_to_write = %Zd",
626 __FUNCTION__, buffer_size, count, bytes_to_write); 626 __func__, buffer_size, count, bytes_to_write);
627 627
628 if (copy_from_user(dev->interrupt_out_buffer, buffer, bytes_to_write) != 0) { 628 if (copy_from_user(dev->interrupt_out_buffer, buffer, bytes_to_write) != 0) {
629 retval = -EFAULT; 629 retval = -EFAULT;
@@ -661,7 +661,7 @@ static ssize_t adu_write(struct file *file, const __user char *buffer,
661exit: 661exit:
662 mutex_unlock(&dev->mtx); 662 mutex_unlock(&dev->mtx);
663exit_nolock: 663exit_nolock:
664 dbg(2," %s : leave, return value %d", __FUNCTION__, retval); 664 dbg(2," %s : leave, return value %d", __func__, retval);
665 return retval; 665 return retval;
666 666
667exit_onqueue: 667exit_onqueue:
@@ -706,7 +706,7 @@ static int adu_probe(struct usb_interface *interface,
706 int out_end_size; 706 int out_end_size;
707 int i; 707 int i;
708 708
709 dbg(2," %s : enter", __FUNCTION__); 709 dbg(2," %s : enter", __func__);
710 710
711 if (udev == NULL) { 711 if (udev == NULL) {
712 dev_err(&interface->dev, "udev is NULL.\n"); 712 dev_err(&interface->dev, "udev is NULL.\n");
@@ -807,7 +807,7 @@ static int adu_probe(struct usb_interface *interface,
807 dev_err(&interface->dev, "Could not retrieve serial number\n"); 807 dev_err(&interface->dev, "Could not retrieve serial number\n");
808 goto error; 808 goto error;
809 } 809 }
810 dbg(2," %s : serial_number=%s", __FUNCTION__, dev->serial_number); 810 dbg(2," %s : serial_number=%s", __func__, dev->serial_number);
811 811
812 /* we can register the device now, as it is ready */ 812 /* we can register the device now, as it is ready */
813 usb_set_intfdata(interface, dev); 813 usb_set_intfdata(interface, dev);
@@ -828,7 +828,7 @@ static int adu_probe(struct usb_interface *interface,
828 udev->descriptor.idProduct, dev->serial_number, 828 udev->descriptor.idProduct, dev->serial_number,
829 (dev->minor - ADU_MINOR_BASE)); 829 (dev->minor - ADU_MINOR_BASE));
830exit: 830exit:
831 dbg(2," %s : leave, return value %p (dev)", __FUNCTION__, dev); 831 dbg(2," %s : leave, return value %p (dev)", __func__, dev);
832 832
833 return retval; 833 return retval;
834 834
@@ -847,7 +847,7 @@ static void adu_disconnect(struct usb_interface *interface)
847 struct adu_device *dev; 847 struct adu_device *dev;
848 int minor; 848 int minor;
849 849
850 dbg(2," %s : enter", __FUNCTION__); 850 dbg(2," %s : enter", __func__);
851 851
852 dev = usb_get_intfdata(interface); 852 dev = usb_get_intfdata(interface);
853 853
@@ -861,7 +861,7 @@ static void adu_disconnect(struct usb_interface *interface)
861 usb_set_intfdata(interface, NULL); 861 usb_set_intfdata(interface, NULL);
862 862
863 /* if the device is not opened, then we clean up right now */ 863 /* if the device is not opened, then we clean up right now */
864 dbg(2," %s : open count %d", __FUNCTION__, dev->open_count); 864 dbg(2," %s : open count %d", __func__, dev->open_count);
865 if (!dev->open_count) 865 if (!dev->open_count)
866 adu_delete(dev); 866 adu_delete(dev);
867 867
@@ -870,7 +870,7 @@ static void adu_disconnect(struct usb_interface *interface)
870 dev_info(&interface->dev, "ADU device adutux%d now disconnected\n", 870 dev_info(&interface->dev, "ADU device adutux%d now disconnected\n",
871 (minor - ADU_MINOR_BASE)); 871 (minor - ADU_MINOR_BASE));
872 872
873 dbg(2," %s : leave", __FUNCTION__); 873 dbg(2," %s : leave", __func__);
874} 874}
875 875
876/* usb specific object needed to register this driver with the usb subsystem */ 876/* usb specific object needed to register this driver with the usb subsystem */
@@ -885,7 +885,7 @@ static int __init adu_init(void)
885{ 885{
886 int result; 886 int result;
887 887
888 dbg(2," %s : enter", __FUNCTION__); 888 dbg(2," %s : enter", __func__);
889 889
890 /* register this driver with the USB subsystem */ 890 /* register this driver with the USB subsystem */
891 result = usb_register(&adu_driver); 891 result = usb_register(&adu_driver);
@@ -899,17 +899,17 @@ static int __init adu_init(void)
899 info("adutux is an experimental driver. Use at your own risk"); 899 info("adutux is an experimental driver. Use at your own risk");
900 900
901exit: 901exit:
902 dbg(2," %s : leave, return value %d", __FUNCTION__, result); 902 dbg(2," %s : leave, return value %d", __func__, result);
903 903
904 return result; 904 return result;
905} 905}
906 906
907static void __exit adu_exit(void) 907static void __exit adu_exit(void)
908{ 908{
909 dbg(2," %s : enter", __FUNCTION__); 909 dbg(2," %s : enter", __func__);
910 /* deregister this driver with the USB subsystem */ 910 /* deregister this driver with the USB subsystem */
911 usb_deregister(&adu_driver); 911 usb_deregister(&adu_driver);
912 dbg(2," %s : leave", __FUNCTION__); 912 dbg(2," %s : leave", __func__);
913} 913}
914 914
915module_init(adu_init); 915module_init(adu_init);
diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c
index a5e4c3545c7..a076c24a312 100644
--- a/drivers/usb/misc/appledisplay.c
+++ b/drivers/usb/misc/appledisplay.c
@@ -103,11 +103,11 @@ static void appledisplay_complete(struct urb *urb)
103 case -ESHUTDOWN: 103 case -ESHUTDOWN:
104 /* This urb is terminated, clean up */ 104 /* This urb is terminated, clean up */
105 dbg("%s - urb shuttingdown with status: %d", 105 dbg("%s - urb shuttingdown with status: %d",
106 __FUNCTION__, status); 106 __func__, status);
107 return; 107 return;
108 default: 108 default:
109 dbg("%s - nonzero urb status received: %d", 109 dbg("%s - nonzero urb status received: %d",
110 __FUNCTION__, status); 110 __func__, status);
111 goto exit; 111 goto exit;
112 } 112 }
113 113
@@ -131,7 +131,7 @@ exit:
131 retval = usb_submit_urb(pdata->urb, GFP_ATOMIC); 131 retval = usb_submit_urb(pdata->urb, GFP_ATOMIC);
132 if (retval) { 132 if (retval) {
133 err("%s - usb_submit_urb failed with result %d", 133 err("%s - usb_submit_urb failed with result %d",
134 __FUNCTION__, retval); 134 __func__, retval);
135 } 135 }
136} 136}
137 137
diff --git a/drivers/usb/misc/auerswald.c b/drivers/usb/misc/auerswald.c
index df7e1ecc810..09393869742 100644
--- a/drivers/usb/misc/auerswald.c
+++ b/drivers/usb/misc/auerswald.c
@@ -31,6 +31,7 @@
31#include <linux/init.h> 31#include <linux/init.h>
32#include <linux/wait.h> 32#include <linux/wait.h>
33#include <linux/usb.h> 33#include <linux/usb.h>
34#include <linux/mutex.h>
34 35
35/*-------------------------------------------------------------------*/ 36/*-------------------------------------------------------------------*/
36/* Debug support */ 37/* Debug support */
@@ -232,7 +233,7 @@ typedef struct auerscon
232/* USB device context */ 233/* USB device context */
233typedef struct 234typedef struct
234{ 235{
235 struct semaphore mutex; /* protection in user context */ 236 struct mutex mutex; /* protection in user context */
236 char name[20]; /* name of the /dev/usb entry */ 237 char name[20]; /* name of the /dev/usb entry */
237 unsigned int dtindex; /* index in the device table */ 238 unsigned int dtindex; /* index in the device table */
238 struct usb_device * usbdev; /* USB device handle */ 239 struct usb_device * usbdev; /* USB device handle */
@@ -253,12 +254,12 @@ typedef struct
253/* character device context */ 254/* character device context */
254typedef struct 255typedef struct
255{ 256{
256 struct semaphore mutex; /* protection in user context */ 257 struct mutex mutex; /* protection in user context */
257 pauerswald_t auerdev; /* context pointer of assigned device */ 258 pauerswald_t auerdev; /* context pointer of assigned device */
258 auerbufctl_t bufctl; /* controls the buffer chain */ 259 auerbufctl_t bufctl; /* controls the buffer chain */
259 auerscon_t scontext; /* service context */ 260 auerscon_t scontext; /* service context */
260 wait_queue_head_t readwait; /* for synchronous reading */ 261 wait_queue_head_t readwait; /* for synchronous reading */
261 struct semaphore readmutex; /* protection against multiple reads */ 262 struct mutex readmutex; /* protection against multiple reads */
262 pauerbuf_t readbuf; /* buffer held for partial reading */ 263 pauerbuf_t readbuf; /* buffer held for partial reading */
263 unsigned int readoffset; /* current offset in readbuf */ 264 unsigned int readoffset; /* current offset in readbuf */
264 unsigned int removed; /* is != 0 if device is removed */ 265 unsigned int removed; /* is != 0 if device is removed */
@@ -283,7 +284,7 @@ static void auerchain_complete (struct urb * urb)
283 int result; 284 int result;
284 285
285 /* get pointer to element and to chain */ 286 /* get pointer to element and to chain */
286 pauerchainelement_t acep = (pauerchainelement_t) urb->context; 287 pauerchainelement_t acep = urb->context;
287 pauerchain_t acp = acep->chain; 288 pauerchain_t acp = acep->chain;
288 289
289 /* restore original entries in urb */ 290 /* restore original entries in urb */
@@ -593,7 +594,7 @@ ac_fail:/* free the elements */
593/* completion handler for synchronous chained URBs */ 594/* completion handler for synchronous chained URBs */
594static void auerchain_blocking_completion (struct urb *urb) 595static void auerchain_blocking_completion (struct urb *urb)
595{ 596{
596 pauerchain_chs_t pchs = (pauerchain_chs_t)urb->context; 597 pauerchain_chs_t pchs = urb->context;
597 pchs->done = 1; 598 pchs->done = 1;
598 wmb(); 599 wmb();
599 wake_up (&pchs->wqh); 600 wake_up (&pchs->wqh);
@@ -846,7 +847,7 @@ static int auerswald_status_retry (int status)
846/* Completion of asynchronous write block */ 847/* Completion of asynchronous write block */
847static void auerchar_ctrlwrite_complete (struct urb * urb) 848static void auerchar_ctrlwrite_complete (struct urb * urb)
848{ 849{
849 pauerbuf_t bp = (pauerbuf_t) urb->context; 850 pauerbuf_t bp = urb->context;
850 pauerswald_t cp = ((pauerswald_t)((char *)(bp->list)-(unsigned long)(&((pauerswald_t)0)->bufctl))); 851 pauerswald_t cp = ((pauerswald_t)((char *)(bp->list)-(unsigned long)(&((pauerswald_t)0)->bufctl)));
851 dbg ("auerchar_ctrlwrite_complete called"); 852 dbg ("auerchar_ctrlwrite_complete called");
852 853
@@ -859,7 +860,7 @@ static void auerchar_ctrlwrite_complete (struct urb * urb)
859/* Completion handler for dummy retry packet */ 860/* Completion handler for dummy retry packet */
860static void auerswald_ctrlread_wretcomplete (struct urb * urb) 861static void auerswald_ctrlread_wretcomplete (struct urb * urb)
861{ 862{
862 pauerbuf_t bp = (pauerbuf_t) urb->context; 863 pauerbuf_t bp = urb->context;
863 pauerswald_t cp; 864 pauerswald_t cp;
864 int ret; 865 int ret;
865 int status = urb->status; 866 int status = urb->status;
@@ -903,7 +904,7 @@ static void auerswald_ctrlread_complete (struct urb * urb)
903 unsigned int serviceid; 904 unsigned int serviceid;
904 pauerswald_t cp; 905 pauerswald_t cp;
905 pauerscon_t scp; 906 pauerscon_t scp;
906 pauerbuf_t bp = (pauerbuf_t) urb->context; 907 pauerbuf_t bp = urb->context;
907 int status = urb->status; 908 int status = urb->status;
908 int ret; 909 int ret;
909 910
@@ -980,9 +981,9 @@ static void auerswald_int_complete (struct urb * urb)
980 int ret; 981 int ret;
981 int status = urb->status; 982 int status = urb->status;
982 pauerbuf_t bp = NULL; 983 pauerbuf_t bp = NULL;
983 pauerswald_t cp = (pauerswald_t) urb->context; 984 pauerswald_t cp = urb->context;
984 985
985 dbg ("%s called", __FUNCTION__); 986 dbg ("%s called", __func__);
986 987
987 switch (status) { 988 switch (status) {
988 case 0: 989 case 0:
@@ -992,10 +993,10 @@ static void auerswald_int_complete (struct urb * urb)
992 case -ENOENT: 993 case -ENOENT:
993 case -ESHUTDOWN: 994 case -ESHUTDOWN:
994 /* this urb is terminated, clean up */ 995 /* this urb is terminated, clean up */
995 dbg("%s - urb shutting down with status: %d", __FUNCTION__, status); 996 dbg("%s - urb shutting down with status: %d", __func__, status);
996 return; 997 return;
997 default: 998 default:
998 dbg("%s - nonzero urb status received: %d", __FUNCTION__, status); 999 dbg("%s - nonzero urb status received: %d", __func__, status);
999 goto exit; 1000 goto exit;
1000 } 1001 }
1001 1002
@@ -1080,7 +1081,7 @@ exit:
1080 ret = usb_submit_urb (urb, GFP_ATOMIC); 1081 ret = usb_submit_urb (urb, GFP_ATOMIC);
1081 if (ret) 1082 if (ret)
1082 err ("%s - usb_submit_urb failed with result %d", 1083 err ("%s - usb_submit_urb failed with result %d",
1083 __FUNCTION__, ret); 1084 __func__, ret);
1084} 1085}
1085 1086
1086/* int memory deallocation 1087/* int memory deallocation
@@ -1376,7 +1377,7 @@ static int auerchar_open (struct inode *inode, struct file *file)
1376 if (cp == NULL) { 1377 if (cp == NULL) {
1377 return -ENODEV; 1378 return -ENODEV;
1378 } 1379 }
1379 if (down_interruptible (&cp->mutex)) { 1380 if (mutex_lock_interruptible(&cp->mutex)) {
1380 return -ERESTARTSYS; 1381 return -ERESTARTSYS;
1381 } 1382 }
1382 1383
@@ -1389,8 +1390,8 @@ static int auerchar_open (struct inode *inode, struct file *file)
1389 } 1390 }
1390 1391
1391 /* Initialize device descriptor */ 1392 /* Initialize device descriptor */
1392 init_MUTEX( &ccp->mutex); 1393 mutex_init(&ccp->mutex);
1393 init_MUTEX( &ccp->readmutex); 1394 mutex_init(&ccp->readmutex);
1394 auerbuf_init (&ccp->bufctl); 1395 auerbuf_init (&ccp->bufctl);
1395 ccp->scontext.id = AUH_UNASSIGNED; 1396 ccp->scontext.id = AUH_UNASSIGNED;
1396 ccp->scontext.dispatch = auerchar_ctrlread_dispatch; 1397 ccp->scontext.dispatch = auerchar_ctrlread_dispatch;
@@ -1405,7 +1406,7 @@ static int auerchar_open (struct inode *inode, struct file *file)
1405 cp->open_count++; 1406 cp->open_count++;
1406 ccp->auerdev = cp; 1407 ccp->auerdev = cp;
1407 dbg("open %s as /dev/%s", cp->dev_desc, cp->name); 1408 dbg("open %s as /dev/%s", cp->dev_desc, cp->name);
1408 up (&cp->mutex); 1409 mutex_unlock(&cp->mutex);
1409 1410
1410 /* file IO stuff */ 1411 /* file IO stuff */
1411 file->f_pos = 0; 1412 file->f_pos = 0;
@@ -1413,7 +1414,7 @@ static int auerchar_open (struct inode *inode, struct file *file)
1413 return nonseekable_open(inode, file); 1414 return nonseekable_open(inode, file);
1414 1415
1415 /* Error exit */ 1416 /* Error exit */
1416ofail: up (&cp->mutex); 1417ofail: mutex_unlock(&cp->mutex);
1417 auerchar_delete (ccp); 1418 auerchar_delete (ccp);
1418 return ret; 1419 return ret;
1419} 1420}
@@ -1432,23 +1433,23 @@ static int auerchar_ioctl (struct inode *inode, struct file *file, unsigned int
1432 dbg ("ioctl"); 1433 dbg ("ioctl");
1433 1434
1434 /* get the mutexes */ 1435 /* get the mutexes */
1435 if (down_interruptible (&ccp->mutex)) { 1436 if (mutex_lock_interruptible(&ccp->mutex)) {
1436 return -ERESTARTSYS; 1437 return -ERESTARTSYS;
1437 } 1438 }
1438 cp = ccp->auerdev; 1439 cp = ccp->auerdev;
1439 if (!cp) { 1440 if (!cp) {
1440 up (&ccp->mutex); 1441 mutex_unlock(&ccp->mutex);
1441 return -ENODEV; 1442 return -ENODEV;
1442 } 1443 }
1443 if (down_interruptible (&cp->mutex)) { 1444 if (mutex_lock_interruptible(&cp->mutex)) {
1444 up(&ccp->mutex); 1445 mutex_unlock(&ccp->mutex);
1445 return -ERESTARTSYS; 1446 return -ERESTARTSYS;
1446 } 1447 }
1447 1448
1448 /* Check for removal */ 1449 /* Check for removal */
1449 if (!cp->usbdev) { 1450 if (!cp->usbdev) {
1450 up(&cp->mutex); 1451 mutex_unlock(&cp->mutex);
1451 up(&ccp->mutex); 1452 mutex_unlock(&ccp->mutex);
1452 return -ENODEV; 1453 return -ENODEV;
1453 } 1454 }
1454 1455
@@ -1550,8 +1551,8 @@ static int auerchar_ioctl (struct inode *inode, struct file *file, unsigned int
1550 break; 1551 break;
1551 } 1552 }
1552 /* release the mutexes */ 1553 /* release the mutexes */
1553 up(&cp->mutex); 1554 mutex_unlock(&cp->mutex);
1554 up(&ccp->mutex); 1555 mutex_unlock(&ccp->mutex);
1555 return ret; 1556 return ret;
1556} 1557}
1557 1558
@@ -1574,18 +1575,18 @@ static ssize_t auerchar_read (struct file *file, char __user *buf, size_t count,
1574 return 0; 1575 return 0;
1575 1576
1576 /* get the mutex */ 1577 /* get the mutex */
1577 if (down_interruptible (&ccp->mutex)) 1578 if (mutex_lock_interruptible(&ccp->mutex))
1578 return -ERESTARTSYS; 1579 return -ERESTARTSYS;
1579 1580
1580 /* Can we expect to read something? */ 1581 /* Can we expect to read something? */
1581 if (ccp->scontext.id == AUH_UNASSIGNED) { 1582 if (ccp->scontext.id == AUH_UNASSIGNED) {
1582 up (&ccp->mutex); 1583 mutex_unlock(&ccp->mutex);
1583 return -EIO; 1584 return -EIO;
1584 } 1585 }
1585 1586
1586 /* only one reader per device allowed */ 1587 /* only one reader per device allowed */
1587 if (down_interruptible (&ccp->readmutex)) { 1588 if (mutex_lock_interruptible(&ccp->readmutex)) {
1588 up (&ccp->mutex); 1589 mutex_unlock(&ccp->mutex);
1589 return -ERESTARTSYS; 1590 return -ERESTARTSYS;
1590 } 1591 }
1591 1592
@@ -1602,8 +1603,8 @@ doreadbuf:
1602 if (count) { 1603 if (count) {
1603 if (copy_to_user (buf, bp->bufp+ccp->readoffset, count)) { 1604 if (copy_to_user (buf, bp->bufp+ccp->readoffset, count)) {
1604 dbg ("auerswald_read: copy_to_user failed"); 1605 dbg ("auerswald_read: copy_to_user failed");
1605 up (&ccp->readmutex); 1606 mutex_unlock(&ccp->readmutex);
1606 up (&ccp->mutex); 1607 mutex_unlock(&ccp->mutex);
1607 return -EFAULT; 1608 return -EFAULT;
1608 } 1609 }
1609 } 1610 }
@@ -1617,8 +1618,8 @@ doreadbuf:
1617 } 1618 }
1618 /* return with number of bytes read */ 1619 /* return with number of bytes read */
1619 if (count) { 1620 if (count) {
1620 up (&ccp->readmutex); 1621 mutex_unlock(&ccp->readmutex);
1621 up (&ccp->mutex); 1622 mutex_unlock(&ccp->mutex);
1622 return count; 1623 return count;
1623 } 1624 }
1624 } 1625 }
@@ -1654,29 +1655,29 @@ doreadlist:
1654 dbg ("No read buffer available, returning -EAGAIN"); 1655 dbg ("No read buffer available, returning -EAGAIN");
1655 set_current_state (TASK_RUNNING); 1656 set_current_state (TASK_RUNNING);
1656 remove_wait_queue (&ccp->readwait, &wait); 1657 remove_wait_queue (&ccp->readwait, &wait);
1657 up (&ccp->readmutex); 1658 mutex_unlock(&ccp->readmutex);
1658 up (&ccp->mutex); 1659 mutex_unlock(&ccp->mutex);
1659 return -EAGAIN; /* nonblocking, no data available */ 1660 return -EAGAIN; /* nonblocking, no data available */
1660 } 1661 }
1661 1662
1662 /* yes, we should wait! */ 1663 /* yes, we should wait! */
1663 up (&ccp->mutex); /* allow other operations while we wait */ 1664 mutex_unlock(&ccp->mutex); /* allow other operations while we wait */
1664 schedule(); 1665 schedule();
1665 remove_wait_queue (&ccp->readwait, &wait); 1666 remove_wait_queue (&ccp->readwait, &wait);
1666 if (signal_pending (current)) { 1667 if (signal_pending (current)) {
1667 /* waked up by a signal */ 1668 /* waked up by a signal */
1668 up (&ccp->readmutex); 1669 mutex_unlock(&ccp->readmutex);
1669 return -ERESTARTSYS; 1670 return -ERESTARTSYS;
1670 } 1671 }
1671 1672
1672 /* Anything left to read? */ 1673 /* Anything left to read? */
1673 if ((ccp->scontext.id == AUH_UNASSIGNED) || ccp->removed) { 1674 if ((ccp->scontext.id == AUH_UNASSIGNED) || ccp->removed) {
1674 up (&ccp->readmutex); 1675 mutex_unlock(&ccp->readmutex);
1675 return -EIO; 1676 return -EIO;
1676 } 1677 }
1677 1678
1678 if (down_interruptible (&ccp->mutex)) { 1679 if (mutex_lock_interruptible(&ccp->mutex)) {
1679 up (&ccp->readmutex); 1680 mutex_unlock(&ccp->readmutex);
1680 return -ERESTARTSYS; 1681 return -ERESTARTSYS;
1681 } 1682 }
1682 1683
@@ -1707,27 +1708,27 @@ static ssize_t auerchar_write (struct file *file, const char __user *buf, size_t
1707 1708
1708write_again: 1709write_again:
1709 /* get the mutex */ 1710 /* get the mutex */
1710 if (down_interruptible (&ccp->mutex)) 1711 if (mutex_lock_interruptible(&ccp->mutex))
1711 return -ERESTARTSYS; 1712 return -ERESTARTSYS;
1712 1713
1713 /* Can we expect to write something? */ 1714 /* Can we expect to write something? */
1714 if (ccp->scontext.id == AUH_UNASSIGNED) { 1715 if (ccp->scontext.id == AUH_UNASSIGNED) {
1715 up (&ccp->mutex); 1716 mutex_unlock(&ccp->mutex);
1716 return -EIO; 1717 return -EIO;
1717 } 1718 }
1718 1719
1719 cp = ccp->auerdev; 1720 cp = ccp->auerdev;
1720 if (!cp) { 1721 if (!cp) {
1721 up (&ccp->mutex); 1722 mutex_unlock(&ccp->mutex);
1722 return -ERESTARTSYS; 1723 return -ERESTARTSYS;
1723 } 1724 }
1724 if (down_interruptible (&cp->mutex)) { 1725 if (mutex_lock_interruptible(&cp->mutex)) {
1725 up (&ccp->mutex); 1726 mutex_unlock(&ccp->mutex);
1726 return -ERESTARTSYS; 1727 return -ERESTARTSYS;
1727 } 1728 }
1728 if (!cp->usbdev) { 1729 if (!cp->usbdev) {
1729 up (&cp->mutex); 1730 mutex_unlock(&cp->mutex);
1730 up (&ccp->mutex); 1731 mutex_unlock(&ccp->mutex);
1731 return -EIO; 1732 return -EIO;
1732 } 1733 }
1733 /* Prepare for sleep */ 1734 /* Prepare for sleep */
@@ -1750,8 +1751,8 @@ write_again:
1750 1751
1751 /* are there any buffers left? */ 1752 /* are there any buffers left? */
1752 if (!bp) { 1753 if (!bp) {
1753 up (&cp->mutex); 1754 mutex_unlock(&cp->mutex);
1754 up (&ccp->mutex); 1755 mutex_unlock(&ccp->mutex);
1755 1756
1756 /* NONBLOCK: don't wait */ 1757 /* NONBLOCK: don't wait */
1757 if (file->f_flags & O_NONBLOCK) { 1758 if (file->f_flags & O_NONBLOCK) {
@@ -1783,8 +1784,8 @@ write_again:
1783 auerbuf_releasebuf (bp); 1784 auerbuf_releasebuf (bp);
1784 /* Wake up all processes waiting for a buffer */ 1785 /* Wake up all processes waiting for a buffer */
1785 wake_up (&cp->bufferwait); 1786 wake_up (&cp->bufferwait);
1786 up (&cp->mutex); 1787 mutex_unlock(&cp->mutex);
1787 up (&ccp->mutex); 1788 mutex_unlock(&ccp->mutex);
1788 return -EFAULT; 1789 return -EFAULT;
1789 } 1790 }
1790 1791
@@ -1803,18 +1804,18 @@ write_again:
1803 auerchar_ctrlwrite_complete, bp); 1804 auerchar_ctrlwrite_complete, bp);
1804 /* up we go */ 1805 /* up we go */
1805 ret = auerchain_submit_urb (&cp->controlchain, bp->urbp); 1806 ret = auerchain_submit_urb (&cp->controlchain, bp->urbp);
1806 up (&cp->mutex); 1807 mutex_unlock(&cp->mutex);
1807 if (ret) { 1808 if (ret) {
1808 dbg ("auerchar_write: nonzero result of auerchain_submit_urb %d", ret); 1809 dbg ("auerchar_write: nonzero result of auerchain_submit_urb %d", ret);
1809 auerbuf_releasebuf (bp); 1810 auerbuf_releasebuf (bp);
1810 /* Wake up all processes waiting for a buffer */ 1811 /* Wake up all processes waiting for a buffer */
1811 wake_up (&cp->bufferwait); 1812 wake_up (&cp->bufferwait);
1812 up (&ccp->mutex); 1813 mutex_unlock(&ccp->mutex);
1813 return -EIO; 1814 return -EIO;
1814 } 1815 }
1815 else { 1816 else {
1816 dbg ("auerchar_write: Write OK"); 1817 dbg ("auerchar_write: Write OK");
1817 up (&ccp->mutex); 1818 mutex_unlock(&ccp->mutex);
1818 return len; 1819 return len;
1819 } 1820 }
1820} 1821}
@@ -1827,24 +1828,24 @@ static int auerchar_release (struct inode *inode, struct file *file)
1827 pauerswald_t cp; 1828 pauerswald_t cp;
1828 dbg("release"); 1829 dbg("release");
1829 1830
1830 down(&ccp->mutex); 1831 mutex_lock(&ccp->mutex);
1831 cp = ccp->auerdev; 1832 cp = ccp->auerdev;
1832 if (cp) { 1833 if (cp) {
1833 down(&cp->mutex); 1834 mutex_lock(&cp->mutex);
1834 /* remove an open service */ 1835 /* remove an open service */
1835 auerswald_removeservice (cp, &ccp->scontext); 1836 auerswald_removeservice (cp, &ccp->scontext);
1836 /* detach from device */ 1837 /* detach from device */
1837 if ((--cp->open_count <= 0) && (cp->usbdev == NULL)) { 1838 if ((--cp->open_count <= 0) && (cp->usbdev == NULL)) {
1838 /* usb device waits for removal */ 1839 /* usb device waits for removal */
1839 up (&cp->mutex); 1840 mutex_unlock(&cp->mutex);
1840 auerswald_delete (cp); 1841 auerswald_delete (cp);
1841 } else { 1842 } else {
1842 up (&cp->mutex); 1843 mutex_unlock(&cp->mutex);
1843 } 1844 }
1844 cp = NULL; 1845 cp = NULL;
1845 ccp->auerdev = NULL; 1846 ccp->auerdev = NULL;
1846 } 1847 }
1847 up (&ccp->mutex); 1848 mutex_unlock(&ccp->mutex);
1848 auerchar_delete (ccp); 1849 auerchar_delete (ccp);
1849 1850
1850 return 0; 1851 return 0;
@@ -1917,7 +1918,7 @@ static int auerswald_probe (struct usb_interface *intf,
1917 } 1918 }
1918 1919
1919 /* Initialize device descriptor */ 1920 /* Initialize device descriptor */
1920 init_MUTEX (&cp->mutex); 1921 mutex_init(&cp->mutex);
1921 cp->usbdev = usbdev; 1922 cp->usbdev = usbdev;
1922 auerchain_init (&cp->controlchain); 1923 auerchain_init (&cp->controlchain);
1923 auerbuf_init (&cp->bufctl); 1924 auerbuf_init (&cp->bufctl);
@@ -2042,7 +2043,7 @@ static void auerswald_disconnect (struct usb_interface *intf)
2042 /* give back our USB minor number */ 2043 /* give back our USB minor number */
2043 usb_deregister_dev(intf, &auerswald_class); 2044 usb_deregister_dev(intf, &auerswald_class);
2044 2045
2045 down (&cp->mutex); 2046 mutex_lock(&cp->mutex);
2046 info ("device /dev/%s now disconnecting", cp->name); 2047 info ("device /dev/%s now disconnecting", cp->name);
2047 2048
2048 /* Stop the interrupt endpoint */ 2049 /* Stop the interrupt endpoint */
@@ -2057,16 +2058,18 @@ static void auerswald_disconnect (struct usb_interface *intf)
2057 2058
2058 if (cp->open_count == 0) { 2059 if (cp->open_count == 0) {
2059 /* nobody is using this device. So we can clean up now */ 2060 /* nobody is using this device. So we can clean up now */
2060 up (&cp->mutex);/* up() is possible here because no other task 2061 mutex_unlock(&cp->mutex);
2061 can open the device (see above). I don't want 2062 /* mutex_unlock() is possible here because no other task
2062 to kfree() a locked mutex. */ 2063 can open the device (see above). I don't want
2064 to kfree() a locked mutex. */
2065
2063 auerswald_delete (cp); 2066 auerswald_delete (cp);
2064 } else { 2067 } else {
2065 /* device is used. Remove the pointer to the 2068 /* device is used. Remove the pointer to the
2066 usb device (it's not valid any more). The last 2069 usb device (it's not valid any more). The last
2067 release() will do the clean up */ 2070 release() will do the clean up */
2068 cp->usbdev = NULL; 2071 cp->usbdev = NULL;
2069 up (&cp->mutex); 2072 mutex_unlock(&cp->mutex);
2070 /* Terminate waiting writers */ 2073 /* Terminate waiting writers */
2071 wake_up (&cp->bufferwait); 2074 wake_up (&cp->bufferwait);
2072 /* Inform all waiting readers */ 2075 /* Inform all waiting readers */
diff --git a/drivers/usb/misc/emi26.c b/drivers/usb/misc/emi26.c
index 4a09b87bdd2..4b9dc81b845 100644
--- a/drivers/usb/misc/emi26.c
+++ b/drivers/usb/misc/emi26.c
@@ -70,8 +70,8 @@ static int emi26_writememory (struct usb_device *dev, int address, unsigned char
70static int emi26_set_reset (struct usb_device *dev, unsigned char reset_bit) 70static int emi26_set_reset (struct usb_device *dev, unsigned char reset_bit)
71{ 71{
72 int response; 72 int response;
73 info("%s - %d", __FUNCTION__, reset_bit); 73 info("%s - %d", __func__, reset_bit);
74 /* printk(KERN_DEBUG "%s - %d", __FUNCTION__, reset_bit); */ 74 /* printk(KERN_DEBUG "%s - %d", __func__, reset_bit); */
75 response = emi26_writememory (dev, CPUCS_REG, &reset_bit, 1, 0xa0); 75 response = emi26_writememory (dev, CPUCS_REG, &reset_bit, 1, 0xa0);
76 if (response < 0) { 76 if (response < 0) {
77 err("emi26: set_reset (%d) failed", reset_bit); 77 err("emi26: set_reset (%d) failed", reset_bit);
@@ -91,7 +91,7 @@ static int emi26_load_firmware (struct usb_device *dev)
91 91
92 buf = kmalloc(FW_LOAD_SIZE, GFP_KERNEL); 92 buf = kmalloc(FW_LOAD_SIZE, GFP_KERNEL);
93 if (!buf) { 93 if (!buf) {
94 err( "%s - error loading firmware: error = %d", __FUNCTION__, -ENOMEM); 94 err( "%s - error loading firmware: error = %d", __func__, -ENOMEM);
95 err = -ENOMEM; 95 err = -ENOMEM;
96 goto wraperr; 96 goto wraperr;
97 } 97 }
@@ -99,7 +99,7 @@ static int emi26_load_firmware (struct usb_device *dev)
99 /* Assert reset (stop the CPU in the EMI) */ 99 /* Assert reset (stop the CPU in the EMI) */
100 err = emi26_set_reset(dev,1); 100 err = emi26_set_reset(dev,1);
101 if (err < 0) { 101 if (err < 0) {
102 err( "%s - error loading firmware: error = %d", __FUNCTION__, err); 102 err( "%s - error loading firmware: error = %d", __func__, err);
103 goto wraperr; 103 goto wraperr;
104 } 104 }
105 105
@@ -107,7 +107,7 @@ static int emi26_load_firmware (struct usb_device *dev)
107 for (i=0; g_Loader[i].type == 0; i++) { 107 for (i=0; g_Loader[i].type == 0; i++) {
108 err = emi26_writememory(dev, g_Loader[i].address, g_Loader[i].data, g_Loader[i].length, ANCHOR_LOAD_INTERNAL); 108 err = emi26_writememory(dev, g_Loader[i].address, g_Loader[i].data, g_Loader[i].length, ANCHOR_LOAD_INTERNAL);
109 if (err < 0) { 109 if (err < 0) {
110 err("%s - error loading firmware: error = %d", __FUNCTION__, err); 110 err("%s - error loading firmware: error = %d", __func__, err);
111 goto wraperr; 111 goto wraperr;
112 } 112 }
113 } 113 }
@@ -115,7 +115,7 @@ static int emi26_load_firmware (struct usb_device *dev)
115 /* De-assert reset (let the CPU run) */ 115 /* De-assert reset (let the CPU run) */
116 err = emi26_set_reset(dev,0); 116 err = emi26_set_reset(dev,0);
117 if (err < 0) { 117 if (err < 0) {
118 err("%s - error loading firmware: error = %d", __FUNCTION__, err); 118 err("%s - error loading firmware: error = %d", __func__, err);
119 goto wraperr; 119 goto wraperr;
120 } 120 }
121 msleep(250); /* let device settle */ 121 msleep(250); /* let device settle */
@@ -135,7 +135,7 @@ static int emi26_load_firmware (struct usb_device *dev)
135 } 135 }
136 err = emi26_writememory(dev, addr, buf, i, ANCHOR_LOAD_FPGA); 136 err = emi26_writememory(dev, addr, buf, i, ANCHOR_LOAD_FPGA);
137 if (err < 0) { 137 if (err < 0) {
138 err("%s - error loading firmware: error = %d", __FUNCTION__, err); 138 err("%s - error loading firmware: error = %d", __func__, err);
139 goto wraperr; 139 goto wraperr;
140 } 140 }
141 } while (i > 0); 141 } while (i > 0);
@@ -143,7 +143,7 @@ static int emi26_load_firmware (struct usb_device *dev)
143 /* Assert reset (stop the CPU in the EMI) */ 143 /* Assert reset (stop the CPU in the EMI) */
144 err = emi26_set_reset(dev,1); 144 err = emi26_set_reset(dev,1);
145 if (err < 0) { 145 if (err < 0) {
146 err("%s - error loading firmware: error = %d", __FUNCTION__, err); 146 err("%s - error loading firmware: error = %d", __func__, err);
147 goto wraperr; 147 goto wraperr;
148 } 148 }
149 149
@@ -151,7 +151,7 @@ static int emi26_load_firmware (struct usb_device *dev)
151 for (i=0; g_Loader[i].type == 0; i++) { 151 for (i=0; g_Loader[i].type == 0; i++) {
152 err = emi26_writememory(dev, g_Loader[i].address, g_Loader[i].data, g_Loader[i].length, ANCHOR_LOAD_INTERNAL); 152 err = emi26_writememory(dev, g_Loader[i].address, g_Loader[i].data, g_Loader[i].length, ANCHOR_LOAD_INTERNAL);
153 if (err < 0) { 153 if (err < 0) {
154 err("%s - error loading firmware: error = %d", __FUNCTION__, err); 154 err("%s - error loading firmware: error = %d", __func__, err);
155 goto wraperr; 155 goto wraperr;
156 } 156 }
157 } 157 }
@@ -160,7 +160,7 @@ static int emi26_load_firmware (struct usb_device *dev)
160 /* De-assert reset (let the CPU run) */ 160 /* De-assert reset (let the CPU run) */
161 err = emi26_set_reset(dev,0); 161 err = emi26_set_reset(dev,0);
162 if (err < 0) { 162 if (err < 0) {
163 err("%s - error loading firmware: error = %d", __FUNCTION__, err); 163 err("%s - error loading firmware: error = %d", __func__, err);
164 goto wraperr; 164 goto wraperr;
165 } 165 }
166 166
@@ -169,7 +169,7 @@ static int emi26_load_firmware (struct usb_device *dev)
169 if (!INTERNAL_RAM(g_Firmware[i].address)) { 169 if (!INTERNAL_RAM(g_Firmware[i].address)) {
170 err = emi26_writememory(dev, g_Firmware[i].address, g_Firmware[i].data, g_Firmware[i].length, ANCHOR_LOAD_EXTERNAL); 170 err = emi26_writememory(dev, g_Firmware[i].address, g_Firmware[i].data, g_Firmware[i].length, ANCHOR_LOAD_EXTERNAL);
171 if (err < 0) { 171 if (err < 0) {
172 err("%s - error loading firmware: error = %d", __FUNCTION__, err); 172 err("%s - error loading firmware: error = %d", __func__, err);
173 goto wraperr; 173 goto wraperr;
174 } 174 }
175 } 175 }
@@ -178,7 +178,7 @@ static int emi26_load_firmware (struct usb_device *dev)
178 /* Assert reset (stop the CPU in the EMI) */ 178 /* Assert reset (stop the CPU in the EMI) */
179 err = emi26_set_reset(dev,1); 179 err = emi26_set_reset(dev,1);
180 if (err < 0) { 180 if (err < 0) {
181 err("%s - error loading firmware: error = %d", __FUNCTION__, err); 181 err("%s - error loading firmware: error = %d", __func__, err);
182 goto wraperr; 182 goto wraperr;
183 } 183 }
184 184
@@ -186,7 +186,7 @@ static int emi26_load_firmware (struct usb_device *dev)
186 if (INTERNAL_RAM(g_Firmware[i].address)) { 186 if (INTERNAL_RAM(g_Firmware[i].address)) {
187 err = emi26_writememory(dev, g_Firmware[i].address, g_Firmware[i].data, g_Firmware[i].length, ANCHOR_LOAD_INTERNAL); 187 err = emi26_writememory(dev, g_Firmware[i].address, g_Firmware[i].data, g_Firmware[i].length, ANCHOR_LOAD_INTERNAL);
188 if (err < 0) { 188 if (err < 0) {
189 err("%s - error loading firmware: error = %d", __FUNCTION__, err); 189 err("%s - error loading firmware: error = %d", __func__, err);
190 goto wraperr; 190 goto wraperr;
191 } 191 }
192 } 192 }
@@ -195,7 +195,7 @@ static int emi26_load_firmware (struct usb_device *dev)
195 /* De-assert reset (let the CPU run) */ 195 /* De-assert reset (let the CPU run) */
196 err = emi26_set_reset(dev,0); 196 err = emi26_set_reset(dev,0);
197 if (err < 0) { 197 if (err < 0) {
198 err("%s - error loading firmware: error = %d", __FUNCTION__, err); 198 err("%s - error loading firmware: error = %d", __func__, err);
199 goto wraperr; 199 goto wraperr;
200 } 200 }
201 msleep(250); /* let device settle */ 201 msleep(250); /* let device settle */
@@ -221,7 +221,7 @@ static int emi26_probe(struct usb_interface *intf, const struct usb_device_id *i
221{ 221{
222 struct usb_device *dev = interface_to_usbdev(intf); 222 struct usb_device *dev = interface_to_usbdev(intf);
223 223
224 info("%s start", __FUNCTION__); 224 info("%s start", __func__);
225 225
226 emi26_load_firmware(dev); 226 emi26_load_firmware(dev);
227 227
diff --git a/drivers/usb/misc/emi62.c b/drivers/usb/misc/emi62.c
index d1362415922..1a2b79ac5e1 100644
--- a/drivers/usb/misc/emi62.c
+++ b/drivers/usb/misc/emi62.c
@@ -78,7 +78,7 @@ static int emi62_writememory (struct usb_device *dev, int address, unsigned char
78static int emi62_set_reset (struct usb_device *dev, unsigned char reset_bit) 78static int emi62_set_reset (struct usb_device *dev, unsigned char reset_bit)
79{ 79{
80 int response; 80 int response;
81 info("%s - %d", __FUNCTION__, reset_bit); 81 info("%s - %d", __func__, reset_bit);
82 82
83 response = emi62_writememory (dev, CPUCS_REG, &reset_bit, 1, 0xa0); 83 response = emi62_writememory (dev, CPUCS_REG, &reset_bit, 1, 0xa0);
84 if (response < 0) { 84 if (response < 0) {
@@ -100,7 +100,7 @@ static int emi62_load_firmware (struct usb_device *dev)
100 dev_dbg(&dev->dev, "load_firmware\n"); 100 dev_dbg(&dev->dev, "load_firmware\n");
101 buf = kmalloc(FW_LOAD_SIZE, GFP_KERNEL); 101 buf = kmalloc(FW_LOAD_SIZE, GFP_KERNEL);
102 if (!buf) { 102 if (!buf) {
103 err( "%s - error loading firmware: error = %d", __FUNCTION__, -ENOMEM); 103 err( "%s - error loading firmware: error = %d", __func__, -ENOMEM);
104 err = -ENOMEM; 104 err = -ENOMEM;
105 goto wraperr; 105 goto wraperr;
106 } 106 }
@@ -108,7 +108,7 @@ static int emi62_load_firmware (struct usb_device *dev)
108 /* Assert reset (stop the CPU in the EMI) */ 108 /* Assert reset (stop the CPU in the EMI) */
109 err = emi62_set_reset(dev,1); 109 err = emi62_set_reset(dev,1);
110 if (err < 0) { 110 if (err < 0) {
111 err("%s - error loading firmware: error = %d", __FUNCTION__, err); 111 err("%s - error loading firmware: error = %d", __func__, err);
112 goto wraperr; 112 goto wraperr;
113 } 113 }
114 114
@@ -116,7 +116,7 @@ static int emi62_load_firmware (struct usb_device *dev)
116 for (i=0; g_emi62_loader[i].type == 0; i++) { 116 for (i=0; g_emi62_loader[i].type == 0; i++) {
117 err = emi62_writememory(dev, g_emi62_loader[i].address, g_emi62_loader[i].data, g_emi62_loader[i].length, ANCHOR_LOAD_INTERNAL); 117 err = emi62_writememory(dev, g_emi62_loader[i].address, g_emi62_loader[i].data, g_emi62_loader[i].length, ANCHOR_LOAD_INTERNAL);
118 if (err < 0) { 118 if (err < 0) {
119 err("%s - error loading firmware: error = %d", __FUNCTION__, err); 119 err("%s - error loading firmware: error = %d", __func__, err);
120 goto wraperr; 120 goto wraperr;
121 } 121 }
122 } 122 }
@@ -124,7 +124,7 @@ static int emi62_load_firmware (struct usb_device *dev)
124 /* De-assert reset (let the CPU run) */ 124 /* De-assert reset (let the CPU run) */
125 err = emi62_set_reset(dev,0); 125 err = emi62_set_reset(dev,0);
126 if (err < 0) { 126 if (err < 0) {
127 err("%s - error loading firmware: error = %d", __FUNCTION__, err); 127 err("%s - error loading firmware: error = %d", __func__, err);
128 goto wraperr; 128 goto wraperr;
129 } 129 }
130 msleep(250); /* let device settle */ 130 msleep(250); /* let device settle */
@@ -144,7 +144,7 @@ static int emi62_load_firmware (struct usb_device *dev)
144 } 144 }
145 err = emi62_writememory(dev, addr, buf, i, ANCHOR_LOAD_FPGA); 145 err = emi62_writememory(dev, addr, buf, i, ANCHOR_LOAD_FPGA);
146 if (err < 0) { 146 if (err < 0) {
147 err("%s - error loading firmware: error = %d", __FUNCTION__, err); 147 err("%s - error loading firmware: error = %d", __func__, err);
148 goto wraperr; 148 goto wraperr;
149 } 149 }
150 } while (i > 0); 150 } while (i > 0);
@@ -152,7 +152,7 @@ static int emi62_load_firmware (struct usb_device *dev)
152 /* Assert reset (stop the CPU in the EMI) */ 152 /* Assert reset (stop the CPU in the EMI) */
153 err = emi62_set_reset(dev,1); 153 err = emi62_set_reset(dev,1);
154 if (err < 0) { 154 if (err < 0) {
155 err("%s - error loading firmware: error = %d", __FUNCTION__, err); 155 err("%s - error loading firmware: error = %d", __func__, err);
156 goto wraperr; 156 goto wraperr;
157 } 157 }
158 158
@@ -160,7 +160,7 @@ static int emi62_load_firmware (struct usb_device *dev)
160 for (i=0; g_emi62_loader[i].type == 0; i++) { 160 for (i=0; g_emi62_loader[i].type == 0; i++) {
161 err = emi62_writememory(dev, g_emi62_loader[i].address, g_emi62_loader[i].data, g_emi62_loader[i].length, ANCHOR_LOAD_INTERNAL); 161 err = emi62_writememory(dev, g_emi62_loader[i].address, g_emi62_loader[i].data, g_emi62_loader[i].length, ANCHOR_LOAD_INTERNAL);
162 if (err < 0) { 162 if (err < 0) {
163 err("%s - error loading firmware: error = %d", __FUNCTION__, err); 163 err("%s - error loading firmware: error = %d", __func__, err);
164 goto wraperr; 164 goto wraperr;
165 } 165 }
166 } 166 }
@@ -168,7 +168,7 @@ static int emi62_load_firmware (struct usb_device *dev)
168 /* De-assert reset (let the CPU run) */ 168 /* De-assert reset (let the CPU run) */
169 err = emi62_set_reset(dev,0); 169 err = emi62_set_reset(dev,0);
170 if (err < 0) { 170 if (err < 0) {
171 err("%s - error loading firmware: error = %d", __FUNCTION__, err); 171 err("%s - error loading firmware: error = %d", __func__, err);
172 goto wraperr; 172 goto wraperr;
173 } 173 }
174 msleep(250); /* let device settle */ 174 msleep(250); /* let device settle */
@@ -181,7 +181,7 @@ static int emi62_load_firmware (struct usb_device *dev)
181 if (!INTERNAL_RAM(g_HexSpdifFw62[i].address)) { 181 if (!INTERNAL_RAM(g_HexSpdifFw62[i].address)) {
182 err = emi62_writememory(dev, g_HexSpdifFw62[i].address, g_HexSpdifFw62[i].data, g_HexSpdifFw62[i].length, ANCHOR_LOAD_EXTERNAL); 182 err = emi62_writememory(dev, g_HexSpdifFw62[i].address, g_HexSpdifFw62[i].data, g_HexSpdifFw62[i].length, ANCHOR_LOAD_EXTERNAL);
183 if (err < 0) { 183 if (err < 0) {
184 err("%s - error loading firmware: error = %d", __FUNCTION__, err); 184 err("%s - error loading firmware: error = %d", __func__, err);
185 goto wraperr; 185 goto wraperr;
186 } 186 }
187 } 187 }
@@ -191,7 +191,7 @@ static int emi62_load_firmware (struct usb_device *dev)
191 if (!INTERNAL_RAM(g_HexMidiFw62[i].address)) { 191 if (!INTERNAL_RAM(g_HexMidiFw62[i].address)) {
192 err = emi62_writememory(dev, g_HexMidiFw62[i].address, g_HexMidiFw62[i].data, g_HexMidiFw62[i].length, ANCHOR_LOAD_EXTERNAL); 192 err = emi62_writememory(dev, g_HexMidiFw62[i].address, g_HexMidiFw62[i].data, g_HexMidiFw62[i].length, ANCHOR_LOAD_EXTERNAL);
193 if (err < 0) { 193 if (err < 0) {
194 err("%s - error loading firmware: error = %d\n", __FUNCTION__, err); 194 err("%s - error loading firmware: error = %d\n", __func__, err);
195 goto wraperr; 195 goto wraperr;
196 return err; 196 return err;
197 } 197 }
@@ -201,7 +201,7 @@ static int emi62_load_firmware (struct usb_device *dev)
201 /* Assert reset (stop the CPU in the EMI) */ 201 /* Assert reset (stop the CPU in the EMI) */
202 err = emi62_set_reset(dev,1); 202 err = emi62_set_reset(dev,1);
203 if (err < 0) { 203 if (err < 0) {
204 err("%s - error loading firmware: error = %d", __FUNCTION__, err); 204 err("%s - error loading firmware: error = %d", __func__, err);
205 goto wraperr; 205 goto wraperr;
206 } 206 }
207 207
@@ -211,7 +211,7 @@ static int emi62_load_firmware (struct usb_device *dev)
211 if (INTERNAL_RAM(g_HexSpdifFw62[i].address)) { 211 if (INTERNAL_RAM(g_HexSpdifFw62[i].address)) {
212 err = emi62_writememory(dev, g_HexSpdifFw62[i].address, g_HexSpdifFw62[i].data, g_HexSpdifFw62[i].length, ANCHOR_LOAD_INTERNAL); 212 err = emi62_writememory(dev, g_HexSpdifFw62[i].address, g_HexSpdifFw62[i].data, g_HexSpdifFw62[i].length, ANCHOR_LOAD_INTERNAL);
213 if (err < 0) { 213 if (err < 0) {
214 err("%s - error loading firmware: error = %d", __FUNCTION__, err); 214 err("%s - error loading firmware: error = %d", __func__, err);
215 goto wraperr; 215 goto wraperr;
216 } 216 }
217 } 217 }
@@ -221,7 +221,7 @@ static int emi62_load_firmware (struct usb_device *dev)
221 if (INTERNAL_RAM(g_HexMidiFw62[i].address)) { 221 if (INTERNAL_RAM(g_HexMidiFw62[i].address)) {
222 err = emi62_writememory(dev, g_HexMidiFw62[i].address, g_HexMidiFw62[i].data, g_HexMidiFw62[i].length, ANCHOR_LOAD_INTERNAL); 222 err = emi62_writememory(dev, g_HexMidiFw62[i].address, g_HexMidiFw62[i].data, g_HexMidiFw62[i].length, ANCHOR_LOAD_INTERNAL);
223 if (err < 0) { 223 if (err < 0) {
224 err("%s - error loading firmware: error = %d\n", __FUNCTION__, err); 224 err("%s - error loading firmware: error = %d\n", __func__, err);
225 goto wraperr; 225 goto wraperr;
226 } 226 }
227 } 227 }
@@ -231,7 +231,7 @@ static int emi62_load_firmware (struct usb_device *dev)
231 /* De-assert reset (let the CPU run) */ 231 /* De-assert reset (let the CPU run) */
232 err = emi62_set_reset(dev,0); 232 err = emi62_set_reset(dev,0);
233 if (err < 0) { 233 if (err < 0) {
234 err("%s - error loading firmware: error = %d", __FUNCTION__, err); 234 err("%s - error loading firmware: error = %d", __func__, err);
235 goto wraperr; 235 goto wraperr;
236 } 236 }
237 msleep(250); /* let device settle */ 237 msleep(250); /* let device settle */
@@ -260,7 +260,7 @@ static int emi62_probe(struct usb_interface *intf, const struct usb_device_id *i
260 struct usb_device *dev = interface_to_usbdev(intf); 260 struct usb_device *dev = interface_to_usbdev(intf);
261 dev_dbg(&intf->dev, "emi62_probe\n"); 261 dev_dbg(&intf->dev, "emi62_probe\n");
262 262
263 info("%s start", __FUNCTION__); 263 info("%s start", __func__);
264 264
265 emi62_load_firmware(dev); 265 emi62_load_firmware(dev);
266 266
diff --git a/drivers/usb/misc/ftdi-elan.c b/drivers/usb/misc/ftdi-elan.c
index 148b7fe639b..ec88b3bfee4 100644
--- a/drivers/usb/misc/ftdi-elan.c
+++ b/drivers/usb/misc/ftdi-elan.c
@@ -746,7 +746,7 @@ static ssize_t ftdi_elan_read(struct file *file, char __user *buffer,
746 746
747static void ftdi_elan_write_bulk_callback(struct urb *urb) 747static void ftdi_elan_write_bulk_callback(struct urb *urb)
748{ 748{
749 struct usb_ftdi *ftdi = (struct usb_ftdi *)urb->context; 749 struct usb_ftdi *ftdi = urb->context;
750 int status = urb->status; 750 int status = urb->status;
751 751
752 if (status && !(status == -ENOENT || status == -ECONNRESET || 752 if (status && !(status == -ENOENT || status == -ECONNRESET ||
diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c
index 801070502cc..1cb54a28347 100644
--- a/drivers/usb/misc/iowarrior.c
+++ b/drivers/usb/misc/iowarrior.c
@@ -154,7 +154,7 @@ MODULE_DEVICE_TABLE(usb, iowarrior_ids);
154 */ 154 */
155static void iowarrior_callback(struct urb *urb) 155static void iowarrior_callback(struct urb *urb)
156{ 156{
157 struct iowarrior *dev = (struct iowarrior *)urb->context; 157 struct iowarrior *dev = urb->context;
158 int intr_idx; 158 int intr_idx;
159 int read_idx; 159 int read_idx;
160 int aux_idx; 160 int aux_idx;
@@ -218,7 +218,7 @@ exit:
218 retval = usb_submit_urb(urb, GFP_ATOMIC); 218 retval = usb_submit_urb(urb, GFP_ATOMIC);
219 if (retval) 219 if (retval)
220 dev_err(&dev->interface->dev, "%s - usb_submit_urb failed with result %d\n", 220 dev_err(&dev->interface->dev, "%s - usb_submit_urb failed with result %d\n",
221 __FUNCTION__, retval); 221 __func__, retval);
222 222
223} 223}
224 224
@@ -230,7 +230,7 @@ static void iowarrior_write_callback(struct urb *urb)
230 struct iowarrior *dev; 230 struct iowarrior *dev;
231 int status = urb->status; 231 int status = urb->status;
232 232
233 dev = (struct iowarrior *)urb->context; 233 dev = urb->context;
234 /* sync/async unlink faults aren't errors */ 234 /* sync/async unlink faults aren't errors */
235 if (status && 235 if (status &&
236 !(status == -ENOENT || 236 !(status == -ENOENT ||
@@ -453,7 +453,7 @@ static ssize_t iowarrior_write(struct file *file,
453 default: 453 default:
454 /* what do we have here ? An unsupported Product-ID ? */ 454 /* what do we have here ? An unsupported Product-ID ? */
455 dev_err(&dev->interface->dev, "%s - not supported for product=0x%x\n", 455 dev_err(&dev->interface->dev, "%s - not supported for product=0x%x\n",
456 __FUNCTION__, dev->product_id); 456 __func__, dev->product_id);
457 retval = -EFAULT; 457 retval = -EFAULT;
458 goto exit; 458 goto exit;
459 break; 459 break;
@@ -604,7 +604,7 @@ static int iowarrior_open(struct inode *inode, struct file *file)
604 604
605 interface = usb_find_interface(&iowarrior_driver, subminor); 605 interface = usb_find_interface(&iowarrior_driver, subminor);
606 if (!interface) { 606 if (!interface) {
607 err("%s - error, can't find device for minor %d", __FUNCTION__, 607 err("%s - error, can't find device for minor %d", __func__,
608 subminor); 608 subminor);
609 return -ENODEV; 609 return -ENODEV;
610 } 610 }
diff --git a/drivers/usb/misc/ldusb.c b/drivers/usb/misc/ldusb.c
index c730d20eec6..11580e81e2c 100644
--- a/drivers/usb/misc/ldusb.c
+++ b/drivers/usb/misc/ldusb.c
@@ -231,7 +231,7 @@ static void ld_usb_interrupt_in_callback(struct urb *urb)
231 goto exit; 231 goto exit;
232 } else { 232 } else {
233 dbg_info(&dev->intf->dev, "%s: nonzero status received: %d\n", 233 dbg_info(&dev->intf->dev, "%s: nonzero status received: %d\n",
234 __FUNCTION__, status); 234 __func__, status);
235 spin_lock(&dev->rbsl); 235 spin_lock(&dev->rbsl);
236 goto resubmit; /* maybe we can recover */ 236 goto resubmit; /* maybe we can recover */
237 } 237 }
@@ -247,7 +247,7 @@ static void ld_usb_interrupt_in_callback(struct urb *urb)
247 memcpy(actual_buffer+1, dev->interrupt_in_buffer, urb->actual_length); 247 memcpy(actual_buffer+1, dev->interrupt_in_buffer, urb->actual_length);
248 dev->ring_head = next_ring_head; 248 dev->ring_head = next_ring_head;
249 dbg_info(&dev->intf->dev, "%s: received %d bytes\n", 249 dbg_info(&dev->intf->dev, "%s: received %d bytes\n",
250 __FUNCTION__, urb->actual_length); 250 __func__, urb->actual_length);
251 } else { 251 } else {
252 dev_warn(&dev->intf->dev, 252 dev_warn(&dev->intf->dev,
253 "Ring buffer overflow, %d bytes dropped\n", 253 "Ring buffer overflow, %d bytes dropped\n",
@@ -286,7 +286,7 @@ static void ld_usb_interrupt_out_callback(struct urb *urb)
286 status == -ESHUTDOWN)) 286 status == -ESHUTDOWN))
287 dbg_info(&dev->intf->dev, 287 dbg_info(&dev->intf->dev,
288 "%s - nonzero write interrupt status received: %d\n", 288 "%s - nonzero write interrupt status received: %d\n",
289 __FUNCTION__, status); 289 __func__, status);
290 290
291 dev->interrupt_out_busy = 0; 291 dev->interrupt_out_busy = 0;
292 wake_up_interruptible(&dev->write_wait); 292 wake_up_interruptible(&dev->write_wait);
@@ -309,7 +309,7 @@ static int ld_usb_open(struct inode *inode, struct file *file)
309 309
310 if (!interface) { 310 if (!interface) {
311 err("%s - error, can't find device for minor %d\n", 311 err("%s - error, can't find device for minor %d\n",
312 __FUNCTION__, subminor); 312 __func__, subminor);
313 return -ENODEV; 313 return -ENODEV;
314 } 314 }
315 315
@@ -556,7 +556,7 @@ static ssize_t ld_usb_write(struct file *file, const char __user *buffer,
556 bytes_to_write = min(count, write_buffer_size*dev->interrupt_out_endpoint_size); 556 bytes_to_write = min(count, write_buffer_size*dev->interrupt_out_endpoint_size);
557 if (bytes_to_write < count) 557 if (bytes_to_write < count)
558 dev_warn(&dev->intf->dev, "Write buffer overflow, %zd bytes dropped\n",count-bytes_to_write); 558 dev_warn(&dev->intf->dev, "Write buffer overflow, %zd bytes dropped\n",count-bytes_to_write);
559 dbg_info(&dev->intf->dev, "%s: count = %zd, bytes_to_write = %zd\n", __FUNCTION__, count, bytes_to_write); 559 dbg_info(&dev->intf->dev, "%s: count = %zd, bytes_to_write = %zd\n", __func__, count, bytes_to_write);
560 560
561 if (copy_from_user(dev->interrupt_out_buffer, buffer, bytes_to_write)) { 561 if (copy_from_user(dev->interrupt_out_buffer, buffer, bytes_to_write)) {
562 retval = -EFAULT; 562 retval = -EFAULT;
diff --git a/drivers/usb/misc/legousbtower.c b/drivers/usb/misc/legousbtower.c
index 6664043f464..9370326a594 100644
--- a/drivers/usb/misc/legousbtower.c
+++ b/drivers/usb/misc/legousbtower.c
@@ -31,7 +31,7 @@
31 * - imported into lejos project 31 * - imported into lejos project
32 * - changed wake_up to wake_up_interruptible 32 * - changed wake_up to wake_up_interruptible
33 * - changed to use lego0 rather than tower0 33 * - changed to use lego0 rather than tower0
34 * - changed dbg() to use __func__ rather than deprecated __FUNCTION__ 34 * - changed dbg() to use __func__ rather than deprecated __func__
35 * 2003-01-12 - 0.53 david (david@csse.uwa.edu.au) 35 * 2003-01-12 - 0.53 david (david@csse.uwa.edu.au)
36 * - changed read and write to write everything or 36 * - changed read and write to write everything or
37 * timeout (from a patch by Chris Riesen and Brett Thaeler driver) 37 * timeout (from a patch by Chris Riesen and Brett Thaeler driver)
@@ -49,7 +49,7 @@
49 * - added poll 49 * - added poll
50 * - forbid seeking 50 * - forbid seeking
51 * - added nonblocking I/O 51 * - added nonblocking I/O
52 * - changed back __func__ to __FUNCTION__ 52 * - changed back __func__ to __func__
53 * - read and log tower firmware version 53 * - read and log tower firmware version
54 * - reset tower on probe, avoids failure of first write 54 * - reset tower on probe, avoids failure of first write
55 * 2004-03-09 - 0.7 Juergen Stuber <starblue@users.sourceforge.net> 55 * 2004-03-09 - 0.7 Juergen Stuber <starblue@users.sourceforge.net>
@@ -309,7 +309,7 @@ static inline void lego_usb_tower_debug_data (int level, const char *function, i
309 */ 309 */
310static inline void tower_delete (struct lego_usb_tower *dev) 310static inline void tower_delete (struct lego_usb_tower *dev)
311{ 311{
312 dbg(2, "%s: enter", __FUNCTION__); 312 dbg(2, "%s: enter", __func__);
313 313
314 tower_abort_transfers (dev); 314 tower_abort_transfers (dev);
315 315
@@ -321,7 +321,7 @@ static inline void tower_delete (struct lego_usb_tower *dev)
321 kfree (dev->interrupt_out_buffer); 321 kfree (dev->interrupt_out_buffer);
322 kfree (dev); 322 kfree (dev);
323 323
324 dbg(2, "%s: leave", __FUNCTION__); 324 dbg(2, "%s: leave", __func__);
325} 325}
326 326
327 327
@@ -337,7 +337,7 @@ static int tower_open (struct inode *inode, struct file *file)
337 struct tower_reset_reply reset_reply; 337 struct tower_reset_reply reset_reply;
338 int result; 338 int result;
339 339
340 dbg(2, "%s: enter", __FUNCTION__); 340 dbg(2, "%s: enter", __func__);
341 341
342 nonseekable_open(inode, file); 342 nonseekable_open(inode, file);
343 subminor = iminor(inode); 343 subminor = iminor(inode);
@@ -346,7 +346,7 @@ static int tower_open (struct inode *inode, struct file *file)
346 346
347 if (!interface) { 347 if (!interface) {
348 err ("%s - error, can't find device for minor %d", 348 err ("%s - error, can't find device for minor %d",
349 __FUNCTION__, subminor); 349 __func__, subminor);
350 retval = -ENODEV; 350 retval = -ENODEV;
351 goto exit; 351 goto exit;
352 } 352 }
@@ -424,7 +424,7 @@ unlock_exit:
424 mutex_unlock(&dev->lock); 424 mutex_unlock(&dev->lock);
425 425
426exit: 426exit:
427 dbg(2, "%s: leave, return value %d ", __FUNCTION__, retval); 427 dbg(2, "%s: leave, return value %d ", __func__, retval);
428 428
429 return retval; 429 return retval;
430} 430}
@@ -437,12 +437,12 @@ static int tower_release (struct inode *inode, struct file *file)
437 struct lego_usb_tower *dev; 437 struct lego_usb_tower *dev;
438 int retval = 0; 438 int retval = 0;
439 439
440 dbg(2, "%s: enter", __FUNCTION__); 440 dbg(2, "%s: enter", __func__);
441 441
442 dev = (struct lego_usb_tower *)file->private_data; 442 dev = (struct lego_usb_tower *)file->private_data;
443 443
444 if (dev == NULL) { 444 if (dev == NULL) {
445 dbg(1, "%s: object is NULL", __FUNCTION__); 445 dbg(1, "%s: object is NULL", __func__);
446 retval = -ENODEV; 446 retval = -ENODEV;
447 goto exit_nolock; 447 goto exit_nolock;
448 } 448 }
@@ -454,7 +454,7 @@ static int tower_release (struct inode *inode, struct file *file)
454 } 454 }
455 455
456 if (dev->open_count != 1) { 456 if (dev->open_count != 1) {
457 dbg(1, "%s: device not opened exactly once", __FUNCTION__); 457 dbg(1, "%s: device not opened exactly once", __func__);
458 retval = -ENODEV; 458 retval = -ENODEV;
459 goto unlock_exit; 459 goto unlock_exit;
460 } 460 }
@@ -480,7 +480,7 @@ unlock_exit:
480exit: 480exit:
481 mutex_unlock(&open_disc_mutex); 481 mutex_unlock(&open_disc_mutex);
482exit_nolock: 482exit_nolock:
483 dbg(2, "%s: leave, return value %d", __FUNCTION__, retval); 483 dbg(2, "%s: leave, return value %d", __func__, retval);
484 return retval; 484 return retval;
485} 485}
486 486
@@ -491,10 +491,10 @@ exit_nolock:
491 */ 491 */
492static void tower_abort_transfers (struct lego_usb_tower *dev) 492static void tower_abort_transfers (struct lego_usb_tower *dev)
493{ 493{
494 dbg(2, "%s: enter", __FUNCTION__); 494 dbg(2, "%s: enter", __func__);
495 495
496 if (dev == NULL) { 496 if (dev == NULL) {
497 dbg(1, "%s: dev is null", __FUNCTION__); 497 dbg(1, "%s: dev is null", __func__);
498 goto exit; 498 goto exit;
499 } 499 }
500 500
@@ -509,7 +509,7 @@ static void tower_abort_transfers (struct lego_usb_tower *dev)
509 usb_kill_urb(dev->interrupt_out_urb); 509 usb_kill_urb(dev->interrupt_out_urb);
510 510
511exit: 511exit:
512 dbg(2, "%s: leave", __FUNCTION__); 512 dbg(2, "%s: leave", __func__);
513} 513}
514 514
515 515
@@ -542,7 +542,7 @@ static unsigned int tower_poll (struct file *file, poll_table *wait)
542 struct lego_usb_tower *dev; 542 struct lego_usb_tower *dev;
543 unsigned int mask = 0; 543 unsigned int mask = 0;
544 544
545 dbg(2, "%s: enter", __FUNCTION__); 545 dbg(2, "%s: enter", __func__);
546 546
547 dev = file->private_data; 547 dev = file->private_data;
548 548
@@ -557,7 +557,7 @@ static unsigned int tower_poll (struct file *file, poll_table *wait)
557 mask |= POLLOUT | POLLWRNORM; 557 mask |= POLLOUT | POLLWRNORM;
558 } 558 }
559 559
560 dbg(2, "%s: leave, mask = %d", __FUNCTION__, mask); 560 dbg(2, "%s: leave, mask = %d", __func__, mask);
561 561
562 return mask; 562 return mask;
563} 563}
@@ -583,7 +583,7 @@ static ssize_t tower_read (struct file *file, char __user *buffer, size_t count,
583 int retval = 0; 583 int retval = 0;
584 unsigned long timeout = 0; 584 unsigned long timeout = 0;
585 585
586 dbg(2, "%s: enter, count = %Zd", __FUNCTION__, count); 586 dbg(2, "%s: enter, count = %Zd", __func__, count);
587 587
588 dev = (struct lego_usb_tower *)file->private_data; 588 dev = (struct lego_usb_tower *)file->private_data;
589 589
@@ -602,7 +602,7 @@ static ssize_t tower_read (struct file *file, char __user *buffer, size_t count,
602 602
603 /* verify that we actually have some data to read */ 603 /* verify that we actually have some data to read */
604 if (count == 0) { 604 if (count == 0) {
605 dbg(1, "%s: read request of 0 bytes", __FUNCTION__); 605 dbg(1, "%s: read request of 0 bytes", __func__);
606 goto unlock_exit; 606 goto unlock_exit;
607 } 607 }
608 608
@@ -658,7 +658,7 @@ unlock_exit:
658 mutex_unlock(&dev->lock); 658 mutex_unlock(&dev->lock);
659 659
660exit: 660exit:
661 dbg(2, "%s: leave, return value %d", __FUNCTION__, retval); 661 dbg(2, "%s: leave, return value %d", __func__, retval);
662 return retval; 662 return retval;
663} 663}
664 664
@@ -672,7 +672,7 @@ static ssize_t tower_write (struct file *file, const char __user *buffer, size_t
672 size_t bytes_to_write; 672 size_t bytes_to_write;
673 int retval = 0; 673 int retval = 0;
674 674
675 dbg(2, "%s: enter, count = %Zd", __FUNCTION__, count); 675 dbg(2, "%s: enter, count = %Zd", __func__, count);
676 676
677 dev = (struct lego_usb_tower *)file->private_data; 677 dev = (struct lego_usb_tower *)file->private_data;
678 678
@@ -691,7 +691,7 @@ static ssize_t tower_write (struct file *file, const char __user *buffer, size_t
691 691
692 /* verify that we actually have some data to write */ 692 /* verify that we actually have some data to write */
693 if (count == 0) { 693 if (count == 0) {
694 dbg(1, "%s: write request of 0 bytes", __FUNCTION__); 694 dbg(1, "%s: write request of 0 bytes", __func__);
695 goto unlock_exit; 695 goto unlock_exit;
696 } 696 }
697 697
@@ -709,7 +709,7 @@ static ssize_t tower_write (struct file *file, const char __user *buffer, size_t
709 709
710 /* write the data into interrupt_out_buffer from userspace */ 710 /* write the data into interrupt_out_buffer from userspace */
711 bytes_to_write = min_t(int, count, write_buffer_size); 711 bytes_to_write = min_t(int, count, write_buffer_size);
712 dbg(4, "%s: count = %Zd, bytes_to_write = %Zd", __FUNCTION__, count, bytes_to_write); 712 dbg(4, "%s: count = %Zd, bytes_to_write = %Zd", __func__, count, bytes_to_write);
713 713
714 if (copy_from_user (dev->interrupt_out_buffer, buffer, bytes_to_write)) { 714 if (copy_from_user (dev->interrupt_out_buffer, buffer, bytes_to_write)) {
715 retval = -EFAULT; 715 retval = -EFAULT;
@@ -742,7 +742,7 @@ unlock_exit:
742 mutex_unlock(&dev->lock); 742 mutex_unlock(&dev->lock);
743 743
744exit: 744exit:
745 dbg(2, "%s: leave, return value %d", __FUNCTION__, retval); 745 dbg(2, "%s: leave, return value %d", __func__, retval);
746 746
747 return retval; 747 return retval;
748} 748}
@@ -753,13 +753,13 @@ exit:
753 */ 753 */
754static void tower_interrupt_in_callback (struct urb *urb) 754static void tower_interrupt_in_callback (struct urb *urb)
755{ 755{
756 struct lego_usb_tower *dev = (struct lego_usb_tower *)urb->context; 756 struct lego_usb_tower *dev = urb->context;
757 int status = urb->status; 757 int status = urb->status;
758 int retval; 758 int retval;
759 759
760 dbg(4, "%s: enter, status %d", __FUNCTION__, status); 760 dbg(4, "%s: enter, status %d", __func__, status);
761 761
762 lego_usb_tower_debug_data(5, __FUNCTION__, urb->actual_length, urb->transfer_buffer); 762 lego_usb_tower_debug_data(5, __func__, urb->actual_length, urb->transfer_buffer);
763 763
764 if (status) { 764 if (status) {
765 if (status == -ENOENT || 765 if (status == -ENOENT ||
@@ -767,7 +767,7 @@ static void tower_interrupt_in_callback (struct urb *urb)
767 status == -ESHUTDOWN) { 767 status == -ESHUTDOWN) {
768 goto exit; 768 goto exit;
769 } else { 769 } else {
770 dbg(1, "%s: nonzero status received: %d", __FUNCTION__, status); 770 dbg(1, "%s: nonzero status received: %d", __func__, status);
771 goto resubmit; /* maybe we can recover */ 771 goto resubmit; /* maybe we can recover */
772 } 772 }
773 } 773 }
@@ -780,9 +780,9 @@ static void tower_interrupt_in_callback (struct urb *urb)
780 urb->actual_length); 780 urb->actual_length);
781 dev->read_buffer_length += urb->actual_length; 781 dev->read_buffer_length += urb->actual_length;
782 dev->read_last_arrival = jiffies; 782 dev->read_last_arrival = jiffies;
783 dbg(3, "%s: received %d bytes", __FUNCTION__, urb->actual_length); 783 dbg(3, "%s: received %d bytes", __func__, urb->actual_length);
784 } else { 784 } else {
785 printk(KERN_WARNING "%s: read_buffer overflow, %d bytes dropped", __FUNCTION__, urb->actual_length); 785 printk(KERN_WARNING "%s: read_buffer overflow, %d bytes dropped", __func__, urb->actual_length);
786 } 786 }
787 spin_unlock (&dev->read_buffer_lock); 787 spin_unlock (&dev->read_buffer_lock);
788 } 788 }
@@ -792,7 +792,7 @@ resubmit:
792 if (dev->interrupt_in_running && dev->udev) { 792 if (dev->interrupt_in_running && dev->udev) {
793 retval = usb_submit_urb (dev->interrupt_in_urb, GFP_ATOMIC); 793 retval = usb_submit_urb (dev->interrupt_in_urb, GFP_ATOMIC);
794 if (retval) { 794 if (retval) {
795 err("%s: usb_submit_urb failed (%d)", __FUNCTION__, retval); 795 err("%s: usb_submit_urb failed (%d)", __func__, retval);
796 } 796 }
797 } 797 }
798 798
@@ -800,8 +800,8 @@ exit:
800 dev->interrupt_in_done = 1; 800 dev->interrupt_in_done = 1;
801 wake_up_interruptible (&dev->read_wait); 801 wake_up_interruptible (&dev->read_wait);
802 802
803 lego_usb_tower_debug_data(5, __FUNCTION__, urb->actual_length, urb->transfer_buffer); 803 lego_usb_tower_debug_data(5, __func__, urb->actual_length, urb->transfer_buffer);
804 dbg(4, "%s: leave, status %d", __FUNCTION__, status); 804 dbg(4, "%s: leave, status %d", __func__, status);
805} 805}
806 806
807 807
@@ -810,25 +810,25 @@ exit:
810 */ 810 */
811static void tower_interrupt_out_callback (struct urb *urb) 811static void tower_interrupt_out_callback (struct urb *urb)
812{ 812{
813 struct lego_usb_tower *dev = (struct lego_usb_tower *)urb->context; 813 struct lego_usb_tower *dev = urb->context;
814 int status = urb->status; 814 int status = urb->status;
815 815
816 dbg(4, "%s: enter, status %d", __FUNCTION__, status); 816 dbg(4, "%s: enter, status %d", __func__, status);
817 lego_usb_tower_debug_data(5, __FUNCTION__, urb->actual_length, urb->transfer_buffer); 817 lego_usb_tower_debug_data(5, __func__, urb->actual_length, urb->transfer_buffer);
818 818
819 /* sync/async unlink faults aren't errors */ 819 /* sync/async unlink faults aren't errors */
820 if (status && !(status == -ENOENT || 820 if (status && !(status == -ENOENT ||
821 status == -ECONNRESET || 821 status == -ECONNRESET ||
822 status == -ESHUTDOWN)) { 822 status == -ESHUTDOWN)) {
823 dbg(1, "%s - nonzero write bulk status received: %d", 823 dbg(1, "%s - nonzero write bulk status received: %d",
824 __FUNCTION__, status); 824 __func__, status);
825 } 825 }
826 826
827 dev->interrupt_out_busy = 0; 827 dev->interrupt_out_busy = 0;
828 wake_up_interruptible(&dev->write_wait); 828 wake_up_interruptible(&dev->write_wait);
829 829
830 lego_usb_tower_debug_data(5, __FUNCTION__, urb->actual_length, urb->transfer_buffer); 830 lego_usb_tower_debug_data(5, __func__, urb->actual_length, urb->transfer_buffer);
831 dbg(4, "%s: leave, status %d", __FUNCTION__, status); 831 dbg(4, "%s: leave, status %d", __func__, status);
832} 832}
833 833
834 834
@@ -849,7 +849,7 @@ static int tower_probe (struct usb_interface *interface, const struct usb_device
849 int retval = -ENOMEM; 849 int retval = -ENOMEM;
850 int result; 850 int result;
851 851
852 dbg(2, "%s: enter", __FUNCTION__); 852 dbg(2, "%s: enter", __func__);
853 853
854 if (udev == NULL) { 854 if (udev == NULL) {
855 info ("udev is NULL."); 855 info ("udev is NULL.");
@@ -978,7 +978,7 @@ static int tower_probe (struct usb_interface *interface, const struct usb_device
978 978
979 979
980exit: 980exit:
981 dbg(2, "%s: leave, return value 0x%.8lx (dev)", __FUNCTION__, (long) dev); 981 dbg(2, "%s: leave, return value 0x%.8lx (dev)", __func__, (long) dev);
982 982
983 return retval; 983 return retval;
984 984
@@ -998,7 +998,7 @@ static void tower_disconnect (struct usb_interface *interface)
998 struct lego_usb_tower *dev; 998 struct lego_usb_tower *dev;
999 int minor; 999 int minor;
1000 1000
1001 dbg(2, "%s: enter", __FUNCTION__); 1001 dbg(2, "%s: enter", __func__);
1002 1002
1003 dev = usb_get_intfdata (interface); 1003 dev = usb_get_intfdata (interface);
1004 mutex_lock(&open_disc_mutex); 1004 mutex_lock(&open_disc_mutex);
@@ -1023,7 +1023,7 @@ static void tower_disconnect (struct usb_interface *interface)
1023 1023
1024 info("LEGO USB Tower #%d now disconnected", (minor - LEGO_USB_TOWER_MINOR_BASE)); 1024 info("LEGO USB Tower #%d now disconnected", (minor - LEGO_USB_TOWER_MINOR_BASE));
1025 1025
1026 dbg(2, "%s: leave", __FUNCTION__); 1026 dbg(2, "%s: leave", __func__);
1027} 1027}
1028 1028
1029 1029
@@ -1036,7 +1036,7 @@ static int __init lego_usb_tower_init(void)
1036 int result; 1036 int result;
1037 int retval = 0; 1037 int retval = 0;
1038 1038
1039 dbg(2, "%s: enter", __FUNCTION__); 1039 dbg(2, "%s: enter", __func__);
1040 1040
1041 /* register this driver with the USB subsystem */ 1041 /* register this driver with the USB subsystem */
1042 result = usb_register(&tower_driver); 1042 result = usb_register(&tower_driver);
@@ -1049,7 +1049,7 @@ static int __init lego_usb_tower_init(void)
1049 info(DRIVER_DESC " " DRIVER_VERSION); 1049 info(DRIVER_DESC " " DRIVER_VERSION);
1050 1050
1051exit: 1051exit:
1052 dbg(2, "%s: leave, return value %d", __FUNCTION__, retval); 1052 dbg(2, "%s: leave, return value %d", __func__, retval);
1053 1053
1054 return retval; 1054 return retval;
1055} 1055}
@@ -1060,12 +1060,12 @@ exit:
1060 */ 1060 */
1061static void __exit lego_usb_tower_exit(void) 1061static void __exit lego_usb_tower_exit(void)
1062{ 1062{
1063 dbg(2, "%s: enter", __FUNCTION__); 1063 dbg(2, "%s: enter", __func__);
1064 1064
1065 /* deregister this driver with the USB subsystem */ 1065 /* deregister this driver with the USB subsystem */
1066 usb_deregister (&tower_driver); 1066 usb_deregister (&tower_driver);
1067 1067
1068 dbg(2, "%s: leave", __FUNCTION__); 1068 dbg(2, "%s: leave", __func__);
1069} 1069}
1070 1070
1071module_init (lego_usb_tower_init); 1071module_init (lego_usb_tower_init);
diff --git a/drivers/usb/misc/phidgetkit.c b/drivers/usb/misc/phidgetkit.c
index aa9bcceabe7..24230c638b8 100644
--- a/drivers/usb/misc/phidgetkit.c
+++ b/drivers/usb/misc/phidgetkit.c
@@ -113,7 +113,7 @@ static int set_outputs(struct interfacekit *kit)
113 113
114 buffer = kzalloc(4, GFP_KERNEL); 114 buffer = kzalloc(4, GFP_KERNEL);
115 if (!buffer) { 115 if (!buffer) {
116 dev_err(&kit->udev->dev, "%s - out of memory\n", __FUNCTION__); 116 dev_err(&kit->udev->dev, "%s - out of memory\n", __func__);
117 return -ENOMEM; 117 return -ENOMEM;
118 } 118 }
119 buffer[0] = (u8)kit->outputs; 119 buffer[0] = (u8)kit->outputs;
@@ -146,7 +146,7 @@ static int change_string(struct interfacekit *kit, const char *display, unsigned
146 buffer = kmalloc(8, GFP_KERNEL); 146 buffer = kmalloc(8, GFP_KERNEL);
147 form_buffer = kmalloc(30, GFP_KERNEL); 147 form_buffer = kmalloc(30, GFP_KERNEL);
148 if ((!buffer) || (!form_buffer)) { 148 if ((!buffer) || (!form_buffer)) {
149 dev_err(&kit->udev->dev, "%s - out of memory\n", __FUNCTION__); 149 dev_err(&kit->udev->dev, "%s - out of memory\n", __func__);
150 goto exit; 150 goto exit;
151 } 151 }
152 152
@@ -216,7 +216,7 @@ static ssize_t set_backlight(struct device *dev, struct device_attribute *attr,
216 216
217 buffer = kzalloc(8, GFP_KERNEL); 217 buffer = kzalloc(8, GFP_KERNEL);
218 if (!buffer) { 218 if (!buffer) {
219 dev_err(&kit->udev->dev, "%s - out of memory\n", __FUNCTION__); 219 dev_err(&kit->udev->dev, "%s - out of memory\n", __func__);
220 goto exit; 220 goto exit;
221 } 221 }
222 222
diff --git a/drivers/usb/misc/phidgetmotorcontrol.c b/drivers/usb/misc/phidgetmotorcontrol.c
index 2ad09b1f484..f0113c17cc5 100644
--- a/drivers/usb/misc/phidgetmotorcontrol.c
+++ b/drivers/usb/misc/phidgetmotorcontrol.c
@@ -61,7 +61,7 @@ static int set_motor(struct motorcontrol *mc, int motor)
61 61
62 buffer = kzalloc(8, GFP_KERNEL); 62 buffer = kzalloc(8, GFP_KERNEL);
63 if (!buffer) { 63 if (!buffer) {
64 dev_err(&mc->intf->dev, "%s - out of memory\n", __FUNCTION__); 64 dev_err(&mc->intf->dev, "%s - out of memory\n", __func__);
65 return -ENOMEM; 65 return -ENOMEM;
66 } 66 }
67 67
diff --git a/drivers/usb/misc/phidgetservo.c b/drivers/usb/misc/phidgetservo.c
index 0d9de2f7393..7d590c09434 100644
--- a/drivers/usb/misc/phidgetservo.c
+++ b/drivers/usb/misc/phidgetservo.c
@@ -89,7 +89,7 @@ change_position_v30(struct phidget_servo *servo, int servo_no, int degrees,
89 buffer = kmalloc(6, GFP_KERNEL); 89 buffer = kmalloc(6, GFP_KERNEL);
90 if (!buffer) { 90 if (!buffer) {
91 dev_err(&servo->udev->dev, "%s - out of memory\n", 91 dev_err(&servo->udev->dev, "%s - out of memory\n",
92 __FUNCTION__); 92 __func__);
93 return -ENOMEM; 93 return -ENOMEM;
94 } 94 }
95 95
@@ -162,7 +162,7 @@ change_position_v20(struct phidget_servo *servo, int servo_no, int degrees,
162 buffer = kmalloc(2, GFP_KERNEL); 162 buffer = kmalloc(2, GFP_KERNEL);
163 if (!buffer) { 163 if (!buffer) {
164 dev_err(&servo->udev->dev, "%s - out of memory\n", 164 dev_err(&servo->udev->dev, "%s - out of memory\n",
165 __FUNCTION__); 165 __func__);
166 return -ENOMEM; 166 return -ENOMEM;
167 } 167 }
168 168
@@ -259,7 +259,7 @@ servo_probe(struct usb_interface *interface, const struct usb_device_id *id)
259 259
260 dev = kzalloc(sizeof (struct phidget_servo), GFP_KERNEL); 260 dev = kzalloc(sizeof (struct phidget_servo), GFP_KERNEL);
261 if (dev == NULL) { 261 if (dev == NULL) {
262 dev_err(&interface->dev, "%s - out of memory\n", __FUNCTION__); 262 dev_err(&interface->dev, "%s - out of memory\n", __func__);
263 rc = -ENOMEM; 263 rc = -ENOMEM;
264 goto out; 264 goto out;
265 } 265 }
diff --git a/drivers/usb/misc/usblcd.c b/drivers/usb/misc/usblcd.c
index 20777d01db6..7f7021ee418 100644
--- a/drivers/usb/misc/usblcd.c
+++ b/drivers/usb/misc/usblcd.c
@@ -78,7 +78,7 @@ static int lcd_open(struct inode *inode, struct file *file)
78 interface = usb_find_interface(&lcd_driver, subminor); 78 interface = usb_find_interface(&lcd_driver, subminor);
79 if (!interface) { 79 if (!interface) {
80 err ("USBLCD: %s - error, can't find device for minor %d", 80 err ("USBLCD: %s - error, can't find device for minor %d",
81 __FUNCTION__, subminor); 81 __func__, subminor);
82 return -ENODEV; 82 return -ENODEV;
83 } 83 }
84 84
@@ -185,7 +185,7 @@ static void lcd_write_bulk_callback(struct urb *urb)
185 struct usb_lcd *dev; 185 struct usb_lcd *dev;
186 int status = urb->status; 186 int status = urb->status;
187 187
188 dev = (struct usb_lcd *)urb->context; 188 dev = urb->context;
189 189
190 /* sync/async unlink faults aren't errors */ 190 /* sync/async unlink faults aren't errors */
191 if (status && 191 if (status &&
@@ -193,7 +193,7 @@ static void lcd_write_bulk_callback(struct urb *urb)
193 status == -ECONNRESET || 193 status == -ECONNRESET ||
194 status == -ESHUTDOWN)) { 194 status == -ESHUTDOWN)) {
195 dbg("USBLCD: %s - nonzero write bulk status received: %d", 195 dbg("USBLCD: %s - nonzero write bulk status received: %d",
196 __FUNCTION__, status); 196 __func__, status);
197 } 197 }
198 198
199 /* free up our allocated buffer */ 199 /* free up our allocated buffer */
@@ -248,7 +248,7 @@ static ssize_t lcd_write(struct file *file, const char __user * user_buffer, siz
248 /* send the data out the bulk port */ 248 /* send the data out the bulk port */
249 retval = usb_submit_urb(urb, GFP_KERNEL); 249 retval = usb_submit_urb(urb, GFP_KERNEL);
250 if (retval) { 250 if (retval) {
251 err("USBLCD: %s - failed submitting write urb, error %d", __FUNCTION__, retval); 251 err("USBLCD: %s - failed submitting write urb, error %d", __func__, retval);
252 goto error_unanchor; 252 goto error_unanchor;
253 } 253 }
254 254
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
index b6b5b2affad..a51983854ca 100644
--- a/drivers/usb/misc/usbtest.c
+++ b/drivers/usb/misc/usbtest.c
@@ -201,7 +201,7 @@ found:
201 201
202static void simple_callback (struct urb *urb) 202static void simple_callback (struct urb *urb)
203{ 203{
204 complete ((struct completion *) urb->context); 204 complete(urb->context);
205} 205}
206 206
207static struct urb *simple_alloc_urb ( 207static struct urb *simple_alloc_urb (
@@ -1046,7 +1046,7 @@ static void unlink1_callback (struct urb *urb)
1046 status = usb_submit_urb (urb, GFP_ATOMIC); 1046 status = usb_submit_urb (urb, GFP_ATOMIC);
1047 if (status) { 1047 if (status) {
1048 urb->status = status; 1048 urb->status = status;
1049 complete ((struct completion *) urb->context); 1049 complete(urb->context);
1050 } 1050 }
1051} 1051}
1052 1052
@@ -1136,7 +1136,7 @@ static int verify_not_halted (int ep, struct urb *urb)
1136 dbg ("ep %02x bogus status: %04x != 0", ep, status); 1136 dbg ("ep %02x bogus status: %04x != 0", ep, status);
1137 return -EINVAL; 1137 return -EINVAL;
1138 } 1138 }
1139 retval = simple_io (urb, 1, 0, 0, __FUNCTION__); 1139 retval = simple_io (urb, 1, 0, 0, __func__);
1140 if (retval != 0) 1140 if (retval != 0)
1141 return -EINVAL; 1141 return -EINVAL;
1142 return 0; 1142 return 0;
@@ -1158,7 +1158,7 @@ static int verify_halted (int ep, struct urb *urb)
1158 dbg ("ep %02x bogus status: %04x != 1", ep, status); 1158 dbg ("ep %02x bogus status: %04x != 1", ep, status);
1159 return -EINVAL; 1159 return -EINVAL;
1160 } 1160 }
1161 retval = simple_io (urb, 1, 0, -EPIPE, __FUNCTION__); 1161 retval = simple_io (urb, 1, 0, -EPIPE, __func__);
1162 if (retval != -EPIPE) 1162 if (retval != -EPIPE)
1163 return -EINVAL; 1163 return -EINVAL;
1164 retval = simple_io (urb, 1, 0, -EPIPE, "verify_still_halted"); 1164 retval = simple_io (urb, 1, 0, -EPIPE, "verify_still_halted");
@@ -1404,7 +1404,7 @@ static struct urb *iso_alloc_urb (
1404 return NULL; 1404 return NULL;
1405 maxp = 0x7ff & le16_to_cpu(desc->wMaxPacketSize); 1405 maxp = 0x7ff & le16_to_cpu(desc->wMaxPacketSize);
1406 maxp *= 1 + (0x3 & (le16_to_cpu(desc->wMaxPacketSize) >> 11)); 1406 maxp *= 1 + (0x3 & (le16_to_cpu(desc->wMaxPacketSize) >> 11));
1407 packets = (bytes + maxp - 1) / maxp; 1407 packets = DIV_ROUND_UP(bytes, maxp);
1408 1408
1409 urb = usb_alloc_urb (packets, GFP_KERNEL); 1409 urb = usb_alloc_urb (packets, GFP_KERNEL);
1410 if (!urb) 1410 if (!urb)
@@ -1564,7 +1564,8 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
1564 if (mutex_lock_interruptible(&dev->lock)) 1564 if (mutex_lock_interruptible(&dev->lock))
1565 return -ERESTARTSYS; 1565 return -ERESTARTSYS;
1566 1566
1567 if (intf->dev.power.power_state.event != PM_EVENT_ON) { 1567 /* FIXME: What if a system sleep starts while a test is running? */
1568 if (!intf->is_active) {
1568 mutex_unlock(&dev->lock); 1569 mutex_unlock(&dev->lock);
1569 return -EHOSTUNREACH; 1570 return -EHOSTUNREACH;
1570 } 1571 }
diff --git a/drivers/usb/mon/Makefile b/drivers/usb/mon/Makefile
index 90c59535778..0f76ed5e161 100644
--- a/drivers/usb/mon/Makefile
+++ b/drivers/usb/mon/Makefile
@@ -1,5 +1,5 @@
1# 1#
2# Makefile for USB Core files and filesystem 2# Makefile for USB monitor
3# 3#
4 4
5usbmon-objs := mon_main.o mon_stat.o mon_text.o mon_bin.o mon_dma.o 5usbmon-objs := mon_main.o mon_stat.o mon_text.o mon_bin.o mon_dma.o
diff --git a/drivers/usb/mon/mon_bin.c b/drivers/usb/mon/mon_bin.c
index 1774ba5c4c3..49145534e06 100644
--- a/drivers/usb/mon/mon_bin.c
+++ b/drivers/usb/mon/mon_bin.c
@@ -1026,8 +1026,6 @@ mon_bin_poll(struct file *file, struct poll_table_struct *wait)
1026 return mask; 1026 return mask;
1027} 1027}
1028 1028
1029#if 0
1030
1031/* 1029/*
1032 * open and close: just keep track of how many times the device is 1030 * open and close: just keep track of how many times the device is
1033 * mapped, to use the proper memory allocation function. 1031 * mapped, to use the proper memory allocation function.
@@ -1063,13 +1061,13 @@ static int mon_bin_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
1063 return 0; 1061 return 0;
1064} 1062}
1065 1063
1066struct vm_operations_struct mon_bin_vm_ops = { 1064static struct vm_operations_struct mon_bin_vm_ops = {
1067 .open = mon_bin_vma_open, 1065 .open = mon_bin_vma_open,
1068 .close = mon_bin_vma_close, 1066 .close = mon_bin_vma_close,
1069 .fault = mon_bin_vma_fault, 1067 .fault = mon_bin_vma_fault,
1070}; 1068};
1071 1069
1072int mon_bin_mmap(struct file *filp, struct vm_area_struct *vma) 1070static int mon_bin_mmap(struct file *filp, struct vm_area_struct *vma)
1073{ 1071{
1074 /* don't do anything here: "fault" will set up page table entries */ 1072 /* don't do anything here: "fault" will set up page table entries */
1075 vma->vm_ops = &mon_bin_vm_ops; 1073 vma->vm_ops = &mon_bin_vm_ops;
@@ -1079,8 +1077,6 @@ int mon_bin_mmap(struct file *filp, struct vm_area_struct *vma)
1079 return 0; 1077 return 0;
1080} 1078}
1081 1079
1082#endif /* 0 */
1083
1084static const struct file_operations mon_fops_binary = { 1080static const struct file_operations mon_fops_binary = {
1085 .owner = THIS_MODULE, 1081 .owner = THIS_MODULE,
1086 .open = mon_bin_open, 1082 .open = mon_bin_open,
@@ -1090,6 +1086,7 @@ static const struct file_operations mon_fops_binary = {
1090 .poll = mon_bin_poll, 1086 .poll = mon_bin_poll,
1091 .ioctl = mon_bin_ioctl, 1087 .ioctl = mon_bin_ioctl,
1092 .release = mon_bin_release, 1088 .release = mon_bin_release,
1089 .mmap = mon_bin_mmap,
1093}; 1090};
1094 1091
1095static int mon_bin_wait_event(struct file *file, struct mon_reader_bin *rp) 1092static int mon_bin_wait_event(struct file *file, struct mon_reader_bin *rp)
diff --git a/drivers/usb/mon/mon_main.c b/drivers/usb/mon/mon_main.c
index b371ffd39d3..442d8076b20 100644
--- a/drivers/usb/mon/mon_main.c
+++ b/drivers/usb/mon/mon_main.c
@@ -129,8 +129,7 @@ static void mon_submit_error(struct usb_bus *ubus, struct urb *urb, int error)
129 129
130/* 130/*
131 */ 131 */
132static void mon_bus_complete(struct mon_bus *mbus, struct urb *urb, 132static void mon_bus_complete(struct mon_bus *mbus, struct urb *urb, int status)
133 int status)
134{ 133{
135 unsigned long flags; 134 unsigned long flags;
136 struct list_head *pos; 135 struct list_head *pos;
diff --git a/drivers/usb/mon/mon_stat.c b/drivers/usb/mon/mon_stat.c
index f6d1491256c..c7a595cd648 100644
--- a/drivers/usb/mon/mon_stat.c
+++ b/drivers/usb/mon/mon_stat.c
@@ -59,6 +59,9 @@ static ssize_t mon_stat_read(struct file *file, char __user *buf,
59 59
60static int mon_stat_release(struct inode *inode, struct file *file) 60static int mon_stat_release(struct inode *inode, struct file *file)
61{ 61{
62 struct snap *sp = file->private_data;
63 file->private_data = NULL;
64 kfree(sp);
62 return 0; 65 return 0;
63} 66}
64 67
diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig
index c1e65dfd935..2cffec85ee7 100644
--- a/drivers/usb/serial/Kconfig
+++ b/drivers/usb/serial/Kconfig
@@ -20,8 +20,8 @@ menuconfig USB_SERIAL
20if USB_SERIAL 20if USB_SERIAL
21 21
22config USB_SERIAL_CONSOLE 22config USB_SERIAL_CONSOLE
23 bool "USB Serial Console device support (EXPERIMENTAL)" 23 bool "USB Serial Console device support"
24 depends on USB_SERIAL=y && EXPERIMENTAL 24 depends on USB_SERIAL=y
25 ---help--- 25 ---help---
26 If you say Y here, it will be possible to use a USB to serial 26 If you say Y here, it will be possible to use a USB to serial
27 converter port as the system console (the system console is the 27 converter port as the system console (the system console is the
@@ -44,13 +44,11 @@ config USB_SERIAL_CONSOLE
44 44
45config USB_EZUSB 45config USB_EZUSB
46 bool "Functions for loading firmware on EZUSB chips" 46 bool "Functions for loading firmware on EZUSB chips"
47 depends on USB_SERIAL
48 help 47 help
49 Say Y here if you need EZUSB device support. 48 Say Y here if you need EZUSB device support.
50 49
51config USB_SERIAL_GENERIC 50config USB_SERIAL_GENERIC
52 bool "USB Generic Serial Driver" 51 bool "USB Generic Serial Driver"
53 depends on USB_SERIAL
54 help 52 help
55 Say Y here if you want to use the generic USB serial driver. Please 53 Say Y here if you want to use the generic USB serial driver. Please
56 read <file:Documentation/usb/usb-serial.txt> for more information on 54 read <file:Documentation/usb/usb-serial.txt> for more information on
@@ -59,8 +57,7 @@ config USB_SERIAL_GENERIC
59 properly. 57 properly.
60 58
61config USB_SERIAL_AIRCABLE 59config USB_SERIAL_AIRCABLE
62 tristate "USB AIRcable Bluetooth Dongle Driver (EXPERIMENTAL)" 60 tristate "USB AIRcable Bluetooth Dongle Driver"
63 depends on USB_SERIAL && EXPERIMENTAL
64 help 61 help
65 Say Y here if you want to use USB AIRcable Bluetooth Dongle. 62 Say Y here if you want to use USB AIRcable Bluetooth Dongle.
66 63
@@ -69,7 +66,6 @@ config USB_SERIAL_AIRCABLE
69 66
70config USB_SERIAL_AIRPRIME 67config USB_SERIAL_AIRPRIME
71 tristate "USB AirPrime CDMA Wireless Driver" 68 tristate "USB AirPrime CDMA Wireless Driver"
72 depends on USB_SERIAL
73 help 69 help
74 Say Y here if you want to use a AirPrime CDMA Wireless PC card. 70 Say Y here if you want to use a AirPrime CDMA Wireless PC card.
75 71
@@ -77,8 +73,7 @@ config USB_SERIAL_AIRPRIME
77 module will be called airprime. 73 module will be called airprime.
78 74
79config USB_SERIAL_ARK3116 75config USB_SERIAL_ARK3116
80 tristate "USB ARK Micro 3116 USB Serial Driver (EXPERIMENTAL)" 76 tristate "USB ARK Micro 3116 USB Serial Driver"
81 depends on USB_SERIAL && EXPERIMENTAL
82 help 77 help
83 Say Y here if you want to use a ARK Micro 3116 USB to Serial 78 Say Y here if you want to use a ARK Micro 3116 USB to Serial
84 device. 79 device.
@@ -88,7 +83,6 @@ config USB_SERIAL_ARK3116
88 83
89config USB_SERIAL_BELKIN 84config USB_SERIAL_BELKIN
90 tristate "USB Belkin and Peracom Single Port Serial Driver" 85 tristate "USB Belkin and Peracom Single Port Serial Driver"
91 depends on USB_SERIAL
92 help 86 help
93 Say Y here if you want to use a Belkin USB Serial single port 87 Say Y here if you want to use a Belkin USB Serial single port
94 adaptor (F5U103 is one of the model numbers) or the Peracom single 88 adaptor (F5U103 is one of the model numbers) or the Peracom single
@@ -99,7 +93,6 @@ config USB_SERIAL_BELKIN
99 93
100config USB_SERIAL_CH341 94config USB_SERIAL_CH341
101 tristate "USB Winchiphead CH341 Single Port Serial Driver" 95 tristate "USB Winchiphead CH341 Single Port Serial Driver"
102 depends on USB_SERIAL
103 help 96 help
104 Say Y here if you want to use a Winchiphead CH341 single port 97 Say Y here if you want to use a Winchiphead CH341 single port
105 USB to serial adapter. 98 USB to serial adapter.
@@ -109,7 +102,6 @@ config USB_SERIAL_CH341
109 102
110config USB_SERIAL_WHITEHEAT 103config USB_SERIAL_WHITEHEAT
111 tristate "USB ConnectTech WhiteHEAT Serial Driver" 104 tristate "USB ConnectTech WhiteHEAT Serial Driver"
112 depends on USB_SERIAL
113 select USB_EZUSB 105 select USB_EZUSB
114 help 106 help
115 Say Y here if you want to use a ConnectTech WhiteHEAT 4 port 107 Say Y here if you want to use a ConnectTech WhiteHEAT 4 port
@@ -120,7 +112,6 @@ config USB_SERIAL_WHITEHEAT
120 112
121config USB_SERIAL_DIGI_ACCELEPORT 113config USB_SERIAL_DIGI_ACCELEPORT
122 tristate "USB Digi International AccelePort USB Serial Driver" 114 tristate "USB Digi International AccelePort USB Serial Driver"
123 depends on USB_SERIAL
124 ---help--- 115 ---help---
125 Say Y here if you want to use Digi AccelePort USB 2 or 4 devices, 116 Say Y here if you want to use Digi AccelePort USB 2 or 4 devices,
126 2 port (plus parallel port) and 4 port USB serial converters. The 117 2 port (plus parallel port) and 4 port USB serial converters. The
@@ -135,7 +126,6 @@ config USB_SERIAL_DIGI_ACCELEPORT
135 126
136config USB_SERIAL_CP2101 127config USB_SERIAL_CP2101
137 tristate "USB CP2101 UART Bridge Controller" 128 tristate "USB CP2101 UART Bridge Controller"
138 depends on USB_SERIAL && EXPERIMENTAL
139 help 129 help
140 Say Y here if you want to use a CP2101/CP2102 based USB to RS232 130 Say Y here if you want to use a CP2101/CP2102 based USB to RS232
141 converter. 131 converter.
@@ -145,7 +135,6 @@ config USB_SERIAL_CP2101
145 135
146config USB_SERIAL_CYPRESS_M8 136config USB_SERIAL_CYPRESS_M8
147 tristate "USB Cypress M8 USB Serial Driver" 137 tristate "USB Cypress M8 USB Serial Driver"
148 depends on USB_SERIAL && EXPERIMENTAL
149 help 138 help
150 Say Y here if you want to use a device that contains the Cypress 139 Say Y here if you want to use a device that contains the Cypress
151 USB to Serial microcontroller, such as the DeLorme Earthmate GPS. 140 USB to Serial microcontroller, such as the DeLorme Earthmate GPS.
@@ -160,7 +149,6 @@ config USB_SERIAL_CYPRESS_M8
160 149
161config USB_SERIAL_EMPEG 150config USB_SERIAL_EMPEG
162 tristate "USB Empeg empeg-car Mark I/II Driver" 151 tristate "USB Empeg empeg-car Mark I/II Driver"
163 depends on USB_SERIAL
164 help 152 help
165 Say Y here if you want to connect to your Empeg empeg-car Mark I/II 153 Say Y here if you want to connect to your Empeg empeg-car Mark I/II
166 mp3 player via USB. The driver uses a single ttyUSB{0,1,2,...} 154 mp3 player via USB. The driver uses a single ttyUSB{0,1,2,...}
@@ -171,8 +159,7 @@ config USB_SERIAL_EMPEG
171 module will be called empeg. 159 module will be called empeg.
172 160
173config USB_SERIAL_FTDI_SIO 161config USB_SERIAL_FTDI_SIO
174 tristate "USB FTDI Single Port Serial Driver (EXPERIMENTAL)" 162 tristate "USB FTDI Single Port Serial Driver"
175 depends on USB_SERIAL && EXPERIMENTAL
176 ---help--- 163 ---help---
177 Say Y here if you want to use a FTDI SIO single port USB to serial 164 Say Y here if you want to use a FTDI SIO single port USB to serial
178 converter device. The implementation I have is called the USC-1000. 165 converter device. The implementation I have is called the USC-1000.
@@ -186,7 +173,6 @@ config USB_SERIAL_FTDI_SIO
186 173
187config USB_SERIAL_FUNSOFT 174config USB_SERIAL_FUNSOFT
188 tristate "USB Fundamental Software Dongle Driver" 175 tristate "USB Fundamental Software Dongle Driver"
189 depends on USB_SERIAL
190 ---help--- 176 ---help---
191 Say Y here if you want to use the Fundamental Software dongle. 177 Say Y here if you want to use the Fundamental Software dongle.
192 178
@@ -195,7 +181,6 @@ config USB_SERIAL_FUNSOFT
195 181
196config USB_SERIAL_VISOR 182config USB_SERIAL_VISOR
197 tristate "USB Handspring Visor / Palm m50x / Sony Clie Driver" 183 tristate "USB Handspring Visor / Palm m50x / Sony Clie Driver"
198 depends on USB_SERIAL
199 help 184 help
200 Say Y here if you want to connect to your HandSpring Visor, Palm 185 Say Y here if you want to connect to your HandSpring Visor, Palm
201 m500 or m505 through its USB docking station. See 186 m500 or m505 through its USB docking station. See
@@ -207,7 +192,6 @@ config USB_SERIAL_VISOR
207 192
208config USB_SERIAL_IPAQ 193config USB_SERIAL_IPAQ
209 tristate "USB PocketPC PDA Driver" 194 tristate "USB PocketPC PDA Driver"
210 depends on USB_SERIAL
211 help 195 help
212 Say Y here if you want to connect to your Compaq iPAQ, HP Jornada 196 Say Y here if you want to connect to your Compaq iPAQ, HP Jornada
213 or any other PDA running Windows CE 3.0 or PocketPC 2002 197 or any other PDA running Windows CE 3.0 or PocketPC 2002
@@ -218,8 +202,7 @@ config USB_SERIAL_IPAQ
218 module will be called ipaq. 202 module will be called ipaq.
219 203
220config USB_SERIAL_IR 204config USB_SERIAL_IR
221 tristate "USB IR Dongle Serial Driver (EXPERIMENTAL)" 205 tristate "USB IR Dongle Serial Driver"
222 depends on USB_SERIAL && EXPERIMENTAL
223 help 206 help
224 Say Y here if you want to enable simple serial support for USB IrDA 207 Say Y here if you want to enable simple serial support for USB IrDA
225 devices. This is useful if you do not want to use the full IrDA 208 devices. This is useful if you do not want to use the full IrDA
@@ -230,7 +213,6 @@ config USB_SERIAL_IR
230 213
231config USB_SERIAL_EDGEPORT 214config USB_SERIAL_EDGEPORT
232 tristate "USB Inside Out Edgeport Serial Driver" 215 tristate "USB Inside Out Edgeport Serial Driver"
233 depends on USB_SERIAL
234 ---help--- 216 ---help---
235 Say Y here if you want to use any of the following devices from 217 Say Y here if you want to use any of the following devices from
236 Inside Out Networks (Digi): 218 Inside Out Networks (Digi):
@@ -256,7 +238,6 @@ config USB_SERIAL_EDGEPORT
256 238
257config USB_SERIAL_EDGEPORT_TI 239config USB_SERIAL_EDGEPORT_TI
258 tristate "USB Inside Out Edgeport Serial Driver (TI devices)" 240 tristate "USB Inside Out Edgeport Serial Driver (TI devices)"
259 depends on USB_SERIAL
260 help 241 help
261 Say Y here if you want to use any of the devices from Inside Out 242 Say Y here if you want to use any of the devices from Inside Out
262 Networks (Digi) that are not supported by the io_edgeport driver. 243 Networks (Digi) that are not supported by the io_edgeport driver.
@@ -267,7 +248,6 @@ config USB_SERIAL_EDGEPORT_TI
267 248
268config USB_SERIAL_GARMIN 249config USB_SERIAL_GARMIN
269 tristate "USB Garmin GPS driver" 250 tristate "USB Garmin GPS driver"
270 depends on USB_SERIAL
271 help 251 help
272 Say Y here if you want to connect to your Garmin GPS. 252 Say Y here if you want to connect to your Garmin GPS.
273 Should work with most Garmin GPS devices which have a native USB port. 253 Should work with most Garmin GPS devices which have a native USB port.
@@ -279,8 +259,7 @@ config USB_SERIAL_GARMIN
279 module will be called garmin_gps. 259 module will be called garmin_gps.
280 260
281config USB_SERIAL_IPW 261config USB_SERIAL_IPW
282 tristate "USB IPWireless (3G UMTS TDD) Driver (EXPERIMENTAL)" 262 tristate "USB IPWireless (3G UMTS TDD) Driver"
283 depends on USB_SERIAL && EXPERIMENTAL
284 help 263 help
285 Say Y here if you want to use a IPWireless USB modem such as 264 Say Y here if you want to use a IPWireless USB modem such as
286 the ones supplied by Axity3G/Sentech South Africa. 265 the ones supplied by Axity3G/Sentech South Africa.
@@ -289,8 +268,7 @@ config USB_SERIAL_IPW
289 module will be called ipw. 268 module will be called ipw.
290 269
291config USB_SERIAL_IUU 270config USB_SERIAL_IUU
292 tristate "USB Infinity USB Unlimited Phoenix Driver (Experimental)" 271 tristate "USB Infinity USB Unlimited Phoenix Driver"
293 depends on USB_SERIAL && EXPERIMENTAL
294 help 272 help
295 Say Y here if you want to use a IUU in phoenix mode and get 273 Say Y here if you want to use a IUU in phoenix mode and get
296 an extra ttyUSBx device. More information available on 274 an extra ttyUSBx device. More information available on
@@ -301,7 +279,6 @@ config USB_SERIAL_IUU
301 279
302config USB_SERIAL_KEYSPAN_PDA 280config USB_SERIAL_KEYSPAN_PDA
303 tristate "USB Keyspan PDA Single Port Serial Driver" 281 tristate "USB Keyspan PDA Single Port Serial Driver"
304 depends on USB_SERIAL
305 select USB_EZUSB 282 select USB_EZUSB
306 help 283 help
307 Say Y here if you want to use a Keyspan PDA single port USB to 284 Say Y here if you want to use a Keyspan PDA single port USB to
@@ -313,7 +290,6 @@ config USB_SERIAL_KEYSPAN_PDA
313 290
314config USB_SERIAL_KEYSPAN 291config USB_SERIAL_KEYSPAN
315 tristate "USB Keyspan USA-xxx Serial Driver" 292 tristate "USB Keyspan USA-xxx Serial Driver"
316 depends on USB_SERIAL
317 select USB_EZUSB 293 select USB_EZUSB
318 ---help--- 294 ---help---
319 Say Y here if you want to use Keyspan USB to serial converter 295 Say Y here if you want to use Keyspan USB to serial converter
@@ -405,8 +381,7 @@ config USB_SERIAL_KEYSPAN_USA49WLC
405 Say Y here to include firmware for the USA-49WLC converter. 381 Say Y here to include firmware for the USA-49WLC converter.
406 382
407config USB_SERIAL_KLSI 383config USB_SERIAL_KLSI
408 tristate "USB KL5KUSB105 (Palmconnect) Driver (EXPERIMENTAL)" 384 tristate "USB KL5KUSB105 (Palmconnect) Driver"
409 depends on USB_SERIAL && EXPERIMENTAL
410 ---help--- 385 ---help---
411 Say Y here if you want to use a KL5KUSB105 - based single port 386 Say Y here if you want to use a KL5KUSB105 - based single port
412 serial adapter. The most widely known -- and currently the only 387 serial adapter. The most widely known -- and currently the only
@@ -422,7 +397,6 @@ config USB_SERIAL_KLSI
422 397
423config USB_SERIAL_KOBIL_SCT 398config USB_SERIAL_KOBIL_SCT
424 tristate "USB KOBIL chipcard reader" 399 tristate "USB KOBIL chipcard reader"
425 depends on USB_SERIAL
426 ---help--- 400 ---help---
427 Say Y here if you want to use one of the following KOBIL USB chipcard 401 Say Y here if you want to use one of the following KOBIL USB chipcard
428 readers: 402 readers:
@@ -440,7 +414,6 @@ config USB_SERIAL_KOBIL_SCT
440 414
441config USB_SERIAL_MCT_U232 415config USB_SERIAL_MCT_U232
442 tristate "USB MCT Single Port Serial Driver" 416 tristate "USB MCT Single Port Serial Driver"
443 depends on USB_SERIAL
444 ---help--- 417 ---help---
445 Say Y here if you want to use a USB Serial single port adapter from 418 Say Y here if you want to use a USB Serial single port adapter from
446 Magic Control Technology Corp. (U232 is one of the model numbers). 419 Magic Control Technology Corp. (U232 is one of the model numbers).
@@ -453,7 +426,6 @@ config USB_SERIAL_MCT_U232
453 426
454config USB_SERIAL_MOS7720 427config USB_SERIAL_MOS7720
455 tristate "USB Moschip 7720 Serial Driver" 428 tristate "USB Moschip 7720 Serial Driver"
456 depends on USB_SERIAL
457 ---help--- 429 ---help---
458 Say Y here if you want to use USB Serial single and double 430 Say Y here if you want to use USB Serial single and double
459 port adapters from Moschip Semiconductor Tech. 431 port adapters from Moschip Semiconductor Tech.
@@ -463,7 +435,6 @@ config USB_SERIAL_MOS7720
463 435
464config USB_SERIAL_MOS7840 436config USB_SERIAL_MOS7840
465 tristate "USB Moschip 7840/7820 USB Serial Driver" 437 tristate "USB Moschip 7840/7820 USB Serial Driver"
466 depends on USB_SERIAL
467 ---help--- 438 ---help---
468 Say Y here if you want to use a MCS7840 Quad-Serial or MCS7820 439 Say Y here if you want to use a MCS7840 Quad-Serial or MCS7820
469 Dual-Serial port device from MosChip Semiconductor. 440 Dual-Serial port device from MosChip Semiconductor.
@@ -478,14 +449,12 @@ config USB_SERIAL_MOS7840
478 449
479config USB_SERIAL_NAVMAN 450config USB_SERIAL_NAVMAN
480 tristate "USB Navman GPS device" 451 tristate "USB Navman GPS device"
481 depends on USB_SERIAL
482 help 452 help
483 To compile this driver as a module, choose M here: the 453 To compile this driver as a module, choose M here: the
484 module will be called navman. 454 module will be called navman.
485 455
486config USB_SERIAL_PL2303 456config USB_SERIAL_PL2303
487 tristate "USB Prolific 2303 Single Port Serial Driver" 457 tristate "USB Prolific 2303 Single Port Serial Driver"
488 depends on USB_SERIAL
489 help 458 help
490 Say Y here if you want to use the PL2303 USB Serial single port 459 Say Y here if you want to use the PL2303 USB Serial single port
491 adapter from Prolific. 460 adapter from Prolific.
@@ -494,8 +463,7 @@ config USB_SERIAL_PL2303
494 module will be called pl2303. 463 module will be called pl2303.
495 464
496config USB_SERIAL_OTI6858 465config USB_SERIAL_OTI6858
497 tristate "USB Ours Technology Inc. OTi-6858 USB To RS232 Bridge Controller (EXPERIMENTAL)" 466 tristate "USB Ours Technology Inc. OTi-6858 USB To RS232 Bridge Controller"
498 depends on USB_SERIAL
499 help 467 help
500 Say Y here if you want to use the OTi-6858 single port USB to serial 468 Say Y here if you want to use the OTi-6858 single port USB to serial
501 converter device. 469 converter device.
@@ -503,9 +471,17 @@ config USB_SERIAL_OTI6858
503 To compile this driver as a module, choose M here: the 471 To compile this driver as a module, choose M here: the
504 module will be called oti6858. 472 module will be called oti6858.
505 473
474config USB_SERIAL_SPCP8X5
475 tristate "USB SPCP8x5 USB To Serial Driver"
476 help
477 Say Y here if you want to use the spcp8x5 converter chip. This is
478 commonly found in some Z-Wave USB devices.
479
480 To compile this driver as a module, choose M here: the
481 module will be called spcp8x5.
482
506config USB_SERIAL_HP4X 483config USB_SERIAL_HP4X
507 tristate "USB HP4x Calculators support" 484 tristate "USB HP4x Calculators support"
508 depends on USB_SERIAL
509 help 485 help
510 Say Y here if you want to use an Hewlett-Packard 4x Calculator. 486 Say Y here if you want to use an Hewlett-Packard 4x Calculator.
511 487
@@ -513,8 +489,7 @@ config USB_SERIAL_HP4X
513 module will be called hp4x. 489 module will be called hp4x.
514 490
515config USB_SERIAL_SAFE 491config USB_SERIAL_SAFE
516 tristate "USB Safe Serial (Encapsulated) Driver (EXPERIMENTAL)" 492 tristate "USB Safe Serial (Encapsulated) Driver"
517 depends on USB_SERIAL && EXPERIMENTAL
518 493
519config USB_SERIAL_SAFE_PADDED 494config USB_SERIAL_SAFE_PADDED
520 bool "USB Secure Encapsulated Driver - Padded" 495 bool "USB Secure Encapsulated Driver - Padded"
@@ -522,7 +497,6 @@ config USB_SERIAL_SAFE_PADDED
522 497
523config USB_SERIAL_SIERRAWIRELESS 498config USB_SERIAL_SIERRAWIRELESS
524 tristate "USB Sierra Wireless Driver" 499 tristate "USB Sierra Wireless Driver"
525 depends on USB_SERIAL
526 help 500 help
527 Say M here if you want to use a Sierra Wireless device (if 501 Say M here if you want to use a Sierra Wireless device (if
528 using an PC 5220 or AC580 please use the Airprime driver 502 using an PC 5220 or AC580 please use the Airprime driver
@@ -533,7 +507,6 @@ config USB_SERIAL_SIERRAWIRELESS
533 507
534config USB_SERIAL_TI 508config USB_SERIAL_TI
535 tristate "USB TI 3410/5052 Serial Driver" 509 tristate "USB TI 3410/5052 Serial Driver"
536 depends on USB_SERIAL
537 help 510 help
538 Say Y here if you want to use the TI USB 3410 or 5052 511 Say Y here if you want to use the TI USB 3410 or 5052
539 serial devices. 512 serial devices.
@@ -542,8 +515,7 @@ config USB_SERIAL_TI
542 module will be called ti_usb_3410_5052. 515 module will be called ti_usb_3410_5052.
543 516
544config USB_SERIAL_CYBERJACK 517config USB_SERIAL_CYBERJACK
545 tristate "USB REINER SCT cyberJack pinpad/e-com chipcard reader (EXPERIMENTAL)" 518 tristate "USB REINER SCT cyberJack pinpad/e-com chipcard reader"
546 depends on USB_SERIAL && EXPERIMENTAL
547 ---help--- 519 ---help---
548 Say Y here if you want to use a cyberJack pinpad/e-com USB chipcard 520 Say Y here if you want to use a cyberJack pinpad/e-com USB chipcard
549 reader. This is an interface to ISO 7816 compatible contact-based 521 reader. This is an interface to ISO 7816 compatible contact-based
@@ -556,7 +528,6 @@ config USB_SERIAL_CYBERJACK
556 528
557config USB_SERIAL_XIRCOM 529config USB_SERIAL_XIRCOM
558 tristate "USB Xircom / Entregra Single Port Serial Driver" 530 tristate "USB Xircom / Entregra Single Port Serial Driver"
559 depends on USB_SERIAL
560 select USB_EZUSB 531 select USB_EZUSB
561 help 532 help
562 Say Y here if you want to use a Xircom or Entregra single port USB to 533 Say Y here if you want to use a Xircom or Entregra single port USB to
@@ -568,7 +539,6 @@ config USB_SERIAL_XIRCOM
568 539
569config USB_SERIAL_OPTION 540config USB_SERIAL_OPTION
570 tristate "USB driver for GSM and CDMA modems" 541 tristate "USB driver for GSM and CDMA modems"
571 depends on USB_SERIAL
572 help 542 help
573 Say Y here if you have a GSM or CDMA modem that's connected to USB. 543 Say Y here if you have a GSM or CDMA modem that's connected to USB.
574 544
@@ -586,8 +556,7 @@ config USB_SERIAL_OPTION
586 it might be accessible via the FTDI_SIO driver. 556 it might be accessible via the FTDI_SIO driver.
587 557
588config USB_SERIAL_OMNINET 558config USB_SERIAL_OMNINET
589 tristate "USB ZyXEL omni.net LCD Plus Driver (EXPERIMENTAL)" 559 tristate "USB ZyXEL omni.net LCD Plus Driver"
590 depends on USB_SERIAL && EXPERIMENTAL
591 help 560 help
592 Say Y here if you want to use a ZyXEL omni.net LCD ISDN TA. 561 Say Y here if you want to use a ZyXEL omni.net LCD ISDN TA.
593 562
@@ -596,7 +565,6 @@ config USB_SERIAL_OMNINET
596 565
597config USB_SERIAL_DEBUG 566config USB_SERIAL_DEBUG
598 tristate "USB Debugging Device" 567 tristate "USB Debugging Device"
599 depends on USB_SERIAL
600 help 568 help
601 Say Y here if you have a USB debugging device used to receive 569 Say Y here if you have a USB debugging device used to receive
602 debugging data from another machine. The most common of these 570 debugging data from another machine. The most common of these
diff --git a/drivers/usb/serial/Makefile b/drivers/usb/serial/Makefile
index 0db109a54d1..756859510d8 100644
--- a/drivers/usb/serial/Makefile
+++ b/drivers/usb/serial/Makefile
@@ -30,8 +30,8 @@ obj-$(CONFIG_USB_SERIAL_GARMIN) += garmin_gps.o
30obj-$(CONFIG_USB_SERIAL_HP4X) += hp4x.o 30obj-$(CONFIG_USB_SERIAL_HP4X) += hp4x.o
31obj-$(CONFIG_USB_SERIAL_IPAQ) += ipaq.o 31obj-$(CONFIG_USB_SERIAL_IPAQ) += ipaq.o
32obj-$(CONFIG_USB_SERIAL_IPW) += ipw.o 32obj-$(CONFIG_USB_SERIAL_IPW) += ipw.o
33obj-$(CONFIG_USB_SERIAL_IUU) += iuu_phoenix.o
34obj-$(CONFIG_USB_SERIAL_IR) += ir-usb.o 33obj-$(CONFIG_USB_SERIAL_IR) += ir-usb.o
34obj-$(CONFIG_USB_SERIAL_IUU) += iuu_phoenix.o
35obj-$(CONFIG_USB_SERIAL_KEYSPAN) += keyspan.o 35obj-$(CONFIG_USB_SERIAL_KEYSPAN) += keyspan.o
36obj-$(CONFIG_USB_SERIAL_KEYSPAN_PDA) += keyspan_pda.o 36obj-$(CONFIG_USB_SERIAL_KEYSPAN_PDA) += keyspan_pda.o
37obj-$(CONFIG_USB_SERIAL_KLSI) += kl5kusb105.o 37obj-$(CONFIG_USB_SERIAL_KLSI) += kl5kusb105.o
@@ -46,6 +46,7 @@ obj-$(CONFIG_USB_SERIAL_OTI6858) += oti6858.o
46obj-$(CONFIG_USB_SERIAL_PL2303) += pl2303.o 46obj-$(CONFIG_USB_SERIAL_PL2303) += pl2303.o
47obj-$(CONFIG_USB_SERIAL_SAFE) += safe_serial.o 47obj-$(CONFIG_USB_SERIAL_SAFE) += safe_serial.o
48obj-$(CONFIG_USB_SERIAL_SIERRAWIRELESS) += sierra.o 48obj-$(CONFIG_USB_SERIAL_SIERRAWIRELESS) += sierra.o
49obj-$(CONFIG_USB_SERIAL_SPCP8X5) += spcp8x5.o
49obj-$(CONFIG_USB_SERIAL_TI) += ti_usb_3410_5052.o 50obj-$(CONFIG_USB_SERIAL_TI) += ti_usb_3410_5052.o
50obj-$(CONFIG_USB_SERIAL_VISOR) += visor.o 51obj-$(CONFIG_USB_SERIAL_VISOR) += visor.o
51obj-$(CONFIG_USB_SERIAL_WHITEHEAT) += whiteheat.o 52obj-$(CONFIG_USB_SERIAL_WHITEHEAT) += whiteheat.o
diff --git a/drivers/usb/serial/aircable.c b/drivers/usb/serial/aircable.c
index 1cd29cd6bd0..a238817762a 100644
--- a/drivers/usb/serial/aircable.c
+++ b/drivers/usb/serial/aircable.c
@@ -210,7 +210,7 @@ static void aircable_send(struct usb_serial_port *port)
210 struct aircable_private *priv = usb_get_serial_port_data(port); 210 struct aircable_private *priv = usb_get_serial_port_data(port);
211 unsigned char* buf; 211 unsigned char* buf;
212 u16 *dbuf; 212 u16 *dbuf;
213 dbg("%s - port %d", __FUNCTION__, port->number); 213 dbg("%s - port %d", __func__, port->number);
214 if (port->write_urb_busy) 214 if (port->write_urb_busy)
215 return; 215 return;
216 216
@@ -220,7 +220,7 @@ static void aircable_send(struct usb_serial_port *port)
220 220
221 buf = kzalloc(count + HCI_HEADER_LENGTH, GFP_ATOMIC); 221 buf = kzalloc(count + HCI_HEADER_LENGTH, GFP_ATOMIC);
222 if (!buf) { 222 if (!buf) {
223 err("%s- kzalloc(%d) failed.", __FUNCTION__, 223 err("%s- kzalloc(%d) failed.", __func__,
224 count + HCI_HEADER_LENGTH); 224 count + HCI_HEADER_LENGTH);
225 return; 225 return;
226 } 226 }
@@ -236,7 +236,7 @@ static void aircable_send(struct usb_serial_port *port)
236 236
237 kfree(buf); 237 kfree(buf);
238 port->write_urb_busy = 1; 238 port->write_urb_busy = 1;
239 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, 239 usb_serial_debug_data(debug, &port->dev, __func__,
240 count + HCI_HEADER_LENGTH, 240 count + HCI_HEADER_LENGTH,
241 port->write_urb->transfer_buffer); 241 port->write_urb->transfer_buffer);
242 port->write_urb->transfer_buffer_length = count + HCI_HEADER_LENGTH; 242 port->write_urb->transfer_buffer_length = count + HCI_HEADER_LENGTH;
@@ -246,7 +246,7 @@ static void aircable_send(struct usb_serial_port *port)
246 if (result) { 246 if (result) {
247 dev_err(&port->dev, 247 dev_err(&port->dev,
248 "%s - failed submitting write urb, error %d\n", 248 "%s - failed submitting write urb, error %d\n",
249 __FUNCTION__, result); 249 __func__, result);
250 port->write_urb_busy = 0; 250 port->write_urb_busy = 0;
251 } 251 }
252 252
@@ -275,7 +275,7 @@ static void aircable_read(struct work_struct *work)
275 275
276 if (!tty) { 276 if (!tty) {
277 schedule_work(&priv->rx_work); 277 schedule_work(&priv->rx_work);
278 err("%s - No tty available", __FUNCTION__); 278 err("%s - No tty available", __func__);
279 return ; 279 return ;
280 } 280 }
281 281
@@ -286,7 +286,7 @@ static void aircable_read(struct work_struct *work)
286 286
287 tty_prepare_flip_string(tty, &data, count); 287 tty_prepare_flip_string(tty, &data, count);
288 if (!data){ 288 if (!data){
289 err("%s- kzalloc(%d) failed.", __FUNCTION__, count); 289 err("%s- kzalloc(%d) failed.", __func__, count);
290 return; 290 return;
291 } 291 }
292 292
@@ -332,7 +332,7 @@ static int aircable_attach (struct usb_serial *serial)
332 332
333 priv = kzalloc(sizeof(struct aircable_private), GFP_KERNEL); 333 priv = kzalloc(sizeof(struct aircable_private), GFP_KERNEL);
334 if (!priv){ 334 if (!priv){
335 err("%s- kmalloc(%Zd) failed.", __FUNCTION__, 335 err("%s- kmalloc(%Zd) failed.", __func__,
336 sizeof(struct aircable_private)); 336 sizeof(struct aircable_private));
337 return -ENOMEM; 337 return -ENOMEM;
338 } 338 }
@@ -366,7 +366,7 @@ static void aircable_shutdown(struct usb_serial *serial)
366 struct usb_serial_port *port = serial->port[0]; 366 struct usb_serial_port *port = serial->port[0];
367 struct aircable_private *priv = usb_get_serial_port_data(port); 367 struct aircable_private *priv = usb_get_serial_port_data(port);
368 368
369 dbg("%s", __FUNCTION__); 369 dbg("%s", __func__);
370 370
371 if (priv) { 371 if (priv) {
372 serial_buf_free(priv->tx_buf); 372 serial_buf_free(priv->tx_buf);
@@ -388,12 +388,12 @@ static int aircable_write(struct usb_serial_port *port,
388 struct aircable_private *priv = usb_get_serial_port_data(port); 388 struct aircable_private *priv = usb_get_serial_port_data(port);
389 int temp; 389 int temp;
390 390
391 dbg("%s - port %d, %d bytes", __FUNCTION__, port->number, count); 391 dbg("%s - port %d, %d bytes", __func__, port->number, count);
392 392
393 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count, source); 393 usb_serial_debug_data(debug, &port->dev, __func__, count, source);
394 394
395 if (!count){ 395 if (!count){
396 dbg("%s - write request of 0 bytes", __FUNCTION__); 396 dbg("%s - write request of 0 bytes", __func__);
397 return count; 397 return count;
398 } 398 }
399 399
@@ -414,7 +414,7 @@ static void aircable_write_bulk_callback(struct urb *urb)
414 int status = urb->status; 414 int status = urb->status;
415 int result; 415 int result;
416 416
417 dbg("%s - urb status: %d", __FUNCTION__ , status); 417 dbg("%s - urb status: %d", __func__ , status);
418 418
419 /* This has been taken from cypress_m8.c cypress_write_int_callback */ 419 /* This has been taken from cypress_m8.c cypress_write_int_callback */
420 switch (status) { 420 switch (status) {
@@ -426,21 +426,21 @@ static void aircable_write_bulk_callback(struct urb *urb)
426 case -ESHUTDOWN: 426 case -ESHUTDOWN:
427 /* this urb is terminated, clean up */ 427 /* this urb is terminated, clean up */
428 dbg("%s - urb shutting down with status: %d", 428 dbg("%s - urb shutting down with status: %d",
429 __FUNCTION__, status); 429 __func__, status);
430 port->write_urb_busy = 0; 430 port->write_urb_busy = 0;
431 return; 431 return;
432 default: 432 default:
433 /* error in the urb, so we have to resubmit it */ 433 /* error in the urb, so we have to resubmit it */
434 dbg("%s - Overflow in write", __FUNCTION__); 434 dbg("%s - Overflow in write", __func__);
435 dbg("%s - nonzero write bulk status received: %d", 435 dbg("%s - nonzero write bulk status received: %d",
436 __FUNCTION__, status); 436 __func__, status);
437 port->write_urb->transfer_buffer_length = 1; 437 port->write_urb->transfer_buffer_length = 1;
438 port->write_urb->dev = port->serial->dev; 438 port->write_urb->dev = port->serial->dev;
439 result = usb_submit_urb(port->write_urb, GFP_ATOMIC); 439 result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
440 if (result) 440 if (result)
441 dev_err(&urb->dev->dev, 441 dev_err(&urb->dev->dev,
442 "%s - failed resubmitting write urb, error %d\n", 442 "%s - failed resubmitting write urb, error %d\n",
443 __FUNCTION__, result); 443 __func__, result);
444 else 444 else
445 return; 445 return;
446 } 446 }
@@ -460,17 +460,17 @@ static void aircable_read_bulk_callback(struct urb *urb)
460 unsigned char *temp; 460 unsigned char *temp;
461 int status = urb->status; 461 int status = urb->status;
462 462
463 dbg("%s - port %d", __FUNCTION__, port->number); 463 dbg("%s - port %d", __func__, port->number);
464 464
465 if (status) { 465 if (status) {
466 dbg("%s - urb status = %d", __FUNCTION__, status); 466 dbg("%s - urb status = %d", __func__, status);
467 if (!port->open_count) { 467 if (!port->open_count) {
468 dbg("%s - port is closed, exiting.", __FUNCTION__); 468 dbg("%s - port is closed, exiting.", __func__);
469 return; 469 return;
470 } 470 }
471 if (status == -EPROTO) { 471 if (status == -EPROTO) {
472 dbg("%s - caught -EPROTO, resubmitting the urb", 472 dbg("%s - caught -EPROTO, resubmitting the urb",
473 __FUNCTION__); 473 __func__);
474 usb_fill_bulk_urb(port->read_urb, port->serial->dev, 474 usb_fill_bulk_urb(port->read_urb, port->serial->dev,
475 usb_rcvbulkpipe(port->serial->dev, 475 usb_rcvbulkpipe(port->serial->dev,
476 port->bulk_in_endpointAddress), 476 port->bulk_in_endpointAddress),
@@ -482,14 +482,14 @@ static void aircable_read_bulk_callback(struct urb *urb)
482 if (result) 482 if (result)
483 dev_err(&urb->dev->dev, 483 dev_err(&urb->dev->dev,
484 "%s - failed resubmitting read urb, error %d\n", 484 "%s - failed resubmitting read urb, error %d\n",
485 __FUNCTION__, result); 485 __func__, result);
486 return; 486 return;
487 } 487 }
488 dbg("%s - unable to handle the error, exiting.", __FUNCTION__); 488 dbg("%s - unable to handle the error, exiting.", __func__);
489 return; 489 return;
490 } 490 }
491 491
492 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, 492 usb_serial_debug_data(debug, &port->dev, __func__,
493 urb->actual_length,urb->transfer_buffer); 493 urb->actual_length,urb->transfer_buffer);
494 494
495 tty = port->tty; 495 tty = port->tty;
@@ -538,7 +538,7 @@ static void aircable_read_bulk_callback(struct urb *urb)
538 if (result) 538 if (result)
539 dev_err(&urb->dev->dev, 539 dev_err(&urb->dev->dev,
540 "%s - failed resubmitting read urb, error %d\n", 540 "%s - failed resubmitting read urb, error %d\n",
541 __FUNCTION__, result); 541 __func__, result);
542 } 542 }
543 543
544 return; 544 return;
@@ -550,7 +550,7 @@ static void aircable_throttle(struct usb_serial_port *port)
550 struct aircable_private *priv = usb_get_serial_port_data(port); 550 struct aircable_private *priv = usb_get_serial_port_data(port);
551 unsigned long flags; 551 unsigned long flags;
552 552
553 dbg("%s - port %d", __FUNCTION__, port->number); 553 dbg("%s - port %d", __func__, port->number);
554 554
555 spin_lock_irqsave(&priv->rx_lock, flags); 555 spin_lock_irqsave(&priv->rx_lock, flags);
556 priv->rx_flags |= THROTTLED; 556 priv->rx_flags |= THROTTLED;
@@ -564,7 +564,7 @@ static void aircable_unthrottle(struct usb_serial_port *port)
564 int actually_throttled; 564 int actually_throttled;
565 unsigned long flags; 565 unsigned long flags;
566 566
567 dbg("%s - port %d", __FUNCTION__, port->number); 567 dbg("%s - port %d", __func__, port->number);
568 568
569 spin_lock_irqsave(&priv->rx_lock, flags); 569 spin_lock_irqsave(&priv->rx_lock, flags);
570 actually_throttled = priv->rx_flags & ACTUALLY_THROTTLED; 570 actually_throttled = priv->rx_flags & ACTUALLY_THROTTLED;
diff --git a/drivers/usb/serial/airprime.c b/drivers/usb/serial/airprime.c
index f156dba0300..725b6b94c27 100644
--- a/drivers/usb/serial/airprime.c
+++ b/drivers/usb/serial/airprime.c
@@ -53,7 +53,7 @@ static int airprime_send_setup(struct usb_serial_port *port)
53 struct usb_serial *serial = port->serial; 53 struct usb_serial *serial = port->serial;
54 struct airprime_private *priv; 54 struct airprime_private *priv;
55 55
56 dbg("%s", __FUNCTION__); 56 dbg("%s", __func__);
57 57
58 if (port->number != 0) 58 if (port->number != 0)
59 return 0; 59 return 0;
@@ -83,14 +83,14 @@ static void airprime_read_bulk_callback(struct urb *urb)
83 int result; 83 int result;
84 int status = urb->status; 84 int status = urb->status;
85 85
86 dbg("%s - port %d", __FUNCTION__, port->number); 86 dbg("%s - port %d", __func__, port->number);
87 87
88 if (status) { 88 if (status) {
89 dbg("%s - nonzero read bulk status received: %d", 89 dbg("%s - nonzero read bulk status received: %d",
90 __FUNCTION__, status); 90 __func__, status);
91 return; 91 return;
92 } 92 }
93 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, urb->actual_length, data); 93 usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data);
94 94
95 tty = port->tty; 95 tty = port->tty;
96 if (tty && urb->actual_length) { 96 if (tty && urb->actual_length) {
@@ -101,7 +101,7 @@ static void airprime_read_bulk_callback(struct urb *urb)
101 result = usb_submit_urb (urb, GFP_ATOMIC); 101 result = usb_submit_urb (urb, GFP_ATOMIC);
102 if (result) 102 if (result)
103 dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", 103 dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n",
104 __FUNCTION__, result); 104 __func__, result);
105 return; 105 return;
106} 106}
107 107
@@ -112,14 +112,14 @@ static void airprime_write_bulk_callback(struct urb *urb)
112 int status = urb->status; 112 int status = urb->status;
113 unsigned long flags; 113 unsigned long flags;
114 114
115 dbg("%s - port %d", __FUNCTION__, port->number); 115 dbg("%s - port %d", __func__, port->number);
116 116
117 /* free up the transfer buffer, as usb_free_urb() does not do this */ 117 /* free up the transfer buffer, as usb_free_urb() does not do this */
118 kfree (urb->transfer_buffer); 118 kfree (urb->transfer_buffer);
119 119
120 if (status) 120 if (status)
121 dbg("%s - nonzero write bulk status received: %d", 121 dbg("%s - nonzero write bulk status received: %d",
122 __FUNCTION__, status); 122 __func__, status);
123 spin_lock_irqsave(&priv->lock, flags); 123 spin_lock_irqsave(&priv->lock, flags);
124 --priv->outstanding_urbs; 124 --priv->outstanding_urbs;
125 spin_unlock_irqrestore(&priv->lock, flags); 125 spin_unlock_irqrestore(&priv->lock, flags);
@@ -136,7 +136,7 @@ static int airprime_open(struct usb_serial_port *port, struct file *filp)
136 int i; 136 int i;
137 int result = 0; 137 int result = 0;
138 138
139 dbg("%s - port %d", __FUNCTION__, port->number); 139 dbg("%s - port %d", __func__, port->number);
140 140
141 /* initialize our private data structure if it isn't already created */ 141 /* initialize our private data structure if it isn't already created */
142 if (!priv) { 142 if (!priv) {
@@ -157,7 +157,7 @@ static int airprime_open(struct usb_serial_port *port, struct file *filp)
157 buffer = kmalloc(buffer_size, GFP_KERNEL); 157 buffer = kmalloc(buffer_size, GFP_KERNEL);
158 if (!buffer) { 158 if (!buffer) {
159 dev_err(&port->dev, "%s - out of memory.\n", 159 dev_err(&port->dev, "%s - out of memory.\n",
160 __FUNCTION__); 160 __func__);
161 result = -ENOMEM; 161 result = -ENOMEM;
162 goto errout; 162 goto errout;
163 } 163 }
@@ -165,7 +165,7 @@ static int airprime_open(struct usb_serial_port *port, struct file *filp)
165 if (!urb) { 165 if (!urb) {
166 kfree(buffer); 166 kfree(buffer);
167 dev_err(&port->dev, "%s - no more urbs?\n", 167 dev_err(&port->dev, "%s - no more urbs?\n",
168 __FUNCTION__); 168 __func__);
169 result = -ENOMEM; 169 result = -ENOMEM;
170 goto errout; 170 goto errout;
171 } 171 }
@@ -180,7 +180,7 @@ static int airprime_open(struct usb_serial_port *port, struct file *filp)
180 kfree(buffer); 180 kfree(buffer);
181 dev_err(&port->dev, 181 dev_err(&port->dev,
182 "%s - failed submitting read urb %d for port %d, error %d\n", 182 "%s - failed submitting read urb %d for port %d, error %d\n",
183 __FUNCTION__, i, port->number, result); 183 __func__, i, port->number, result);
184 goto errout; 184 goto errout;
185 } 185 }
186 /* remember this urb so we can kill it when the port is closed */ 186 /* remember this urb so we can kill it when the port is closed */
@@ -212,7 +212,7 @@ static void airprime_close(struct usb_serial_port *port, struct file * filp)
212 struct airprime_private *priv = usb_get_serial_port_data(port); 212 struct airprime_private *priv = usb_get_serial_port_data(port);
213 int i; 213 int i;
214 214
215 dbg("%s - port %d", __FUNCTION__, port->number); 215 dbg("%s - port %d", __func__, port->number);
216 216
217 priv->rts_state = 0; 217 priv->rts_state = 0;
218 priv->dtr_state = 0; 218 priv->dtr_state = 0;
@@ -242,12 +242,12 @@ static int airprime_write(struct usb_serial_port *port,
242 unsigned char *buffer; 242 unsigned char *buffer;
243 unsigned long flags; 243 unsigned long flags;
244 int status; 244 int status;
245 dbg("%s - port %d", __FUNCTION__, port->number); 245 dbg("%s - port %d", __func__, port->number);
246 246
247 spin_lock_irqsave(&priv->lock, flags); 247 spin_lock_irqsave(&priv->lock, flags);
248 if (priv->outstanding_urbs > NUM_WRITE_URBS) { 248 if (priv->outstanding_urbs > NUM_WRITE_URBS) {
249 spin_unlock_irqrestore(&priv->lock, flags); 249 spin_unlock_irqrestore(&priv->lock, flags);
250 dbg("%s - write limit hit\n", __FUNCTION__); 250 dbg("%s - write limit hit\n", __func__);
251 return 0; 251 return 0;
252 } 252 }
253 spin_unlock_irqrestore(&priv->lock, flags); 253 spin_unlock_irqrestore(&priv->lock, flags);
@@ -264,7 +264,7 @@ static int airprime_write(struct usb_serial_port *port,
264 } 264 }
265 memcpy (buffer, buf, count); 265 memcpy (buffer, buf, count);
266 266
267 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count, buffer); 267 usb_serial_debug_data(debug, &port->dev, __func__, count, buffer);
268 268
269 usb_fill_bulk_urb(urb, serial->dev, 269 usb_fill_bulk_urb(urb, serial->dev,
270 usb_sndbulkpipe(serial->dev, 270 usb_sndbulkpipe(serial->dev,
@@ -277,7 +277,7 @@ static int airprime_write(struct usb_serial_port *port,
277 if (status) { 277 if (status) {
278 dev_err(&port->dev, 278 dev_err(&port->dev,
279 "%s - usb_submit_urb(write bulk) failed with status = %d\n", 279 "%s - usb_submit_urb(write bulk) failed with status = %d\n",
280 __FUNCTION__, status); 280 __func__, status);
281 count = status; 281 count = status;
282 kfree (buffer); 282 kfree (buffer);
283 } else { 283 } else {
@@ -306,9 +306,6 @@ static struct usb_serial_driver airprime_device = {
306 }, 306 },
307 .usb_driver = &airprime_driver, 307 .usb_driver = &airprime_driver,
308 .id_table = id_table, 308 .id_table = id_table,
309 .num_interrupt_in = NUM_DONT_CARE,
310 .num_bulk_in = NUM_DONT_CARE,
311 .num_bulk_out = NUM_DONT_CARE,
312 .open = airprime_open, 309 .open = airprime_open,
313 .close = airprime_close, 310 .close = airprime_close,
314 .write = airprime_write, 311 .write = airprime_write,
@@ -331,7 +328,7 @@ static int __init airprime_init(void)
331 328
332static void __exit airprime_exit(void) 329static void __exit airprime_exit(void)
333{ 330{
334 dbg("%s", __FUNCTION__); 331 dbg("%s", __func__);
335 332
336 usb_deregister(&airprime_driver); 333 usb_deregister(&airprime_driver);
337 usb_serial_deregister(&airprime_device); 334 usb_serial_deregister(&airprime_device);
diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c
index fe2bfd67ba8..599ab2e548a 100644
--- a/drivers/usb/serial/ark3116.c
+++ b/drivers/usb/serial/ark3116.c
@@ -173,7 +173,7 @@ static void ark3116_set_termios(struct usb_serial_port *port,
173 173
174 config = 0; 174 config = 0;
175 175
176 dbg("%s - port %d", __FUNCTION__, port->number); 176 dbg("%s - port %d", __func__, port->number);
177 177
178 spin_lock_irqsave(&priv->lock, flags); 178 spin_lock_irqsave(&priv->lock, flags);
179 if (!priv->termios_initialized) { 179 if (!priv->termios_initialized) {
@@ -192,6 +192,7 @@ static void ark3116_set_termios(struct usb_serial_port *port,
192 buf = kmalloc(1, GFP_KERNEL); 192 buf = kmalloc(1, GFP_KERNEL);
193 if (!buf) { 193 if (!buf) {
194 dbg("error kmalloc"); 194 dbg("error kmalloc");
195 *port->tty->termios = *old_termios;
195 return; 196 return;
196 } 197 }
197 198
@@ -323,7 +324,7 @@ static int ark3116_open(struct usb_serial_port *port, struct file *filp)
323 char *buf; 324 char *buf;
324 int result = 0; 325 int result = 0;
325 326
326 dbg("%s - port %d", __FUNCTION__, port->number); 327 dbg("%s - port %d", __func__, port->number);
327 328
328 buf = kmalloc(1, GFP_KERNEL); 329 buf = kmalloc(1, GFP_KERNEL);
329 if (!buf) { 330 if (!buf) {
@@ -395,7 +396,7 @@ static int ark3116_ioctl(struct usb_serial_port *port, struct file *file,
395 return -EFAULT; 396 return -EFAULT;
396 return 0; 397 return 0;
397 default: 398 default:
398 dbg("%s cmd 0x%04x not supported", __FUNCTION__, cmd); 399 dbg("%s cmd 0x%04x not supported", __func__, cmd);
399 break; 400 break;
400 } 401 }
401 402
@@ -447,9 +448,6 @@ static struct usb_serial_driver ark3116_device = {
447 }, 448 },
448 .id_table = id_table, 449 .id_table = id_table,
449 .usb_driver = &ark3116_driver, 450 .usb_driver = &ark3116_driver,
450 .num_interrupt_in = 1,
451 .num_bulk_in = 1,
452 .num_bulk_out = 1,
453 .num_ports = 1, 451 .num_ports = 1,
454 .attach = ark3116_attach, 452 .attach = ark3116_attach,
455 .set_termios = ark3116_set_termios, 453 .set_termios = ark3116_set_termios,
diff --git a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c
index df0a2b3b029..0a322fc53d6 100644
--- a/drivers/usb/serial/belkin_sa.c
+++ b/drivers/usb/serial/belkin_sa.c
@@ -128,9 +128,6 @@ static struct usb_serial_driver belkin_device = {
128 .description = "Belkin / Peracom / GoHubs USB Serial Adapter", 128 .description = "Belkin / Peracom / GoHubs USB Serial Adapter",
129 .usb_driver = &belkin_driver, 129 .usb_driver = &belkin_driver,
130 .id_table = id_table_combined, 130 .id_table = id_table_combined,
131 .num_interrupt_in = 1,
132 .num_bulk_in = 1,
133 .num_bulk_out = 1,
134 .num_ports = 1, 131 .num_ports = 1,
135 .open = belkin_sa_open, 132 .open = belkin_sa_open,
136 .close = belkin_sa_close, 133 .close = belkin_sa_close,
@@ -198,7 +195,7 @@ static void belkin_sa_shutdown (struct usb_serial *serial)
198 struct belkin_sa_private *priv; 195 struct belkin_sa_private *priv;
199 int i; 196 int i;
200 197
201 dbg ("%s", __FUNCTION__); 198 dbg ("%s", __func__);
202 199
203 /* stop reads and writes on all ports */ 200 /* stop reads and writes on all ports */
204 for (i=0; i < serial->num_ports; ++i) { 201 for (i=0; i < serial->num_ports; ++i) {
@@ -213,7 +210,7 @@ static int belkin_sa_open (struct usb_serial_port *port, struct file *filp)
213{ 210{
214 int retval = 0; 211 int retval = 0;
215 212
216 dbg("%s port %d", __FUNCTION__, port->number); 213 dbg("%s port %d", __func__, port->number);
217 214
218 /*Start reading from the device*/ 215 /*Start reading from the device*/
219 /* TODO: Look at possibility of submitting multiple URBs to device to 216 /* TODO: Look at possibility of submitting multiple URBs to device to
@@ -240,7 +237,7 @@ exit:
240 237
241static void belkin_sa_close (struct usb_serial_port *port, struct file *filp) 238static void belkin_sa_close (struct usb_serial_port *port, struct file *filp)
242{ 239{
243 dbg("%s port %d", __FUNCTION__, port->number); 240 dbg("%s port %d", __func__, port->number);
244 241
245 /* shutdown our bulk reads and writes */ 242 /* shutdown our bulk reads and writes */
246 usb_kill_urb(port->write_urb); 243 usb_kill_urb(port->write_urb);
@@ -251,7 +248,7 @@ static void belkin_sa_close (struct usb_serial_port *port, struct file *filp)
251 248
252static void belkin_sa_read_int_callback (struct urb *urb) 249static void belkin_sa_read_int_callback (struct urb *urb)
253{ 250{
254 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 251 struct usb_serial_port *port = urb->context;
255 struct belkin_sa_private *priv; 252 struct belkin_sa_private *priv;
256 unsigned char *data = urb->transfer_buffer; 253 unsigned char *data = urb->transfer_buffer;
257 int retval; 254 int retval;
@@ -267,15 +264,15 @@ static void belkin_sa_read_int_callback (struct urb *urb)
267 case -ESHUTDOWN: 264 case -ESHUTDOWN:
268 /* this urb is terminated, clean up */ 265 /* this urb is terminated, clean up */
269 dbg("%s - urb shutting down with status: %d", 266 dbg("%s - urb shutting down with status: %d",
270 __FUNCTION__, status); 267 __func__, status);
271 return; 268 return;
272 default: 269 default:
273 dbg("%s - nonzero urb status received: %d", 270 dbg("%s - nonzero urb status received: %d",
274 __FUNCTION__, status); 271 __func__, status);
275 goto exit; 272 goto exit;
276 } 273 }
277 274
278 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, urb->actual_length, data); 275 usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data);
279 276
280 /* Handle known interrupt data */ 277 /* Handle known interrupt data */
281 /* ignore data[0] and data[1] */ 278 /* ignore data[0] and data[1] */
@@ -334,7 +331,7 @@ exit:
334 retval = usb_submit_urb (urb, GFP_ATOMIC); 331 retval = usb_submit_urb (urb, GFP_ATOMIC);
335 if (retval) 332 if (retval)
336 err ("%s - usb_submit_urb failed with result %d", 333 err ("%s - usb_submit_urb failed with result %d",
337 __FUNCTION__, retval); 334 __func__, retval);
338} 335}
339 336
340static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios *old_termios) 337static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios *old_termios)
@@ -481,7 +478,7 @@ static int belkin_sa_tiocmget (struct usb_serial_port *port, struct file *file)
481 unsigned long control_state; 478 unsigned long control_state;
482 unsigned long flags; 479 unsigned long flags;
483 480
484 dbg("%s", __FUNCTION__); 481 dbg("%s", __func__);
485 482
486 spin_lock_irqsave(&priv->lock, flags); 483 spin_lock_irqsave(&priv->lock, flags);
487 control_state = priv->control_state; 484 control_state = priv->control_state;
@@ -502,7 +499,7 @@ static int belkin_sa_tiocmset (struct usb_serial_port *port, struct file *file,
502 int rts = 0; 499 int rts = 0;
503 int dtr = 0; 500 int dtr = 0;
504 501
505 dbg("%s", __FUNCTION__); 502 dbg("%s", __func__);
506 503
507 spin_lock_irqsave(&priv->lock, flags); 504 spin_lock_irqsave(&priv->lock, flags);
508 control_state = priv->control_state; 505 control_state = priv->control_state;
diff --git a/drivers/usb/serial/ch341.c b/drivers/usb/serial/ch341.c
index 42582d49b69..d947d955bce 100644
--- a/drivers/usb/serial/ch341.c
+++ b/drivers/usb/serial/ch341.c
@@ -318,9 +318,6 @@ static struct usb_serial_driver ch341_device = {
318 }, 318 },
319 .id_table = id_table, 319 .id_table = id_table,
320 .usb_driver = &ch341_driver, 320 .usb_driver = &ch341_driver,
321 .num_interrupt_in = NUM_DONT_CARE,
322 .num_bulk_in = 1,
323 .num_bulk_out = 1,
324 .num_ports = 1, 321 .num_ports = 1,
325 .open = ch341_open, 322 .open = ch341_open,
326 .set_termios = ch341_set_termios, 323 .set_termios = ch341_set_termios,
diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
index 66ce30c1b75..201184c3fb8 100644
--- a/drivers/usb/serial/console.c
+++ b/drivers/usb/serial/console.c
@@ -67,7 +67,7 @@ static int usb_console_setup(struct console *co, char *options)
67 struct tty_struct *tty = NULL; 67 struct tty_struct *tty = NULL;
68 struct ktermios *termios = NULL, dummy; 68 struct ktermios *termios = NULL, dummy;
69 69
70 dbg ("%s", __FUNCTION__); 70 dbg ("%s", __func__);
71 71
72 if (options) { 72 if (options) {
73 baud = simple_strtoul(options, NULL, 10); 73 baud = simple_strtoul(options, NULL, 10);
@@ -225,10 +225,10 @@ static void usb_console_write(struct console *co, const char *buf, unsigned coun
225 if (count == 0) 225 if (count == 0)
226 return; 226 return;
227 227
228 dbg("%s - port %d, %d byte(s)", __FUNCTION__, port->number, count); 228 dbg("%s - port %d, %d byte(s)", __func__, port->number, count);
229 229
230 if (!port->open_count) { 230 if (!port->open_count) {
231 dbg ("%s - port not opened", __FUNCTION__); 231 dbg ("%s - port not opened", __func__);
232 return; 232 return;
233 } 233 }
234 234
@@ -248,7 +248,7 @@ static void usb_console_write(struct console *co, const char *buf, unsigned coun
248 retval = serial->type->write(port, buf, i); 248 retval = serial->type->write(port, buf, i);
249 else 249 else
250 retval = usb_serial_generic_write(port, buf, i); 250 retval = usb_serial_generic_write(port, buf, i);
251 dbg("%s - return value : %d", __FUNCTION__, retval); 251 dbg("%s - return value : %d", __func__, retval);
252 if (lf) { 252 if (lf) {
253 /* append CR after LF */ 253 /* append CR after LF */
254 unsigned char cr = 13; 254 unsigned char cr = 13;
@@ -256,7 +256,7 @@ static void usb_console_write(struct console *co, const char *buf, unsigned coun
256 retval = serial->type->write(port, &cr, 1); 256 retval = serial->type->write(port, &cr, 1);
257 else 257 else
258 retval = usb_serial_generic_write(port, &cr, 1); 258 retval = usb_serial_generic_write(port, &cr, 1);
259 dbg("%s - return value : %d", __FUNCTION__, retval); 259 dbg("%s - return value : %d", __func__, retval);
260 } 260 }
261 buf += i; 261 buf += i;
262 count -= i; 262 count -= i;
diff --git a/drivers/usb/serial/cp2101.c b/drivers/usb/serial/cp2101.c
index 324bb61d68f..dc0ea08ed23 100644
--- a/drivers/usb/serial/cp2101.c
+++ b/drivers/usb/serial/cp2101.c
@@ -53,9 +53,11 @@ static void cp2101_shutdown(struct usb_serial*);
53static int debug; 53static int debug;
54 54
55static struct usb_device_id id_table [] = { 55static struct usb_device_id id_table [] = {
56 { USB_DEVICE(0x0489, 0xE000) }, /* Pirelli Broadband S.p.A, DP-L10 SIP/GSM Mobile */
56 { USB_DEVICE(0x08e6, 0x5501) }, /* Gemalto Prox-PU/CU contactless smartcard reader */ 57 { USB_DEVICE(0x08e6, 0x5501) }, /* Gemalto Prox-PU/CU contactless smartcard reader */
57 { USB_DEVICE(0x0FCF, 0x1003) }, /* Dynastream ANT development board */ 58 { USB_DEVICE(0x0FCF, 0x1003) }, /* Dynastream ANT development board */
58 { USB_DEVICE(0x0FCF, 0x1004) }, /* Dynastream ANT2USB */ 59 { USB_DEVICE(0x0FCF, 0x1004) }, /* Dynastream ANT2USB */
60 { USB_DEVICE(0x0FCF, 0x1006) }, /* Dynastream ANT development board */
59 { USB_DEVICE(0x10A6, 0xAA26) }, /* Knock-off DCU-11 cable */ 61 { USB_DEVICE(0x10A6, 0xAA26) }, /* Knock-off DCU-11 cable */
60 { USB_DEVICE(0x10AB, 0x10C5) }, /* Siemens MC60 Cable */ 62 { USB_DEVICE(0x10AB, 0x10C5) }, /* Siemens MC60 Cable */
61 { USB_DEVICE(0x10B5, 0xAC70) }, /* Nokia CA-42 USB */ 63 { USB_DEVICE(0x10B5, 0xAC70) }, /* Nokia CA-42 USB */
@@ -71,6 +73,7 @@ static struct usb_device_id id_table [] = {
71 { USB_DEVICE(0x10C4, 0x814A) }, /* West Mountain Radio RIGblaster P&P */ 73 { USB_DEVICE(0x10C4, 0x814A) }, /* West Mountain Radio RIGblaster P&P */
72 { USB_DEVICE(0x10C4, 0x814B) }, /* West Mountain Radio RIGtalk */ 74 { USB_DEVICE(0x10C4, 0x814B) }, /* West Mountain Radio RIGtalk */
73 { USB_DEVICE(0x10C4, 0x815E) }, /* Helicomm IP-Link 1220-DVM */ 75 { USB_DEVICE(0x10C4, 0x815E) }, /* Helicomm IP-Link 1220-DVM */
76 { USB_DEVICE(0x10C4, 0x81AC) }, /* MSD Dash Hawk */
74 { USB_DEVICE(0x10C4, 0x81C8) }, /* Lipowsky Industrie Elektronik GmbH, Baby-JTAG */ 77 { USB_DEVICE(0x10C4, 0x81C8) }, /* Lipowsky Industrie Elektronik GmbH, Baby-JTAG */
75 { USB_DEVICE(0x10C4, 0x81E2) }, /* Lipowsky Industrie Elektronik GmbH, Baby-LIN */ 78 { USB_DEVICE(0x10C4, 0x81E2) }, /* Lipowsky Industrie Elektronik GmbH, Baby-LIN */
76 { USB_DEVICE(0x10C4, 0x81E7) }, /* Aerocomm Radio */ 79 { USB_DEVICE(0x10C4, 0x81E7) }, /* Aerocomm Radio */
@@ -106,9 +109,6 @@ static struct usb_serial_driver cp2101_device = {
106 }, 109 },
107 .usb_driver = &cp2101_driver, 110 .usb_driver = &cp2101_driver,
108 .id_table = id_table, 111 .id_table = id_table,
109 .num_interrupt_in = 0,
110 .num_bulk_in = NUM_DONT_CARE,
111 .num_bulk_out = NUM_DONT_CARE,
112 .num_ports = 1, 112 .num_ports = 1,
113 .open = cp2101_open, 113 .open = cp2101_open,
114 .close = cp2101_close, 114 .close = cp2101_close,
@@ -193,7 +193,7 @@ static int cp2101_get_config(struct usb_serial_port* port, u8 request,
193 193
194 buf = kcalloc(length, sizeof(__le32), GFP_KERNEL); 194 buf = kcalloc(length, sizeof(__le32), GFP_KERNEL);
195 if (!buf) { 195 if (!buf) {
196 dev_err(&port->dev, "%s - out of memory.\n", __FUNCTION__); 196 dev_err(&port->dev, "%s - out of memory.\n", __func__);
197 return -ENOMEM; 197 return -ENOMEM;
198 } 198 }
199 199
@@ -214,7 +214,7 @@ static int cp2101_get_config(struct usb_serial_port* port, u8 request,
214 if (result != size) { 214 if (result != size) {
215 dev_err(&port->dev, "%s - Unable to send config request, " 215 dev_err(&port->dev, "%s - Unable to send config request, "
216 "request=0x%x size=%d result=%d\n", 216 "request=0x%x size=%d result=%d\n",
217 __FUNCTION__, request, size, result); 217 __func__, request, size, result);
218 return -EPROTO; 218 return -EPROTO;
219 } 219 }
220 220
@@ -240,7 +240,7 @@ static int cp2101_set_config(struct usb_serial_port* port, u8 request,
240 buf = kmalloc(length * sizeof(__le32), GFP_KERNEL); 240 buf = kmalloc(length * sizeof(__le32), GFP_KERNEL);
241 if (!buf) { 241 if (!buf) {
242 dev_err(&port->dev, "%s - out of memory.\n", 242 dev_err(&port->dev, "%s - out of memory.\n",
243 __FUNCTION__); 243 __func__);
244 return -ENOMEM; 244 return -ENOMEM;
245 } 245 }
246 246
@@ -265,7 +265,7 @@ static int cp2101_set_config(struct usb_serial_port* port, u8 request,
265 if ((size > 2 && result != size) || result < 0) { 265 if ((size > 2 && result != size) || result < 0) {
266 dev_err(&port->dev, "%s - Unable to send request, " 266 dev_err(&port->dev, "%s - Unable to send request, "
267 "request=0x%x size=%d result=%d\n", 267 "request=0x%x size=%d result=%d\n",
268 __FUNCTION__, request, size, result); 268 __func__, request, size, result);
269 return -EPROTO; 269 return -EPROTO;
270 } 270 }
271 271
@@ -293,11 +293,11 @@ static int cp2101_open (struct usb_serial_port *port, struct file *filp)
293 struct usb_serial *serial = port->serial; 293 struct usb_serial *serial = port->serial;
294 int result; 294 int result;
295 295
296 dbg("%s - port %d", __FUNCTION__, port->number); 296 dbg("%s - port %d", __func__, port->number);
297 297
298 if (cp2101_set_config_single(port, CP2101_UART, UART_ENABLE)) { 298 if (cp2101_set_config_single(port, CP2101_UART, UART_ENABLE)) {
299 dev_err(&port->dev, "%s - Unable to enable UART\n", 299 dev_err(&port->dev, "%s - Unable to enable UART\n",
300 __FUNCTION__); 300 __func__);
301 return -EPROTO; 301 return -EPROTO;
302 } 302 }
303 303
@@ -312,7 +312,7 @@ static int cp2101_open (struct usb_serial_port *port, struct file *filp)
312 result = usb_submit_urb(port->read_urb, GFP_KERNEL); 312 result = usb_submit_urb(port->read_urb, GFP_KERNEL);
313 if (result) { 313 if (result) {
314 dev_err(&port->dev, "%s - failed resubmitting read urb, " 314 dev_err(&port->dev, "%s - failed resubmitting read urb, "
315 "error %d\n", __FUNCTION__, result); 315 "error %d\n", __func__, result);
316 return result; 316 return result;
317 } 317 }
318 318
@@ -329,7 +329,7 @@ static void cp2101_cleanup (struct usb_serial_port *port)
329{ 329{
330 struct usb_serial *serial = port->serial; 330 struct usb_serial *serial = port->serial;
331 331
332 dbg("%s - port %d", __FUNCTION__, port->number); 332 dbg("%s - port %d", __func__, port->number);
333 333
334 if (serial->dev) { 334 if (serial->dev) {
335 /* shutdown any bulk reads that might be going on */ 335 /* shutdown any bulk reads that might be going on */
@@ -342,10 +342,10 @@ static void cp2101_cleanup (struct usb_serial_port *port)
342 342
343static void cp2101_close (struct usb_serial_port *port, struct file * filp) 343static void cp2101_close (struct usb_serial_port *port, struct file * filp)
344{ 344{
345 dbg("%s - port %d", __FUNCTION__, port->number); 345 dbg("%s - port %d", __func__, port->number);
346 346
347 /* shutdown our urbs */ 347 /* shutdown our urbs */
348 dbg("%s - shutting down urbs", __FUNCTION__); 348 dbg("%s - shutting down urbs", __func__);
349 usb_kill_urb(port->write_urb); 349 usb_kill_urb(port->write_urb);
350 usb_kill_urb(port->read_urb); 350 usb_kill_urb(port->read_urb);
351 351
@@ -367,10 +367,10 @@ static void cp2101_get_termios (struct usb_serial_port *port)
367 int baud; 367 int baud;
368 int bits; 368 int bits;
369 369
370 dbg("%s - port %d", __FUNCTION__, port->number); 370 dbg("%s - port %d", __func__, port->number);
371 371
372 if (!port->tty || !port->tty->termios) { 372 if (!port->tty || !port->tty->termios) {
373 dbg("%s - no tty structures", __FUNCTION__); 373 dbg("%s - no tty structures", __func__);
374 return; 374 return;
375 } 375 }
376 376
@@ -379,7 +379,7 @@ static void cp2101_get_termios (struct usb_serial_port *port)
379 if (baud) 379 if (baud)
380 baud = BAUD_RATE_GEN_FREQ / baud; 380 baud = BAUD_RATE_GEN_FREQ / baud;
381 381
382 dbg("%s - baud rate = %d", __FUNCTION__, baud); 382 dbg("%s - baud rate = %d", __func__, baud);
383 383
384 tty_encode_baud_rate(port->tty, baud, baud); 384 tty_encode_baud_rate(port->tty, baud, baud);
385 cflag = port->tty->termios->c_cflag; 385 cflag = port->tty->termios->c_cflag;
@@ -388,24 +388,24 @@ static void cp2101_get_termios (struct usb_serial_port *port)
388 cflag &= ~CSIZE; 388 cflag &= ~CSIZE;
389 switch(bits & BITS_DATA_MASK) { 389 switch(bits & BITS_DATA_MASK) {
390 case BITS_DATA_5: 390 case BITS_DATA_5:
391 dbg("%s - data bits = 5", __FUNCTION__); 391 dbg("%s - data bits = 5", __func__);
392 cflag |= CS5; 392 cflag |= CS5;
393 break; 393 break;
394 case BITS_DATA_6: 394 case BITS_DATA_6:
395 dbg("%s - data bits = 6", __FUNCTION__); 395 dbg("%s - data bits = 6", __func__);
396 cflag |= CS6; 396 cflag |= CS6;
397 break; 397 break;
398 case BITS_DATA_7: 398 case BITS_DATA_7:
399 dbg("%s - data bits = 7", __FUNCTION__); 399 dbg("%s - data bits = 7", __func__);
400 cflag |= CS7; 400 cflag |= CS7;
401 break; 401 break;
402 case BITS_DATA_8: 402 case BITS_DATA_8:
403 dbg("%s - data bits = 8", __FUNCTION__); 403 dbg("%s - data bits = 8", __func__);
404 cflag |= CS8; 404 cflag |= CS8;
405 break; 405 break;
406 case BITS_DATA_9: 406 case BITS_DATA_9:
407 dbg("%s - data bits = 9 (not supported, " 407 dbg("%s - data bits = 9 (not supported, "
408 "using 8 data bits)", __FUNCTION__); 408 "using 8 data bits)", __func__);
409 cflag |= CS8; 409 cflag |= CS8;
410 bits &= ~BITS_DATA_MASK; 410 bits &= ~BITS_DATA_MASK;
411 bits |= BITS_DATA_8; 411 bits |= BITS_DATA_8;
@@ -413,7 +413,7 @@ static void cp2101_get_termios (struct usb_serial_port *port)
413 break; 413 break;
414 default: 414 default:
415 dbg("%s - Unknown number of data bits, " 415 dbg("%s - Unknown number of data bits, "
416 "using 8", __FUNCTION__); 416 "using 8", __func__);
417 cflag |= CS8; 417 cflag |= CS8;
418 bits &= ~BITS_DATA_MASK; 418 bits &= ~BITS_DATA_MASK;
419 bits |= BITS_DATA_8; 419 bits |= BITS_DATA_8;
@@ -423,35 +423,35 @@ static void cp2101_get_termios (struct usb_serial_port *port)
423 423
424 switch(bits & BITS_PARITY_MASK) { 424 switch(bits & BITS_PARITY_MASK) {
425 case BITS_PARITY_NONE: 425 case BITS_PARITY_NONE:
426 dbg("%s - parity = NONE", __FUNCTION__); 426 dbg("%s - parity = NONE", __func__);
427 cflag &= ~PARENB; 427 cflag &= ~PARENB;
428 break; 428 break;
429 case BITS_PARITY_ODD: 429 case BITS_PARITY_ODD:
430 dbg("%s - parity = ODD", __FUNCTION__); 430 dbg("%s - parity = ODD", __func__);
431 cflag |= (PARENB|PARODD); 431 cflag |= (PARENB|PARODD);
432 break; 432 break;
433 case BITS_PARITY_EVEN: 433 case BITS_PARITY_EVEN:
434 dbg("%s - parity = EVEN", __FUNCTION__); 434 dbg("%s - parity = EVEN", __func__);
435 cflag &= ~PARODD; 435 cflag &= ~PARODD;
436 cflag |= PARENB; 436 cflag |= PARENB;
437 break; 437 break;
438 case BITS_PARITY_MARK: 438 case BITS_PARITY_MARK:
439 dbg("%s - parity = MARK (not supported, " 439 dbg("%s - parity = MARK (not supported, "
440 "disabling parity)", __FUNCTION__); 440 "disabling parity)", __func__);
441 cflag &= ~PARENB; 441 cflag &= ~PARENB;
442 bits &= ~BITS_PARITY_MASK; 442 bits &= ~BITS_PARITY_MASK;
443 cp2101_set_config(port, CP2101_BITS, &bits, 2); 443 cp2101_set_config(port, CP2101_BITS, &bits, 2);
444 break; 444 break;
445 case BITS_PARITY_SPACE: 445 case BITS_PARITY_SPACE:
446 dbg("%s - parity = SPACE (not supported, " 446 dbg("%s - parity = SPACE (not supported, "
447 "disabling parity)", __FUNCTION__); 447 "disabling parity)", __func__);
448 cflag &= ~PARENB; 448 cflag &= ~PARENB;
449 bits &= ~BITS_PARITY_MASK; 449 bits &= ~BITS_PARITY_MASK;
450 cp2101_set_config(port, CP2101_BITS, &bits, 2); 450 cp2101_set_config(port, CP2101_BITS, &bits, 2);
451 break; 451 break;
452 default: 452 default:
453 dbg("%s - Unknown parity mode, " 453 dbg("%s - Unknown parity mode, "
454 "disabling parity", __FUNCTION__); 454 "disabling parity", __func__);
455 cflag &= ~PARENB; 455 cflag &= ~PARENB;
456 bits &= ~BITS_PARITY_MASK; 456 bits &= ~BITS_PARITY_MASK;
457 cp2101_set_config(port, CP2101_BITS, &bits, 2); 457 cp2101_set_config(port, CP2101_BITS, &bits, 2);
@@ -461,21 +461,21 @@ static void cp2101_get_termios (struct usb_serial_port *port)
461 cflag &= ~CSTOPB; 461 cflag &= ~CSTOPB;
462 switch(bits & BITS_STOP_MASK) { 462 switch(bits & BITS_STOP_MASK) {
463 case BITS_STOP_1: 463 case BITS_STOP_1:
464 dbg("%s - stop bits = 1", __FUNCTION__); 464 dbg("%s - stop bits = 1", __func__);
465 break; 465 break;
466 case BITS_STOP_1_5: 466 case BITS_STOP_1_5:
467 dbg("%s - stop bits = 1.5 (not supported, " 467 dbg("%s - stop bits = 1.5 (not supported, "
468 "using 1 stop bit)", __FUNCTION__); 468 "using 1 stop bit)", __func__);
469 bits &= ~BITS_STOP_MASK; 469 bits &= ~BITS_STOP_MASK;
470 cp2101_set_config(port, CP2101_BITS, &bits, 2); 470 cp2101_set_config(port, CP2101_BITS, &bits, 2);
471 break; 471 break;
472 case BITS_STOP_2: 472 case BITS_STOP_2:
473 dbg("%s - stop bits = 2", __FUNCTION__); 473 dbg("%s - stop bits = 2", __func__);
474 cflag |= CSTOPB; 474 cflag |= CSTOPB;
475 break; 475 break;
476 default: 476 default:
477 dbg("%s - Unknown number of stop bits, " 477 dbg("%s - Unknown number of stop bits, "
478 "using 1 stop bit", __FUNCTION__); 478 "using 1 stop bit", __func__);
479 bits &= ~BITS_STOP_MASK; 479 bits &= ~BITS_STOP_MASK;
480 cp2101_set_config(port, CP2101_BITS, &bits, 2); 480 cp2101_set_config(port, CP2101_BITS, &bits, 2);
481 break; 481 break;
@@ -483,10 +483,10 @@ static void cp2101_get_termios (struct usb_serial_port *port)
483 483
484 cp2101_get_config(port, CP2101_MODEMCTL, modem_ctl, 16); 484 cp2101_get_config(port, CP2101_MODEMCTL, modem_ctl, 16);
485 if (modem_ctl[0] & 0x0008) { 485 if (modem_ctl[0] & 0x0008) {
486 dbg("%s - flow control = CRTSCTS", __FUNCTION__); 486 dbg("%s - flow control = CRTSCTS", __func__);
487 cflag |= CRTSCTS; 487 cflag |= CRTSCTS;
488 } else { 488 } else {
489 dbg("%s - flow control = NONE", __FUNCTION__); 489 dbg("%s - flow control = NONE", __func__);
490 cflag &= ~CRTSCTS; 490 cflag &= ~CRTSCTS;
491 } 491 }
492 492
@@ -500,10 +500,10 @@ static void cp2101_set_termios (struct usb_serial_port *port,
500 int baud=0, bits; 500 int baud=0, bits;
501 unsigned int modem_ctl[4]; 501 unsigned int modem_ctl[4];
502 502
503 dbg("%s - port %d", __FUNCTION__, port->number); 503 dbg("%s - port %d", __func__, port->number);
504 504
505 if (!port->tty || !port->tty->termios) { 505 if (!port->tty || !port->tty->termios) {
506 dbg("%s - no tty structures", __FUNCTION__); 506 dbg("%s - no tty structures", __func__);
507 return; 507 return;
508 } 508 }
509 port->tty->termios->c_cflag &= ~CMSPAR; 509 port->tty->termios->c_cflag &= ~CMSPAR;
@@ -542,7 +542,7 @@ static void cp2101_set_termios (struct usb_serial_port *port,
542 } 542 }
543 543
544 if (baud) { 544 if (baud) {
545 dbg("%s - Setting baud rate to %d baud", __FUNCTION__, 545 dbg("%s - Setting baud rate to %d baud", __func__,
546 baud); 546 baud);
547 if (cp2101_set_config_single(port, CP2101_BAUDRATE, 547 if (cp2101_set_config_single(port, CP2101_BAUDRATE,
548 (BAUD_RATE_GEN_FREQ / baud))) { 548 (BAUD_RATE_GEN_FREQ / baud))) {
@@ -562,23 +562,23 @@ static void cp2101_set_termios (struct usb_serial_port *port,
562 switch (cflag & CSIZE) { 562 switch (cflag & CSIZE) {
563 case CS5: 563 case CS5:
564 bits |= BITS_DATA_5; 564 bits |= BITS_DATA_5;
565 dbg("%s - data bits = 5", __FUNCTION__); 565 dbg("%s - data bits = 5", __func__);
566 break; 566 break;
567 case CS6: 567 case CS6:
568 bits |= BITS_DATA_6; 568 bits |= BITS_DATA_6;
569 dbg("%s - data bits = 6", __FUNCTION__); 569 dbg("%s - data bits = 6", __func__);
570 break; 570 break;
571 case CS7: 571 case CS7:
572 bits |= BITS_DATA_7; 572 bits |= BITS_DATA_7;
573 dbg("%s - data bits = 7", __FUNCTION__); 573 dbg("%s - data bits = 7", __func__);
574 break; 574 break;
575 case CS8: 575 case CS8:
576 bits |= BITS_DATA_8; 576 bits |= BITS_DATA_8;
577 dbg("%s - data bits = 8", __FUNCTION__); 577 dbg("%s - data bits = 8", __func__);
578 break; 578 break;
579 /*case CS9: 579 /*case CS9:
580 bits |= BITS_DATA_9; 580 bits |= BITS_DATA_9;
581 dbg("%s - data bits = 9", __FUNCTION__); 581 dbg("%s - data bits = 9", __func__);
582 break;*/ 582 break;*/
583 default: 583 default:
584 dev_err(&port->dev, "cp2101 driver does not " 584 dev_err(&port->dev, "cp2101 driver does not "
@@ -598,10 +598,10 @@ static void cp2101_set_termios (struct usb_serial_port *port,
598 if (cflag & PARENB) { 598 if (cflag & PARENB) {
599 if (cflag & PARODD) { 599 if (cflag & PARODD) {
600 bits |= BITS_PARITY_ODD; 600 bits |= BITS_PARITY_ODD;
601 dbg("%s - parity = ODD", __FUNCTION__); 601 dbg("%s - parity = ODD", __func__);
602 } else { 602 } else {
603 bits |= BITS_PARITY_EVEN; 603 bits |= BITS_PARITY_EVEN;
604 dbg("%s - parity = EVEN", __FUNCTION__); 604 dbg("%s - parity = EVEN", __func__);
605 } 605 }
606 } 606 }
607 if (cp2101_set_config(port, CP2101_BITS, &bits, 2)) 607 if (cp2101_set_config(port, CP2101_BITS, &bits, 2))
@@ -614,10 +614,10 @@ static void cp2101_set_termios (struct usb_serial_port *port,
614 bits &= ~BITS_STOP_MASK; 614 bits &= ~BITS_STOP_MASK;
615 if (cflag & CSTOPB) { 615 if (cflag & CSTOPB) {
616 bits |= BITS_STOP_2; 616 bits |= BITS_STOP_2;
617 dbg("%s - stop bits = 2", __FUNCTION__); 617 dbg("%s - stop bits = 2", __func__);
618 } else { 618 } else {
619 bits |= BITS_STOP_1; 619 bits |= BITS_STOP_1;
620 dbg("%s - stop bits = 1", __FUNCTION__); 620 dbg("%s - stop bits = 1", __func__);
621 } 621 }
622 if (cp2101_set_config(port, CP2101_BITS, &bits, 2)) 622 if (cp2101_set_config(port, CP2101_BITS, &bits, 2))
623 dev_err(&port->dev, "Number of stop bits requested " 623 dev_err(&port->dev, "Number of stop bits requested "
@@ -627,23 +627,23 @@ static void cp2101_set_termios (struct usb_serial_port *port,
627 if ((cflag & CRTSCTS) != (old_cflag & CRTSCTS)) { 627 if ((cflag & CRTSCTS) != (old_cflag & CRTSCTS)) {
628 cp2101_get_config(port, CP2101_MODEMCTL, modem_ctl, 16); 628 cp2101_get_config(port, CP2101_MODEMCTL, modem_ctl, 16);
629 dbg("%s - read modem controls = 0x%.4x 0x%.4x 0x%.4x 0x%.4x", 629 dbg("%s - read modem controls = 0x%.4x 0x%.4x 0x%.4x 0x%.4x",
630 __FUNCTION__, modem_ctl[0], modem_ctl[1], 630 __func__, modem_ctl[0], modem_ctl[1],
631 modem_ctl[2], modem_ctl[3]); 631 modem_ctl[2], modem_ctl[3]);
632 632
633 if (cflag & CRTSCTS) { 633 if (cflag & CRTSCTS) {
634 modem_ctl[0] &= ~0x7B; 634 modem_ctl[0] &= ~0x7B;
635 modem_ctl[0] |= 0x09; 635 modem_ctl[0] |= 0x09;
636 modem_ctl[1] = 0x80; 636 modem_ctl[1] = 0x80;
637 dbg("%s - flow control = CRTSCTS", __FUNCTION__); 637 dbg("%s - flow control = CRTSCTS", __func__);
638 } else { 638 } else {
639 modem_ctl[0] &= ~0x7B; 639 modem_ctl[0] &= ~0x7B;
640 modem_ctl[0] |= 0x01; 640 modem_ctl[0] |= 0x01;
641 modem_ctl[1] |= 0x40; 641 modem_ctl[1] |= 0x40;
642 dbg("%s - flow control = NONE", __FUNCTION__); 642 dbg("%s - flow control = NONE", __func__);
643 } 643 }
644 644
645 dbg("%s - write modem controls = 0x%.4x 0x%.4x 0x%.4x 0x%.4x", 645 dbg("%s - write modem controls = 0x%.4x 0x%.4x 0x%.4x 0x%.4x",
646 __FUNCTION__, modem_ctl[0], modem_ctl[1], 646 __func__, modem_ctl[0], modem_ctl[1],
647 modem_ctl[2], modem_ctl[3]); 647 modem_ctl[2], modem_ctl[3]);
648 cp2101_set_config(port, CP2101_MODEMCTL, modem_ctl, 16); 648 cp2101_set_config(port, CP2101_MODEMCTL, modem_ctl, 16);
649 } 649 }
@@ -655,7 +655,7 @@ static int cp2101_tiocmset (struct usb_serial_port *port, struct file *file,
655{ 655{
656 int control = 0; 656 int control = 0;
657 657
658 dbg("%s - port %d", __FUNCTION__, port->number); 658 dbg("%s - port %d", __func__, port->number);
659 659
660 if (set & TIOCM_RTS) { 660 if (set & TIOCM_RTS) {
661 control |= CONTROL_RTS; 661 control |= CONTROL_RTS;
@@ -674,7 +674,7 @@ static int cp2101_tiocmset (struct usb_serial_port *port, struct file *file,
674 control |= CONTROL_WRITE_DTR; 674 control |= CONTROL_WRITE_DTR;
675 } 675 }
676 676
677 dbg("%s - control = 0x%.4x", __FUNCTION__, control); 677 dbg("%s - control = 0x%.4x", __func__, control);
678 678
679 return cp2101_set_config(port, CP2101_CONTROL, &control, 2); 679 return cp2101_set_config(port, CP2101_CONTROL, &control, 2);
680 680
@@ -684,7 +684,7 @@ static int cp2101_tiocmget (struct usb_serial_port *port, struct file *file)
684{ 684{
685 int control, result; 685 int control, result;
686 686
687 dbg("%s - port %d", __FUNCTION__, port->number); 687 dbg("%s - port %d", __func__, port->number);
688 688
689 cp2101_get_config(port, CP2101_CONTROL, &control, 1); 689 cp2101_get_config(port, CP2101_CONTROL, &control, 1);
690 690
@@ -695,7 +695,7 @@ static int cp2101_tiocmget (struct usb_serial_port *port, struct file *file)
695 |((control & CONTROL_RING)? TIOCM_RI : 0) 695 |((control & CONTROL_RING)? TIOCM_RI : 0)
696 |((control & CONTROL_DCD) ? TIOCM_CD : 0); 696 |((control & CONTROL_DCD) ? TIOCM_CD : 0);
697 697
698 dbg("%s - control = 0x%.2x", __FUNCTION__, control); 698 dbg("%s - control = 0x%.2x", __func__, control);
699 699
700 return result; 700 return result;
701} 701}
@@ -704,12 +704,12 @@ static void cp2101_break_ctl (struct usb_serial_port *port, int break_state)
704{ 704{
705 int state; 705 int state;
706 706
707 dbg("%s - port %d", __FUNCTION__, port->number); 707 dbg("%s - port %d", __func__, port->number);
708 if (break_state == 0) 708 if (break_state == 0)
709 state = BREAK_OFF; 709 state = BREAK_OFF;
710 else 710 else
711 state = BREAK_ON; 711 state = BREAK_ON;
712 dbg("%s - turning break %s", __FUNCTION__, 712 dbg("%s - turning break %s", __func__,
713 state==BREAK_OFF ? "off" : "on"); 713 state==BREAK_OFF ? "off" : "on");
714 cp2101_set_config(port, CP2101_BREAK, &state, 2); 714 cp2101_set_config(port, CP2101_BREAK, &state, 2);
715} 715}
@@ -725,7 +725,7 @@ static void cp2101_shutdown (struct usb_serial *serial)
725{ 725{
726 int i; 726 int i;
727 727
728 dbg("%s", __FUNCTION__); 728 dbg("%s", __func__);
729 729
730 /* Stop reads and writes on all ports */ 730 /* Stop reads and writes on all ports */
731 for (i=0; i < serial->num_ports; ++i) { 731 for (i=0; i < serial->num_ports; ++i) {
diff --git a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c
index 8d9b045aa7e..c164e2cf275 100644
--- a/drivers/usb/serial/cyberjack.c
+++ b/drivers/usb/serial/cyberjack.c
@@ -90,9 +90,6 @@ static struct usb_serial_driver cyberjack_device = {
90 .description = "Reiner SCT Cyberjack USB card reader", 90 .description = "Reiner SCT Cyberjack USB card reader",
91 .usb_driver = &cyberjack_driver, 91 .usb_driver = &cyberjack_driver,
92 .id_table = id_table, 92 .id_table = id_table,
93 .num_interrupt_in = 1,
94 .num_bulk_in = 1,
95 .num_bulk_out = 1,
96 .num_ports = 1, 93 .num_ports = 1,
97 .attach = cyberjack_startup, 94 .attach = cyberjack_startup,
98 .shutdown = cyberjack_shutdown, 95 .shutdown = cyberjack_shutdown,
@@ -119,7 +116,7 @@ static int cyberjack_startup (struct usb_serial *serial)
119 struct cyberjack_private *priv; 116 struct cyberjack_private *priv;
120 int i; 117 int i;
121 118
122 dbg("%s", __FUNCTION__); 119 dbg("%s", __func__);
123 120
124 /* allocate the private data structure */ 121 /* allocate the private data structure */
125 priv = kmalloc(sizeof(struct cyberjack_private), GFP_KERNEL); 122 priv = kmalloc(sizeof(struct cyberjack_private), GFP_KERNEL);
@@ -142,7 +139,7 @@ static int cyberjack_startup (struct usb_serial *serial)
142 GFP_KERNEL); 139 GFP_KERNEL);
143 if (result) 140 if (result)
144 err(" usb_submit_urb(read int) failed"); 141 err(" usb_submit_urb(read int) failed");
145 dbg("%s - usb_submit_urb(int urb)", __FUNCTION__); 142 dbg("%s - usb_submit_urb(int urb)", __func__);
146 } 143 }
147 144
148 return( 0 ); 145 return( 0 );
@@ -152,9 +149,9 @@ static void cyberjack_shutdown (struct usb_serial *serial)
152{ 149{
153 int i; 150 int i;
154 151
155 dbg("%s", __FUNCTION__); 152 dbg("%s", __func__);
156 153
157 for (i=0; i < serial->num_ports; ++i) { 154 for (i = 0; i < serial->num_ports; ++i) {
158 usb_kill_urb(serial->port[i]->interrupt_in_urb); 155 usb_kill_urb(serial->port[i]->interrupt_in_urb);
159 /* My special items, the standard routines free my urbs */ 156 /* My special items, the standard routines free my urbs */
160 kfree(usb_get_serial_port_data(serial->port[i])); 157 kfree(usb_get_serial_port_data(serial->port[i]));
@@ -168,9 +165,9 @@ static int cyberjack_open (struct usb_serial_port *port, struct file *filp)
168 unsigned long flags; 165 unsigned long flags;
169 int result = 0; 166 int result = 0;
170 167
171 dbg("%s - port %d", __FUNCTION__, port->number); 168 dbg("%s - port %d", __func__, port->number);
172 169
173 dbg("%s - usb_clear_halt", __FUNCTION__ ); 170 dbg("%s - usb_clear_halt", __func__ );
174 usb_clear_halt(port->serial->dev, port->write_urb->pipe); 171 usb_clear_halt(port->serial->dev, port->write_urb->pipe);
175 172
176 /* force low_latency on so that our tty_push actually forces 173 /* force low_latency on so that our tty_push actually forces
@@ -191,7 +188,7 @@ static int cyberjack_open (struct usb_serial_port *port, struct file *filp)
191 188
192static void cyberjack_close (struct usb_serial_port *port, struct file *filp) 189static void cyberjack_close (struct usb_serial_port *port, struct file *filp)
193{ 190{
194 dbg("%s - port %d", __FUNCTION__, port->number); 191 dbg("%s - port %d", __func__, port->number);
195 192
196 if (port->serial->dev) { 193 if (port->serial->dev) {
197 /* shutdown any bulk reads that might be going on */ 194 /* shutdown any bulk reads that might be going on */
@@ -208,17 +205,17 @@ static int cyberjack_write (struct usb_serial_port *port, const unsigned char *b
208 int result; 205 int result;
209 int wrexpected; 206 int wrexpected;
210 207
211 dbg("%s - port %d", __FUNCTION__, port->number); 208 dbg("%s - port %d", __func__, port->number);
212 209
213 if (count == 0) { 210 if (count == 0) {
214 dbg("%s - write request of 0 bytes", __FUNCTION__); 211 dbg("%s - write request of 0 bytes", __func__);
215 return (0); 212 return 0;
216 } 213 }
217 214
218 spin_lock_bh(&port->lock); 215 spin_lock_bh(&port->lock);
219 if (port->write_urb_busy) { 216 if (port->write_urb_busy) {
220 spin_unlock_bh(&port->lock); 217 spin_unlock_bh(&port->lock);
221 dbg("%s - already writing", __FUNCTION__); 218 dbg("%s - already writing", __func__);
222 return 0; 219 return 0;
223 } 220 }
224 port->write_urb_busy = 1; 221 port->write_urb_busy = 1;
@@ -226,24 +223,24 @@ static int cyberjack_write (struct usb_serial_port *port, const unsigned char *b
226 223
227 spin_lock_irqsave(&priv->lock, flags); 224 spin_lock_irqsave(&priv->lock, flags);
228 225
229 if( (count+priv->wrfilled)>sizeof(priv->wrbuf) ) { 226 if( (count+priv->wrfilled) > sizeof(priv->wrbuf) ) {
230 /* To much data for buffer. Reset buffer. */ 227 /* To much data for buffer. Reset buffer. */
231 priv->wrfilled=0; 228 priv->wrfilled = 0;
232 spin_unlock_irqrestore(&priv->lock, flags);
233 port->write_urb_busy = 0; 229 port->write_urb_busy = 0;
234 return (0); 230 spin_unlock_irqrestore(&priv->lock, flags);
231 return 0;
235 } 232 }
236 233
237 /* Copy data */ 234 /* Copy data */
238 memcpy (priv->wrbuf+priv->wrfilled, buf, count); 235 memcpy (priv->wrbuf+priv->wrfilled, buf, count);
239 236
240 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count, 237 usb_serial_debug_data(debug, &port->dev, __func__, count,
241 priv->wrbuf+priv->wrfilled); 238 priv->wrbuf+priv->wrfilled);
242 priv->wrfilled += count; 239 priv->wrfilled += count;
243 240
244 if( priv->wrfilled >= 3 ) { 241 if( priv->wrfilled >= 3 ) {
245 wrexpected = ((int)priv->wrbuf[2]<<8)+priv->wrbuf[1]+3; 242 wrexpected = ((int)priv->wrbuf[2]<<8)+priv->wrbuf[1]+3;
246 dbg("%s - expected data: %d", __FUNCTION__, wrexpected); 243 dbg("%s - expected data: %d", __func__, wrexpected);
247 } else { 244 } else {
248 wrexpected = sizeof(priv->wrbuf); 245 wrexpected = sizeof(priv->wrbuf);
249 } 246 }
@@ -252,7 +249,7 @@ static int cyberjack_write (struct usb_serial_port *port, const unsigned char *b
252 /* We have enough data to begin transmission */ 249 /* We have enough data to begin transmission */
253 int length; 250 int length;
254 251
255 dbg("%s - transmitting data (frame 1)", __FUNCTION__); 252 dbg("%s - transmitting data (frame 1)", __func__);
256 length = (wrexpected > port->bulk_out_size) ? port->bulk_out_size : wrexpected; 253 length = (wrexpected > port->bulk_out_size) ? port->bulk_out_size : wrexpected;
257 254
258 memcpy (port->write_urb->transfer_buffer, priv->wrbuf, length ); 255 memcpy (port->write_urb->transfer_buffer, priv->wrbuf, length );
@@ -270,23 +267,23 @@ static int cyberjack_write (struct usb_serial_port *port, const unsigned char *b
270 /* send the data out the bulk port */ 267 /* send the data out the bulk port */
271 result = usb_submit_urb(port->write_urb, GFP_ATOMIC); 268 result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
272 if (result) { 269 if (result) {
273 err("%s - failed submitting write urb, error %d", __FUNCTION__, result); 270 err("%s - failed submitting write urb, error %d", __func__, result);
274 /* Throw away data. No better idea what to do with it. */ 271 /* Throw away data. No better idea what to do with it. */
275 priv->wrfilled=0; 272 priv->wrfilled = 0;
276 priv->wrsent=0; 273 priv->wrsent = 0;
277 spin_unlock_irqrestore(&priv->lock, flags); 274 spin_unlock_irqrestore(&priv->lock, flags);
278 port->write_urb_busy = 0; 275 port->write_urb_busy = 0;
279 return 0; 276 return 0;
280 } 277 }
281 278
282 dbg("%s - priv->wrsent=%d", __FUNCTION__,priv->wrsent); 279 dbg("%s - priv->wrsent=%d", __func__,priv->wrsent);
283 dbg("%s - priv->wrfilled=%d", __FUNCTION__,priv->wrfilled); 280 dbg("%s - priv->wrfilled=%d", __func__,priv->wrfilled);
284 281
285 if( priv->wrsent>=priv->wrfilled ) { 282 if( priv->wrsent>=priv->wrfilled ) {
286 dbg("%s - buffer cleaned", __FUNCTION__); 283 dbg("%s - buffer cleaned", __func__);
287 memset( priv->wrbuf, 0, sizeof(priv->wrbuf) ); 284 memset( priv->wrbuf, 0, sizeof(priv->wrbuf) );
288 priv->wrfilled=0; 285 priv->wrfilled = 0;
289 priv->wrsent=0; 286 priv->wrsent = 0;
290 } 287 }
291 } 288 }
292 289
@@ -297,27 +294,28 @@ static int cyberjack_write (struct usb_serial_port *port, const unsigned char *b
297 294
298static int cyberjack_write_room( struct usb_serial_port *port ) 295static int cyberjack_write_room( struct usb_serial_port *port )
299{ 296{
297 /* FIXME: .... */
300 return CYBERJACK_LOCAL_BUF_SIZE; 298 return CYBERJACK_LOCAL_BUF_SIZE;
301} 299}
302 300
303static void cyberjack_read_int_callback( struct urb *urb ) 301static void cyberjack_read_int_callback( struct urb *urb )
304{ 302{
305 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 303 struct usb_serial_port *port = urb->context;
306 struct cyberjack_private *priv = usb_get_serial_port_data(port); 304 struct cyberjack_private *priv = usb_get_serial_port_data(port);
307 unsigned char *data = urb->transfer_buffer; 305 unsigned char *data = urb->transfer_buffer;
308 int status = urb->status; 306 int status = urb->status;
309 int result; 307 int result;
310 308
311 dbg("%s - port %d", __FUNCTION__, port->number); 309 dbg("%s - port %d", __func__, port->number);
312 310
313 /* the urb might have been killed. */ 311 /* the urb might have been killed. */
314 if (status) 312 if (status)
315 return; 313 return;
316 314
317 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, urb->actual_length, data); 315 usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data);
318 316
319 /* React only to interrupts signaling a bulk_in transfer */ 317 /* React only to interrupts signaling a bulk_in transfer */
320 if( (urb->actual_length==4) && (data[0]==0x01) ) { 318 if( (urb->actual_length == 4) && (data[0] == 0x01) ) {
321 short old_rdtodo; 319 short old_rdtodo;
322 320
323 /* This is a announcement of coming bulk_ins. */ 321 /* This is a announcement of coming bulk_ins. */
@@ -336,7 +334,7 @@ static void cyberjack_read_int_callback( struct urb *urb )
336 /* "+=" is probably more fault tollerant than "=" */ 334 /* "+=" is probably more fault tollerant than "=" */
337 priv->rdtodo += size; 335 priv->rdtodo += size;
338 336
339 dbg("%s - rdtodo: %d", __FUNCTION__, priv->rdtodo); 337 dbg("%s - rdtodo: %d", __func__, priv->rdtodo);
340 338
341 spin_unlock(&priv->lock); 339 spin_unlock(&priv->lock);
342 340
@@ -344,8 +342,8 @@ static void cyberjack_read_int_callback( struct urb *urb )
344 port->read_urb->dev = port->serial->dev; 342 port->read_urb->dev = port->serial->dev;
345 result = usb_submit_urb(port->read_urb, GFP_ATOMIC); 343 result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
346 if( result ) 344 if( result )
347 err("%s - failed resubmitting read urb, error %d", __FUNCTION__, result); 345 err("%s - failed resubmitting read urb, error %d", __func__, result);
348 dbg("%s - usb_submit_urb(read urb)", __FUNCTION__); 346 dbg("%s - usb_submit_urb(read urb)", __func__);
349 } 347 }
350 } 348 }
351 349
@@ -354,12 +352,12 @@ resubmit:
354 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); 352 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC);
355 if (result) 353 if (result)
356 err(" usb_submit_urb(read int) failed"); 354 err(" usb_submit_urb(read int) failed");
357 dbg("%s - usb_submit_urb(int urb)", __FUNCTION__); 355 dbg("%s - usb_submit_urb(int urb)", __func__);
358} 356}
359 357
360static void cyberjack_read_bulk_callback (struct urb *urb) 358static void cyberjack_read_bulk_callback (struct urb *urb)
361{ 359{
362 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 360 struct usb_serial_port *port = urb->context;
363 struct cyberjack_private *priv = usb_get_serial_port_data(port); 361 struct cyberjack_private *priv = usb_get_serial_port_data(port);
364 struct tty_struct *tty; 362 struct tty_struct *tty;
365 unsigned char *data = urb->transfer_buffer; 363 unsigned char *data = urb->transfer_buffer;
@@ -367,18 +365,18 @@ static void cyberjack_read_bulk_callback (struct urb *urb)
367 int result; 365 int result;
368 int status = urb->status; 366 int status = urb->status;
369 367
370 dbg("%s - port %d", __FUNCTION__, port->number); 368 dbg("%s - port %d", __func__, port->number);
371 369
372 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, urb->actual_length, data); 370 usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data);
373 if (status) { 371 if (status) {
374 dbg("%s - nonzero read bulk status received: %d", 372 dbg("%s - nonzero read bulk status received: %d",
375 __FUNCTION__, status); 373 __func__, status);
376 return; 374 return;
377 } 375 }
378 376
379 tty = port->tty; 377 tty = port->tty;
380 if (!tty) { 378 if (!tty) {
381 dbg("%s - ignoring since device not open\n", __FUNCTION__); 379 dbg("%s - ignoring since device not open\n", __func__);
382 return; 380 return;
383 } 381 }
384 if (urb->actual_length) { 382 if (urb->actual_length) {
@@ -397,30 +395,30 @@ static void cyberjack_read_bulk_callback (struct urb *urb)
397 395
398 spin_unlock(&priv->lock); 396 spin_unlock(&priv->lock);
399 397
400 dbg("%s - rdtodo: %d", __FUNCTION__, todo); 398 dbg("%s - rdtodo: %d", __func__, todo);
401 399
402 /* Continue to read if we have still urbs to do. */ 400 /* Continue to read if we have still urbs to do. */
403 if( todo /* || (urb->actual_length==port->bulk_in_endpointAddress)*/ ) { 401 if( todo /* || (urb->actual_length==port->bulk_in_endpointAddress)*/ ) {
404 port->read_urb->dev = port->serial->dev; 402 port->read_urb->dev = port->serial->dev;
405 result = usb_submit_urb(port->read_urb, GFP_ATOMIC); 403 result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
406 if (result) 404 if (result)
407 err("%s - failed resubmitting read urb, error %d", __FUNCTION__, result); 405 err("%s - failed resubmitting read urb, error %d", __func__, result);
408 dbg("%s - usb_submit_urb(read urb)", __FUNCTION__); 406 dbg("%s - usb_submit_urb(read urb)", __func__);
409 } 407 }
410} 408}
411 409
412static void cyberjack_write_bulk_callback (struct urb *urb) 410static void cyberjack_write_bulk_callback (struct urb *urb)
413{ 411{
414 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 412 struct usb_serial_port *port = urb->context;
415 struct cyberjack_private *priv = usb_get_serial_port_data(port); 413 struct cyberjack_private *priv = usb_get_serial_port_data(port);
416 int status = urb->status; 414 int status = urb->status;
417 415
418 dbg("%s - port %d", __FUNCTION__, port->number); 416 dbg("%s - port %d", __func__, port->number);
419 417
420 port->write_urb_busy = 0; 418 port->write_urb_busy = 0;
421 if (status) { 419 if (status) {
422 dbg("%s - nonzero write bulk status received: %d", 420 dbg("%s - nonzero write bulk status received: %d",
423 __FUNCTION__, status); 421 __func__, status);
424 return; 422 return;
425 } 423 }
426 424
@@ -430,7 +428,7 @@ static void cyberjack_write_bulk_callback (struct urb *urb)
430 if( priv->wrfilled ) { 428 if( priv->wrfilled ) {
431 int length, blksize, result; 429 int length, blksize, result;
432 430
433 dbg("%s - transmitting data (frame n)", __FUNCTION__); 431 dbg("%s - transmitting data (frame n)", __func__);
434 432
435 length = ((priv->wrfilled - priv->wrsent) > port->bulk_out_size) ? 433 length = ((priv->wrfilled - priv->wrsent) > port->bulk_out_size) ?
436 port->bulk_out_size : (priv->wrfilled - priv->wrsent); 434 port->bulk_out_size : (priv->wrfilled - priv->wrsent);
@@ -451,23 +449,23 @@ static void cyberjack_write_bulk_callback (struct urb *urb)
451 /* send the data out the bulk port */ 449 /* send the data out the bulk port */
452 result = usb_submit_urb(port->write_urb, GFP_ATOMIC); 450 result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
453 if (result) { 451 if (result) {
454 err("%s - failed submitting write urb, error %d", __FUNCTION__, result); 452 err("%s - failed submitting write urb, error %d", __func__, result);
455 /* Throw away data. No better idea what to do with it. */ 453 /* Throw away data. No better idea what to do with it. */
456 priv->wrfilled=0; 454 priv->wrfilled = 0;
457 priv->wrsent=0; 455 priv->wrsent = 0;
458 goto exit; 456 goto exit;
459 } 457 }
460 458
461 dbg("%s - priv->wrsent=%d", __FUNCTION__,priv->wrsent); 459 dbg("%s - priv->wrsent=%d", __func__,priv->wrsent);
462 dbg("%s - priv->wrfilled=%d", __FUNCTION__,priv->wrfilled); 460 dbg("%s - priv->wrfilled=%d", __func__,priv->wrfilled);
463 461
464 blksize = ((int)priv->wrbuf[2]<<8)+priv->wrbuf[1]+3; 462 blksize = ((int)priv->wrbuf[2]<<8)+priv->wrbuf[1]+3;
465 463
466 if( (priv->wrsent>=priv->wrfilled) || (priv->wrsent>=blksize) ) { 464 if( (priv->wrsent>=priv->wrfilled) || (priv->wrsent>=blksize) ) {
467 dbg("%s - buffer cleaned", __FUNCTION__); 465 dbg("%s - buffer cleaned", __func__);
468 memset( priv->wrbuf, 0, sizeof(priv->wrbuf) ); 466 memset( priv->wrbuf, 0, sizeof(priv->wrbuf) );
469 priv->wrfilled=0; 467 priv->wrfilled = 0;
470 priv->wrsent=0; 468 priv->wrsent = 0;
471 } 469 }
472 } 470 }
473 471
diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c
index 779d07851a4..32121794808 100644
--- a/drivers/usb/serial/cypress_m8.c
+++ b/drivers/usb/serial/cypress_m8.c
@@ -122,6 +122,11 @@ static struct usb_driver cypress_driver = {
122 .no_dynamic_id = 1, 122 .no_dynamic_id = 1,
123}; 123};
124 124
125enum packet_format {
126 packet_format_1, /* b0:status, b1:payload count */
127 packet_format_2 /* b0[7:3]:status, b0[2:0]:payload count */
128};
129
125struct cypress_private { 130struct cypress_private {
126 spinlock_t lock; /* private lock */ 131 spinlock_t lock; /* private lock */
127 int chiptype; /* identifier of device, for quirks/etc */ 132 int chiptype; /* identifier of device, for quirks/etc */
@@ -139,8 +144,9 @@ struct cypress_private {
139 __u8 current_status; /* received from last read - info on dsr,cts,cd,ri,etc */ 144 __u8 current_status; /* received from last read - info on dsr,cts,cd,ri,etc */
140 __u8 current_config; /* stores the current configuration byte */ 145 __u8 current_config; /* stores the current configuration byte */
141 __u8 rx_flags; /* throttling - used from whiteheat/ftdi_sio */ 146 __u8 rx_flags; /* throttling - used from whiteheat/ftdi_sio */
147 enum packet_format pkt_fmt; /* format to use for packet send / receive */
148 int get_cfg_unsafe; /* If true, the CYPRESS_GET_CONFIG is unsafe */
142 int baud_rate; /* stores current baud rate in integer form */ 149 int baud_rate; /* stores current baud rate in integer form */
143 int cbr_mask; /* stores current baud rate in masked form */
144 int isthrottled; /* if throttled, discard reads */ 150 int isthrottled; /* if throttled, discard reads */
145 wait_queue_head_t delta_msr_wait; /* used for TIOCMIWAIT */ 151 wait_queue_head_t delta_msr_wait; /* used for TIOCMIWAIT */
146 char prev_status, diff_status; /* used for TIOCMIWAIT */ 152 char prev_status, diff_status; /* used for TIOCMIWAIT */
@@ -176,9 +182,6 @@ static void cypress_unthrottle (struct usb_serial_port *port);
176static void cypress_set_dead (struct usb_serial_port *port); 182static void cypress_set_dead (struct usb_serial_port *port);
177static void cypress_read_int_callback (struct urb *urb); 183static void cypress_read_int_callback (struct urb *urb);
178static void cypress_write_int_callback (struct urb *urb); 184static void cypress_write_int_callback (struct urb *urb);
179/* baud helper functions */
180static int mask_to_rate (unsigned mask);
181static unsigned rate_to_mask (int rate);
182/* write buffer functions */ 185/* write buffer functions */
183static struct cypress_buf *cypress_buf_alloc(unsigned int size); 186static struct cypress_buf *cypress_buf_alloc(unsigned int size);
184static void cypress_buf_free(struct cypress_buf *cb); 187static void cypress_buf_free(struct cypress_buf *cb);
@@ -197,10 +200,6 @@ static struct usb_serial_driver cypress_earthmate_device = {
197 .description = "DeLorme Earthmate USB", 200 .description = "DeLorme Earthmate USB",
198 .usb_driver = &cypress_driver, 201 .usb_driver = &cypress_driver,
199 .id_table = id_table_earthmate, 202 .id_table = id_table_earthmate,
200 .num_interrupt_in = 1,
201 .num_interrupt_out = 1,
202 .num_bulk_in = NUM_DONT_CARE,
203 .num_bulk_out = NUM_DONT_CARE,
204 .num_ports = 1, 203 .num_ports = 1,
205 .attach = cypress_earthmate_startup, 204 .attach = cypress_earthmate_startup,
206 .shutdown = cypress_shutdown, 205 .shutdown = cypress_shutdown,
@@ -227,10 +226,6 @@ static struct usb_serial_driver cypress_hidcom_device = {
227 .description = "HID->COM RS232 Adapter", 226 .description = "HID->COM RS232 Adapter",
228 .usb_driver = &cypress_driver, 227 .usb_driver = &cypress_driver,
229 .id_table = id_table_cyphidcomrs232, 228 .id_table = id_table_cyphidcomrs232,
230 .num_interrupt_in = 1,
231 .num_interrupt_out = 1,
232 .num_bulk_in = NUM_DONT_CARE,
233 .num_bulk_out = NUM_DONT_CARE,
234 .num_ports = 1, 229 .num_ports = 1,
235 .attach = cypress_hidcom_startup, 230 .attach = cypress_hidcom_startup,
236 .shutdown = cypress_shutdown, 231 .shutdown = cypress_shutdown,
@@ -257,10 +252,6 @@ static struct usb_serial_driver cypress_ca42v2_device = {
257 .description = "Nokia CA-42 V2 Adapter", 252 .description = "Nokia CA-42 V2 Adapter",
258 .usb_driver = &cypress_driver, 253 .usb_driver = &cypress_driver,
259 .id_table = id_table_nokiaca42v2, 254 .id_table = id_table_nokiaca42v2,
260 .num_interrupt_in = 1,
261 .num_interrupt_out = 1,
262 .num_bulk_in = NUM_DONT_CARE,
263 .num_bulk_out = NUM_DONT_CARE,
264 .num_ports = 1, 255 .num_ports = 1,
265 .attach = cypress_ca42v2_startup, 256 .attach = cypress_ca42v2_startup,
266 .shutdown = cypress_shutdown, 257 .shutdown = cypress_shutdown,
@@ -284,16 +275,62 @@ static struct usb_serial_driver cypress_ca42v2_device = {
284 *****************************************************************************/ 275 *****************************************************************************/
285 276
286 277
278static int analyze_baud_rate(struct usb_serial_port *port, speed_t new_rate)
279{
280 struct cypress_private *priv;
281 priv = usb_get_serial_port_data(port);
282
283 /*
284 * The general purpose firmware for the Cypress M8 allows for
285 * a maximum speed of 57600bps (I have no idea whether DeLorme
286 * chose to use the general purpose firmware or not), if you
287 * need to modify this speed setting for your own project
288 * please add your own chiptype and modify the code likewise.
289 * The Cypress HID->COM device will work successfully up to
290 * 115200bps (but the actual throughput is around 3kBps).
291 */
292 if (port->serial->dev->speed == USB_SPEED_LOW) {
293 /*
294 * Mike Isely <isely@pobox.com> 2-Feb-2008: The
295 * Cypress app note that describes this mechanism
296 * states the the low-speed part can't handle more
297 * than 800 bytes/sec, in which case 4800 baud is the
298 * safest speed for a part like that.
299 */
300 if (new_rate > 4800) {
301 dbg("%s - failed setting baud rate, device incapable "
302 "speed %d", __func__, new_rate);
303 return -1;
304 }
305 }
306 switch (priv->chiptype) {
307 case CT_EARTHMATE:
308 if (new_rate <= 600) {
309 /* 300 and 600 baud rates are supported under
310 * the generic firmware, but are not used with
311 * NMEA and SiRF protocols */
312 dbg("%s - failed setting baud rate, unsupported speed "
313 "of %d on Earthmate GPS", __func__, new_rate);
314 return -1;
315 }
316 break;
317 default:
318 break;
319 }
320 return new_rate;
321}
322
323
287/* This function can either set or retrieve the current serial line settings */ 324/* This function can either set or retrieve the current serial line settings */
288static int cypress_serial_control (struct usb_serial_port *port, unsigned baud_mask, int data_bits, int stop_bits, 325static int cypress_serial_control (struct usb_serial_port *port, speed_t baud_rate, int data_bits, int stop_bits,
289 int parity_enable, int parity_type, int reset, int cypress_request_type) 326 int parity_enable, int parity_type, int reset, int cypress_request_type)
290{ 327{
291 int new_baudrate = 0, retval = 0, tries = 0; 328 int new_baudrate = 0, retval = 0, tries = 0;
292 struct cypress_private *priv; 329 struct cypress_private *priv;
293 __u8 feature_buffer[8]; 330 __u8 feature_buffer[5];
294 unsigned long flags; 331 unsigned long flags;
295 332
296 dbg("%s", __FUNCTION__); 333 dbg("%s", __func__);
297 334
298 priv = usb_get_serial_port_data(port); 335 priv = usb_get_serial_port_data(port);
299 336
@@ -302,58 +339,23 @@ static int cypress_serial_control (struct usb_serial_port *port, unsigned baud_m
302 339
303 switch(cypress_request_type) { 340 switch(cypress_request_type) {
304 case CYPRESS_SET_CONFIG: 341 case CYPRESS_SET_CONFIG:
305 342 new_baudrate = priv->baud_rate;
306 /* 343 /* 0 means 'Hang up' so doesn't change the true bit rate */
307 * The general purpose firmware for the Cypress M8 allows for a maximum speed 344 if (baud_rate == 0)
308 * of 57600bps (I have no idea whether DeLorme chose to use the general purpose
309 * firmware or not), if you need to modify this speed setting for your own
310 * project please add your own chiptype and modify the code likewise. The
311 * Cypress HID->COM device will work successfully up to 115200bps (but the
312 * actual throughput is around 3kBps).
313 */
314 if (baud_mask != priv->cbr_mask) {
315 dbg("%s - baud rate is changing", __FUNCTION__);
316 if ( priv->chiptype == CT_EARTHMATE ) {
317 /* 300 and 600 baud rates are supported under the generic firmware,
318 * but are not used with NMEA and SiRF protocols */
319
320 if ( (baud_mask == B300) || (baud_mask == B600) ) {
321 err("%s - failed setting baud rate, unsupported speed",
322 __FUNCTION__);
323 new_baudrate = priv->baud_rate;
324 } else if ( (new_baudrate = mask_to_rate(baud_mask)) == -1) {
325 err("%s - failed setting baud rate, unsupported speed",
326 __FUNCTION__);
327 new_baudrate = priv->baud_rate;
328 }
329 } else if (priv->chiptype == CT_CYPHIDCOM) {
330 if ( (new_baudrate = mask_to_rate(baud_mask)) == -1) {
331 err("%s - failed setting baud rate, unsupported speed",
332 __FUNCTION__);
333 new_baudrate = priv->baud_rate;
334 }
335 } else if (priv->chiptype == CT_CA42V2) {
336 if ( (new_baudrate = mask_to_rate(baud_mask)) == -1) {
337 err("%s - failed setting baud rate, unsupported speed",
338 __FUNCTION__);
339 new_baudrate = priv->baud_rate;
340 }
341 } else if (priv->chiptype == CT_GENERIC) {
342 if ( (new_baudrate = mask_to_rate(baud_mask)) == -1) {
343 err("%s - failed setting baud rate, unsupported speed",
344 __FUNCTION__);
345 new_baudrate = priv->baud_rate;
346 }
347 } else {
348 info("%s - please define your chiptype", __FUNCTION__);
349 new_baudrate = priv->baud_rate;
350 }
351 } else { /* baud rate not changing, keep the old */
352 new_baudrate = priv->baud_rate; 345 new_baudrate = priv->baud_rate;
346 /* Change of speed ? */
347 else if (baud_rate != priv->baud_rate) {
348 dbg("%s - baud rate is changing", __func__);
349 retval = analyze_baud_rate(port, baud_rate);
350 if (retval >= 0) {
351 new_baudrate = retval;
352 dbg("%s - New baud rate set to %d",
353 __func__, new_baudrate);
354 }
353 } 355 }
354 dbg("%s - baud rate is being sent as %d", __FUNCTION__, new_baudrate); 356 dbg("%s - baud rate is being sent as %d", __func__, new_baudrate);
355 357
356 memset(feature_buffer, 0, 8); 358 memset(feature_buffer, 0, sizeof(feature_buffer));
357 /* fill the feature_buffer with new configuration */ 359 /* fill the feature_buffer with new configuration */
358 *((u_int32_t *)feature_buffer) = new_baudrate; 360 *((u_int32_t *)feature_buffer) = new_baudrate;
359 361
@@ -365,48 +367,65 @@ static int cypress_serial_control (struct usb_serial_port *port, unsigned baud_m
365 /* 1 bit gap */ 367 /* 1 bit gap */
366 feature_buffer[4] |= (reset << 7); /* assign reset at end of byte, 1 bit space */ 368 feature_buffer[4] |= (reset << 7); /* assign reset at end of byte, 1 bit space */
367 369
368 dbg("%s - device is being sent this feature report:", __FUNCTION__); 370 dbg("%s - device is being sent this feature report:", __func__);
369 dbg("%s - %02X - %02X - %02X - %02X - %02X", __FUNCTION__, feature_buffer[0], feature_buffer[1], 371 dbg("%s - %02X - %02X - %02X - %02X - %02X", __func__, feature_buffer[0], feature_buffer[1],
370 feature_buffer[2], feature_buffer[3], feature_buffer[4]); 372 feature_buffer[2], feature_buffer[3], feature_buffer[4]);
371 373
372 do { 374 do {
373 retval = usb_control_msg (port->serial->dev, usb_sndctrlpipe(port->serial->dev, 0), 375 retval = usb_control_msg(port->serial->dev,
374 HID_REQ_SET_REPORT, USB_DIR_OUT | USB_RECIP_INTERFACE | USB_TYPE_CLASS, 376 usb_sndctrlpipe(port->serial->dev, 0),
375 0x0300, 0, feature_buffer, 8, 500); 377 HID_REQ_SET_REPORT,
378 USB_DIR_OUT | USB_RECIP_INTERFACE | USB_TYPE_CLASS,
379 0x0300, 0, feature_buffer,
380 sizeof(feature_buffer), 500);
376 381
377 if (tries++ >= 3) 382 if (tries++ >= 3)
378 break; 383 break;
379 384
380 } while (retval != 8 && retval != -ENODEV); 385 } while (retval != sizeof(feature_buffer) &&
386 retval != -ENODEV);
381 387
382 if (retval != 8) { 388 if (retval != sizeof(feature_buffer)) {
383 err("%s - failed sending serial line settings - %d", __FUNCTION__, retval); 389 err("%s - failed sending serial line settings - %d", __func__, retval);
384 cypress_set_dead(port); 390 cypress_set_dead(port);
385 } else { 391 } else {
386 spin_lock_irqsave(&priv->lock, flags); 392 spin_lock_irqsave(&priv->lock, flags);
387 priv->baud_rate = new_baudrate; 393 priv->baud_rate = new_baudrate;
388 priv->cbr_mask = baud_mask;
389 priv->current_config = feature_buffer[4]; 394 priv->current_config = feature_buffer[4];
390 spin_unlock_irqrestore(&priv->lock, flags); 395 spin_unlock_irqrestore(&priv->lock, flags);
396 /* If we asked for a speed change encode it */
397 if (baud_rate)
398 tty_encode_baud_rate(port->tty,
399 new_baudrate, new_baudrate);
391 } 400 }
392 break; 401 break;
393 case CYPRESS_GET_CONFIG: 402 case CYPRESS_GET_CONFIG:
394 dbg("%s - retreiving serial line settings", __FUNCTION__); 403 if (priv->get_cfg_unsafe) {
404 /* Not implemented for this device,
405 and if we try to do it we're likely
406 to crash the hardware. */
407 return -ENOTTY;
408 }
409 dbg("%s - retreiving serial line settings", __func__);
395 /* set initial values in feature buffer */ 410 /* set initial values in feature buffer */
396 memset(feature_buffer, 0, 8); 411 memset(feature_buffer, 0, sizeof(feature_buffer));
397 412
398 do { 413 do {
399 retval = usb_control_msg (port->serial->dev, usb_rcvctrlpipe(port->serial->dev, 0), 414 retval = usb_control_msg(port->serial->dev,
400 HID_REQ_GET_REPORT, USB_DIR_IN | USB_RECIP_INTERFACE | USB_TYPE_CLASS, 415 usb_rcvctrlpipe(port->serial->dev, 0),
401 0x0300, 0, feature_buffer, 8, 500); 416 HID_REQ_GET_REPORT,
402 417 USB_DIR_IN | USB_RECIP_INTERFACE | USB_TYPE_CLASS,
418 0x0300, 0, feature_buffer,
419 sizeof(feature_buffer), 500);
420
403 if (tries++ >= 3) 421 if (tries++ >= 3)
404 break; 422 break;
405 423
406 } while (retval != 5 && retval != -ENODEV); 424 } while (retval != sizeof(feature_buffer) &&
425 retval != -ENODEV);
407 426
408 if (retval != 5) { 427 if (retval != sizeof(feature_buffer)) {
409 err("%s - failed to retrieve serial line settings - %d", __FUNCTION__, retval); 428 err("%s - failed to retrieve serial line settings - %d", __func__, retval);
410 cypress_set_dead(port); 429 cypress_set_dead(port);
411 return retval; 430 return retval;
412 } else { 431 } else {
@@ -415,9 +434,6 @@ static int cypress_serial_control (struct usb_serial_port *port, unsigned baud_m
415 /* store the config in one byte, and later use bit masks to check values */ 434 /* store the config in one byte, and later use bit masks to check values */
416 priv->current_config = feature_buffer[4]; 435 priv->current_config = feature_buffer[4];
417 priv->baud_rate = *((u_int32_t *)feature_buffer); 436 priv->baud_rate = *((u_int32_t *)feature_buffer);
418
419 if ( (priv->cbr_mask = rate_to_mask(priv->baud_rate)) == 0x40)
420 dbg("%s - failed setting the baud mask (not defined)", __FUNCTION__);
421 spin_unlock_irqrestore(&priv->lock, flags); 437 spin_unlock_irqrestore(&priv->lock, flags);
422 } 438 }
423 } 439 }
@@ -447,51 +463,6 @@ static void cypress_set_dead(struct usb_serial_port *port)
447} 463}
448 464
449 465
450/* given a baud mask, it will return integer baud on success */
451static int mask_to_rate (unsigned mask)
452{
453 int rate;
454
455 switch (mask) {
456 case B0: rate = 0; break;
457 case B300: rate = 300; break;
458 case B600: rate = 600; break;
459 case B1200: rate = 1200; break;
460 case B2400: rate = 2400; break;
461 case B4800: rate = 4800; break;
462 case B9600: rate = 9600; break;
463 case B19200: rate = 19200; break;
464 case B38400: rate = 38400; break;
465 case B57600: rate = 57600; break;
466 case B115200: rate = 115200; break;
467 default: rate = -1;
468 }
469
470 return rate;
471}
472
473
474static unsigned rate_to_mask (int rate)
475{
476 unsigned mask;
477
478 switch (rate) {
479 case 0: mask = B0; break;
480 case 300: mask = B300; break;
481 case 600: mask = B600; break;
482 case 1200: mask = B1200; break;
483 case 2400: mask = B2400; break;
484 case 4800: mask = B4800; break;
485 case 9600: mask = B9600; break;
486 case 19200: mask = B19200; break;
487 case 38400: mask = B38400; break;
488 case 57600: mask = B57600; break;
489 case 115200: mask = B115200; break;
490 default: mask = 0x40;
491 }
492
493 return mask;
494}
495/***************************************************************************** 466/*****************************************************************************
496 * Cypress serial driver functions 467 * Cypress serial driver functions
497 *****************************************************************************/ 468 *****************************************************************************/
@@ -502,7 +473,7 @@ static int generic_startup (struct usb_serial *serial)
502 struct cypress_private *priv; 473 struct cypress_private *priv;
503 struct usb_serial_port *port = serial->port[0]; 474 struct usb_serial_port *port = serial->port[0];
504 475
505 dbg("%s - port %d", __FUNCTION__, port->number); 476 dbg("%s - port %d", __func__, port->number);
506 477
507 priv = kzalloc(sizeof (struct cypress_private), GFP_KERNEL); 478 priv = kzalloc(sizeof (struct cypress_private), GFP_KERNEL);
508 if (!priv) 479 if (!priv)
@@ -523,17 +494,27 @@ static int generic_startup (struct usb_serial *serial)
523 priv->line_control = 0; 494 priv->line_control = 0;
524 priv->termios_initialized = 0; 495 priv->termios_initialized = 0;
525 priv->rx_flags = 0; 496 priv->rx_flags = 0;
526 priv->cbr_mask = B300; 497 /* Default packet format setting is determined by packet size.
498 Anything with a size larger then 9 must have a separate
499 count field since the 3 bit count field is otherwise too
500 small. Otherwise we can use the slightly more compact
501 format. This is in accordance with the cypress_m8 serial
502 converter app note. */
503 if (port->interrupt_out_size > 9) {
504 priv->pkt_fmt = packet_format_1;
505 } else {
506 priv->pkt_fmt = packet_format_2;
507 }
527 if (interval > 0) { 508 if (interval > 0) {
528 priv->write_urb_interval = interval; 509 priv->write_urb_interval = interval;
529 priv->read_urb_interval = interval; 510 priv->read_urb_interval = interval;
530 dbg("%s - port %d read & write intervals forced to %d", 511 dbg("%s - port %d read & write intervals forced to %d",
531 __FUNCTION__,port->number,interval); 512 __func__,port->number,interval);
532 } else { 513 } else {
533 priv->write_urb_interval = port->interrupt_out_urb->interval; 514 priv->write_urb_interval = port->interrupt_out_urb->interval;
534 priv->read_urb_interval = port->interrupt_in_urb->interval; 515 priv->read_urb_interval = port->interrupt_in_urb->interval;
535 dbg("%s - port %d intervals: read=%d write=%d", 516 dbg("%s - port %d intervals: read=%d write=%d",
536 __FUNCTION__,port->number, 517 __func__,port->number,
537 priv->read_urb_interval,priv->write_urb_interval); 518 priv->read_urb_interval,priv->write_urb_interval);
538 } 519 }
539 usb_set_serial_port_data(port, priv); 520 usb_set_serial_port_data(port, priv);
@@ -545,17 +526,30 @@ static int generic_startup (struct usb_serial *serial)
545static int cypress_earthmate_startup (struct usb_serial *serial) 526static int cypress_earthmate_startup (struct usb_serial *serial)
546{ 527{
547 struct cypress_private *priv; 528 struct cypress_private *priv;
529 struct usb_serial_port *port = serial->port[0];
548 530
549 dbg("%s", __FUNCTION__); 531 dbg("%s", __func__);
550 532
551 if (generic_startup(serial)) { 533 if (generic_startup(serial)) {
552 dbg("%s - Failed setting up port %d", __FUNCTION__, 534 dbg("%s - Failed setting up port %d", __func__,
553 serial->port[0]->number); 535 port->number);
554 return 1; 536 return 1;
555 } 537 }
556 538
557 priv = usb_get_serial_port_data(serial->port[0]); 539 priv = usb_get_serial_port_data(port);
558 priv->chiptype = CT_EARTHMATE; 540 priv->chiptype = CT_EARTHMATE;
541 /* All Earthmate devices use the separated-count packet
542 format! Idiotic. */
543 priv->pkt_fmt = packet_format_1;
544 if (serial->dev->descriptor.idProduct != PRODUCT_ID_EARTHMATEUSB) {
545 /* The old original USB Earthmate seemed able to
546 handle GET_CONFIG requests; everything they've
547 produced since that time crashes if this command is
548 attempted :-( */
549 dbg("%s - Marking this device as unsafe for GET_CONFIG "
550 "commands", __func__);
551 priv->get_cfg_unsafe = !0;
552 }
559 553
560 return 0; 554 return 0;
561} /* cypress_earthmate_startup */ 555} /* cypress_earthmate_startup */
@@ -565,10 +559,10 @@ static int cypress_hidcom_startup (struct usb_serial *serial)
565{ 559{
566 struct cypress_private *priv; 560 struct cypress_private *priv;
567 561
568 dbg("%s", __FUNCTION__); 562 dbg("%s", __func__);
569 563
570 if (generic_startup(serial)) { 564 if (generic_startup(serial)) {
571 dbg("%s - Failed setting up port %d", __FUNCTION__, 565 dbg("%s - Failed setting up port %d", __func__,
572 serial->port[0]->number); 566 serial->port[0]->number);
573 return 1; 567 return 1;
574 } 568 }
@@ -584,10 +578,10 @@ static int cypress_ca42v2_startup (struct usb_serial *serial)
584{ 578{
585 struct cypress_private *priv; 579 struct cypress_private *priv;
586 580
587 dbg("%s", __FUNCTION__); 581 dbg("%s", __func__);
588 582
589 if (generic_startup(serial)) { 583 if (generic_startup(serial)) {
590 dbg("%s - Failed setting up port %d", __FUNCTION__, 584 dbg("%s - Failed setting up port %d", __func__,
591 serial->port[0]->number); 585 serial->port[0]->number);
592 return 1; 586 return 1;
593 } 587 }
@@ -603,7 +597,7 @@ static void cypress_shutdown (struct usb_serial *serial)
603{ 597{
604 struct cypress_private *priv; 598 struct cypress_private *priv;
605 599
606 dbg ("%s - port %d", __FUNCTION__, serial->port[0]->number); 600 dbg ("%s - port %d", __func__, serial->port[0]->number);
607 601
608 /* all open ports are closed at this point */ 602 /* all open ports are closed at this point */
609 603
@@ -624,7 +618,7 @@ static int cypress_open (struct usb_serial_port *port, struct file *filp)
624 unsigned long flags; 618 unsigned long flags;
625 int result = 0; 619 int result = 0;
626 620
627 dbg("%s - port %d", __FUNCTION__, port->number); 621 dbg("%s - port %d", __func__, port->number);
628 622
629 if (!priv->comm_is_ok) 623 if (!priv->comm_is_ok)
630 return -EIO; 624 return -EIO;
@@ -652,16 +646,16 @@ static int cypress_open (struct usb_serial_port *port, struct file *filp)
652 result = cypress_write(port, NULL, 0); 646 result = cypress_write(port, NULL, 0);
653 647
654 if (result) { 648 if (result) {
655 dev_err(&port->dev, "%s - failed setting the control lines - error %d\n", __FUNCTION__, result); 649 dev_err(&port->dev, "%s - failed setting the control lines - error %d\n", __func__, result);
656 return result; 650 return result;
657 } else 651 } else
658 dbg("%s - success setting the control lines", __FUNCTION__); 652 dbg("%s - success setting the control lines", __func__);
659 653
660 cypress_set_termios(port, &priv->tmp_termios); 654 cypress_set_termios(port, &priv->tmp_termios);
661 655
662 /* setup the port and start reading from the device */ 656 /* setup the port and start reading from the device */
663 if(!port->interrupt_in_urb){ 657 if(!port->interrupt_in_urb){
664 err("%s - interrupt_in_urb is empty!", __FUNCTION__); 658 err("%s - interrupt_in_urb is empty!", __func__);
665 return(-1); 659 return(-1);
666 } 660 }
667 661
@@ -672,7 +666,7 @@ static int cypress_open (struct usb_serial_port *port, struct file *filp)
672 result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); 666 result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
673 667
674 if (result){ 668 if (result){
675 dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", __FUNCTION__, result); 669 dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", __func__, result);
676 cypress_set_dead(port); 670 cypress_set_dead(port);
677 } 671 }
678 672
@@ -688,7 +682,7 @@ static void cypress_close(struct usb_serial_port *port, struct file * filp)
688 long timeout; 682 long timeout;
689 wait_queue_t wait; 683 wait_queue_t wait;
690 684
691 dbg("%s - port %d", __FUNCTION__, port->number); 685 dbg("%s - port %d", __func__, port->number);
692 686
693 /* wait for data to drain from buffer */ 687 /* wait for data to drain from buffer */
694 spin_lock_irq(&priv->lock); 688 spin_lock_irq(&priv->lock);
@@ -726,7 +720,7 @@ static void cypress_close(struct usb_serial_port *port, struct file * filp)
726 timeout = 2*HZ; 720 timeout = 2*HZ;
727 schedule_timeout_interruptible(timeout); 721 schedule_timeout_interruptible(timeout);
728 722
729 dbg("%s - stopping urbs", __FUNCTION__); 723 dbg("%s - stopping urbs", __func__);
730 usb_kill_urb (port->interrupt_in_urb); 724 usb_kill_urb (port->interrupt_in_urb);
731 usb_kill_urb (port->interrupt_out_urb); 725 usb_kill_urb (port->interrupt_out_urb);
732 726
@@ -755,7 +749,7 @@ static int cypress_write(struct usb_serial_port *port, const unsigned char *buf,
755 struct cypress_private *priv = usb_get_serial_port_data(port); 749 struct cypress_private *priv = usb_get_serial_port_data(port);
756 unsigned long flags; 750 unsigned long flags;
757 751
758 dbg("%s - port %d, %d bytes", __FUNCTION__, port->number, count); 752 dbg("%s - port %d, %d bytes", __func__, port->number, count);
759 753
760 /* line control commands, which need to be executed immediately, 754 /* line control commands, which need to be executed immediately,
761 are not put into the buffer for obvious reasons. 755 are not put into the buffer for obvious reasons.
@@ -788,12 +782,12 @@ static void cypress_send(struct usb_serial_port *port)
788 if (!priv->comm_is_ok) 782 if (!priv->comm_is_ok)
789 return; 783 return;
790 784
791 dbg("%s - port %d", __FUNCTION__, port->number); 785 dbg("%s - port %d", __func__, port->number);
792 dbg("%s - interrupt out size is %d", __FUNCTION__, port->interrupt_out_size); 786 dbg("%s - interrupt out size is %d", __func__, port->interrupt_out_size);
793 787
794 spin_lock_irqsave(&priv->lock, flags); 788 spin_lock_irqsave(&priv->lock, flags);
795 if (priv->write_urb_in_use) { 789 if (priv->write_urb_in_use) {
796 dbg("%s - can't write, urb in use", __FUNCTION__); 790 dbg("%s - can't write, urb in use", __func__);
797 spin_unlock_irqrestore(&priv->lock, flags); 791 spin_unlock_irqrestore(&priv->lock, flags);
798 return; 792 return;
799 } 793 }
@@ -803,21 +797,18 @@ static void cypress_send(struct usb_serial_port *port)
803 memset(port->interrupt_out_urb->transfer_buffer, 0, port->interrupt_out_size); 797 memset(port->interrupt_out_urb->transfer_buffer, 0, port->interrupt_out_size);
804 798
805 spin_lock_irqsave(&priv->lock, flags); 799 spin_lock_irqsave(&priv->lock, flags);
806 switch (port->interrupt_out_size) { 800 switch (priv->pkt_fmt) {
807 case 32: 801 default:
808 /* this is for the CY7C64013... */ 802 case packet_format_1:
809 offset = 2; 803 /* this is for the CY7C64013... */
810 port->interrupt_out_buffer[0] = priv->line_control; 804 offset = 2;
811 break; 805 port->interrupt_out_buffer[0] = priv->line_control;
812 case 8: 806 break;
813 /* this is for the CY7C63743... */ 807 case packet_format_2:
814 offset = 1; 808 /* this is for the CY7C63743... */
815 port->interrupt_out_buffer[0] = priv->line_control; 809 offset = 1;
816 break; 810 port->interrupt_out_buffer[0] = priv->line_control;
817 default: 811 break;
818 dbg("%s - wrong packet size", __FUNCTION__);
819 spin_unlock_irqrestore(&priv->lock, flags);
820 return;
821 } 812 }
822 813
823 if (priv->line_control & CONTROL_RESET) 814 if (priv->line_control & CONTROL_RESET)
@@ -825,7 +816,7 @@ static void cypress_send(struct usb_serial_port *port)
825 816
826 if (priv->cmd_ctrl) { 817 if (priv->cmd_ctrl) {
827 priv->cmd_count++; 818 priv->cmd_count++;
828 dbg("%s - line control command being issued", __FUNCTION__); 819 dbg("%s - line control command being issued", __func__);
829 spin_unlock_irqrestore(&priv->lock, flags); 820 spin_unlock_irqrestore(&priv->lock, flags);
830 goto send; 821 goto send;
831 } else 822 } else
@@ -838,15 +829,16 @@ static void cypress_send(struct usb_serial_port *port)
838 return; 829 return;
839 } 830 }
840 831
841 switch (port->interrupt_out_size) { 832 switch (priv->pkt_fmt) {
842 case 32: 833 default:
843 port->interrupt_out_buffer[1] = count; 834 case packet_format_1:
844 break; 835 port->interrupt_out_buffer[1] = count;
845 case 8: 836 break;
846 port->interrupt_out_buffer[0] |= count; 837 case packet_format_2:
838 port->interrupt_out_buffer[0] |= count;
847 } 839 }
848 840
849 dbg("%s - count is %d", __FUNCTION__, count); 841 dbg("%s - count is %d", __func__, count);
850 842
851send: 843send:
852 spin_lock_irqsave(&priv->lock, flags); 844 spin_lock_irqsave(&priv->lock, flags);
@@ -856,9 +848,10 @@ send:
856 if (priv->cmd_ctrl) 848 if (priv->cmd_ctrl)
857 actual_size = 1; 849 actual_size = 1;
858 else 850 else
859 actual_size = count + (port->interrupt_out_size == 32 ? 2 : 1); 851 actual_size = count +
860 852 (priv->pkt_fmt == packet_format_1 ? 2 : 1);
861 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, port->interrupt_out_size, 853
854 usb_serial_debug_data(debug, &port->dev, __func__, port->interrupt_out_size,
862 port->interrupt_out_urb->transfer_buffer); 855 port->interrupt_out_urb->transfer_buffer);
863 856
864 usb_fill_int_urb(port->interrupt_out_urb, port->serial->dev, 857 usb_fill_int_urb(port->interrupt_out_urb, port->serial->dev,
@@ -867,7 +860,7 @@ send:
867 cypress_write_int_callback, port, priv->write_urb_interval); 860 cypress_write_int_callback, port, priv->write_urb_interval);
868 result = usb_submit_urb (port->interrupt_out_urb, GFP_ATOMIC); 861 result = usb_submit_urb (port->interrupt_out_urb, GFP_ATOMIC);
869 if (result) { 862 if (result) {
870 dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __FUNCTION__, 863 dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __func__,
871 result); 864 result);
872 priv->write_urb_in_use = 0; 865 priv->write_urb_in_use = 0;
873 cypress_set_dead(port); 866 cypress_set_dead(port);
@@ -891,13 +884,13 @@ static int cypress_write_room(struct usb_serial_port *port)
891 int room = 0; 884 int room = 0;
892 unsigned long flags; 885 unsigned long flags;
893 886
894 dbg("%s - port %d", __FUNCTION__, port->number); 887 dbg("%s - port %d", __func__, port->number);
895 888
896 spin_lock_irqsave(&priv->lock, flags); 889 spin_lock_irqsave(&priv->lock, flags);
897 room = cypress_buf_space_avail(priv->buf); 890 room = cypress_buf_space_avail(priv->buf);
898 spin_unlock_irqrestore(&priv->lock, flags); 891 spin_unlock_irqrestore(&priv->lock, flags);
899 892
900 dbg("%s - returns %d", __FUNCTION__, room); 893 dbg("%s - returns %d", __func__, room);
901 return room; 894 return room;
902} 895}
903 896
@@ -909,7 +902,7 @@ static int cypress_tiocmget (struct usb_serial_port *port, struct file *file)
909 unsigned int result = 0; 902 unsigned int result = 0;
910 unsigned long flags; 903 unsigned long flags;
911 904
912 dbg("%s - port %d", __FUNCTION__, port->number); 905 dbg("%s - port %d", __func__, port->number);
913 906
914 spin_lock_irqsave(&priv->lock, flags); 907 spin_lock_irqsave(&priv->lock, flags);
915 control = priv->line_control; 908 control = priv->line_control;
@@ -923,7 +916,7 @@ static int cypress_tiocmget (struct usb_serial_port *port, struct file *file)
923 | ((status & UART_RI) ? TIOCM_RI : 0) 916 | ((status & UART_RI) ? TIOCM_RI : 0)
924 | ((status & UART_CD) ? TIOCM_CD : 0); 917 | ((status & UART_CD) ? TIOCM_CD : 0);
925 918
926 dbg("%s - result = %x", __FUNCTION__, result); 919 dbg("%s - result = %x", __func__, result);
927 920
928 return result; 921 return result;
929} 922}
@@ -935,7 +928,7 @@ static int cypress_tiocmset (struct usb_serial_port *port, struct file *file,
935 struct cypress_private *priv = usb_get_serial_port_data(port); 928 struct cypress_private *priv = usb_get_serial_port_data(port);
936 unsigned long flags; 929 unsigned long flags;
937 930
938 dbg("%s - port %d", __FUNCTION__, port->number); 931 dbg("%s - port %d", __func__, port->number);
939 932
940 spin_lock_irqsave(&priv->lock, flags); 933 spin_lock_irqsave(&priv->lock, flags);
941 if (set & TIOCM_RTS) 934 if (set & TIOCM_RTS)
@@ -946,9 +939,9 @@ static int cypress_tiocmset (struct usb_serial_port *port, struct file *file,
946 priv->line_control &= ~CONTROL_RTS; 939 priv->line_control &= ~CONTROL_RTS;
947 if (clear & TIOCM_DTR) 940 if (clear & TIOCM_DTR)
948 priv->line_control &= ~CONTROL_DTR; 941 priv->line_control &= ~CONTROL_DTR;
942 priv->cmd_ctrl = 1;
949 spin_unlock_irqrestore(&priv->lock, flags); 943 spin_unlock_irqrestore(&priv->lock, flags);
950 944
951 priv->cmd_ctrl = 1;
952 return cypress_write(port, NULL, 0); 945 return cypress_write(port, NULL, 0);
953} 946}
954 947
@@ -957,23 +950,9 @@ static int cypress_ioctl (struct usb_serial_port *port, struct file * file, unsi
957{ 950{
958 struct cypress_private *priv = usb_get_serial_port_data(port); 951 struct cypress_private *priv = usb_get_serial_port_data(port);
959 952
960 dbg("%s - port %d, cmd 0x%.4x", __FUNCTION__, port->number, cmd); 953 dbg("%s - port %d, cmd 0x%.4x", __func__, port->number, cmd);
961 954
962 switch (cmd) { 955 switch (cmd) {
963 case TIOCGSERIAL:
964 if (copy_to_user((void __user *)arg, port->tty->termios, sizeof(struct ktermios))) {
965 return -EFAULT;
966 }
967 return (0);
968 break;
969 case TIOCSSERIAL:
970 if (copy_from_user(port->tty->termios, (void __user *)arg, sizeof(struct ktermios))) {
971 return -EFAULT;
972 }
973 /* here we need to call cypress_set_termios to invoke the new settings */
974 cypress_set_termios(port, &priv->tmp_termios);
975 return (0);
976 break;
977 /* This code comes from drivers/char/serial.c and ftdi_sio.c */ 956 /* This code comes from drivers/char/serial.c and ftdi_sio.c */
978 case TIOCMIWAIT: 957 case TIOCMIWAIT:
979 while (priv != NULL) { 958 while (priv != NULL) {
@@ -1009,7 +988,7 @@ static int cypress_ioctl (struct usb_serial_port *port, struct file * file, unsi
1009 break; 988 break;
1010 } 989 }
1011 990
1012 dbg("%s - arg not supported - it was 0x%04x - check include/asm/ioctls.h", __FUNCTION__, cmd); 991 dbg("%s - arg not supported - it was 0x%04x - check include/asm/ioctls.h", __func__, cmd);
1013 992
1014 return -ENOIOCTLCMD; 993 return -ENOIOCTLCMD;
1015} /* cypress_ioctl */ 994} /* cypress_ioctl */
@@ -1021,18 +1000,14 @@ static void cypress_set_termios (struct usb_serial_port *port,
1021 struct cypress_private *priv = usb_get_serial_port_data(port); 1000 struct cypress_private *priv = usb_get_serial_port_data(port);
1022 struct tty_struct *tty; 1001 struct tty_struct *tty;
1023 int data_bits, stop_bits, parity_type, parity_enable; 1002 int data_bits, stop_bits, parity_type, parity_enable;
1024 unsigned cflag, iflag, baud_mask; 1003 unsigned cflag, iflag;
1025 unsigned long flags; 1004 unsigned long flags;
1026 __u8 oldlines; 1005 __u8 oldlines;
1027 int linechange = 0; 1006 int linechange = 0;
1028 1007
1029 dbg("%s - port %d", __FUNCTION__, port->number); 1008 dbg("%s - port %d", __func__, port->number);
1030 1009
1031 tty = port->tty; 1010 tty = port->tty;
1032 if ((!tty) || (!tty->termios)) {
1033 dbg("%s - no tty structures", __FUNCTION__);
1034 return;
1035 }
1036 1011
1037 spin_lock_irqsave(&priv->lock, flags); 1012 spin_lock_irqsave(&priv->lock, flags);
1038 if (!priv->termios_initialized) { 1013 if (!priv->termios_initialized) {
@@ -1040,40 +1015,37 @@ static void cypress_set_termios (struct usb_serial_port *port,
1040 *(tty->termios) = tty_std_termios; 1015 *(tty->termios) = tty_std_termios;
1041 tty->termios->c_cflag = B4800 | CS8 | CREAD | HUPCL | 1016 tty->termios->c_cflag = B4800 | CS8 | CREAD | HUPCL |
1042 CLOCAL; 1017 CLOCAL;
1018 tty->termios->c_ispeed = 4800;
1019 tty->termios->c_ospeed = 4800;
1043 } else if (priv->chiptype == CT_CYPHIDCOM) { 1020 } else if (priv->chiptype == CT_CYPHIDCOM) {
1044 *(tty->termios) = tty_std_termios; 1021 *(tty->termios) = tty_std_termios;
1045 tty->termios->c_cflag = B9600 | CS8 | CREAD | HUPCL | 1022 tty->termios->c_cflag = B9600 | CS8 | CREAD | HUPCL |
1046 CLOCAL; 1023 CLOCAL;
1024 tty->termios->c_ispeed = 9600;
1025 tty->termios->c_ospeed = 9600;
1047 } else if (priv->chiptype == CT_CA42V2) { 1026 } else if (priv->chiptype == CT_CA42V2) {
1048 *(tty->termios) = tty_std_termios; 1027 *(tty->termios) = tty_std_termios;
1049 tty->termios->c_cflag = B9600 | CS8 | CREAD | HUPCL | 1028 tty->termios->c_cflag = B9600 | CS8 | CREAD | HUPCL |
1050 CLOCAL; 1029 CLOCAL;
1030 tty->termios->c_ispeed = 9600;
1031 tty->termios->c_ospeed = 9600;
1051 } 1032 }
1052 priv->termios_initialized = 1; 1033 priv->termios_initialized = 1;
1053 } 1034 }
1054 spin_unlock_irqrestore(&priv->lock, flags); 1035 spin_unlock_irqrestore(&priv->lock, flags);
1055 1036
1037 /* Unsupported features need clearing */
1038 tty->termios->c_cflag &= ~(CMSPAR|CRTSCTS);
1039
1056 cflag = tty->termios->c_cflag; 1040 cflag = tty->termios->c_cflag;
1057 iflag = tty->termios->c_iflag; 1041 iflag = tty->termios->c_iflag;
1058 1042
1059 /* check if there are new settings */ 1043 /* check if there are new settings */
1060 if (old_termios) { 1044 if (old_termios) {
1061 if ((cflag != old_termios->c_cflag) || 1045 spin_lock_irqsave(&priv->lock, flags);
1062 (RELEVANT_IFLAG(iflag) != 1046 priv->tmp_termios = *(tty->termios);
1063 RELEVANT_IFLAG(old_termios->c_iflag))) { 1047 spin_unlock_irqrestore(&priv->lock, flags);
1064 dbg("%s - attempting to set new termios settings", 1048 }
1065 __FUNCTION__);
1066 /* should make a copy of this in case something goes
1067 * wrong in the function, we can restore it */
1068 spin_lock_irqsave(&priv->lock, flags);
1069 priv->tmp_termios = *(tty->termios);
1070 spin_unlock_irqrestore(&priv->lock, flags);
1071 } else {
1072 dbg("%s - nothing to do, exiting", __FUNCTION__);
1073 return;
1074 }
1075 } else
1076 return;
1077 1049
1078 /* set number of data bits, parity, stop bits */ 1050 /* set number of data bits, parity, stop bits */
1079 /* when parity is disabled the parity type bit is ignored */ 1051 /* when parity is disabled the parity type bit is ignored */
@@ -1104,7 +1076,7 @@ static void cypress_set_termios (struct usb_serial_port *port,
1104 break; 1076 break;
1105 default: 1077 default:
1106 err("%s - CSIZE was set, but not CS5-CS8", 1078 err("%s - CSIZE was set, but not CS5-CS8",
1107 __FUNCTION__); 1079 __func__);
1108 data_bits = 3; 1080 data_bits = 3;
1109 } 1081 }
1110 } else 1082 } else
@@ -1114,54 +1086,17 @@ static void cypress_set_termios (struct usb_serial_port *port,
1114 oldlines = priv->line_control; 1086 oldlines = priv->line_control;
1115 if ((cflag & CBAUD) == B0) { 1087 if ((cflag & CBAUD) == B0) {
1116 /* drop dtr and rts */ 1088 /* drop dtr and rts */
1117 dbg("%s - dropping the lines, baud rate 0bps", __FUNCTION__); 1089 dbg("%s - dropping the lines, baud rate 0bps", __func__);
1118 baud_mask = B0;
1119 priv->line_control &= ~(CONTROL_DTR | CONTROL_RTS); 1090 priv->line_control &= ~(CONTROL_DTR | CONTROL_RTS);
1120 } else { 1091 } else
1121 baud_mask = (cflag & CBAUD);
1122 switch(baud_mask) {
1123 case B300:
1124 dbg("%s - setting baud 300bps", __FUNCTION__);
1125 break;
1126 case B600:
1127 dbg("%s - setting baud 600bps", __FUNCTION__);
1128 break;
1129 case B1200:
1130 dbg("%s - setting baud 1200bps", __FUNCTION__);
1131 break;
1132 case B2400:
1133 dbg("%s - setting baud 2400bps", __FUNCTION__);
1134 break;
1135 case B4800:
1136 dbg("%s - setting baud 4800bps", __FUNCTION__);
1137 break;
1138 case B9600:
1139 dbg("%s - setting baud 9600bps", __FUNCTION__);
1140 break;
1141 case B19200:
1142 dbg("%s - setting baud 19200bps", __FUNCTION__);
1143 break;
1144 case B38400:
1145 dbg("%s - setting baud 38400bps", __FUNCTION__);
1146 break;
1147 case B57600:
1148 dbg("%s - setting baud 57600bps", __FUNCTION__);
1149 break;
1150 case B115200:
1151 dbg("%s - setting baud 115200bps", __FUNCTION__);
1152 break;
1153 default:
1154 dbg("%s - unknown masked baud rate", __FUNCTION__);
1155 }
1156 priv->line_control = (CONTROL_DTR | CONTROL_RTS); 1092 priv->line_control = (CONTROL_DTR | CONTROL_RTS);
1157 }
1158 spin_unlock_irqrestore(&priv->lock, flags); 1093 spin_unlock_irqrestore(&priv->lock, flags);
1159 1094
1160 dbg("%s - sending %d stop_bits, %d parity_enable, %d parity_type, " 1095 dbg("%s - sending %d stop_bits, %d parity_enable, %d parity_type, "
1161 "%d data_bits (+5)", __FUNCTION__, stop_bits, 1096 "%d data_bits (+5)", __func__, stop_bits,
1162 parity_enable, parity_type, data_bits); 1097 parity_enable, parity_type, data_bits);
1163 1098
1164 cypress_serial_control(port, baud_mask, data_bits, stop_bits, 1099 cypress_serial_control(port, tty_get_baud_rate(tty), data_bits, stop_bits,
1165 parity_enable, parity_type, 0, CYPRESS_SET_CONFIG); 1100 parity_enable, parity_type, 0, CYPRESS_SET_CONFIG);
1166 1101
1167 /* we perform a CYPRESS_GET_CONFIG so that the current settings are 1102 /* we perform a CYPRESS_GET_CONFIG so that the current settings are
@@ -1219,13 +1154,13 @@ static int cypress_chars_in_buffer(struct usb_serial_port *port)
1219 int chars = 0; 1154 int chars = 0;
1220 unsigned long flags; 1155 unsigned long flags;
1221 1156
1222 dbg("%s - port %d", __FUNCTION__, port->number); 1157 dbg("%s - port %d", __func__, port->number);
1223 1158
1224 spin_lock_irqsave(&priv->lock, flags); 1159 spin_lock_irqsave(&priv->lock, flags);
1225 chars = cypress_buf_data_avail(priv->buf); 1160 chars = cypress_buf_data_avail(priv->buf);
1226 spin_unlock_irqrestore(&priv->lock, flags); 1161 spin_unlock_irqrestore(&priv->lock, flags);
1227 1162
1228 dbg("%s - returns %d", __FUNCTION__, chars); 1163 dbg("%s - returns %d", __func__, chars);
1229 return chars; 1164 return chars;
1230} 1165}
1231 1166
@@ -1235,7 +1170,7 @@ static void cypress_throttle (struct usb_serial_port *port)
1235 struct cypress_private *priv = usb_get_serial_port_data(port); 1170 struct cypress_private *priv = usb_get_serial_port_data(port);
1236 unsigned long flags; 1171 unsigned long flags;
1237 1172
1238 dbg("%s - port %d", __FUNCTION__, port->number); 1173 dbg("%s - port %d", __func__, port->number);
1239 1174
1240 spin_lock_irqsave(&priv->lock, flags); 1175 spin_lock_irqsave(&priv->lock, flags);
1241 priv->rx_flags = THROTTLED; 1176 priv->rx_flags = THROTTLED;
@@ -1249,7 +1184,7 @@ static void cypress_unthrottle (struct usb_serial_port *port)
1249 int actually_throttled, result; 1184 int actually_throttled, result;
1250 unsigned long flags; 1185 unsigned long flags;
1251 1186
1252 dbg("%s - port %d", __FUNCTION__, port->number); 1187 dbg("%s - port %d", __func__, port->number);
1253 1188
1254 spin_lock_irqsave(&priv->lock, flags); 1189 spin_lock_irqsave(&priv->lock, flags);
1255 actually_throttled = priv->rx_flags & ACTUALLY_THROTTLED; 1190 actually_throttled = priv->rx_flags & ACTUALLY_THROTTLED;
@@ -1265,7 +1200,7 @@ static void cypress_unthrottle (struct usb_serial_port *port)
1265 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); 1200 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC);
1266 if (result) { 1201 if (result) {
1267 dev_err(&port->dev, "%s - failed submitting read urb, " 1202 dev_err(&port->dev, "%s - failed submitting read urb, "
1268 "error %d\n", __FUNCTION__, result); 1203 "error %d\n", __func__, result);
1269 cypress_set_dead(port); 1204 cypress_set_dead(port);
1270 } 1205 }
1271 } 1206 }
@@ -1274,7 +1209,7 @@ static void cypress_unthrottle (struct usb_serial_port *port)
1274 1209
1275static void cypress_read_int_callback(struct urb *urb) 1210static void cypress_read_int_callback(struct urb *urb)
1276{ 1211{
1277 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 1212 struct usb_serial_port *port = urb->context;
1278 struct cypress_private *priv = usb_get_serial_port_data(port); 1213 struct cypress_private *priv = usb_get_serial_port_data(port);
1279 struct tty_struct *tty; 1214 struct tty_struct *tty;
1280 unsigned char *data = urb->transfer_buffer; 1215 unsigned char *data = urb->transfer_buffer;
@@ -1286,7 +1221,7 @@ static void cypress_read_int_callback(struct urb *urb)
1286 int i = 0; 1221 int i = 0;
1287 int status = urb->status; 1222 int status = urb->status;
1288 1223
1289 dbg("%s - port %d", __FUNCTION__, port->number); 1224 dbg("%s - port %d", __func__, port->number);
1290 1225
1291 switch (status) { 1226 switch (status) {
1292 case 0: /* success */ 1227 case 0: /* success */
@@ -1302,14 +1237,14 @@ static void cypress_read_int_callback(struct urb *urb)
1302 default: 1237 default:
1303 /* something ugly is going on... */ 1238 /* something ugly is going on... */
1304 dev_err(&urb->dev->dev,"%s - unexpected nonzero read status received: %d\n", 1239 dev_err(&urb->dev->dev,"%s - unexpected nonzero read status received: %d\n",
1305 __FUNCTION__, status); 1240 __func__, status);
1306 cypress_set_dead(port); 1241 cypress_set_dead(port);
1307 return; 1242 return;
1308 } 1243 }
1309 1244
1310 spin_lock_irqsave(&priv->lock, flags); 1245 spin_lock_irqsave(&priv->lock, flags);
1311 if (priv->rx_flags & THROTTLED) { 1246 if (priv->rx_flags & THROTTLED) {
1312 dbg("%s - now throttling", __FUNCTION__); 1247 dbg("%s - now throttling", __func__);
1313 priv->rx_flags |= ACTUALLY_THROTTLED; 1248 priv->rx_flags |= ACTUALLY_THROTTLED;
1314 spin_unlock_irqrestore(&priv->lock, flags); 1249 spin_unlock_irqrestore(&priv->lock, flags);
1315 return; 1250 return;
@@ -1318,48 +1253,48 @@ static void cypress_read_int_callback(struct urb *urb)
1318 1253
1319 tty = port->tty; 1254 tty = port->tty;
1320 if (!tty) { 1255 if (!tty) {
1321 dbg("%s - bad tty pointer - exiting", __FUNCTION__); 1256 dbg("%s - bad tty pointer - exiting", __func__);
1322 return; 1257 return;
1323 } 1258 }
1324 1259
1325 spin_lock_irqsave(&priv->lock, flags); 1260 spin_lock_irqsave(&priv->lock, flags);
1326 switch(urb->actual_length) { 1261 result = urb->actual_length;
1327 case 32: 1262 switch (priv->pkt_fmt) {
1328 /* This is for the CY7C64013... */ 1263 default:
1329 priv->current_status = data[0] & 0xF8; 1264 case packet_format_1:
1330 bytes = data[1] + 2; 1265 /* This is for the CY7C64013... */
1331 i = 2; 1266 priv->current_status = data[0] & 0xF8;
1332 if (bytes > 2) 1267 bytes = data[1] + 2;
1333 havedata = 1; 1268 i = 2;
1334 break; 1269 if (bytes > 2)
1335 case 8: 1270 havedata = 1;
1336 /* This is for the CY7C63743... */ 1271 break;
1337 priv->current_status = data[0] & 0xF8; 1272 case packet_format_2:
1338 bytes = (data[0] & 0x07) + 1; 1273 /* This is for the CY7C63743... */
1339 i = 1; 1274 priv->current_status = data[0] & 0xF8;
1340 if (bytes > 1) 1275 bytes = (data[0] & 0x07) + 1;
1341 havedata = 1; 1276 i = 1;
1342 break; 1277 if (bytes > 1)
1343 default: 1278 havedata = 1;
1344 dbg("%s - wrong packet size - received %d bytes", 1279 break;
1345 __FUNCTION__, urb->actual_length);
1346 spin_unlock_irqrestore(&priv->lock, flags);
1347 goto continue_read;
1348 } 1280 }
1349 spin_unlock_irqrestore(&priv->lock, flags); 1281 spin_unlock_irqrestore(&priv->lock, flags);
1282 if (result < bytes) {
1283 dbg("%s - wrong packet size - received %d bytes but packet "
1284 "said %d bytes", __func__, result, bytes);
1285 goto continue_read;
1286 }
1350 1287
1351 usb_serial_debug_data (debug, &port->dev, __FUNCTION__, 1288 usb_serial_debug_data (debug, &port->dev, __func__,
1352 urb->actual_length, data); 1289 urb->actual_length, data);
1353 1290
1354 spin_lock_irqsave(&priv->lock, flags); 1291 spin_lock_irqsave(&priv->lock, flags);
1355 /* check to see if status has changed */ 1292 /* check to see if status has changed */
1356 if (priv != NULL) { 1293 if (priv->current_status != priv->prev_status) {
1357 if (priv->current_status != priv->prev_status) { 1294 priv->diff_status |= priv->current_status ^
1358 priv->diff_status |= priv->current_status ^ 1295 priv->prev_status;
1359 priv->prev_status; 1296 wake_up_interruptible(&priv->delta_msr_wait);
1360 wake_up_interruptible(&priv->delta_msr_wait); 1297 priv->prev_status = priv->current_status;
1361 priv->prev_status = priv->current_status;
1362 }
1363 } 1298 }
1364 spin_unlock_irqrestore(&priv->lock, flags); 1299 spin_unlock_irqrestore(&priv->lock, flags);
1365 1300
@@ -1367,7 +1302,7 @@ static void cypress_read_int_callback(struct urb *urb)
1367 * though */ 1302 * though */
1368 if (tty && !(tty->termios->c_cflag & CLOCAL) && 1303 if (tty && !(tty->termios->c_cflag & CLOCAL) &&
1369 !(priv->current_status & UART_CD)) { 1304 !(priv->current_status & UART_CD)) {
1370 dbg("%s - calling hangup", __FUNCTION__); 1305 dbg("%s - calling hangup", __func__);
1371 tty_hangup(tty); 1306 tty_hangup(tty);
1372 goto continue_read; 1307 goto continue_read;
1373 } 1308 }
@@ -1380,7 +1315,7 @@ static void cypress_read_int_callback(struct urb *urb)
1380 if (priv->current_status & CYP_ERROR) { 1315 if (priv->current_status & CYP_ERROR) {
1381 spin_unlock_irqrestore(&priv->lock, flags); 1316 spin_unlock_irqrestore(&priv->lock, flags);
1382 tty_flag = TTY_PARITY; 1317 tty_flag = TTY_PARITY;
1383 dbg("%s - Parity Error detected", __FUNCTION__); 1318 dbg("%s - Parity Error detected", __func__);
1384 } else 1319 } else
1385 spin_unlock_irqrestore(&priv->lock, flags); 1320 spin_unlock_irqrestore(&priv->lock, flags);
1386 1321
@@ -1414,7 +1349,7 @@ continue_read:
1414 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); 1349 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC);
1415 if (result) { 1350 if (result) {
1416 dev_err(&urb->dev->dev, "%s - failed resubmitting " 1351 dev_err(&urb->dev->dev, "%s - failed resubmitting "
1417 "read urb, error %d\n", __FUNCTION__, 1352 "read urb, error %d\n", __func__,
1418 result); 1353 result);
1419 cypress_set_dead(port); 1354 cypress_set_dead(port);
1420 } 1355 }
@@ -1426,12 +1361,12 @@ continue_read:
1426 1361
1427static void cypress_write_int_callback(struct urb *urb) 1362static void cypress_write_int_callback(struct urb *urb)
1428{ 1363{
1429 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 1364 struct usb_serial_port *port = urb->context;
1430 struct cypress_private *priv = usb_get_serial_port_data(port); 1365 struct cypress_private *priv = usb_get_serial_port_data(port);
1431 int result; 1366 int result;
1432 int status = urb->status; 1367 int status = urb->status;
1433 1368
1434 dbg("%s - port %d", __FUNCTION__, port->number); 1369 dbg("%s - port %d", __func__, port->number);
1435 1370
1436 switch (status) { 1371 switch (status) {
1437 case 0: 1372 case 0:
@@ -1442,7 +1377,7 @@ static void cypress_write_int_callback(struct urb *urb)
1442 case -ESHUTDOWN: 1377 case -ESHUTDOWN:
1443 /* this urb is terminated, clean up */ 1378 /* this urb is terminated, clean up */
1444 dbg("%s - urb shutting down with status: %d", 1379 dbg("%s - urb shutting down with status: %d",
1445 __FUNCTION__, status); 1380 __func__, status);
1446 priv->write_urb_in_use = 0; 1381 priv->write_urb_in_use = 0;
1447 return; 1382 return;
1448 case -EPIPE: /* no break needed; clear halt and resubmit */ 1383 case -EPIPE: /* no break needed; clear halt and resubmit */
@@ -1451,19 +1386,19 @@ static void cypress_write_int_callback(struct urb *urb)
1451 usb_clear_halt(port->serial->dev, 0x02); 1386 usb_clear_halt(port->serial->dev, 0x02);
1452 /* error in the urb, so we have to resubmit it */ 1387 /* error in the urb, so we have to resubmit it */
1453 dbg("%s - nonzero write bulk status received: %d", 1388 dbg("%s - nonzero write bulk status received: %d",
1454 __FUNCTION__, status); 1389 __func__, status);
1455 port->interrupt_out_urb->transfer_buffer_length = 1; 1390 port->interrupt_out_urb->transfer_buffer_length = 1;
1456 port->interrupt_out_urb->dev = port->serial->dev; 1391 port->interrupt_out_urb->dev = port->serial->dev;
1457 result = usb_submit_urb(port->interrupt_out_urb, GFP_ATOMIC); 1392 result = usb_submit_urb(port->interrupt_out_urb, GFP_ATOMIC);
1458 if (!result) 1393 if (!result)
1459 return; 1394 return;
1460 dev_err(&urb->dev->dev, "%s - failed resubmitting write urb, error %d\n", 1395 dev_err(&urb->dev->dev, "%s - failed resubmitting write urb, error %d\n",
1461 __FUNCTION__, result); 1396 __func__, result);
1462 cypress_set_dead(port); 1397 cypress_set_dead(port);
1463 break; 1398 break;
1464 default: 1399 default:
1465 dev_err(&urb->dev->dev,"%s - unexpected nonzero write status received: %d\n", 1400 dev_err(&urb->dev->dev,"%s - unexpected nonzero write status received: %d\n",
1466 __FUNCTION__, status); 1401 __func__, status);
1467 cypress_set_dead(port); 1402 cypress_set_dead(port);
1468 break; 1403 break;
1469 } 1404 }
@@ -1668,7 +1603,7 @@ static int __init cypress_init(void)
1668{ 1603{
1669 int retval; 1604 int retval;
1670 1605
1671 dbg("%s", __FUNCTION__); 1606 dbg("%s", __func__);
1672 1607
1673 retval = usb_serial_register(&cypress_earthmate_device); 1608 retval = usb_serial_register(&cypress_earthmate_device);
1674 if (retval) 1609 if (retval)
@@ -1699,7 +1634,7 @@ failed_em_register:
1699 1634
1700static void __exit cypress_exit (void) 1635static void __exit cypress_exit (void)
1701{ 1636{
1702 dbg("%s", __FUNCTION__); 1637 dbg("%s", __func__);
1703 1638
1704 usb_deregister (&cypress_driver); 1639 usb_deregister (&cypress_driver);
1705 usb_serial_deregister (&cypress_earthmate_device); 1640 usb_serial_deregister (&cypress_earthmate_device);
diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c
index 5f9c6e46bee..d17d1645714 100644
--- a/drivers/usb/serial/digi_acceleport.c
+++ b/drivers/usb/serial/digi_acceleport.c
@@ -508,9 +508,6 @@ static struct usb_serial_driver digi_acceleport_2_device = {
508 .description = "Digi 2 port USB adapter", 508 .description = "Digi 2 port USB adapter",
509 .usb_driver = &digi_driver, 509 .usb_driver = &digi_driver,
510 .id_table = id_table_2, 510 .id_table = id_table_2,
511 .num_interrupt_in = 0,
512 .num_bulk_in = 4,
513 .num_bulk_out = 4,
514 .num_ports = 3, 511 .num_ports = 3,
515 .open = digi_open, 512 .open = digi_open,
516 .close = digi_close, 513 .close = digi_close,
@@ -538,9 +535,6 @@ static struct usb_serial_driver digi_acceleport_4_device = {
538 .description = "Digi 4 port USB adapter", 535 .description = "Digi 4 port USB adapter",
539 .usb_driver = &digi_driver, 536 .usb_driver = &digi_driver,
540 .id_table = id_table_4, 537 .id_table = id_table_4,
541 .num_interrupt_in = 0,
542 .num_bulk_in = 5,
543 .num_bulk_out = 5,
544 .num_ports = 4, 538 .num_ports = 4,
545 .open = digi_open, 539 .open = digi_open,
546 .close = digi_close, 540 .close = digi_close,
@@ -665,7 +659,7 @@ static int digi_write_oob_command(struct usb_serial_port *port,
665 } 659 }
666 spin_unlock_irqrestore(&oob_priv->dp_port_lock, flags); 660 spin_unlock_irqrestore(&oob_priv->dp_port_lock, flags);
667 if (ret) 661 if (ret)
668 err("%s: usb_submit_urb failed, ret=%d", __FUNCTION__, ret); 662 err("%s: usb_submit_urb failed, ret=%d", __func__, ret);
669 return ret; 663 return ret;
670 664
671} 665}
@@ -746,7 +740,7 @@ static int digi_write_inb_command(struct usb_serial_port *port,
746 740
747 if (ret) 741 if (ret)
748 err("%s: usb_submit_urb failed, ret=%d, port=%d", 742 err("%s: usb_submit_urb failed, ret=%d, port=%d",
749 __FUNCTION__, ret, priv->dp_port_num); 743 __func__, ret, priv->dp_port_num);
750 return ret; 744 return ret;
751} 745}
752 746
@@ -810,7 +804,7 @@ static int digi_set_modem_signals(struct usb_serial_port *port,
810 spin_unlock(&port_priv->dp_port_lock); 804 spin_unlock(&port_priv->dp_port_lock);
811 spin_unlock_irqrestore(&oob_priv->dp_port_lock, flags); 805 spin_unlock_irqrestore(&oob_priv->dp_port_lock, flags);
812 if (ret) 806 if (ret)
813 err("%s: usb_submit_urb failed, ret=%d", __FUNCTION__, ret); 807 err("%s: usb_submit_urb failed, ret=%d", __func__, ret);
814 return ret; 808 return ret;
815} 809}
816 810
@@ -903,7 +897,7 @@ static void digi_rx_unthrottle(struct usb_serial_port *port)
903 897
904 if (ret) 898 if (ret)
905 err("%s: usb_submit_urb failed, ret=%d, port=%d", 899 err("%s: usb_submit_urb failed, ret=%d, port=%d",
906 __FUNCTION__, ret, priv->dp_port_num); 900 __func__, ret, priv->dp_port_num);
907} 901}
908 902
909 903
@@ -1113,7 +1107,7 @@ static int digi_tiocmget(struct usb_serial_port *port, struct file *file)
1113 unsigned int val; 1107 unsigned int val;
1114 unsigned long flags; 1108 unsigned long flags;
1115 1109
1116 dbg("%s: TOP: port=%d", __FUNCTION__, priv->dp_port_num); 1110 dbg("%s: TOP: port=%d", __func__, priv->dp_port_num);
1117 1111
1118 spin_lock_irqsave(&priv->dp_port_lock, flags); 1112 spin_lock_irqsave(&priv->dp_port_lock, flags);
1119 val = priv->dp_modem_signals; 1113 val = priv->dp_modem_signals;
@@ -1129,7 +1123,7 @@ static int digi_tiocmset(struct usb_serial_port *port, struct file *file,
1129 unsigned int val; 1123 unsigned int val;
1130 unsigned long flags; 1124 unsigned long flags;
1131 1125
1132 dbg("%s: TOP: port=%d", __FUNCTION__, priv->dp_port_num); 1126 dbg("%s: TOP: port=%d", __func__, priv->dp_port_num);
1133 1127
1134 spin_lock_irqsave(&priv->dp_port_lock, flags); 1128 spin_lock_irqsave(&priv->dp_port_lock, flags);
1135 val = (priv->dp_modem_signals & ~clear) | set; 1129 val = (priv->dp_modem_signals & ~clear) | set;
@@ -1224,7 +1218,7 @@ static int digi_write(struct usb_serial_port *port, const unsigned char *buf, in
1224 spin_unlock_irqrestore(&priv->dp_port_lock, flags); 1218 spin_unlock_irqrestore(&priv->dp_port_lock, flags);
1225 if (ret < 0) 1219 if (ret < 0)
1226 err("%s: usb_submit_urb failed, ret=%d, port=%d", 1220 err("%s: usb_submit_urb failed, ret=%d, port=%d",
1227 __FUNCTION__, ret, priv->dp_port_num); 1221 __func__, ret, priv->dp_port_num);
1228 dbg("digi_write: returning %d", ret); 1222 dbg("digi_write: returning %d", ret);
1229 return ret; 1223 return ret;
1230 1224
@@ -1233,7 +1227,7 @@ static int digi_write(struct usb_serial_port *port, const unsigned char *buf, in
1233static void digi_write_bulk_callback(struct urb *urb) 1227static void digi_write_bulk_callback(struct urb *urb)
1234{ 1228{
1235 1229
1236 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 1230 struct usb_serial_port *port = urb->context;
1237 struct usb_serial *serial; 1231 struct usb_serial *serial;
1238 struct digi_port *priv; 1232 struct digi_port *priv;
1239 struct digi_serial *serial_priv; 1233 struct digi_serial *serial_priv;
@@ -1245,13 +1239,13 @@ static void digi_write_bulk_callback(struct urb *urb)
1245 /* port and serial sanity check */ 1239 /* port and serial sanity check */
1246 if (port == NULL || (priv=usb_get_serial_port_data(port)) == NULL) { 1240 if (port == NULL || (priv=usb_get_serial_port_data(port)) == NULL) {
1247 err("%s: port or port->private is NULL, status=%d", 1241 err("%s: port or port->private is NULL, status=%d",
1248 __FUNCTION__, status); 1242 __func__, status);
1249 return; 1243 return;
1250 } 1244 }
1251 serial = port->serial; 1245 serial = port->serial;
1252 if (serial == NULL || (serial_priv=usb_get_serial_data(serial)) == NULL) { 1246 if (serial == NULL || (serial_priv=usb_get_serial_data(serial)) == NULL) {
1253 err("%s: serial or serial->private is NULL, status=%d", 1247 err("%s: serial or serial->private is NULL, status=%d",
1254 __FUNCTION__, status); 1248 __func__, status);
1255 return; 1249 return;
1256 } 1250 }
1257 1251
@@ -1292,7 +1286,7 @@ static void digi_write_bulk_callback(struct urb *urb)
1292 spin_unlock(&priv->dp_port_lock); 1286 spin_unlock(&priv->dp_port_lock);
1293 if (ret) 1287 if (ret)
1294 err("%s: usb_submit_urb failed, ret=%d, port=%d", 1288 err("%s: usb_submit_urb failed, ret=%d, port=%d",
1295 __FUNCTION__, ret, priv->dp_port_num); 1289 __func__, ret, priv->dp_port_num);
1296} 1290}
1297 1291
1298static int digi_write_room(struct usb_serial_port *port) 1292static int digi_write_room(struct usb_serial_port *port)
@@ -1521,7 +1515,7 @@ static int digi_startup_device(struct usb_serial *serial)
1521 port->write_urb->dev = port->serial->dev; 1515 port->write_urb->dev = port->serial->dev;
1522 if ((ret = usb_submit_urb(port->read_urb, GFP_KERNEL)) != 0) { 1516 if ((ret = usb_submit_urb(port->read_urb, GFP_KERNEL)) != 0) {
1523 err("%s: usb_submit_urb failed, ret=%d, port=%d", 1517 err("%s: usb_submit_urb failed, ret=%d, port=%d",
1524 __FUNCTION__, ret, i); 1518 __func__, ret, i);
1525 break; 1519 break;
1526 } 1520 }
1527 } 1521 }
@@ -1611,7 +1605,7 @@ static void digi_shutdown(struct usb_serial *serial)
1611 1605
1612static void digi_read_bulk_callback(struct urb *urb) 1606static void digi_read_bulk_callback(struct urb *urb)
1613{ 1607{
1614 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 1608 struct usb_serial_port *port = urb->context;
1615 struct digi_port *priv; 1609 struct digi_port *priv;
1616 struct digi_serial *serial_priv; 1610 struct digi_serial *serial_priv;
1617 int ret; 1611 int ret;
@@ -1622,20 +1616,20 @@ static void digi_read_bulk_callback(struct urb *urb)
1622 /* port sanity check, do not resubmit if port is not valid */ 1616 /* port sanity check, do not resubmit if port is not valid */
1623 if (port == NULL || (priv = usb_get_serial_port_data(port)) == NULL) { 1617 if (port == NULL || (priv = usb_get_serial_port_data(port)) == NULL) {
1624 err("%s: port or port->private is NULL, status=%d", 1618 err("%s: port or port->private is NULL, status=%d",
1625 __FUNCTION__, status); 1619 __func__, status);
1626 return; 1620 return;
1627 } 1621 }
1628 if (port->serial == NULL || 1622 if (port->serial == NULL ||
1629 (serial_priv=usb_get_serial_data(port->serial)) == NULL) { 1623 (serial_priv=usb_get_serial_data(port->serial)) == NULL) {
1630 err("%s: serial is bad or serial->private is NULL, status=%d", 1624 err("%s: serial is bad or serial->private is NULL, status=%d",
1631 __FUNCTION__, status); 1625 __func__, status);
1632 return; 1626 return;
1633 } 1627 }
1634 1628
1635 /* do not resubmit urb if it has any status error */ 1629 /* do not resubmit urb if it has any status error */
1636 if (status) { 1630 if (status) {
1637 err("%s: nonzero read bulk status: status=%d, port=%d", 1631 err("%s: nonzero read bulk status: status=%d, port=%d",
1638 __FUNCTION__, status, priv->dp_port_num); 1632 __func__, status, priv->dp_port_num);
1639 return; 1633 return;
1640 } 1634 }
1641 1635
@@ -1652,7 +1646,7 @@ static void digi_read_bulk_callback(struct urb *urb)
1652 urb->dev = port->serial->dev; 1646 urb->dev = port->serial->dev;
1653 if ((ret = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { 1647 if ((ret = usb_submit_urb(urb, GFP_ATOMIC)) != 0) {
1654 err("%s: failed resubmitting urb, ret=%d, port=%d", 1648 err("%s: failed resubmitting urb, ret=%d, port=%d",
1655 __FUNCTION__, ret, priv->dp_port_num); 1649 __func__, ret, priv->dp_port_num);
1656 } 1650 }
1657 1651
1658} 1652}
@@ -1670,7 +1664,7 @@ static void digi_read_bulk_callback(struct urb *urb)
1670static int digi_read_inb_callback(struct urb *urb) 1664static int digi_read_inb_callback(struct urb *urb)
1671{ 1665{
1672 1666
1673 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 1667 struct usb_serial_port *port = urb->context;
1674 struct tty_struct *tty = port->tty; 1668 struct tty_struct *tty = port->tty;
1675 struct digi_port *priv = usb_get_serial_port_data(port); 1669 struct digi_port *priv = usb_get_serial_port_data(port);
1676 int opcode = ((unsigned char *)urb->transfer_buffer)[0]; 1670 int opcode = ((unsigned char *)urb->transfer_buffer)[0];
@@ -1690,7 +1684,7 @@ static int digi_read_inb_callback(struct urb *urb)
1690 if (urb->actual_length != len + 2) { 1684 if (urb->actual_length != len + 2) {
1691 err("%s: INCOMPLETE OR MULTIPLE PACKET, urb->status=%d, " 1685 err("%s: INCOMPLETE OR MULTIPLE PACKET, urb->status=%d, "
1692 "port=%d, opcode=%d, len=%d, actual_length=%d, " 1686 "port=%d, opcode=%d, len=%d, actual_length=%d, "
1693 "status=%d", __FUNCTION__, status, priv->dp_port_num, 1687 "status=%d", __func__, status, priv->dp_port_num,
1694 opcode, len, urb->actual_length, port_status); 1688 opcode, len, urb->actual_length, port_status);
1695 return -1; 1689 return -1;
1696 } 1690 }
@@ -1739,9 +1733,9 @@ static int digi_read_inb_callback(struct urb *urb)
1739 spin_unlock(&priv->dp_port_lock); 1733 spin_unlock(&priv->dp_port_lock);
1740 1734
1741 if (opcode == DIGI_CMD_RECEIVE_DISABLE) 1735 if (opcode == DIGI_CMD_RECEIVE_DISABLE)
1742 dbg("%s: got RECEIVE_DISABLE", __FUNCTION__); 1736 dbg("%s: got RECEIVE_DISABLE", __func__);
1743 else if (opcode != DIGI_CMD_RECEIVE_DATA) 1737 else if (opcode != DIGI_CMD_RECEIVE_DATA)
1744 dbg("%s: unknown opcode: %d", __FUNCTION__, opcode); 1738 dbg("%s: unknown opcode: %d", __func__, opcode);
1745 1739
1746 return(throttled ? 1 : 0); 1740 return(throttled ? 1 : 0);
1747 1741
@@ -1760,7 +1754,7 @@ static int digi_read_inb_callback(struct urb *urb)
1760static int digi_read_oob_callback(struct urb *urb) 1754static int digi_read_oob_callback(struct urb *urb)
1761{ 1755{
1762 1756
1763 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 1757 struct usb_serial_port *port = urb->context;
1764 struct usb_serial *serial = port->serial; 1758 struct usb_serial *serial = port->serial;
1765 struct digi_port *priv = usb_get_serial_port_data(port); 1759 struct digi_port *priv = usb_get_serial_port_data(port);
1766 int opcode, line, status, val; 1760 int opcode, line, status, val;
diff --git a/drivers/usb/serial/empeg.c b/drivers/usb/serial/empeg.c
index a5c8e1e17ea..c5ec309a3cb 100644
--- a/drivers/usb/serial/empeg.c
+++ b/drivers/usb/serial/empeg.c
@@ -118,9 +118,6 @@ static struct usb_serial_driver empeg_device = {
118 }, 118 },
119 .id_table = id_table, 119 .id_table = id_table,
120 .usb_driver = &empeg_driver, 120 .usb_driver = &empeg_driver,
121 .num_interrupt_in = 0,
122 .num_bulk_in = 1,
123 .num_bulk_out = 1,
124 .num_ports = 1, 121 .num_ports = 1,
125 .open = empeg_open, 122 .open = empeg_open,
126 .close = empeg_close, 123 .close = empeg_close,
@@ -153,7 +150,7 @@ static int empeg_open (struct usb_serial_port *port, struct file *filp)
153 struct usb_serial *serial = port->serial; 150 struct usb_serial *serial = port->serial;
154 int result = 0; 151 int result = 0;
155 152
156 dbg("%s - port %d", __FUNCTION__, port->number); 153 dbg("%s - port %d", __func__, port->number);
157 154
158 /* Force default termio settings */ 155 /* Force default termio settings */
159 empeg_set_termios (port, NULL) ; 156 empeg_set_termios (port, NULL) ;
@@ -175,7 +172,7 @@ static int empeg_open (struct usb_serial_port *port, struct file *filp)
175 result = usb_submit_urb(port->read_urb, GFP_KERNEL); 172 result = usb_submit_urb(port->read_urb, GFP_KERNEL);
176 173
177 if (result) 174 if (result)
178 dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", __FUNCTION__, result); 175 dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", __func__, result);
179 176
180 return result; 177 return result;
181} 178}
@@ -183,7 +180,7 @@ static int empeg_open (struct usb_serial_port *port, struct file *filp)
183 180
184static void empeg_close (struct usb_serial_port *port, struct file * filp) 181static void empeg_close (struct usb_serial_port *port, struct file * filp)
185{ 182{
186 dbg("%s - port %d", __FUNCTION__, port->number); 183 dbg("%s - port %d", __func__, port->number);
187 184
188 /* shutdown our bulk read */ 185 /* shutdown our bulk read */
189 usb_kill_urb(port->read_urb); 186 usb_kill_urb(port->read_urb);
@@ -203,7 +200,7 @@ static int empeg_write (struct usb_serial_port *port, const unsigned char *buf,
203 int bytes_sent = 0; 200 int bytes_sent = 0;
204 int transfer_size; 201 int transfer_size;
205 202
206 dbg("%s - port %d", __FUNCTION__, port->number); 203 dbg("%s - port %d", __func__, port->number);
207 204
208 while (count > 0) { 205 while (count > 0) {
209 206
@@ -222,14 +219,14 @@ static int empeg_write (struct usb_serial_port *port, const unsigned char *buf,
222 spin_unlock_irqrestore (&write_urb_pool_lock, flags); 219 spin_unlock_irqrestore (&write_urb_pool_lock, flags);
223 220
224 if (urb == NULL) { 221 if (urb == NULL) {
225 dbg("%s - no more free urbs", __FUNCTION__); 222 dbg("%s - no more free urbs", __func__);
226 goto exit; 223 goto exit;
227 } 224 }
228 225
229 if (urb->transfer_buffer == NULL) { 226 if (urb->transfer_buffer == NULL) {
230 urb->transfer_buffer = kmalloc (URB_TRANSFER_BUFFER_SIZE, GFP_ATOMIC); 227 urb->transfer_buffer = kmalloc (URB_TRANSFER_BUFFER_SIZE, GFP_ATOMIC);
231 if (urb->transfer_buffer == NULL) { 228 if (urb->transfer_buffer == NULL) {
232 dev_err(&port->dev, "%s no more kernel memory...\n", __FUNCTION__); 229 dev_err(&port->dev, "%s no more kernel memory...\n", __func__);
233 goto exit; 230 goto exit;
234 } 231 }
235 } 232 }
@@ -238,7 +235,7 @@ static int empeg_write (struct usb_serial_port *port, const unsigned char *buf,
238 235
239 memcpy (urb->transfer_buffer, current_position, transfer_size); 236 memcpy (urb->transfer_buffer, current_position, transfer_size);
240 237
241 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, transfer_size, urb->transfer_buffer); 238 usb_serial_debug_data(debug, &port->dev, __func__, transfer_size, urb->transfer_buffer);
242 239
243 /* build up our urb */ 240 /* build up our urb */
244 usb_fill_bulk_urb ( 241 usb_fill_bulk_urb (
@@ -254,7 +251,7 @@ static int empeg_write (struct usb_serial_port *port, const unsigned char *buf,
254 /* send it down the pipe */ 251 /* send it down the pipe */
255 status = usb_submit_urb(urb, GFP_ATOMIC); 252 status = usb_submit_urb(urb, GFP_ATOMIC);
256 if (status) { 253 if (status) {
257 dev_err(&port->dev, "%s - usb_submit_urb(write bulk) failed with status = %d\n", __FUNCTION__, status); 254 dev_err(&port->dev, "%s - usb_submit_urb(write bulk) failed with status = %d\n", __func__, status);
258 bytes_sent = status; 255 bytes_sent = status;
259 break; 256 break;
260 } 257 }
@@ -278,7 +275,7 @@ static int empeg_write_room (struct usb_serial_port *port)
278 int i; 275 int i;
279 int room = 0; 276 int room = 0;
280 277
281 dbg("%s - port %d", __FUNCTION__, port->number); 278 dbg("%s - port %d", __func__, port->number);
282 279
283 spin_lock_irqsave (&write_urb_pool_lock, flags); 280 spin_lock_irqsave (&write_urb_pool_lock, flags);
284 281
@@ -291,7 +288,7 @@ static int empeg_write_room (struct usb_serial_port *port)
291 288
292 spin_unlock_irqrestore (&write_urb_pool_lock, flags); 289 spin_unlock_irqrestore (&write_urb_pool_lock, flags);
293 290
294 dbg("%s - returns %d", __FUNCTION__, room); 291 dbg("%s - returns %d", __func__, room);
295 292
296 return (room); 293 return (room);
297 294
@@ -304,7 +301,7 @@ static int empeg_chars_in_buffer (struct usb_serial_port *port)
304 int i; 301 int i;
305 int chars = 0; 302 int chars = 0;
306 303
307 dbg("%s - port %d", __FUNCTION__, port->number); 304 dbg("%s - port %d", __func__, port->number);
308 305
309 spin_lock_irqsave (&write_urb_pool_lock, flags); 306 spin_lock_irqsave (&write_urb_pool_lock, flags);
310 307
@@ -317,7 +314,7 @@ static int empeg_chars_in_buffer (struct usb_serial_port *port)
317 314
318 spin_unlock_irqrestore (&write_urb_pool_lock, flags); 315 spin_unlock_irqrestore (&write_urb_pool_lock, flags);
319 316
320 dbg("%s - returns %d", __FUNCTION__, chars); 317 dbg("%s - returns %d", __func__, chars);
321 318
322 return (chars); 319 return (chars);
323 320
@@ -329,11 +326,11 @@ static void empeg_write_bulk_callback (struct urb *urb)
329 struct usb_serial_port *port = urb->context; 326 struct usb_serial_port *port = urb->context;
330 int status = urb->status; 327 int status = urb->status;
331 328
332 dbg("%s - port %d", __FUNCTION__, port->number); 329 dbg("%s - port %d", __func__, port->number);
333 330
334 if (status) { 331 if (status) {
335 dbg("%s - nonzero write bulk status received: %d", 332 dbg("%s - nonzero write bulk status received: %d",
336 __FUNCTION__, status); 333 __func__, status);
337 return; 334 return;
338 } 335 }
339 336
@@ -343,21 +340,21 @@ static void empeg_write_bulk_callback (struct urb *urb)
343 340
344static void empeg_read_bulk_callback (struct urb *urb) 341static void empeg_read_bulk_callback (struct urb *urb)
345{ 342{
346 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 343 struct usb_serial_port *port = urb->context;
347 struct tty_struct *tty; 344 struct tty_struct *tty;
348 unsigned char *data = urb->transfer_buffer; 345 unsigned char *data = urb->transfer_buffer;
349 int result; 346 int result;
350 int status = urb->status; 347 int status = urb->status;
351 348
352 dbg("%s - port %d", __FUNCTION__, port->number); 349 dbg("%s - port %d", __func__, port->number);
353 350
354 if (status) { 351 if (status) {
355 dbg("%s - nonzero read bulk status received: %d", 352 dbg("%s - nonzero read bulk status received: %d",
356 __FUNCTION__, status); 353 __func__, status);
357 return; 354 return;
358 } 355 }
359 356
360 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, urb->actual_length, data); 357 usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data);
361 358
362 tty = port->tty; 359 tty = port->tty;
363 360
@@ -382,7 +379,7 @@ static void empeg_read_bulk_callback (struct urb *urb)
382 result = usb_submit_urb(port->read_urb, GFP_ATOMIC); 379 result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
383 380
384 if (result) 381 if (result)
385 dev_err(&urb->dev->dev, "%s - failed resubmitting read urb, error %d\n", __FUNCTION__, result); 382 dev_err(&urb->dev->dev, "%s - failed resubmitting read urb, error %d\n", __func__, result);
386 383
387 return; 384 return;
388 385
@@ -391,7 +388,7 @@ static void empeg_read_bulk_callback (struct urb *urb)
391 388
392static void empeg_throttle (struct usb_serial_port *port) 389static void empeg_throttle (struct usb_serial_port *port)
393{ 390{
394 dbg("%s - port %d", __FUNCTION__, port->number); 391 dbg("%s - port %d", __func__, port->number);
395 usb_kill_urb(port->read_urb); 392 usb_kill_urb(port->read_urb);
396} 393}
397 394
@@ -400,14 +397,14 @@ static void empeg_unthrottle (struct usb_serial_port *port)
400{ 397{
401 int result; 398 int result;
402 399
403 dbg("%s - port %d", __FUNCTION__, port->number); 400 dbg("%s - port %d", __func__, port->number);
404 401
405 port->read_urb->dev = port->serial->dev; 402 port->read_urb->dev = port->serial->dev;
406 403
407 result = usb_submit_urb(port->read_urb, GFP_ATOMIC); 404 result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
408 405
409 if (result) 406 if (result)
410 dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", __FUNCTION__, result); 407 dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", __func__, result);
411 408
412 return; 409 return;
413} 410}
@@ -417,14 +414,14 @@ static int empeg_startup (struct usb_serial *serial)
417{ 414{
418 int r; 415 int r;
419 416
420 dbg("%s", __FUNCTION__); 417 dbg("%s", __func__);
421 418
422 if (serial->dev->actconfig->desc.bConfigurationValue != 1) { 419 if (serial->dev->actconfig->desc.bConfigurationValue != 1) {
423 err("active config #%d != 1 ??", 420 err("active config #%d != 1 ??",
424 serial->dev->actconfig->desc.bConfigurationValue); 421 serial->dev->actconfig->desc.bConfigurationValue);
425 return -ENODEV; 422 return -ENODEV;
426 } 423 }
427 dbg("%s - reset config", __FUNCTION__); 424 dbg("%s - reset config", __func__);
428 r = usb_reset_configuration (serial->dev); 425 r = usb_reset_configuration (serial->dev);
429 426
430 /* continue on with initialization */ 427 /* continue on with initialization */
@@ -435,13 +432,13 @@ static int empeg_startup (struct usb_serial *serial)
435 432
436static void empeg_shutdown (struct usb_serial *serial) 433static void empeg_shutdown (struct usb_serial *serial)
437{ 434{
438 dbg ("%s", __FUNCTION__); 435 dbg ("%s", __func__);
439} 436}
440 437
441 438
442static int empeg_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg) 439static int empeg_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg)
443{ 440{
444 dbg("%s - port %d, cmd 0x%.4x", __FUNCTION__, port->number, cmd); 441 dbg("%s - port %d, cmd 0x%.4x", __func__, port->number, cmd);
445 442
446 return -ENOIOCTLCMD; 443 return -ENOIOCTLCMD;
447} 444}
@@ -450,7 +447,7 @@ static int empeg_ioctl (struct usb_serial_port *port, struct file * file, unsign
450static void empeg_set_termios (struct usb_serial_port *port, struct ktermios *old_termios) 447static void empeg_set_termios (struct usb_serial_port *port, struct ktermios *old_termios)
451{ 448{
452 struct ktermios *termios = port->tty->termios; 449 struct ktermios *termios = port->tty->termios;
453 dbg("%s - port %d", __FUNCTION__, port->number); 450 dbg("%s - port %d", __func__, port->number);
454 451
455 /* 452 /*
456 * The empeg-car player wants these particular tty settings. 453 * The empeg-car player wants these particular tty settings.
@@ -517,7 +514,7 @@ static int __init empeg_init (void)
517 urb->transfer_buffer = kmalloc (URB_TRANSFER_BUFFER_SIZE, GFP_KERNEL); 514 urb->transfer_buffer = kmalloc (URB_TRANSFER_BUFFER_SIZE, GFP_KERNEL);
518 if (!urb->transfer_buffer) { 515 if (!urb->transfer_buffer) {
519 err("%s - out of memory for urb buffers.", 516 err("%s - out of memory for urb buffers.",
520 __FUNCTION__); 517 __func__);
521 continue; 518 continue;
522 } 519 }
523 } 520 }
diff --git a/drivers/usb/serial/ezusb.c b/drivers/usb/serial/ezusb.c
index 3f698baa0ab..cc4fbd9d60b 100644
--- a/drivers/usb/serial/ezusb.c
+++ b/drivers/usb/serial/ezusb.c
@@ -27,13 +27,13 @@ int ezusb_writememory (struct usb_serial *serial, int address, unsigned char *da
27 27
28 /* dbg("ezusb_writememory %x, %d", address, length); */ 28 /* dbg("ezusb_writememory %x, %d", address, length); */
29 if (!serial->dev) { 29 if (!serial->dev) {
30 err("%s - no physical device present, failing.", __FUNCTION__); 30 err("%s - no physical device present, failing.", __func__);
31 return -ENODEV; 31 return -ENODEV;
32 } 32 }
33 33
34 transfer_buffer = kmemdup(data, length, GFP_KERNEL); 34 transfer_buffer = kmemdup(data, length, GFP_KERNEL);
35 if (!transfer_buffer) { 35 if (!transfer_buffer) {
36 dev_err(&serial->dev->dev, "%s - kmalloc(%d) failed.\n", __FUNCTION__, length); 36 dev_err(&serial->dev->dev, "%s - kmalloc(%d) failed.\n", __func__, length);
37 return -ENOMEM; 37 return -ENOMEM;
38 } 38 }
39 result = usb_control_msg (serial->dev, usb_sndctrlpipe(serial->dev, 0), bRequest, 0x40, address, 0, transfer_buffer, length, 3000); 39 result = usb_control_msg (serial->dev, usb_sndctrlpipe(serial->dev, 0), bRequest, 0x40, address, 0, transfer_buffer, length, 3000);
@@ -45,10 +45,10 @@ int ezusb_set_reset (struct usb_serial *serial, unsigned char reset_bit)
45{ 45{
46 int response; 46 int response;
47 47
48 /* dbg("%s - %d", __FUNCTION__, reset_bit); */ 48 /* dbg("%s - %d", __func__, reset_bit); */
49 response = ezusb_writememory (serial, CPUCS_REG, &reset_bit, 1, 0xa0); 49 response = ezusb_writememory (serial, CPUCS_REG, &reset_bit, 1, 0xa0);
50 if (response < 0) 50 if (response < 0)
51 dev_err(&serial->dev->dev, "%s- %d failed\n", __FUNCTION__, reset_bit); 51 dev_err(&serial->dev->dev, "%s- %d failed\n", __func__, reset_bit);
52 return response; 52 return response;
53} 53}
54 54
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 3abb3c86364..23f51a41093 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -439,9 +439,6 @@ static struct usb_serial_driver ftdi_sio_device = {
439 .description = "FTDI USB Serial Device", 439 .description = "FTDI USB Serial Device",
440 .usb_driver = &ftdi_driver , 440 .usb_driver = &ftdi_driver ,
441 .id_table = id_table_combined, 441 .id_table = id_table_combined,
442 .num_interrupt_in = 0,
443 .num_bulk_in = 1,
444 .num_bulk_out = 1,
445 .num_ports = 1, 442 .num_ports = 1,
446 .probe = ftdi_sio_probe, 443 .probe = ftdi_sio_probe,
447 .port_probe = ftdi_sio_port_probe, 444 .port_probe = ftdi_sio_port_probe,
@@ -528,14 +525,13 @@ static int update_mctrl(struct usb_serial_port *port, unsigned int set, unsigned
528 int rv; 525 int rv;
529 526
530 if (((set | clear) & (TIOCM_DTR | TIOCM_RTS)) == 0) { 527 if (((set | clear) & (TIOCM_DTR | TIOCM_RTS)) == 0) {
531 dbg("%s - DTR|RTS not being set|cleared", __FUNCTION__); 528 dbg("%s - DTR|RTS not being set|cleared", __func__);
532 return 0; /* no change */ 529 return 0; /* no change */
533 } 530 }
534 531
535 buf = kmalloc(1, GFP_NOIO); 532 buf = kmalloc(1, GFP_NOIO);
536 if (!buf) { 533 if (!buf)
537 return -ENOMEM; 534 return -ENOMEM;
538 }
539 535
540 clear &= ~set; /* 'set' takes precedence over 'clear' */ 536 clear &= ~set; /* 'set' takes precedence over 'clear' */
541 urb_value = 0; 537 urb_value = 0;
@@ -557,17 +553,18 @@ static int update_mctrl(struct usb_serial_port *port, unsigned int set, unsigned
557 kfree(buf); 553 kfree(buf);
558 if (rv < 0) { 554 if (rv < 0) {
559 err("%s Error from MODEM_CTRL urb: DTR %s, RTS %s", 555 err("%s Error from MODEM_CTRL urb: DTR %s, RTS %s",
560 __FUNCTION__, 556 __func__,
561 (set & TIOCM_DTR) ? "HIGH" : 557 (set & TIOCM_DTR) ? "HIGH" :
562 (clear & TIOCM_DTR) ? "LOW" : "unchanged", 558 (clear & TIOCM_DTR) ? "LOW" : "unchanged",
563 (set & TIOCM_RTS) ? "HIGH" : 559 (set & TIOCM_RTS) ? "HIGH" :
564 (clear & TIOCM_RTS) ? "LOW" : "unchanged"); 560 (clear & TIOCM_RTS) ? "LOW" : "unchanged");
565 } else { 561 } else {
566 dbg("%s - DTR %s, RTS %s", __FUNCTION__, 562 dbg("%s - DTR %s, RTS %s", __func__,
567 (set & TIOCM_DTR) ? "HIGH" : 563 (set & TIOCM_DTR) ? "HIGH" :
568 (clear & TIOCM_DTR) ? "LOW" : "unchanged", 564 (clear & TIOCM_DTR) ? "LOW" : "unchanged",
569 (set & TIOCM_RTS) ? "HIGH" : 565 (set & TIOCM_RTS) ? "HIGH" :
570 (clear & TIOCM_RTS) ? "LOW" : "unchanged"); 566 (clear & TIOCM_RTS) ? "LOW" : "unchanged");
567 /* FIXME: locking on last_dtr_rts */
571 priv->last_dtr_rts = (priv->last_dtr_rts & ~clear) | set; 568 priv->last_dtr_rts = (priv->last_dtr_rts & ~clear) | set;
572 } 569 }
573 return rv; 570 return rv;
@@ -642,7 +639,7 @@ static __u32 get_ftdi_divisor(struct usb_serial_port * port)
642 /* 1. Get the baud rate from the tty settings, this observes alt_speed hack */ 639 /* 1. Get the baud rate from the tty settings, this observes alt_speed hack */
643 640
644 baud = tty_get_baud_rate(port->tty); 641 baud = tty_get_baud_rate(port->tty);
645 dbg("%s - tty_get_baud_rate reports speed %d", __FUNCTION__, baud); 642 dbg("%s - tty_get_baud_rate reports speed %d", __func__, baud);
646 643
647 /* 2. Observe async-compatible custom_divisor hack, update baudrate if needed */ 644 /* 2. Observe async-compatible custom_divisor hack, update baudrate if needed */
648 645
@@ -650,7 +647,7 @@ static __u32 get_ftdi_divisor(struct usb_serial_port * port)
650 ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) && 647 ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) &&
651 (priv->custom_divisor)) { 648 (priv->custom_divisor)) {
652 baud = priv->baud_base / priv->custom_divisor; 649 baud = priv->baud_base / priv->custom_divisor;
653 dbg("%s - custom divisor %d sets baud rate to %d", __FUNCTION__, priv->custom_divisor, baud); 650 dbg("%s - custom divisor %d sets baud rate to %d", __func__, priv->custom_divisor, baud);
654 } 651 }
655 652
656 /* 3. Convert baudrate to device-specific divisor */ 653 /* 3. Convert baudrate to device-specific divisor */
@@ -671,7 +668,7 @@ static __u32 get_ftdi_divisor(struct usb_serial_port * port)
671 case 115200: div_value = ftdi_sio_b115200; break; 668 case 115200: div_value = ftdi_sio_b115200; break;
672 } /* baud */ 669 } /* baud */
673 if (div_value == 0) { 670 if (div_value == 0) {
674 dbg("%s - Baudrate (%d) requested is not supported", __FUNCTION__, baud); 671 dbg("%s - Baudrate (%d) requested is not supported", __func__, baud);
675 div_value = ftdi_sio_b9600; 672 div_value = ftdi_sio_b9600;
676 baud = 9600; 673 baud = 9600;
677 div_okay = 0; 674 div_okay = 0;
@@ -681,7 +678,7 @@ static __u32 get_ftdi_divisor(struct usb_serial_port * port)
681 if (baud <= 3000000) { 678 if (baud <= 3000000) {
682 div_value = ftdi_232am_baud_to_divisor(baud); 679 div_value = ftdi_232am_baud_to_divisor(baud);
683 } else { 680 } else {
684 dbg("%s - Baud rate too high!", __FUNCTION__); 681 dbg("%s - Baud rate too high!", __func__);
685 baud = 9600; 682 baud = 9600;
686 div_value = ftdi_232am_baud_to_divisor(9600); 683 div_value = ftdi_232am_baud_to_divisor(9600);
687 div_okay = 0; 684 div_okay = 0;
@@ -693,7 +690,7 @@ static __u32 get_ftdi_divisor(struct usb_serial_port * port)
693 if (baud <= 3000000) { 690 if (baud <= 3000000) {
694 div_value = ftdi_232bm_baud_to_divisor(baud); 691 div_value = ftdi_232bm_baud_to_divisor(baud);
695 } else { 692 } else {
696 dbg("%s - Baud rate too high!", __FUNCTION__); 693 dbg("%s - Baud rate too high!", __func__);
697 div_value = ftdi_232bm_baud_to_divisor(9600); 694 div_value = ftdi_232bm_baud_to_divisor(9600);
698 div_okay = 0; 695 div_okay = 0;
699 baud = 9600; 696 baud = 9600;
@@ -703,7 +700,7 @@ static __u32 get_ftdi_divisor(struct usb_serial_port * port)
703 700
704 if (div_okay) { 701 if (div_okay) {
705 dbg("%s - Baud rate set to %d (divisor 0x%lX) on chip %s", 702 dbg("%s - Baud rate set to %d (divisor 0x%lX) on chip %s",
706 __FUNCTION__, baud, (unsigned long)div_value, 703 __func__, baud, (unsigned long)div_value,
707 ftdi_chip_name[priv->chip_type]); 704 ftdi_chip_name[priv->chip_type]);
708 } 705 }
709 706
@@ -804,7 +801,7 @@ static void ftdi_determine_type(struct usb_serial_port *port)
804 801
805 version = le16_to_cpu(udev->descriptor.bcdDevice); 802 version = le16_to_cpu(udev->descriptor.bcdDevice);
806 interfaces = udev->actconfig->desc.bNumInterfaces; 803 interfaces = udev->actconfig->desc.bNumInterfaces;
807 dbg("%s: bcdDevice = 0x%x, bNumInterfaces = %u", __FUNCTION__, 804 dbg("%s: bcdDevice = 0x%x, bNumInterfaces = %u", __func__,
808 version, interfaces); 805 version, interfaces);
809 if (interfaces > 1) { 806 if (interfaces > 1) {
810 int inter; 807 int inter;
@@ -822,7 +819,7 @@ static void ftdi_determine_type(struct usb_serial_port *port)
822 * to 0x200 when iSerialNumber is 0. */ 819 * to 0x200 when iSerialNumber is 0. */
823 if (version < 0x500) { 820 if (version < 0x500) {
824 dbg("%s: something fishy - bcdDevice too low for multi-interface device", 821 dbg("%s: something fishy - bcdDevice too low for multi-interface device",
825 __FUNCTION__); 822 __func__);
826 } 823 }
827 } else if (version < 0x200) { 824 } else if (version < 0x200) {
828 /* Old device. Assume its the original SIO. */ 825 /* Old device. Assume its the original SIO. */
@@ -860,7 +857,7 @@ static ssize_t show_latency_timer(struct device *dev, struct device_attribute *a
860 int rv = 0; 857 int rv = 0;
861 858
862 859
863 dbg("%s",__FUNCTION__); 860 dbg("%s",__func__);
864 861
865 rv = usb_control_msg(udev, 862 rv = usb_control_msg(udev,
866 usb_rcvctrlpipe(udev, 0), 863 usb_rcvctrlpipe(udev, 0),
@@ -887,7 +884,7 @@ static ssize_t store_latency_timer(struct device *dev, struct device_attribute *
887 int v = simple_strtoul(valbuf, NULL, 10); 884 int v = simple_strtoul(valbuf, NULL, 10);
888 int rv = 0; 885 int rv = 0;
889 886
890 dbg("%s: setting latency timer = %i", __FUNCTION__, v); 887 dbg("%s: setting latency timer = %i", __func__, v);
891 888
892 rv = usb_control_msg(udev, 889 rv = usb_control_msg(udev,
893 usb_sndctrlpipe(udev, 0), 890 usb_sndctrlpipe(udev, 0),
@@ -916,7 +913,7 @@ static ssize_t store_event_char(struct device *dev, struct device_attribute *att
916 int v = simple_strtoul(valbuf, NULL, 10); 913 int v = simple_strtoul(valbuf, NULL, 10);
917 int rv = 0; 914 int rv = 0;
918 915
919 dbg("%s: setting event char = %i", __FUNCTION__, v); 916 dbg("%s: setting event char = %i", __func__, v);
920 917
921 rv = usb_control_msg(udev, 918 rv = usb_control_msg(udev,
922 usb_sndctrlpipe(udev, 0), 919 usb_sndctrlpipe(udev, 0),
@@ -941,7 +938,7 @@ static int create_sysfs_attrs(struct usb_serial_port *port)
941 struct ftdi_private *priv = usb_get_serial_port_data(port); 938 struct ftdi_private *priv = usb_get_serial_port_data(port);
942 int retval = 0; 939 int retval = 0;
943 940
944 dbg("%s",__FUNCTION__); 941 dbg("%s",__func__);
945 942
946 /* XXX I've no idea if the original SIO supports the event_char 943 /* XXX I've no idea if the original SIO supports the event_char
947 * sysfs parameter, so I'm playing it safe. */ 944 * sysfs parameter, so I'm playing it safe. */
@@ -963,7 +960,7 @@ static void remove_sysfs_attrs(struct usb_serial_port *port)
963{ 960{
964 struct ftdi_private *priv = usb_get_serial_port_data(port); 961 struct ftdi_private *priv = usb_get_serial_port_data(port);
965 962
966 dbg("%s",__FUNCTION__); 963 dbg("%s",__func__);
967 964
968 /* XXX see create_sysfs_attrs */ 965 /* XXX see create_sysfs_attrs */
969 if (priv->chip_type != SIO) { 966 if (priv->chip_type != SIO) {
@@ -1005,11 +1002,11 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port)
1005 struct ftdi_sio_quirk *quirk = usb_get_serial_data(port->serial); 1002 struct ftdi_sio_quirk *quirk = usb_get_serial_data(port->serial);
1006 1003
1007 1004
1008 dbg("%s",__FUNCTION__); 1005 dbg("%s",__func__);
1009 1006
1010 priv = kzalloc(sizeof(struct ftdi_private), GFP_KERNEL); 1007 priv = kzalloc(sizeof(struct ftdi_private), GFP_KERNEL);
1011 if (!priv){ 1008 if (!priv){
1012 err("%s- kmalloc(%Zd) failed.", __FUNCTION__, sizeof(struct ftdi_private)); 1009 err("%s- kmalloc(%Zd) failed.", __func__, sizeof(struct ftdi_private));
1013 return -ENOMEM; 1010 return -ENOMEM;
1014 } 1011 }
1015 1012
@@ -1058,7 +1055,7 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port)
1058/* Called from usbserial:serial_probe */ 1055/* Called from usbserial:serial_probe */
1059static void ftdi_USB_UIRT_setup (struct ftdi_private *priv) 1056static void ftdi_USB_UIRT_setup (struct ftdi_private *priv)
1060{ 1057{
1061 dbg("%s",__FUNCTION__); 1058 dbg("%s",__func__);
1062 1059
1063 priv->flags |= ASYNC_SPD_CUST; 1060 priv->flags |= ASYNC_SPD_CUST;
1064 priv->custom_divisor = 77; 1061 priv->custom_divisor = 77;
@@ -1069,7 +1066,7 @@ static void ftdi_USB_UIRT_setup (struct ftdi_private *priv)
1069 * baudrate (38400 gets mapped to 100000) and RTS-CTS enabled. */ 1066 * baudrate (38400 gets mapped to 100000) and RTS-CTS enabled. */
1070static void ftdi_HE_TIRA1_setup (struct ftdi_private *priv) 1067static void ftdi_HE_TIRA1_setup (struct ftdi_private *priv)
1071{ 1068{
1072 dbg("%s",__FUNCTION__); 1069 dbg("%s",__func__);
1073 1070
1074 priv->flags |= ASYNC_SPD_CUST; 1071 priv->flags |= ASYNC_SPD_CUST;
1075 priv->custom_divisor = 240; 1072 priv->custom_divisor = 240;
@@ -1087,7 +1084,7 @@ static int ftdi_jtag_probe(struct usb_serial *serial)
1087 struct usb_device *udev = serial->dev; 1084 struct usb_device *udev = serial->dev;
1088 struct usb_interface *interface = serial->interface; 1085 struct usb_interface *interface = serial->interface;
1089 1086
1090 dbg("%s",__FUNCTION__); 1087 dbg("%s",__func__);
1091 1088
1092 if (interface == udev->actconfig->interface[0]) { 1089 if (interface == udev->actconfig->interface[0]) {
1093 info("Ignoring serial port reserved for JTAG"); 1090 info("Ignoring serial port reserved for JTAG");
@@ -1123,14 +1120,14 @@ static int ftdi_mtxorb_hack_setup(struct usb_serial *serial)
1123 */ 1120 */
1124static void ftdi_shutdown (struct usb_serial *serial) 1121static void ftdi_shutdown (struct usb_serial *serial)
1125{ 1122{
1126 dbg("%s", __FUNCTION__); 1123 dbg("%s", __func__);
1127} 1124}
1128 1125
1129static int ftdi_sio_port_remove(struct usb_serial_port *port) 1126static int ftdi_sio_port_remove(struct usb_serial_port *port)
1130{ 1127{
1131 struct ftdi_private *priv = usb_get_serial_port_data(port); 1128 struct ftdi_private *priv = usb_get_serial_port_data(port);
1132 1129
1133 dbg("%s", __FUNCTION__); 1130 dbg("%s", __func__);
1134 1131
1135 remove_sysfs_attrs(port); 1132 remove_sysfs_attrs(port);
1136 1133
@@ -1155,7 +1152,7 @@ static int ftdi_open (struct usb_serial_port *port, struct file *filp)
1155 int result = 0; 1152 int result = 0;
1156 char buf[1]; /* Needed for the usb_control_msg I think */ 1153 char buf[1]; /* Needed for the usb_control_msg I think */
1157 1154
1158 dbg("%s", __FUNCTION__); 1155 dbg("%s", __func__);
1159 1156
1160 spin_lock_irqsave(&priv->tx_lock, flags); 1157 spin_lock_irqsave(&priv->tx_lock, flags);
1161 priv->tx_bytes = 0; 1158 priv->tx_bytes = 0;
@@ -1200,7 +1197,7 @@ static int ftdi_open (struct usb_serial_port *port, struct file *filp)
1200 ftdi_read_bulk_callback, port); 1197 ftdi_read_bulk_callback, port);
1201 result = usb_submit_urb(port->read_urb, GFP_KERNEL); 1198 result = usb_submit_urb(port->read_urb, GFP_KERNEL);
1202 if (result) 1199 if (result)
1203 err("%s - failed submitting read urb, error %d", __FUNCTION__, result); 1200 err("%s - failed submitting read urb, error %d", __func__, result);
1204 1201
1205 1202
1206 return result; 1203 return result;
@@ -1222,7 +1219,7 @@ static void ftdi_close (struct usb_serial_port *port, struct file *filp)
1222 struct ftdi_private *priv = usb_get_serial_port_data(port); 1219 struct ftdi_private *priv = usb_get_serial_port_data(port);
1223 char buf[1]; 1220 char buf[1];
1224 1221
1225 dbg("%s", __FUNCTION__); 1222 dbg("%s", __func__);
1226 1223
1227 mutex_lock(&port->serial->disc_mutex); 1224 mutex_lock(&port->serial->disc_mutex);
1228 if (c_cflag & HUPCL && !port->serial->disconnected){ 1225 if (c_cflag & HUPCL && !port->serial->disconnected){
@@ -1269,7 +1266,7 @@ static int ftdi_write (struct usb_serial_port *port,
1269 int transfer_size; 1266 int transfer_size;
1270 unsigned long flags; 1267 unsigned long flags;
1271 1268
1272 dbg("%s port %d, %d bytes", __FUNCTION__, port->number, count); 1269 dbg("%s port %d, %d bytes", __func__, port->number, count);
1273 1270
1274 if (count == 0) { 1271 if (count == 0) {
1275 dbg("write request of 0 bytes"); 1272 dbg("write request of 0 bytes");
@@ -1278,7 +1275,7 @@ static int ftdi_write (struct usb_serial_port *port,
1278 spin_lock_irqsave(&priv->tx_lock, flags); 1275 spin_lock_irqsave(&priv->tx_lock, flags);
1279 if (priv->tx_outstanding_urbs > URB_UPPER_LIMIT) { 1276 if (priv->tx_outstanding_urbs > URB_UPPER_LIMIT) {
1280 spin_unlock_irqrestore(&priv->tx_lock, flags); 1277 spin_unlock_irqrestore(&priv->tx_lock, flags);
1281 dbg("%s - write limit hit\n", __FUNCTION__); 1278 dbg("%s - write limit hit\n", __func__);
1282 return 0; 1279 return 0;
1283 } 1280 }
1284 priv->tx_outstanding_urbs++; 1281 priv->tx_outstanding_urbs++;
@@ -1298,14 +1295,14 @@ static int ftdi_write (struct usb_serial_port *port,
1298 1295
1299 buffer = kmalloc (transfer_size, GFP_ATOMIC); 1296 buffer = kmalloc (transfer_size, GFP_ATOMIC);
1300 if (!buffer) { 1297 if (!buffer) {
1301 err("%s ran out of kernel memory for urb ...", __FUNCTION__); 1298 err("%s ran out of kernel memory for urb ...", __func__);
1302 count = -ENOMEM; 1299 count = -ENOMEM;
1303 goto error_no_buffer; 1300 goto error_no_buffer;
1304 } 1301 }
1305 1302
1306 urb = usb_alloc_urb(0, GFP_ATOMIC); 1303 urb = usb_alloc_urb(0, GFP_ATOMIC);
1307 if (!urb) { 1304 if (!urb) {
1308 err("%s - no more free urbs", __FUNCTION__); 1305 err("%s - no more free urbs", __func__);
1309 count = -ENOMEM; 1306 count = -ENOMEM;
1310 goto error_no_urb; 1307 goto error_no_urb;
1311 } 1308 }
@@ -1337,7 +1334,7 @@ static int ftdi_write (struct usb_serial_port *port,
1337 memcpy (buffer, buf, count); 1334 memcpy (buffer, buf, count);
1338 } 1335 }
1339 1336
1340 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, transfer_size, buffer); 1337 usb_serial_debug_data(debug, &port->dev, __func__, transfer_size, buffer);
1341 1338
1342 /* fill the buffer and send it */ 1339 /* fill the buffer and send it */
1343 usb_fill_bulk_urb(urb, port->serial->dev, 1340 usb_fill_bulk_urb(urb, port->serial->dev,
@@ -1347,7 +1344,7 @@ static int ftdi_write (struct usb_serial_port *port,
1347 1344
1348 status = usb_submit_urb(urb, GFP_ATOMIC); 1345 status = usb_submit_urb(urb, GFP_ATOMIC);
1349 if (status) { 1346 if (status) {
1350 err("%s - failed submitting write urb, error %d", __FUNCTION__, status); 1347 err("%s - failed submitting write urb, error %d", __func__, status);
1351 count = status; 1348 count = status;
1352 goto error; 1349 goto error;
1353 } else { 1350 } else {
@@ -1361,7 +1358,7 @@ static int ftdi_write (struct usb_serial_port *port,
1361 * really free it when it is finished with it */ 1358 * really free it when it is finished with it */
1362 usb_free_urb(urb); 1359 usb_free_urb(urb);
1363 1360
1364 dbg("%s write returning: %d", __FUNCTION__, count); 1361 dbg("%s write returning: %d", __func__, count);
1365 return count; 1362 return count;
1366error: 1363error:
1367 usb_free_urb(urb); 1364 usb_free_urb(urb);
@@ -1380,7 +1377,7 @@ error_no_buffer:
1380static void ftdi_write_bulk_callback (struct urb *urb) 1377static void ftdi_write_bulk_callback (struct urb *urb)
1381{ 1378{
1382 unsigned long flags; 1379 unsigned long flags;
1383 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 1380 struct usb_serial_port *port = urb->context;
1384 struct ftdi_private *priv; 1381 struct ftdi_private *priv;
1385 int data_offset; /* will be 1 for the SIO and 0 otherwise */ 1382 int data_offset; /* will be 1 for the SIO and 0 otherwise */
1386 unsigned long countback; 1383 unsigned long countback;
@@ -1389,7 +1386,7 @@ static void ftdi_write_bulk_callback (struct urb *urb)
1389 /* free up the transfer buffer, as usb_free_urb() does not do this */ 1386 /* free up the transfer buffer, as usb_free_urb() does not do this */
1390 kfree (urb->transfer_buffer); 1387 kfree (urb->transfer_buffer);
1391 1388
1392 dbg("%s - port %d", __FUNCTION__, port->number); 1389 dbg("%s - port %d", __func__, port->number);
1393 1390
1394 if (status) { 1391 if (status) {
1395 dbg("nonzero write bulk status received: %d", status); 1392 dbg("nonzero write bulk status received: %d", status);
@@ -1398,7 +1395,7 @@ static void ftdi_write_bulk_callback (struct urb *urb)
1398 1395
1399 priv = usb_get_serial_port_data(port); 1396 priv = usb_get_serial_port_data(port);
1400 if (!priv) { 1397 if (!priv) {
1401 dbg("%s - bad port private data pointer - exiting", __FUNCTION__); 1398 dbg("%s - bad port private data pointer - exiting", __func__);
1402 return; 1399 return;
1403 } 1400 }
1404 /* account for transferred data */ 1401 /* account for transferred data */
@@ -1406,7 +1403,7 @@ static void ftdi_write_bulk_callback (struct urb *urb)
1406 data_offset = priv->write_offset; 1403 data_offset = priv->write_offset;
1407 if (data_offset > 0) { 1404 if (data_offset > 0) {
1408 /* Subtract the control bytes */ 1405 /* Subtract the control bytes */
1409 countback -= (data_offset * ((countback + (PKTSZ - 1)) / PKTSZ)); 1406 countback -= (data_offset * DIV_ROUND_UP(countback, PKTSZ));
1410 } 1407 }
1411 spin_lock_irqsave(&priv->tx_lock, flags); 1408 spin_lock_irqsave(&priv->tx_lock, flags);
1412 --priv->tx_outstanding_urbs; 1409 --priv->tx_outstanding_urbs;
@@ -1423,7 +1420,7 @@ static int ftdi_write_room( struct usb_serial_port *port )
1423 int room; 1420 int room;
1424 unsigned long flags; 1421 unsigned long flags;
1425 1422
1426 dbg("%s - port %d", __FUNCTION__, port->number); 1423 dbg("%s - port %d", __func__, port->number);
1427 1424
1428 spin_lock_irqsave(&priv->tx_lock, flags); 1425 spin_lock_irqsave(&priv->tx_lock, flags);
1429 if (priv->tx_outstanding_urbs < URB_UPPER_LIMIT) { 1426 if (priv->tx_outstanding_urbs < URB_UPPER_LIMIT) {
@@ -1447,13 +1444,13 @@ static int ftdi_chars_in_buffer (struct usb_serial_port *port)
1447 int buffered; 1444 int buffered;
1448 unsigned long flags; 1445 unsigned long flags;
1449 1446
1450 dbg("%s - port %d", __FUNCTION__, port->number); 1447 dbg("%s - port %d", __func__, port->number);
1451 1448
1452 spin_lock_irqsave(&priv->tx_lock, flags); 1449 spin_lock_irqsave(&priv->tx_lock, flags);
1453 buffered = (int)priv->tx_outstanding_bytes; 1450 buffered = (int)priv->tx_outstanding_bytes;
1454 spin_unlock_irqrestore(&priv->tx_lock, flags); 1451 spin_unlock_irqrestore(&priv->tx_lock, flags);
1455 if (buffered < 0) { 1452 if (buffered < 0) {
1456 err("%s outstanding tx bytes is negative!", __FUNCTION__); 1453 err("%s outstanding tx bytes is negative!", __func__);
1457 buffered = 0; 1454 buffered = 0;
1458 } 1455 }
1459 return buffered; 1456 return buffered;
@@ -1463,7 +1460,7 @@ static int ftdi_chars_in_buffer (struct usb_serial_port *port)
1463 1460
1464static void ftdi_read_bulk_callback (struct urb *urb) 1461static void ftdi_read_bulk_callback (struct urb *urb)
1465{ /* ftdi_read_bulk_callback */ 1462{ /* ftdi_read_bulk_callback */
1466 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 1463 struct usb_serial_port *port = urb->context;
1467 struct tty_struct *tty; 1464 struct tty_struct *tty;
1468 struct ftdi_private *priv; 1465 struct ftdi_private *priv;
1469 unsigned long countread; 1466 unsigned long countread;
@@ -1471,30 +1468,30 @@ static void ftdi_read_bulk_callback (struct urb *urb)
1471 int status = urb->status; 1468 int status = urb->status;
1472 1469
1473 if (urb->number_of_packets > 0) { 1470 if (urb->number_of_packets > 0) {
1474 err("%s transfer_buffer_length %d actual_length %d number of packets %d",__FUNCTION__, 1471 err("%s transfer_buffer_length %d actual_length %d number of packets %d",__func__,
1475 urb->transfer_buffer_length, urb->actual_length, urb->number_of_packets ); 1472 urb->transfer_buffer_length, urb->actual_length, urb->number_of_packets );
1476 err("%s transfer_flags %x ", __FUNCTION__,urb->transfer_flags ); 1473 err("%s transfer_flags %x ", __func__,urb->transfer_flags );
1477 } 1474 }
1478 1475
1479 dbg("%s - port %d", __FUNCTION__, port->number); 1476 dbg("%s - port %d", __func__, port->number);
1480 1477
1481 if (port->open_count <= 0) 1478 if (port->open_count <= 0)
1482 return; 1479 return;
1483 1480
1484 tty = port->tty; 1481 tty = port->tty;
1485 if (!tty) { 1482 if (!tty) {
1486 dbg("%s - bad tty pointer - exiting",__FUNCTION__); 1483 dbg("%s - bad tty pointer - exiting",__func__);
1487 return; 1484 return;
1488 } 1485 }
1489 1486
1490 priv = usb_get_serial_port_data(port); 1487 priv = usb_get_serial_port_data(port);
1491 if (!priv) { 1488 if (!priv) {
1492 dbg("%s - bad port private data pointer - exiting", __FUNCTION__); 1489 dbg("%s - bad port private data pointer - exiting", __func__);
1493 return; 1490 return;
1494 } 1491 }
1495 1492
1496 if (urb != port->read_urb) { 1493 if (urb != port->read_urb) {
1497 err("%s - Not my urb!", __FUNCTION__); 1494 err("%s - Not my urb!", __func__);
1498 } 1495 }
1499 1496
1500 if (status) { 1497 if (status) {
@@ -1506,7 +1503,7 @@ static void ftdi_read_bulk_callback (struct urb *urb)
1506 1503
1507 /* count data bytes, but not status bytes */ 1504 /* count data bytes, but not status bytes */
1508 countread = urb->actual_length; 1505 countread = urb->actual_length;
1509 countread -= 2 * ((countread + (PKTSZ - 1)) / PKTSZ); 1506 countread -= 2 * DIV_ROUND_UP(countread, PKTSZ);
1510 spin_lock_irqsave(&priv->rx_lock, flags); 1507 spin_lock_irqsave(&priv->rx_lock, flags);
1511 priv->rx_bytes += countread; 1508 priv->rx_bytes += countread;
1512 spin_unlock_irqrestore(&priv->rx_lock, flags); 1509 spin_unlock_irqrestore(&priv->rx_lock, flags);
@@ -1532,39 +1529,39 @@ static void ftdi_process_read (struct work_struct *work)
1532 int packet_offset; 1529 int packet_offset;
1533 unsigned long flags; 1530 unsigned long flags;
1534 1531
1535 dbg("%s - port %d", __FUNCTION__, port->number); 1532 dbg("%s - port %d", __func__, port->number);
1536 1533
1537 if (port->open_count <= 0) 1534 if (port->open_count <= 0)
1538 return; 1535 return;
1539 1536
1540 tty = port->tty; 1537 tty = port->tty;
1541 if (!tty) { 1538 if (!tty) {
1542 dbg("%s - bad tty pointer - exiting",__FUNCTION__); 1539 dbg("%s - bad tty pointer - exiting",__func__);
1543 return; 1540 return;
1544 } 1541 }
1545 1542
1546 priv = usb_get_serial_port_data(port); 1543 priv = usb_get_serial_port_data(port);
1547 if (!priv) { 1544 if (!priv) {
1548 dbg("%s - bad port private data pointer - exiting", __FUNCTION__); 1545 dbg("%s - bad port private data pointer - exiting", __func__);
1549 return; 1546 return;
1550 } 1547 }
1551 1548
1552 urb = port->read_urb; 1549 urb = port->read_urb;
1553 if (!urb) { 1550 if (!urb) {
1554 dbg("%s - bad read_urb pointer - exiting", __FUNCTION__); 1551 dbg("%s - bad read_urb pointer - exiting", __func__);
1555 return; 1552 return;
1556 } 1553 }
1557 1554
1558 data = urb->transfer_buffer; 1555 data = urb->transfer_buffer;
1559 1556
1560 if (priv->rx_processed) { 1557 if (priv->rx_processed) {
1561 dbg("%s - already processed: %d bytes, %d remain", __FUNCTION__, 1558 dbg("%s - already processed: %d bytes, %d remain", __func__,
1562 priv->rx_processed, 1559 priv->rx_processed,
1563 urb->actual_length - priv->rx_processed); 1560 urb->actual_length - priv->rx_processed);
1564 } else { 1561 } else {
1565 /* The first two bytes of every read packet are status */ 1562 /* The first two bytes of every read packet are status */
1566 if (urb->actual_length > 2) { 1563 if (urb->actual_length > 2) {
1567 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, urb->actual_length, data); 1564 usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data);
1568 } else { 1565 } else {
1569 dbg("Status only: %03oo %03oo",data[0],data[1]); 1566 dbg("Status only: %03oo %03oo",data[0],data[1]);
1570 } 1567 }
@@ -1594,17 +1591,17 @@ static void ftdi_process_read (struct work_struct *work)
1594 1591
1595 length = min(PKTSZ, urb->actual_length-packet_offset)-2; 1592 length = min(PKTSZ, urb->actual_length-packet_offset)-2;
1596 if (length < 0) { 1593 if (length < 0) {
1597 err("%s - bad packet length: %d", __FUNCTION__, length+2); 1594 err("%s - bad packet length: %d", __func__, length+2);
1598 length = 0; 1595 length = 0;
1599 } 1596 }
1600 1597
1601 if (priv->rx_flags & THROTTLED) { 1598 if (priv->rx_flags & THROTTLED) {
1602 dbg("%s - throttled", __FUNCTION__); 1599 dbg("%s - throttled", __func__);
1603 break; 1600 break;
1604 } 1601 }
1605 if (tty_buffer_request_room(tty, length) < length) { 1602 if (tty_buffer_request_room(tty, length) < length) {
1606 /* break out & wait for throttling/unthrottling to happen */ 1603 /* break out & wait for throttling/unthrottling to happen */
1607 dbg("%s - receive room low", __FUNCTION__); 1604 dbg("%s - receive room low", __func__);
1608 break; 1605 break;
1609 } 1606 }
1610 1607
@@ -1672,7 +1669,7 @@ static void ftdi_process_read (struct work_struct *work)
1672 /* not completely processed - record progress */ 1669 /* not completely processed - record progress */
1673 priv->rx_processed = packet_offset; 1670 priv->rx_processed = packet_offset;
1674 dbg("%s - incomplete, %d bytes processed, %d remain", 1671 dbg("%s - incomplete, %d bytes processed, %d remain",
1675 __FUNCTION__, packet_offset, 1672 __func__, packet_offset,
1676 urb->actual_length - packet_offset); 1673 urb->actual_length - packet_offset);
1677 /* check if we were throttled while processing */ 1674 /* check if we were throttled while processing */
1678 spin_lock_irqsave(&priv->rx_lock, flags); 1675 spin_lock_irqsave(&priv->rx_lock, flags);
@@ -1680,7 +1677,7 @@ static void ftdi_process_read (struct work_struct *work)
1680 priv->rx_flags |= ACTUALLY_THROTTLED; 1677 priv->rx_flags |= ACTUALLY_THROTTLED;
1681 spin_unlock_irqrestore(&priv->rx_lock, flags); 1678 spin_unlock_irqrestore(&priv->rx_lock, flags);
1682 dbg("%s - deferring remainder until unthrottled", 1679 dbg("%s - deferring remainder until unthrottled",
1683 __FUNCTION__); 1680 __func__);
1684 return; 1681 return;
1685 } 1682 }
1686 spin_unlock_irqrestore(&priv->rx_lock, flags); 1683 spin_unlock_irqrestore(&priv->rx_lock, flags);
@@ -1689,7 +1686,7 @@ static void ftdi_process_read (struct work_struct *work)
1689 /* delay processing of remainder */ 1686 /* delay processing of remainder */
1690 schedule_delayed_work(&priv->rx_work, 1); 1687 schedule_delayed_work(&priv->rx_work, 1);
1691 } else { 1688 } else {
1692 dbg("%s - port is closed", __FUNCTION__); 1689 dbg("%s - port is closed", __func__);
1693 } 1690 }
1694 return; 1691 return;
1695 } 1692 }
@@ -1707,7 +1704,7 @@ static void ftdi_process_read (struct work_struct *work)
1707 1704
1708 result = usb_submit_urb(port->read_urb, GFP_ATOMIC); 1705 result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
1709 if (result) 1706 if (result)
1710 err("%s - failed resubmitting read urb, error %d", __FUNCTION__, result); 1707 err("%s - failed resubmitting read urb, error %d", __func__, result);
1711 } 1708 }
1712 1709
1713 return; 1710 return;
@@ -1736,10 +1733,10 @@ static void ftdi_break_ctl( struct usb_serial_port *port, int break_state )
1736 FTDI_SIO_SET_DATA_REQUEST_TYPE, 1733 FTDI_SIO_SET_DATA_REQUEST_TYPE,
1737 urb_value , priv->interface, 1734 urb_value , priv->interface,
1738 buf, 0, WDR_TIMEOUT) < 0) { 1735 buf, 0, WDR_TIMEOUT) < 0) {
1739 err("%s FAILED to enable/disable break state (state was %d)", __FUNCTION__,break_state); 1736 err("%s FAILED to enable/disable break state (state was %d)", __func__,break_state);
1740 } 1737 }
1741 1738
1742 dbg("%s break state is %d - urb is %d", __FUNCTION__,break_state, urb_value); 1739 dbg("%s break state is %d - urb is %d", __func__,break_state, urb_value);
1743 1740
1744} 1741}
1745 1742
@@ -1763,18 +1760,18 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios *old
1763 unsigned char vstop; 1760 unsigned char vstop;
1764 unsigned char vstart; 1761 unsigned char vstart;
1765 1762
1766 dbg("%s", __FUNCTION__); 1763 dbg("%s", __func__);
1767 1764
1768 /* Force baud rate if this device requires it, unless it is set to B0. */ 1765 /* Force baud rate if this device requires it, unless it is set to B0. */
1769 if (priv->force_baud && ((termios->c_cflag & CBAUD) != B0)) { 1766 if (priv->force_baud && ((termios->c_cflag & CBAUD) != B0)) {
1770 dbg("%s: forcing baud rate for this device", __FUNCTION__); 1767 dbg("%s: forcing baud rate for this device", __func__);
1771 tty_encode_baud_rate(port->tty, priv->force_baud, 1768 tty_encode_baud_rate(port->tty, priv->force_baud,
1772 priv->force_baud); 1769 priv->force_baud);
1773 } 1770 }
1774 1771
1775 /* Force RTS-CTS if this device requires it. */ 1772 /* Force RTS-CTS if this device requires it. */
1776 if (priv->force_rtscts) { 1773 if (priv->force_rtscts) {
1777 dbg("%s: forcing rtscts for this device", __FUNCTION__); 1774 dbg("%s: forcing rtscts for this device", __func__);
1778 termios->c_cflag |= CRTSCTS; 1775 termios->c_cflag |= CRTSCTS;
1779 } 1776 }
1780 1777
@@ -1818,7 +1815,7 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios *old
1818 FTDI_SIO_SET_DATA_REQUEST_TYPE, 1815 FTDI_SIO_SET_DATA_REQUEST_TYPE,
1819 urb_value , priv->interface, 1816 urb_value , priv->interface,
1820 buf, 0, WDR_SHORT_TIMEOUT) < 0) { 1817 buf, 0, WDR_SHORT_TIMEOUT) < 0) {
1821 err("%s FAILED to set databits/stopbits/parity", __FUNCTION__); 1818 err("%s FAILED to set databits/stopbits/parity", __func__);
1822 } 1819 }
1823 1820
1824 /* Now do the baudrate */ 1821 /* Now do the baudrate */
@@ -1829,14 +1826,14 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios *old
1829 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 1826 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE,
1830 0, priv->interface, 1827 0, priv->interface,
1831 buf, 0, WDR_TIMEOUT) < 0) { 1828 buf, 0, WDR_TIMEOUT) < 0) {
1832 err("%s error from disable flowcontrol urb", __FUNCTION__); 1829 err("%s error from disable flowcontrol urb", __func__);
1833 } 1830 }
1834 /* Drop RTS and DTR */ 1831 /* Drop RTS and DTR */
1835 clear_mctrl(port, TIOCM_DTR | TIOCM_RTS); 1832 clear_mctrl(port, TIOCM_DTR | TIOCM_RTS);
1836 } else { 1833 } else {
1837 /* set the baudrate determined before */ 1834 /* set the baudrate determined before */
1838 if (change_speed(port)) { 1835 if (change_speed(port)) {
1839 err("%s urb failed to set baudrate", __FUNCTION__); 1836 err("%s urb failed to set baudrate", __func__);
1840 } 1837 }
1841 /* Ensure RTS and DTR are raised when baudrate changed from 0 */ 1838 /* Ensure RTS and DTR are raised when baudrate changed from 0 */
1842 if (!old_termios || (old_termios->c_cflag & CBAUD) == B0) { 1839 if (!old_termios || (old_termios->c_cflag & CBAUD) == B0) {
@@ -1847,7 +1844,7 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios *old
1847 /* Set flow control */ 1844 /* Set flow control */
1848 /* Note device also supports DTR/CD (ugh) and Xon/Xoff in hardware */ 1845 /* Note device also supports DTR/CD (ugh) and Xon/Xoff in hardware */
1849 if (cflag & CRTSCTS) { 1846 if (cflag & CRTSCTS) {
1850 dbg("%s Setting to CRTSCTS flow control", __FUNCTION__); 1847 dbg("%s Setting to CRTSCTS flow control", __func__);
1851 if (usb_control_msg(dev, 1848 if (usb_control_msg(dev,
1852 usb_sndctrlpipe(dev, 0), 1849 usb_sndctrlpipe(dev, 0),
1853 FTDI_SIO_SET_FLOW_CTRL_REQUEST, 1850 FTDI_SIO_SET_FLOW_CTRL_REQUEST,
@@ -1865,7 +1862,7 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios *old
1865 * if IXOFF is not set, the pre-xon/xoff code is executed. 1862 * if IXOFF is not set, the pre-xon/xoff code is executed.
1866 */ 1863 */
1867 if (iflag & IXOFF) { 1864 if (iflag & IXOFF) {
1868 dbg("%s request to enable xonxoff iflag=%04x",__FUNCTION__,iflag); 1865 dbg("%s request to enable xonxoff iflag=%04x",__func__,iflag);
1869 // Try to enable the XON/XOFF on the ftdi_sio 1866 // Try to enable the XON/XOFF on the ftdi_sio
1870 // Set the vstart and vstop -- could have been done up above where 1867 // Set the vstart and vstop -- could have been done up above where
1871 // a lot of other dereferencing is done but that would be very 1868 // a lot of other dereferencing is done but that would be very
@@ -1886,7 +1883,7 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios *old
1886 } else { 1883 } else {
1887 /* else clause to only run if cfag ! CRTSCTS and iflag ! XOFF */ 1884 /* else clause to only run if cfag ! CRTSCTS and iflag ! XOFF */
1888 /* CHECKME Assuming XON/XOFF handled by tty stack - not by device */ 1885 /* CHECKME Assuming XON/XOFF handled by tty stack - not by device */
1889 dbg("%s Turning off hardware flow control", __FUNCTION__); 1886 dbg("%s Turning off hardware flow control", __func__);
1890 if (usb_control_msg(dev, 1887 if (usb_control_msg(dev,
1891 usb_sndctrlpipe(dev, 0), 1888 usb_sndctrlpipe(dev, 0),
1892 FTDI_SIO_SET_FLOW_CTRL_REQUEST, 1889 FTDI_SIO_SET_FLOW_CTRL_REQUEST,
@@ -1908,7 +1905,7 @@ static int ftdi_tiocmget (struct usb_serial_port *port, struct file *file)
1908 unsigned char buf[2]; 1905 unsigned char buf[2];
1909 int ret; 1906 int ret;
1910 1907
1911 dbg("%s TIOCMGET", __FUNCTION__); 1908 dbg("%s TIOCMGET", __func__);
1912 switch (priv->chip_type) { 1909 switch (priv->chip_type) {
1913 case SIO: 1910 case SIO:
1914 /* Request the status from the device */ 1911 /* Request the status from the device */
@@ -1918,7 +1915,7 @@ static int ftdi_tiocmget (struct usb_serial_port *port, struct file *file)
1918 FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE, 1915 FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE,
1919 0, 0, 1916 0, 0,
1920 buf, 1, WDR_TIMEOUT)) < 0 ) { 1917 buf, 1, WDR_TIMEOUT)) < 0 ) {
1921 err("%s Could not get modem status of device - err: %d", __FUNCTION__, 1918 err("%s Could not get modem status of device - err: %d", __func__,
1922 ret); 1919 ret);
1923 return(ret); 1920 return(ret);
1924 } 1921 }
@@ -1935,7 +1932,7 @@ static int ftdi_tiocmget (struct usb_serial_port *port, struct file *file)
1935 FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE, 1932 FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE,
1936 0, priv->interface, 1933 0, priv->interface,
1937 buf, 2, WDR_TIMEOUT)) < 0 ) { 1934 buf, 2, WDR_TIMEOUT)) < 0 ) {
1938 err("%s Could not get modem status of device - err: %d", __FUNCTION__, 1935 err("%s Could not get modem status of device - err: %d", __func__,
1939 ret); 1936 ret);
1940 return(ret); 1937 return(ret);
1941 } 1938 }
@@ -1954,7 +1951,7 @@ static int ftdi_tiocmget (struct usb_serial_port *port, struct file *file)
1954 1951
1955static int ftdi_tiocmset(struct usb_serial_port *port, struct file * file, unsigned int set, unsigned int clear) 1952static int ftdi_tiocmset(struct usb_serial_port *port, struct file * file, unsigned int set, unsigned int clear)
1956{ 1953{
1957 dbg("%s TIOCMSET", __FUNCTION__); 1954 dbg("%s TIOCMSET", __func__);
1958 return update_mctrl(port, set, clear); 1955 return update_mctrl(port, set, clear);
1959} 1956}
1960 1957
@@ -1963,7 +1960,7 @@ static int ftdi_ioctl (struct usb_serial_port *port, struct file * file, unsigne
1963{ 1960{
1964 struct ftdi_private *priv = usb_get_serial_port_data(port); 1961 struct ftdi_private *priv = usb_get_serial_port_data(port);
1965 1962
1966 dbg("%s cmd 0x%04x", __FUNCTION__, cmd); 1963 dbg("%s cmd 0x%04x", __func__, cmd);
1967 1964
1968 /* Based on code from acm.c and others */ 1965 /* Based on code from acm.c and others */
1969 switch (cmd) { 1966 switch (cmd) {
@@ -2022,7 +2019,7 @@ static int ftdi_ioctl (struct usb_serial_port *port, struct file * file, unsigne
2022 /* This is not necessarily an error - turns out the higher layers will do 2019 /* This is not necessarily an error - turns out the higher layers will do
2023 * some ioctls itself (see comment above) 2020 * some ioctls itself (see comment above)
2024 */ 2021 */
2025 dbg("%s arg not supported - it was 0x%04x - check /usr/include/asm/ioctls.h", __FUNCTION__, cmd); 2022 dbg("%s arg not supported - it was 0x%04x - check /usr/include/asm/ioctls.h", __func__, cmd);
2026 2023
2027 return(-ENOIOCTLCMD); 2024 return(-ENOIOCTLCMD);
2028} /* ftdi_ioctl */ 2025} /* ftdi_ioctl */
@@ -2033,7 +2030,7 @@ static void ftdi_throttle (struct usb_serial_port *port)
2033 struct ftdi_private *priv = usb_get_serial_port_data(port); 2030 struct ftdi_private *priv = usb_get_serial_port_data(port);
2034 unsigned long flags; 2031 unsigned long flags;
2035 2032
2036 dbg("%s - port %d", __FUNCTION__, port->number); 2033 dbg("%s - port %d", __func__, port->number);
2037 2034
2038 spin_lock_irqsave(&priv->rx_lock, flags); 2035 spin_lock_irqsave(&priv->rx_lock, flags);
2039 priv->rx_flags |= THROTTLED; 2036 priv->rx_flags |= THROTTLED;
@@ -2047,7 +2044,7 @@ static void ftdi_unthrottle (struct usb_serial_port *port)
2047 int actually_throttled; 2044 int actually_throttled;
2048 unsigned long flags; 2045 unsigned long flags;
2049 2046
2050 dbg("%s - port %d", __FUNCTION__, port->number); 2047 dbg("%s - port %d", __func__, port->number);
2051 2048
2052 spin_lock_irqsave(&priv->rx_lock, flags); 2049 spin_lock_irqsave(&priv->rx_lock, flags);
2053 actually_throttled = priv->rx_flags & ACTUALLY_THROTTLED; 2050 actually_throttled = priv->rx_flags & ACTUALLY_THROTTLED;
@@ -2062,7 +2059,7 @@ static int __init ftdi_init (void)
2062{ 2059{
2063 int retval; 2060 int retval;
2064 2061
2065 dbg("%s", __FUNCTION__); 2062 dbg("%s", __func__);
2066 if (vendor > 0 && product > 0) { 2063 if (vendor > 0 && product > 0) {
2067 /* Add user specified VID/PID to reserved element of table. */ 2064 /* Add user specified VID/PID to reserved element of table. */
2068 int i; 2065 int i;
@@ -2091,7 +2088,7 @@ failed_sio_register:
2091static void __exit ftdi_exit (void) 2088static void __exit ftdi_exit (void)
2092{ 2089{
2093 2090
2094 dbg("%s", __FUNCTION__); 2091 dbg("%s", __func__);
2095 2092
2096 usb_deregister (&ftdi_driver); 2093 usb_deregister (&ftdi_driver);
2097 usb_serial_deregister (&ftdi_sio_device); 2094 usb_serial_deregister (&ftdi_sio_device);
diff --git a/drivers/usb/serial/funsoft.c b/drivers/usb/serial/funsoft.c
index b5194dc7d3b..e8ba2cb5995 100644
--- a/drivers/usb/serial/funsoft.c
+++ b/drivers/usb/serial/funsoft.c
@@ -39,9 +39,6 @@ static struct usb_serial_driver funsoft_device = {
39 }, 39 },
40 .id_table = id_table, 40 .id_table = id_table,
41 .usb_driver = &funsoft_driver, 41 .usb_driver = &funsoft_driver,
42 .num_interrupt_in = NUM_DONT_CARE,
43 .num_bulk_in = NUM_DONT_CARE,
44 .num_bulk_out = NUM_DONT_CARE,
45 .num_ports = 1, 42 .num_ports = 1,
46}; 43};
47 44
diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c
index d74e43d6923..8ce5a56a48e 100644
--- a/drivers/usb/serial/garmin_gps.c
+++ b/drivers/usb/serial/garmin_gps.c
@@ -280,7 +280,7 @@ static void send_to_tty(struct usb_serial_port *port,
280 if (tty && actual_length) { 280 if (tty && actual_length) {
281 281
282 usb_serial_debug_data(debug, &port->dev, 282 usb_serial_debug_data(debug, &port->dev,
283 __FUNCTION__, actual_length, data); 283 __func__, actual_length, data);
284 284
285 tty_buffer_request_room(tty, actual_length); 285 tty_buffer_request_room(tty, actual_length);
286 tty_insert_flip_string(tty, data, actual_length); 286 tty_insert_flip_string(tty, data, actual_length);
@@ -355,7 +355,7 @@ static void pkt_clear(struct garmin_data * garmin_data_p)
355 unsigned long flags; 355 unsigned long flags;
356 struct garmin_packet *result = NULL; 356 struct garmin_packet *result = NULL;
357 357
358 dbg("%s", __FUNCTION__); 358 dbg("%s", __func__);
359 359
360 spin_lock_irqsave(&garmin_data_p->lock, flags); 360 spin_lock_irqsave(&garmin_data_p->lock, flags);
361 while (!list_empty(&garmin_data_p->pktlist)) { 361 while (!list_empty(&garmin_data_p->pktlist)) {
@@ -379,7 +379,7 @@ static int gsp_send_ack(struct garmin_data * garmin_data_p, __u8 pkt_id)
379 __u8 *ptr = pkt; 379 __u8 *ptr = pkt;
380 unsigned l = 0; 380 unsigned l = 0;
381 381
382 dbg("%s - pkt-id: 0x%X.", __FUNCTION__, 0xFF & pkt_id); 382 dbg("%s - pkt-id: 0x%X.", __func__, 0xFF & pkt_id);
383 383
384 *ptr++ = DLE; 384 *ptr++ = DLE;
385 *ptr++ = ACK; 385 *ptr++ = ACK;
@@ -429,11 +429,11 @@ static int gsp_rec_packet(struct garmin_data * garmin_data_p, int count)
429 int size = recpkt[1]; 429 int size = recpkt[1];
430 430
431 usb_serial_debug_data(debug, &garmin_data_p->port->dev, 431 usb_serial_debug_data(debug, &garmin_data_p->port->dev,
432 __FUNCTION__, count-GSP_INITIAL_OFFSET, recpkt); 432 __func__, count-GSP_INITIAL_OFFSET, recpkt);
433 433
434 if (size != (count-GSP_INITIAL_OFFSET-3)) { 434 if (size != (count-GSP_INITIAL_OFFSET-3)) {
435 dbg("%s - invalid size, expected %d bytes, got %d", 435 dbg("%s - invalid size, expected %d bytes, got %d",
436 __FUNCTION__, size, (count-GSP_INITIAL_OFFSET-3)); 436 __func__, size, (count-GSP_INITIAL_OFFSET-3));
437 return -EINVPKT; 437 return -EINVPKT;
438 } 438 }
439 439
@@ -443,7 +443,7 @@ static int gsp_rec_packet(struct garmin_data * garmin_data_p, int count)
443 // sanity check, remove after test ... 443 // sanity check, remove after test ...
444 if ((__u8*)&(usbdata[3]) != recpkt) { 444 if ((__u8*)&(usbdata[3]) != recpkt) {
445 dbg("%s - ptr mismatch %p - %p", 445 dbg("%s - ptr mismatch %p - %p",
446 __FUNCTION__, &(usbdata[4]), recpkt); 446 __func__, &(usbdata[4]), recpkt);
447 return -EINVPKT; 447 return -EINVPKT;
448 } 448 }
449 449
@@ -454,7 +454,7 @@ static int gsp_rec_packet(struct garmin_data * garmin_data_p, int count)
454 454
455 if ((0xff & (cksum + *recpkt)) != 0) { 455 if ((0xff & (cksum + *recpkt)) != 0) {
456 dbg("%s - invalid checksum, expected %02x, got %02x", 456 dbg("%s - invalid checksum, expected %02x, got %02x",
457 __FUNCTION__, 0xff & -cksum, 0xff & *recpkt); 457 __func__, 0xff & -cksum, 0xff & *recpkt);
458 return -EINVPKT; 458 return -EINVPKT;
459 } 459 }
460 460
@@ -519,7 +519,7 @@ static int gsp_receive(struct garmin_data * garmin_data_p,
519 spin_unlock_irqrestore(&garmin_data_p->lock, flags); 519 spin_unlock_irqrestore(&garmin_data_p->lock, flags);
520 520
521 dbg("%s - dle=%d skip=%d size=%d count=%d", 521 dbg("%s - dle=%d skip=%d size=%d count=%d",
522 __FUNCTION__, dleSeen, skip, size, count); 522 __func__, dleSeen, skip, size, count);
523 523
524 if (size == 0) { 524 if (size == 0) {
525 size = GSP_INITIAL_OFFSET; 525 size = GSP_INITIAL_OFFSET;
@@ -578,7 +578,7 @@ static int gsp_receive(struct garmin_data * garmin_data_p,
578 } 578 }
579 579
580 if (size >= GPS_IN_BUFSIZ) { 580 if (size >= GPS_IN_BUFSIZ) {
581 dbg("%s - packet too large.", __FUNCTION__); 581 dbg("%s - packet too large.", __func__);
582 skip = 1; 582 skip = 1;
583 size = GSP_INITIAL_OFFSET; 583 size = GSP_INITIAL_OFFSET;
584 dleSeen = 0; 584 dleSeen = 0;
@@ -634,7 +634,7 @@ static int gsp_send(struct garmin_data * garmin_data_p,
634 int i=0; 634 int i=0;
635 int k; 635 int k;
636 636
637 dbg("%s - state %d - %d bytes.", __FUNCTION__, 637 dbg("%s - state %d - %d bytes.", __func__,
638 garmin_data_p->state, count); 638 garmin_data_p->state, count);
639 639
640 k = garmin_data_p->outsize; 640 k = garmin_data_p->outsize;
@@ -658,13 +658,13 @@ static int gsp_send(struct garmin_data * garmin_data_p,
658 return 0; 658 return 0;
659 } 659 }
660 660
661 dbg("%s - %d bytes in buffer, %d bytes in pkt.", __FUNCTION__, 661 dbg("%s - %d bytes in buffer, %d bytes in pkt.", __func__,
662 k, i); 662 k, i);
663 663
664 /* garmin_data_p->outbuffer now contains a complete packet */ 664 /* garmin_data_p->outbuffer now contains a complete packet */
665 665
666 usb_serial_debug_data(debug, &garmin_data_p->port->dev, 666 usb_serial_debug_data(debug, &garmin_data_p->port->dev,
667 __FUNCTION__, k, garmin_data_p->outbuffer); 667 __func__, k, garmin_data_p->outbuffer);
668 668
669 garmin_data_p->outsize = 0; 669 garmin_data_p->outsize = 0;
670 670
@@ -749,7 +749,7 @@ static void gsp_next_packet(struct garmin_data * garmin_data_p)
749 struct garmin_packet *pkt = NULL; 749 struct garmin_packet *pkt = NULL;
750 750
751 while ((pkt = pkt_pop(garmin_data_p)) != NULL) { 751 while ((pkt = pkt_pop(garmin_data_p)) != NULL) {
752 dbg("%s - next pkt: %d", __FUNCTION__, pkt->seq); 752 dbg("%s - next pkt: %d", __func__, pkt->seq);
753 if (gsp_send(garmin_data_p, pkt->data, pkt->size) > 0) { 753 if (gsp_send(garmin_data_p, pkt->data, pkt->size) > 0) {
754 kfree(pkt); 754 kfree(pkt);
755 return; 755 return;
@@ -794,7 +794,7 @@ static int nat_receive(struct garmin_data * garmin_data_p,
794 if (len >= GPS_IN_BUFSIZ) { 794 if (len >= GPS_IN_BUFSIZ) {
795 /* seem to be an invalid packet, ignore rest of input */ 795 /* seem to be an invalid packet, ignore rest of input */
796 dbg("%s - packet size too large: %d", 796 dbg("%s - packet size too large: %d",
797 __FUNCTION__, len); 797 __func__, len);
798 garmin_data_p->insize = 0; 798 garmin_data_p->insize = 0;
799 count = 0; 799 count = 0;
800 result = -EINVPKT; 800 result = -EINVPKT;
@@ -873,11 +873,11 @@ static int process_resetdev_request(struct usb_serial_port *port)
873 spin_unlock_irqrestore(&garmin_data_p->lock, flags); 873 spin_unlock_irqrestore(&garmin_data_p->lock, flags);
874 874
875 usb_kill_urb (port->interrupt_in_urb); 875 usb_kill_urb (port->interrupt_in_urb);
876 dbg("%s - usb_reset_device", __FUNCTION__ ); 876 dbg("%s - usb_reset_device", __func__ );
877 status = usb_reset_device(port->serial->dev); 877 status = usb_reset_device(port->serial->dev);
878 if (status) 878 if (status)
879 dbg("%s - usb_reset_device failed: %d", 879 dbg("%s - usb_reset_device failed: %d",
880 __FUNCTION__, status); 880 __func__, status);
881 return status; 881 return status;
882} 882}
883 883
@@ -926,18 +926,18 @@ static int garmin_init_session(struct usb_serial_port *port)
926 if (status == 0) { 926 if (status == 0) {
927 usb_kill_urb (port->interrupt_in_urb); 927 usb_kill_urb (port->interrupt_in_urb);
928 928
929 dbg("%s - adding interrupt input", __FUNCTION__); 929 dbg("%s - adding interrupt input", __func__);
930 port->interrupt_in_urb->dev = serial->dev; 930 port->interrupt_in_urb->dev = serial->dev;
931 status = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); 931 status = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
932 if (status) 932 if (status)
933 dev_err(&serial->dev->dev, 933 dev_err(&serial->dev->dev,
934 "%s - failed submitting interrupt urb," 934 "%s - failed submitting interrupt urb,"
935 " error %d\n", 935 " error %d\n",
936 __FUNCTION__, status); 936 __func__, status);
937 } 937 }
938 938
939 if (status == 0) { 939 if (status == 0) {
940 dbg("%s - starting session ...", __FUNCTION__); 940 dbg("%s - starting session ...", __func__);
941 garmin_data_p->state = STATE_ACTIVE; 941 garmin_data_p->state = STATE_ACTIVE;
942 status = garmin_write_bulk(port, GARMIN_START_SESSION_REQ, 942 status = garmin_write_bulk(port, GARMIN_START_SESSION_REQ,
943 sizeof(GARMIN_START_SESSION_REQ), 943 sizeof(GARMIN_START_SESSION_REQ),
@@ -976,7 +976,7 @@ static int garmin_open (struct usb_serial_port *port, struct file *filp)
976 int status = 0; 976 int status = 0;
977 struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); 977 struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
978 978
979 dbg("%s - port %d", __FUNCTION__, port->number); 979 dbg("%s - port %d", __func__, port->number);
980 980
981 /* 981 /*
982 * Force low_latency on so that our tty_push actually forces the data 982 * Force low_latency on so that our tty_push actually forces the data
@@ -1013,7 +1013,7 @@ static void garmin_close (struct usb_serial_port *port, struct file * filp)
1013 struct usb_serial *serial = port->serial; 1013 struct usb_serial *serial = port->serial;
1014 struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); 1014 struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
1015 1015
1016 dbg("%s - port %d - mode=%d state=%d flags=0x%X", __FUNCTION__, 1016 dbg("%s - port %d - mode=%d state=%d flags=0x%X", __func__,
1017 port->number, garmin_data_p->mode, 1017 port->number, garmin_data_p->mode,
1018 garmin_data_p->state, garmin_data_p->flags); 1018 garmin_data_p->state, garmin_data_p->flags);
1019 1019
@@ -1046,13 +1046,13 @@ static void garmin_close (struct usb_serial_port *port, struct file * filp)
1046static void garmin_write_bulk_callback (struct urb *urb) 1046static void garmin_write_bulk_callback (struct urb *urb)
1047{ 1047{
1048 unsigned long flags; 1048 unsigned long flags;
1049 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 1049 struct usb_serial_port *port = urb->context;
1050 int status = urb->status; 1050 int status = urb->status;
1051 1051
1052 if (port) { 1052 if (port) {
1053 struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); 1053 struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
1054 1054
1055 dbg("%s - port %d", __FUNCTION__, port->number); 1055 dbg("%s - port %d", __func__, port->number);
1056 1056
1057 if (GARMIN_LAYERID_APPL == getLayerId(urb->transfer_buffer) 1057 if (GARMIN_LAYERID_APPL == getLayerId(urb->transfer_buffer)
1058 && (garmin_data_p->mode == MODE_GARMIN_SERIAL)) { 1058 && (garmin_data_p->mode == MODE_GARMIN_SERIAL)) {
@@ -1061,7 +1061,7 @@ static void garmin_write_bulk_callback (struct urb *urb)
1061 1061
1062 if (status) { 1062 if (status) {
1063 dbg("%s - nonzero write bulk status received: %d", 1063 dbg("%s - nonzero write bulk status received: %d",
1064 __FUNCTION__, urb->status); 1064 __func__, urb->status);
1065 spin_lock_irqsave(&garmin_data_p->lock, flags); 1065 spin_lock_irqsave(&garmin_data_p->lock, flags);
1066 garmin_data_p->flags |= CLEAR_HALT_REQUIRED; 1066 garmin_data_p->flags |= CLEAR_HALT_REQUIRED;
1067 spin_unlock_irqrestore(&garmin_data_p->lock, flags); 1067 spin_unlock_irqrestore(&garmin_data_p->lock, flags);
@@ -1088,7 +1088,7 @@ static int garmin_write_bulk (struct usb_serial_port *port,
1088 unsigned char *buffer; 1088 unsigned char *buffer;
1089 int status; 1089 int status;
1090 1090
1091 dbg("%s - port %d, state %d", __FUNCTION__, port->number, 1091 dbg("%s - port %d, state %d", __func__, port->number,
1092 garmin_data_p->state); 1092 garmin_data_p->state);
1093 1093
1094 spin_lock_irqsave(&garmin_data_p->lock, flags); 1094 spin_lock_irqsave(&garmin_data_p->lock, flags);
@@ -1110,7 +1110,7 @@ static int garmin_write_bulk (struct usb_serial_port *port,
1110 1110
1111 memcpy (buffer, buf, count); 1111 memcpy (buffer, buf, count);
1112 1112
1113 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count, buffer); 1113 usb_serial_debug_data(debug, &port->dev, __func__, count, buffer);
1114 1114
1115 usb_fill_bulk_urb (urb, serial->dev, 1115 usb_fill_bulk_urb (urb, serial->dev,
1116 usb_sndbulkpipe (serial->dev, 1116 usb_sndbulkpipe (serial->dev,
@@ -1134,7 +1134,7 @@ static int garmin_write_bulk (struct usb_serial_port *port,
1134 dev_err(&port->dev, 1134 dev_err(&port->dev,
1135 "%s - usb_submit_urb(write bulk) " 1135 "%s - usb_submit_urb(write bulk) "
1136 "failed with status = %d\n", 1136 "failed with status = %d\n",
1137 __FUNCTION__, status); 1137 __func__, status);
1138 count = status; 1138 count = status;
1139 } 1139 }
1140 1140
@@ -1154,7 +1154,7 @@ static int garmin_write (struct usb_serial_port *port,
1154 struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); 1154 struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
1155 __le32 *privpkt = (__le32 *)garmin_data_p->privpkt; 1155 __le32 *privpkt = (__le32 *)garmin_data_p->privpkt;
1156 1156
1157 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count, buf); 1157 usb_serial_debug_data(debug, &port->dev, __func__, count, buf);
1158 1158
1159 /* check for our private packets */ 1159 /* check for our private packets */
1160 if (count >= GARMIN_PKTHDR_LENGTH) { 1160 if (count >= GARMIN_PKTHDR_LENGTH) {
@@ -1172,7 +1172,7 @@ static int garmin_write (struct usb_serial_port *port,
1172 && GARMIN_LAYERID_PRIVATE == getLayerId(garmin_data_p->privpkt)) { 1172 && GARMIN_LAYERID_PRIVATE == getLayerId(garmin_data_p->privpkt)) {
1173 1173
1174 dbg("%s - processing private request %d", 1174 dbg("%s - processing private request %d",
1175 __FUNCTION__, pktid); 1175 __func__, pktid);
1176 1176
1177 // drop all unfinished transfers 1177 // drop all unfinished transfers
1178 garmin_clear(garmin_data_p); 1178 garmin_clear(garmin_data_p);
@@ -1184,7 +1184,7 @@ static int garmin_write (struct usb_serial_port *port,
1184 return -EINVPKT; 1184 return -EINVPKT;
1185 debug = __le32_to_cpu(privpkt[3]); 1185 debug = __le32_to_cpu(privpkt[3]);
1186 dbg("%s - debug level set to 0x%X", 1186 dbg("%s - debug level set to 0x%X",
1187 __FUNCTION__, debug); 1187 __func__, debug);
1188 break; 1188 break;
1189 1189
1190 case PRIV_PKTID_SET_MODE: 1190 case PRIV_PKTID_SET_MODE:
@@ -1192,7 +1192,7 @@ static int garmin_write (struct usb_serial_port *port,
1192 return -EINVPKT; 1192 return -EINVPKT;
1193 garmin_data_p->mode = __le32_to_cpu(privpkt[3]); 1193 garmin_data_p->mode = __le32_to_cpu(privpkt[3]);
1194 dbg("%s - mode set to %d", 1194 dbg("%s - mode set to %d",
1195 __FUNCTION__, garmin_data_p->mode); 1195 __func__, garmin_data_p->mode);
1196 break; 1196 break;
1197 1197
1198 case PRIV_PKTID_INFO_REQ: 1198 case PRIV_PKTID_INFO_REQ:
@@ -1208,7 +1208,7 @@ static int garmin_write (struct usb_serial_port *port,
1208 return -EINVPKT; 1208 return -EINVPKT;
1209 initial_mode = __le32_to_cpu(privpkt[3]); 1209 initial_mode = __le32_to_cpu(privpkt[3]);
1210 dbg("%s - initial_mode set to %d", 1210 dbg("%s - initial_mode set to %d",
1211 __FUNCTION__, 1211 __func__,
1212 garmin_data_p->mode); 1212 garmin_data_p->mode);
1213 break; 1213 break;
1214 } 1214 }
@@ -1255,7 +1255,7 @@ static void garmin_read_process(struct garmin_data * garmin_data_p,
1255{ 1255{
1256 if (garmin_data_p->flags & FLAGS_DROP_DATA) { 1256 if (garmin_data_p->flags & FLAGS_DROP_DATA) {
1257 /* abort-transfer cmd is actice */ 1257 /* abort-transfer cmd is actice */
1258 dbg("%s - pkt dropped", __FUNCTION__); 1258 dbg("%s - pkt dropped", __func__);
1259 } else if (garmin_data_p->state != STATE_DISCONNECTED && 1259 } else if (garmin_data_p->state != STATE_DISCONNECTED &&
1260 garmin_data_p->state != STATE_RESET ) { 1260 garmin_data_p->state != STATE_RESET ) {
1261 1261
@@ -1286,28 +1286,28 @@ static void garmin_read_process(struct garmin_data * garmin_data_p,
1286static void garmin_read_bulk_callback (struct urb *urb) 1286static void garmin_read_bulk_callback (struct urb *urb)
1287{ 1287{
1288 unsigned long flags; 1288 unsigned long flags;
1289 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 1289 struct usb_serial_port *port = urb->context;
1290 struct usb_serial *serial = port->serial; 1290 struct usb_serial *serial = port->serial;
1291 struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); 1291 struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
1292 unsigned char *data = urb->transfer_buffer; 1292 unsigned char *data = urb->transfer_buffer;
1293 int status = urb->status; 1293 int status = urb->status;
1294 int retval; 1294 int retval;
1295 1295
1296 dbg("%s - port %d", __FUNCTION__, port->number); 1296 dbg("%s - port %d", __func__, port->number);
1297 1297
1298 if (!serial) { 1298 if (!serial) {
1299 dbg("%s - bad serial pointer, exiting", __FUNCTION__); 1299 dbg("%s - bad serial pointer, exiting", __func__);
1300 return; 1300 return;
1301 } 1301 }
1302 1302
1303 if (status) { 1303 if (status) {
1304 dbg("%s - nonzero read bulk status received: %d", 1304 dbg("%s - nonzero read bulk status received: %d",
1305 __FUNCTION__, status); 1305 __func__, status);
1306 return; 1306 return;
1307 } 1307 }
1308 1308
1309 usb_serial_debug_data(debug, &port->dev, 1309 usb_serial_debug_data(debug, &port->dev,
1310 __FUNCTION__, urb->actual_length, data); 1310 __func__, urb->actual_length, data);
1311 1311
1312 garmin_read_process(garmin_data_p, data, urb->actual_length); 1312 garmin_read_process(garmin_data_p, data, urb->actual_length);
1313 1313
@@ -1320,7 +1320,7 @@ static void garmin_read_bulk_callback (struct urb *urb)
1320 if (retval) 1320 if (retval)
1321 dev_err(&port->dev, 1321 dev_err(&port->dev,
1322 "%s - failed resubmitting read urb, error %d\n", 1322 "%s - failed resubmitting read urb, error %d\n",
1323 __FUNCTION__, retval); 1323 __func__, retval);
1324 } else if (urb->actual_length > 0) { 1324 } else if (urb->actual_length > 0) {
1325 /* Continue trying to read until nothing more is received */ 1325 /* Continue trying to read until nothing more is received */
1326 if (0 == (garmin_data_p->flags & FLAGS_THROTTLED)) { 1326 if (0 == (garmin_data_p->flags & FLAGS_THROTTLED)) {
@@ -1328,10 +1328,10 @@ static void garmin_read_bulk_callback (struct urb *urb)
1328 if (retval) 1328 if (retval)
1329 dev_err(&port->dev, 1329 dev_err(&port->dev,
1330 "%s - failed resubmitting read urb, " 1330 "%s - failed resubmitting read urb, "
1331 "error %d\n", __FUNCTION__, retval); 1331 "error %d\n", __func__, retval);
1332 } 1332 }
1333 } else { 1333 } else {
1334 dbg("%s - end of bulk data", __FUNCTION__); 1334 dbg("%s - end of bulk data", __func__);
1335 spin_lock_irqsave(&garmin_data_p->lock, flags); 1335 spin_lock_irqsave(&garmin_data_p->lock, flags);
1336 garmin_data_p->flags &= ~FLAGS_BULK_IN_ACTIVE; 1336 garmin_data_p->flags &= ~FLAGS_BULK_IN_ACTIVE;
1337 spin_unlock_irqrestore(&garmin_data_p->lock, flags); 1337 spin_unlock_irqrestore(&garmin_data_p->lock, flags);
@@ -1344,7 +1344,7 @@ static void garmin_read_int_callback (struct urb *urb)
1344{ 1344{
1345 unsigned long flags; 1345 unsigned long flags;
1346 int retval; 1346 int retval;
1347 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 1347 struct usb_serial_port *port = urb->context;
1348 struct usb_serial *serial = port->serial; 1348 struct usb_serial *serial = port->serial;
1349 struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); 1349 struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
1350 unsigned char *data = urb->transfer_buffer; 1350 unsigned char *data = urb->transfer_buffer;
@@ -1359,22 +1359,22 @@ static void garmin_read_int_callback (struct urb *urb)
1359 case -ESHUTDOWN: 1359 case -ESHUTDOWN:
1360 /* this urb is terminated, clean up */ 1360 /* this urb is terminated, clean up */
1361 dbg("%s - urb shutting down with status: %d", 1361 dbg("%s - urb shutting down with status: %d",
1362 __FUNCTION__, status); 1362 __func__, status);
1363 return; 1363 return;
1364 default: 1364 default:
1365 dbg("%s - nonzero urb status received: %d", 1365 dbg("%s - nonzero urb status received: %d",
1366 __FUNCTION__, status); 1366 __func__, status);
1367 return; 1367 return;
1368 } 1368 }
1369 1369
1370 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, 1370 usb_serial_debug_data(debug, &port->dev, __func__,
1371 urb->actual_length, urb->transfer_buffer); 1371 urb->actual_length, urb->transfer_buffer);
1372 1372
1373 if (urb->actual_length == sizeof(GARMIN_BULK_IN_AVAIL_REPLY) && 1373 if (urb->actual_length == sizeof(GARMIN_BULK_IN_AVAIL_REPLY) &&
1374 0 == memcmp(data, GARMIN_BULK_IN_AVAIL_REPLY, 1374 0 == memcmp(data, GARMIN_BULK_IN_AVAIL_REPLY,
1375 sizeof(GARMIN_BULK_IN_AVAIL_REPLY))) { 1375 sizeof(GARMIN_BULK_IN_AVAIL_REPLY))) {
1376 1376
1377 dbg("%s - bulk data available.", __FUNCTION__); 1377 dbg("%s - bulk data available.", __func__);
1378 1378
1379 if (0 == (garmin_data_p->flags & FLAGS_BULK_IN_ACTIVE)) { 1379 if (0 == (garmin_data_p->flags & FLAGS_BULK_IN_ACTIVE)) {
1380 1380
@@ -1389,7 +1389,7 @@ static void garmin_read_int_callback (struct urb *urb)
1389 if (retval) { 1389 if (retval) {
1390 dev_err(&port->dev, 1390 dev_err(&port->dev,
1391 "%s - failed submitting read urb, error %d\n", 1391 "%s - failed submitting read urb, error %d\n",
1392 __FUNCTION__, retval); 1392 __func__, retval);
1393 } else { 1393 } else {
1394 spin_lock_irqsave(&garmin_data_p->lock, flags); 1394 spin_lock_irqsave(&garmin_data_p->lock, flags);
1395 garmin_data_p->flags |= FLAGS_BULK_IN_ACTIVE; 1395 garmin_data_p->flags |= FLAGS_BULK_IN_ACTIVE;
@@ -1417,14 +1417,14 @@ static void garmin_read_int_callback (struct urb *urb)
1417 = __le32_to_cpup((__le32*)(data+GARMIN_PKTHDR_LENGTH)); 1417 = __le32_to_cpup((__le32*)(data+GARMIN_PKTHDR_LENGTH));
1418 1418
1419 dbg("%s - start-of-session reply seen - serial %u.", 1419 dbg("%s - start-of-session reply seen - serial %u.",
1420 __FUNCTION__, garmin_data_p->serial_num); 1420 __func__, garmin_data_p->serial_num);
1421 } 1421 }
1422 1422
1423 if (garmin_data_p->ignorePkts) { 1423 if (garmin_data_p->ignorePkts) {
1424 /* this reply belongs to a request generated by the driver, 1424 /* this reply belongs to a request generated by the driver,
1425 ignore it. */ 1425 ignore it. */
1426 dbg("%s - pkt ignored (%d)", 1426 dbg("%s - pkt ignored (%d)",
1427 __FUNCTION__, garmin_data_p->ignorePkts); 1427 __func__, garmin_data_p->ignorePkts);
1428 spin_lock_irqsave(&garmin_data_p->lock, flags); 1428 spin_lock_irqsave(&garmin_data_p->lock, flags);
1429 garmin_data_p->ignorePkts--; 1429 garmin_data_p->ignorePkts--;
1430 spin_unlock_irqrestore(&garmin_data_p->lock, flags); 1430 spin_unlock_irqrestore(&garmin_data_p->lock, flags);
@@ -1437,7 +1437,7 @@ static void garmin_read_int_callback (struct urb *urb)
1437 if (retval) 1437 if (retval)
1438 dev_err(&urb->dev->dev, 1438 dev_err(&urb->dev->dev,
1439 "%s - Error %d submitting interrupt urb\n", 1439 "%s - Error %d submitting interrupt urb\n",
1440 __FUNCTION__, retval); 1440 __func__, retval);
1441} 1441}
1442 1442
1443 1443
@@ -1473,7 +1473,7 @@ static void garmin_throttle (struct usb_serial_port *port)
1473 unsigned long flags; 1473 unsigned long flags;
1474 struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); 1474 struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
1475 1475
1476 dbg("%s - port %d", __FUNCTION__, port->number); 1476 dbg("%s - port %d", __func__, port->number);
1477 /* set flag, data received will be put into a queue 1477 /* set flag, data received will be put into a queue
1478 for later processing */ 1478 for later processing */
1479 spin_lock_irqsave(&garmin_data_p->lock, flags); 1479 spin_lock_irqsave(&garmin_data_p->lock, flags);
@@ -1488,7 +1488,7 @@ static void garmin_unthrottle (struct usb_serial_port *port)
1488 struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); 1488 struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
1489 int status; 1489 int status;
1490 1490
1491 dbg("%s - port %d", __FUNCTION__, port->number); 1491 dbg("%s - port %d", __func__, port->number);
1492 spin_lock_irqsave(&garmin_data_p->lock, flags); 1492 spin_lock_irqsave(&garmin_data_p->lock, flags);
1493 garmin_data_p->flags &= ~FLAGS_THROTTLED; 1493 garmin_data_p->flags &= ~FLAGS_THROTTLED;
1494 spin_unlock_irqrestore(&garmin_data_p->lock, flags); 1494 spin_unlock_irqrestore(&garmin_data_p->lock, flags);
@@ -1503,7 +1503,7 @@ static void garmin_unthrottle (struct usb_serial_port *port)
1503 if (status) 1503 if (status)
1504 dev_err(&port->dev, 1504 dev_err(&port->dev,
1505 "%s - failed resubmitting read urb, error %d\n", 1505 "%s - failed resubmitting read urb, error %d\n",
1506 __FUNCTION__, status); 1506 __func__, status);
1507 } 1507 }
1508} 1508}
1509 1509
@@ -1532,11 +1532,11 @@ static int garmin_attach (struct usb_serial *serial)
1532 struct usb_serial_port *port = serial->port[0]; 1532 struct usb_serial_port *port = serial->port[0];
1533 struct garmin_data * garmin_data_p = NULL; 1533 struct garmin_data * garmin_data_p = NULL;
1534 1534
1535 dbg("%s", __FUNCTION__); 1535 dbg("%s", __func__);
1536 1536
1537 garmin_data_p = kzalloc(sizeof(struct garmin_data), GFP_KERNEL); 1537 garmin_data_p = kzalloc(sizeof(struct garmin_data), GFP_KERNEL);
1538 if (garmin_data_p == NULL) { 1538 if (garmin_data_p == NULL) {
1539 dev_err(&port->dev, "%s - Out of memory\n", __FUNCTION__); 1539 dev_err(&port->dev, "%s - Out of memory\n", __func__);
1540 return -ENOMEM; 1540 return -ENOMEM;
1541 } 1541 }
1542 init_timer(&garmin_data_p->timer); 1542 init_timer(&garmin_data_p->timer);
@@ -1561,7 +1561,7 @@ static void garmin_shutdown (struct usb_serial *serial)
1561 struct usb_serial_port *port = serial->port[0]; 1561 struct usb_serial_port *port = serial->port[0];
1562 struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); 1562 struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
1563 1563
1564 dbg("%s", __FUNCTION__); 1564 dbg("%s", __func__);
1565 1565
1566 usb_kill_urb (port->interrupt_in_urb); 1566 usb_kill_urb (port->interrupt_in_urb);
1567 del_timer_sync(&garmin_data_p->timer); 1567 del_timer_sync(&garmin_data_p->timer);
@@ -1579,9 +1579,6 @@ static struct usb_serial_driver garmin_device = {
1579 .description = "Garmin GPS usb/tty", 1579 .description = "Garmin GPS usb/tty",
1580 .usb_driver = &garmin_driver, 1580 .usb_driver = &garmin_driver,
1581 .id_table = id_table, 1581 .id_table = id_table,
1582 .num_interrupt_in = 1,
1583 .num_bulk_in = 1,
1584 .num_bulk_out = 1,
1585 .num_ports = 1, 1582 .num_ports = 1,
1586 .open = garmin_open, 1583 .open = garmin_open,
1587 .close = garmin_close, 1584 .close = garmin_close,
diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c
index 7cfce9dabb9..537f12a027c 100644
--- a/drivers/usb/serial/generic.c
+++ b/drivers/usb/serial/generic.c
@@ -62,9 +62,6 @@ struct usb_serial_driver usb_serial_generic_device = {
62 }, 62 },
63 .id_table = generic_device_ids, 63 .id_table = generic_device_ids,
64 .usb_driver = &generic_driver, 64 .usb_driver = &generic_driver,
65 .num_interrupt_in = NUM_DONT_CARE,
66 .num_bulk_in = NUM_DONT_CARE,
67 .num_bulk_out = NUM_DONT_CARE,
68 .num_ports = 1, 65 .num_ports = 1,
69 .shutdown = usb_serial_generic_shutdown, 66 .shutdown = usb_serial_generic_shutdown,
70 .throttle = usb_serial_generic_throttle, 67 .throttle = usb_serial_generic_throttle,
@@ -121,7 +118,7 @@ int usb_serial_generic_open (struct usb_serial_port *port, struct file *filp)
121 int result = 0; 118 int result = 0;
122 unsigned long flags; 119 unsigned long flags;
123 120
124 dbg("%s - port %d", __FUNCTION__, port->number); 121 dbg("%s - port %d", __func__, port->number);
125 122
126 /* force low_latency on so that our tty_push actually forces the data through, 123 /* force low_latency on so that our tty_push actually forces the data through,
127 otherwise it is scheduled, and with high data rates (like with OHCI) data 124 otherwise it is scheduled, and with high data rates (like with OHCI) data
@@ -148,7 +145,7 @@ int usb_serial_generic_open (struct usb_serial_port *port, struct file *filp)
148 port); 145 port);
149 result = usb_submit_urb(port->read_urb, GFP_KERNEL); 146 result = usb_submit_urb(port->read_urb, GFP_KERNEL);
150 if (result) 147 if (result)
151 dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", __FUNCTION__, result); 148 dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", __func__, result);
152 } 149 }
153 150
154 return result; 151 return result;
@@ -159,7 +156,7 @@ static void generic_cleanup (struct usb_serial_port *port)
159{ 156{
160 struct usb_serial *serial = port->serial; 157 struct usb_serial *serial = port->serial;
161 158
162 dbg("%s - port %d", __FUNCTION__, port->number); 159 dbg("%s - port %d", __func__, port->number);
163 160
164 if (serial->dev) { 161 if (serial->dev) {
165 /* shutdown any bulk reads that might be going on */ 162 /* shutdown any bulk reads that might be going on */
@@ -197,7 +194,7 @@ int usb_serial_generic_resume(struct usb_serial *serial)
197 194
198void usb_serial_generic_close (struct usb_serial_port *port, struct file * filp) 195void usb_serial_generic_close (struct usb_serial_port *port, struct file * filp)
199{ 196{
200 dbg("%s - port %d", __FUNCTION__, port->number); 197 dbg("%s - port %d", __func__, port->number);
201 generic_cleanup (port); 198 generic_cleanup (port);
202} 199}
203 200
@@ -207,10 +204,10 @@ int usb_serial_generic_write(struct usb_serial_port *port, const unsigned char *
207 int result; 204 int result;
208 unsigned char *data; 205 unsigned char *data;
209 206
210 dbg("%s - port %d", __FUNCTION__, port->number); 207 dbg("%s - port %d", __func__, port->number);
211 208
212 if (count == 0) { 209 if (count == 0) {
213 dbg("%s - write request of 0 bytes", __FUNCTION__); 210 dbg("%s - write request of 0 bytes", __func__);
214 return (0); 211 return (0);
215 } 212 }
216 213
@@ -220,7 +217,7 @@ int usb_serial_generic_write(struct usb_serial_port *port, const unsigned char *
220 spin_lock_irqsave(&port->lock, flags); 217 spin_lock_irqsave(&port->lock, flags);
221 if (port->write_urb_busy) { 218 if (port->write_urb_busy) {
222 spin_unlock_irqrestore(&port->lock, flags); 219 spin_unlock_irqrestore(&port->lock, flags);
223 dbg("%s - already writing", __FUNCTION__); 220 dbg("%s - already writing", __func__);
224 return 0; 221 return 0;
225 } 222 }
226 port->write_urb_busy = 1; 223 port->write_urb_busy = 1;
@@ -230,7 +227,7 @@ int usb_serial_generic_write(struct usb_serial_port *port, const unsigned char *
230 227
231 memcpy (port->write_urb->transfer_buffer, buf, count); 228 memcpy (port->write_urb->transfer_buffer, buf, count);
232 data = port->write_urb->transfer_buffer; 229 data = port->write_urb->transfer_buffer;
233 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count, data); 230 usb_serial_debug_data(debug, &port->dev, __func__, count, data);
234 231
235 /* set up our urb */ 232 /* set up our urb */
236 usb_fill_bulk_urb (port->write_urb, serial->dev, 233 usb_fill_bulk_urb (port->write_urb, serial->dev,
@@ -245,7 +242,7 @@ int usb_serial_generic_write(struct usb_serial_port *port, const unsigned char *
245 port->write_urb_busy = 1; 242 port->write_urb_busy = 1;
246 result = usb_submit_urb(port->write_urb, GFP_ATOMIC); 243 result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
247 if (result) { 244 if (result) {
248 dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __FUNCTION__, result); 245 dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __func__, result);
249 /* don't have to grab the lock here, as we will retry if != 0 */ 246 /* don't have to grab the lock here, as we will retry if != 0 */
250 port->write_urb_busy = 0; 247 port->write_urb_busy = 0;
251 } else 248 } else
@@ -263,15 +260,16 @@ int usb_serial_generic_write_room (struct usb_serial_port *port)
263 struct usb_serial *serial = port->serial; 260 struct usb_serial *serial = port->serial;
264 int room = 0; 261 int room = 0;
265 262
266 dbg("%s - port %d", __FUNCTION__, port->number); 263 dbg("%s - port %d", __func__, port->number);
267 264
265 /* FIXME: Locking */
268 if (serial->num_bulk_out) { 266 if (serial->num_bulk_out) {
269 if (!(port->write_urb_busy)) 267 if (!(port->write_urb_busy))
270 room = port->bulk_out_size; 268 room = port->bulk_out_size;
271 } 269 }
272 270
273 dbg("%s - returns %d", __FUNCTION__, room); 271 dbg("%s - returns %d", __func__, room);
274 return (room); 272 return room;
275} 273}
276 274
277int usb_serial_generic_chars_in_buffer (struct usb_serial_port *port) 275int usb_serial_generic_chars_in_buffer (struct usb_serial_port *port)
@@ -279,14 +277,15 @@ int usb_serial_generic_chars_in_buffer (struct usb_serial_port *port)
279 struct usb_serial *serial = port->serial; 277 struct usb_serial *serial = port->serial;
280 int chars = 0; 278 int chars = 0;
281 279
282 dbg("%s - port %d", __FUNCTION__, port->number); 280 dbg("%s - port %d", __func__, port->number);
283 281
282 /* FIXME: Locking */
284 if (serial->num_bulk_out) { 283 if (serial->num_bulk_out) {
285 if (port->write_urb_busy) 284 if (port->write_urb_busy)
286 chars = port->write_urb->transfer_buffer_length; 285 chars = port->write_urb->transfer_buffer_length;
287 } 286 }
288 287
289 dbg("%s - returns %d", __FUNCTION__, chars); 288 dbg("%s - returns %d", __func__, chars);
290 return (chars); 289 return (chars);
291} 290}
292 291
@@ -308,7 +307,7 @@ static void resubmit_read_urb(struct usb_serial_port *port, gfp_t mem_flags)
308 usb_serial_generic_read_bulk_callback), port); 307 usb_serial_generic_read_bulk_callback), port);
309 result = usb_submit_urb(urb, mem_flags); 308 result = usb_submit_urb(urb, mem_flags);
310 if (result) 309 if (result)
311 dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", __FUNCTION__, result); 310 dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", __func__, result);
312} 311}
313 312
314/* Push data to tty layer and resubmit the bulk read URB */ 313/* Push data to tty layer and resubmit the bulk read URB */
@@ -332,20 +331,20 @@ static void flush_and_resubmit_read_urb (struct usb_serial_port *port)
332 331
333void usb_serial_generic_read_bulk_callback (struct urb *urb) 332void usb_serial_generic_read_bulk_callback (struct urb *urb)
334{ 333{
335 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 334 struct usb_serial_port *port = urb->context;
336 unsigned char *data = urb->transfer_buffer; 335 unsigned char *data = urb->transfer_buffer;
337 int status = urb->status; 336 int status = urb->status;
338 unsigned long flags; 337 unsigned long flags;
339 338
340 dbg("%s - port %d", __FUNCTION__, port->number); 339 dbg("%s - port %d", __func__, port->number);
341 340
342 if (unlikely(status != 0)) { 341 if (unlikely(status != 0)) {
343 dbg("%s - nonzero read bulk status received: %d", 342 dbg("%s - nonzero read bulk status received: %d",
344 __FUNCTION__, status); 343 __func__, status);
345 return; 344 return;
346 } 345 }
347 346
348 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, urb->actual_length, data); 347 usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data);
349 348
350 /* Throttle the device if requested by tty */ 349 /* Throttle the device if requested by tty */
351 spin_lock_irqsave(&port->lock, flags); 350 spin_lock_irqsave(&port->lock, flags);
@@ -360,18 +359,17 @@ EXPORT_SYMBOL_GPL(usb_serial_generic_read_bulk_callback);
360 359
361void usb_serial_generic_write_bulk_callback (struct urb *urb) 360void usb_serial_generic_write_bulk_callback (struct urb *urb)
362{ 361{
363 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 362 struct usb_serial_port *port = urb->context;
364 int status = urb->status; 363 int status = urb->status;
365 364
366 dbg("%s - port %d", __FUNCTION__, port->number); 365 dbg("%s - port %d", __func__, port->number);
367 366
368 port->write_urb_busy = 0; 367 port->write_urb_busy = 0;
369 if (status) { 368 if (status) {
370 dbg("%s - nonzero write bulk status received: %d", 369 dbg("%s - nonzero write bulk status received: %d",
371 __FUNCTION__, status); 370 __func__, status);
372 return; 371 return;
373 } 372 }
374
375 usb_serial_port_softint(port); 373 usb_serial_port_softint(port);
376} 374}
377EXPORT_SYMBOL_GPL(usb_serial_generic_write_bulk_callback); 375EXPORT_SYMBOL_GPL(usb_serial_generic_write_bulk_callback);
@@ -380,7 +378,7 @@ void usb_serial_generic_throttle (struct usb_serial_port *port)
380{ 378{
381 unsigned long flags; 379 unsigned long flags;
382 380
383 dbg("%s - port %d", __FUNCTION__, port->number); 381 dbg("%s - port %d", __func__, port->number);
384 382
385 /* Set the throttle request flag. It will be picked up 383 /* Set the throttle request flag. It will be picked up
386 * by usb_serial_generic_read_bulk_callback(). */ 384 * by usb_serial_generic_read_bulk_callback(). */
@@ -394,7 +392,7 @@ void usb_serial_generic_unthrottle (struct usb_serial_port *port)
394 int was_throttled; 392 int was_throttled;
395 unsigned long flags; 393 unsigned long flags;
396 394
397 dbg("%s - port %d", __FUNCTION__, port->number); 395 dbg("%s - port %d", __func__, port->number);
398 396
399 /* Clear the throttle flags */ 397 /* Clear the throttle flags */
400 spin_lock_irqsave(&port->lock, flags); 398 spin_lock_irqsave(&port->lock, flags);
@@ -412,7 +410,7 @@ void usb_serial_generic_shutdown (struct usb_serial *serial)
412{ 410{
413 int i; 411 int i;
414 412
415 dbg("%s", __FUNCTION__); 413 dbg("%s", __func__);
416 414
417 /* stop reads and writes on all ports */ 415 /* stop reads and writes on all ports */
418 for (i=0; i < serial->num_ports; ++i) { 416 for (i=0; i < serial->num_ports; ++i) {
diff --git a/drivers/usb/serial/hp4x.c b/drivers/usb/serial/hp4x.c
index 6c6ebae741c..75b88b356eb 100644
--- a/drivers/usb/serial/hp4x.c
+++ b/drivers/usb/serial/hp4x.c
@@ -50,9 +50,6 @@ static struct usb_serial_driver hp49gp_device = {
50 }, 50 },
51 .id_table = id_table, 51 .id_table = id_table,
52 .usb_driver = &hp49gp_driver, 52 .usb_driver = &hp49gp_driver,
53 .num_interrupt_in = NUM_DONT_CARE,
54 .num_bulk_in = NUM_DONT_CARE,
55 .num_bulk_out = NUM_DONT_CARE,
56 .num_ports = 1, 53 .num_ports = 1,
57}; 54};
58 55
diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
index 3428ccc28da..ce2e487f324 100644
--- a/drivers/usb/serial/io_edgeport.c
+++ b/drivers/usb/serial/io_edgeport.c
@@ -371,7 +371,7 @@ static int get_string (struct usb_device *dev, int Id, char *string, int buflen)
371 struct usb_string_descriptor StringDesc; 371 struct usb_string_descriptor StringDesc;
372 struct usb_string_descriptor *pStringDesc; 372 struct usb_string_descriptor *pStringDesc;
373 373
374 dbg("%s - USB String ID = %d", __FUNCTION__, Id ); 374 dbg("%s - USB String ID = %d", __func__, Id );
375 375
376 if (!usb_get_descriptor(dev, USB_DT_STRING, Id, &StringDesc, sizeof(StringDesc))) { 376 if (!usb_get_descriptor(dev, USB_DT_STRING, Id, &StringDesc, sizeof(StringDesc))) {
377 return 0; 377 return 0;
@@ -391,7 +391,7 @@ static int get_string (struct usb_device *dev, int Id, char *string, int buflen)
391 unicode_to_ascii(string, buflen, pStringDesc->wData, pStringDesc->bLength/2); 391 unicode_to_ascii(string, buflen, pStringDesc->wData, pStringDesc->bLength/2);
392 392
393 kfree(pStringDesc); 393 kfree(pStringDesc);
394 dbg("%s - USB String %s", __FUNCTION__, string); 394 dbg("%s - USB String %s", __func__, string);
395 return strlen(string); 395 return strlen(string);
396} 396}
397 397
@@ -407,7 +407,7 @@ static int get_string_desc (struct usb_device *dev, int Id, struct usb_string_de
407 struct usb_string_descriptor StringDesc; 407 struct usb_string_descriptor StringDesc;
408 struct usb_string_descriptor *pStringDesc; 408 struct usb_string_descriptor *pStringDesc;
409 409
410 dbg("%s - USB String ID = %d", __FUNCTION__, Id ); 410 dbg("%s - USB String ID = %d", __func__, Id );
411 411
412 if (!usb_get_descriptor(dev, USB_DT_STRING, Id, &StringDesc, sizeof(StringDesc))) { 412 if (!usb_get_descriptor(dev, USB_DT_STRING, Id, &StringDesc, sizeof(StringDesc))) {
413 return 0; 413 return 0;
@@ -537,7 +537,7 @@ static int get_epic_descriptor(struct edgeport_serial *ep)
537 sizeof(struct edge_compatibility_descriptor), 537 sizeof(struct edge_compatibility_descriptor),
538 300); 538 300);
539 539
540 dbg("%s result = %d", __FUNCTION__, result); 540 dbg("%s result = %d", __func__, result);
541 541
542 if (result > 0) { 542 if (result > 0) {
543 ep->is_epic = 1; 543 ep->is_epic = 1;
@@ -589,7 +589,7 @@ static int get_epic_descriptor(struct edgeport_serial *ep)
589 *****************************************************************************/ 589 *****************************************************************************/
590static void edge_interrupt_callback (struct urb *urb) 590static void edge_interrupt_callback (struct urb *urb)
591{ 591{
592 struct edgeport_serial *edge_serial = (struct edgeport_serial *)urb->context; 592 struct edgeport_serial *edge_serial = urb->context;
593 struct edgeport_port *edge_port; 593 struct edgeport_port *edge_port;
594 struct usb_serial_port *port; 594 struct usb_serial_port *port;
595 unsigned char *data = urb->transfer_buffer; 595 unsigned char *data = urb->transfer_buffer;
@@ -601,7 +601,7 @@ static void edge_interrupt_callback (struct urb *urb)
601 int result; 601 int result;
602 int status = urb->status; 602 int status = urb->status;
603 603
604 dbg("%s", __FUNCTION__); 604 dbg("%s", __func__);
605 605
606 switch (status) { 606 switch (status) {
607 case 0: 607 case 0:
@@ -612,35 +612,35 @@ static void edge_interrupt_callback (struct urb *urb)
612 case -ESHUTDOWN: 612 case -ESHUTDOWN:
613 /* this urb is terminated, clean up */ 613 /* this urb is terminated, clean up */
614 dbg("%s - urb shutting down with status: %d", 614 dbg("%s - urb shutting down with status: %d",
615 __FUNCTION__, status); 615 __func__, status);
616 return; 616 return;
617 default: 617 default:
618 dbg("%s - nonzero urb status received: %d", 618 dbg("%s - nonzero urb status received: %d",
619 __FUNCTION__, status); 619 __func__, status);
620 goto exit; 620 goto exit;
621 } 621 }
622 622
623 // process this interrupt-read even if there are no ports open 623 // process this interrupt-read even if there are no ports open
624 if (length) { 624 if (length) {
625 usb_serial_debug_data(debug, &edge_serial->serial->dev->dev, __FUNCTION__, length, data); 625 usb_serial_debug_data(debug, &edge_serial->serial->dev->dev, __func__, length, data);
626 626
627 if (length > 1) { 627 if (length > 1) {
628 bytes_avail = data[0] | (data[1] << 8); 628 bytes_avail = data[0] | (data[1] << 8);
629 if (bytes_avail) { 629 if (bytes_avail) {
630 spin_lock(&edge_serial->es_lock); 630 spin_lock(&edge_serial->es_lock);
631 edge_serial->rxBytesAvail += bytes_avail; 631 edge_serial->rxBytesAvail += bytes_avail;
632 dbg("%s - bytes_avail=%d, rxBytesAvail=%d, read_in_progress=%d", __FUNCTION__, bytes_avail, edge_serial->rxBytesAvail, edge_serial->read_in_progress); 632 dbg("%s - bytes_avail=%d, rxBytesAvail=%d, read_in_progress=%d", __func__, bytes_avail, edge_serial->rxBytesAvail, edge_serial->read_in_progress);
633 633
634 if (edge_serial->rxBytesAvail > 0 && 634 if (edge_serial->rxBytesAvail > 0 &&
635 !edge_serial->read_in_progress) { 635 !edge_serial->read_in_progress) {
636 dbg("%s - posting a read", __FUNCTION__); 636 dbg("%s - posting a read", __func__);
637 edge_serial->read_in_progress = true; 637 edge_serial->read_in_progress = true;
638 638
639 /* we have pending bytes on the bulk in pipe, send a request */ 639 /* we have pending bytes on the bulk in pipe, send a request */
640 edge_serial->read_urb->dev = edge_serial->serial->dev; 640 edge_serial->read_urb->dev = edge_serial->serial->dev;
641 result = usb_submit_urb(edge_serial->read_urb, GFP_ATOMIC); 641 result = usb_submit_urb(edge_serial->read_urb, GFP_ATOMIC);
642 if (result) { 642 if (result) {
643 dev_err(&edge_serial->serial->dev->dev, "%s - usb_submit_urb(read bulk) failed with result = %d\n", __FUNCTION__, result); 643 dev_err(&edge_serial->serial->dev->dev, "%s - usb_submit_urb(read bulk) failed with result = %d\n", __func__, result);
644 edge_serial->read_in_progress = false; 644 edge_serial->read_in_progress = false;
645 } 645 }
646 } 646 }
@@ -659,7 +659,7 @@ static void edge_interrupt_callback (struct urb *urb)
659 spin_lock(&edge_port->ep_lock); 659 spin_lock(&edge_port->ep_lock);
660 edge_port->txCredits += txCredits; 660 edge_port->txCredits += txCredits;
661 spin_unlock(&edge_port->ep_lock); 661 spin_unlock(&edge_port->ep_lock);
662 dbg("%s - txcredits for port%d = %d", __FUNCTION__, portNumber, edge_port->txCredits); 662 dbg("%s - txcredits for port%d = %d", __func__, portNumber, edge_port->txCredits);
663 663
664 /* tell the tty driver that something has changed */ 664 /* tell the tty driver that something has changed */
665 if (edge_port->port->tty) 665 if (edge_port->port->tty)
@@ -677,7 +677,7 @@ static void edge_interrupt_callback (struct urb *urb)
677exit: 677exit:
678 result = usb_submit_urb (urb, GFP_ATOMIC); 678 result = usb_submit_urb (urb, GFP_ATOMIC);
679 if (result) { 679 if (result) {
680 dev_err(&urb->dev->dev, "%s - Error %d submitting control urb\n", __FUNCTION__, result); 680 dev_err(&urb->dev->dev, "%s - Error %d submitting control urb\n", __func__, result);
681 } 681 }
682} 682}
683 683
@@ -689,49 +689,49 @@ exit:
689 *****************************************************************************/ 689 *****************************************************************************/
690static void edge_bulk_in_callback (struct urb *urb) 690static void edge_bulk_in_callback (struct urb *urb)
691{ 691{
692 struct edgeport_serial *edge_serial = (struct edgeport_serial *)urb->context; 692 struct edgeport_serial *edge_serial = urb->context;
693 unsigned char *data = urb->transfer_buffer; 693 unsigned char *data = urb->transfer_buffer;
694 int retval; 694 int retval;
695 __u16 raw_data_length; 695 __u16 raw_data_length;
696 int status = urb->status; 696 int status = urb->status;
697 697
698 dbg("%s", __FUNCTION__); 698 dbg("%s", __func__);
699 699
700 if (status) { 700 if (status) {
701 dbg("%s - nonzero read bulk status received: %d", 701 dbg("%s - nonzero read bulk status received: %d",
702 __FUNCTION__, status); 702 __func__, status);
703 edge_serial->read_in_progress = false; 703 edge_serial->read_in_progress = false;
704 return; 704 return;
705 } 705 }
706 706
707 if (urb->actual_length == 0) { 707 if (urb->actual_length == 0) {
708 dbg("%s - read bulk callback with no data", __FUNCTION__); 708 dbg("%s - read bulk callback with no data", __func__);
709 edge_serial->read_in_progress = false; 709 edge_serial->read_in_progress = false;
710 return; 710 return;
711 } 711 }
712 712
713 raw_data_length = urb->actual_length; 713 raw_data_length = urb->actual_length;
714 714
715 usb_serial_debug_data(debug, &edge_serial->serial->dev->dev, __FUNCTION__, raw_data_length, data); 715 usb_serial_debug_data(debug, &edge_serial->serial->dev->dev, __func__, raw_data_length, data);
716 716
717 spin_lock(&edge_serial->es_lock); 717 spin_lock(&edge_serial->es_lock);
718 718
719 /* decrement our rxBytes available by the number that we just got */ 719 /* decrement our rxBytes available by the number that we just got */
720 edge_serial->rxBytesAvail -= raw_data_length; 720 edge_serial->rxBytesAvail -= raw_data_length;
721 721
722 dbg("%s - Received = %d, rxBytesAvail %d", __FUNCTION__, raw_data_length, edge_serial->rxBytesAvail); 722 dbg("%s - Received = %d, rxBytesAvail %d", __func__, raw_data_length, edge_serial->rxBytesAvail);
723 723
724 process_rcvd_data (edge_serial, data, urb->actual_length); 724 process_rcvd_data (edge_serial, data, urb->actual_length);
725 725
726 /* check to see if there's any more data for us to read */ 726 /* check to see if there's any more data for us to read */
727 if (edge_serial->rxBytesAvail > 0) { 727 if (edge_serial->rxBytesAvail > 0) {
728 dbg("%s - posting a read", __FUNCTION__); 728 dbg("%s - posting a read", __func__);
729 edge_serial->read_urb->dev = edge_serial->serial->dev; 729 edge_serial->read_urb->dev = edge_serial->serial->dev;
730 retval = usb_submit_urb(edge_serial->read_urb, GFP_ATOMIC); 730 retval = usb_submit_urb(edge_serial->read_urb, GFP_ATOMIC);
731 if (retval) { 731 if (retval) {
732 dev_err(&urb->dev->dev, 732 dev_err(&urb->dev->dev,
733 "%s - usb_submit_urb(read bulk) failed, " 733 "%s - usb_submit_urb(read bulk) failed, "
734 "retval = %d\n", __FUNCTION__, retval); 734 "retval = %d\n", __func__, retval);
735 edge_serial->read_in_progress = false; 735 edge_serial->read_in_progress = false;
736 } 736 }
737 } else { 737 } else {
@@ -749,15 +749,15 @@ static void edge_bulk_in_callback (struct urb *urb)
749 *****************************************************************************/ 749 *****************************************************************************/
750static void edge_bulk_out_data_callback (struct urb *urb) 750static void edge_bulk_out_data_callback (struct urb *urb)
751{ 751{
752 struct edgeport_port *edge_port = (struct edgeport_port *)urb->context; 752 struct edgeport_port *edge_port = urb->context;
753 struct tty_struct *tty; 753 struct tty_struct *tty;
754 int status = urb->status; 754 int status = urb->status;
755 755
756 dbg("%s", __FUNCTION__); 756 dbg("%s", __func__);
757 757
758 if (status) { 758 if (status) {
759 dbg("%s - nonzero write bulk status received: %d", 759 dbg("%s - nonzero write bulk status received: %d",
760 __FUNCTION__, status); 760 __func__, status);
761 } 761 }
762 762
763 tty = edge_port->port->tty; 763 tty = edge_port->port->tty;
@@ -782,14 +782,14 @@ static void edge_bulk_out_data_callback (struct urb *urb)
782 *****************************************************************************/ 782 *****************************************************************************/
783static void edge_bulk_out_cmd_callback (struct urb *urb) 783static void edge_bulk_out_cmd_callback (struct urb *urb)
784{ 784{
785 struct edgeport_port *edge_port = (struct edgeport_port *)urb->context; 785 struct edgeport_port *edge_port = urb->context;
786 struct tty_struct *tty; 786 struct tty_struct *tty;
787 int status = urb->status; 787 int status = urb->status;
788 788
789 dbg("%s", __FUNCTION__); 789 dbg("%s", __func__);
790 790
791 atomic_dec(&CmdUrbs); 791 atomic_dec(&CmdUrbs);
792 dbg("%s - FREE URB %p (outstanding %d)", __FUNCTION__, urb, atomic_read(&CmdUrbs)); 792 dbg("%s - FREE URB %p (outstanding %d)", __func__, urb, atomic_read(&CmdUrbs));
793 793
794 794
795 /* clean up the transfer buffer */ 795 /* clean up the transfer buffer */
@@ -799,7 +799,7 @@ static void edge_bulk_out_cmd_callback (struct urb *urb)
799 usb_free_urb (urb); 799 usb_free_urb (urb);
800 800
801 if (status) { 801 if (status) {
802 dbg("%s - nonzero write bulk status received: %d", __FUNCTION__, status); 802 dbg("%s - nonzero write bulk status received: %d", __func__, status);
803 return; 803 return;
804 } 804 }
805 805
@@ -833,7 +833,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp)
833 struct edgeport_serial *edge_serial; 833 struct edgeport_serial *edge_serial;
834 int response; 834 int response;
835 835
836 dbg("%s - port %d", __FUNCTION__, port->number); 836 dbg("%s - port %d", __func__, port->number);
837 837
838 if (edge_port == NULL) 838 if (edge_port == NULL)
839 return -ENODEV; 839 return -ENODEV;
@@ -883,7 +883,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp)
883 * this interrupt will continue as long as the edgeport is connected */ 883 * this interrupt will continue as long as the edgeport is connected */
884 response = usb_submit_urb (edge_serial->interrupt_read_urb, GFP_KERNEL); 884 response = usb_submit_urb (edge_serial->interrupt_read_urb, GFP_KERNEL);
885 if (response) { 885 if (response) {
886 dev_err(&port->dev, "%s - Error %d submitting control urb\n", __FUNCTION__, response); 886 dev_err(&port->dev, "%s - Error %d submitting control urb\n", __func__, response);
887 } 887 }
888 } 888 }
889 889
@@ -907,7 +907,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp)
907 response = send_iosp_ext_cmd (edge_port, IOSP_CMD_OPEN_PORT, 0); 907 response = send_iosp_ext_cmd (edge_port, IOSP_CMD_OPEN_PORT, 0);
908 908
909 if (response < 0) { 909 if (response < 0) {
910 dev_err(&port->dev, "%s - error sending open port command\n", __FUNCTION__); 910 dev_err(&port->dev, "%s - error sending open port command\n", __func__);
911 edge_port->openPending = false; 911 edge_port->openPending = false;
912 return -ENODEV; 912 return -ENODEV;
913 } 913 }
@@ -917,7 +917,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp)
917 917
918 if (!edge_port->open) { 918 if (!edge_port->open) {
919 /* open timed out */ 919 /* open timed out */
920 dbg("%s - open timedout", __FUNCTION__); 920 dbg("%s - open timedout", __func__);
921 edge_port->openPending = false; 921 edge_port->openPending = false;
922 return -ENODEV; 922 return -ENODEV;
923 } 923 }
@@ -930,7 +930,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp)
930 edge_port->txfifo.fifo = kmalloc (edge_port->maxTxCredits, GFP_KERNEL); 930 edge_port->txfifo.fifo = kmalloc (edge_port->maxTxCredits, GFP_KERNEL);
931 931
932 if (!edge_port->txfifo.fifo) { 932 if (!edge_port->txfifo.fifo) {
933 dbg("%s - no memory", __FUNCTION__); 933 dbg("%s - no memory", __func__);
934 edge_close (port, filp); 934 edge_close (port, filp);
935 return -ENOMEM; 935 return -ENOMEM;
936 } 936 }
@@ -940,14 +940,14 @@ static int edge_open (struct usb_serial_port *port, struct file * filp)
940 edge_port->write_in_progress = false; 940 edge_port->write_in_progress = false;
941 941
942 if (!edge_port->write_urb) { 942 if (!edge_port->write_urb) {
943 dbg("%s - no memory", __FUNCTION__); 943 dbg("%s - no memory", __func__);
944 edge_close (port, filp); 944 edge_close (port, filp);
945 return -ENOMEM; 945 return -ENOMEM;
946 } 946 }
947 947
948 dbg("%s(%d) - Initialize TX fifo to %d bytes", __FUNCTION__, port->number, edge_port->maxTxCredits); 948 dbg("%s(%d) - Initialize TX fifo to %d bytes", __func__, port->number, edge_port->maxTxCredits);
949 949
950 dbg("%s exited", __FUNCTION__); 950 dbg("%s exited", __func__);
951 951
952 return 0; 952 return 0;
953} 953}
@@ -976,11 +976,11 @@ static void block_until_chase_response(struct edgeport_port *edge_port)
976 976
977 // Did we get our Chase response 977 // Did we get our Chase response
978 if (!edge_port->chaseResponsePending) { 978 if (!edge_port->chaseResponsePending) {
979 dbg("%s - Got Chase Response", __FUNCTION__); 979 dbg("%s - Got Chase Response", __func__);
980 980
981 // did we get all of our credit back? 981 // did we get all of our credit back?
982 if (edge_port->txCredits == edge_port->maxTxCredits ) { 982 if (edge_port->txCredits == edge_port->maxTxCredits ) {
983 dbg("%s - Got all credits", __FUNCTION__); 983 dbg("%s - Got all credits", __func__);
984 return; 984 return;
985 } 985 }
986 } 986 }
@@ -995,12 +995,12 @@ static void block_until_chase_response(struct edgeport_port *edge_port)
995 loop--; 995 loop--;
996 if (loop == 0) { 996 if (loop == 0) {
997 edge_port->chaseResponsePending = false; 997 edge_port->chaseResponsePending = false;
998 dbg("%s - Chase TIMEOUT", __FUNCTION__); 998 dbg("%s - Chase TIMEOUT", __func__);
999 return; 999 return;
1000 } 1000 }
1001 } else { 1001 } else {
1002 // Reset timeout value back to 10 seconds 1002 // Reset timeout value back to 10 seconds
1003 dbg("%s - Last %d, Current %d", __FUNCTION__, lastCredits, edge_port->txCredits); 1003 dbg("%s - Last %d, Current %d", __func__, lastCredits, edge_port->txCredits);
1004 loop = 10; 1004 loop = 10;
1005 } 1005 }
1006 } 1006 }
@@ -1031,7 +1031,7 @@ static void block_until_tx_empty (struct edgeport_port *edge_port)
1031 1031
1032 // Is the Edgeport Buffer empty? 1032 // Is the Edgeport Buffer empty?
1033 if (lastCount == 0) { 1033 if (lastCount == 0) {
1034 dbg("%s - TX Buffer Empty", __FUNCTION__); 1034 dbg("%s - TX Buffer Empty", __func__);
1035 return; 1035 return;
1036 } 1036 }
1037 1037
@@ -1040,13 +1040,13 @@ static void block_until_tx_empty (struct edgeport_port *edge_port)
1040 schedule_timeout(timeout); 1040 schedule_timeout(timeout);
1041 finish_wait(&edge_port->wait_chase, &wait); 1041 finish_wait(&edge_port->wait_chase, &wait);
1042 1042
1043 dbg("%s wait", __FUNCTION__); 1043 dbg("%s wait", __func__);
1044 1044
1045 if (lastCount == fifo->count) { 1045 if (lastCount == fifo->count) {
1046 // No activity.. count down. 1046 // No activity.. count down.
1047 loop--; 1047 loop--;
1048 if (loop == 0) { 1048 if (loop == 0) {
1049 dbg("%s - TIMEOUT", __FUNCTION__); 1049 dbg("%s - TIMEOUT", __func__);
1050 return; 1050 return;
1051 } 1051 }
1052 } else { 1052 } else {
@@ -1067,7 +1067,7 @@ static void edge_close (struct usb_serial_port *port, struct file * filp)
1067 struct edgeport_port *edge_port; 1067 struct edgeport_port *edge_port;
1068 int status; 1068 int status;
1069 1069
1070 dbg("%s - port %d", __FUNCTION__, port->number); 1070 dbg("%s - port %d", __func__, port->number);
1071 1071
1072 edge_serial = usb_get_serial_data(port->serial); 1072 edge_serial = usb_get_serial_data(port->serial);
1073 edge_port = usb_get_serial_port_data(port); 1073 edge_port = usb_get_serial_port_data(port);
@@ -1085,7 +1085,7 @@ static void edge_close (struct usb_serial_port *port, struct file * filp)
1085 /* flush and chase */ 1085 /* flush and chase */
1086 edge_port->chaseResponsePending = true; 1086 edge_port->chaseResponsePending = true;
1087 1087
1088 dbg("%s - Sending IOSP_CMD_CHASE_PORT", __FUNCTION__); 1088 dbg("%s - Sending IOSP_CMD_CHASE_PORT", __func__);
1089 status = send_iosp_ext_cmd (edge_port, IOSP_CMD_CHASE_PORT, 0); 1089 status = send_iosp_ext_cmd (edge_port, IOSP_CMD_CHASE_PORT, 0);
1090 if (status == 0) { 1090 if (status == 0) {
1091 // block until chase finished 1091 // block until chase finished
@@ -1099,7 +1099,7 @@ static void edge_close (struct usb_serial_port *port, struct file * filp)
1099 ((edge_serial->is_epic) && 1099 ((edge_serial->is_epic) &&
1100 (edge_serial->epic_descriptor.Supports.IOSPClose))) { 1100 (edge_serial->epic_descriptor.Supports.IOSPClose))) {
1101 /* close the port */ 1101 /* close the port */
1102 dbg("%s - Sending IOSP_CMD_CLOSE_PORT", __FUNCTION__); 1102 dbg("%s - Sending IOSP_CMD_CLOSE_PORT", __func__);
1103 send_iosp_ext_cmd (edge_port, IOSP_CMD_CLOSE_PORT, 0); 1103 send_iosp_ext_cmd (edge_port, IOSP_CMD_CLOSE_PORT, 0);
1104 } 1104 }
1105 1105
@@ -1119,7 +1119,7 @@ static void edge_close (struct usb_serial_port *port, struct file * filp)
1119 kfree(edge_port->txfifo.fifo); 1119 kfree(edge_port->txfifo.fifo);
1120 edge_port->txfifo.fifo = NULL; 1120 edge_port->txfifo.fifo = NULL;
1121 1121
1122 dbg("%s exited", __FUNCTION__); 1122 dbg("%s exited", __func__);
1123} 1123}
1124 1124
1125/***************************************************************************** 1125/*****************************************************************************
@@ -1139,7 +1139,7 @@ static int edge_write (struct usb_serial_port *port, const unsigned char *data,
1139 int secondhalf; 1139 int secondhalf;
1140 unsigned long flags; 1140 unsigned long flags;
1141 1141
1142 dbg("%s - port %d", __FUNCTION__, port->number); 1142 dbg("%s - port %d", __func__, port->number);
1143 1143
1144 if (edge_port == NULL) 1144 if (edge_port == NULL)
1145 return -ENODEV; 1145 return -ENODEV;
@@ -1152,12 +1152,12 @@ static int edge_write (struct usb_serial_port *port, const unsigned char *data,
1152 // calculate number of bytes to put in fifo 1152 // calculate number of bytes to put in fifo
1153 copySize = min ((unsigned int)count, (edge_port->txCredits - fifo->count)); 1153 copySize = min ((unsigned int)count, (edge_port->txCredits - fifo->count));
1154 1154
1155 dbg("%s(%d) of %d byte(s) Fifo room %d -- will copy %d bytes", __FUNCTION__, 1155 dbg("%s(%d) of %d byte(s) Fifo room %d -- will copy %d bytes", __func__,
1156 port->number, count, edge_port->txCredits - fifo->count, copySize); 1156 port->number, count, edge_port->txCredits - fifo->count, copySize);
1157 1157
1158 /* catch writes of 0 bytes which the tty driver likes to give us, and when txCredits is empty */ 1158 /* catch writes of 0 bytes which the tty driver likes to give us, and when txCredits is empty */
1159 if (copySize == 0) { 1159 if (copySize == 0) {
1160 dbg("%s - copySize = Zero", __FUNCTION__); 1160 dbg("%s - copySize = Zero", __func__);
1161 goto finish_write; 1161 goto finish_write;
1162 } 1162 }
1163 1163
@@ -1169,11 +1169,11 @@ static int edge_write (struct usb_serial_port *port, const unsigned char *data,
1169 1169
1170 bytesleft = fifo->size - fifo->head; 1170 bytesleft = fifo->size - fifo->head;
1171 firsthalf = min (bytesleft, copySize); 1171 firsthalf = min (bytesleft, copySize);
1172 dbg("%s - copy %d bytes of %d into fifo ", __FUNCTION__, firsthalf, bytesleft); 1172 dbg("%s - copy %d bytes of %d into fifo ", __func__, firsthalf, bytesleft);
1173 1173
1174 /* now copy our data */ 1174 /* now copy our data */
1175 memcpy(&fifo->fifo[fifo->head], data, firsthalf); 1175 memcpy(&fifo->fifo[fifo->head], data, firsthalf);
1176 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, firsthalf, &fifo->fifo[fifo->head]); 1176 usb_serial_debug_data(debug, &port->dev, __func__, firsthalf, &fifo->fifo[fifo->head]);
1177 1177
1178 // update the index and size 1178 // update the index and size
1179 fifo->head += firsthalf; 1179 fifo->head += firsthalf;
@@ -1187,9 +1187,9 @@ static int edge_write (struct usb_serial_port *port, const unsigned char *data,
1187 secondhalf = copySize-firsthalf; 1187 secondhalf = copySize-firsthalf;
1188 1188
1189 if (secondhalf) { 1189 if (secondhalf) {
1190 dbg("%s - copy rest of data %d", __FUNCTION__, secondhalf); 1190 dbg("%s - copy rest of data %d", __func__, secondhalf);
1191 memcpy(&fifo->fifo[fifo->head], &data[firsthalf], secondhalf); 1191 memcpy(&fifo->fifo[fifo->head], &data[firsthalf], secondhalf);
1192 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, secondhalf, &fifo->fifo[fifo->head]); 1192 usb_serial_debug_data(debug, &port->dev, __func__, secondhalf, &fifo->fifo[fifo->head]);
1193 // update the index and size 1193 // update the index and size
1194 fifo->count += secondhalf; 1194 fifo->count += secondhalf;
1195 fifo->head += secondhalf; 1195 fifo->head += secondhalf;
@@ -1201,7 +1201,7 @@ finish_write:
1201 1201
1202 send_more_port_data((struct edgeport_serial *)usb_get_serial_data(port->serial), edge_port); 1202 send_more_port_data((struct edgeport_serial *)usb_get_serial_data(port->serial), edge_port);
1203 1203
1204 dbg("%s wrote %d byte(s) TxCredits %d, Fifo %d", __FUNCTION__, copySize, edge_port->txCredits, fifo->count); 1204 dbg("%s wrote %d byte(s) TxCredits %d, Fifo %d", __func__, copySize, edge_port->txCredits, fifo->count);
1205 1205
1206 return copySize; 1206 return copySize;
1207} 1207}
@@ -1232,14 +1232,14 @@ static void send_more_port_data(struct edgeport_serial *edge_serial, struct edge
1232 int secondhalf; 1232 int secondhalf;
1233 unsigned long flags; 1233 unsigned long flags;
1234 1234
1235 dbg("%s(%d)", __FUNCTION__, edge_port->port->number); 1235 dbg("%s(%d)", __func__, edge_port->port->number);
1236 1236
1237 spin_lock_irqsave(&edge_port->ep_lock, flags); 1237 spin_lock_irqsave(&edge_port->ep_lock, flags);
1238 1238
1239 if (edge_port->write_in_progress || 1239 if (edge_port->write_in_progress ||
1240 !edge_port->open || 1240 !edge_port->open ||
1241 (fifo->count == 0)) { 1241 (fifo->count == 0)) {
1242 dbg("%s(%d) EXIT - fifo %d, PendingWrite = %d", __FUNCTION__, edge_port->port->number, fifo->count, edge_port->write_in_progress); 1242 dbg("%s(%d) EXIT - fifo %d, PendingWrite = %d", __func__, edge_port->port->number, fifo->count, edge_port->write_in_progress);
1243 goto exit_send; 1243 goto exit_send;
1244 } 1244 }
1245 1245
@@ -1251,7 +1251,7 @@ static void send_more_port_data(struct edgeport_serial *edge_serial, struct edge
1251 // it's better to wait for more credits so we can do a larger 1251 // it's better to wait for more credits so we can do a larger
1252 // write. 1252 // write.
1253 if (edge_port->txCredits < EDGE_FW_GET_TX_CREDITS_SEND_THRESHOLD(edge_port->maxTxCredits,EDGE_FW_BULK_MAX_PACKET_SIZE)) { 1253 if (edge_port->txCredits < EDGE_FW_GET_TX_CREDITS_SEND_THRESHOLD(edge_port->maxTxCredits,EDGE_FW_BULK_MAX_PACKET_SIZE)) {
1254 dbg("%s(%d) Not enough credit - fifo %d TxCredit %d", __FUNCTION__, edge_port->port->number, fifo->count, edge_port->txCredits ); 1254 dbg("%s(%d) Not enough credit - fifo %d TxCredit %d", __func__, edge_port->port->number, fifo->count, edge_port->txCredits );
1255 goto exit_send; 1255 goto exit_send;
1256 } 1256 }
1257 1257
@@ -1269,7 +1269,7 @@ static void send_more_port_data(struct edgeport_serial *edge_serial, struct edge
1269 count = fifo->count; 1269 count = fifo->count;
1270 buffer = kmalloc (count+2, GFP_ATOMIC); 1270 buffer = kmalloc (count+2, GFP_ATOMIC);
1271 if (buffer == NULL) { 1271 if (buffer == NULL) {
1272 dev_err(&edge_port->port->dev, "%s - no more kernel memory...\n", __FUNCTION__); 1272 dev_err(&edge_port->port->dev, "%s - no more kernel memory...\n", __func__);
1273 edge_port->write_in_progress = false; 1273 edge_port->write_in_progress = false;
1274 goto exit_send; 1274 goto exit_send;
1275 } 1275 }
@@ -1294,7 +1294,7 @@ static void send_more_port_data(struct edgeport_serial *edge_serial, struct edge
1294 } 1294 }
1295 1295
1296 if (count) 1296 if (count)
1297 usb_serial_debug_data(debug, &edge_port->port->dev, __FUNCTION__, count, &buffer[2]); 1297 usb_serial_debug_data(debug, &edge_port->port->dev, __func__, count, &buffer[2]);
1298 1298
1299 /* fill up the urb with all of our data and submit it */ 1299 /* fill up the urb with all of our data and submit it */
1300 usb_fill_bulk_urb (urb, edge_serial->serial->dev, 1300 usb_fill_bulk_urb (urb, edge_serial->serial->dev,
@@ -1309,14 +1309,14 @@ static void send_more_port_data(struct edgeport_serial *edge_serial, struct edge
1309 status = usb_submit_urb(urb, GFP_ATOMIC); 1309 status = usb_submit_urb(urb, GFP_ATOMIC);
1310 if (status) { 1310 if (status) {
1311 /* something went wrong */ 1311 /* something went wrong */
1312 dev_err(&edge_port->port->dev, "%s - usb_submit_urb(write bulk) failed, status = %d, data lost\n", __FUNCTION__, status); 1312 dev_err(&edge_port->port->dev, "%s - usb_submit_urb(write bulk) failed, status = %d, data lost\n", __func__, status);
1313 edge_port->write_in_progress = false; 1313 edge_port->write_in_progress = false;
1314 1314
1315 /* revert the credits as something bad happened. */ 1315 /* revert the credits as something bad happened. */
1316 edge_port->txCredits += count; 1316 edge_port->txCredits += count;
1317 edge_port->icount.tx -= count; 1317 edge_port->icount.tx -= count;
1318 } 1318 }
1319 dbg("%s wrote %d byte(s) TxCredit %d, Fifo %d", __FUNCTION__, count, edge_port->txCredits, fifo->count); 1319 dbg("%s wrote %d byte(s) TxCredit %d, Fifo %d", __func__, count, edge_port->txCredits, fifo->count);
1320 1320
1321exit_send: 1321exit_send:
1322 spin_unlock_irqrestore(&edge_port->ep_lock, flags); 1322 spin_unlock_irqrestore(&edge_port->ep_lock, flags);
@@ -1337,17 +1337,17 @@ static int edge_write_room (struct usb_serial_port *port)
1337 int room; 1337 int room;
1338 unsigned long flags; 1338 unsigned long flags;
1339 1339
1340 dbg("%s", __FUNCTION__); 1340 dbg("%s", __func__);
1341 1341
1342 if (edge_port == NULL) 1342 if (edge_port == NULL)
1343 return -ENODEV; 1343 return -ENODEV;
1344 if (edge_port->closePending) 1344 if (edge_port->closePending)
1345 return -ENODEV; 1345 return -ENODEV;
1346 1346
1347 dbg("%s - port %d", __FUNCTION__, port->number); 1347 dbg("%s - port %d", __func__, port->number);
1348 1348
1349 if (!edge_port->open) { 1349 if (!edge_port->open) {
1350 dbg("%s - port not opened", __FUNCTION__); 1350 dbg("%s - port not opened", __func__);
1351 return -EINVAL; 1351 return -EINVAL;
1352 } 1352 }
1353 1353
@@ -1356,7 +1356,7 @@ static int edge_write_room (struct usb_serial_port *port)
1356 room = edge_port->txCredits - edge_port->txfifo.count; 1356 room = edge_port->txCredits - edge_port->txfifo.count;
1357 spin_unlock_irqrestore(&edge_port->ep_lock, flags); 1357 spin_unlock_irqrestore(&edge_port->ep_lock, flags);
1358 1358
1359 dbg("%s - returns %d", __FUNCTION__, room); 1359 dbg("%s - returns %d", __func__, room);
1360 return room; 1360 return room;
1361} 1361}
1362 1362
@@ -1376,7 +1376,7 @@ static int edge_chars_in_buffer (struct usb_serial_port *port)
1376 int num_chars; 1376 int num_chars;
1377 unsigned long flags; 1377 unsigned long flags;
1378 1378
1379 dbg("%s", __FUNCTION__); 1379 dbg("%s", __func__);
1380 1380
1381 if (edge_port == NULL) 1381 if (edge_port == NULL)
1382 return -ENODEV; 1382 return -ENODEV;
@@ -1384,7 +1384,7 @@ static int edge_chars_in_buffer (struct usb_serial_port *port)
1384 return -ENODEV; 1384 return -ENODEV;
1385 1385
1386 if (!edge_port->open) { 1386 if (!edge_port->open) {
1387 dbg("%s - port not opened", __FUNCTION__); 1387 dbg("%s - port not opened", __func__);
1388 return -EINVAL; 1388 return -EINVAL;
1389 } 1389 }
1390 1390
@@ -1392,7 +1392,7 @@ static int edge_chars_in_buffer (struct usb_serial_port *port)
1392 num_chars = edge_port->maxTxCredits - edge_port->txCredits + edge_port->txfifo.count; 1392 num_chars = edge_port->maxTxCredits - edge_port->txCredits + edge_port->txfifo.count;
1393 spin_unlock_irqrestore(&edge_port->ep_lock, flags); 1393 spin_unlock_irqrestore(&edge_port->ep_lock, flags);
1394 if (num_chars) { 1394 if (num_chars) {
1395 dbg("%s(port %d) - returns %d", __FUNCTION__, port->number, num_chars); 1395 dbg("%s(port %d) - returns %d", __func__, port->number, num_chars);
1396 } 1396 }
1397 1397
1398 return num_chars; 1398 return num_chars;
@@ -1410,19 +1410,19 @@ static void edge_throttle (struct usb_serial_port *port)
1410 struct tty_struct *tty; 1410 struct tty_struct *tty;
1411 int status; 1411 int status;
1412 1412
1413 dbg("%s - port %d", __FUNCTION__, port->number); 1413 dbg("%s - port %d", __func__, port->number);
1414 1414
1415 if (edge_port == NULL) 1415 if (edge_port == NULL)
1416 return; 1416 return;
1417 1417
1418 if (!edge_port->open) { 1418 if (!edge_port->open) {
1419 dbg("%s - port not opened", __FUNCTION__); 1419 dbg("%s - port not opened", __func__);
1420 return; 1420 return;
1421 } 1421 }
1422 1422
1423 tty = port->tty; 1423 tty = port->tty;
1424 if (!tty) { 1424 if (!tty) {
1425 dbg ("%s - no tty available", __FUNCTION__); 1425 dbg ("%s - no tty available", __func__);
1426 return; 1426 return;
1427 } 1427 }
1428 1428
@@ -1459,19 +1459,19 @@ static void edge_unthrottle (struct usb_serial_port *port)
1459 struct tty_struct *tty; 1459 struct tty_struct *tty;
1460 int status; 1460 int status;
1461 1461
1462 dbg("%s - port %d", __FUNCTION__, port->number); 1462 dbg("%s - port %d", __func__, port->number);
1463 1463
1464 if (edge_port == NULL) 1464 if (edge_port == NULL)
1465 return; 1465 return;
1466 1466
1467 if (!edge_port->open) { 1467 if (!edge_port->open) {
1468 dbg("%s - port not opened", __FUNCTION__); 1468 dbg("%s - port not opened", __func__);
1469 return; 1469 return;
1470 } 1470 }
1471 1471
1472 tty = port->tty; 1472 tty = port->tty;
1473 if (!tty) { 1473 if (!tty) {
1474 dbg ("%s - no tty available", __FUNCTION__); 1474 dbg ("%s - no tty available", __func__);
1475 return; 1475 return;
1476 } 1476 }
1477 1477
@@ -1509,18 +1509,18 @@ static void edge_set_termios (struct usb_serial_port *port, struct ktermios *old
1509 unsigned int cflag; 1509 unsigned int cflag;
1510 1510
1511 cflag = tty->termios->c_cflag; 1511 cflag = tty->termios->c_cflag;
1512 dbg("%s - clfag %08x iflag %08x", __FUNCTION__, 1512 dbg("%s - clfag %08x iflag %08x", __func__,
1513 tty->termios->c_cflag, tty->termios->c_iflag); 1513 tty->termios->c_cflag, tty->termios->c_iflag);
1514 dbg("%s - old clfag %08x old iflag %08x", __FUNCTION__, 1514 dbg("%s - old clfag %08x old iflag %08x", __func__,
1515 old_termios->c_cflag, old_termios->c_iflag); 1515 old_termios->c_cflag, old_termios->c_iflag);
1516 1516
1517 dbg("%s - port %d", __FUNCTION__, port->number); 1517 dbg("%s - port %d", __func__, port->number);
1518 1518
1519 if (edge_port == NULL) 1519 if (edge_port == NULL)
1520 return; 1520 return;
1521 1521
1522 if (!edge_port->open) { 1522 if (!edge_port->open) {
1523 dbg("%s - port not opened", __FUNCTION__); 1523 dbg("%s - port not opened", __func__);
1524 return; 1524 return;
1525 } 1525 }
1526 1526
@@ -1549,7 +1549,7 @@ static int get_lsr_info(struct edgeport_port *edge_port, unsigned int __user *va
1549 spin_lock_irqsave(&edge_port->ep_lock, flags); 1549 spin_lock_irqsave(&edge_port->ep_lock, flags);
1550 if (edge_port->maxTxCredits == edge_port->txCredits && 1550 if (edge_port->maxTxCredits == edge_port->txCredits &&
1551 edge_port->txfifo.count == 0) { 1551 edge_port->txfifo.count == 0) {
1552 dbg("%s -- Empty", __FUNCTION__); 1552 dbg("%s -- Empty", __func__);
1553 result = TIOCSER_TEMT; 1553 result = TIOCSER_TEMT;
1554 } 1554 }
1555 spin_unlock_irqrestore(&edge_port->ep_lock, flags); 1555 spin_unlock_irqrestore(&edge_port->ep_lock, flags);
@@ -1569,7 +1569,7 @@ static int get_number_bytes_avail(struct edgeport_port *edge_port, unsigned int
1569 1569
1570 result = tty->read_cnt; 1570 result = tty->read_cnt;
1571 1571
1572 dbg("%s(%d) = %d", __FUNCTION__, edge_port->port->number, result); 1572 dbg("%s(%d) = %d", __func__, edge_port->port->number, result);
1573 if (copy_to_user(value, &result, sizeof(int))) 1573 if (copy_to_user(value, &result, sizeof(int)))
1574 return -EFAULT; 1574 return -EFAULT;
1575 //return 0; 1575 //return 0;
@@ -1581,7 +1581,7 @@ static int edge_tiocmset (struct usb_serial_port *port, struct file *file, unsig
1581 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 1581 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
1582 unsigned int mcr; 1582 unsigned int mcr;
1583 1583
1584 dbg("%s - port %d", __FUNCTION__, port->number); 1584 dbg("%s - port %d", __func__, port->number);
1585 1585
1586 mcr = edge_port->shadowMCR; 1586 mcr = edge_port->shadowMCR;
1587 if (set & TIOCM_RTS) 1587 if (set & TIOCM_RTS)
@@ -1612,7 +1612,7 @@ static int edge_tiocmget(struct usb_serial_port *port, struct file *file)
1612 unsigned int msr; 1612 unsigned int msr;
1613 unsigned int mcr; 1613 unsigned int mcr;
1614 1614
1615 dbg("%s - port %d", __FUNCTION__, port->number); 1615 dbg("%s - port %d", __func__, port->number);
1616 1616
1617 msr = edge_port->shadowMSR; 1617 msr = edge_port->shadowMSR;
1618 mcr = edge_port->shadowMCR; 1618 mcr = edge_port->shadowMCR;
@@ -1624,7 +1624,7 @@ static int edge_tiocmget(struct usb_serial_port *port, struct file *file)
1624 | ((msr & EDGEPORT_MSR_DSR) ? TIOCM_DSR: 0); /* 0x100 */ 1624 | ((msr & EDGEPORT_MSR_DSR) ? TIOCM_DSR: 0); /* 0x100 */
1625 1625
1626 1626
1627 dbg("%s -- %x", __FUNCTION__, result); 1627 dbg("%s -- %x", __func__, result);
1628 1628
1629 return result; 1629 return result;
1630} 1630}
@@ -1670,30 +1670,30 @@ static int edge_ioctl (struct usb_serial_port *port, struct file *file, unsigned
1670 struct async_icount cprev; 1670 struct async_icount cprev;
1671 struct serial_icounter_struct icount; 1671 struct serial_icounter_struct icount;
1672 1672
1673 dbg("%s - port %d, cmd = 0x%x", __FUNCTION__, port->number, cmd); 1673 dbg("%s - port %d, cmd = 0x%x", __func__, port->number, cmd);
1674 1674
1675 switch (cmd) { 1675 switch (cmd) {
1676 // return number of bytes available 1676 // return number of bytes available
1677 case TIOCINQ: 1677 case TIOCINQ:
1678 dbg("%s (%d) TIOCINQ", __FUNCTION__, port->number); 1678 dbg("%s (%d) TIOCINQ", __func__, port->number);
1679 return get_number_bytes_avail(edge_port, (unsigned int __user *) arg); 1679 return get_number_bytes_avail(edge_port, (unsigned int __user *) arg);
1680 break; 1680 break;
1681 1681
1682 case TIOCSERGETLSR: 1682 case TIOCSERGETLSR:
1683 dbg("%s (%d) TIOCSERGETLSR", __FUNCTION__, port->number); 1683 dbg("%s (%d) TIOCSERGETLSR", __func__, port->number);
1684 return get_lsr_info(edge_port, (unsigned int __user *) arg); 1684 return get_lsr_info(edge_port, (unsigned int __user *) arg);
1685 return 0; 1685 return 0;
1686 1686
1687 case TIOCGSERIAL: 1687 case TIOCGSERIAL:
1688 dbg("%s (%d) TIOCGSERIAL", __FUNCTION__, port->number); 1688 dbg("%s (%d) TIOCGSERIAL", __func__, port->number);
1689 return get_serial_info(edge_port, (struct serial_struct __user *) arg); 1689 return get_serial_info(edge_port, (struct serial_struct __user *) arg);
1690 1690
1691 case TIOCSSERIAL: 1691 case TIOCSSERIAL:
1692 dbg("%s (%d) TIOCSSERIAL", __FUNCTION__, port->number); 1692 dbg("%s (%d) TIOCSSERIAL", __func__, port->number);
1693 break; 1693 break;
1694 1694
1695 case TIOCMIWAIT: 1695 case TIOCMIWAIT:
1696 dbg("%s (%d) TIOCMIWAIT", __FUNCTION__, port->number); 1696 dbg("%s (%d) TIOCMIWAIT", __func__, port->number);
1697 cprev = edge_port->icount; 1697 cprev = edge_port->icount;
1698 while (1) { 1698 while (1) {
1699 prepare_to_wait(&edge_port->delta_msr_wait, &wait, TASK_INTERRUPTIBLE); 1699 prepare_to_wait(&edge_port->delta_msr_wait, &wait, TASK_INTERRUPTIBLE);
@@ -1732,7 +1732,7 @@ static int edge_ioctl (struct usb_serial_port *port, struct file *file, unsigned
1732 icount.brk = cnow.brk; 1732 icount.brk = cnow.brk;
1733 icount.buf_overrun = cnow.buf_overrun; 1733 icount.buf_overrun = cnow.buf_overrun;
1734 1734
1735 dbg("%s (%d) TIOCGICOUNT RX=%d, TX=%d", __FUNCTION__, port->number, icount.rx, icount.tx ); 1735 dbg("%s (%d) TIOCGICOUNT RX=%d, TX=%d", __func__, port->number, icount.rx, icount.tx );
1736 if (copy_to_user((void __user *)arg, &icount, sizeof(icount))) 1736 if (copy_to_user((void __user *)arg, &icount, sizeof(icount)))
1737 return -EFAULT; 1737 return -EFAULT;
1738 return 0; 1738 return 0;
@@ -1758,7 +1758,7 @@ static void edge_break (struct usb_serial_port *port, int break_state)
1758 /* flush and chase */ 1758 /* flush and chase */
1759 edge_port->chaseResponsePending = true; 1759 edge_port->chaseResponsePending = true;
1760 1760
1761 dbg("%s - Sending IOSP_CMD_CHASE_PORT", __FUNCTION__); 1761 dbg("%s - Sending IOSP_CMD_CHASE_PORT", __func__);
1762 status = send_iosp_ext_cmd (edge_port, IOSP_CMD_CHASE_PORT, 0); 1762 status = send_iosp_ext_cmd (edge_port, IOSP_CMD_CHASE_PORT, 0);
1763 if (status == 0) { 1763 if (status == 0) {
1764 // block until chase finished 1764 // block until chase finished
@@ -1772,14 +1772,14 @@ static void edge_break (struct usb_serial_port *port, int break_state)
1772 ((edge_serial->is_epic) && 1772 ((edge_serial->is_epic) &&
1773 (edge_serial->epic_descriptor.Supports.IOSPSetClrBreak))) { 1773 (edge_serial->epic_descriptor.Supports.IOSPSetClrBreak))) {
1774 if (break_state == -1) { 1774 if (break_state == -1) {
1775 dbg("%s - Sending IOSP_CMD_SET_BREAK", __FUNCTION__); 1775 dbg("%s - Sending IOSP_CMD_SET_BREAK", __func__);
1776 status = send_iosp_ext_cmd (edge_port, IOSP_CMD_SET_BREAK, 0); 1776 status = send_iosp_ext_cmd (edge_port, IOSP_CMD_SET_BREAK, 0);
1777 } else { 1777 } else {
1778 dbg("%s - Sending IOSP_CMD_CLEAR_BREAK", __FUNCTION__); 1778 dbg("%s - Sending IOSP_CMD_CLEAR_BREAK", __func__);
1779 status = send_iosp_ext_cmd (edge_port, IOSP_CMD_CLEAR_BREAK, 0); 1779 status = send_iosp_ext_cmd (edge_port, IOSP_CMD_CLEAR_BREAK, 0);
1780 } 1780 }
1781 if (status) { 1781 if (status) {
1782 dbg("%s - error sending break set/clear command.", __FUNCTION__); 1782 dbg("%s - error sending break set/clear command.", __func__);
1783 } 1783 }
1784 } 1784 }
1785 1785
@@ -1799,14 +1799,14 @@ static void process_rcvd_data (struct edgeport_serial *edge_serial, unsigned cha
1799 __u16 lastBufferLength; 1799 __u16 lastBufferLength;
1800 __u16 rxLen; 1800 __u16 rxLen;
1801 1801
1802 dbg("%s", __FUNCTION__); 1802 dbg("%s", __func__);
1803 1803
1804 lastBufferLength = bufferLength + 1; 1804 lastBufferLength = bufferLength + 1;
1805 1805
1806 while (bufferLength > 0) { 1806 while (bufferLength > 0) {
1807 /* failsafe incase we get a message that we don't understand */ 1807 /* failsafe incase we get a message that we don't understand */
1808 if (lastBufferLength == bufferLength) { 1808 if (lastBufferLength == bufferLength) {
1809 dbg("%s - stuck in loop, exiting it.", __FUNCTION__); 1809 dbg("%s - stuck in loop, exiting it.", __func__);
1810 break; 1810 break;
1811 } 1811 }
1812 lastBufferLength = bufferLength; 1812 lastBufferLength = bufferLength;
@@ -1828,7 +1828,7 @@ static void process_rcvd_data (struct edgeport_serial *edge_serial, unsigned cha
1828 ++buffer; 1828 ++buffer;
1829 --bufferLength; 1829 --bufferLength;
1830 1830
1831 dbg("%s - Hdr1=%02X Hdr2=%02X", __FUNCTION__, edge_serial->rxHeader1, edge_serial->rxHeader2); 1831 dbg("%s - Hdr1=%02X Hdr2=%02X", __func__, edge_serial->rxHeader1, edge_serial->rxHeader2);
1832 1832
1833 // Process depending on whether this header is 1833 // Process depending on whether this header is
1834 // data or status 1834 // data or status
@@ -1858,7 +1858,7 @@ static void process_rcvd_data (struct edgeport_serial *edge_serial, unsigned cha
1858 edge_serial->rxPort = IOSP_GET_HDR_PORT(edge_serial->rxHeader1); 1858 edge_serial->rxPort = IOSP_GET_HDR_PORT(edge_serial->rxHeader1);
1859 edge_serial->rxBytesRemaining = IOSP_GET_HDR_DATA_LEN(edge_serial->rxHeader1, edge_serial->rxHeader2); 1859 edge_serial->rxBytesRemaining = IOSP_GET_HDR_DATA_LEN(edge_serial->rxHeader1, edge_serial->rxHeader2);
1860 1860
1861 dbg("%s - Data for Port %u Len %u", __FUNCTION__, edge_serial->rxPort, edge_serial->rxBytesRemaining); 1861 dbg("%s - Data for Port %u Len %u", __func__, edge_serial->rxPort, edge_serial->rxBytesRemaining);
1862 1862
1863 //ASSERT( DevExt->RxPort < DevExt->NumPorts ); 1863 //ASSERT( DevExt->RxPort < DevExt->NumPorts );
1864 //ASSERT( DevExt->RxBytesRemaining < IOSP_MAX_DATA_LENGTH ); 1864 //ASSERT( DevExt->RxBytesRemaining < IOSP_MAX_DATA_LENGTH );
@@ -1891,7 +1891,7 @@ static void process_rcvd_data (struct edgeport_serial *edge_serial, unsigned cha
1891 if (edge_port->open) { 1891 if (edge_port->open) {
1892 tty = edge_port->port->tty; 1892 tty = edge_port->port->tty;
1893 if (tty) { 1893 if (tty) {
1894 dbg("%s - Sending %d bytes to TTY for port %d", __FUNCTION__, rxLen, edge_serial->rxPort); 1894 dbg("%s - Sending %d bytes to TTY for port %d", __func__, rxLen, edge_serial->rxPort);
1895 edge_tty_recv(&edge_serial->serial->dev->dev, tty, buffer, rxLen); 1895 edge_tty_recv(&edge_serial->serial->dev->dev, tty, buffer, rxLen);
1896 } 1896 }
1897 edge_port->icount.rx += rxLen; 1897 edge_port->icount.rx += rxLen;
@@ -1930,17 +1930,17 @@ static void process_rcvd_status (struct edgeport_serial *edge_serial, __u8 byte2
1930 port = edge_serial->serial->port[edge_serial->rxPort]; 1930 port = edge_serial->serial->port[edge_serial->rxPort];
1931 edge_port = usb_get_serial_port_data(port); 1931 edge_port = usb_get_serial_port_data(port);
1932 if (edge_port == NULL) { 1932 if (edge_port == NULL) {
1933 dev_err(&edge_serial->serial->dev->dev, "%s - edge_port == NULL for port %d\n", __FUNCTION__, edge_serial->rxPort); 1933 dev_err(&edge_serial->serial->dev->dev, "%s - edge_port == NULL for port %d\n", __func__, edge_serial->rxPort);
1934 return; 1934 return;
1935 } 1935 }
1936 1936
1937 dbg("%s - port %d", __FUNCTION__, edge_serial->rxPort); 1937 dbg("%s - port %d", __func__, edge_serial->rxPort);
1938 1938
1939 if (code == IOSP_EXT_STATUS) { 1939 if (code == IOSP_EXT_STATUS) {
1940 switch (byte2) { 1940 switch (byte2) {
1941 case IOSP_EXT_STATUS_CHASE_RSP: 1941 case IOSP_EXT_STATUS_CHASE_RSP:
1942 // we want to do EXT status regardless of port open/closed 1942 // we want to do EXT status regardless of port open/closed
1943 dbg("%s - Port %u EXT CHASE_RSP Data = %02x", __FUNCTION__, edge_serial->rxPort, byte3 ); 1943 dbg("%s - Port %u EXT CHASE_RSP Data = %02x", __func__, edge_serial->rxPort, byte3 );
1944 // Currently, the only EXT_STATUS is Chase, so process here instead of one more call 1944 // Currently, the only EXT_STATUS is Chase, so process here instead of one more call
1945 // to one more subroutine. If/when more EXT_STATUS, there'll be more work to do. 1945 // to one more subroutine. If/when more EXT_STATUS, there'll be more work to do.
1946 // Also, we currently clear flag and close the port regardless of content of above's Byte3. 1946 // Also, we currently clear flag and close the port regardless of content of above's Byte3.
@@ -1951,7 +1951,7 @@ static void process_rcvd_status (struct edgeport_serial *edge_serial, __u8 byte2
1951 return; 1951 return;
1952 1952
1953 case IOSP_EXT_STATUS_RX_CHECK_RSP: 1953 case IOSP_EXT_STATUS_RX_CHECK_RSP:
1954 dbg("%s ========== Port %u CHECK_RSP Sequence = %02x =============\n", __FUNCTION__, edge_serial->rxPort, byte3 ); 1954 dbg("%s ========== Port %u CHECK_RSP Sequence = %02x =============\n", __func__, edge_serial->rxPort, byte3 );
1955 //Port->RxCheckRsp = true; 1955 //Port->RxCheckRsp = true;
1956 return; 1956 return;
1957 } 1957 }
@@ -1960,7 +1960,7 @@ static void process_rcvd_status (struct edgeport_serial *edge_serial, __u8 byte2
1960 if (code == IOSP_STATUS_OPEN_RSP) { 1960 if (code == IOSP_STATUS_OPEN_RSP) {
1961 edge_port->txCredits = GET_TX_BUFFER_SIZE(byte3); 1961 edge_port->txCredits = GET_TX_BUFFER_SIZE(byte3);
1962 edge_port->maxTxCredits = edge_port->txCredits; 1962 edge_port->maxTxCredits = edge_port->txCredits;
1963 dbg("%s - Port %u Open Response Inital MSR = %02x TxBufferSize = %d", __FUNCTION__, edge_serial->rxPort, byte2, edge_port->txCredits); 1963 dbg("%s - Port %u Open Response Inital MSR = %02x TxBufferSize = %d", __func__, edge_serial->rxPort, byte2, edge_port->txCredits);
1964 handle_new_msr (edge_port, byte2); 1964 handle_new_msr (edge_port, byte2);
1965 1965
1966 /* send the current line settings to the port so we are in sync with any further termios calls */ 1966 /* send the current line settings to the port so we are in sync with any further termios calls */
@@ -1984,23 +1984,23 @@ static void process_rcvd_status (struct edgeport_serial *edge_serial, __u8 byte2
1984 switch (code) { 1984 switch (code) {
1985 // Not currently sent by Edgeport 1985 // Not currently sent by Edgeport
1986 case IOSP_STATUS_LSR: 1986 case IOSP_STATUS_LSR:
1987 dbg("%s - Port %u LSR Status = %02x", __FUNCTION__, edge_serial->rxPort, byte2); 1987 dbg("%s - Port %u LSR Status = %02x", __func__, edge_serial->rxPort, byte2);
1988 handle_new_lsr(edge_port, false, byte2, 0); 1988 handle_new_lsr(edge_port, false, byte2, 0);
1989 break; 1989 break;
1990 1990
1991 case IOSP_STATUS_LSR_DATA: 1991 case IOSP_STATUS_LSR_DATA:
1992 dbg("%s - Port %u LSR Status = %02x, Data = %02x", __FUNCTION__, edge_serial->rxPort, byte2, byte3); 1992 dbg("%s - Port %u LSR Status = %02x, Data = %02x", __func__, edge_serial->rxPort, byte2, byte3);
1993 // byte2 is LSR Register 1993 // byte2 is LSR Register
1994 // byte3 is broken data byte 1994 // byte3 is broken data byte
1995 handle_new_lsr(edge_port, true, byte2, byte3); 1995 handle_new_lsr(edge_port, true, byte2, byte3);
1996 break; 1996 break;
1997 // 1997 //
1998 // case IOSP_EXT_4_STATUS: 1998 // case IOSP_EXT_4_STATUS:
1999 // dbg("%s - Port %u LSR Status = %02x Data = %02x", __FUNCTION__, edge_serial->rxPort, byte2, byte3); 1999 // dbg("%s - Port %u LSR Status = %02x Data = %02x", __func__, edge_serial->rxPort, byte2, byte3);
2000 // break; 2000 // break;
2001 // 2001 //
2002 case IOSP_STATUS_MSR: 2002 case IOSP_STATUS_MSR:
2003 dbg("%s - Port %u MSR Status = %02x", __FUNCTION__, edge_serial->rxPort, byte2); 2003 dbg("%s - Port %u MSR Status = %02x", __func__, edge_serial->rxPort, byte2);
2004 2004
2005 // Process this new modem status and generate appropriate 2005 // Process this new modem status and generate appropriate
2006 // events, etc, based on the new status. This routine 2006 // events, etc, based on the new status. This routine
@@ -2009,7 +2009,7 @@ static void process_rcvd_status (struct edgeport_serial *edge_serial, __u8 byte2
2009 break; 2009 break;
2010 2010
2011 default: 2011 default:
2012 dbg("%s - Unrecognized IOSP status code %u\n", __FUNCTION__, code); 2012 dbg("%s - Unrecognized IOSP status code %u\n", __func__, code);
2013 break; 2013 break;
2014 } 2014 }
2015 2015
@@ -2029,7 +2029,7 @@ static void edge_tty_recv(struct device *dev, struct tty_struct *tty, unsigned c
2029 cnt = tty_buffer_request_room(tty, length); 2029 cnt = tty_buffer_request_room(tty, length);
2030 if (cnt < length) { 2030 if (cnt < length) {
2031 dev_err(dev, "%s - dropping data, %d bytes lost\n", 2031 dev_err(dev, "%s - dropping data, %d bytes lost\n",
2032 __FUNCTION__, length - cnt); 2032 __func__, length - cnt);
2033 if(cnt == 0) 2033 if(cnt == 0)
2034 break; 2034 break;
2035 } 2035 }
@@ -2050,7 +2050,7 @@ static void handle_new_msr(struct edgeport_port *edge_port, __u8 newMsr)
2050{ 2050{
2051 struct async_icount *icount; 2051 struct async_icount *icount;
2052 2052
2053 dbg("%s %02x", __FUNCTION__, newMsr); 2053 dbg("%s %02x", __func__, newMsr);
2054 2054
2055 if (newMsr & (EDGEPORT_MSR_DELTA_CTS | EDGEPORT_MSR_DELTA_DSR | EDGEPORT_MSR_DELTA_RI | EDGEPORT_MSR_DELTA_CD)) { 2055 if (newMsr & (EDGEPORT_MSR_DELTA_CTS | EDGEPORT_MSR_DELTA_DSR | EDGEPORT_MSR_DELTA_RI | EDGEPORT_MSR_DELTA_CD)) {
2056 icount = &edge_port->icount; 2056 icount = &edge_port->icount;
@@ -2087,7 +2087,7 @@ static void handle_new_lsr(struct edgeport_port *edge_port, __u8 lsrData, __u8 l
2087 __u8 newLsr = (__u8)(lsr & (__u8)(LSR_OVER_ERR | LSR_PAR_ERR | LSR_FRM_ERR | LSR_BREAK)); 2087 __u8 newLsr = (__u8)(lsr & (__u8)(LSR_OVER_ERR | LSR_PAR_ERR | LSR_FRM_ERR | LSR_BREAK));
2088 struct async_icount *icount; 2088 struct async_icount *icount;
2089 2089
2090 dbg("%s - %02x", __FUNCTION__, newLsr); 2090 dbg("%s - %02x", __func__, newLsr);
2091 2091
2092 edge_port->shadowLSR = lsr; 2092 edge_port->shadowLSR = lsr;
2093 2093
@@ -2136,11 +2136,11 @@ static int sram_write (struct usb_serial *serial, __u16 extAddr, __u16 addr, __u
2136 __u16 current_length; 2136 __u16 current_length;
2137 unsigned char *transfer_buffer; 2137 unsigned char *transfer_buffer;
2138 2138
2139 dbg("%s - %x, %x, %d", __FUNCTION__, extAddr, addr, length); 2139 dbg("%s - %x, %x, %d", __func__, extAddr, addr, length);
2140 2140
2141 transfer_buffer = kmalloc (64, GFP_KERNEL); 2141 transfer_buffer = kmalloc (64, GFP_KERNEL);
2142 if (!transfer_buffer) { 2142 if (!transfer_buffer) {
2143 dev_err(&serial->dev->dev, "%s - kmalloc(%d) failed.\n", __FUNCTION__, 64); 2143 dev_err(&serial->dev->dev, "%s - kmalloc(%d) failed.\n", __func__, 64);
2144 return -ENOMEM; 2144 return -ENOMEM;
2145 } 2145 }
2146 2146
@@ -2152,7 +2152,7 @@ static int sram_write (struct usb_serial *serial, __u16 extAddr, __u16 addr, __u
2152 } else { 2152 } else {
2153 current_length = length; 2153 current_length = length;
2154 } 2154 }
2155// dbg("%s - writing %x, %x, %d", __FUNCTION__, extAddr, addr, current_length); 2155// dbg("%s - writing %x, %x, %d", __func__, extAddr, addr, current_length);
2156 memcpy (transfer_buffer, data, current_length); 2156 memcpy (transfer_buffer, data, current_length);
2157 result = usb_control_msg (serial->dev, usb_sndctrlpipe(serial->dev, 0), USB_REQUEST_ION_WRITE_RAM, 2157 result = usb_control_msg (serial->dev, usb_sndctrlpipe(serial->dev, 0), USB_REQUEST_ION_WRITE_RAM,
2158 0x40, addr, extAddr, transfer_buffer, current_length, 300); 2158 0x40, addr, extAddr, transfer_buffer, current_length, 300);
@@ -2181,11 +2181,11 @@ static int rom_write (struct usb_serial *serial, __u16 extAddr, __u16 addr, __u1
2181 __u16 current_length; 2181 __u16 current_length;
2182 unsigned char *transfer_buffer; 2182 unsigned char *transfer_buffer;
2183 2183
2184// dbg("%s - %x, %x, %d", __FUNCTION__, extAddr, addr, length); 2184// dbg("%s - %x, %x, %d", __func__, extAddr, addr, length);
2185 2185
2186 transfer_buffer = kmalloc (64, GFP_KERNEL); 2186 transfer_buffer = kmalloc (64, GFP_KERNEL);
2187 if (!transfer_buffer) { 2187 if (!transfer_buffer) {
2188 dev_err(&serial->dev->dev, "%s - kmalloc(%d) failed.\n", __FUNCTION__, 64); 2188 dev_err(&serial->dev->dev, "%s - kmalloc(%d) failed.\n", __func__, 64);
2189 return -ENOMEM; 2189 return -ENOMEM;
2190 } 2190 }
2191 2191
@@ -2197,7 +2197,7 @@ static int rom_write (struct usb_serial *serial, __u16 extAddr, __u16 addr, __u1
2197 } else { 2197 } else {
2198 current_length = length; 2198 current_length = length;
2199 } 2199 }
2200// dbg("%s - writing %x, %x, %d", __FUNCTION__, extAddr, addr, current_length); 2200// dbg("%s - writing %x, %x, %d", __func__, extAddr, addr, current_length);
2201 memcpy (transfer_buffer, data, current_length); 2201 memcpy (transfer_buffer, data, current_length);
2202 result = usb_control_msg (serial->dev, usb_sndctrlpipe(serial->dev, 0), USB_REQUEST_ION_WRITE_ROM, 2202 result = usb_control_msg (serial->dev, usb_sndctrlpipe(serial->dev, 0), USB_REQUEST_ION_WRITE_ROM,
2203 0x40, addr, extAddr, transfer_buffer, current_length, 300); 2203 0x40, addr, extAddr, transfer_buffer, current_length, 300);
@@ -2226,11 +2226,11 @@ static int rom_read (struct usb_serial *serial, __u16 extAddr, __u16 addr, __u16
2226 __u16 current_length; 2226 __u16 current_length;
2227 unsigned char *transfer_buffer; 2227 unsigned char *transfer_buffer;
2228 2228
2229 dbg("%s - %x, %x, %d", __FUNCTION__, extAddr, addr, length); 2229 dbg("%s - %x, %x, %d", __func__, extAddr, addr, length);
2230 2230
2231 transfer_buffer = kmalloc (64, GFP_KERNEL); 2231 transfer_buffer = kmalloc (64, GFP_KERNEL);
2232 if (!transfer_buffer) { 2232 if (!transfer_buffer) {
2233 dev_err(&serial->dev->dev, "%s - kmalloc(%d) failed.\n", __FUNCTION__, 64); 2233 dev_err(&serial->dev->dev, "%s - kmalloc(%d) failed.\n", __func__, 64);
2234 return -ENOMEM; 2234 return -ENOMEM;
2235 } 2235 }
2236 2236
@@ -2242,7 +2242,7 @@ static int rom_read (struct usb_serial *serial, __u16 extAddr, __u16 addr, __u16
2242 } else { 2242 } else {
2243 current_length = length; 2243 current_length = length;
2244 } 2244 }
2245// dbg("%s - %x, %x, %d", __FUNCTION__, extAddr, addr, current_length); 2245// dbg("%s - %x, %x, %d", __func__, extAddr, addr, current_length);
2246 result = usb_control_msg (serial->dev, usb_rcvctrlpipe(serial->dev, 0), USB_REQUEST_ION_READ_ROM, 2246 result = usb_control_msg (serial->dev, usb_rcvctrlpipe(serial->dev, 0), USB_REQUEST_ION_READ_ROM,
2247 0xC0, addr, extAddr, transfer_buffer, current_length, 300); 2247 0xC0, addr, extAddr, transfer_buffer, current_length, 300);
2248 if (result < 0) 2248 if (result < 0)
@@ -2269,11 +2269,11 @@ static int send_iosp_ext_cmd (struct edgeport_port *edge_port, __u8 command, __u
2269 int length = 0; 2269 int length = 0;
2270 int status = 0; 2270 int status = 0;
2271 2271
2272 dbg("%s - %d, %d", __FUNCTION__, command, param); 2272 dbg("%s - %d, %d", __func__, command, param);
2273 2273
2274 buffer = kmalloc (10, GFP_ATOMIC); 2274 buffer = kmalloc (10, GFP_ATOMIC);
2275 if (!buffer) { 2275 if (!buffer) {
2276 dev_err(&edge_port->port->dev, "%s - kmalloc(%d) failed.\n", __FUNCTION__, 10); 2276 dev_err(&edge_port->port->dev, "%s - kmalloc(%d) failed.\n", __func__, 10);
2277 return -ENOMEM; 2277 return -ENOMEM;
2278 } 2278 }
2279 2279
@@ -2304,7 +2304,7 @@ static int write_cmd_usb (struct edgeport_port *edge_port, unsigned char *buffer
2304 struct urb *urb; 2304 struct urb *urb;
2305 int timeout; 2305 int timeout;
2306 2306
2307 usb_serial_debug_data(debug, &edge_port->port->dev, __FUNCTION__, length, buffer); 2307 usb_serial_debug_data(debug, &edge_port->port->dev, __func__, length, buffer);
2308 2308
2309 /* Allocate our next urb */ 2309 /* Allocate our next urb */
2310 urb = usb_alloc_urb (0, GFP_ATOMIC); 2310 urb = usb_alloc_urb (0, GFP_ATOMIC);
@@ -2312,7 +2312,7 @@ static int write_cmd_usb (struct edgeport_port *edge_port, unsigned char *buffer
2312 return -ENOMEM; 2312 return -ENOMEM;
2313 2313
2314 atomic_inc(&CmdUrbs); 2314 atomic_inc(&CmdUrbs);
2315 dbg("%s - ALLOCATE URB %p (outstanding %d)", __FUNCTION__, urb, atomic_read(&CmdUrbs)); 2315 dbg("%s - ALLOCATE URB %p (outstanding %d)", __func__, urb, atomic_read(&CmdUrbs));
2316 2316
2317 usb_fill_bulk_urb (urb, edge_serial->serial->dev, 2317 usb_fill_bulk_urb (urb, edge_serial->serial->dev,
2318 usb_sndbulkpipe(edge_serial->serial->dev, edge_serial->bulk_out_endpoint), 2318 usb_sndbulkpipe(edge_serial->serial->dev, edge_serial->bulk_out_endpoint),
@@ -2323,7 +2323,7 @@ static int write_cmd_usb (struct edgeport_port *edge_port, unsigned char *buffer
2323 2323
2324 if (status) { 2324 if (status) {
2325 /* something went wrong */ 2325 /* something went wrong */
2326 dev_err(&edge_port->port->dev, "%s - usb_submit_urb(write command) failed, status = %d\n", __FUNCTION__, status); 2326 dev_err(&edge_port->port->dev, "%s - usb_submit_urb(write command) failed, status = %d\n", __func__, status);
2327 usb_kill_urb(urb); 2327 usb_kill_urb(urb);
2328 usb_free_urb(urb); 2328 usb_free_urb(urb);
2329 atomic_dec(&CmdUrbs); 2329 atomic_dec(&CmdUrbs);
@@ -2337,7 +2337,7 @@ static int write_cmd_usb (struct edgeport_port *edge_port, unsigned char *buffer
2337 2337
2338 if (edge_port->commandPending) { 2338 if (edge_port->commandPending) {
2339 /* command timed out */ 2339 /* command timed out */
2340 dbg("%s - command timed out", __FUNCTION__); 2340 dbg("%s - command timed out", __func__);
2341 status = -EINVAL; 2341 status = -EINVAL;
2342 } 2342 }
2343#endif 2343#endif
@@ -2367,18 +2367,18 @@ static int send_cmd_write_baud_rate (struct edgeport_port *edge_port, int baudRa
2367 return 0; 2367 return 0;
2368 } 2368 }
2369 2369
2370 dbg("%s - port = %d, baud = %d", __FUNCTION__, edge_port->port->number, baudRate); 2370 dbg("%s - port = %d, baud = %d", __func__, edge_port->port->number, baudRate);
2371 2371
2372 status = calc_baud_rate_divisor (baudRate, &divisor); 2372 status = calc_baud_rate_divisor (baudRate, &divisor);
2373 if (status) { 2373 if (status) {
2374 dev_err(&edge_port->port->dev, "%s - bad baud rate\n", __FUNCTION__); 2374 dev_err(&edge_port->port->dev, "%s - bad baud rate\n", __func__);
2375 return status; 2375 return status;
2376 } 2376 }
2377 2377
2378 // Alloc memory for the string of commands. 2378 // Alloc memory for the string of commands.
2379 cmdBuffer = kmalloc (0x100, GFP_ATOMIC); 2379 cmdBuffer = kmalloc (0x100, GFP_ATOMIC);
2380 if (!cmdBuffer) { 2380 if (!cmdBuffer) {
2381 dev_err(&edge_port->port->dev, "%s - kmalloc(%d) failed.\n", __FUNCTION__, 0x100); 2381 dev_err(&edge_port->port->dev, "%s - kmalloc(%d) failed.\n", __func__, 0x100);
2382 return -ENOMEM; 2382 return -ENOMEM;
2383 } 2383 }
2384 currCmd = cmdBuffer; 2384 currCmd = cmdBuffer;
@@ -2414,7 +2414,7 @@ static int calc_baud_rate_divisor (int baudrate, int *divisor)
2414 __u16 custom; 2414 __u16 custom;
2415 2415
2416 2416
2417 dbg("%s - %d", __FUNCTION__, baudrate); 2417 dbg("%s - %d", __func__, baudrate);
2418 2418
2419 for (i = 0; i < ARRAY_SIZE(divisor_table); i++) { 2419 for (i = 0; i < ARRAY_SIZE(divisor_table); i++) {
2420 if ( divisor_table[i].BaudRate == baudrate ) { 2420 if ( divisor_table[i].BaudRate == baudrate ) {
@@ -2432,7 +2432,7 @@ static int calc_baud_rate_divisor (int baudrate, int *divisor)
2432 2432
2433 *divisor = custom; 2433 *divisor = custom;
2434 2434
2435 dbg("%s - Baud %d = %d\n", __FUNCTION__, baudrate, custom); 2435 dbg("%s - Baud %d = %d\n", __func__, baudrate, custom);
2436 return 0; 2436 return 0;
2437 } 2437 }
2438 2438
@@ -2452,7 +2452,7 @@ static int send_cmd_write_uart_register (struct edgeport_port *edge_port, __u8 r
2452 unsigned long cmdLen = 0; 2452 unsigned long cmdLen = 0;
2453 int status; 2453 int status;
2454 2454
2455 dbg("%s - write to %s register 0x%02x", (regNum == MCR) ? "MCR" : "LCR", __FUNCTION__, regValue); 2455 dbg("%s - write to %s register 0x%02x", (regNum == MCR) ? "MCR" : "LCR", __func__, regValue);
2456 2456
2457 if (edge_serial->is_epic && 2457 if (edge_serial->is_epic &&
2458 !edge_serial->epic_descriptor.Supports.IOSPWriteMCR && 2458 !edge_serial->epic_descriptor.Supports.IOSPWriteMCR &&
@@ -2513,29 +2513,29 @@ static void change_port_settings (struct edgeport_port *edge_port, struct ktermi
2513 __u8 txFlow; 2513 __u8 txFlow;
2514 int status; 2514 int status;
2515 2515
2516 dbg("%s - port %d", __FUNCTION__, edge_port->port->number); 2516 dbg("%s - port %d", __func__, edge_port->port->number);
2517 2517
2518 if (!edge_port->open && 2518 if (!edge_port->open &&
2519 !edge_port->openPending) { 2519 !edge_port->openPending) {
2520 dbg("%s - port not opened", __FUNCTION__); 2520 dbg("%s - port not opened", __func__);
2521 return; 2521 return;
2522 } 2522 }
2523 2523
2524 tty = edge_port->port->tty; 2524 tty = edge_port->port->tty;
2525 if ((!tty) || 2525 if ((!tty) ||
2526 (!tty->termios)) { 2526 (!tty->termios)) {
2527 dbg("%s - no tty structures", __FUNCTION__); 2527 dbg("%s - no tty structures", __func__);
2528 return; 2528 return;
2529 } 2529 }
2530 2530
2531 cflag = tty->termios->c_cflag; 2531 cflag = tty->termios->c_cflag;
2532 2532
2533 switch (cflag & CSIZE) { 2533 switch (cflag & CSIZE) {
2534 case CS5: lData = LCR_BITS_5; mask = 0x1f; dbg("%s - data bits = 5", __FUNCTION__); break; 2534 case CS5: lData = LCR_BITS_5; mask = 0x1f; dbg("%s - data bits = 5", __func__); break;
2535 case CS6: lData = LCR_BITS_6; mask = 0x3f; dbg("%s - data bits = 6", __FUNCTION__); break; 2535 case CS6: lData = LCR_BITS_6; mask = 0x3f; dbg("%s - data bits = 6", __func__); break;
2536 case CS7: lData = LCR_BITS_7; mask = 0x7f; dbg("%s - data bits = 7", __FUNCTION__); break; 2536 case CS7: lData = LCR_BITS_7; mask = 0x7f; dbg("%s - data bits = 7", __func__); break;
2537 default: 2537 default:
2538 case CS8: lData = LCR_BITS_8; dbg("%s - data bits = 8", __FUNCTION__); break; 2538 case CS8: lData = LCR_BITS_8; dbg("%s - data bits = 8", __func__); break;
2539 } 2539 }
2540 2540
2541 lParity = LCR_PAR_NONE; 2541 lParity = LCR_PAR_NONE;
@@ -2543,28 +2543,28 @@ static void change_port_settings (struct edgeport_port *edge_port, struct ktermi
2543 if (cflag & CMSPAR) { 2543 if (cflag & CMSPAR) {
2544 if (cflag & PARODD) { 2544 if (cflag & PARODD) {
2545 lParity = LCR_PAR_MARK; 2545 lParity = LCR_PAR_MARK;
2546 dbg("%s - parity = mark", __FUNCTION__); 2546 dbg("%s - parity = mark", __func__);
2547 } else { 2547 } else {
2548 lParity = LCR_PAR_SPACE; 2548 lParity = LCR_PAR_SPACE;
2549 dbg("%s - parity = space", __FUNCTION__); 2549 dbg("%s - parity = space", __func__);
2550 } 2550 }
2551 } else if (cflag & PARODD) { 2551 } else if (cflag & PARODD) {
2552 lParity = LCR_PAR_ODD; 2552 lParity = LCR_PAR_ODD;
2553 dbg("%s - parity = odd", __FUNCTION__); 2553 dbg("%s - parity = odd", __func__);
2554 } else { 2554 } else {
2555 lParity = LCR_PAR_EVEN; 2555 lParity = LCR_PAR_EVEN;
2556 dbg("%s - parity = even", __FUNCTION__); 2556 dbg("%s - parity = even", __func__);
2557 } 2557 }
2558 } else { 2558 } else {
2559 dbg("%s - parity = none", __FUNCTION__); 2559 dbg("%s - parity = none", __func__);
2560 } 2560 }
2561 2561
2562 if (cflag & CSTOPB) { 2562 if (cflag & CSTOPB) {
2563 lStop = LCR_STOP_2; 2563 lStop = LCR_STOP_2;
2564 dbg("%s - stop bits = 2", __FUNCTION__); 2564 dbg("%s - stop bits = 2", __func__);
2565 } else { 2565 } else {
2566 lStop = LCR_STOP_1; 2566 lStop = LCR_STOP_1;
2567 dbg("%s - stop bits = 1", __FUNCTION__); 2567 dbg("%s - stop bits = 1", __func__);
2568 } 2568 }
2569 2569
2570 /* figure out the flow control settings */ 2570 /* figure out the flow control settings */
@@ -2572,9 +2572,9 @@ static void change_port_settings (struct edgeport_port *edge_port, struct ktermi
2572 if (cflag & CRTSCTS) { 2572 if (cflag & CRTSCTS) {
2573 rxFlow |= IOSP_RX_FLOW_RTS; 2573 rxFlow |= IOSP_RX_FLOW_RTS;
2574 txFlow |= IOSP_TX_FLOW_CTS; 2574 txFlow |= IOSP_TX_FLOW_CTS;
2575 dbg("%s - RTS/CTS is enabled", __FUNCTION__); 2575 dbg("%s - RTS/CTS is enabled", __func__);
2576 } else { 2576 } else {
2577 dbg("%s - RTS/CTS is disabled", __FUNCTION__); 2577 dbg("%s - RTS/CTS is disabled", __func__);
2578 } 2578 }
2579 2579
2580 /* if we are implementing XON/XOFF, set the start and stop character in the device */ 2580 /* if we are implementing XON/XOFF, set the start and stop character in the device */
@@ -2592,17 +2592,17 @@ static void change_port_settings (struct edgeport_port *edge_port, struct ktermi
2592 /* if we are implementing INBOUND XON/XOFF */ 2592 /* if we are implementing INBOUND XON/XOFF */
2593 if (I_IXOFF(tty)) { 2593 if (I_IXOFF(tty)) {
2594 rxFlow |= IOSP_RX_FLOW_XON_XOFF; 2594 rxFlow |= IOSP_RX_FLOW_XON_XOFF;
2595 dbg("%s - INBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x", __FUNCTION__, start_char, stop_char); 2595 dbg("%s - INBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x", __func__, start_char, stop_char);
2596 } else { 2596 } else {
2597 dbg("%s - INBOUND XON/XOFF is disabled", __FUNCTION__); 2597 dbg("%s - INBOUND XON/XOFF is disabled", __func__);
2598 } 2598 }
2599 2599
2600 /* if we are implementing OUTBOUND XON/XOFF */ 2600 /* if we are implementing OUTBOUND XON/XOFF */
2601 if (I_IXON(tty)) { 2601 if (I_IXON(tty)) {
2602 txFlow |= IOSP_TX_FLOW_XON_XOFF; 2602 txFlow |= IOSP_TX_FLOW_XON_XOFF;
2603 dbg("%s - OUTBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x", __FUNCTION__, start_char, stop_char); 2603 dbg("%s - OUTBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x", __func__, start_char, stop_char);
2604 } else { 2604 } else {
2605 dbg("%s - OUTBOUND XON/XOFF is disabled", __FUNCTION__); 2605 dbg("%s - OUTBOUND XON/XOFF is disabled", __func__);
2606 } 2606 }
2607 } 2607 }
2608 2608
@@ -2645,7 +2645,7 @@ static void change_port_settings (struct edgeport_port *edge_port, struct ktermi
2645 baud = 9600; 2645 baud = 9600;
2646 } 2646 }
2647 2647
2648 dbg("%s - baud rate = %d", __FUNCTION__, baud); 2648 dbg("%s - baud rate = %d", __func__, baud);
2649 status = send_cmd_write_baud_rate (edge_port, baud); 2649 status = send_cmd_write_baud_rate (edge_port, baud);
2650 if (status == -1) { 2650 if (status == -1) {
2651 /* Speed change was not possible - put back the old speed */ 2651 /* Speed change was not possible - put back the old speed */
@@ -2843,7 +2843,7 @@ static int edge_startup (struct usb_serial *serial)
2843 /* create our private serial structure */ 2843 /* create our private serial structure */
2844 edge_serial = kzalloc(sizeof(struct edgeport_serial), GFP_KERNEL); 2844 edge_serial = kzalloc(sizeof(struct edgeport_serial), GFP_KERNEL);
2845 if (edge_serial == NULL) { 2845 if (edge_serial == NULL) {
2846 dev_err(&serial->dev->dev, "%s - Out of memory\n", __FUNCTION__); 2846 dev_err(&serial->dev->dev, "%s - Out of memory\n", __func__);
2847 return -ENOMEM; 2847 return -ENOMEM;
2848 } 2848 }
2849 spin_lock_init(&edge_serial->es_lock); 2849 spin_lock_init(&edge_serial->es_lock);
@@ -2885,19 +2885,19 @@ static int edge_startup (struct usb_serial *serial)
2885 serial->num_ports); 2885 serial->num_ports);
2886 } 2886 }
2887 2887
2888 dbg("%s - time 1 %ld", __FUNCTION__, jiffies); 2888 dbg("%s - time 1 %ld", __func__, jiffies);
2889 2889
2890 /* If not an EPiC device */ 2890 /* If not an EPiC device */
2891 if (!edge_serial->is_epic) { 2891 if (!edge_serial->is_epic) {
2892 /* now load the application firmware into this device */ 2892 /* now load the application firmware into this device */
2893 load_application_firmware (edge_serial); 2893 load_application_firmware (edge_serial);
2894 2894
2895 dbg("%s - time 2 %ld", __FUNCTION__, jiffies); 2895 dbg("%s - time 2 %ld", __func__, jiffies);
2896 2896
2897 /* Check current Edgeport EEPROM and update if necessary */ 2897 /* Check current Edgeport EEPROM and update if necessary */
2898 update_edgeport_E2PROM (edge_serial); 2898 update_edgeport_E2PROM (edge_serial);
2899 2899
2900 dbg("%s - time 3 %ld", __FUNCTION__, jiffies); 2900 dbg("%s - time 3 %ld", __func__, jiffies);
2901 2901
2902 /* set the configuration to use #1 */ 2902 /* set the configuration to use #1 */
2903// dbg("set_configuration 1"); 2903// dbg("set_configuration 1");
@@ -2911,7 +2911,7 @@ static int edge_startup (struct usb_serial *serial)
2911 for (i = 0; i < serial->num_ports; ++i) { 2911 for (i = 0; i < serial->num_ports; ++i) {
2912 edge_port = kmalloc (sizeof(struct edgeport_port), GFP_KERNEL); 2912 edge_port = kmalloc (sizeof(struct edgeport_port), GFP_KERNEL);
2913 if (edge_port == NULL) { 2913 if (edge_port == NULL) {
2914 dev_err(&serial->dev->dev, "%s - Out of memory\n", __FUNCTION__); 2914 dev_err(&serial->dev->dev, "%s - Out of memory\n", __func__);
2915 for (j = 0; j < i; ++j) { 2915 for (j = 0; j < i; ++j) {
2916 kfree (usb_get_serial_port_data(serial->port[j])); 2916 kfree (usb_get_serial_port_data(serial->port[j]));
2917 usb_set_serial_port_data(serial->port[j], NULL); 2917 usb_set_serial_port_data(serial->port[j], NULL);
@@ -3017,7 +3017,7 @@ static int edge_startup (struct usb_serial *serial)
3017 * continue as long as the edgeport is connected */ 3017 * continue as long as the edgeport is connected */
3018 response = usb_submit_urb(edge_serial->interrupt_read_urb, GFP_KERNEL); 3018 response = usb_submit_urb(edge_serial->interrupt_read_urb, GFP_KERNEL);
3019 if (response) 3019 if (response)
3020 err("%s - Error %d submitting control urb", __FUNCTION__, response); 3020 err("%s - Error %d submitting control urb", __func__, response);
3021 } 3021 }
3022 return response; 3022 return response;
3023} 3023}
@@ -3032,7 +3032,7 @@ static void edge_shutdown (struct usb_serial *serial)
3032 struct edgeport_serial *edge_serial = usb_get_serial_data(serial); 3032 struct edgeport_serial *edge_serial = usb_get_serial_data(serial);
3033 int i; 3033 int i;
3034 3034
3035 dbg("%s", __FUNCTION__); 3035 dbg("%s", __func__);
3036 3036
3037 /* stop reads and writes on all ports */ 3037 /* stop reads and writes on all ports */
3038 for (i=0; i < serial->num_ports; ++i) { 3038 for (i=0; i < serial->num_ports; ++i) {
diff --git a/drivers/usb/serial/io_tables.h b/drivers/usb/serial/io_tables.h
index 6d300877254..2ec85893f27 100644
--- a/drivers/usb/serial/io_tables.h
+++ b/drivers/usb/serial/io_tables.h
@@ -111,9 +111,6 @@ static struct usb_serial_driver edgeport_2port_device = {
111 .description = "Edgeport 2 port adapter", 111 .description = "Edgeport 2 port adapter",
112 .usb_driver = &io_driver, 112 .usb_driver = &io_driver,
113 .id_table = edgeport_2port_id_table, 113 .id_table = edgeport_2port_id_table,
114 .num_interrupt_in = 1,
115 .num_bulk_in = 1,
116 .num_bulk_out = 1,
117 .num_ports = 2, 114 .num_ports = 2,
118 .open = edge_open, 115 .open = edge_open,
119 .close = edge_close, 116 .close = edge_close,
@@ -142,9 +139,6 @@ static struct usb_serial_driver edgeport_4port_device = {
142 .description = "Edgeport 4 port adapter", 139 .description = "Edgeport 4 port adapter",
143 .usb_driver = &io_driver, 140 .usb_driver = &io_driver,
144 .id_table = edgeport_4port_id_table, 141 .id_table = edgeport_4port_id_table,
145 .num_interrupt_in = 1,
146 .num_bulk_in = 1,
147 .num_bulk_out = 1,
148 .num_ports = 4, 142 .num_ports = 4,
149 .open = edge_open, 143 .open = edge_open,
150 .close = edge_close, 144 .close = edge_close,
@@ -173,9 +167,6 @@ static struct usb_serial_driver edgeport_8port_device = {
173 .description = "Edgeport 8 port adapter", 167 .description = "Edgeport 8 port adapter",
174 .usb_driver = &io_driver, 168 .usb_driver = &io_driver,
175 .id_table = edgeport_8port_id_table, 169 .id_table = edgeport_8port_id_table,
176 .num_interrupt_in = 1,
177 .num_bulk_in = 1,
178 .num_bulk_out = 1,
179 .num_ports = 8, 170 .num_ports = 8,
180 .open = edge_open, 171 .open = edge_open,
181 .close = edge_close, 172 .close = edge_close,
@@ -203,9 +194,6 @@ static struct usb_serial_driver epic_device = {
203 }, 194 },
204 .description = "EPiC device", 195 .description = "EPiC device",
205 .id_table = Epic_port_id_table, 196 .id_table = Epic_port_id_table,
206 .num_interrupt_in = 1,
207 .num_bulk_in = 1,
208 .num_bulk_out = 1,
209 .num_ports = 1, 197 .num_ports = 1,
210 .open = edge_open, 198 .open = edge_open,
211 .close = edge_close, 199 .close = edge_close,
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
index e5ea5ef6335..05e4fa73073 100644
--- a/drivers/usb/serial/io_ti.c
+++ b/drivers/usb/serial/io_ti.c
@@ -290,7 +290,7 @@ static int TIReadVendorRequestSync (struct usb_device *dev,
290 return status; 290 return status;
291 if (status != size) { 291 if (status != size) {
292 dbg ("%s - wanted to write %d, but only wrote %d", 292 dbg ("%s - wanted to write %d, but only wrote %d",
293 __FUNCTION__, size, status); 293 __func__, size, status);
294 return -ECOMM; 294 return -ECOMM;
295 } 295 }
296 return 0; 296 return 0;
@@ -320,7 +320,7 @@ static int TISendVendorRequestSync (struct usb_device *dev,
320 return status; 320 return status;
321 if (status != size) { 321 if (status != size) {
322 dbg ("%s - wanted to write %d, but only wrote %d", 322 dbg ("%s - wanted to write %d, but only wrote %d",
323 __FUNCTION__, size, status); 323 __func__, size, status);
324 return -ECOMM; 324 return -ECOMM;
325 } 325 }
326 return 0; 326 return 0;
@@ -344,7 +344,7 @@ static int TIPurgeDataSync (struct usb_serial_port *port, __u16 mask)
344{ 344{
345 int port_number = port->number - port->serial->minor; 345 int port_number = port->number - port->serial->minor;
346 346
347 dbg ("%s - port %d, mask %x", __FUNCTION__, port_number, mask); 347 dbg ("%s - port %d, mask %x", __func__, port_number, mask);
348 348
349 return TIWriteCommandSync (port->serial->dev, 349 return TIWriteCommandSync (port->serial->dev,
350 UMPC_PURGE_PORT, 350 UMPC_PURGE_PORT,
@@ -369,7 +369,7 @@ static int TIReadDownloadMemory(struct usb_device *dev, int start_address,
369 __u8 read_length; 369 __u8 read_length;
370 __be16 be_start_address; 370 __be16 be_start_address;
371 371
372 dbg ("%s - @ %x for %d", __FUNCTION__, start_address, length); 372 dbg ("%s - @ %x for %d", __func__, start_address, length);
373 373
374 /* Read in blocks of 64 bytes 374 /* Read in blocks of 64 bytes
375 * (TI firmware can't handle more than 64 byte reads) 375 * (TI firmware can't handle more than 64 byte reads)
@@ -381,7 +381,7 @@ static int TIReadDownloadMemory(struct usb_device *dev, int start_address,
381 read_length = (__u8)length; 381 read_length = (__u8)length;
382 382
383 if (read_length > 1) { 383 if (read_length > 1) {
384 dbg ("%s - @ %x for %d", __FUNCTION__, 384 dbg ("%s - @ %x for %d", __func__,
385 start_address, read_length); 385 start_address, read_length);
386 } 386 }
387 be_start_address = cpu_to_be16 (start_address); 387 be_start_address = cpu_to_be16 (start_address);
@@ -393,12 +393,12 @@ static int TIReadDownloadMemory(struct usb_device *dev, int start_address,
393 read_length); // TransferBufferLength 393 read_length); // TransferBufferLength
394 394
395 if (status) { 395 if (status) {
396 dbg ("%s - ERROR %x", __FUNCTION__, status); 396 dbg ("%s - ERROR %x", __func__, status);
397 return status; 397 return status;
398 } 398 }
399 399
400 if (read_length > 1) { 400 if (read_length > 1) {
401 usb_serial_debug_data(debug, &dev->dev, __FUNCTION__, 401 usb_serial_debug_data(debug, &dev->dev, __func__,
402 read_length, buffer); 402 read_length, buffer);
403 } 403 }
404 404
@@ -434,13 +434,13 @@ static int TIReadBootMemory (struct edgeport_serial *serial, int start_address,
434 &buffer[i], // TransferBuffer 434 &buffer[i], // TransferBuffer
435 0x01); // TransferBufferLength 435 0x01); // TransferBufferLength
436 if (status) { 436 if (status) {
437 dbg ("%s - ERROR %x", __FUNCTION__, status); 437 dbg ("%s - ERROR %x", __func__, status);
438 return status; 438 return status;
439 } 439 }
440 } 440 }
441 441
442 dbg ("%s - start_address = %x, length = %d", __FUNCTION__, start_address, length); 442 dbg ("%s - start_address = %x, length = %d", __func__, start_address, length);
443 usb_serial_debug_data(debug, &serial->serial->dev->dev, __FUNCTION__, length, buffer); 443 usb_serial_debug_data(debug, &serial->serial->dev->dev, __func__, length, buffer);
444 444
445 serial->TiReadI2C = 1; 445 serial->TiReadI2C = 1;
446 446
@@ -472,8 +472,8 @@ static int TIWriteBootMemory (struct edgeport_serial *serial, int start_address,
472 return status; 472 return status;
473 } 473 }
474 474
475 dbg ("%s - start_sddr = %x, length = %d", __FUNCTION__, start_address, length); 475 dbg ("%s - start_sddr = %x, length = %d", __func__, start_address, length);
476 usb_serial_debug_data(debug, &serial->serial->dev->dev, __FUNCTION__, length, buffer); 476 usb_serial_debug_data(debug, &serial->serial->dev->dev, __func__, length, buffer);
477 477
478 return status; 478 return status;
479} 479}
@@ -494,8 +494,8 @@ static int TIWriteDownloadI2C (struct edgeport_serial *serial, int start_address
494 if (write_length > length) 494 if (write_length > length)
495 write_length = length; 495 write_length = length;
496 496
497 dbg ("%s - BytesInFirstPage Addr = %x, length = %d", __FUNCTION__, start_address, write_length); 497 dbg ("%s - BytesInFirstPage Addr = %x, length = %d", __func__, start_address, write_length);
498 usb_serial_debug_data(debug, &serial->serial->dev->dev, __FUNCTION__, write_length, buffer); 498 usb_serial_debug_data(debug, &serial->serial->dev->dev, __func__, write_length, buffer);
499 499
500 /* Write first page */ 500 /* Write first page */
501 be_start_address = cpu_to_be16 (start_address); 501 be_start_address = cpu_to_be16 (start_address);
@@ -506,7 +506,7 @@ static int TIWriteDownloadI2C (struct edgeport_serial *serial, int start_address
506 buffer, // TransferBuffer 506 buffer, // TransferBuffer
507 write_length); 507 write_length);
508 if (status) { 508 if (status) {
509 dbg ("%s - ERROR %d", __FUNCTION__, status); 509 dbg ("%s - ERROR %d", __func__, status);
510 return status; 510 return status;
511 } 511 }
512 512
@@ -521,8 +521,8 @@ static int TIWriteDownloadI2C (struct edgeport_serial *serial, int start_address
521 else 521 else
522 write_length = length; 522 write_length = length;
523 523
524 dbg ("%s - Page Write Addr = %x, length = %d", __FUNCTION__, start_address, write_length); 524 dbg ("%s - Page Write Addr = %x, length = %d", __func__, start_address, write_length);
525 usb_serial_debug_data(debug, &serial->serial->dev->dev, __FUNCTION__, write_length, buffer); 525 usb_serial_debug_data(debug, &serial->serial->dev->dev, __func__, write_length, buffer);
526 526
527 /* Write next page */ 527 /* Write next page */
528 be_start_address = cpu_to_be16 (start_address); 528 be_start_address = cpu_to_be16 (start_address);
@@ -533,7 +533,7 @@ static int TIWriteDownloadI2C (struct edgeport_serial *serial, int start_address
533 buffer, // TransferBuffer 533 buffer, // TransferBuffer
534 write_length); // TransferBufferLength 534 write_length); // TransferBufferLength
535 if (status) { 535 if (status) {
536 dev_err (&serial->serial->dev->dev, "%s - ERROR %d\n", __FUNCTION__, status); 536 dev_err (&serial->serial->dev->dev, "%s - ERROR %d\n", __func__, status);
537 return status; 537 return status;
538 } 538 }
539 539
@@ -559,7 +559,7 @@ static int TIIsTxActive (struct edgeport_port *port)
559 559
560 oedb = kmalloc (sizeof (* oedb), GFP_KERNEL); 560 oedb = kmalloc (sizeof (* oedb), GFP_KERNEL);
561 if (!oedb) { 561 if (!oedb) {
562 dev_err (&port->port->dev, "%s - out of memory\n", __FUNCTION__); 562 dev_err (&port->port->dev, "%s - out of memory\n", __func__);
563 return -ENOMEM; 563 return -ENOMEM;
564 } 564 }
565 565
@@ -579,7 +579,7 @@ static int TIIsTxActive (struct edgeport_port *port)
579 if (status) 579 if (status)
580 goto exit_is_tx_active; 580 goto exit_is_tx_active;
581 581
582 dbg ("%s - XByteCount 0x%X", __FUNCTION__, oedb->XByteCount); 582 dbg ("%s - XByteCount 0x%X", __func__, oedb->XByteCount);
583 583
584 /* and the LSR */ 584 /* and the LSR */
585 status = TIReadRam (port->port->serial->dev, 585 status = TIReadRam (port->port->serial->dev,
@@ -589,7 +589,7 @@ static int TIIsTxActive (struct edgeport_port *port)
589 589
590 if (status) 590 if (status)
591 goto exit_is_tx_active; 591 goto exit_is_tx_active;
592 dbg ("%s - LSR = 0x%X", __FUNCTION__, *lsr); 592 dbg ("%s - LSR = 0x%X", __func__, *lsr);
593 593
594 /* If either buffer has data or we are transmitting then return TRUE */ 594 /* If either buffer has data or we are transmitting then return TRUE */
595 if ((oedb->XByteCount & 0x80 ) != 0 ) 595 if ((oedb->XByteCount & 0x80 ) != 0 )
@@ -600,7 +600,7 @@ static int TIIsTxActive (struct edgeport_port *port)
600 600
601 /* We return Not Active if we get any kind of error */ 601 /* We return Not Active if we get any kind of error */
602exit_is_tx_active: 602exit_is_tx_active:
603 dbg ("%s - return %d", __FUNCTION__, bytes_left ); 603 dbg ("%s - return %d", __func__, bytes_left );
604 604
605 kfree(lsr); 605 kfree(lsr);
606 kfree(oedb); 606 kfree(oedb);
@@ -654,7 +654,7 @@ static void TIChasePort(struct edgeport_port *port, unsigned long timeout, int f
654 /* (TIIsTxActive doesn't seem to wait for the last byte) */ 654 /* (TIIsTxActive doesn't seem to wait for the last byte) */
655 if ((baud_rate=port->baud_rate) == 0) 655 if ((baud_rate=port->baud_rate) == 0)
656 baud_rate = 50; 656 baud_rate = 50;
657 msleep(max(1,(10000+baud_rate-1)/baud_rate)); 657 msleep(max(1, DIV_ROUND_UP(10000, baud_rate)));
658} 658}
659 659
660static int TIChooseConfiguration (struct usb_device *dev) 660static int TIChooseConfiguration (struct usb_device *dev)
@@ -664,11 +664,11 @@ static int TIChooseConfiguration (struct usb_device *dev)
664 // we want. However, we just support one config at this point, 664 // we want. However, we just support one config at this point,
665 // configuration # 1, which is Config Descriptor 0. 665 // configuration # 1, which is Config Descriptor 0.
666 666
667 dbg ("%s - Number of Interfaces = %d", __FUNCTION__, dev->config->desc.bNumInterfaces); 667 dbg ("%s - Number of Interfaces = %d", __func__, dev->config->desc.bNumInterfaces);
668 dbg ("%s - MAX Power = %d", __FUNCTION__, dev->config->desc.bMaxPower*2); 668 dbg ("%s - MAX Power = %d", __func__, dev->config->desc.bMaxPower*2);
669 669
670 if (dev->config->desc.bNumInterfaces != 1) { 670 if (dev->config->desc.bNumInterfaces != 1) {
671 dev_err (&dev->dev, "%s - bNumInterfaces is not 1, ERROR!\n", __FUNCTION__); 671 dev_err (&dev->dev, "%s - bNumInterfaces is not 1, ERROR!\n", __func__);
672 return -ENODEV; 672 return -ENODEV;
673 } 673 }
674 674
@@ -751,7 +751,7 @@ static int ValidChecksum(struct ti_i2c_desc *rom_desc, __u8 *buffer)
751 cs = (__u8)(cs + buffer[i]); 751 cs = (__u8)(cs + buffer[i]);
752 } 752 }
753 if (cs != rom_desc->CheckSum) { 753 if (cs != rom_desc->CheckSum) {
754 dbg ("%s - Mismatch %x - %x", __FUNCTION__, rom_desc->CheckSum, cs); 754 dbg ("%s - Mismatch %x - %x", __func__, rom_desc->CheckSum, cs);
755 return -EINVAL; 755 return -EINVAL;
756 } 756 }
757 return 0; 757 return 0;
@@ -769,12 +769,12 @@ static int TiValidateI2cImage (struct edgeport_serial *serial)
769 769
770 rom_desc = kmalloc (sizeof (*rom_desc), GFP_KERNEL); 770 rom_desc = kmalloc (sizeof (*rom_desc), GFP_KERNEL);
771 if (!rom_desc) { 771 if (!rom_desc) {
772 dev_err (dev, "%s - out of memory\n", __FUNCTION__); 772 dev_err (dev, "%s - out of memory\n", __func__);
773 return -ENOMEM; 773 return -ENOMEM;
774 } 774 }
775 buffer = kmalloc (TI_MAX_I2C_SIZE, GFP_KERNEL); 775 buffer = kmalloc (TI_MAX_I2C_SIZE, GFP_KERNEL);
776 if (!buffer) { 776 if (!buffer) {
777 dev_err (dev, "%s - out of memory when allocating buffer\n", __FUNCTION__); 777 dev_err (dev, "%s - out of memory when allocating buffer\n", __func__);
778 kfree (rom_desc); 778 kfree (rom_desc);
779 return -ENOMEM; 779 return -ENOMEM;
780 } 780 }
@@ -785,7 +785,7 @@ static int TiValidateI2cImage (struct edgeport_serial *serial)
785 goto ExitTiValidateI2cImage; 785 goto ExitTiValidateI2cImage;
786 786
787 if (*buffer != UMP5152 && *buffer != UMP3410) { 787 if (*buffer != UMP5152 && *buffer != UMP3410) {
788 dev_err (dev, "%s - invalid buffer signature\n", __FUNCTION__); 788 dev_err (dev, "%s - invalid buffer signature\n", __func__);
789 status = -ENODEV; 789 status = -ENODEV;
790 goto ExitTiValidateI2cImage; 790 goto ExitTiValidateI2cImage;
791 } 791 }
@@ -801,11 +801,11 @@ static int TiValidateI2cImage (struct edgeport_serial *serial)
801 801
802 if ((start_address + sizeof(struct ti_i2c_desc) + rom_desc->Size) > TI_MAX_I2C_SIZE) { 802 if ((start_address + sizeof(struct ti_i2c_desc) + rom_desc->Size) > TI_MAX_I2C_SIZE) {
803 status = -ENODEV; 803 status = -ENODEV;
804 dbg ("%s - structure too big, erroring out.", __FUNCTION__); 804 dbg ("%s - structure too big, erroring out.", __func__);
805 break; 805 break;
806 } 806 }
807 807
808 dbg ("%s Type = 0x%x", __FUNCTION__, rom_desc->Type); 808 dbg ("%s Type = 0x%x", __func__, rom_desc->Type);
809 809
810 // Skip type 2 record 810 // Skip type 2 record
811 ttype = rom_desc->Type & 0x0f; 811 ttype = rom_desc->Type & 0x0f;
@@ -845,13 +845,13 @@ static int TIReadManufDescriptor (struct edgeport_serial *serial, __u8 *buffer)
845 845
846 rom_desc = kmalloc (sizeof (*rom_desc), GFP_KERNEL); 846 rom_desc = kmalloc (sizeof (*rom_desc), GFP_KERNEL);
847 if (!rom_desc) { 847 if (!rom_desc) {
848 dev_err (&serial->serial->dev->dev, "%s - out of memory\n", __FUNCTION__); 848 dev_err (&serial->serial->dev->dev, "%s - out of memory\n", __func__);
849 return -ENOMEM; 849 return -ENOMEM;
850 } 850 }
851 start_address = TIGetDescriptorAddress (serial, I2C_DESC_TYPE_ION, rom_desc); 851 start_address = TIGetDescriptorAddress (serial, I2C_DESC_TYPE_ION, rom_desc);
852 852
853 if (!start_address) { 853 if (!start_address) {
854 dbg ("%s - Edge Descriptor not found in I2C", __FUNCTION__); 854 dbg ("%s - Edge Descriptor not found in I2C", __func__);
855 status = -ENODEV; 855 status = -ENODEV;
856 goto exit; 856 goto exit;
857 } 857 }
@@ -867,12 +867,12 @@ static int TIReadManufDescriptor (struct edgeport_serial *serial, __u8 *buffer)
867 status = ValidChecksum(rom_desc, buffer); 867 status = ValidChecksum(rom_desc, buffer);
868 868
869 desc = (struct edge_ti_manuf_descriptor *)buffer; 869 desc = (struct edge_ti_manuf_descriptor *)buffer;
870 dbg ( "%s - IonConfig 0x%x", __FUNCTION__, desc->IonConfig ); 870 dbg ( "%s - IonConfig 0x%x", __func__, desc->IonConfig );
871 dbg ( "%s - Version %d", __FUNCTION__, desc->Version ); 871 dbg ( "%s - Version %d", __func__, desc->Version );
872 dbg ( "%s - Cpu/Board 0x%x", __FUNCTION__, desc->CpuRev_BoardRev ); 872 dbg ( "%s - Cpu/Board 0x%x", __func__, desc->CpuRev_BoardRev );
873 dbg ( "%s - NumPorts %d", __FUNCTION__, desc->NumPorts ); 873 dbg ( "%s - NumPorts %d", __func__, desc->NumPorts );
874 dbg ( "%s - NumVirtualPorts %d", __FUNCTION__, desc->NumVirtualPorts ); 874 dbg ( "%s - NumVirtualPorts %d", __func__, desc->NumVirtualPorts );
875 dbg ( "%s - TotalPorts %d", __FUNCTION__, desc->TotalPorts ); 875 dbg ( "%s - TotalPorts %d", __func__, desc->TotalPorts );
876 876
877exit: 877exit:
878 kfree (rom_desc); 878 kfree (rom_desc);
@@ -902,7 +902,7 @@ static int BuildI2CFirmwareHeader (__u8 *header, struct device *dev)
902 902
903 buffer = kmalloc (buffer_size, GFP_KERNEL); 903 buffer = kmalloc (buffer_size, GFP_KERNEL);
904 if (!buffer) { 904 if (!buffer) {
905 dev_err (dev, "%s - out of memory\n", __FUNCTION__); 905 dev_err (dev, "%s - out of memory\n", __func__);
906 return -ENOMEM; 906 return -ENOMEM;
907 } 907 }
908 908
@@ -955,11 +955,11 @@ static int TIGetI2cTypeInBootMode (struct edgeport_serial *serial)
955 &data, // TransferBuffer 955 &data, // TransferBuffer
956 0x01); // TransferBufferLength 956 0x01); // TransferBufferLength
957 if (status) 957 if (status)
958 dbg ("%s - read 2 status error = %d", __FUNCTION__, status); 958 dbg ("%s - read 2 status error = %d", __func__, status);
959 else 959 else
960 dbg ("%s - read 2 data = 0x%x", __FUNCTION__, data); 960 dbg ("%s - read 2 data = 0x%x", __func__, data);
961 if ((!status) && (data == UMP5152 || data == UMP3410)) { 961 if ((!status) && (data == UMP5152 || data == UMP3410)) {
962 dbg ("%s - ROM_TYPE_II", __FUNCTION__); 962 dbg ("%s - ROM_TYPE_II", __func__);
963 serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_II; 963 serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_II;
964 return 0; 964 return 0;
965 } 965 }
@@ -972,16 +972,16 @@ static int TIGetI2cTypeInBootMode (struct edgeport_serial *serial)
972 &data, // TransferBuffer 972 &data, // TransferBuffer
973 0x01); // TransferBufferLength 973 0x01); // TransferBufferLength
974 if (status) 974 if (status)
975 dbg ("%s - read 3 status error = %d", __FUNCTION__, status); 975 dbg ("%s - read 3 status error = %d", __func__, status);
976 else 976 else
977 dbg ("%s - read 2 data = 0x%x", __FUNCTION__, data); 977 dbg ("%s - read 2 data = 0x%x", __func__, data);
978 if ((!status) && (data == UMP5152 || data == UMP3410)) { 978 if ((!status) && (data == UMP5152 || data == UMP3410)) {
979 dbg ("%s - ROM_TYPE_III", __FUNCTION__); 979 dbg ("%s - ROM_TYPE_III", __func__);
980 serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_III; 980 serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_III;
981 return 0; 981 return 0;
982 } 982 }
983 983
984 dbg ("%s - Unknown", __FUNCTION__); 984 dbg ("%s - Unknown", __func__);
985 serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_II; 985 serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_II;
986 return -ENODEV; 986 return -ENODEV;
987} 987}
@@ -1063,7 +1063,7 @@ static int TIDownloadFirmware (struct edgeport_serial *serial)
1063 1063
1064 interface = &serial->serial->interface->cur_altsetting->desc; 1064 interface = &serial->serial->interface->cur_altsetting->desc;
1065 if (!interface) { 1065 if (!interface) {
1066 dev_err (dev, "%s - no interface set, error!\n", __FUNCTION__); 1066 dev_err (dev, "%s - no interface set, error!\n", __func__);
1067 return -ENODEV; 1067 return -ENODEV;
1068 } 1068 }
1069 1069
@@ -1086,12 +1086,11 @@ static int TIDownloadFirmware (struct edgeport_serial *serial)
1086 if (serial->product_info.TiMode == TI_MODE_DOWNLOAD) { 1086 if (serial->product_info.TiMode == TI_MODE_DOWNLOAD) {
1087 struct ti_i2c_desc *rom_desc; 1087 struct ti_i2c_desc *rom_desc;
1088 1088
1089 dbg ("%s - <<<<<<<<<<<<<<<RUNNING IN DOWNLOAD MODE>>>>>>>>>>", __FUNCTION__); 1089 dbg("%s - RUNNING IN DOWNLOAD MODE", __func__);
1090 1090
1091 status = TiValidateI2cImage (serial); 1091 status = TiValidateI2cImage (serial);
1092 if (status) { 1092 if (status) {
1093 dbg ("%s - <<<<<<<<<<<<<<<DOWNLOAD MODE -- BAD I2C >>>>>>>>>>", 1093 dbg("%s - DOWNLOAD MODE -- BAD I2C", __func__);
1094 __FUNCTION__);
1095 return status; 1094 return status;
1096 } 1095 }
1097 1096
@@ -1100,7 +1099,7 @@ static int TIDownloadFirmware (struct edgeport_serial *serial)
1100 */ 1099 */
1101 ti_manuf_desc = kmalloc (sizeof (*ti_manuf_desc), GFP_KERNEL); 1100 ti_manuf_desc = kmalloc (sizeof (*ti_manuf_desc), GFP_KERNEL);
1102 if (!ti_manuf_desc) { 1101 if (!ti_manuf_desc) {
1103 dev_err (dev, "%s - out of memory.\n", __FUNCTION__); 1102 dev_err (dev, "%s - out of memory.\n", __func__);
1104 return -ENOMEM; 1103 return -ENOMEM;
1105 } 1104 }
1106 status = TIReadManufDescriptor (serial, (__u8 *)ti_manuf_desc); 1105 status = TIReadManufDescriptor (serial, (__u8 *)ti_manuf_desc);
@@ -1111,7 +1110,7 @@ static int TIDownloadFirmware (struct edgeport_serial *serial)
1111 1110
1112 // Check version number of ION descriptor 1111 // Check version number of ION descriptor
1113 if (!ignore_cpu_rev && TI_GET_CPU_REVISION(ti_manuf_desc->CpuRev_BoardRev) < 2) { 1112 if (!ignore_cpu_rev && TI_GET_CPU_REVISION(ti_manuf_desc->CpuRev_BoardRev) < 2) {
1114 dbg ( "%s - Wrong CPU Rev %d (Must be 2)", __FUNCTION__, 1113 dbg ( "%s - Wrong CPU Rev %d (Must be 2)", __func__,
1115 TI_GET_CPU_REVISION(ti_manuf_desc->CpuRev_BoardRev)); 1114 TI_GET_CPU_REVISION(ti_manuf_desc->CpuRev_BoardRev));
1116 kfree (ti_manuf_desc); 1115 kfree (ti_manuf_desc);
1117 return -EINVAL; 1116 return -EINVAL;
@@ -1119,7 +1118,7 @@ static int TIDownloadFirmware (struct edgeport_serial *serial)
1119 1118
1120 rom_desc = kmalloc (sizeof (*rom_desc), GFP_KERNEL); 1119 rom_desc = kmalloc (sizeof (*rom_desc), GFP_KERNEL);
1121 if (!rom_desc) { 1120 if (!rom_desc) {
1122 dev_err (dev, "%s - out of memory.\n", __FUNCTION__); 1121 dev_err (dev, "%s - out of memory.\n", __func__);
1123 kfree (ti_manuf_desc); 1122 kfree (ti_manuf_desc);
1124 return -ENOMEM; 1123 return -ENOMEM;
1125 } 1124 }
@@ -1129,11 +1128,11 @@ static int TIDownloadFirmware (struct edgeport_serial *serial)
1129 struct ti_i2c_firmware_rec *firmware_version; 1128 struct ti_i2c_firmware_rec *firmware_version;
1130 __u8 record; 1129 __u8 record;
1131 1130
1132 dbg ("%s - Found Type FIRMWARE (Type 2) record", __FUNCTION__); 1131 dbg ("%s - Found Type FIRMWARE (Type 2) record", __func__);
1133 1132
1134 firmware_version = kmalloc (sizeof (*firmware_version), GFP_KERNEL); 1133 firmware_version = kmalloc (sizeof (*firmware_version), GFP_KERNEL);
1135 if (!firmware_version) { 1134 if (!firmware_version) {
1136 dev_err (dev, "%s - out of memory.\n", __FUNCTION__); 1135 dev_err (dev, "%s - out of memory.\n", __func__);
1137 kfree (rom_desc); 1136 kfree (rom_desc);
1138 kfree (ti_manuf_desc); 1137 kfree (ti_manuf_desc);
1139 return -ENOMEM; 1138 return -ENOMEM;
@@ -1159,7 +1158,7 @@ static int TIDownloadFirmware (struct edgeport_serial *serial)
1159 (OperationalCodeImageVersion.MinorVersion); 1158 (OperationalCodeImageVersion.MinorVersion);
1160 1159
1161 dbg ("%s - >>>Firmware Versions Device %d.%d Driver %d.%d", 1160 dbg ("%s - >>>Firmware Versions Device %d.%d Driver %d.%d",
1162 __FUNCTION__, 1161 __func__,
1163 firmware_version->Ver_Major, 1162 firmware_version->Ver_Major,
1164 firmware_version->Ver_Minor, 1163 firmware_version->Ver_Minor,
1165 OperationalCodeImageVersion.MajorVersion, 1164 OperationalCodeImageVersion.MajorVersion,
@@ -1168,7 +1167,7 @@ static int TIDownloadFirmware (struct edgeport_serial *serial)
1168 // Check if we have an old version in the I2C and update if necessary 1167 // Check if we have an old version in the I2C and update if necessary
1169 if (download_cur_ver != download_new_ver) { 1168 if (download_cur_ver != download_new_ver) {
1170 dbg ("%s - Update I2C Download from %d.%d to %d.%d", 1169 dbg ("%s - Update I2C Download from %d.%d to %d.%d",
1171 __FUNCTION__, 1170 __func__,
1172 firmware_version->Ver_Major, 1171 firmware_version->Ver_Major,
1173 firmware_version->Ver_Minor, 1172 firmware_version->Ver_Minor,
1174 OperationalCodeImageVersion.MajorVersion, 1173 OperationalCodeImageVersion.MajorVersion,
@@ -1210,14 +1209,14 @@ static int TIDownloadFirmware (struct edgeport_serial *serial)
1210 } 1209 }
1211 1210
1212 if (record != I2C_DESC_TYPE_FIRMWARE_BLANK) { 1211 if (record != I2C_DESC_TYPE_FIRMWARE_BLANK) {
1213 dev_err (dev, "%s - error resetting device\n", __FUNCTION__); 1212 dev_err (dev, "%s - error resetting device\n", __func__);
1214 kfree (firmware_version); 1213 kfree (firmware_version);
1215 kfree (rom_desc); 1214 kfree (rom_desc);
1216 kfree (ti_manuf_desc); 1215 kfree (ti_manuf_desc);
1217 return -ENODEV; 1216 return -ENODEV;
1218 } 1217 }
1219 1218
1220 dbg ("%s - HARDWARE RESET", __FUNCTION__); 1219 dbg ("%s - HARDWARE RESET", __func__);
1221 1220
1222 // Reset UMP -- Back to BOOT MODE 1221 // Reset UMP -- Back to BOOT MODE
1223 status = TISendVendorRequestSync (serial->serial->dev, 1222 status = TISendVendorRequestSync (serial->serial->dev,
@@ -1227,7 +1226,7 @@ static int TIDownloadFirmware (struct edgeport_serial *serial)
1227 NULL, // TransferBuffer 1226 NULL, // TransferBuffer
1228 0); // TransferBufferLength 1227 0); // TransferBufferLength
1229 1228
1230 dbg ( "%s - HARDWARE RESET return %d", __FUNCTION__, status); 1229 dbg ( "%s - HARDWARE RESET return %d", __func__, status);
1231 1230
1232 /* return an error on purpose. */ 1231 /* return an error on purpose. */
1233 kfree (firmware_version); 1232 kfree (firmware_version);
@@ -1245,7 +1244,7 @@ static int TIDownloadFirmware (struct edgeport_serial *serial)
1245 1244
1246 header = kmalloc (HEADER_SIZE, GFP_KERNEL); 1245 header = kmalloc (HEADER_SIZE, GFP_KERNEL);
1247 if (!header) { 1246 if (!header) {
1248 dev_err (dev, "%s - out of memory.\n", __FUNCTION__); 1247 dev_err (dev, "%s - out of memory.\n", __func__);
1249 kfree (rom_desc); 1248 kfree (rom_desc);
1250 kfree (ti_manuf_desc); 1249 kfree (ti_manuf_desc);
1251 return -ENOMEM; 1250 return -ENOMEM;
@@ -1253,14 +1252,14 @@ static int TIDownloadFirmware (struct edgeport_serial *serial)
1253 1252
1254 vheader = kmalloc (HEADER_SIZE, GFP_KERNEL); 1253 vheader = kmalloc (HEADER_SIZE, GFP_KERNEL);
1255 if (!vheader) { 1254 if (!vheader) {
1256 dev_err (dev, "%s - out of memory.\n", __FUNCTION__); 1255 dev_err (dev, "%s - out of memory.\n", __func__);
1257 kfree (header); 1256 kfree (header);
1258 kfree (rom_desc); 1257 kfree (rom_desc);
1259 kfree (ti_manuf_desc); 1258 kfree (ti_manuf_desc);
1260 return -ENOMEM; 1259 return -ENOMEM;
1261 } 1260 }
1262 1261
1263 dbg ("%s - Found Type BLANK FIRMWARE (Type F2) record", __FUNCTION__); 1262 dbg ("%s - Found Type BLANK FIRMWARE (Type F2) record", __func__);
1264 1263
1265 // In order to update the I2C firmware we must change the type 2 record to type 0xF2. 1264 // In order to update the I2C firmware we must change the type 2 record to type 0xF2.
1266 // This will force the UMP to come up in Boot Mode. Then while in boot mode, the driver 1265 // This will force the UMP to come up in Boot Mode. Then while in boot mode, the driver
@@ -1298,7 +1297,7 @@ static int TIDownloadFirmware (struct edgeport_serial *serial)
1298 vheader); 1297 vheader);
1299 1298
1300 if (status) { 1299 if (status) {
1301 dbg ("%s - can't read header back", __FUNCTION__); 1300 dbg ("%s - can't read header back", __func__);
1302 kfree (vheader); 1301 kfree (vheader);
1303 kfree (header); 1302 kfree (header);
1304 kfree (rom_desc); 1303 kfree (rom_desc);
@@ -1306,7 +1305,7 @@ static int TIDownloadFirmware (struct edgeport_serial *serial)
1306 return status; 1305 return status;
1307 } 1306 }
1308 if (memcmp(vheader, header, HEADER_SIZE)) { 1307 if (memcmp(vheader, header, HEADER_SIZE)) {
1309 dbg ("%s - write download record failed", __FUNCTION__); 1308 dbg ("%s - write download record failed", __func__);
1310 kfree (vheader); 1309 kfree (vheader);
1311 kfree (header); 1310 kfree (header);
1312 kfree (rom_desc); 1311 kfree (rom_desc);
@@ -1317,7 +1316,7 @@ static int TIDownloadFirmware (struct edgeport_serial *serial)
1317 kfree (vheader); 1316 kfree (vheader);
1318 kfree (header); 1317 kfree (header);
1319 1318
1320 dbg ("%s - Start firmware update", __FUNCTION__); 1319 dbg ("%s - Start firmware update", __func__);
1321 1320
1322 // Tell firmware to copy download image into I2C 1321 // Tell firmware to copy download image into I2C
1323 status = TISendVendorRequestSync (serial->serial->dev, 1322 status = TISendVendorRequestSync (serial->serial->dev,
@@ -1327,9 +1326,9 @@ static int TIDownloadFirmware (struct edgeport_serial *serial)
1327 NULL, // TransferBuffer 1326 NULL, // TransferBuffer
1328 0); // TransferBufferLength 1327 0); // TransferBufferLength
1329 1328
1330 dbg ("%s - Update complete 0x%x", __FUNCTION__, status); 1329 dbg ("%s - Update complete 0x%x", __func__, status);
1331 if (status) { 1330 if (status) {
1332 dev_err (dev, "%s - UMPC_COPY_DNLD_TO_I2C failed\n", __FUNCTION__); 1331 dev_err (dev, "%s - UMPC_COPY_DNLD_TO_I2C failed\n", __func__);
1333 kfree (rom_desc); 1332 kfree (rom_desc);
1334 kfree (ti_manuf_desc); 1333 kfree (ti_manuf_desc);
1335 return status; 1334 return status;
@@ -1345,8 +1344,7 @@ static int TIDownloadFirmware (struct edgeport_serial *serial)
1345 /********************************************************************/ 1344 /********************************************************************/
1346 /* Boot Mode */ 1345 /* Boot Mode */
1347 /********************************************************************/ 1346 /********************************************************************/
1348 dbg ("%s - <<<<<<<<<<<<<<<RUNNING IN BOOT MODE>>>>>>>>>>>>>>>", 1347 dbg("%s - RUNNING IN BOOT MODE", __func__);
1349 __FUNCTION__);
1350 1348
1351 // Configure the TI device so we can use the BULK pipes for download 1349 // Configure the TI device so we can use the BULK pipes for download
1352 status = TIConfigureBootDevice (serial->serial->dev); 1350 status = TIConfigureBootDevice (serial->serial->dev);
@@ -1354,7 +1352,7 @@ static int TIDownloadFirmware (struct edgeport_serial *serial)
1354 return status; 1352 return status;
1355 1353
1356 if (le16_to_cpu(serial->serial->dev->descriptor.idVendor) != USB_VENDOR_ID_ION) { 1354 if (le16_to_cpu(serial->serial->dev->descriptor.idVendor) != USB_VENDOR_ID_ION) {
1357 dbg ("%s - VID = 0x%x", __FUNCTION__, 1355 dbg ("%s - VID = 0x%x", __func__,
1358 le16_to_cpu(serial->serial->dev->descriptor.idVendor)); 1356 le16_to_cpu(serial->serial->dev->descriptor.idVendor));
1359 serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_II; 1357 serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_II;
1360 goto StayInBootMode; 1358 goto StayInBootMode;
@@ -1368,7 +1366,7 @@ static int TIDownloadFirmware (struct edgeport_serial *serial)
1368 1366
1369 // Registry variable set? 1367 // Registry variable set?
1370 if (TIStayInBootMode) { 1368 if (TIStayInBootMode) {
1371 dbg ("%s - TIStayInBootMode", __FUNCTION__); 1369 dbg ("%s - TIStayInBootMode", __func__);
1372 goto StayInBootMode; 1370 goto StayInBootMode;
1373 } 1371 }
1374 1372
@@ -1385,7 +1383,7 @@ static int TIDownloadFirmware (struct edgeport_serial *serial)
1385 */ 1383 */
1386 ti_manuf_desc = kmalloc (sizeof (*ti_manuf_desc), GFP_KERNEL); 1384 ti_manuf_desc = kmalloc (sizeof (*ti_manuf_desc), GFP_KERNEL);
1387 if (!ti_manuf_desc) { 1385 if (!ti_manuf_desc) {
1388 dev_err (dev, "%s - out of memory.\n", __FUNCTION__); 1386 dev_err (dev, "%s - out of memory.\n", __func__);
1389 return -ENOMEM; 1387 return -ENOMEM;
1390 } 1388 }
1391 status = TIReadManufDescriptor (serial, (__u8 *)ti_manuf_desc); 1389 status = TIReadManufDescriptor (serial, (__u8 *)ti_manuf_desc);
@@ -1396,7 +1394,7 @@ static int TIDownloadFirmware (struct edgeport_serial *serial)
1396 1394
1397 // Check for version 2 1395 // Check for version 2
1398 if (!ignore_cpu_rev && TI_GET_CPU_REVISION(ti_manuf_desc->CpuRev_BoardRev) < 2) { 1396 if (!ignore_cpu_rev && TI_GET_CPU_REVISION(ti_manuf_desc->CpuRev_BoardRev) < 2) {
1399 dbg ("%s - Wrong CPU Rev %d (Must be 2)", __FUNCTION__, 1397 dbg ("%s - Wrong CPU Rev %d (Must be 2)", __func__,
1400 TI_GET_CPU_REVISION(ti_manuf_desc->CpuRev_BoardRev)); 1398 TI_GET_CPU_REVISION(ti_manuf_desc->CpuRev_BoardRev));
1401 kfree (ti_manuf_desc); 1399 kfree (ti_manuf_desc);
1402 goto StayInBootMode; 1400 goto StayInBootMode;
@@ -1420,7 +1418,7 @@ static int TIDownloadFirmware (struct edgeport_serial *serial)
1420 buffer_size = (((1024 * 16) - 512) + sizeof(struct ti_i2c_image_header)); 1418 buffer_size = (((1024 * 16) - 512) + sizeof(struct ti_i2c_image_header));
1421 buffer = kmalloc (buffer_size, GFP_KERNEL); 1419 buffer = kmalloc (buffer_size, GFP_KERNEL);
1422 if (!buffer) { 1420 if (!buffer) {
1423 dev_err (dev, "%s - out of memory\n", __FUNCTION__); 1421 dev_err (dev, "%s - out of memory\n", __func__);
1424 return -ENOMEM; 1422 return -ENOMEM;
1425 } 1423 }
1426 1424
@@ -1440,20 +1438,20 @@ static int TIDownloadFirmware (struct edgeport_serial *serial)
1440 header->CheckSum = cs; 1438 header->CheckSum = cs;
1441 1439
1442 // Download the operational code 1440 // Download the operational code
1443 dbg ("%s - Downloading operational code image (TI UMP)", __FUNCTION__); 1441 dbg ("%s - Downloading operational code image (TI UMP)", __func__);
1444 status = TIDownloadCodeImage (serial, buffer, buffer_size); 1442 status = TIDownloadCodeImage (serial, buffer, buffer_size);
1445 1443
1446 kfree (buffer); 1444 kfree (buffer);
1447 1445
1448 if (status) { 1446 if (status) {
1449 dbg ("%s - Error downloading operational code image", __FUNCTION__); 1447 dbg ("%s - Error downloading operational code image", __func__);
1450 return status; 1448 return status;
1451 } 1449 }
1452 1450
1453 // Device will reboot 1451 // Device will reboot
1454 serial->product_info.TiMode = TI_MODE_TRANSITIONING; 1452 serial->product_info.TiMode = TI_MODE_TRANSITIONING;
1455 1453
1456 dbg ("%s - Download successful -- Device rebooting...", __FUNCTION__); 1454 dbg ("%s - Download successful -- Device rebooting...", __func__);
1457 1455
1458 /* return an error on purpose */ 1456 /* return an error on purpose */
1459 return -ENODEV; 1457 return -ENODEV;
@@ -1461,7 +1459,7 @@ static int TIDownloadFirmware (struct edgeport_serial *serial)
1461 1459
1462StayInBootMode: 1460StayInBootMode:
1463 // Eprom is invalid or blank stay in boot mode 1461 // Eprom is invalid or blank stay in boot mode
1464 dbg ("%s - <<<<<<<<<<<<<<<STAYING IN BOOT MODE>>>>>>>>>>>>", __FUNCTION__); 1462 dbg("%s - STAYING IN BOOT MODE", __func__);
1465 serial->product_info.TiMode = TI_MODE_BOOT; 1463 serial->product_info.TiMode = TI_MODE_BOOT;
1466 1464
1467 return 0; 1465 return 0;
@@ -1472,7 +1470,7 @@ static int TISetDtr (struct edgeport_port *port)
1472{ 1470{
1473 int port_number = port->port->number - port->port->serial->minor; 1471 int port_number = port->port->number - port->port->serial->minor;
1474 1472
1475 dbg ("%s", __FUNCTION__); 1473 dbg ("%s", __func__);
1476 port->shadow_mcr |= MCR_DTR; 1474 port->shadow_mcr |= MCR_DTR;
1477 1475
1478 return TIWriteCommandSync (port->port->serial->dev, 1476 return TIWriteCommandSync (port->port->serial->dev,
@@ -1487,7 +1485,7 @@ static int TIClearDtr (struct edgeport_port *port)
1487{ 1485{
1488 int port_number = port->port->number - port->port->serial->minor; 1486 int port_number = port->port->number - port->port->serial->minor;
1489 1487
1490 dbg ("%s", __FUNCTION__); 1488 dbg ("%s", __func__);
1491 port->shadow_mcr &= ~MCR_DTR; 1489 port->shadow_mcr &= ~MCR_DTR;
1492 1490
1493 return TIWriteCommandSync (port->port->serial->dev, 1491 return TIWriteCommandSync (port->port->serial->dev,
@@ -1502,7 +1500,7 @@ static int TISetRts (struct edgeport_port *port)
1502{ 1500{
1503 int port_number = port->port->number - port->port->serial->minor; 1501 int port_number = port->port->number - port->port->serial->minor;
1504 1502
1505 dbg ("%s", __FUNCTION__); 1503 dbg ("%s", __func__);
1506 port->shadow_mcr |= MCR_RTS; 1504 port->shadow_mcr |= MCR_RTS;
1507 1505
1508 return TIWriteCommandSync (port->port->serial->dev, 1506 return TIWriteCommandSync (port->port->serial->dev,
@@ -1517,7 +1515,7 @@ static int TIClearRts (struct edgeport_port *port)
1517{ 1515{
1518 int port_number = port->port->number - port->port->serial->minor; 1516 int port_number = port->port->number - port->port->serial->minor;
1519 1517
1520 dbg ("%s", __FUNCTION__); 1518 dbg ("%s", __func__);
1521 port->shadow_mcr &= ~MCR_RTS; 1519 port->shadow_mcr &= ~MCR_RTS;
1522 1520
1523 return TIWriteCommandSync (port->port->serial->dev, 1521 return TIWriteCommandSync (port->port->serial->dev,
@@ -1532,7 +1530,7 @@ static int TISetLoopBack (struct edgeport_port *port)
1532{ 1530{
1533 int port_number = port->port->number - port->port->serial->minor; 1531 int port_number = port->port->number - port->port->serial->minor;
1534 1532
1535 dbg ("%s", __FUNCTION__); 1533 dbg ("%s", __func__);
1536 1534
1537 return TIWriteCommandSync (port->port->serial->dev, 1535 return TIWriteCommandSync (port->port->serial->dev,
1538 UMPC_SET_CLR_LOOPBACK, 1536 UMPC_SET_CLR_LOOPBACK,
@@ -1546,7 +1544,7 @@ static int TIClearLoopBack (struct edgeport_port *port)
1546{ 1544{
1547 int port_number = port->port->number - port->port->serial->minor; 1545 int port_number = port->port->number - port->port->serial->minor;
1548 1546
1549 dbg ("%s", __FUNCTION__); 1547 dbg ("%s", __func__);
1550 1548
1551 return TIWriteCommandSync (port->port->serial->dev, 1549 return TIWriteCommandSync (port->port->serial->dev,
1552 UMPC_SET_CLR_LOOPBACK, 1550 UMPC_SET_CLR_LOOPBACK,
@@ -1560,7 +1558,7 @@ static int TISetBreak (struct edgeport_port *port)
1560{ 1558{
1561 int port_number = port->port->number - port->port->serial->minor; 1559 int port_number = port->port->number - port->port->serial->minor;
1562 1560
1563 dbg ("%s", __FUNCTION__); 1561 dbg ("%s", __func__);
1564 1562
1565 return TIWriteCommandSync (port->port->serial->dev, 1563 return TIWriteCommandSync (port->port->serial->dev,
1566 UMPC_SET_CLR_BREAK, 1564 UMPC_SET_CLR_BREAK,
@@ -1574,7 +1572,7 @@ static int TIClearBreak (struct edgeport_port *port)
1574{ 1572{
1575 int port_number = port->port->number - port->port->serial->minor; 1573 int port_number = port->port->number - port->port->serial->minor;
1576 1574
1577 dbg ("%s", __FUNCTION__); 1575 dbg ("%s", __func__);
1578 1576
1579 return TIWriteCommandSync (port->port->serial->dev, 1577 return TIWriteCommandSync (port->port->serial->dev,
1580 UMPC_SET_CLR_BREAK, 1578 UMPC_SET_CLR_BREAK,
@@ -1588,7 +1586,7 @@ static int TIRestoreMCR (struct edgeport_port *port, __u8 mcr)
1588{ 1586{
1589 int status = 0; 1587 int status = 0;
1590 1588
1591 dbg ("%s - %x", __FUNCTION__, mcr); 1589 dbg ("%s - %x", __func__, mcr);
1592 1590
1593 if (mcr & MCR_DTR) 1591 if (mcr & MCR_DTR)
1594 status = TISetDtr (port); 1592 status = TISetDtr (port);
@@ -1642,7 +1640,7 @@ static void handle_new_msr (struct edgeport_port *edge_port, __u8 msr)
1642 struct async_icount *icount; 1640 struct async_icount *icount;
1643 struct tty_struct *tty; 1641 struct tty_struct *tty;
1644 1642
1645 dbg ("%s - %02x", __FUNCTION__, msr); 1643 dbg ("%s - %02x", __func__, msr);
1646 1644
1647 if (msr & (EDGEPORT_MSR_DELTA_CTS | EDGEPORT_MSR_DELTA_DSR | EDGEPORT_MSR_DELTA_RI | EDGEPORT_MSR_DELTA_CD)) { 1645 if (msr & (EDGEPORT_MSR_DELTA_CTS | EDGEPORT_MSR_DELTA_DSR | EDGEPORT_MSR_DELTA_RI | EDGEPORT_MSR_DELTA_CD)) {
1648 icount = &edge_port->icount; 1646 icount = &edge_port->icount;
@@ -1681,7 +1679,7 @@ static void handle_new_lsr (struct edgeport_port *edge_port, int lsr_data, __u8
1681 struct async_icount *icount; 1679 struct async_icount *icount;
1682 __u8 new_lsr = (__u8)(lsr & (__u8)(LSR_OVER_ERR | LSR_PAR_ERR | LSR_FRM_ERR | LSR_BREAK)); 1680 __u8 new_lsr = (__u8)(lsr & (__u8)(LSR_OVER_ERR | LSR_PAR_ERR | LSR_FRM_ERR | LSR_BREAK));
1683 1681
1684 dbg ("%s - %02x", __FUNCTION__, new_lsr); 1682 dbg ("%s - %02x", __func__, new_lsr);
1685 1683
1686 edge_port->shadow_lsr = lsr; 1684 edge_port->shadow_lsr = lsr;
1687 1685
@@ -1712,7 +1710,7 @@ static void handle_new_lsr (struct edgeport_port *edge_port, int lsr_data, __u8
1712 1710
1713static void edge_interrupt_callback (struct urb *urb) 1711static void edge_interrupt_callback (struct urb *urb)
1714{ 1712{
1715 struct edgeport_serial *edge_serial = (struct edgeport_serial *)urb->context; 1713 struct edgeport_serial *edge_serial = urb->context;
1716 struct usb_serial_port *port; 1714 struct usb_serial_port *port;
1717 struct edgeport_port *edge_port; 1715 struct edgeport_port *edge_port;
1718 unsigned char *data = urb->transfer_buffer; 1716 unsigned char *data = urb->transfer_buffer;
@@ -1724,7 +1722,7 @@ static void edge_interrupt_callback (struct urb *urb)
1724 __u8 msr; 1722 __u8 msr;
1725 int status = urb->status; 1723 int status = urb->status;
1726 1724
1727 dbg("%s", __FUNCTION__); 1725 dbg("%s", __func__);
1728 1726
1729 switch (status) { 1727 switch (status) {
1730 case 0: 1728 case 0:
@@ -1735,34 +1733,34 @@ static void edge_interrupt_callback (struct urb *urb)
1735 case -ESHUTDOWN: 1733 case -ESHUTDOWN:
1736 /* this urb is terminated, clean up */ 1734 /* this urb is terminated, clean up */
1737 dbg("%s - urb shutting down with status: %d", 1735 dbg("%s - urb shutting down with status: %d",
1738 __FUNCTION__, status); 1736 __func__, status);
1739 return; 1737 return;
1740 default: 1738 default:
1741 dev_err(&urb->dev->dev, "%s - nonzero urb status received: " 1739 dev_err(&urb->dev->dev, "%s - nonzero urb status received: "
1742 "%d\n", __FUNCTION__, status); 1740 "%d\n", __func__, status);
1743 goto exit; 1741 goto exit;
1744 } 1742 }
1745 1743
1746 if (!length) { 1744 if (!length) {
1747 dbg ("%s - no data in urb", __FUNCTION__); 1745 dbg ("%s - no data in urb", __func__);
1748 goto exit; 1746 goto exit;
1749 } 1747 }
1750 1748
1751 usb_serial_debug_data(debug, &edge_serial->serial->dev->dev, __FUNCTION__, length, data); 1749 usb_serial_debug_data(debug, &edge_serial->serial->dev->dev, __func__, length, data);
1752 1750
1753 if (length != 2) { 1751 if (length != 2) {
1754 dbg ("%s - expecting packet of size 2, got %d", __FUNCTION__, length); 1752 dbg ("%s - expecting packet of size 2, got %d", __func__, length);
1755 goto exit; 1753 goto exit;
1756 } 1754 }
1757 1755
1758 port_number = TIUMP_GET_PORT_FROM_CODE (data[0]); 1756 port_number = TIUMP_GET_PORT_FROM_CODE (data[0]);
1759 function = TIUMP_GET_FUNC_FROM_CODE (data[0]); 1757 function = TIUMP_GET_FUNC_FROM_CODE (data[0]);
1760 dbg ("%s - port_number %d, function %d, info 0x%x", 1758 dbg ("%s - port_number %d, function %d, info 0x%x",
1761 __FUNCTION__, port_number, function, data[1]); 1759 __func__, port_number, function, data[1]);
1762 port = edge_serial->serial->port[port_number]; 1760 port = edge_serial->serial->port[port_number];
1763 edge_port = usb_get_serial_port_data(port); 1761 edge_port = usb_get_serial_port_data(port);
1764 if (!edge_port) { 1762 if (!edge_port) {
1765 dbg ("%s - edge_port not found", __FUNCTION__); 1763 dbg ("%s - edge_port not found", __func__);
1766 return; 1764 return;
1767 } 1765 }
1768 switch (function) { 1766 switch (function) {
@@ -1771,12 +1769,12 @@ static void edge_interrupt_callback (struct urb *urb)
1771 if (lsr & UMP_UART_LSR_DATA_MASK) { 1769 if (lsr & UMP_UART_LSR_DATA_MASK) {
1772 /* Save the LSR event for bulk read completion routine */ 1770 /* Save the LSR event for bulk read completion routine */
1773 dbg ("%s - LSR Event Port %u LSR Status = %02x", 1771 dbg ("%s - LSR Event Port %u LSR Status = %02x",
1774 __FUNCTION__, port_number, lsr); 1772 __func__, port_number, lsr);
1775 edge_port->lsr_event = 1; 1773 edge_port->lsr_event = 1;
1776 edge_port->lsr_mask = lsr; 1774 edge_port->lsr_mask = lsr;
1777 } else { 1775 } else {
1778 dbg ("%s - ===== Port %d LSR Status = %02x ======", 1776 dbg ("%s - ===== Port %d LSR Status = %02x ======",
1779 __FUNCTION__, port_number, lsr); 1777 __func__, port_number, lsr);
1780 handle_new_lsr (edge_port, 0, lsr, 0); 1778 handle_new_lsr (edge_port, 0, lsr, 0);
1781 } 1779 }
1782 break; 1780 break;
@@ -1785,13 +1783,13 @@ static void edge_interrupt_callback (struct urb *urb)
1785 /* Copy MSR from UMP */ 1783 /* Copy MSR from UMP */
1786 msr = data[1]; 1784 msr = data[1];
1787 dbg ("%s - ===== Port %u MSR Status = %02x ======\n", 1785 dbg ("%s - ===== Port %u MSR Status = %02x ======\n",
1788 __FUNCTION__, port_number, msr); 1786 __func__, port_number, msr);
1789 handle_new_msr (edge_port, msr); 1787 handle_new_msr (edge_port, msr);
1790 break; 1788 break;
1791 1789
1792 default: 1790 default:
1793 dev_err (&urb->dev->dev, "%s - Unknown Interrupt code from UMP %x\n", 1791 dev_err (&urb->dev->dev, "%s - Unknown Interrupt code from UMP %x\n",
1794 __FUNCTION__, data[1]); 1792 __func__, data[1]);
1795 break; 1793 break;
1796 1794
1797 } 1795 }
@@ -1800,19 +1798,19 @@ exit:
1800 retval = usb_submit_urb (urb, GFP_ATOMIC); 1798 retval = usb_submit_urb (urb, GFP_ATOMIC);
1801 if (retval) 1799 if (retval)
1802 dev_err (&urb->dev->dev, "%s - usb_submit_urb failed with result %d\n", 1800 dev_err (&urb->dev->dev, "%s - usb_submit_urb failed with result %d\n",
1803 __FUNCTION__, retval); 1801 __func__, retval);
1804} 1802}
1805 1803
1806static void edge_bulk_in_callback (struct urb *urb) 1804static void edge_bulk_in_callback (struct urb *urb)
1807{ 1805{
1808 struct edgeport_port *edge_port = (struct edgeport_port *)urb->context; 1806 struct edgeport_port *edge_port = urb->context;
1809 unsigned char *data = urb->transfer_buffer; 1807 unsigned char *data = urb->transfer_buffer;
1810 struct tty_struct *tty; 1808 struct tty_struct *tty;
1811 int retval = 0; 1809 int retval = 0;
1812 int port_number; 1810 int port_number;
1813 int status = urb->status; 1811 int status = urb->status;
1814 1812
1815 dbg("%s", __FUNCTION__); 1813 dbg("%s", __func__);
1816 1814
1817 switch (status) { 1815 switch (status) {
1818 case 0: 1816 case 0:
@@ -1823,18 +1821,18 @@ static void edge_bulk_in_callback (struct urb *urb)
1823 case -ESHUTDOWN: 1821 case -ESHUTDOWN:
1824 /* this urb is terminated, clean up */ 1822 /* this urb is terminated, clean up */
1825 dbg("%s - urb shutting down with status: %d", 1823 dbg("%s - urb shutting down with status: %d",
1826 __FUNCTION__, status); 1824 __func__, status);
1827 return; 1825 return;
1828 default: 1826 default:
1829 dev_err (&urb->dev->dev,"%s - nonzero read bulk status received: %d\n", 1827 dev_err (&urb->dev->dev,"%s - nonzero read bulk status received: %d\n",
1830 __FUNCTION__, status); 1828 __func__, status);
1831 } 1829 }
1832 1830
1833 if (status == -EPIPE) 1831 if (status == -EPIPE)
1834 goto exit; 1832 goto exit;
1835 1833
1836 if (status) { 1834 if (status) {
1837 dev_err(&urb->dev->dev,"%s - stopping read!\n", __FUNCTION__); 1835 dev_err(&urb->dev->dev,"%s - stopping read!\n", __func__);
1838 return; 1836 return;
1839 } 1837 }
1840 1838
@@ -1843,7 +1841,7 @@ static void edge_bulk_in_callback (struct urb *urb)
1843 if (edge_port->lsr_event) { 1841 if (edge_port->lsr_event) {
1844 edge_port->lsr_event = 0; 1842 edge_port->lsr_event = 0;
1845 dbg ("%s ===== Port %u LSR Status = %02x, Data = %02x ======", 1843 dbg ("%s ===== Port %u LSR Status = %02x, Data = %02x ======",
1846 __FUNCTION__, port_number, edge_port->lsr_mask, *data); 1844 __func__, port_number, edge_port->lsr_mask, *data);
1847 handle_new_lsr (edge_port, 1, edge_port->lsr_mask, *data); 1845 handle_new_lsr (edge_port, 1, edge_port->lsr_mask, *data);
1848 /* Adjust buffer length/pointer */ 1846 /* Adjust buffer length/pointer */
1849 --urb->actual_length; 1847 --urb->actual_length;
@@ -1852,10 +1850,10 @@ static void edge_bulk_in_callback (struct urb *urb)
1852 1850
1853 tty = edge_port->port->tty; 1851 tty = edge_port->port->tty;
1854 if (tty && urb->actual_length) { 1852 if (tty && urb->actual_length) {
1855 usb_serial_debug_data(debug, &edge_port->port->dev, __FUNCTION__, urb->actual_length, data); 1853 usb_serial_debug_data(debug, &edge_port->port->dev, __func__, urb->actual_length, data);
1856 1854
1857 if (edge_port->close_pending) { 1855 if (edge_port->close_pending) {
1858 dbg ("%s - close is pending, dropping data on the floor.", __FUNCTION__); 1856 dbg ("%s - close is pending, dropping data on the floor.", __func__);
1859 } else { 1857 } else {
1860 edge_tty_recv(&edge_port->port->dev, tty, data, urb->actual_length); 1858 edge_tty_recv(&edge_port->port->dev, tty, data, urb->actual_length);
1861 } 1859 }
@@ -1874,7 +1872,7 @@ exit:
1874 spin_unlock(&edge_port->ep_lock); 1872 spin_unlock(&edge_port->ep_lock);
1875 if (retval) 1873 if (retval)
1876 dev_err (&urb->dev->dev, "%s - usb_submit_urb failed with result %d\n", 1874 dev_err (&urb->dev->dev, "%s - usb_submit_urb failed with result %d\n",
1877 __FUNCTION__, retval); 1875 __func__, retval);
1878} 1876}
1879 1877
1880static void edge_tty_recv(struct device *dev, struct tty_struct *tty, unsigned char *data, int length) 1878static void edge_tty_recv(struct device *dev, struct tty_struct *tty, unsigned char *data, int length)
@@ -1885,7 +1883,7 @@ static void edge_tty_recv(struct device *dev, struct tty_struct *tty, unsigned c
1885 cnt = tty_buffer_request_room(tty, length); 1883 cnt = tty_buffer_request_room(tty, length);
1886 if (cnt < length) { 1884 if (cnt < length) {
1887 dev_err(dev, "%s - dropping data, %d bytes lost\n", 1885 dev_err(dev, "%s - dropping data, %d bytes lost\n",
1888 __FUNCTION__, length - cnt); 1886 __func__, length - cnt);
1889 if(cnt == 0) 1887 if(cnt == 0)
1890 break; 1888 break;
1891 } 1889 }
@@ -1899,11 +1897,11 @@ static void edge_tty_recv(struct device *dev, struct tty_struct *tty, unsigned c
1899 1897
1900static void edge_bulk_out_callback (struct urb *urb) 1898static void edge_bulk_out_callback (struct urb *urb)
1901{ 1899{
1902 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 1900 struct usb_serial_port *port = urb->context;
1903 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 1901 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
1904 int status = urb->status; 1902 int status = urb->status;
1905 1903
1906 dbg ("%s - port %d", __FUNCTION__, port->number); 1904 dbg ("%s - port %d", __func__, port->number);
1907 1905
1908 edge_port->ep_write_urb_in_use = 0; 1906 edge_port->ep_write_urb_in_use = 0;
1909 1907
@@ -1916,11 +1914,11 @@ static void edge_bulk_out_callback (struct urb *urb)
1916 case -ESHUTDOWN: 1914 case -ESHUTDOWN:
1917 /* this urb is terminated, clean up */ 1915 /* this urb is terminated, clean up */
1918 dbg("%s - urb shutting down with status: %d", 1916 dbg("%s - urb shutting down with status: %d",
1919 __FUNCTION__, status); 1917 __func__, status);
1920 return; 1918 return;
1921 default: 1919 default:
1922 dev_err(&urb->dev->dev, "%s - nonzero write bulk status " 1920 dev_err(&urb->dev->dev, "%s - nonzero write bulk status "
1923 "received: %d\n", __FUNCTION__, status); 1921 "received: %d\n", __func__, status);
1924 } 1922 }
1925 1923
1926 /* send any buffered data */ 1924 /* send any buffered data */
@@ -1938,13 +1936,12 @@ static int edge_open (struct usb_serial_port *port, struct file * filp)
1938 u16 open_settings; 1936 u16 open_settings;
1939 u8 transaction_timeout; 1937 u8 transaction_timeout;
1940 1938
1941 dbg("%s - port %d", __FUNCTION__, port->number); 1939 dbg("%s - port %d", __func__, port->number);
1942 1940
1943 if (edge_port == NULL) 1941 if (edge_port == NULL)
1944 return -ENODEV; 1942 return -ENODEV;
1945 1943
1946 if (port->tty) 1944 port->tty->low_latency = low_latency;
1947 port->tty->low_latency = low_latency;
1948 1945
1949 port_number = port->number - port->serial->minor; 1946 port_number = port->number - port->serial->minor;
1950 switch (port_number) { 1947 switch (port_number) {
@@ -1962,7 +1959,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp)
1962 } 1959 }
1963 1960
1964 dbg ("%s - port_number = %d, uart_base = %04x, dma_address = %04x", 1961 dbg ("%s - port_number = %d, uart_base = %04x, dma_address = %04x",
1965 __FUNCTION__, port_number, edge_port->uart_base, edge_port->dma_address); 1962 __func__, port_number, edge_port->uart_base, edge_port->dma_address);
1966 1963
1967 dev = port->serial->dev; 1964 dev = port->serial->dev;
1968 1965
@@ -1973,7 +1970,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp)
1973 status = TIClearLoopBack (edge_port); 1970 status = TIClearLoopBack (edge_port);
1974 if (status) { 1971 if (status) {
1975 dev_err(&port->dev,"%s - cannot send clear loopback command, %d\n", 1972 dev_err(&port->dev,"%s - cannot send clear loopback command, %d\n",
1976 __FUNCTION__, status); 1973 __func__, status);
1977 return status; 1974 return status;
1978 } 1975 }
1979 1976
@@ -1992,7 +1989,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp)
1992 UMP_PIPE_TRANS_TIMEOUT_ENA | 1989 UMP_PIPE_TRANS_TIMEOUT_ENA |
1993 (transaction_timeout << 2)); 1990 (transaction_timeout << 2));
1994 1991
1995 dbg ("%s - Sending UMPC_OPEN_PORT", __FUNCTION__); 1992 dbg ("%s - Sending UMPC_OPEN_PORT", __func__);
1996 1993
1997 /* Tell TI to open and start the port */ 1994 /* Tell TI to open and start the port */
1998 status = TIWriteCommandSync (dev, 1995 status = TIWriteCommandSync (dev,
@@ -2002,7 +1999,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp)
2002 NULL, 1999 NULL,
2003 0); 2000 0);
2004 if (status) { 2001 if (status) {
2005 dev_err(&port->dev,"%s - cannot send open command, %d\n", __FUNCTION__, status); 2002 dev_err(&port->dev,"%s - cannot send open command, %d\n", __func__, status);
2006 return status; 2003 return status;
2007 } 2004 }
2008 2005
@@ -2014,14 +2011,14 @@ static int edge_open (struct usb_serial_port *port, struct file * filp)
2014 NULL, 2011 NULL,
2015 0); 2012 0);
2016 if (status) { 2013 if (status) {
2017 dev_err(&port->dev,"%s - cannot send start DMA command, %d\n", __FUNCTION__, status); 2014 dev_err(&port->dev,"%s - cannot send start DMA command, %d\n", __func__, status);
2018 return status; 2015 return status;
2019 } 2016 }
2020 2017
2021 /* Clear TX and RX buffers in UMP */ 2018 /* Clear TX and RX buffers in UMP */
2022 status = TIPurgeDataSync (port, UMP_PORT_DIR_OUT | UMP_PORT_DIR_IN); 2019 status = TIPurgeDataSync (port, UMP_PORT_DIR_OUT | UMP_PORT_DIR_IN);
2023 if (status) { 2020 if (status) {
2024 dev_err(&port->dev,"%s - cannot send clear buffers command, %d\n", __FUNCTION__, status); 2021 dev_err(&port->dev,"%s - cannot send clear buffers command, %d\n", __func__, status);
2025 return status; 2022 return status;
2026 } 2023 }
2027 2024
@@ -2033,7 +2030,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp)
2033 &edge_port->shadow_msr, // TransferBuffer 2030 &edge_port->shadow_msr, // TransferBuffer
2034 1); // TransferBufferLength 2031 1); // TransferBufferLength
2035 if (status) { 2032 if (status) {
2036 dev_err(&port->dev,"%s - cannot send read MSR command, %d\n", __FUNCTION__, status); 2033 dev_err(&port->dev,"%s - cannot send read MSR command, %d\n", __func__, status);
2037 return status; 2034 return status;
2038 } 2035 }
2039 2036
@@ -2050,7 +2047,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp)
2050 /* we are the first port to be opened, let's post the interrupt urb */ 2047 /* we are the first port to be opened, let's post the interrupt urb */
2051 urb = edge_serial->serial->port[0]->interrupt_in_urb; 2048 urb = edge_serial->serial->port[0]->interrupt_in_urb;
2052 if (!urb) { 2049 if (!urb) {
2053 dev_err (&port->dev, "%s - no interrupt urb present, exiting\n", __FUNCTION__); 2050 dev_err (&port->dev, "%s - no interrupt urb present, exiting\n", __func__);
2054 status = -EINVAL; 2051 status = -EINVAL;
2055 goto release_es_lock; 2052 goto release_es_lock;
2056 } 2053 }
@@ -2059,7 +2056,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp)
2059 urb->dev = dev; 2056 urb->dev = dev;
2060 status = usb_submit_urb (urb, GFP_KERNEL); 2057 status = usb_submit_urb (urb, GFP_KERNEL);
2061 if (status) { 2058 if (status) {
2062 dev_err (&port->dev, "%s - usb_submit_urb failed with value %d\n", __FUNCTION__, status); 2059 dev_err (&port->dev, "%s - usb_submit_urb failed with value %d\n", __func__, status);
2063 goto release_es_lock; 2060 goto release_es_lock;
2064 } 2061 }
2065 } 2062 }
@@ -2074,7 +2071,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp)
2074 /* start up our bulk read urb */ 2071 /* start up our bulk read urb */
2075 urb = port->read_urb; 2072 urb = port->read_urb;
2076 if (!urb) { 2073 if (!urb) {
2077 dev_err (&port->dev, "%s - no read urb present, exiting\n", __FUNCTION__); 2074 dev_err (&port->dev, "%s - no read urb present, exiting\n", __func__);
2078 status = -EINVAL; 2075 status = -EINVAL;
2079 goto unlink_int_urb; 2076 goto unlink_int_urb;
2080 } 2077 }
@@ -2084,13 +2081,13 @@ static int edge_open (struct usb_serial_port *port, struct file * filp)
2084 urb->dev = dev; 2081 urb->dev = dev;
2085 status = usb_submit_urb (urb, GFP_KERNEL); 2082 status = usb_submit_urb (urb, GFP_KERNEL);
2086 if (status) { 2083 if (status) {
2087 dev_err (&port->dev, "%s - read bulk usb_submit_urb failed with value %d\n", __FUNCTION__, status); 2084 dev_err (&port->dev, "%s - read bulk usb_submit_urb failed with value %d\n", __func__, status);
2088 goto unlink_int_urb; 2085 goto unlink_int_urb;
2089 } 2086 }
2090 2087
2091 ++edge_serial->num_ports_open; 2088 ++edge_serial->num_ports_open;
2092 2089
2093 dbg("%s - exited", __FUNCTION__); 2090 dbg("%s - exited", __func__);
2094 2091
2095 goto release_es_lock; 2092 goto release_es_lock;
2096 2093
@@ -2109,7 +2106,7 @@ static void edge_close (struct usb_serial_port *port, struct file *filp)
2109 int port_number; 2106 int port_number;
2110 int status; 2107 int status;
2111 2108
2112 dbg("%s - port %d", __FUNCTION__, port->number); 2109 dbg("%s - port %d", __func__, port->number);
2113 2110
2114 edge_serial = usb_get_serial_data(port->serial); 2111 edge_serial = usb_get_serial_data(port->serial);
2115 edge_port = usb_get_serial_port_data(port); 2112 edge_port = usb_get_serial_port_data(port);
@@ -2129,7 +2126,7 @@ static void edge_close (struct usb_serial_port *port, struct file *filp)
2129 2126
2130 /* assuming we can still talk to the device, 2127 /* assuming we can still talk to the device,
2131 * send a close port command to it */ 2128 * send a close port command to it */
2132 dbg("%s - send umpc_close_port", __FUNCTION__); 2129 dbg("%s - send umpc_close_port", __func__);
2133 port_number = port->number - port->serial->minor; 2130 port_number = port->number - port->serial->minor;
2134 status = TIWriteCommandSync (port->serial->dev, 2131 status = TIWriteCommandSync (port->serial->dev,
2135 UMPC_CLOSE_PORT, 2132 UMPC_CLOSE_PORT,
@@ -2147,7 +2144,7 @@ static void edge_close (struct usb_serial_port *port, struct file *filp)
2147 mutex_unlock(&edge_serial->es_lock); 2144 mutex_unlock(&edge_serial->es_lock);
2148 edge_port->close_pending = 0; 2145 edge_port->close_pending = 0;
2149 2146
2150 dbg("%s - exited", __FUNCTION__); 2147 dbg("%s - exited", __func__);
2151} 2148}
2152 2149
2153static int edge_write (struct usb_serial_port *port, const unsigned char *data, int count) 2150static int edge_write (struct usb_serial_port *port, const unsigned char *data, int count)
@@ -2155,10 +2152,10 @@ static int edge_write (struct usb_serial_port *port, const unsigned char *data,
2155 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 2152 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
2156 unsigned long flags; 2153 unsigned long flags;
2157 2154
2158 dbg("%s - port %d", __FUNCTION__, port->number); 2155 dbg("%s - port %d", __func__, port->number);
2159 2156
2160 if (count == 0) { 2157 if (count == 0) {
2161 dbg("%s - write request of 0 bytes", __FUNCTION__); 2158 dbg("%s - write request of 0 bytes", __func__);
2162 return 0; 2159 return 0;
2163 } 2160 }
2164 2161
@@ -2184,7 +2181,7 @@ static void edge_send(struct usb_serial_port *port)
2184 unsigned long flags; 2181 unsigned long flags;
2185 2182
2186 2183
2187 dbg("%s - port %d", __FUNCTION__, port->number); 2184 dbg("%s - port %d", __func__, port->number);
2188 2185
2189 spin_lock_irqsave(&edge_port->ep_lock, flags); 2186 spin_lock_irqsave(&edge_port->ep_lock, flags);
2190 2187
@@ -2206,7 +2203,7 @@ static void edge_send(struct usb_serial_port *port)
2206 2203
2207 spin_unlock_irqrestore(&edge_port->ep_lock, flags); 2204 spin_unlock_irqrestore(&edge_port->ep_lock, flags);
2208 2205
2209 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count, port->write_urb->transfer_buffer); 2206 usb_serial_debug_data(debug, &port->dev, __func__, count, port->write_urb->transfer_buffer);
2210 2207
2211 /* set up our urb */ 2208 /* set up our urb */
2212 usb_fill_bulk_urb (port->write_urb, port->serial->dev, 2209 usb_fill_bulk_urb (port->write_urb, port->serial->dev,
@@ -2219,7 +2216,7 @@ static void edge_send(struct usb_serial_port *port)
2219 /* send the data out the bulk port */ 2216 /* send the data out the bulk port */
2220 result = usb_submit_urb(port->write_urb, GFP_ATOMIC); 2217 result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
2221 if (result) { 2218 if (result) {
2222 dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __FUNCTION__, result); 2219 dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __func__, result);
2223 edge_port->ep_write_urb_in_use = 0; 2220 edge_port->ep_write_urb_in_use = 0;
2224 // TODO: reschedule edge_send 2221 // TODO: reschedule edge_send
2225 } else { 2222 } else {
@@ -2240,7 +2237,7 @@ static int edge_write_room (struct usb_serial_port *port)
2240 int room = 0; 2237 int room = 0;
2241 unsigned long flags; 2238 unsigned long flags;
2242 2239
2243 dbg("%s - port %d", __FUNCTION__, port->number); 2240 dbg("%s - port %d", __func__, port->number);
2244 2241
2245 if (edge_port == NULL) 2242 if (edge_port == NULL)
2246 return -ENODEV; 2243 return -ENODEV;
@@ -2251,7 +2248,7 @@ static int edge_write_room (struct usb_serial_port *port)
2251 room = edge_buf_space_avail(edge_port->ep_out_buf); 2248 room = edge_buf_space_avail(edge_port->ep_out_buf);
2252 spin_unlock_irqrestore(&edge_port->ep_lock, flags); 2249 spin_unlock_irqrestore(&edge_port->ep_lock, flags);
2253 2250
2254 dbg("%s - returns %d", __FUNCTION__, room); 2251 dbg("%s - returns %d", __func__, room);
2255 return room; 2252 return room;
2256} 2253}
2257 2254
@@ -2261,7 +2258,7 @@ static int edge_chars_in_buffer (struct usb_serial_port *port)
2261 int chars = 0; 2258 int chars = 0;
2262 unsigned long flags; 2259 unsigned long flags;
2263 2260
2264 dbg("%s - port %d", __FUNCTION__, port->number); 2261 dbg("%s - port %d", __func__, port->number);
2265 2262
2266 if (edge_port == NULL) 2263 if (edge_port == NULL)
2267 return -ENODEV; 2264 return -ENODEV;
@@ -2272,7 +2269,7 @@ static int edge_chars_in_buffer (struct usb_serial_port *port)
2272 chars = edge_buf_data_avail(edge_port->ep_out_buf); 2269 chars = edge_buf_data_avail(edge_port->ep_out_buf);
2273 spin_unlock_irqrestore(&edge_port->ep_lock, flags); 2270 spin_unlock_irqrestore(&edge_port->ep_lock, flags);
2274 2271
2275 dbg ("%s - returns %d", __FUNCTION__, chars); 2272 dbg ("%s - returns %d", __func__, chars);
2276 return chars; 2273 return chars;
2277} 2274}
2278 2275
@@ -2282,14 +2279,14 @@ static void edge_throttle (struct usb_serial_port *port)
2282 struct tty_struct *tty; 2279 struct tty_struct *tty;
2283 int status; 2280 int status;
2284 2281
2285 dbg("%s - port %d", __FUNCTION__, port->number); 2282 dbg("%s - port %d", __func__, port->number);
2286 2283
2287 if (edge_port == NULL) 2284 if (edge_port == NULL)
2288 return; 2285 return;
2289 2286
2290 tty = port->tty; 2287 tty = port->tty;
2291 if (!tty) { 2288 if (!tty) {
2292 dbg ("%s - no tty available", __FUNCTION__); 2289 dbg ("%s - no tty available", __func__);
2293 return; 2290 return;
2294 } 2291 }
2295 2292
@@ -2298,7 +2295,7 @@ static void edge_throttle (struct usb_serial_port *port)
2298 unsigned char stop_char = STOP_CHAR(tty); 2295 unsigned char stop_char = STOP_CHAR(tty);
2299 status = edge_write (port, &stop_char, 1); 2296 status = edge_write (port, &stop_char, 1);
2300 if (status <= 0) { 2297 if (status <= 0) {
2301 dev_err(&port->dev, "%s - failed to write stop character, %d\n", __FUNCTION__, status); 2298 dev_err(&port->dev, "%s - failed to write stop character, %d\n", __func__, status);
2302 } 2299 }
2303 } 2300 }
2304 2301
@@ -2315,14 +2312,14 @@ static void edge_unthrottle (struct usb_serial_port *port)
2315 struct tty_struct *tty; 2312 struct tty_struct *tty;
2316 int status; 2313 int status;
2317 2314
2318 dbg("%s - port %d", __FUNCTION__, port->number); 2315 dbg("%s - port %d", __func__, port->number);
2319 2316
2320 if (edge_port == NULL) 2317 if (edge_port == NULL)
2321 return; 2318 return;
2322 2319
2323 tty = port->tty; 2320 tty = port->tty;
2324 if (!tty) { 2321 if (!tty) {
2325 dbg ("%s - no tty available", __FUNCTION__); 2322 dbg ("%s - no tty available", __func__);
2326 return; 2323 return;
2327 } 2324 }
2328 2325
@@ -2331,7 +2328,7 @@ static void edge_unthrottle (struct usb_serial_port *port)
2331 unsigned char start_char = START_CHAR(tty); 2328 unsigned char start_char = START_CHAR(tty);
2332 status = edge_write (port, &start_char, 1); 2329 status = edge_write (port, &start_char, 1);
2333 if (status <= 0) { 2330 if (status <= 0) {
2334 dev_err(&port->dev, "%s - failed to write start character, %d\n", __FUNCTION__, status); 2331 dev_err(&port->dev, "%s - failed to write start character, %d\n", __func__, status);
2335 } 2332 }
2336 } 2333 }
2337 2334
@@ -2340,7 +2337,7 @@ static void edge_unthrottle (struct usb_serial_port *port)
2340 if (C_CRTSCTS(tty)) { 2337 if (C_CRTSCTS(tty)) {
2341 status = restart_read(edge_port); 2338 status = restart_read(edge_port);
2342 if (status) 2339 if (status)
2343 dev_err(&port->dev, "%s - read bulk usb_submit_urb failed with value %d\n", __FUNCTION__, status); 2340 dev_err(&port->dev, "%s - read bulk usb_submit_urb failed with value %d\n", __func__, status);
2344 } 2341 }
2345 2342
2346} 2343}
@@ -2390,13 +2387,13 @@ static void change_port_settings (struct edgeport_port *edge_port, struct ktermi
2390 int status; 2387 int status;
2391 int port_number = edge_port->port->number - edge_port->port->serial->minor; 2388 int port_number = edge_port->port->number - edge_port->port->serial->minor;
2392 2389
2393 dbg("%s - port %d", __FUNCTION__, edge_port->port->number); 2390 dbg("%s - port %d", __func__, edge_port->port->number);
2394 2391
2395 tty = edge_port->port->tty; 2392 tty = edge_port->port->tty;
2396 2393
2397 config = kmalloc (sizeof (*config), GFP_KERNEL); 2394 config = kmalloc (sizeof (*config), GFP_KERNEL);
2398 if (!config) { 2395 if (!config) {
2399 dev_err (&edge_port->port->dev, "%s - out of memory\n", __FUNCTION__); 2396 dev_err (&edge_port->port->dev, "%s - out of memory\n", __func__);
2400 return; 2397 return;
2401 } 2398 }
2402 2399
@@ -2412,20 +2409,20 @@ static void change_port_settings (struct edgeport_port *edge_port, struct ktermi
2412 switch (cflag & CSIZE) { 2409 switch (cflag & CSIZE) {
2413 case CS5: 2410 case CS5:
2414 config->bDataBits = UMP_UART_CHAR5BITS; 2411 config->bDataBits = UMP_UART_CHAR5BITS;
2415 dbg ("%s - data bits = 5", __FUNCTION__); 2412 dbg ("%s - data bits = 5", __func__);
2416 break; 2413 break;
2417 case CS6: 2414 case CS6:
2418 config->bDataBits = UMP_UART_CHAR6BITS; 2415 config->bDataBits = UMP_UART_CHAR6BITS;
2419 dbg ("%s - data bits = 6", __FUNCTION__); 2416 dbg ("%s - data bits = 6", __func__);
2420 break; 2417 break;
2421 case CS7: 2418 case CS7:
2422 config->bDataBits = UMP_UART_CHAR7BITS; 2419 config->bDataBits = UMP_UART_CHAR7BITS;
2423 dbg ("%s - data bits = 7", __FUNCTION__); 2420 dbg ("%s - data bits = 7", __func__);
2424 break; 2421 break;
2425 default: 2422 default:
2426 case CS8: 2423 case CS8:
2427 config->bDataBits = UMP_UART_CHAR8BITS; 2424 config->bDataBits = UMP_UART_CHAR8BITS;
2428 dbg ("%s - data bits = 8", __FUNCTION__); 2425 dbg ("%s - data bits = 8", __func__);
2429 break; 2426 break;
2430 } 2427 }
2431 2428
@@ -2433,32 +2430,32 @@ static void change_port_settings (struct edgeport_port *edge_port, struct ktermi
2433 if (cflag & PARODD) { 2430 if (cflag & PARODD) {
2434 config->wFlags |= UMP_MASK_UART_FLAGS_PARITY; 2431 config->wFlags |= UMP_MASK_UART_FLAGS_PARITY;
2435 config->bParity = UMP_UART_ODDPARITY; 2432 config->bParity = UMP_UART_ODDPARITY;
2436 dbg("%s - parity = odd", __FUNCTION__); 2433 dbg("%s - parity = odd", __func__);
2437 } else { 2434 } else {
2438 config->wFlags |= UMP_MASK_UART_FLAGS_PARITY; 2435 config->wFlags |= UMP_MASK_UART_FLAGS_PARITY;
2439 config->bParity = UMP_UART_EVENPARITY; 2436 config->bParity = UMP_UART_EVENPARITY;
2440 dbg("%s - parity = even", __FUNCTION__); 2437 dbg("%s - parity = even", __func__);
2441 } 2438 }
2442 } else { 2439 } else {
2443 config->bParity = UMP_UART_NOPARITY; 2440 config->bParity = UMP_UART_NOPARITY;
2444 dbg("%s - parity = none", __FUNCTION__); 2441 dbg("%s - parity = none", __func__);
2445 } 2442 }
2446 2443
2447 if (cflag & CSTOPB) { 2444 if (cflag & CSTOPB) {
2448 config->bStopBits = UMP_UART_STOPBIT2; 2445 config->bStopBits = UMP_UART_STOPBIT2;
2449 dbg("%s - stop bits = 2", __FUNCTION__); 2446 dbg("%s - stop bits = 2", __func__);
2450 } else { 2447 } else {
2451 config->bStopBits = UMP_UART_STOPBIT1; 2448 config->bStopBits = UMP_UART_STOPBIT1;
2452 dbg("%s - stop bits = 1", __FUNCTION__); 2449 dbg("%s - stop bits = 1", __func__);
2453 } 2450 }
2454 2451
2455 /* figure out the flow control settings */ 2452 /* figure out the flow control settings */
2456 if (cflag & CRTSCTS) { 2453 if (cflag & CRTSCTS) {
2457 config->wFlags |= UMP_MASK_UART_FLAGS_OUT_X_CTS_FLOW; 2454 config->wFlags |= UMP_MASK_UART_FLAGS_OUT_X_CTS_FLOW;
2458 config->wFlags |= UMP_MASK_UART_FLAGS_RTS_FLOW; 2455 config->wFlags |= UMP_MASK_UART_FLAGS_RTS_FLOW;
2459 dbg("%s - RTS/CTS is enabled", __FUNCTION__); 2456 dbg("%s - RTS/CTS is enabled", __func__);
2460 } else { 2457 } else {
2461 dbg("%s - RTS/CTS is disabled", __FUNCTION__); 2458 dbg("%s - RTS/CTS is disabled", __func__);
2462 tty->hw_stopped = 0; 2459 tty->hw_stopped = 0;
2463 restart_read(edge_port); 2460 restart_read(edge_port);
2464 } 2461 }
@@ -2472,18 +2469,18 @@ static void change_port_settings (struct edgeport_port *edge_port, struct ktermi
2472 if (I_IXOFF(tty)) { 2469 if (I_IXOFF(tty)) {
2473 config->wFlags |= UMP_MASK_UART_FLAGS_IN_X; 2470 config->wFlags |= UMP_MASK_UART_FLAGS_IN_X;
2474 dbg ("%s - INBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x", 2471 dbg ("%s - INBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x",
2475 __FUNCTION__, config->cXon, config->cXoff); 2472 __func__, config->cXon, config->cXoff);
2476 } else { 2473 } else {
2477 dbg ("%s - INBOUND XON/XOFF is disabled", __FUNCTION__); 2474 dbg ("%s - INBOUND XON/XOFF is disabled", __func__);
2478 } 2475 }
2479 2476
2480 /* if we are implementing OUTBOUND XON/XOFF */ 2477 /* if we are implementing OUTBOUND XON/XOFF */
2481 if (I_IXON(tty)) { 2478 if (I_IXON(tty)) {
2482 config->wFlags |= UMP_MASK_UART_FLAGS_OUT_X; 2479 config->wFlags |= UMP_MASK_UART_FLAGS_OUT_X;
2483 dbg ("%s - OUTBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x", 2480 dbg ("%s - OUTBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x",
2484 __FUNCTION__, config->cXon, config->cXoff); 2481 __func__, config->cXon, config->cXoff);
2485 } else { 2482 } else {
2486 dbg ("%s - OUTBOUND XON/XOFF is disabled", __FUNCTION__); 2483 dbg ("%s - OUTBOUND XON/XOFF is disabled", __func__);
2487 } 2484 }
2488 } 2485 }
2489 2486
@@ -2502,7 +2499,7 @@ static void change_port_settings (struct edgeport_port *edge_port, struct ktermi
2502 2499
2503 /* FIXME: Recompute actual baud from divisor here */ 2500 /* FIXME: Recompute actual baud from divisor here */
2504 2501
2505 dbg ("%s - baud rate = %d, wBaudRate = %d", __FUNCTION__, baud, config->wBaudRate); 2502 dbg ("%s - baud rate = %d, wBaudRate = %d", __func__, baud, config->wBaudRate);
2506 2503
2507 dbg ("wBaudRate: %d", (int)(461550L / config->wBaudRate)); 2504 dbg ("wBaudRate: %d", (int)(461550L / config->wBaudRate));
2508 dbg ("wFlags: 0x%x", config->wFlags); 2505 dbg ("wFlags: 0x%x", config->wFlags);
@@ -2525,7 +2522,7 @@ static void change_port_settings (struct edgeport_port *edge_port, struct ktermi
2525 sizeof(*config)); 2522 sizeof(*config));
2526 if (status) { 2523 if (status) {
2527 dbg ("%s - error %d when trying to write config to device", 2524 dbg ("%s - error %d when trying to write config to device",
2528 __FUNCTION__, status); 2525 __func__, status);
2529 } 2526 }
2530 2527
2531 kfree (config); 2528 kfree (config);
@@ -2541,12 +2538,12 @@ static void edge_set_termios (struct usb_serial_port *port, struct ktermios *old
2541 2538
2542 cflag = tty->termios->c_cflag; 2539 cflag = tty->termios->c_cflag;
2543 2540
2544 dbg("%s - clfag %08x iflag %08x", __FUNCTION__, 2541 dbg("%s - clfag %08x iflag %08x", __func__,
2545 tty->termios->c_cflag, tty->termios->c_iflag); 2542 tty->termios->c_cflag, tty->termios->c_iflag);
2546 dbg("%s - old clfag %08x old iflag %08x", __FUNCTION__, 2543 dbg("%s - old clfag %08x old iflag %08x", __func__,
2547 old_termios->c_cflag, old_termios->c_iflag); 2544 old_termios->c_cflag, old_termios->c_iflag);
2548 2545
2549 dbg("%s - port %d", __FUNCTION__, port->number); 2546 dbg("%s - port %d", __func__, port->number);
2550 2547
2551 if (edge_port == NULL) 2548 if (edge_port == NULL)
2552 return; 2549 return;
@@ -2561,9 +2558,11 @@ static int edge_tiocmset (struct usb_serial_port *port, struct file *file, unsig
2561{ 2558{
2562 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 2559 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
2563 unsigned int mcr; 2560 unsigned int mcr;
2561 unsigned long flags;
2564 2562
2565 dbg("%s - port %d", __FUNCTION__, port->number); 2563 dbg("%s - port %d", __func__, port->number);
2566 2564
2565 spin_lock_irqsave(&edge_port->ep_lock, flags);
2567 mcr = edge_port->shadow_mcr; 2566 mcr = edge_port->shadow_mcr;
2568 if (set & TIOCM_RTS) 2567 if (set & TIOCM_RTS)
2569 mcr |= MCR_RTS; 2568 mcr |= MCR_RTS;
@@ -2580,6 +2579,7 @@ static int edge_tiocmset (struct usb_serial_port *port, struct file *file, unsig
2580 mcr &= ~MCR_LOOPBACK; 2579 mcr &= ~MCR_LOOPBACK;
2581 2580
2582 edge_port->shadow_mcr = mcr; 2581 edge_port->shadow_mcr = mcr;
2582 spin_unlock_irqrestore(&edge_port->ep_lock, flags);
2583 2583
2584 TIRestoreMCR (edge_port, mcr); 2584 TIRestoreMCR (edge_port, mcr);
2585 2585
@@ -2592,8 +2592,11 @@ static int edge_tiocmget(struct usb_serial_port *port, struct file *file)
2592 unsigned int result = 0; 2592 unsigned int result = 0;
2593 unsigned int msr; 2593 unsigned int msr;
2594 unsigned int mcr; 2594 unsigned int mcr;
2595 unsigned long flags;
2595 2596
2596 dbg("%s - port %d", __FUNCTION__, port->number); 2597 dbg("%s - port %d", __func__, port->number);
2598
2599 spin_lock_irqsave(&edge_port->ep_lock, flags);
2597 2600
2598 msr = edge_port->shadow_msr; 2601 msr = edge_port->shadow_msr;
2599 mcr = edge_port->shadow_mcr; 2602 mcr = edge_port->shadow_mcr;
@@ -2605,7 +2608,8 @@ static int edge_tiocmget(struct usb_serial_port *port, struct file *file)
2605 | ((msr & EDGEPORT_MSR_DSR) ? TIOCM_DSR: 0); /* 0x100 */ 2608 | ((msr & EDGEPORT_MSR_DSR) ? TIOCM_DSR: 0); /* 0x100 */
2606 2609
2607 2610
2608 dbg("%s -- %x", __FUNCTION__, result); 2611 dbg("%s -- %x", __func__, result);
2612 spin_unlock_irqrestore(&edge_port->ep_lock, flags);
2609 2613
2610 return result; 2614 return result;
2611} 2615}
@@ -2644,30 +2648,30 @@ static int edge_ioctl (struct usb_serial_port *port, struct file *file, unsigned
2644 struct async_icount cnow; 2648 struct async_icount cnow;
2645 struct async_icount cprev; 2649 struct async_icount cprev;
2646 2650
2647 dbg("%s - port %d, cmd = 0x%x", __FUNCTION__, port->number, cmd); 2651 dbg("%s - port %d, cmd = 0x%x", __func__, port->number, cmd);
2648 2652
2649 switch (cmd) { 2653 switch (cmd) {
2650 case TIOCINQ: 2654 case TIOCINQ:
2651 dbg("%s - (%d) TIOCINQ", __FUNCTION__, port->number); 2655 dbg("%s - (%d) TIOCINQ", __func__, port->number);
2652// return get_number_bytes_avail(edge_port, (unsigned int *) arg); 2656// return get_number_bytes_avail(edge_port, (unsigned int *) arg);
2653 break; 2657 break;
2654 2658
2655 case TIOCSERGETLSR: 2659 case TIOCSERGETLSR:
2656 dbg("%s - (%d) TIOCSERGETLSR", __FUNCTION__, port->number); 2660 dbg("%s - (%d) TIOCSERGETLSR", __func__, port->number);
2657// return get_lsr_info(edge_port, (unsigned int *) arg); 2661// return get_lsr_info(edge_port, (unsigned int *) arg);
2658 break; 2662 break;
2659 2663
2660 case TIOCGSERIAL: 2664 case TIOCGSERIAL:
2661 dbg("%s - (%d) TIOCGSERIAL", __FUNCTION__, port->number); 2665 dbg("%s - (%d) TIOCGSERIAL", __func__, port->number);
2662 return get_serial_info(edge_port, (struct serial_struct __user *) arg); 2666 return get_serial_info(edge_port, (struct serial_struct __user *) arg);
2663 break; 2667 break;
2664 2668
2665 case TIOCSSERIAL: 2669 case TIOCSSERIAL:
2666 dbg("%s - (%d) TIOCSSERIAL", __FUNCTION__, port->number); 2670 dbg("%s - (%d) TIOCSSERIAL", __func__, port->number);
2667 break; 2671 break;
2668 2672
2669 case TIOCMIWAIT: 2673 case TIOCMIWAIT:
2670 dbg("%s - (%d) TIOCMIWAIT", __FUNCTION__, port->number); 2674 dbg("%s - (%d) TIOCMIWAIT", __func__, port->number);
2671 cprev = edge_port->icount; 2675 cprev = edge_port->icount;
2672 while (1) { 2676 while (1) {
2673 interruptible_sleep_on(&edge_port->delta_msr_wait); 2677 interruptible_sleep_on(&edge_port->delta_msr_wait);
@@ -2690,7 +2694,7 @@ static int edge_ioctl (struct usb_serial_port *port, struct file *file, unsigned
2690 break; 2694 break;
2691 2695
2692 case TIOCGICOUNT: 2696 case TIOCGICOUNT:
2693 dbg ("%s - (%d) TIOCGICOUNT RX=%d, TX=%d", __FUNCTION__, 2697 dbg ("%s - (%d) TIOCGICOUNT RX=%d, TX=%d", __func__,
2694 port->number, edge_port->icount.rx, edge_port->icount.tx); 2698 port->number, edge_port->icount.rx, edge_port->icount.tx);
2695 if (copy_to_user((void __user *)arg, &edge_port->icount, sizeof(edge_port->icount))) 2699 if (copy_to_user((void __user *)arg, &edge_port->icount, sizeof(edge_port->icount)))
2696 return -EFAULT; 2700 return -EFAULT;
@@ -2705,7 +2709,7 @@ static void edge_break (struct usb_serial_port *port, int break_state)
2705 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 2709 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
2706 int status; 2710 int status;
2707 2711
2708 dbg ("%s - state = %d", __FUNCTION__, break_state); 2712 dbg ("%s - state = %d", __func__, break_state);
2709 2713
2710 /* chase the port close */ 2714 /* chase the port close */
2711 TIChasePort (edge_port, 0, 0); 2715 TIChasePort (edge_port, 0, 0);
@@ -2717,7 +2721,7 @@ static void edge_break (struct usb_serial_port *port, int break_state)
2717 } 2721 }
2718 if (status) { 2722 if (status) {
2719 dbg ("%s - error %d sending break set/clear command.", 2723 dbg ("%s - error %d sending break set/clear command.",
2720 __FUNCTION__, status); 2724 __func__, status);
2721 } 2725 }
2722} 2726}
2723 2727
@@ -2734,7 +2738,7 @@ static int edge_startup (struct usb_serial *serial)
2734 /* create our private serial structure */ 2738 /* create our private serial structure */
2735 edge_serial = kzalloc(sizeof(struct edgeport_serial), GFP_KERNEL); 2739 edge_serial = kzalloc(sizeof(struct edgeport_serial), GFP_KERNEL);
2736 if (edge_serial == NULL) { 2740 if (edge_serial == NULL) {
2737 dev_err(&serial->dev->dev, "%s - Out of memory\n", __FUNCTION__); 2741 dev_err(&serial->dev->dev, "%s - Out of memory\n", __func__);
2738 return -ENOMEM; 2742 return -ENOMEM;
2739 } 2743 }
2740 mutex_init(&edge_serial->es_lock); 2744 mutex_init(&edge_serial->es_lock);
@@ -2751,13 +2755,13 @@ static int edge_startup (struct usb_serial *serial)
2751 for (i = 0; i < serial->num_ports; ++i) { 2755 for (i = 0; i < serial->num_ports; ++i) {
2752 edge_port = kzalloc(sizeof(struct edgeport_port), GFP_KERNEL); 2756 edge_port = kzalloc(sizeof(struct edgeport_port), GFP_KERNEL);
2753 if (edge_port == NULL) { 2757 if (edge_port == NULL) {
2754 dev_err(&serial->dev->dev, "%s - Out of memory\n", __FUNCTION__); 2758 dev_err(&serial->dev->dev, "%s - Out of memory\n", __func__);
2755 goto cleanup; 2759 goto cleanup;
2756 } 2760 }
2757 spin_lock_init(&edge_port->ep_lock); 2761 spin_lock_init(&edge_port->ep_lock);
2758 edge_port->ep_out_buf = edge_buf_alloc(EDGE_OUT_BUF_SIZE); 2762 edge_port->ep_out_buf = edge_buf_alloc(EDGE_OUT_BUF_SIZE);
2759 if (edge_port->ep_out_buf == NULL) { 2763 if (edge_port->ep_out_buf == NULL) {
2760 dev_err(&serial->dev->dev, "%s - Out of memory\n", __FUNCTION__); 2764 dev_err(&serial->dev->dev, "%s - Out of memory\n", __func__);
2761 kfree(edge_port); 2765 kfree(edge_port);
2762 goto cleanup; 2766 goto cleanup;
2763 } 2767 }
@@ -2786,7 +2790,7 @@ static void edge_shutdown (struct usb_serial *serial)
2786 int i; 2790 int i;
2787 struct edgeport_port *edge_port; 2791 struct edgeport_port *edge_port;
2788 2792
2789 dbg ("%s", __FUNCTION__); 2793 dbg ("%s", __func__);
2790 2794
2791 for (i = 0; i < serial->num_ports; ++i) { 2795 for (i = 0; i < serial->num_ports; ++i) {
2792 edge_port = usb_get_serial_port_data(serial->port[i]); 2796 edge_port = usb_get_serial_port_data(serial->port[i]);
@@ -2818,12 +2822,12 @@ static ssize_t store_uart_mode(struct device *dev,
2818 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 2822 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
2819 unsigned int v = simple_strtoul(valbuf, NULL, 0); 2823 unsigned int v = simple_strtoul(valbuf, NULL, 0);
2820 2824
2821 dbg("%s: setting uart_mode = %d", __FUNCTION__, v); 2825 dbg("%s: setting uart_mode = %d", __func__, v);
2822 2826
2823 if (v < 256) 2827 if (v < 256)
2824 edge_port->bUartMode = v; 2828 edge_port->bUartMode = v;
2825 else 2829 else
2826 dev_err(dev, "%s - uart_mode %d is invalid\n", __FUNCTION__, v); 2830 dev_err(dev, "%s - uart_mode %d is invalid\n", __func__, v);
2827 2831
2828 return count; 2832 return count;
2829} 2833}
@@ -3028,9 +3032,6 @@ static struct usb_serial_driver edgeport_1port_device = {
3028 .description = "Edgeport TI 1 port adapter", 3032 .description = "Edgeport TI 1 port adapter",
3029 .usb_driver = &io_driver, 3033 .usb_driver = &io_driver,
3030 .id_table = edgeport_1port_id_table, 3034 .id_table = edgeport_1port_id_table,
3031 .num_interrupt_in = 1,
3032 .num_bulk_in = 1,
3033 .num_bulk_out = 1,
3034 .num_ports = 1, 3035 .num_ports = 1,
3035 .open = edge_open, 3036 .open = edge_open,
3036 .close = edge_close, 3037 .close = edge_close,
@@ -3060,9 +3061,6 @@ static struct usb_serial_driver edgeport_2port_device = {
3060 .description = "Edgeport TI 2 port adapter", 3061 .description = "Edgeport TI 2 port adapter",
3061 .usb_driver = &io_driver, 3062 .usb_driver = &io_driver,
3062 .id_table = edgeport_2port_id_table, 3063 .id_table = edgeport_2port_id_table,
3063 .num_interrupt_in = 1,
3064 .num_bulk_in = 2,
3065 .num_bulk_out = 2,
3066 .num_ports = 2, 3064 .num_ports = 2,
3067 .open = edge_open, 3065 .open = edge_open,
3068 .close = edge_close, 3066 .close = edge_close,
diff --git a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c
index 9b38a08ac83..ea924dc4849 100644
--- a/drivers/usb/serial/ipaq.c
+++ b/drivers/usb/serial/ipaq.c
@@ -570,10 +570,7 @@ static struct usb_serial_driver ipaq_device = {
570 .description = "PocketPC PDA", 570 .description = "PocketPC PDA",
571 .usb_driver = &ipaq_driver, 571 .usb_driver = &ipaq_driver,
572 .id_table = ipaq_id_table, 572 .id_table = ipaq_id_table,
573 .num_interrupt_in = NUM_DONT_CARE, 573 .num_ports = 2,
574 .num_bulk_in = 1,
575 .num_bulk_out = 1,
576 .num_ports = 1,
577 .open = ipaq_open, 574 .open = ipaq_open,
578 .close = ipaq_close, 575 .close = ipaq_close,
579 .attach = ipaq_startup, 576 .attach = ipaq_startup,
@@ -597,13 +594,13 @@ static int ipaq_open(struct usb_serial_port *port, struct file *filp)
597 int i, result = 0; 594 int i, result = 0;
598 int retries = connect_retries; 595 int retries = connect_retries;
599 596
600 dbg("%s - port %d", __FUNCTION__, port->number); 597 dbg("%s - port %d", __func__, port->number);
601 598
602 bytes_in = 0; 599 bytes_in = 0;
603 bytes_out = 0; 600 bytes_out = 0;
604 priv = kmalloc(sizeof(struct ipaq_private), GFP_KERNEL); 601 priv = kmalloc(sizeof(struct ipaq_private), GFP_KERNEL);
605 if (priv == NULL) { 602 if (priv == NULL) {
606 err("%s - Out of memory", __FUNCTION__); 603 err("%s - Out of memory", __func__);
607 return -ENOMEM; 604 return -ENOMEM;
608 } 605 }
609 usb_set_serial_port_data(port, priv); 606 usb_set_serial_port_data(port, priv);
@@ -682,7 +679,7 @@ static int ipaq_open(struct usb_serial_port *port, struct file *filp)
682 } 679 }
683 680
684 if (!retries && result) { 681 if (!retries && result) {
685 err("%s - failed doing control urb, error %d", __FUNCTION__, 682 err("%s - failed doing control urb, error %d", __func__,
686 result); 683 result);
687 goto error; 684 goto error;
688 } 685 }
@@ -695,7 +692,7 @@ static int ipaq_open(struct usb_serial_port *port, struct file *filp)
695 692
696 result = usb_submit_urb(port->read_urb, GFP_KERNEL); 693 result = usb_submit_urb(port->read_urb, GFP_KERNEL);
697 if (result) { 694 if (result) {
698 err("%s - failed submitting read urb, error %d", __FUNCTION__, result); 695 err("%s - failed submitting read urb, error %d", __func__, result);
699 goto error; 696 goto error;
700 } 697 }
701 698
@@ -703,7 +700,7 @@ static int ipaq_open(struct usb_serial_port *port, struct file *filp)
703 700
704enomem: 701enomem:
705 result = -ENOMEM; 702 result = -ENOMEM;
706 err("%s - Out of memory", __FUNCTION__); 703 err("%s - Out of memory", __func__);
707error: 704error:
708 ipaq_destroy_lists(port); 705 ipaq_destroy_lists(port);
709 kfree(priv); 706 kfree(priv);
@@ -715,7 +712,7 @@ static void ipaq_close(struct usb_serial_port *port, struct file *filp)
715{ 712{
716 struct ipaq_private *priv = usb_get_serial_port_data(port); 713 struct ipaq_private *priv = usb_get_serial_port_data(port);
717 714
718 dbg("%s - port %d", __FUNCTION__, port->number); 715 dbg("%s - port %d", __func__, port->number);
719 716
720 /* 717 /*
721 * shut down bulk read and write 718 * shut down bulk read and write
@@ -732,21 +729,21 @@ static void ipaq_close(struct usb_serial_port *port, struct file *filp)
732 729
733static void ipaq_read_bulk_callback(struct urb *urb) 730static void ipaq_read_bulk_callback(struct urb *urb)
734{ 731{
735 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 732 struct usb_serial_port *port = urb->context;
736 struct tty_struct *tty; 733 struct tty_struct *tty;
737 unsigned char *data = urb->transfer_buffer; 734 unsigned char *data = urb->transfer_buffer;
738 int result; 735 int result;
739 int status = urb->status; 736 int status = urb->status;
740 737
741 dbg("%s - port %d", __FUNCTION__, port->number); 738 dbg("%s - port %d", __func__, port->number);
742 739
743 if (status) { 740 if (status) {
744 dbg("%s - nonzero read bulk status received: %d", 741 dbg("%s - nonzero read bulk status received: %d",
745 __FUNCTION__, status); 742 __func__, status);
746 return; 743 return;
747 } 744 }
748 745
749 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, urb->actual_length, data); 746 usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data);
750 747
751 tty = port->tty; 748 tty = port->tty;
752 if (tty && urb->actual_length) { 749 if (tty && urb->actual_length) {
@@ -763,7 +760,7 @@ static void ipaq_read_bulk_callback(struct urb *urb)
763 ipaq_read_bulk_callback, port); 760 ipaq_read_bulk_callback, port);
764 result = usb_submit_urb(port->read_urb, GFP_ATOMIC); 761 result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
765 if (result) 762 if (result)
766 err("%s - failed resubmitting read urb, error %d", __FUNCTION__, result); 763 err("%s - failed resubmitting read urb, error %d", __func__, result);
767 return; 764 return;
768} 765}
769 766
@@ -774,7 +771,7 @@ static int ipaq_write(struct usb_serial_port *port, const unsigned char *buf,
774 int bytes_sent = 0; 771 int bytes_sent = 0;
775 int transfer_size; 772 int transfer_size;
776 773
777 dbg("%s - port %d", __FUNCTION__, port->number); 774 dbg("%s - port %d", __func__, port->number);
778 775
779 while (count > 0) { 776 while (count > 0) {
780 transfer_size = min(count, PACKET_SIZE); 777 transfer_size = min(count, PACKET_SIZE);
@@ -799,7 +796,7 @@ static int ipaq_write_bulk(struct usb_serial_port *port, const unsigned char *bu
799 unsigned long flags; 796 unsigned long flags;
800 797
801 if (priv->free_len <= 0) { 798 if (priv->free_len <= 0) {
802 dbg("%s - we're stuffed", __FUNCTION__); 799 dbg("%s - we're stuffed", __func__);
803 return -EAGAIN; 800 return -EAGAIN;
804 } 801 }
805 802
@@ -811,12 +808,12 @@ static int ipaq_write_bulk(struct usb_serial_port *port, const unsigned char *bu
811 } 808 }
812 spin_unlock_irqrestore(&write_list_lock, flags); 809 spin_unlock_irqrestore(&write_list_lock, flags);
813 if (pkt == NULL) { 810 if (pkt == NULL) {
814 dbg("%s - we're stuffed", __FUNCTION__); 811 dbg("%s - we're stuffed", __func__);
815 return -EAGAIN; 812 return -EAGAIN;
816 } 813 }
817 814
818 memcpy(pkt->data, buf, count); 815 memcpy(pkt->data, buf, count);
819 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count, pkt->data); 816 usb_serial_debug_data(debug, &port->dev, __func__, count, pkt->data);
820 817
821 pkt->len = count; 818 pkt->len = count;
822 pkt->written = 0; 819 pkt->written = 0;
@@ -829,7 +826,7 @@ static int ipaq_write_bulk(struct usb_serial_port *port, const unsigned char *bu
829 spin_unlock_irqrestore(&write_list_lock, flags); 826 spin_unlock_irqrestore(&write_list_lock, flags);
830 result = usb_submit_urb(port->write_urb, GFP_ATOMIC); 827 result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
831 if (result) { 828 if (result) {
832 err("%s - failed submitting write urb, error %d", __FUNCTION__, result); 829 err("%s - failed submitting write urb, error %d", __func__, result);
833 } 830 }
834 } else { 831 } else {
835 spin_unlock_irqrestore(&write_list_lock, flags); 832 spin_unlock_irqrestore(&write_list_lock, flags);
@@ -872,17 +869,17 @@ static void ipaq_write_gather(struct usb_serial_port *port)
872 869
873static void ipaq_write_bulk_callback(struct urb *urb) 870static void ipaq_write_bulk_callback(struct urb *urb)
874{ 871{
875 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 872 struct usb_serial_port *port = urb->context;
876 struct ipaq_private *priv = usb_get_serial_port_data(port); 873 struct ipaq_private *priv = usb_get_serial_port_data(port);
877 unsigned long flags; 874 unsigned long flags;
878 int result; 875 int result;
879 int status = urb->status; 876 int status = urb->status;
880 877
881 dbg("%s - port %d", __FUNCTION__, port->number); 878 dbg("%s - port %d", __func__, port->number);
882 879
883 if (status) { 880 if (status) {
884 dbg("%s - nonzero write bulk status received: %d", 881 dbg("%s - nonzero write bulk status received: %d",
885 __FUNCTION__, status); 882 __func__, status);
886 return; 883 return;
887 } 884 }
888 885
@@ -892,7 +889,7 @@ static void ipaq_write_bulk_callback(struct urb *urb)
892 spin_unlock_irqrestore(&write_list_lock, flags); 889 spin_unlock_irqrestore(&write_list_lock, flags);
893 result = usb_submit_urb(port->write_urb, GFP_ATOMIC); 890 result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
894 if (result) { 891 if (result) {
895 err("%s - failed submitting write urb, error %d", __FUNCTION__, result); 892 err("%s - failed submitting write urb, error %d", __func__, result);
896 } 893 }
897 } else { 894 } else {
898 priv->active = 0; 895 priv->active = 0;
@@ -906,7 +903,7 @@ static int ipaq_write_room(struct usb_serial_port *port)
906{ 903{
907 struct ipaq_private *priv = usb_get_serial_port_data(port); 904 struct ipaq_private *priv = usb_get_serial_port_data(port);
908 905
909 dbg("%s - freelen %d", __FUNCTION__, priv->free_len); 906 dbg("%s - freelen %d", __func__, priv->free_len);
910 return priv->free_len; 907 return priv->free_len;
911} 908}
912 909
@@ -914,7 +911,7 @@ static int ipaq_chars_in_buffer(struct usb_serial_port *port)
914{ 911{
915 struct ipaq_private *priv = usb_get_serial_port_data(port); 912 struct ipaq_private *priv = usb_get_serial_port_data(port);
916 913
917 dbg("%s - queuelen %d", __FUNCTION__, priv->queue_len); 914 dbg("%s - queuelen %d", __func__, priv->queue_len);
918 return priv->queue_len; 915 return priv->queue_len;
919} 916}
920 917
@@ -936,7 +933,7 @@ static void ipaq_destroy_lists(struct usb_serial_port *port)
936 933
937static int ipaq_startup(struct usb_serial *serial) 934static int ipaq_startup(struct usb_serial *serial)
938{ 935{
939 dbg("%s", __FUNCTION__); 936 dbg("%s", __func__);
940 if (serial->dev->actconfig->desc.bConfigurationValue != 1) { 937 if (serial->dev->actconfig->desc.bConfigurationValue != 1) {
941 err("active config #%d != 1 ??", 938 err("active config #%d != 1 ??",
942 serial->dev->actconfig->desc.bConfigurationValue); 939 serial->dev->actconfig->desc.bConfigurationValue);
@@ -947,7 +944,7 @@ static int ipaq_startup(struct usb_serial *serial)
947 944
948static void ipaq_shutdown(struct usb_serial *serial) 945static void ipaq_shutdown(struct usb_serial *serial)
949{ 946{
950 dbg("%s", __FUNCTION__); 947 dbg("%s", __func__);
951} 948}
952 949
953static int __init ipaq_init(void) 950static int __init ipaq_init(void)
diff --git a/drivers/usb/serial/ipw.c b/drivers/usb/serial/ipw.c
index cbe5530f3db..bc85ca5c1c3 100644
--- a/drivers/usb/serial/ipw.c
+++ b/drivers/usb/serial/ipw.c
@@ -169,15 +169,15 @@ static void ipw_read_bulk_callback(struct urb *urb)
169 int result; 169 int result;
170 int status = urb->status; 170 int status = urb->status;
171 171
172 dbg("%s - port %d", __FUNCTION__, port->number); 172 dbg("%s - port %d", __func__, port->number);
173 173
174 if (status) { 174 if (status) {
175 dbg("%s - nonzero read bulk status received: %d", 175 dbg("%s - nonzero read bulk status received: %d",
176 __FUNCTION__, status); 176 __func__, status);
177 return; 177 return;
178 } 178 }
179 179
180 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, urb->actual_length, data); 180 usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data);
181 181
182 tty = port->tty; 182 tty = port->tty;
183 if (tty && urb->actual_length) { 183 if (tty && urb->actual_length) {
@@ -195,7 +195,7 @@ static void ipw_read_bulk_callback(struct urb *urb)
195 ipw_read_bulk_callback, port); 195 ipw_read_bulk_callback, port);
196 result = usb_submit_urb(port->read_urb, GFP_ATOMIC); 196 result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
197 if (result) 197 if (result)
198 dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", __FUNCTION__, result); 198 dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", __func__, result);
199 return; 199 return;
200} 200}
201 201
@@ -206,7 +206,7 @@ static int ipw_open(struct usb_serial_port *port, struct file *filp)
206 u8 *buf_flow_init; 206 u8 *buf_flow_init;
207 int result; 207 int result;
208 208
209 dbg("%s", __FUNCTION__); 209 dbg("%s", __func__);
210 210
211 buf_flow_init = kmemdup(buf_flow_static, 16, GFP_KERNEL); 211 buf_flow_init = kmemdup(buf_flow_static, 16, GFP_KERNEL);
212 if (!buf_flow_init) 212 if (!buf_flow_init)
@@ -217,7 +217,7 @@ static int ipw_open(struct usb_serial_port *port, struct file *filp)
217 217
218 /* --1: Tell the modem to initialize (we think) From sniffs this is always the 218 /* --1: Tell the modem to initialize (we think) From sniffs this is always the
219 * first thing that gets sent to the modem during opening of the device */ 219 * first thing that gets sent to the modem during opening of the device */
220 dbg("%s: Sending SIO_INIT (we guess)",__FUNCTION__); 220 dbg("%s: Sending SIO_INIT (we guess)",__func__);
221 result = usb_control_msg(dev, usb_sndctrlpipe(dev,0), 221 result = usb_control_msg(dev, usb_sndctrlpipe(dev,0),
222 IPW_SIO_INIT, 222 IPW_SIO_INIT,
223 USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, 223 USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
@@ -234,7 +234,7 @@ static int ipw_open(struct usb_serial_port *port, struct file *filp)
234 usb_clear_halt(dev, usb_sndbulkpipe(dev, port->bulk_out_endpointAddress)); 234 usb_clear_halt(dev, usb_sndbulkpipe(dev, port->bulk_out_endpointAddress));
235 235
236 /*--2: Start reading from the device */ 236 /*--2: Start reading from the device */
237 dbg("%s: setting up bulk read callback",__FUNCTION__); 237 dbg("%s: setting up bulk read callback",__func__);
238 usb_fill_bulk_urb(port->read_urb, dev, 238 usb_fill_bulk_urb(port->read_urb, dev,
239 usb_rcvbulkpipe(dev, port->bulk_in_endpointAddress), 239 usb_rcvbulkpipe(dev, port->bulk_in_endpointAddress),
240 port->bulk_in_buffer, 240 port->bulk_in_buffer,
@@ -242,10 +242,10 @@ static int ipw_open(struct usb_serial_port *port, struct file *filp)
242 ipw_read_bulk_callback, port); 242 ipw_read_bulk_callback, port);
243 result = usb_submit_urb(port->read_urb, GFP_KERNEL); 243 result = usb_submit_urb(port->read_urb, GFP_KERNEL);
244 if (result < 0) 244 if (result < 0)
245 dbg("%s - usb_submit_urb(read bulk) failed with status %d", __FUNCTION__, result); 245 dbg("%s - usb_submit_urb(read bulk) failed with status %d", __func__, result);
246 246
247 /*--3: Tell the modem to open the floodgates on the rx bulk channel */ 247 /*--3: Tell the modem to open the floodgates on the rx bulk channel */
248 dbg("%s:asking modem for RxRead (RXBULK_ON)",__FUNCTION__); 248 dbg("%s:asking modem for RxRead (RXBULK_ON)",__func__);
249 result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 249 result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
250 IPW_SIO_RXCTL, 250 IPW_SIO_RXCTL,
251 USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, 251 USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
@@ -258,7 +258,7 @@ static int ipw_open(struct usb_serial_port *port, struct file *filp)
258 dev_err(&port->dev, "Enabling bulk RxRead failed (error = %d)\n", result); 258 dev_err(&port->dev, "Enabling bulk RxRead failed (error = %d)\n", result);
259 259
260 /*--4: setup the initial flowcontrol */ 260 /*--4: setup the initial flowcontrol */
261 dbg("%s:setting init flowcontrol (%s)",__FUNCTION__,buf_flow_init); 261 dbg("%s:setting init flowcontrol (%s)",__func__,buf_flow_init);
262 result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 262 result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
263 IPW_SIO_HANDFLOW, 263 IPW_SIO_HANDFLOW,
264 USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, 264 USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
@@ -272,7 +272,7 @@ static int ipw_open(struct usb_serial_port *port, struct file *filp)
272 272
273 273
274 /*--5: raise the dtr */ 274 /*--5: raise the dtr */
275 dbg("%s:raising dtr",__FUNCTION__); 275 dbg("%s:raising dtr",__func__);
276 result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 276 result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
277 IPW_SIO_SET_PIN, 277 IPW_SIO_SET_PIN,
278 USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, 278 USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
@@ -285,7 +285,7 @@ static int ipw_open(struct usb_serial_port *port, struct file *filp)
285 dev_err(&port->dev, "setting dtr failed (error = %d)\n", result); 285 dev_err(&port->dev, "setting dtr failed (error = %d)\n", result);
286 286
287 /*--6: raise the rts */ 287 /*--6: raise the rts */
288 dbg("%s:raising rts",__FUNCTION__); 288 dbg("%s:raising rts",__func__);
289 result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 289 result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
290 IPW_SIO_SET_PIN, 290 IPW_SIO_SET_PIN,
291 USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, 291 USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
@@ -307,12 +307,12 @@ static void ipw_close(struct usb_serial_port *port, struct file * filp)
307 int result; 307 int result;
308 308
309 if (tty_hung_up_p(filp)) { 309 if (tty_hung_up_p(filp)) {
310 dbg("%s: tty_hung_up_p ...", __FUNCTION__); 310 dbg("%s: tty_hung_up_p ...", __func__);
311 return; 311 return;
312 } 312 }
313 313
314 /*--1: drop the dtr */ 314 /*--1: drop the dtr */
315 dbg("%s:dropping dtr",__FUNCTION__); 315 dbg("%s:dropping dtr",__func__);
316 result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 316 result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
317 IPW_SIO_SET_PIN, 317 IPW_SIO_SET_PIN,
318 USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, 318 USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
@@ -325,7 +325,7 @@ static void ipw_close(struct usb_serial_port *port, struct file * filp)
325 dev_err(&port->dev, "dropping dtr failed (error = %d)\n", result); 325 dev_err(&port->dev, "dropping dtr failed (error = %d)\n", result);
326 326
327 /*--2: drop the rts */ 327 /*--2: drop the rts */
328 dbg("%s:dropping rts",__FUNCTION__); 328 dbg("%s:dropping rts",__func__);
329 result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 329 result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
330 IPW_SIO_SET_PIN, USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, 330 IPW_SIO_SET_PIN, USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
331 IPW_PIN_CLRRTS, 331 IPW_PIN_CLRRTS,
@@ -338,7 +338,7 @@ static void ipw_close(struct usb_serial_port *port, struct file * filp)
338 338
339 339
340 /*--3: purge */ 340 /*--3: purge */
341 dbg("%s:sending purge",__FUNCTION__); 341 dbg("%s:sending purge",__func__);
342 result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 342 result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
343 IPW_SIO_PURGE, USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, 343 IPW_SIO_PURGE, USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
344 0x03, 344 0x03,
@@ -373,13 +373,13 @@ static void ipw_write_bulk_callback(struct urb *urb)
373 struct usb_serial_port *port = urb->context; 373 struct usb_serial_port *port = urb->context;
374 int status = urb->status; 374 int status = urb->status;
375 375
376 dbg("%s", __FUNCTION__); 376 dbg("%s", __func__);
377 377
378 port->write_urb_busy = 0; 378 port->write_urb_busy = 0;
379 379
380 if (status) 380 if (status)
381 dbg("%s - nonzero write bulk status received: %d", 381 dbg("%s - nonzero write bulk status received: %d",
382 __FUNCTION__, status); 382 __func__, status);
383 383
384 usb_serial_port_softint(port); 384 usb_serial_port_softint(port);
385} 385}
@@ -389,18 +389,18 @@ static int ipw_write(struct usb_serial_port *port, const unsigned char *buf, int
389 struct usb_device *dev = port->serial->dev; 389 struct usb_device *dev = port->serial->dev;
390 int ret; 390 int ret;
391 391
392 dbg("%s: TOP: count=%d, in_interrupt=%ld", __FUNCTION__, 392 dbg("%s: TOP: count=%d, in_interrupt=%ld", __func__,
393 count, in_interrupt() ); 393 count, in_interrupt() );
394 394
395 if (count == 0) { 395 if (count == 0) {
396 dbg("%s - write request of 0 bytes", __FUNCTION__); 396 dbg("%s - write request of 0 bytes", __func__);
397 return 0; 397 return 0;
398 } 398 }
399 399
400 spin_lock_bh(&port->lock); 400 spin_lock_bh(&port->lock);
401 if (port->write_urb_busy) { 401 if (port->write_urb_busy) {
402 spin_unlock_bh(&port->lock); 402 spin_unlock_bh(&port->lock);
403 dbg("%s - already writing", __FUNCTION__); 403 dbg("%s - already writing", __func__);
404 return 0; 404 return 0;
405 } 405 }
406 port->write_urb_busy = 1; 406 port->write_urb_busy = 1;
@@ -409,7 +409,7 @@ static int ipw_write(struct usb_serial_port *port, const unsigned char *buf, int
409 count = min(count, port->bulk_out_size); 409 count = min(count, port->bulk_out_size);
410 memcpy(port->bulk_out_buffer, buf, count); 410 memcpy(port->bulk_out_buffer, buf, count);
411 411
412 dbg("%s count now:%d", __FUNCTION__, count); 412 dbg("%s count now:%d", __func__, count);
413 413
414 usb_fill_bulk_urb(port->write_urb, dev, 414 usb_fill_bulk_urb(port->write_urb, dev,
415 usb_sndbulkpipe(dev, port->bulk_out_endpointAddress), 415 usb_sndbulkpipe(dev, port->bulk_out_endpointAddress),
@@ -421,11 +421,11 @@ static int ipw_write(struct usb_serial_port *port, const unsigned char *buf, int
421 ret = usb_submit_urb(port->write_urb, GFP_ATOMIC); 421 ret = usb_submit_urb(port->write_urb, GFP_ATOMIC);
422 if (ret != 0) { 422 if (ret != 0) {
423 port->write_urb_busy = 0; 423 port->write_urb_busy = 0;
424 dbg("%s - usb_submit_urb(write bulk) failed with error = %d", __FUNCTION__, ret); 424 dbg("%s - usb_submit_urb(write bulk) failed with error = %d", __func__, ret);
425 return ret; 425 return ret;
426 } 426 }
427 427
428 dbg("%s returning %d", __FUNCTION__, count); 428 dbg("%s returning %d", __func__, count);
429 return count; 429 return count;
430} 430}
431 431
@@ -448,9 +448,6 @@ static struct usb_serial_driver ipw_device = {
448 .description = "IPWireless converter", 448 .description = "IPWireless converter",
449 .usb_driver = &usb_ipw_driver, 449 .usb_driver = &usb_ipw_driver,
450 .id_table = usb_ipw_ids, 450 .id_table = usb_ipw_ids,
451 .num_interrupt_in = NUM_DONT_CARE,
452 .num_bulk_in = 1,
453 .num_bulk_out = 1,
454 .num_ports = 1, 451 .num_ports = 1,
455 .open = ipw_open, 452 .open = ipw_open,
456 .close = ipw_close, 453 .close = ipw_close,
diff --git a/drivers/usb/serial/ir-usb.c b/drivers/usb/serial/ir-usb.c
index 6b803ab9854..004d57385a7 100644
--- a/drivers/usb/serial/ir-usb.c
+++ b/drivers/usb/serial/ir-usb.c
@@ -145,9 +145,6 @@ static struct usb_serial_driver ir_device = {
145 .description = "IR Dongle", 145 .description = "IR Dongle",
146 .usb_driver = &ir_driver, 146 .usb_driver = &ir_driver,
147 .id_table = id_table, 147 .id_table = id_table,
148 .num_interrupt_in = 1,
149 .num_bulk_in = 1,
150 .num_bulk_out = 1,
151 .num_ports = 1, 148 .num_ports = 1,
152 .set_termios = ir_set_termios, 149 .set_termios = ir_set_termios,
153 .attach = ir_startup, 150 .attach = ir_startup,
@@ -198,16 +195,16 @@ static struct irda_class_desc *irda_usb_find_class_desc(struct usb_device *dev,
198 USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE, 195 USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
199 0, ifnum, desc, sizeof(*desc), 1000); 196 0, ifnum, desc, sizeof(*desc), 1000);
200 197
201 dbg("%s - ret=%d", __FUNCTION__, ret); 198 dbg("%s - ret=%d", __func__, ret);
202 if (ret < sizeof(*desc)) { 199 if (ret < sizeof(*desc)) {
203 dbg("%s - class descriptor read %s (%d)", 200 dbg("%s - class descriptor read %s (%d)",
204 __FUNCTION__, 201 __func__,
205 (ret<0) ? "failed" : "too short", 202 (ret<0) ? "failed" : "too short",
206 ret); 203 ret);
207 goto error; 204 goto error;
208 } 205 }
209 if (desc->bDescriptorType != USB_DT_IRDA) { 206 if (desc->bDescriptorType != USB_DT_IRDA) {
210 dbg("%s - bad class descriptor type", __FUNCTION__); 207 dbg("%s - bad class descriptor type", __func__);
211 goto error; 208 goto error;
212 } 209 }
213 210
@@ -251,7 +248,7 @@ static int ir_startup (struct usb_serial *serial)
251 } 248 }
252 249
253 dbg ("%s - Baud rates supported:%s%s%s%s%s%s%s%s%s", 250 dbg ("%s - Baud rates supported:%s%s%s%s%s%s%s%s%s",
254 __FUNCTION__, 251 __func__,
255 (irda_desc->wBaudRate & 0x0001) ? " 2400" : "", 252 (irda_desc->wBaudRate & 0x0001) ? " 2400" : "",
256 (irda_desc->wBaudRate & 0x0002) ? " 9600" : "", 253 (irda_desc->wBaudRate & 0x0002) ? " 9600" : "",
257 (irda_desc->wBaudRate & 0x0004) ? " 19200" : "", 254 (irda_desc->wBaudRate & 0x0004) ? " 19200" : "",
@@ -284,13 +281,13 @@ static int ir_open (struct usb_serial_port *port, struct file *filp)
284 char *buffer; 281 char *buffer;
285 int result = 0; 282 int result = 0;
286 283
287 dbg("%s - port %d", __FUNCTION__, port->number); 284 dbg("%s - port %d", __func__, port->number);
288 285
289 if (buffer_size) { 286 if (buffer_size) {
290 /* override the default buffer sizes */ 287 /* override the default buffer sizes */
291 buffer = kmalloc (buffer_size, GFP_KERNEL); 288 buffer = kmalloc (buffer_size, GFP_KERNEL);
292 if (!buffer) { 289 if (!buffer) {
293 dev_err (&port->dev, "%s - out of memory.\n", __FUNCTION__); 290 dev_err (&port->dev, "%s - out of memory.\n", __func__);
294 return -ENOMEM; 291 return -ENOMEM;
295 } 292 }
296 kfree (port->read_urb->transfer_buffer); 293 kfree (port->read_urb->transfer_buffer);
@@ -299,7 +296,7 @@ static int ir_open (struct usb_serial_port *port, struct file *filp)
299 296
300 buffer = kmalloc (buffer_size, GFP_KERNEL); 297 buffer = kmalloc (buffer_size, GFP_KERNEL);
301 if (!buffer) { 298 if (!buffer) {
302 dev_err (&port->dev, "%s - out of memory.\n", __FUNCTION__); 299 dev_err (&port->dev, "%s - out of memory.\n", __func__);
303 return -ENOMEM; 300 return -ENOMEM;
304 } 301 }
305 kfree (port->write_urb->transfer_buffer); 302 kfree (port->write_urb->transfer_buffer);
@@ -319,14 +316,14 @@ static int ir_open (struct usb_serial_port *port, struct file *filp)
319 port); 316 port);
320 result = usb_submit_urb(port->read_urb, GFP_KERNEL); 317 result = usb_submit_urb(port->read_urb, GFP_KERNEL);
321 if (result) 318 if (result)
322 dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", __FUNCTION__, result); 319 dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", __func__, result);
323 320
324 return result; 321 return result;
325} 322}
326 323
327static void ir_close (struct usb_serial_port *port, struct file * filp) 324static void ir_close (struct usb_serial_port *port, struct file * filp)
328{ 325{
329 dbg("%s - port %d", __FUNCTION__, port->number); 326 dbg("%s - port %d", __func__, port->number);
330 327
331 /* shutdown our bulk read */ 328 /* shutdown our bulk read */
332 usb_kill_urb(port->read_urb); 329 usb_kill_urb(port->read_urb);
@@ -338,10 +335,10 @@ static int ir_write (struct usb_serial_port *port, const unsigned char *buf, int
338 int result; 335 int result;
339 int transfer_size; 336 int transfer_size;
340 337
341 dbg("%s - port = %d, count = %d", __FUNCTION__, port->number, count); 338 dbg("%s - port = %d, count = %d", __func__, port->number, count);
342 339
343 if (!port->tty) { 340 if (!port->tty) {
344 dev_err (&port->dev, "%s - no tty???\n", __FUNCTION__); 341 dev_err (&port->dev, "%s - no tty???\n", __func__);
345 return 0; 342 return 0;
346 } 343 }
347 344
@@ -351,7 +348,7 @@ static int ir_write (struct usb_serial_port *port, const unsigned char *buf, int
351 spin_lock_bh(&port->lock); 348 spin_lock_bh(&port->lock);
352 if (port->write_urb_busy) { 349 if (port->write_urb_busy) {
353 spin_unlock_bh(&port->lock); 350 spin_unlock_bh(&port->lock);
354 dbg("%s - already writing", __FUNCTION__); 351 dbg("%s - already writing", __func__);
355 return 0; 352 return 0;
356 } 353 }
357 port->write_urb_busy = 1; 354 port->write_urb_busy = 1;
@@ -387,7 +384,7 @@ static int ir_write (struct usb_serial_port *port, const unsigned char *buf, int
387 result = usb_submit_urb (port->write_urb, GFP_ATOMIC); 384 result = usb_submit_urb (port->write_urb, GFP_ATOMIC);
388 if (result) { 385 if (result) {
389 port->write_urb_busy = 0; 386 port->write_urb_busy = 0;
390 dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __FUNCTION__, result); 387 dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __func__, result);
391 } else 388 } else
392 result = transfer_size; 389 result = transfer_size;
393 390
@@ -396,22 +393,22 @@ static int ir_write (struct usb_serial_port *port, const unsigned char *buf, int
396 393
397static void ir_write_bulk_callback (struct urb *urb) 394static void ir_write_bulk_callback (struct urb *urb)
398{ 395{
399 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 396 struct usb_serial_port *port = urb->context;
400 int status = urb->status; 397 int status = urb->status;
401 398
402 dbg("%s - port %d", __FUNCTION__, port->number); 399 dbg("%s - port %d", __func__, port->number);
403 400
404 port->write_urb_busy = 0; 401 port->write_urb_busy = 0;
405 if (status) { 402 if (status) {
406 dbg("%s - nonzero write bulk status received: %d", 403 dbg("%s - nonzero write bulk status received: %d",
407 __FUNCTION__, status); 404 __func__, status);
408 return; 405 return;
409 } 406 }
410 407
411 usb_serial_debug_data ( 408 usb_serial_debug_data (
412 debug, 409 debug,
413 &port->dev, 410 &port->dev,
414 __FUNCTION__, 411 __func__,
415 urb->actual_length, 412 urb->actual_length,
416 urb->transfer_buffer); 413 urb->transfer_buffer);
417 414
@@ -420,16 +417,16 @@ static void ir_write_bulk_callback (struct urb *urb)
420 417
421static void ir_read_bulk_callback (struct urb *urb) 418static void ir_read_bulk_callback (struct urb *urb)
422{ 419{
423 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 420 struct usb_serial_port *port = urb->context;
424 struct tty_struct *tty; 421 struct tty_struct *tty;
425 unsigned char *data = urb->transfer_buffer; 422 unsigned char *data = urb->transfer_buffer;
426 int result; 423 int result;
427 int status = urb->status; 424 int status = urb->status;
428 425
429 dbg("%s - port %d", __FUNCTION__, port->number); 426 dbg("%s - port %d", __func__, port->number);
430 427
431 if (!port->open_count) { 428 if (!port->open_count) {
432 dbg("%s - port closed.", __FUNCTION__); 429 dbg("%s - port closed.", __func__);
433 return; 430 return;
434 } 431 }
435 432
@@ -447,7 +444,7 @@ static void ir_read_bulk_callback (struct urb *urb)
447 usb_serial_debug_data ( 444 usb_serial_debug_data (
448 debug, 445 debug,
449 &port->dev, 446 &port->dev,
450 __FUNCTION__, 447 __func__,
451 urb->actual_length, 448 urb->actual_length,
452 data); 449 data);
453 450
@@ -480,13 +477,13 @@ static void ir_read_bulk_callback (struct urb *urb)
480 result = usb_submit_urb(port->read_urb, GFP_ATOMIC); 477 result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
481 if (result) 478 if (result)
482 dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", 479 dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n",
483 __FUNCTION__, result); 480 __func__, result);
484 481
485 break ; 482 break ;
486 483
487 default: 484 default:
488 dbg("%s - nonzero read bulk status received: %d", 485 dbg("%s - nonzero read bulk status received: %d",
489 __FUNCTION__, 486 __func__,
490 status); 487 status);
491 break ; 488 break ;
492 489
@@ -502,7 +499,7 @@ static void ir_set_termios (struct usb_serial_port *port, struct ktermios *old_t
502 speed_t baud; 499 speed_t baud;
503 int ir_baud; 500 int ir_baud;
504 501
505 dbg("%s - port %d", __FUNCTION__, port->number); 502 dbg("%s - port %d", __func__, port->number);
506 503
507 baud = tty_get_baud_rate(port->tty); 504 baud = tty_get_baud_rate(port->tty);
508 505
@@ -554,7 +551,7 @@ static void ir_set_termios (struct usb_serial_port *port, struct ktermios *old_t
554 551
555 result = usb_submit_urb (port->write_urb, GFP_KERNEL); 552 result = usb_submit_urb (port->write_urb, GFP_KERNEL);
556 if (result) 553 if (result)
557 dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __FUNCTION__, result); 554 dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __func__, result);
558 555
559 /* Only speed changes are supported */ 556 /* Only speed changes are supported */
560 tty_termios_copy_hw(port->tty->termios, old_termios); 557 tty_termios_copy_hw(port->tty->termios, old_termios);
diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c
index fde188e23ce..8a217648b25 100644
--- a/drivers/usb/serial/iuu_phoenix.c
+++ b/drivers/usb/serial/iuu_phoenix.c
@@ -98,10 +98,10 @@ static int iuu_alloc_buf(struct iuu_private *priv)
98 priv->writebuf = kzalloc(256, GFP_KERNEL); 98 priv->writebuf = kzalloc(256, GFP_KERNEL);
99 if (!priv->buf || !priv->dbgbuf || !priv->writebuf) { 99 if (!priv->buf || !priv->dbgbuf || !priv->writebuf) {
100 iuu_free_buf(priv); 100 iuu_free_buf(priv);
101 dbg("%s problem allocation buffer", __FUNCTION__); 101 dbg("%s problem allocation buffer", __func__);
102 return -ENOMEM; 102 return -ENOMEM;
103 } 103 }
104 dbg("%s - Privates buffers allocation success", __FUNCTION__); 104 dbg("%s - Privates buffers allocation success", __func__);
105 return 0; 105 return 0;
106} 106}
107 107
@@ -109,7 +109,7 @@ static int iuu_startup(struct usb_serial *serial)
109{ 109{
110 struct iuu_private *priv; 110 struct iuu_private *priv;
111 priv = kzalloc(sizeof(struct iuu_private), GFP_KERNEL); 111 priv = kzalloc(sizeof(struct iuu_private), GFP_KERNEL);
112 dbg("%s- priv allocation success", __FUNCTION__); 112 dbg("%s- priv allocation success", __func__);
113 if (!priv) 113 if (!priv)
114 return -ENOMEM; 114 return -ENOMEM;
115 if (iuu_alloc_buf(priv)) { 115 if (iuu_alloc_buf(priv)) {
@@ -130,17 +130,17 @@ static void iuu_shutdown(struct usb_serial *serial)
130 if (!port) 130 if (!port)
131 return; 131 return;
132 132
133 dbg("%s", __FUNCTION__); 133 dbg("%s", __func__);
134 134
135 if (priv) { 135 if (priv) {
136 iuu_free_buf(priv); 136 iuu_free_buf(priv);
137 dbg("%s - I will free all", __FUNCTION__); 137 dbg("%s - I will free all", __func__);
138 usb_set_serial_port_data(port, NULL); 138 usb_set_serial_port_data(port, NULL);
139 139
140 dbg("%s - priv is not anymore in port structure", __FUNCTION__); 140 dbg("%s - priv is not anymore in port structure", __func__);
141 kfree(priv); 141 kfree(priv);
142 142
143 dbg("%s priv is now kfree", __FUNCTION__); 143 dbg("%s priv is now kfree", __func__);
144 } 144 }
145} 145}
146 146
@@ -148,20 +148,21 @@ static int iuu_tiocmset(struct usb_serial_port *port, struct file *file,
148 unsigned int set, unsigned int clear) 148 unsigned int set, unsigned int clear)
149{ 149{
150 struct iuu_private *priv = usb_get_serial_port_data(port); 150 struct iuu_private *priv = usb_get_serial_port_data(port);
151 struct tty_struct *tty; 151 unsigned long flags;
152 tty = port->tty;
153 152
154 dbg("%s (%d) msg : SET = 0x%04x, CLEAR = 0x%04x ", __FUNCTION__, 153 /* FIXME: locking on tiomstatus */
154 dbg("%s (%d) msg : SET = 0x%04x, CLEAR = 0x%04x ", __func__,
155 port->number, set, clear); 155 port->number, set, clear);
156
157 spin_lock_irqsave(&priv->lock, flags);
156 if (set & TIOCM_RTS) 158 if (set & TIOCM_RTS)
157 priv->tiostatus = TIOCM_RTS; 159 priv->tiostatus = TIOCM_RTS;
158 160
159 if (!(set & TIOCM_RTS) && priv->tiostatus == TIOCM_RTS) { 161 if (!(set & TIOCM_RTS) && priv->tiostatus == TIOCM_RTS) {
160 dbg("%s TIOCMSET RESET called !!!", __FUNCTION__); 162 dbg("%s TIOCMSET RESET called !!!", __func__);
161 priv->reset = 1; 163 priv->reset = 1;
162 return 0;
163 } 164 }
164 165 spin_unlock_irqrestore(&priv->lock, flags);
165 return 0; 166 return 0;
166} 167}
167 168
@@ -173,17 +174,24 @@ static int iuu_tiocmset(struct usb_serial_port *port, struct file *file,
173static int iuu_tiocmget(struct usb_serial_port *port, struct file *file) 174static int iuu_tiocmget(struct usb_serial_port *port, struct file *file)
174{ 175{
175 struct iuu_private *priv = usb_get_serial_port_data(port); 176 struct iuu_private *priv = usb_get_serial_port_data(port);
176 return priv->tiostatus; 177 unsigned long flags;
178 int rc;
179
180 spin_lock_irqsave(&priv->lock, flags);
181 rc = priv->tiostatus;
182 spin_unlock_irqrestore(&priv->lock, flags);
183
184 return rc;
177} 185}
178 186
179static void iuu_rxcmd(struct urb *urb) 187static void iuu_rxcmd(struct urb *urb)
180{ 188{
181 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 189 struct usb_serial_port *port = urb->context;
182 int result; 190 int result;
183 dbg("%s - enter", __FUNCTION__); 191 dbg("%s - enter", __func__);
184 192
185 if (urb->status) { 193 if (urb->status) {
186 dbg("%s - urb->status = %d", __FUNCTION__, urb->status); 194 dbg("%s - urb->status = %d", __func__, urb->status);
187 /* error stop all */ 195 /* error stop all */
188 return; 196 return;
189 } 197 }
@@ -203,7 +211,7 @@ static int iuu_reset(struct usb_serial_port *port, u8 wt)
203 struct iuu_private *priv = usb_get_serial_port_data(port); 211 struct iuu_private *priv = usb_get_serial_port_data(port);
204 int result; 212 int result;
205 char *buf_ptr = port->write_urb->transfer_buffer; 213 char *buf_ptr = port->write_urb->transfer_buffer;
206 dbg("%s - enter", __FUNCTION__); 214 dbg("%s - enter", __func__);
207 215
208 /* Prepare the reset sequence */ 216 /* Prepare the reset sequence */
209 217
@@ -232,19 +240,19 @@ static int iuu_reset(struct usb_serial_port *port, u8 wt)
232 */ 240 */
233static void iuu_update_status_callback(struct urb *urb) 241static void iuu_update_status_callback(struct urb *urb)
234{ 242{
235 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 243 struct usb_serial_port *port = urb->context;
236 struct iuu_private *priv = usb_get_serial_port_data(port); 244 struct iuu_private *priv = usb_get_serial_port_data(port);
237 u8 *st; 245 u8 *st;
238 dbg("%s - enter", __FUNCTION__); 246 dbg("%s - enter", __func__);
239 247
240 if (urb->status) { 248 if (urb->status) {
241 dbg("%s - urb->status = %d", __FUNCTION__, urb->status); 249 dbg("%s - urb->status = %d", __func__, urb->status);
242 /* error stop all */ 250 /* error stop all */
243 return; 251 return;
244 } 252 }
245 253
246 st = urb->transfer_buffer; 254 st = urb->transfer_buffer;
247 dbg("%s - enter", __FUNCTION__); 255 dbg("%s - enter", __func__);
248 if (urb->actual_length == 1) { 256 if (urb->actual_length == 1) {
249 switch (st[0]) { 257 switch (st[0]) {
250 case 0x1: 258 case 0x1:
@@ -262,11 +270,11 @@ static void iuu_update_status_callback(struct urb *urb)
262 270
263static void iuu_status_callback(struct urb *urb) 271static void iuu_status_callback(struct urb *urb)
264{ 272{
265 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 273 struct usb_serial_port *port = urb->context;
266 int result; 274 int result;
267 dbg("%s - enter", __FUNCTION__); 275 dbg("%s - enter", __func__);
268 276
269 dbg("%s - urb->status = %d", __FUNCTION__, urb->status); 277 dbg("%s - urb->status = %d", __func__, urb->status);
270 usb_fill_bulk_urb(port->read_urb, port->serial->dev, 278 usb_fill_bulk_urb(port->read_urb, port->serial->dev,
271 usb_rcvbulkpipe(port->serial->dev, 279 usb_rcvbulkpipe(port->serial->dev,
272 port->bulk_in_endpointAddress), 280 port->bulk_in_endpointAddress),
@@ -279,7 +287,7 @@ static int iuu_status(struct usb_serial_port *port)
279{ 287{
280 int result; 288 int result;
281 289
282 dbg("%s - enter", __FUNCTION__); 290 dbg("%s - enter", __func__);
283 291
284 memset(port->write_urb->transfer_buffer, IUU_GET_STATE_REGISTER, 1); 292 memset(port->write_urb->transfer_buffer, IUU_GET_STATE_REGISTER, 1);
285 usb_fill_bulk_urb(port->write_urb, port->serial->dev, 293 usb_fill_bulk_urb(port->write_urb, port->serial->dev,
@@ -298,7 +306,7 @@ static int bulk_immediate(struct usb_serial_port *port, u8 *buf, u8 count)
298 struct usb_serial *serial = port->serial; 306 struct usb_serial *serial = port->serial;
299 int actual = 0; 307 int actual = 0;
300 308
301 dbg("%s - enter", __FUNCTION__); 309 dbg("%s - enter", __func__);
302 310
303 /* send the data out the bulk port */ 311 /* send the data out the bulk port */
304 312
@@ -309,9 +317,9 @@ static int bulk_immediate(struct usb_serial_port *port, u8 *buf, u8 count)
309 count, &actual, HZ * 1); 317 count, &actual, HZ * 1);
310 318
311 if (status != IUU_OPERATION_OK) { 319 if (status != IUU_OPERATION_OK) {
312 dbg("%s - error = %2x", __FUNCTION__, status); 320 dbg("%s - error = %2x", __func__, status);
313 } else { 321 } else {
314 dbg("%s - write OK !", __FUNCTION__); 322 dbg("%s - write OK !", __func__);
315 } 323 }
316 return status; 324 return status;
317} 325}
@@ -322,7 +330,7 @@ static int read_immediate(struct usb_serial_port *port, u8 *buf, u8 count)
322 struct usb_serial *serial = port->serial; 330 struct usb_serial *serial = port->serial;
323 int actual = 0; 331 int actual = 0;
324 332
325 dbg("%s - enter", __FUNCTION__); 333 dbg("%s - enter", __func__);
326 334
327 /* send the data out the bulk port */ 335 /* send the data out the bulk port */
328 336
@@ -333,9 +341,9 @@ static int read_immediate(struct usb_serial_port *port, u8 *buf, u8 count)
333 count, &actual, HZ * 1); 341 count, &actual, HZ * 1);
334 342
335 if (status != IUU_OPERATION_OK) { 343 if (status != IUU_OPERATION_OK) {
336 dbg("%s - error = %2x", __FUNCTION__, status); 344 dbg("%s - error = %2x", __func__, status);
337 } else { 345 } else {
338 dbg("%s - read OK !", __FUNCTION__); 346 dbg("%s - read OK !", __func__);
339 } 347 }
340 348
341 return status; 349 return status;
@@ -350,7 +358,7 @@ static int iuu_led(struct usb_serial_port *port, unsigned int R,
350 if (!buf) 358 if (!buf)
351 return -ENOMEM; 359 return -ENOMEM;
352 360
353 dbg("%s - enter", __FUNCTION__); 361 dbg("%s - enter", __func__);
354 362
355 buf[0] = IUU_SET_LED; 363 buf[0] = IUU_SET_LED;
356 buf[1] = R & 0xFF; 364 buf[1] = R & 0xFF;
@@ -363,9 +371,9 @@ static int iuu_led(struct usb_serial_port *port, unsigned int R,
363 status = bulk_immediate(port, buf, 8); 371 status = bulk_immediate(port, buf, 8);
364 kfree(buf); 372 kfree(buf);
365 if (status != IUU_OPERATION_OK) 373 if (status != IUU_OPERATION_OK)
366 dbg("%s - led error status = %2x", __FUNCTION__, status); 374 dbg("%s - led error status = %2x", __func__, status);
367 else 375 else
368 dbg("%s - led OK !", __FUNCTION__); 376 dbg("%s - led OK !", __func__);
369 return IUU_OPERATION_OK; 377 return IUU_OPERATION_OK;
370} 378}
371 379
@@ -384,7 +392,7 @@ static void iuu_rgbf_fill_buffer(u8 *buf, u8 r1, u8 r2, u8 g1, u8 g2, u8 b1,
384 392
385static void iuu_led_activity_on(struct urb *urb) 393static void iuu_led_activity_on(struct urb *urb)
386{ 394{
387 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 395 struct usb_serial_port *port = urb->context;
388 int result; 396 int result;
389 char *buf_ptr = port->write_urb->transfer_buffer; 397 char *buf_ptr = port->write_urb->transfer_buffer;
390 *buf_ptr++ = IUU_SET_LED; 398 *buf_ptr++ = IUU_SET_LED;
@@ -405,7 +413,7 @@ static void iuu_led_activity_on(struct urb *urb)
405 413
406static void iuu_led_activity_off(struct urb *urb) 414static void iuu_led_activity_off(struct urb *urb)
407{ 415{
408 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 416 struct usb_serial_port *port = urb->context;
409 int result; 417 int result;
410 char *buf_ptr = port->write_urb->transfer_buffer; 418 char *buf_ptr = port->write_urb->transfer_buffer;
411 if (xmas == 1) { 419 if (xmas == 1) {
@@ -443,7 +451,7 @@ static int iuu_clk(struct usb_serial_port *port, int dwFrq)
443 unsigned int P2 = 0; 451 unsigned int P2 = 0;
444 int frq = (int)dwFrq; 452 int frq = (int)dwFrq;
445 453
446 dbg("%s - enter", __FUNCTION__); 454 dbg("%s - enter", __func__);
447 455
448 if (frq == 0) { 456 if (frq == 0) {
449 priv->buf[Count++] = IUU_UART_WRITE_I2C; 457 priv->buf[Count++] = IUU_UART_WRITE_I2C;
@@ -453,7 +461,7 @@ static int iuu_clk(struct usb_serial_port *port, int dwFrq)
453 461
454 status = bulk_immediate(port, (u8 *) priv->buf, Count); 462 status = bulk_immediate(port, (u8 *) priv->buf, Count);
455 if (status != 0) { 463 if (status != 0) {
456 dbg("%s - write error ", __FUNCTION__); 464 dbg("%s - write error ", __func__);
457 return status; 465 return status;
458 } 466 }
459 } else if (frq == 3579000) { 467 } else if (frq == 3579000) {
@@ -562,7 +570,7 @@ static int iuu_clk(struct usb_serial_port *port, int dwFrq)
562 570
563 status = bulk_immediate(port, (u8 *) priv->buf, Count); 571 status = bulk_immediate(port, (u8 *) priv->buf, Count);
564 if (status != IUU_OPERATION_OK) 572 if (status != IUU_OPERATION_OK)
565 dbg("%s - write error ", __FUNCTION__); 573 dbg("%s - write error ", __func__);
566 return status; 574 return status;
567} 575}
568 576
@@ -573,7 +581,7 @@ static int iuu_uart_flush(struct usb_serial_port *port)
573 u8 rxcmd = IUU_UART_RX; 581 u8 rxcmd = IUU_UART_RX;
574 struct iuu_private *priv = usb_get_serial_port_data(port); 582 struct iuu_private *priv = usb_get_serial_port_data(port);
575 583
576 dbg("%s - enter", __FUNCTION__); 584 dbg("%s - enter", __func__);
577 585
578 if (iuu_led(port, 0xF000, 0, 0, 0xFF) < 0) 586 if (iuu_led(port, 0xF000, 0, 0, 0xFF) < 0)
579 return -EIO; 587 return -EIO;
@@ -581,50 +589,50 @@ static int iuu_uart_flush(struct usb_serial_port *port)
581 for (i = 0; i < 2; i++) { 589 for (i = 0; i < 2; i++) {
582 status = bulk_immediate(port, &rxcmd, 1); 590 status = bulk_immediate(port, &rxcmd, 1);
583 if (status != IUU_OPERATION_OK) { 591 if (status != IUU_OPERATION_OK) {
584 dbg("%s - uart_flush_write error", __FUNCTION__); 592 dbg("%s - uart_flush_write error", __func__);
585 return status; 593 return status;
586 } 594 }
587 595
588 status = read_immediate(port, &priv->len, 1); 596 status = read_immediate(port, &priv->len, 1);
589 if (status != IUU_OPERATION_OK) { 597 if (status != IUU_OPERATION_OK) {
590 dbg("%s - uart_flush_read error", __FUNCTION__); 598 dbg("%s - uart_flush_read error", __func__);
591 return status; 599 return status;
592 } 600 }
593 601
594 if (priv->len > 0) { 602 if (priv->len > 0) {
595 dbg("%s - uart_flush datalen is : %i ", __FUNCTION__, 603 dbg("%s - uart_flush datalen is : %i ", __func__,
596 priv->len); 604 priv->len);
597 status = read_immediate(port, priv->buf, priv->len); 605 status = read_immediate(port, priv->buf, priv->len);
598 if (status != IUU_OPERATION_OK) { 606 if (status != IUU_OPERATION_OK) {
599 dbg("%s - uart_flush_read error", __FUNCTION__); 607 dbg("%s - uart_flush_read error", __func__);
600 return status; 608 return status;
601 } 609 }
602 } 610 }
603 } 611 }
604 dbg("%s - uart_flush_read OK!", __FUNCTION__); 612 dbg("%s - uart_flush_read OK!", __func__);
605 iuu_led(port, 0, 0xF000, 0, 0xFF); 613 iuu_led(port, 0, 0xF000, 0, 0xFF);
606 return status; 614 return status;
607} 615}
608 616
609static void read_buf_callback(struct urb *urb) 617static void read_buf_callback(struct urb *urb)
610{ 618{
611 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 619 struct usb_serial_port *port = urb->context;
612 unsigned char *data = urb->transfer_buffer; 620 unsigned char *data = urb->transfer_buffer;
613 struct tty_struct *tty; 621 struct tty_struct *tty;
614 dbg("%s - urb->status = %d", __FUNCTION__, urb->status); 622 dbg("%s - urb->status = %d", __func__, urb->status);
615 623
616 if (urb->status) { 624 if (urb->status) {
617 dbg("%s - urb->status = %d", __FUNCTION__, urb->status); 625 dbg("%s - urb->status = %d", __func__, urb->status);
618 if (urb->status == -EPROTO) { 626 if (urb->status == -EPROTO) {
619 /* reschedule needed */ 627 /* reschedule needed */
620 } 628 }
621 return; 629 return;
622 } 630 }
623 631
624 dbg("%s - %i chars to write", __FUNCTION__, urb->actual_length); 632 dbg("%s - %i chars to write", __func__, urb->actual_length);
625 tty = port->tty; 633 tty = port->tty;
626 if (data == NULL) 634 if (data == NULL)
627 dbg("%s - data is NULL !!!", __FUNCTION__); 635 dbg("%s - data is NULL !!!", __func__);
628 if (tty && urb->actual_length && data) { 636 if (tty && urb->actual_length && data) {
629 tty_insert_flip_string(tty, data, urb->actual_length); 637 tty_insert_flip_string(tty, data, urb->actual_length);
630 tty_flip_buffer_push(tty); 638 tty_flip_buffer_push(tty);
@@ -639,7 +647,7 @@ static int iuu_bulk_write(struct usb_serial_port *port)
639 int result; 647 int result;
640 int i; 648 int i;
641 char *buf_ptr = port->write_urb->transfer_buffer; 649 char *buf_ptr = port->write_urb->transfer_buffer;
642 dbg("%s - enter", __FUNCTION__); 650 dbg("%s - enter", __func__);
643 651
644 *buf_ptr++ = IUU_UART_ESC; 652 *buf_ptr++ = IUU_UART_ESC;
645 *buf_ptr++ = IUU_UART_TX; 653 *buf_ptr++ = IUU_UART_TX;
@@ -652,7 +660,7 @@ static int iuu_bulk_write(struct usb_serial_port *port)
652 sprintf(priv->dbgbuf + i*2 , 660 sprintf(priv->dbgbuf + i*2 ,
653 "%02X", priv->writebuf[i]); 661 "%02X", priv->writebuf[i]);
654 priv->dbgbuf[priv->writelen+i*2] = 0; 662 priv->dbgbuf[priv->writelen+i*2] = 0;
655 dbg("%s - writing %i chars : %s", __FUNCTION__, 663 dbg("%s - writing %i chars : %s", __func__,
656 priv->writelen, priv->dbgbuf); 664 priv->writelen, priv->dbgbuf);
657 } 665 }
658 usb_fill_bulk_urb(port->write_urb, port->serial->dev, 666 usb_fill_bulk_urb(port->write_urb, port->serial->dev,
@@ -671,7 +679,7 @@ static int iuu_bulk_write(struct usb_serial_port *port)
671static int iuu_read_buf(struct usb_serial_port *port, int len) 679static int iuu_read_buf(struct usb_serial_port *port, int len)
672{ 680{
673 int result; 681 int result;
674 dbg("%s - enter", __FUNCTION__); 682 dbg("%s - enter", __func__);
675 683
676 usb_fill_bulk_urb(port->read_urb, port->serial->dev, 684 usb_fill_bulk_urb(port->read_urb, port->serial->dev,
677 usb_rcvbulkpipe(port->serial->dev, 685 usb_rcvbulkpipe(port->serial->dev,
@@ -684,7 +692,7 @@ static int iuu_read_buf(struct usb_serial_port *port, int len)
684 692
685static void iuu_uart_read_callback(struct urb *urb) 693static void iuu_uart_read_callback(struct urb *urb)
686{ 694{
687 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 695 struct usb_serial_port *port = urb->context;
688 struct iuu_private *priv = usb_get_serial_port_data(port); 696 struct iuu_private *priv = usb_get_serial_port_data(port);
689 unsigned int flags; 697 unsigned int flags;
690 int status; 698 int status;
@@ -693,21 +701,21 @@ static void iuu_uart_read_callback(struct urb *urb)
693 unsigned char *data = urb->transfer_buffer; 701 unsigned char *data = urb->transfer_buffer;
694 priv->poll++; 702 priv->poll++;
695 703
696 dbg("%s - enter", __FUNCTION__); 704 dbg("%s - enter", __func__);
697 705
698 if (urb->status) { 706 if (urb->status) {
699 dbg("%s - urb->status = %d", __FUNCTION__, urb->status); 707 dbg("%s - urb->status = %d", __func__, urb->status);
700 /* error stop all */ 708 /* error stop all */
701 return; 709 return;
702 } 710 }
703 if (data == NULL) 711 if (data == NULL)
704 dbg("%s - data is NULL !!!", __FUNCTION__); 712 dbg("%s - data is NULL !!!", __func__);
705 713
706 if (urb->actual_length == 1 && data != NULL) 714 if (urb->actual_length == 1 && data != NULL)
707 len = (int) data[0]; 715 len = (int) data[0];
708 716
709 if (urb->actual_length > 1) { 717 if (urb->actual_length > 1) {
710 dbg("%s - urb->actual_length = %i", __FUNCTION__, 718 dbg("%s - urb->actual_length = %i", __func__,
711 urb->actual_length); 719 urb->actual_length);
712 error = 1; 720 error = 1;
713 return; 721 return;
@@ -716,7 +724,7 @@ static void iuu_uart_read_callback(struct urb *urb)
716 724
717 if (len > 0 && error == 0) { 725 if (len > 0 && error == 0) {
718 dbg("%s - call read buf - len to read is %i ", 726 dbg("%s - call read buf - len to read is %i ",
719 __FUNCTION__, len); 727 __func__, len);
720 status = iuu_read_buf(port, len); 728 status = iuu_read_buf(port, len);
721 return; 729 return;
722 } 730 }
@@ -742,7 +750,7 @@ static void iuu_uart_read_callback(struct urb *urb)
742 } 750 }
743 spin_unlock_irqrestore(&priv->lock, flags); 751 spin_unlock_irqrestore(&priv->lock, flags);
744 /* if nothing to write call again rxcmd */ 752 /* if nothing to write call again rxcmd */
745 dbg("%s - rxcmd recall", __FUNCTION__); 753 dbg("%s - rxcmd recall", __func__);
746 iuu_led_activity_off(urb); 754 iuu_led_activity_off(urb);
747 return; 755 return;
748} 756}
@@ -752,7 +760,7 @@ static int iuu_uart_write(struct usb_serial_port *port, const u8 *buf,
752{ 760{
753 struct iuu_private *priv = usb_get_serial_port_data(port); 761 struct iuu_private *priv = usb_get_serial_port_data(port);
754 unsigned int flags; 762 unsigned int flags;
755 dbg("%s - enter", __FUNCTION__); 763 dbg("%s - enter", __func__);
756 764
757 if (count > 256) 765 if (count > 256)
758 return -ENOMEM; 766 return -ENOMEM;
@@ -773,14 +781,14 @@ static int iuu_uart_write(struct usb_serial_port *port, const u8 *buf,
773 781
774static void read_rxcmd_callback(struct urb *urb) 782static void read_rxcmd_callback(struct urb *urb)
775{ 783{
776 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 784 struct usb_serial_port *port = urb->context;
777 int result; 785 int result;
778 dbg("%s - enter", __FUNCTION__); 786 dbg("%s - enter", __func__);
779 787
780 dbg("%s - urb->status = %d", __FUNCTION__, urb->status); 788 dbg("%s - urb->status = %d", __func__, urb->status);
781 789
782 if (urb->status) { 790 if (urb->status) {
783 dbg("%s - urb->status = %d", __FUNCTION__, urb->status); 791 dbg("%s - urb->status = %d", __func__, urb->status);
784 /* error stop all */ 792 /* error stop all */
785 return; 793 return;
786 } 794 }
@@ -791,7 +799,7 @@ static void read_rxcmd_callback(struct urb *urb)
791 port->read_urb->transfer_buffer, 256, 799 port->read_urb->transfer_buffer, 256,
792 iuu_uart_read_callback, port); 800 iuu_uart_read_callback, port);
793 result = usb_submit_urb(port->read_urb, GFP_ATOMIC); 801 result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
794 dbg("%s - submit result = %d", __FUNCTION__, result); 802 dbg("%s - submit result = %d", __func__, result);
795 return; 803 return;
796} 804}
797 805
@@ -812,13 +820,13 @@ static int iuu_uart_on(struct usb_serial_port *port)
812 820
813 status = bulk_immediate(port, buf, 4); 821 status = bulk_immediate(port, buf, 4);
814 if (status != IUU_OPERATION_OK) { 822 if (status != IUU_OPERATION_OK) {
815 dbg("%s - uart_on error", __FUNCTION__); 823 dbg("%s - uart_on error", __func__);
816 goto uart_enable_failed; 824 goto uart_enable_failed;
817 } 825 }
818 /* iuu_reset() the card after iuu_uart_on() */ 826 /* iuu_reset() the card after iuu_uart_on() */
819 status = iuu_uart_flush(port); 827 status = iuu_uart_flush(port);
820 if (status != IUU_OPERATION_OK) 828 if (status != IUU_OPERATION_OK)
821 dbg("%s - uart_flush error", __FUNCTION__); 829 dbg("%s - uart_flush error", __func__);
822uart_enable_failed: 830uart_enable_failed:
823 kfree(buf); 831 kfree(buf);
824 return status; 832 return status;
@@ -836,7 +844,7 @@ static int iuu_uart_off(struct usb_serial_port *port)
836 844
837 status = bulk_immediate(port, buf, 1); 845 status = bulk_immediate(port, buf, 1);
838 if (status != IUU_OPERATION_OK) 846 if (status != IUU_OPERATION_OK)
839 dbg("%s - uart_off error", __FUNCTION__); 847 dbg("%s - uart_off error", __func__);
840 848
841 kfree(buf); 849 kfree(buf);
842 return status; 850 return status;
@@ -930,7 +938,7 @@ static int iuu_uart_baud(struct usb_serial_port *port, u32 baud,
930 938
931 status = bulk_immediate(port, dataout, DataCount); 939 status = bulk_immediate(port, dataout, DataCount);
932 if (status != IUU_OPERATION_OK) 940 if (status != IUU_OPERATION_OK)
933 dbg("%s - uart_off error", __FUNCTION__); 941 dbg("%s - uart_off error", __func__);
934 kfree(dataout); 942 kfree(dataout);
935 return status; 943 return status;
936} 944}
@@ -952,7 +960,7 @@ static void iuu_close(struct usb_serial_port *port, struct file *filp)
952 if (!serial) 960 if (!serial)
953 return; 961 return;
954 962
955 dbg("%s - port %d", __FUNCTION__, port->number); 963 dbg("%s - port %d", __func__, port->number);
956 964
957 iuu_uart_off(port); 965 iuu_uart_off(port);
958 if (serial->dev) { 966 if (serial->dev) {
@@ -969,7 +977,7 @@ static void iuu_close(struct usb_serial_port *port, struct file *filp)
969 } 977 }
970 /* free writebuf */ 978 /* free writebuf */
971 /* shutdown our urbs */ 979 /* shutdown our urbs */
972 dbg("%s - shutting down urbs", __FUNCTION__); 980 dbg("%s - shutting down urbs", __func__);
973 usb_kill_urb(port->write_urb); 981 usb_kill_urb(port->write_urb);
974 usb_kill_urb(port->read_urb); 982 usb_kill_urb(port->read_urb);
975 usb_kill_urb(port->interrupt_in_urb); 983 usb_kill_urb(port->interrupt_in_urb);
@@ -990,7 +998,7 @@ static int iuu_open(struct usb_serial_port *port, struct file *filp)
990 unsigned long flags; 998 unsigned long flags;
991 struct iuu_private *priv = usb_get_serial_port_data(port); 999 struct iuu_private *priv = usb_get_serial_port_data(port);
992 1000
993 dbg("%s - port %d", __FUNCTION__, port->number); 1001 dbg("%s - port %d", __func__, port->number);
994 usb_clear_halt(serial->dev, port->write_urb->pipe); 1002 usb_clear_halt(serial->dev, port->write_urb->pipe);
995 usb_clear_halt(serial->dev, port->read_urb->pipe); 1003 usb_clear_halt(serial->dev, port->read_urb->pipe);
996 1004
@@ -1127,7 +1135,7 @@ static int iuu_open(struct usb_serial_port *port, struct file *filp)
1127 1135
1128 iuu_uart_flush(port); 1136 iuu_uart_flush(port);
1129 1137
1130 dbg("%s - initialization done", __FUNCTION__); 1138 dbg("%s - initialization done", __func__);
1131 1139
1132 memset(port->write_urb->transfer_buffer, IUU_UART_RX, 1); 1140 memset(port->write_urb->transfer_buffer, IUU_UART_RX, 1);
1133 usb_fill_bulk_urb(port->write_urb, port->serial->dev, 1141 usb_fill_bulk_urb(port->write_urb, port->serial->dev,
@@ -1139,11 +1147,11 @@ static int iuu_open(struct usb_serial_port *port, struct file *filp)
1139 1147
1140 if (result) { 1148 if (result) {
1141 dev_err(&port->dev, "%s - failed submitting read urb," 1149 dev_err(&port->dev, "%s - failed submitting read urb,"
1142 " error %d\n", __FUNCTION__, result); 1150 " error %d\n", __func__, result);
1143 iuu_close(port, NULL); 1151 iuu_close(port, NULL);
1144 return -EPROTO; 1152 return -EPROTO;
1145 } else { 1153 } else {
1146 dbg("%s - rxcmd OK", __FUNCTION__); 1154 dbg("%s - rxcmd OK", __func__);
1147 } 1155 }
1148 return result; 1156 return result;
1149} 1157}
@@ -1154,9 +1162,6 @@ static struct usb_serial_driver iuu_device = {
1154 .name = "iuu_phoenix", 1162 .name = "iuu_phoenix",
1155 }, 1163 },
1156 .id_table = id_table, 1164 .id_table = id_table,
1157 .num_interrupt_in = NUM_DONT_CARE,
1158 .num_bulk_in = 1,
1159 .num_bulk_out = 1,
1160 .num_ports = 1, 1165 .num_ports = 1,
1161 .open = iuu_open, 1166 .open = iuu_open,
1162 .close = iuu_close, 1167 .close = iuu_close,
diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
index ea7bba69f4d..3df8a66c5c3 100644
--- a/drivers/usb/serial/keyspan.c
+++ b/drivers/usb/serial/keyspan.c
@@ -244,13 +244,13 @@ module_exit(keyspan_exit);
244 244
245static void keyspan_rx_throttle (struct usb_serial_port *port) 245static void keyspan_rx_throttle (struct usb_serial_port *port)
246{ 246{
247 dbg("%s - port %d", __FUNCTION__, port->number); 247 dbg("%s - port %d", __func__, port->number);
248} 248}
249 249
250 250
251static void keyspan_rx_unthrottle (struct usb_serial_port *port) 251static void keyspan_rx_unthrottle (struct usb_serial_port *port)
252{ 252{
253 dbg("%s - port %d", __FUNCTION__, port->number); 253 dbg("%s - port %d", __func__, port->number);
254} 254}
255 255
256 256
@@ -258,7 +258,7 @@ static void keyspan_break_ctl (struct usb_serial_port *port, int break_state)
258{ 258{
259 struct keyspan_port_private *p_priv; 259 struct keyspan_port_private *p_priv;
260 260
261 dbg("%s", __FUNCTION__); 261 dbg("%s", __func__);
262 262
263 p_priv = usb_get_serial_port_data(port); 263 p_priv = usb_get_serial_port_data(port);
264 264
@@ -280,7 +280,7 @@ static void keyspan_set_termios (struct usb_serial_port *port,
280 unsigned int cflag; 280 unsigned int cflag;
281 struct tty_struct *tty = port->tty; 281 struct tty_struct *tty = port->tty;
282 282
283 dbg("%s", __FUNCTION__); 283 dbg("%s", __func__);
284 284
285 p_priv = usb_get_serial_port_data(port); 285 p_priv = usb_get_serial_port_data(port);
286 d_details = p_priv->device_details; 286 d_details = p_priv->device_details;
@@ -377,7 +377,7 @@ static int keyspan_write(struct usb_serial_port *port,
377 } 377 }
378 378
379 dbg("%s - for port %d (%d chars), flip=%d", 379 dbg("%s - for port %d (%d chars), flip=%d",
380 __FUNCTION__, port->number, count, p_priv->out_flip); 380 __func__, port->number, count, p_priv->out_flip);
381 381
382 for (left = count; left > 0; left -= todo) { 382 for (left = count; left > 0; left -= todo) {
383 todo = left; 383 todo = left;
@@ -389,11 +389,11 @@ static int keyspan_write(struct usb_serial_port *port,
389 /* Check we have a valid urb/endpoint before we use it... */ 389 /* Check we have a valid urb/endpoint before we use it... */
390 if ((this_urb = p_priv->out_urbs[flip]) == NULL) { 390 if ((this_urb = p_priv->out_urbs[flip]) == NULL) {
391 /* no bulk out, so return 0 bytes written */ 391 /* no bulk out, so return 0 bytes written */
392 dbg("%s - no output urb :(", __FUNCTION__); 392 dbg("%s - no output urb :(", __func__);
393 return count; 393 return count;
394 } 394 }
395 395
396 dbg("%s - endpoint %d flip %d", __FUNCTION__, usb_pipeendpoint(this_urb->pipe), flip); 396 dbg("%s - endpoint %d flip %d", __func__, usb_pipeendpoint(this_urb->pipe), flip);
397 397
398 if (this_urb->status == -EINPROGRESS) { 398 if (this_urb->status == -EINPROGRESS) {
399 if (time_before(jiffies, p_priv->tx_start_time[flip] + 10 * HZ)) 399 if (time_before(jiffies, p_priv->tx_start_time[flip] + 10 * HZ))
@@ -435,17 +435,17 @@ static void usa26_indat_callback(struct urb *urb)
435 unsigned char *data = urb->transfer_buffer; 435 unsigned char *data = urb->transfer_buffer;
436 int status = urb->status; 436 int status = urb->status;
437 437
438 dbg ("%s", __FUNCTION__); 438 dbg ("%s", __func__);
439 439
440 endpoint = usb_pipeendpoint(urb->pipe); 440 endpoint = usb_pipeendpoint(urb->pipe);
441 441
442 if (status) { 442 if (status) {
443 dbg("%s - nonzero status: %x on endpoint %d.", 443 dbg("%s - nonzero status: %x on endpoint %d.",
444 __FUNCTION__, status, endpoint); 444 __func__, status, endpoint);
445 return; 445 return;
446 } 446 }
447 447
448 port = (struct usb_serial_port *) urb->context; 448 port = urb->context;
449 tty = port->tty; 449 tty = port->tty;
450 if (tty && urb->actual_length) { 450 if (tty && urb->actual_length) {
451 /* 0x80 bit is error flag */ 451 /* 0x80 bit is error flag */
@@ -459,7 +459,7 @@ static void usa26_indat_callback(struct urb *urb)
459 } 459 }
460 } else { 460 } else {
461 /* some bytes had errors, every byte has status */ 461 /* some bytes had errors, every byte has status */
462 dbg("%s - RX error!!!!", __FUNCTION__); 462 dbg("%s - RX error!!!!", __func__);
463 for (i = 0; i + 1 < urb->actual_length; i += 2) { 463 for (i = 0; i + 1 < urb->actual_length; i += 2) {
464 int stat = data[i], flag = 0; 464 int stat = data[i], flag = 0;
465 if (stat & RXERROR_OVERRUN) 465 if (stat & RXERROR_OVERRUN)
@@ -479,7 +479,7 @@ static void usa26_indat_callback(struct urb *urb)
479 urb->dev = port->serial->dev; 479 urb->dev = port->serial->dev;
480 if (port->open_count) 480 if (port->open_count)
481 if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { 481 if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) {
482 dbg("%s - resubmit read urb failed. (%d)", __FUNCTION__, err); 482 dbg("%s - resubmit read urb failed. (%d)", __func__, err);
483 } 483 }
484 return; 484 return;
485} 485}
@@ -490,9 +490,9 @@ static void usa2x_outdat_callback(struct urb *urb)
490 struct usb_serial_port *port; 490 struct usb_serial_port *port;
491 struct keyspan_port_private *p_priv; 491 struct keyspan_port_private *p_priv;
492 492
493 port = (struct usb_serial_port *) urb->context; 493 port = urb->context;
494 p_priv = usb_get_serial_port_data(port); 494 p_priv = usb_get_serial_port_data(port);
495 dbg ("%s - urb %d", __FUNCTION__, urb == p_priv->out_urbs[1]); 495 dbg ("%s - urb %d", __func__, urb == p_priv->out_urbs[1]);
496 496
497 if (port->open_count) 497 if (port->open_count)
498 usb_serial_port_softint(port); 498 usb_serial_port_softint(port);
@@ -500,7 +500,7 @@ static void usa2x_outdat_callback(struct urb *urb)
500 500
501static void usa26_inack_callback(struct urb *urb) 501static void usa26_inack_callback(struct urb *urb)
502{ 502{
503 dbg ("%s", __FUNCTION__); 503 dbg ("%s", __func__);
504 504
505} 505}
506 506
@@ -509,11 +509,11 @@ static void usa26_outcont_callback(struct urb *urb)
509 struct usb_serial_port *port; 509 struct usb_serial_port *port;
510 struct keyspan_port_private *p_priv; 510 struct keyspan_port_private *p_priv;
511 511
512 port = (struct usb_serial_port *) urb->context; 512 port = urb->context;
513 p_priv = usb_get_serial_port_data(port); 513 p_priv = usb_get_serial_port_data(port);
514 514
515 if (p_priv->resend_cont) { 515 if (p_priv->resend_cont) {
516 dbg ("%s - sending setup", __FUNCTION__); 516 dbg ("%s - sending setup", __func__);
517 keyspan_usa26_send_setup(port->serial, port, p_priv->resend_cont - 1); 517 keyspan_usa26_send_setup(port->serial, port, p_priv->resend_cont - 1);
518 } 518 }
519} 519}
@@ -528,14 +528,14 @@ static void usa26_instat_callback(struct urb *urb)
528 int old_dcd_state, err; 528 int old_dcd_state, err;
529 int status = urb->status; 529 int status = urb->status;
530 530
531 serial = (struct usb_serial *) urb->context; 531 serial = urb->context;
532 532
533 if (status) { 533 if (status) {
534 dbg("%s - nonzero status: %x", __FUNCTION__, status); 534 dbg("%s - nonzero status: %x", __func__, status);
535 return; 535 return;
536 } 536 }
537 if (urb->actual_length != 9) { 537 if (urb->actual_length != 9) {
538 dbg("%s - %d byte report??", __FUNCTION__, urb->actual_length); 538 dbg("%s - %d byte report??", __func__, urb->actual_length);
539 goto exit; 539 goto exit;
540 } 540 }
541 541
@@ -543,7 +543,7 @@ static void usa26_instat_callback(struct urb *urb)
543 543
544#if 0 544#if 0
545 dbg("%s - port status: port %d cts %d dcd %d dsr %d ri %d toff %d txoff %d rxen %d cr %d", 545 dbg("%s - port status: port %d cts %d dcd %d dsr %d ri %d toff %d txoff %d rxen %d cr %d",
546 __FUNCTION__, msg->port, msg->hskia_cts, msg->gpia_dcd, msg->dsr, msg->ri, msg->_txOff, 546 __func__, msg->port, msg->hskia_cts, msg->gpia_dcd, msg->dsr, msg->ri, msg->_txOff,
547 msg->_txXoff, msg->rxEnabled, msg->controlResponse); 547 msg->_txXoff, msg->rxEnabled, msg->controlResponse);
548#endif 548#endif
549 549
@@ -552,7 +552,7 @@ static void usa26_instat_callback(struct urb *urb)
552 552
553 /* Check port number from message and retrieve private data */ 553 /* Check port number from message and retrieve private data */
554 if (msg->port >= serial->num_ports) { 554 if (msg->port >= serial->num_ports) {
555 dbg ("%s - Unexpected port number %d", __FUNCTION__, msg->port); 555 dbg ("%s - Unexpected port number %d", __func__, msg->port);
556 goto exit; 556 goto exit;
557 } 557 }
558 port = serial->port[msg->port]; 558 port = serial->port[msg->port];
@@ -576,14 +576,14 @@ static void usa26_instat_callback(struct urb *urb)
576 /* Resubmit urb so we continue receiving */ 576 /* Resubmit urb so we continue receiving */
577 urb->dev = serial->dev; 577 urb->dev = serial->dev;
578 if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { 578 if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) {
579 dbg("%s - resubmit read urb failed. (%d)", __FUNCTION__, err); 579 dbg("%s - resubmit read urb failed. (%d)", __func__, err);
580 } 580 }
581exit: ; 581exit: ;
582} 582}
583 583
584static void usa26_glocont_callback(struct urb *urb) 584static void usa26_glocont_callback(struct urb *urb)
585{ 585{
586 dbg ("%s", __FUNCTION__); 586 dbg ("%s", __func__);
587 587
588} 588}
589 589
@@ -597,9 +597,9 @@ static void usa28_indat_callback(struct urb *urb)
597 struct keyspan_port_private *p_priv; 597 struct keyspan_port_private *p_priv;
598 int status = urb->status; 598 int status = urb->status;
599 599
600 dbg ("%s", __FUNCTION__); 600 dbg ("%s", __func__);
601 601
602 port = (struct usb_serial_port *) urb->context; 602 port = urb->context;
603 p_priv = usb_get_serial_port_data(port); 603 p_priv = usb_get_serial_port_data(port);
604 data = urb->transfer_buffer; 604 data = urb->transfer_buffer;
605 605
@@ -609,11 +609,11 @@ static void usa28_indat_callback(struct urb *urb)
609 do { 609 do {
610 if (status) { 610 if (status) {
611 dbg("%s - nonzero status: %x on endpoint %d.", 611 dbg("%s - nonzero status: %x on endpoint %d.",
612 __FUNCTION__, status, usb_pipeendpoint(urb->pipe)); 612 __func__, status, usb_pipeendpoint(urb->pipe));
613 return; 613 return;
614 } 614 }
615 615
616 port = (struct usb_serial_port *) urb->context; 616 port = urb->context;
617 p_priv = usb_get_serial_port_data(port); 617 p_priv = usb_get_serial_port_data(port);
618 data = urb->transfer_buffer; 618 data = urb->transfer_buffer;
619 619
@@ -629,7 +629,7 @@ static void usa28_indat_callback(struct urb *urb)
629 urb->dev = port->serial->dev; 629 urb->dev = port->serial->dev;
630 if (port->open_count) 630 if (port->open_count)
631 if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { 631 if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) {
632 dbg("%s - resubmit read urb failed. (%d)", __FUNCTION__, err); 632 dbg("%s - resubmit read urb failed. (%d)", __func__, err);
633 } 633 }
634 p_priv->in_flip ^= 1; 634 p_priv->in_flip ^= 1;
635 635
@@ -639,7 +639,7 @@ static void usa28_indat_callback(struct urb *urb)
639 639
640static void usa28_inack_callback(struct urb *urb) 640static void usa28_inack_callback(struct urb *urb)
641{ 641{
642 dbg ("%s", __FUNCTION__); 642 dbg ("%s", __func__);
643} 643}
644 644
645static void usa28_outcont_callback(struct urb *urb) 645static void usa28_outcont_callback(struct urb *urb)
@@ -647,11 +647,11 @@ static void usa28_outcont_callback(struct urb *urb)
647 struct usb_serial_port *port; 647 struct usb_serial_port *port;
648 struct keyspan_port_private *p_priv; 648 struct keyspan_port_private *p_priv;
649 649
650 port = (struct usb_serial_port *) urb->context; 650 port = urb->context;
651 p_priv = usb_get_serial_port_data(port); 651 p_priv = usb_get_serial_port_data(port);
652 652
653 if (p_priv->resend_cont) { 653 if (p_priv->resend_cont) {
654 dbg ("%s - sending setup", __FUNCTION__); 654 dbg ("%s - sending setup", __func__);
655 keyspan_usa28_send_setup(port->serial, port, p_priv->resend_cont - 1); 655 keyspan_usa28_send_setup(port->serial, port, p_priv->resend_cont - 1);
656 } 656 }
657} 657}
@@ -667,19 +667,19 @@ static void usa28_instat_callback(struct urb *urb)
667 int old_dcd_state; 667 int old_dcd_state;
668 int status = urb->status; 668 int status = urb->status;
669 669
670 serial = (struct usb_serial *) urb->context; 670 serial = urb->context;
671 671
672 if (status) { 672 if (status) {
673 dbg("%s - nonzero status: %x", __FUNCTION__, status); 673 dbg("%s - nonzero status: %x", __func__, status);
674 return; 674 return;
675 } 675 }
676 676
677 if (urb->actual_length != sizeof(struct keyspan_usa28_portStatusMessage)) { 677 if (urb->actual_length != sizeof(struct keyspan_usa28_portStatusMessage)) {
678 dbg("%s - bad length %d", __FUNCTION__, urb->actual_length); 678 dbg("%s - bad length %d", __func__, urb->actual_length);
679 goto exit; 679 goto exit;
680 } 680 }
681 681
682 /*dbg("%s %x %x %x %x %x %x %x %x %x %x %x %x", __FUNCTION__ 682 /*dbg("%s %x %x %x %x %x %x %x %x %x %x %x %x", __func__
683 data[0], data[1], data[2], data[3], data[4], data[5], 683 data[0], data[1], data[2], data[3], data[4], data[5],
684 data[6], data[7], data[8], data[9], data[10], data[11]);*/ 684 data[6], data[7], data[8], data[9], data[10], data[11]);*/
685 685
@@ -689,7 +689,7 @@ static void usa28_instat_callback(struct urb *urb)
689 689
690 /* Check port number from message and retrieve private data */ 690 /* Check port number from message and retrieve private data */
691 if (msg->port >= serial->num_ports) { 691 if (msg->port >= serial->num_ports) {
692 dbg ("%s - Unexpected port number %d", __FUNCTION__, msg->port); 692 dbg ("%s - Unexpected port number %d", __func__, msg->port);
693 goto exit; 693 goto exit;
694 } 694 }
695 port = serial->port[msg->port]; 695 port = serial->port[msg->port];
@@ -713,14 +713,14 @@ static void usa28_instat_callback(struct urb *urb)
713 /* Resubmit urb so we continue receiving */ 713 /* Resubmit urb so we continue receiving */
714 urb->dev = serial->dev; 714 urb->dev = serial->dev;
715 if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { 715 if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) {
716 dbg("%s - resubmit read urb failed. (%d)", __FUNCTION__, err); 716 dbg("%s - resubmit read urb failed. (%d)", __func__, err);
717 } 717 }
718exit: ; 718exit: ;
719} 719}
720 720
721static void usa28_glocont_callback(struct urb *urb) 721static void usa28_glocont_callback(struct urb *urb)
722{ 722{
723 dbg ("%s", __FUNCTION__); 723 dbg ("%s", __func__);
724} 724}
725 725
726 726
@@ -731,15 +731,15 @@ static void usa49_glocont_callback(struct urb *urb)
731 struct keyspan_port_private *p_priv; 731 struct keyspan_port_private *p_priv;
732 int i; 732 int i;
733 733
734 dbg ("%s", __FUNCTION__); 734 dbg ("%s", __func__);
735 735
736 serial = (struct usb_serial *) urb->context; 736 serial = urb->context;
737 for (i = 0; i < serial->num_ports; ++i) { 737 for (i = 0; i < serial->num_ports; ++i) {
738 port = serial->port[i]; 738 port = serial->port[i];
739 p_priv = usb_get_serial_port_data(port); 739 p_priv = usb_get_serial_port_data(port);
740 740
741 if (p_priv->resend_cont) { 741 if (p_priv->resend_cont) {
742 dbg ("%s - sending setup", __FUNCTION__); 742 dbg ("%s - sending setup", __func__);
743 keyspan_usa49_send_setup(serial, port, p_priv->resend_cont - 1); 743 keyspan_usa49_send_setup(serial, port, p_priv->resend_cont - 1);
744 break; 744 break;
745 } 745 }
@@ -759,21 +759,21 @@ static void usa49_instat_callback(struct urb *urb)
759 int old_dcd_state; 759 int old_dcd_state;
760 int status = urb->status; 760 int status = urb->status;
761 761
762 dbg ("%s", __FUNCTION__); 762 dbg ("%s", __func__);
763 763
764 serial = (struct usb_serial *) urb->context; 764 serial = urb->context;
765 765
766 if (status) { 766 if (status) {
767 dbg("%s - nonzero status: %x", __FUNCTION__, status); 767 dbg("%s - nonzero status: %x", __func__, status);
768 return; 768 return;
769 } 769 }
770 770
771 if (urb->actual_length != sizeof(struct keyspan_usa49_portStatusMessage)) { 771 if (urb->actual_length != sizeof(struct keyspan_usa49_portStatusMessage)) {
772 dbg("%s - bad length %d", __FUNCTION__, urb->actual_length); 772 dbg("%s - bad length %d", __func__, urb->actual_length);
773 goto exit; 773 goto exit;
774 } 774 }
775 775
776 /*dbg(" %x %x %x %x %x %x %x %x %x %x %x", __FUNCTION__, 776 /*dbg(" %x %x %x %x %x %x %x %x %x %x %x", __func__,
777 data[0], data[1], data[2], data[3], data[4], data[5], 777 data[0], data[1], data[2], data[3], data[4], data[5],
778 data[6], data[7], data[8], data[9], data[10]);*/ 778 data[6], data[7], data[8], data[9], data[10]);*/
779 779
@@ -782,7 +782,7 @@ static void usa49_instat_callback(struct urb *urb)
782 782
783 /* Check port number from message and retrieve private data */ 783 /* Check port number from message and retrieve private data */
784 if (msg->portNumber >= serial->num_ports) { 784 if (msg->portNumber >= serial->num_ports) {
785 dbg ("%s - Unexpected port number %d", __FUNCTION__, msg->portNumber); 785 dbg ("%s - Unexpected port number %d", __func__, msg->portNumber);
786 goto exit; 786 goto exit;
787 } 787 }
788 port = serial->port[msg->portNumber]; 788 port = serial->port[msg->portNumber];
@@ -807,14 +807,14 @@ static void usa49_instat_callback(struct urb *urb)
807 urb->dev = serial->dev; 807 urb->dev = serial->dev;
808 808
809 if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { 809 if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) {
810 dbg("%s - resubmit read urb failed. (%d)", __FUNCTION__, err); 810 dbg("%s - resubmit read urb failed. (%d)", __func__, err);
811 } 811 }
812exit: ; 812exit: ;
813} 813}
814 814
815static void usa49_inack_callback(struct urb *urb) 815static void usa49_inack_callback(struct urb *urb)
816{ 816{
817 dbg ("%s", __FUNCTION__); 817 dbg ("%s", __func__);
818} 818}
819 819
820static void usa49_indat_callback(struct urb *urb) 820static void usa49_indat_callback(struct urb *urb)
@@ -826,17 +826,17 @@ static void usa49_indat_callback(struct urb *urb)
826 unsigned char *data = urb->transfer_buffer; 826 unsigned char *data = urb->transfer_buffer;
827 int status = urb->status; 827 int status = urb->status;
828 828
829 dbg ("%s", __FUNCTION__); 829 dbg ("%s", __func__);
830 830
831 endpoint = usb_pipeendpoint(urb->pipe); 831 endpoint = usb_pipeendpoint(urb->pipe);
832 832
833 if (status) { 833 if (status) {
834 dbg("%s - nonzero status: %x on endpoint %d.", __FUNCTION__, 834 dbg("%s - nonzero status: %x on endpoint %d.", __func__,
835 status, endpoint); 835 status, endpoint);
836 return; 836 return;
837 } 837 }
838 838
839 port = (struct usb_serial_port *) urb->context; 839 port = urb->context;
840 tty = port->tty; 840 tty = port->tty;
841 if (tty && urb->actual_length) { 841 if (tty && urb->actual_length) {
842 /* 0x80 bit is error flag */ 842 /* 0x80 bit is error flag */
@@ -866,7 +866,7 @@ static void usa49_indat_callback(struct urb *urb)
866 urb->dev = port->serial->dev; 866 urb->dev = port->serial->dev;
867 if (port->open_count) 867 if (port->open_count)
868 if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { 868 if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) {
869 dbg("%s - resubmit read urb failed. (%d)", __FUNCTION__, err); 869 dbg("%s - resubmit read urb failed. (%d)", __func__, err);
870 } 870 }
871} 871}
872 872
@@ -879,12 +879,12 @@ static void usa49wg_indat_callback(struct urb *urb)
879 unsigned char *data = urb->transfer_buffer; 879 unsigned char *data = urb->transfer_buffer;
880 int status = urb->status; 880 int status = urb->status;
881 881
882 dbg ("%s", __FUNCTION__); 882 dbg ("%s", __func__);
883 883
884 serial = urb->context; 884 serial = urb->context;
885 885
886 if (status) { 886 if (status) {
887 dbg("%s - nonzero status: %x", __FUNCTION__, status); 887 dbg("%s - nonzero status: %x", __func__, status);
888 return; 888 return;
889 } 889 }
890 890
@@ -898,7 +898,7 @@ static void usa49wg_indat_callback(struct urb *urb)
898 /* Check port number from message*/ 898 /* Check port number from message*/
899 if (data[i] >= serial->num_ports) { 899 if (data[i] >= serial->num_ports) {
900 dbg ("%s - Unexpected port number %d", 900 dbg ("%s - Unexpected port number %d",
901 __FUNCTION__, data[i]); 901 __func__, data[i]);
902 return; 902 return;
903 } 903 }
904 port = serial->port[data[i++]]; 904 port = serial->port[data[i++]];
@@ -944,13 +944,13 @@ static void usa49wg_indat_callback(struct urb *urb)
944 944
945 err = usb_submit_urb(urb, GFP_ATOMIC); 945 err = usb_submit_urb(urb, GFP_ATOMIC);
946 if (err != 0) 946 if (err != 0)
947 dbg("%s - resubmit read urb failed. (%d)", __FUNCTION__, err); 947 dbg("%s - resubmit read urb failed. (%d)", __func__, err);
948} 948}
949 949
950/* not used, usa-49 doesn't have per-port control endpoints */ 950/* not used, usa-49 doesn't have per-port control endpoints */
951static void usa49_outcont_callback(struct urb *urb) 951static void usa49_outcont_callback(struct urb *urb)
952{ 952{
953 dbg ("%s", __FUNCTION__); 953 dbg ("%s", __func__);
954} 954}
955 955
956static void usa90_indat_callback(struct urb *urb) 956static void usa90_indat_callback(struct urb *urb)
@@ -963,17 +963,17 @@ static void usa90_indat_callback(struct urb *urb)
963 unsigned char *data = urb->transfer_buffer; 963 unsigned char *data = urb->transfer_buffer;
964 int status = urb->status; 964 int status = urb->status;
965 965
966 dbg ("%s", __FUNCTION__); 966 dbg ("%s", __func__);
967 967
968 endpoint = usb_pipeendpoint(urb->pipe); 968 endpoint = usb_pipeendpoint(urb->pipe);
969 969
970 if (status) { 970 if (status) {
971 dbg("%s - nonzero status: %x on endpoint %d.", 971 dbg("%s - nonzero status: %x on endpoint %d.",
972 __FUNCTION__, status, endpoint); 972 __func__, status, endpoint);
973 return; 973 return;
974 } 974 }
975 975
976 port = (struct usb_serial_port *) urb->context; 976 port = urb->context;
977 p_priv = usb_get_serial_port_data(port); 977 p_priv = usb_get_serial_port_data(port);
978 978
979 tty = port->tty; 979 tty = port->tty;
@@ -1000,7 +1000,7 @@ static void usa90_indat_callback(struct urb *urb)
1000 } 1000 }
1001 else { 1001 else {
1002 /* some bytes had errors, every byte has status */ 1002 /* some bytes had errors, every byte has status */
1003 dbg("%s - RX error!!!!", __FUNCTION__); 1003 dbg("%s - RX error!!!!", __func__);
1004 for (i = 0; i + 1 < urb->actual_length; i += 2) { 1004 for (i = 0; i + 1 < urb->actual_length; i += 2) {
1005 int stat = data[i], flag = 0; 1005 int stat = data[i], flag = 0;
1006 if (stat & RXERROR_OVERRUN) 1006 if (stat & RXERROR_OVERRUN)
@@ -1021,7 +1021,7 @@ static void usa90_indat_callback(struct urb *urb)
1021 urb->dev = port->serial->dev; 1021 urb->dev = port->serial->dev;
1022 if (port->open_count) 1022 if (port->open_count)
1023 if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { 1023 if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) {
1024 dbg("%s - resubmit read urb failed. (%d)", __FUNCTION__, err); 1024 dbg("%s - resubmit read urb failed. (%d)", __func__, err);
1025 } 1025 }
1026 return; 1026 return;
1027} 1027}
@@ -1037,14 +1037,14 @@ static void usa90_instat_callback(struct urb *urb)
1037 int old_dcd_state, err; 1037 int old_dcd_state, err;
1038 int status = urb->status; 1038 int status = urb->status;
1039 1039
1040 serial = (struct usb_serial *) urb->context; 1040 serial = urb->context;
1041 1041
1042 if (status) { 1042 if (status) {
1043 dbg("%s - nonzero status: %x", __FUNCTION__, status); 1043 dbg("%s - nonzero status: %x", __func__, status);
1044 return; 1044 return;
1045 } 1045 }
1046 if (urb->actual_length < 14) { 1046 if (urb->actual_length < 14) {
1047 dbg("%s - %d byte report??", __FUNCTION__, urb->actual_length); 1047 dbg("%s - %d byte report??", __func__, urb->actual_length);
1048 goto exit; 1048 goto exit;
1049 } 1049 }
1050 1050
@@ -1073,7 +1073,7 @@ static void usa90_instat_callback(struct urb *urb)
1073 /* Resubmit urb so we continue receiving */ 1073 /* Resubmit urb so we continue receiving */
1074 urb->dev = serial->dev; 1074 urb->dev = serial->dev;
1075 if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { 1075 if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) {
1076 dbg("%s - resubmit read urb failed. (%d)", __FUNCTION__, err); 1076 dbg("%s - resubmit read urb failed. (%d)", __func__, err);
1077 } 1077 }
1078exit: 1078exit:
1079 ; 1079 ;
@@ -1084,11 +1084,11 @@ static void usa90_outcont_callback(struct urb *urb)
1084 struct usb_serial_port *port; 1084 struct usb_serial_port *port;
1085 struct keyspan_port_private *p_priv; 1085 struct keyspan_port_private *p_priv;
1086 1086
1087 port = (struct usb_serial_port *) urb->context; 1087 port = urb->context;
1088 p_priv = usb_get_serial_port_data(port); 1088 p_priv = usb_get_serial_port_data(port);
1089 1089
1090 if (p_priv->resend_cont) { 1090 if (p_priv->resend_cont) {
1091 dbg ("%s - sending setup", __FUNCTION__); 1091 dbg ("%s - sending setup", __func__);
1092 keyspan_usa90_send_setup(port->serial, port, p_priv->resend_cont - 1); 1092 keyspan_usa90_send_setup(port->serial, port, p_priv->resend_cont - 1);
1093 } 1093 }
1094} 1094}
@@ -1105,17 +1105,17 @@ static void usa67_instat_callback(struct urb *urb)
1105 int old_dcd_state; 1105 int old_dcd_state;
1106 int status = urb->status; 1106 int status = urb->status;
1107 1107
1108 dbg ("%s", __FUNCTION__); 1108 dbg ("%s", __func__);
1109 1109
1110 serial = urb->context; 1110 serial = urb->context;
1111 1111
1112 if (status) { 1112 if (status) {
1113 dbg("%s - nonzero status: %x", __FUNCTION__, status); 1113 dbg("%s - nonzero status: %x", __func__, status);
1114 return; 1114 return;
1115 } 1115 }
1116 1116
1117 if (urb->actual_length != sizeof(struct keyspan_usa67_portStatusMessage)) { 1117 if (urb->actual_length != sizeof(struct keyspan_usa67_portStatusMessage)) {
1118 dbg("%s - bad length %d", __FUNCTION__, urb->actual_length); 1118 dbg("%s - bad length %d", __func__, urb->actual_length);
1119 return; 1119 return;
1120 } 1120 }
1121 1121
@@ -1125,7 +1125,7 @@ static void usa67_instat_callback(struct urb *urb)
1125 1125
1126 /* Check port number from message and retrieve private data */ 1126 /* Check port number from message and retrieve private data */
1127 if (msg->port >= serial->num_ports) { 1127 if (msg->port >= serial->num_ports) {
1128 dbg ("%s - Unexpected port number %d", __FUNCTION__, msg->port); 1128 dbg ("%s - Unexpected port number %d", __func__, msg->port);
1129 return; 1129 return;
1130 } 1130 }
1131 1131
@@ -1149,7 +1149,7 @@ static void usa67_instat_callback(struct urb *urb)
1149 urb->dev = serial->dev; 1149 urb->dev = serial->dev;
1150 err = usb_submit_urb(urb, GFP_ATOMIC); 1150 err = usb_submit_urb(urb, GFP_ATOMIC);
1151 if (err != 0) 1151 if (err != 0)
1152 dbg("%s - resubmit read urb failed. (%d)", __FUNCTION__, err); 1152 dbg("%s - resubmit read urb failed. (%d)", __func__, err);
1153} 1153}
1154 1154
1155static void usa67_glocont_callback(struct urb *urb) 1155static void usa67_glocont_callback(struct urb *urb)
@@ -1159,7 +1159,7 @@ static void usa67_glocont_callback(struct urb *urb)
1159 struct keyspan_port_private *p_priv; 1159 struct keyspan_port_private *p_priv;
1160 int i; 1160 int i;
1161 1161
1162 dbg ("%s", __FUNCTION__); 1162 dbg ("%s", __func__);
1163 1163
1164 serial = urb->context; 1164 serial = urb->context;
1165 for (i = 0; i < serial->num_ports; ++i) { 1165 for (i = 0; i < serial->num_ports; ++i) {
@@ -1167,7 +1167,7 @@ static void usa67_glocont_callback(struct urb *urb)
1167 p_priv = usb_get_serial_port_data(port); 1167 p_priv = usb_get_serial_port_data(port);
1168 1168
1169 if (p_priv->resend_cont) { 1169 if (p_priv->resend_cont) {
1170 dbg ("%s - sending setup", __FUNCTION__); 1170 dbg ("%s - sending setup", __func__);
1171 keyspan_usa67_send_setup(serial, port, 1171 keyspan_usa67_send_setup(serial, port,
1172 p_priv->resend_cont - 1); 1172 p_priv->resend_cont - 1);
1173 break; 1173 break;
@@ -1183,10 +1183,11 @@ static int keyspan_write_room (struct usb_serial_port *port)
1183 int data_len; 1183 int data_len;
1184 struct urb *this_urb; 1184 struct urb *this_urb;
1185 1185
1186 dbg("%s", __FUNCTION__); 1186 dbg("%s", __func__);
1187 p_priv = usb_get_serial_port_data(port); 1187 p_priv = usb_get_serial_port_data(port);
1188 d_details = p_priv->device_details; 1188 d_details = p_priv->device_details;
1189 1189
1190 /* FIXME: locking */
1190 if (d_details->msg_format == msg_usa90) 1191 if (d_details->msg_format == msg_usa90)
1191 data_len = 64; 1192 data_len = 64;
1192 else 1193 else
@@ -1203,13 +1204,13 @@ static int keyspan_write_room (struct usb_serial_port *port)
1203 if (this_urb->status != -EINPROGRESS) 1204 if (this_urb->status != -EINPROGRESS)
1204 return (data_len); 1205 return (data_len);
1205 } 1206 }
1206 return (0); 1207 return 0;
1207} 1208}
1208 1209
1209 1210
1210static int keyspan_chars_in_buffer (struct usb_serial_port *port) 1211static int keyspan_chars_in_buffer (struct usb_serial_port *port)
1211{ 1212{
1212 return (0); 1213 return 0;
1213} 1214}
1214 1215
1215 1216
@@ -1228,7 +1229,7 @@ static int keyspan_open (struct usb_serial_port *port, struct file *filp)
1228 p_priv = usb_get_serial_port_data(port); 1229 p_priv = usb_get_serial_port_data(port);
1229 d_details = p_priv->device_details; 1230 d_details = p_priv->device_details;
1230 1231
1231 dbg("%s - port%d.", __FUNCTION__, port->number); 1232 dbg("%s - port%d.", __func__, port->number);
1232 1233
1233 /* Set some sane defaults */ 1234 /* Set some sane defaults */
1234 p_priv->rts_state = 1; 1235 p_priv->rts_state = 1;
@@ -1253,7 +1254,7 @@ static int keyspan_open (struct usb_serial_port *port, struct file *filp)
1253 usb_clear_halt(urb->dev, urb->pipe); 1254 usb_clear_halt(urb->dev, urb->pipe);
1254 1255
1255 if ((err = usb_submit_urb(urb, GFP_KERNEL)) != 0) { 1256 if ((err = usb_submit_urb(urb, GFP_KERNEL)) != 0) {
1256 dbg("%s - submit urb %d failed (%d)", __FUNCTION__, i, err); 1257 dbg("%s - submit urb %d failed (%d)", __func__, i, err);
1257 } 1258 }
1258 } 1259 }
1259 1260
@@ -1289,7 +1290,7 @@ static int keyspan_open (struct usb_serial_port *port, struct file *filp)
1289 //mdelay(100); 1290 //mdelay(100);
1290 //keyspan_set_termios(port, NULL); 1291 //keyspan_set_termios(port, NULL);
1291 1292
1292 return (0); 1293 return 0;
1293} 1294}
1294 1295
1295static inline void stop_urb(struct urb *urb) 1296static inline void stop_urb(struct urb *urb)
@@ -1305,7 +1306,7 @@ static void keyspan_close(struct usb_serial_port *port, struct file *filp)
1305 struct keyspan_serial_private *s_priv; 1306 struct keyspan_serial_private *s_priv;
1306 struct keyspan_port_private *p_priv; 1307 struct keyspan_port_private *p_priv;
1307 1308
1308 dbg("%s", __FUNCTION__); 1309 dbg("%s", __func__);
1309 s_priv = usb_get_serial_data(serial); 1310 s_priv = usb_get_serial_data(serial);
1310 p_priv = usb_get_serial_port_data(port); 1311 p_priv = usb_get_serial_port_data(port);
1311 1312
@@ -1320,7 +1321,7 @@ static void keyspan_close(struct usb_serial_port *port, struct file *filp)
1320 } 1321 }
1321 1322
1322 /*while (p_priv->outcont_urb->status == -EINPROGRESS) { 1323 /*while (p_priv->outcont_urb->status == -EINPROGRESS) {
1323 dbg("%s - urb in progress", __FUNCTION__); 1324 dbg("%s - urb in progress", __func__);
1324 }*/ 1325 }*/
1325 1326
1326 p_priv->out_flip = 0; 1327 p_priv->out_flip = 0;
@@ -1484,10 +1485,10 @@ static struct urb *keyspan_setup_urb (struct usb_serial *serial, int endpoint,
1484 if (endpoint == -1) 1485 if (endpoint == -1)
1485 return NULL; /* endpoint not needed */ 1486 return NULL; /* endpoint not needed */
1486 1487
1487 dbg ("%s - alloc for endpoint %d.", __FUNCTION__, endpoint); 1488 dbg ("%s - alloc for endpoint %d.", __func__, endpoint);
1488 urb = usb_alloc_urb(0, GFP_KERNEL); /* No ISO */ 1489 urb = usb_alloc_urb(0, GFP_KERNEL); /* No ISO */
1489 if (urb == NULL) { 1490 if (urb == NULL) {
1490 dbg ("%s - alloc for endpoint %d failed.", __FUNCTION__, endpoint); 1491 dbg ("%s - alloc for endpoint %d failed.", __func__, endpoint);
1491 return NULL; 1492 return NULL;
1492 } 1493 }
1493 1494
@@ -1588,7 +1589,7 @@ static void keyspan_setup_urbs(struct usb_serial *serial)
1588 struct callbacks *cback; 1589 struct callbacks *cback;
1589 int endp; 1590 int endp;
1590 1591
1591 dbg ("%s", __FUNCTION__); 1592 dbg ("%s", __func__);
1592 1593
1593 s_priv = usb_get_serial_data(serial); 1594 s_priv = usb_get_serial_data(serial);
1594 d_details = s_priv->device_details; 1595 d_details = s_priv->device_details;
@@ -1662,7 +1663,7 @@ static int keyspan_usa19_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi,
1662 div, /* divisor */ 1663 div, /* divisor */
1663 cnt; /* inverse of divisor (programmed into 8051) */ 1664 cnt; /* inverse of divisor (programmed into 8051) */
1664 1665
1665 dbg ("%s - %d.", __FUNCTION__, baud_rate); 1666 dbg ("%s - %d.", __func__, baud_rate);
1666 1667
1667 /* prevent divide by zero... */ 1668 /* prevent divide by zero... */
1668 if( (b16 = (baud_rate * 16L)) == 0) { 1669 if( (b16 = (baud_rate * 16L)) == 0) {
@@ -1695,7 +1696,7 @@ static int keyspan_usa19_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi,
1695 *rate_hi = (u8) ((cnt >> 8) & 0xff); 1696 *rate_hi = (u8) ((cnt >> 8) & 0xff);
1696 } 1697 }
1697 if (rate_low && rate_hi) { 1698 if (rate_low && rate_hi) {
1698 dbg ("%s - %d %02x %02x.", __FUNCTION__, baud_rate, *rate_hi, *rate_low); 1699 dbg ("%s - %d %02x %02x.", __func__, baud_rate, *rate_hi, *rate_low);
1699 } 1700 }
1700 1701
1701 return (KEYSPAN_BAUD_RATE_OK); 1702 return (KEYSPAN_BAUD_RATE_OK);
@@ -1708,7 +1709,7 @@ static int keyspan_usa19hs_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi,
1708 u32 b16, /* baud rate times 16 (actual rate used internally) */ 1709 u32 b16, /* baud rate times 16 (actual rate used internally) */
1709 div; /* divisor */ 1710 div; /* divisor */
1710 1711
1711 dbg ("%s - %d.", __FUNCTION__, baud_rate); 1712 dbg ("%s - %d.", __func__, baud_rate);
1712 1713
1713 /* prevent divide by zero... */ 1714 /* prevent divide by zero... */
1714 if( (b16 = (baud_rate * 16L)) == 0) 1715 if( (b16 = (baud_rate * 16L)) == 0)
@@ -1731,7 +1732,7 @@ static int keyspan_usa19hs_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi,
1731 *rate_hi = (u8) ((div >> 8) & 0xff); 1732 *rate_hi = (u8) ((div >> 8) & 0xff);
1732 1733
1733 if (rate_low && rate_hi) 1734 if (rate_low && rate_hi)
1734 dbg ("%s - %d %02x %02x.", __FUNCTION__, baud_rate, *rate_hi, *rate_low); 1735 dbg ("%s - %d %02x %02x.", __func__, baud_rate, *rate_hi, *rate_low);
1735 1736
1736 return (KEYSPAN_BAUD_RATE_OK); 1737 return (KEYSPAN_BAUD_RATE_OK);
1737} 1738}
@@ -1748,7 +1749,7 @@ static int keyspan_usa19w_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi,
1748 u8 best_prescaler; 1749 u8 best_prescaler;
1749 int i; 1750 int i;
1750 1751
1751 dbg ("%s - %d.", __FUNCTION__, baud_rate); 1752 dbg ("%s - %d.", __func__, baud_rate);
1752 1753
1753 /* prevent divide by zero */ 1754 /* prevent divide by zero */
1754 if( (b16 = baud_rate * 16L) == 0) { 1755 if( (b16 = baud_rate * 16L) == 0) {
@@ -1796,7 +1797,7 @@ static int keyspan_usa19w_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi,
1796 } 1797 }
1797 if (prescaler) { 1798 if (prescaler) {
1798 *prescaler = best_prescaler; 1799 *prescaler = best_prescaler;
1799 /* dbg("%s - %d %d", __FUNCTION__, *prescaler, div); */ 1800 /* dbg("%s - %d %d", __func__, *prescaler, div); */
1800 } 1801 }
1801 return (KEYSPAN_BAUD_RATE_OK); 1802 return (KEYSPAN_BAUD_RATE_OK);
1802} 1803}
@@ -1809,7 +1810,7 @@ static int keyspan_usa28_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi,
1809 div, /* divisor */ 1810 div, /* divisor */
1810 cnt; /* inverse of divisor (programmed into 8051) */ 1811 cnt; /* inverse of divisor (programmed into 8051) */
1811 1812
1812 dbg ("%s - %d.", __FUNCTION__, baud_rate); 1813 dbg ("%s - %d.", __func__, baud_rate);
1813 1814
1814 /* prevent divide by zero */ 1815 /* prevent divide by zero */
1815 if ((b16 = baud_rate * 16L) == 0) 1816 if ((b16 = baud_rate * 16L) == 0)
@@ -1848,7 +1849,7 @@ static int keyspan_usa28_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi,
1848 if (rate_hi) { 1849 if (rate_hi) {
1849 *rate_hi = (u8) ((cnt >> 8) & 0xff); 1850 *rate_hi = (u8) ((cnt >> 8) & 0xff);
1850 } 1851 }
1851 dbg ("%s - %d OK.", __FUNCTION__, baud_rate); 1852 dbg ("%s - %d OK.", __func__, baud_rate);
1852 return (KEYSPAN_BAUD_RATE_OK); 1853 return (KEYSPAN_BAUD_RATE_OK);
1853} 1854}
1854 1855
@@ -1864,7 +1865,7 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial,
1864 struct urb *this_urb; 1865 struct urb *this_urb;
1865 int device_port, err; 1866 int device_port, err;
1866 1867
1867 dbg ("%s reset=%d", __FUNCTION__, reset_port); 1868 dbg ("%s reset=%d", __func__, reset_port);
1868 1869
1869 s_priv = usb_get_serial_data(serial); 1870 s_priv = usb_get_serial_data(serial);
1870 p_priv = usb_get_serial_port_data(port); 1871 p_priv = usb_get_serial_port_data(port);
@@ -1874,11 +1875,11 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial,
1874 outcont_urb = d_details->outcont_endpoints[port->number]; 1875 outcont_urb = d_details->outcont_endpoints[port->number];
1875 this_urb = p_priv->outcont_urb; 1876 this_urb = p_priv->outcont_urb;
1876 1877
1877 dbg("%s - endpoint %d", __FUNCTION__, usb_pipeendpoint(this_urb->pipe)); 1878 dbg("%s - endpoint %d", __func__, usb_pipeendpoint(this_urb->pipe));
1878 1879
1879 /* Make sure we have an urb then send the message */ 1880 /* Make sure we have an urb then send the message */
1880 if (this_urb == NULL) { 1881 if (this_urb == NULL) {
1881 dbg("%s - oops no urb.", __FUNCTION__); 1882 dbg("%s - oops no urb.", __func__);
1882 return -1; 1883 return -1;
1883 } 1884 }
1884 1885
@@ -1887,7 +1888,7 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial,
1887 if ((reset_port + 1) > p_priv->resend_cont) 1888 if ((reset_port + 1) > p_priv->resend_cont)
1888 p_priv->resend_cont = reset_port + 1; 1889 p_priv->resend_cont = reset_port + 1;
1889 if (this_urb->status == -EINPROGRESS) { 1890 if (this_urb->status == -EINPROGRESS) {
1890 /* dbg ("%s - already writing", __FUNCTION__); */ 1891 /* dbg ("%s - already writing", __func__); */
1891 mdelay(5); 1892 mdelay(5);
1892 return(-1); 1893 return(-1);
1893 } 1894 }
@@ -1901,7 +1902,7 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial,
1901 if (d_details->calculate_baud_rate 1902 if (d_details->calculate_baud_rate
1902 (p_priv->baud, d_details->baudclk, &msg.baudHi, 1903 (p_priv->baud, d_details->baudclk, &msg.baudHi,
1903 &msg.baudLo, &msg.prescaler, device_port) == KEYSPAN_INVALID_BAUD_RATE ) { 1904 &msg.baudLo, &msg.prescaler, device_port) == KEYSPAN_INVALID_BAUD_RATE ) {
1904 dbg("%s - Invalid baud rate %d requested, using 9600.", __FUNCTION__, 1905 dbg("%s - Invalid baud rate %d requested, using 9600.", __func__,
1905 p_priv->baud); 1906 p_priv->baud);
1906 msg.baudLo = 0; 1907 msg.baudLo = 0;
1907 msg.baudHi = 125; /* Values for 9600 baud */ 1908 msg.baudHi = 125; /* Values for 9600 baud */
@@ -1996,17 +1997,17 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial,
1996 1997
1997 this_urb->dev = serial->dev; 1998 this_urb->dev = serial->dev;
1998 if ((err = usb_submit_urb(this_urb, GFP_ATOMIC)) != 0) { 1999 if ((err = usb_submit_urb(this_urb, GFP_ATOMIC)) != 0) {
1999 dbg("%s - usb_submit_urb(setup) failed (%d)", __FUNCTION__, err); 2000 dbg("%s - usb_submit_urb(setup) failed (%d)", __func__, err);
2000 } 2001 }
2001#if 0 2002#if 0
2002 else { 2003 else {
2003 dbg("%s - usb_submit_urb(%d) OK %d bytes (end %d)", __FUNCTION__ 2004 dbg("%s - usb_submit_urb(%d) OK %d bytes (end %d)", __func__
2004 outcont_urb, this_urb->transfer_buffer_length, 2005 outcont_urb, this_urb->transfer_buffer_length,
2005 usb_pipeendpoint(this_urb->pipe)); 2006 usb_pipeendpoint(this_urb->pipe));
2006 } 2007 }
2007#endif 2008#endif
2008 2009
2009 return (0); 2010 return 0;
2010} 2011}
2011 2012
2012static int keyspan_usa28_send_setup(struct usb_serial *serial, 2013static int keyspan_usa28_send_setup(struct usb_serial *serial,
@@ -2020,7 +2021,7 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial,
2020 struct urb *this_urb; 2021 struct urb *this_urb;
2021 int device_port, err; 2022 int device_port, err;
2022 2023
2023 dbg ("%s", __FUNCTION__); 2024 dbg ("%s", __func__);
2024 2025
2025 s_priv = usb_get_serial_data(serial); 2026 s_priv = usb_get_serial_data(serial);
2026 p_priv = usb_get_serial_port_data(port); 2027 p_priv = usb_get_serial_port_data(port);
@@ -2029,7 +2030,7 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial,
2029 2030
2030 /* only do something if we have a bulk out endpoint */ 2031 /* only do something if we have a bulk out endpoint */
2031 if ((this_urb = p_priv->outcont_urb) == NULL) { 2032 if ((this_urb = p_priv->outcont_urb) == NULL) {
2032 dbg("%s - oops no urb.", __FUNCTION__); 2033 dbg("%s - oops no urb.", __func__);
2033 return -1; 2034 return -1;
2034 } 2035 }
2035 2036
@@ -2038,7 +2039,7 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial,
2038 if ((reset_port + 1) > p_priv->resend_cont) 2039 if ((reset_port + 1) > p_priv->resend_cont)
2039 p_priv->resend_cont = reset_port + 1; 2040 p_priv->resend_cont = reset_port + 1;
2040 if (this_urb->status == -EINPROGRESS) { 2041 if (this_urb->status == -EINPROGRESS) {
2041 dbg ("%s already writing", __FUNCTION__); 2042 dbg ("%s already writing", __func__);
2042 mdelay(5); 2043 mdelay(5);
2043 return(-1); 2044 return(-1);
2044 } 2045 }
@@ -2048,7 +2049,7 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial,
2048 msg.setBaudRate = 1; 2049 msg.setBaudRate = 1;
2049 if (d_details->calculate_baud_rate(p_priv->baud, d_details->baudclk, 2050 if (d_details->calculate_baud_rate(p_priv->baud, d_details->baudclk,
2050 &msg.baudHi, &msg.baudLo, NULL, device_port) == KEYSPAN_INVALID_BAUD_RATE ) { 2051 &msg.baudHi, &msg.baudLo, NULL, device_port) == KEYSPAN_INVALID_BAUD_RATE ) {
2051 dbg("%s - Invalid baud rate requested %d.", __FUNCTION__, p_priv->baud); 2052 dbg("%s - Invalid baud rate requested %d.", __func__, p_priv->baud);
2052 msg.baudLo = 0xff; 2053 msg.baudLo = 0xff;
2053 msg.baudHi = 0xb2; /* Values for 9600 baud */ 2054 msg.baudHi = 0xb2; /* Values for 9600 baud */
2054 } 2055 }
@@ -2122,16 +2123,16 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial,
2122 2123
2123 this_urb->dev = serial->dev; 2124 this_urb->dev = serial->dev;
2124 if ((err = usb_submit_urb(this_urb, GFP_ATOMIC)) != 0) { 2125 if ((err = usb_submit_urb(this_urb, GFP_ATOMIC)) != 0) {
2125 dbg("%s - usb_submit_urb(setup) failed", __FUNCTION__); 2126 dbg("%s - usb_submit_urb(setup) failed", __func__);
2126 } 2127 }
2127#if 0 2128#if 0
2128 else { 2129 else {
2129 dbg("%s - usb_submit_urb(setup) OK %d bytes", __FUNCTION__, 2130 dbg("%s - usb_submit_urb(setup) OK %d bytes", __func__,
2130 this_urb->transfer_buffer_length); 2131 this_urb->transfer_buffer_length);
2131 } 2132 }
2132#endif 2133#endif
2133 2134
2134 return (0); 2135 return 0;
2135} 2136}
2136 2137
2137static int keyspan_usa49_send_setup(struct usb_serial *serial, 2138static int keyspan_usa49_send_setup(struct usb_serial *serial,
@@ -2146,7 +2147,7 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial,
2146 struct urb *this_urb; 2147 struct urb *this_urb;
2147 int err, device_port; 2148 int err, device_port;
2148 2149
2149 dbg ("%s", __FUNCTION__); 2150 dbg ("%s", __func__);
2150 2151
2151 s_priv = usb_get_serial_data(serial); 2152 s_priv = usb_get_serial_data(serial);
2152 p_priv = usb_get_serial_port_data(port); 2153 p_priv = usb_get_serial_port_data(port);
@@ -2157,11 +2158,11 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial,
2157 /* Work out which port within the device is being setup */ 2158 /* Work out which port within the device is being setup */
2158 device_port = port->number - port->serial->minor; 2159 device_port = port->number - port->serial->minor;
2159 2160
2160 dbg("%s - endpoint %d port %d (%d)",__FUNCTION__, usb_pipeendpoint(this_urb->pipe), port->number, device_port); 2161 dbg("%s - endpoint %d port %d (%d)",__func__, usb_pipeendpoint(this_urb->pipe), port->number, device_port);
2161 2162
2162 /* Make sure we have an urb then send the message */ 2163 /* Make sure we have an urb then send the message */
2163 if (this_urb == NULL) { 2164 if (this_urb == NULL) {
2164 dbg("%s - oops no urb for port %d.", __FUNCTION__, port->number); 2165 dbg("%s - oops no urb for port %d.", __func__, port->number);
2165 return -1; 2166 return -1;
2166 } 2167 }
2167 2168
@@ -2171,7 +2172,7 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial,
2171 p_priv->resend_cont = reset_port + 1; 2172 p_priv->resend_cont = reset_port + 1;
2172 2173
2173 if (this_urb->status == -EINPROGRESS) { 2174 if (this_urb->status == -EINPROGRESS) {
2174 /* dbg ("%s - already writing", __FUNCTION__); */ 2175 /* dbg ("%s - already writing", __func__); */
2175 mdelay(5); 2176 mdelay(5);
2176 return(-1); 2177 return(-1);
2177 } 2178 }
@@ -2188,7 +2189,7 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial,
2188 if (d_details->calculate_baud_rate 2189 if (d_details->calculate_baud_rate
2189 (p_priv->baud, d_details->baudclk, &msg.baudHi, 2190 (p_priv->baud, d_details->baudclk, &msg.baudHi,
2190 &msg.baudLo, &msg.prescaler, device_port) == KEYSPAN_INVALID_BAUD_RATE ) { 2191 &msg.baudLo, &msg.prescaler, device_port) == KEYSPAN_INVALID_BAUD_RATE ) {
2191 dbg("%s - Invalid baud rate %d requested, using 9600.", __FUNCTION__, 2192 dbg("%s - Invalid baud rate %d requested, using 9600.", __func__,
2192 p_priv->baud); 2193 p_priv->baud);
2193 msg.baudLo = 0; 2194 msg.baudLo = 0;
2194 msg.baudHi = 125; /* Values for 9600 baud */ 2195 msg.baudHi = 125; /* Values for 9600 baud */
@@ -2307,17 +2308,17 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial,
2307 this_urb->dev = serial->dev; 2308 this_urb->dev = serial->dev;
2308 } 2309 }
2309 if ((err = usb_submit_urb(this_urb, GFP_ATOMIC)) != 0) { 2310 if ((err = usb_submit_urb(this_urb, GFP_ATOMIC)) != 0) {
2310 dbg("%s - usb_submit_urb(setup) failed (%d)", __FUNCTION__, err); 2311 dbg("%s - usb_submit_urb(setup) failed (%d)", __func__, err);
2311 } 2312 }
2312#if 0 2313#if 0
2313 else { 2314 else {
2314 dbg("%s - usb_submit_urb(%d) OK %d bytes (end %d)", __FUNCTION__, 2315 dbg("%s - usb_submit_urb(%d) OK %d bytes (end %d)", __func__,
2315 outcont_urb, this_urb->transfer_buffer_length, 2316 outcont_urb, this_urb->transfer_buffer_length,
2316 usb_pipeendpoint(this_urb->pipe)); 2317 usb_pipeendpoint(this_urb->pipe));
2317 } 2318 }
2318#endif 2319#endif
2319 2320
2320 return (0); 2321 return 0;
2321} 2322}
2322 2323
2323static int keyspan_usa90_send_setup(struct usb_serial *serial, 2324static int keyspan_usa90_send_setup(struct usb_serial *serial,
@@ -2332,7 +2333,7 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial,
2332 int err; 2333 int err;
2333 u8 prescaler; 2334 u8 prescaler;
2334 2335
2335 dbg ("%s", __FUNCTION__); 2336 dbg ("%s", __func__);
2336 2337
2337 s_priv = usb_get_serial_data(serial); 2338 s_priv = usb_get_serial_data(serial);
2338 p_priv = usb_get_serial_port_data(port); 2339 p_priv = usb_get_serial_port_data(port);
@@ -2340,7 +2341,7 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial,
2340 2341
2341 /* only do something if we have a bulk out endpoint */ 2342 /* only do something if we have a bulk out endpoint */
2342 if ((this_urb = p_priv->outcont_urb) == NULL) { 2343 if ((this_urb = p_priv->outcont_urb) == NULL) {
2343 dbg("%s - oops no urb.", __FUNCTION__); 2344 dbg("%s - oops no urb.", __func__);
2344 return -1; 2345 return -1;
2345 } 2346 }
2346 2347
@@ -2349,7 +2350,7 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial,
2349 if ((reset_port + 1) > p_priv->resend_cont) 2350 if ((reset_port + 1) > p_priv->resend_cont)
2350 p_priv->resend_cont = reset_port + 1; 2351 p_priv->resend_cont = reset_port + 1;
2351 if (this_urb->status == -EINPROGRESS) { 2352 if (this_urb->status == -EINPROGRESS) {
2352 dbg ("%s already writing", __FUNCTION__); 2353 dbg ("%s already writing", __func__);
2353 mdelay(5); 2354 mdelay(5);
2354 return(-1); 2355 return(-1);
2355 } 2356 }
@@ -2363,7 +2364,7 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial,
2363 if (d_details->calculate_baud_rate 2364 if (d_details->calculate_baud_rate
2364 (p_priv->baud, d_details->baudclk, &msg.baudHi, 2365 (p_priv->baud, d_details->baudclk, &msg.baudHi,
2365 &msg.baudLo, &prescaler, 0) == KEYSPAN_INVALID_BAUD_RATE ) { 2366 &msg.baudLo, &prescaler, 0) == KEYSPAN_INVALID_BAUD_RATE ) {
2366 dbg("%s - Invalid baud rate %d requested, using 9600.", __FUNCTION__, 2367 dbg("%s - Invalid baud rate %d requested, using 9600.", __func__,
2367 p_priv->baud); 2368 p_priv->baud);
2368 p_priv->baud = 9600; 2369 p_priv->baud = 9600;
2369 d_details->calculate_baud_rate (p_priv->baud, d_details->baudclk, 2370 d_details->calculate_baud_rate (p_priv->baud, d_details->baudclk,
@@ -2453,9 +2454,9 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial,
2453 2454
2454 this_urb->dev = serial->dev; 2455 this_urb->dev = serial->dev;
2455 if ((err = usb_submit_urb(this_urb, GFP_ATOMIC)) != 0) { 2456 if ((err = usb_submit_urb(this_urb, GFP_ATOMIC)) != 0) {
2456 dbg("%s - usb_submit_urb(setup) failed (%d)", __FUNCTION__, err); 2457 dbg("%s - usb_submit_urb(setup) failed (%d)", __func__, err);
2457 } 2458 }
2458 return (0); 2459 return 0;
2459} 2460}
2460 2461
2461static int keyspan_usa67_send_setup(struct usb_serial *serial, 2462static int keyspan_usa67_send_setup(struct usb_serial *serial,
@@ -2469,7 +2470,7 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial,
2469 struct urb *this_urb; 2470 struct urb *this_urb;
2470 int err, device_port; 2471 int err, device_port;
2471 2472
2472 dbg ("%s", __FUNCTION__); 2473 dbg ("%s", __func__);
2473 2474
2474 s_priv = usb_get_serial_data(serial); 2475 s_priv = usb_get_serial_data(serial);
2475 p_priv = usb_get_serial_port_data(port); 2476 p_priv = usb_get_serial_port_data(port);
@@ -2482,7 +2483,7 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial,
2482 2483
2483 /* Make sure we have an urb then send the message */ 2484 /* Make sure we have an urb then send the message */
2484 if (this_urb == NULL) { 2485 if (this_urb == NULL) {
2485 dbg("%s - oops no urb for port %d.", __FUNCTION__, 2486 dbg("%s - oops no urb for port %d.", __func__,
2486 port->number); 2487 port->number);
2487 return -1; 2488 return -1;
2488 } 2489 }
@@ -2492,7 +2493,7 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial,
2492 if ((reset_port + 1) > p_priv->resend_cont) 2493 if ((reset_port + 1) > p_priv->resend_cont)
2493 p_priv->resend_cont = reset_port + 1; 2494 p_priv->resend_cont = reset_port + 1;
2494 if (this_urb->status == -EINPROGRESS) { 2495 if (this_urb->status == -EINPROGRESS) {
2495 /* dbg ("%s - already writing", __FUNCTION__); */ 2496 /* dbg ("%s - already writing", __func__); */
2496 mdelay(5); 2497 mdelay(5);
2497 return(-1); 2498 return(-1);
2498 } 2499 }
@@ -2508,7 +2509,7 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial,
2508 if (d_details->calculate_baud_rate 2509 if (d_details->calculate_baud_rate
2509 (p_priv->baud, d_details->baudclk, &msg.baudHi, 2510 (p_priv->baud, d_details->baudclk, &msg.baudHi,
2510 &msg.baudLo, &msg.prescaler, device_port) == KEYSPAN_INVALID_BAUD_RATE ) { 2511 &msg.baudLo, &msg.prescaler, device_port) == KEYSPAN_INVALID_BAUD_RATE ) {
2511 dbg("%s - Invalid baud rate %d requested, using 9600.", __FUNCTION__, 2512 dbg("%s - Invalid baud rate %d requested, using 9600.", __func__,
2512 p_priv->baud); 2513 p_priv->baud);
2513 msg.baudLo = 0; 2514 msg.baudLo = 0;
2514 msg.baudHi = 125; /* Values for 9600 baud */ 2515 msg.baudHi = 125; /* Values for 9600 baud */
@@ -2601,9 +2602,9 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial,
2601 2602
2602 err = usb_submit_urb(this_urb, GFP_ATOMIC); 2603 err = usb_submit_urb(this_urb, GFP_ATOMIC);
2603 if (err != 0) 2604 if (err != 0)
2604 dbg("%s - usb_submit_urb(setup) failed (%d)", __FUNCTION__, 2605 dbg("%s - usb_submit_urb(setup) failed (%d)", __func__,
2605 err); 2606 err);
2606 return (0); 2607 return 0;
2607} 2608}
2608 2609
2609static void keyspan_send_setup(struct usb_serial_port *port, int reset_port) 2610static void keyspan_send_setup(struct usb_serial_port *port, int reset_port)
@@ -2612,7 +2613,7 @@ static void keyspan_send_setup(struct usb_serial_port *port, int reset_port)
2612 struct keyspan_serial_private *s_priv; 2613 struct keyspan_serial_private *s_priv;
2613 const struct keyspan_device_details *d_details; 2614 const struct keyspan_device_details *d_details;
2614 2615
2615 dbg ("%s", __FUNCTION__); 2616 dbg ("%s", __func__);
2616 2617
2617 s_priv = usb_get_serial_data(serial); 2618 s_priv = usb_get_serial_data(serial);
2618 d_details = s_priv->device_details; 2619 d_details = s_priv->device_details;
@@ -2647,20 +2648,20 @@ static int keyspan_startup (struct usb_serial *serial)
2647 struct keyspan_port_private *p_priv; 2648 struct keyspan_port_private *p_priv;
2648 const struct keyspan_device_details *d_details; 2649 const struct keyspan_device_details *d_details;
2649 2650
2650 dbg("%s", __FUNCTION__); 2651 dbg("%s", __func__);
2651 2652
2652 for (i = 0; (d_details = keyspan_devices[i]) != NULL; ++i) 2653 for (i = 0; (d_details = keyspan_devices[i]) != NULL; ++i)
2653 if (d_details->product_id == le16_to_cpu(serial->dev->descriptor.idProduct)) 2654 if (d_details->product_id == le16_to_cpu(serial->dev->descriptor.idProduct))
2654 break; 2655 break;
2655 if (d_details == NULL) { 2656 if (d_details == NULL) {
2656 dev_err(&serial->dev->dev, "%s - unknown product id %x\n", __FUNCTION__, le16_to_cpu(serial->dev->descriptor.idProduct)); 2657 dev_err(&serial->dev->dev, "%s - unknown product id %x\n", __func__, le16_to_cpu(serial->dev->descriptor.idProduct));
2657 return 1; 2658 return 1;
2658 } 2659 }
2659 2660
2660 /* Setup private data for serial driver */ 2661 /* Setup private data for serial driver */
2661 s_priv = kzalloc(sizeof(struct keyspan_serial_private), GFP_KERNEL); 2662 s_priv = kzalloc(sizeof(struct keyspan_serial_private), GFP_KERNEL);
2662 if (!s_priv) { 2663 if (!s_priv) {
2663 dbg("%s - kmalloc for keyspan_serial_private failed.", __FUNCTION__); 2664 dbg("%s - kmalloc for keyspan_serial_private failed.", __func__);
2664 return -ENOMEM; 2665 return -ENOMEM;
2665 } 2666 }
2666 2667
@@ -2672,7 +2673,7 @@ static int keyspan_startup (struct usb_serial *serial)
2672 port = serial->port[i]; 2673 port = serial->port[i];
2673 p_priv = kzalloc(sizeof(struct keyspan_port_private), GFP_KERNEL); 2674 p_priv = kzalloc(sizeof(struct keyspan_port_private), GFP_KERNEL);
2674 if (!p_priv) { 2675 if (!p_priv) {
2675 dbg("%s - kmalloc for keyspan_port_private (%d) failed!.", __FUNCTION__, i); 2676 dbg("%s - kmalloc for keyspan_port_private (%d) failed!.", __func__, i);
2676 return (1); 2677 return (1);
2677 } 2678 }
2678 p_priv->device_details = d_details; 2679 p_priv->device_details = d_details;
@@ -2685,18 +2686,18 @@ static int keyspan_startup (struct usb_serial *serial)
2685 s_priv->instat_urb->dev = serial->dev; 2686 s_priv->instat_urb->dev = serial->dev;
2686 err = usb_submit_urb(s_priv->instat_urb, GFP_KERNEL); 2687 err = usb_submit_urb(s_priv->instat_urb, GFP_KERNEL);
2687 if (err != 0) 2688 if (err != 0)
2688 dbg("%s - submit instat urb failed %d", __FUNCTION__, 2689 dbg("%s - submit instat urb failed %d", __func__,
2689 err); 2690 err);
2690 } 2691 }
2691 if (s_priv->indat_urb != NULL) { 2692 if (s_priv->indat_urb != NULL) {
2692 s_priv->indat_urb->dev = serial->dev; 2693 s_priv->indat_urb->dev = serial->dev;
2693 err = usb_submit_urb(s_priv->indat_urb, GFP_KERNEL); 2694 err = usb_submit_urb(s_priv->indat_urb, GFP_KERNEL);
2694 if (err != 0) 2695 if (err != 0)
2695 dbg("%s - submit indat urb failed %d", __FUNCTION__, 2696 dbg("%s - submit indat urb failed %d", __func__,
2696 err); 2697 err);
2697 } 2698 }
2698 2699
2699 return (0); 2700 return 0;
2700} 2701}
2701 2702
2702static void keyspan_shutdown (struct usb_serial *serial) 2703static void keyspan_shutdown (struct usb_serial *serial)
@@ -2706,7 +2707,7 @@ static void keyspan_shutdown (struct usb_serial *serial)
2706 struct keyspan_serial_private *s_priv; 2707 struct keyspan_serial_private *s_priv;
2707 struct keyspan_port_private *p_priv; 2708 struct keyspan_port_private *p_priv;
2708 2709
2709 dbg("%s", __FUNCTION__); 2710 dbg("%s", __func__);
2710 2711
2711 s_priv = usb_get_serial_data(serial); 2712 s_priv = usb_get_serial_data(serial);
2712 2713
diff --git a/drivers/usb/serial/keyspan.h b/drivers/usb/serial/keyspan.h
index 74ce8bca3e6..8d6ed0293bf 100644
--- a/drivers/usb/serial/keyspan.h
+++ b/drivers/usb/serial/keyspan.h
@@ -636,10 +636,6 @@ static struct usb_serial_driver keyspan_pre_device = {
636 }, 636 },
637 .description = "Keyspan - (without firmware)", 637 .description = "Keyspan - (without firmware)",
638 .id_table = keyspan_pre_ids, 638 .id_table = keyspan_pre_ids,
639 .num_interrupt_in = NUM_DONT_CARE,
640 .num_interrupt_out = NUM_DONT_CARE,
641 .num_bulk_in = NUM_DONT_CARE,
642 .num_bulk_out = NUM_DONT_CARE,
643 .num_ports = 1, 639 .num_ports = 1,
644 .attach = keyspan_fake_startup, 640 .attach = keyspan_fake_startup,
645}; 641};
@@ -651,10 +647,6 @@ static struct usb_serial_driver keyspan_1port_device = {
651 }, 647 },
652 .description = "Keyspan 1 port adapter", 648 .description = "Keyspan 1 port adapter",
653 .id_table = keyspan_1port_ids, 649 .id_table = keyspan_1port_ids,
654 .num_interrupt_in = NUM_DONT_CARE,
655 .num_interrupt_out = NUM_DONT_CARE,
656 .num_bulk_in = NUM_DONT_CARE,
657 .num_bulk_out = NUM_DONT_CARE,
658 .num_ports = 1, 650 .num_ports = 1,
659 .open = keyspan_open, 651 .open = keyspan_open,
660 .close = keyspan_close, 652 .close = keyspan_close,
@@ -679,10 +671,6 @@ static struct usb_serial_driver keyspan_2port_device = {
679 }, 671 },
680 .description = "Keyspan 2 port adapter", 672 .description = "Keyspan 2 port adapter",
681 .id_table = keyspan_2port_ids, 673 .id_table = keyspan_2port_ids,
682 .num_interrupt_in = NUM_DONT_CARE,
683 .num_interrupt_out = NUM_DONT_CARE,
684 .num_bulk_in = NUM_DONT_CARE,
685 .num_bulk_out = NUM_DONT_CARE,
686 .num_ports = 2, 674 .num_ports = 2,
687 .open = keyspan_open, 675 .open = keyspan_open,
688 .close = keyspan_close, 676 .close = keyspan_close,
@@ -707,10 +695,6 @@ static struct usb_serial_driver keyspan_4port_device = {
707 }, 695 },
708 .description = "Keyspan 4 port adapter", 696 .description = "Keyspan 4 port adapter",
709 .id_table = keyspan_4port_ids, 697 .id_table = keyspan_4port_ids,
710 .num_interrupt_in = NUM_DONT_CARE,
711 .num_interrupt_out = NUM_DONT_CARE,
712 .num_bulk_in = NUM_DONT_CARE,
713 .num_bulk_out = NUM_DONT_CARE,
714 .num_ports = 4, 698 .num_ports = 4,
715 .open = keyspan_open, 699 .open = keyspan_open,
716 .close = keyspan_close, 700 .close = keyspan_close,
diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c
index b1fa5a376e9..ff54203944c 100644
--- a/drivers/usb/serial/keyspan_pda.c
+++ b/drivers/usb/serial/keyspan_pda.c
@@ -208,13 +208,13 @@ static void keyspan_pda_request_unthrottle(struct work_struct *work)
208 2000); 208 2000);
209 if (result < 0) 209 if (result < 0)
210 dbg("%s - error %d from usb_control_msg", 210 dbg("%s - error %d from usb_control_msg",
211 __FUNCTION__, result); 211 __func__, result);
212} 212}
213 213
214 214
215static void keyspan_pda_rx_interrupt (struct urb *urb) 215static void keyspan_pda_rx_interrupt (struct urb *urb)
216{ 216{
217 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 217 struct usb_serial_port *port = urb->context;
218 struct tty_struct *tty = port->tty; 218 struct tty_struct *tty = port->tty;
219 unsigned char *data = urb->transfer_buffer; 219 unsigned char *data = urb->transfer_buffer;
220 int i; 220 int i;
@@ -232,11 +232,11 @@ static void keyspan_pda_rx_interrupt (struct urb *urb)
232 case -ESHUTDOWN: 232 case -ESHUTDOWN:
233 /* this urb is terminated, clean up */ 233 /* this urb is terminated, clean up */
234 dbg("%s - urb shutting down with status: %d", 234 dbg("%s - urb shutting down with status: %d",
235 __FUNCTION__, status); 235 __func__, status);
236 return; 236 return;
237 default: 237 default:
238 dbg("%s - nonzero urb status received: %d", 238 dbg("%s - nonzero urb status received: %d",
239 __FUNCTION__, status); 239 __func__, status);
240 goto exit; 240 goto exit;
241 } 241 }
242 242
@@ -274,7 +274,7 @@ exit:
274 retval = usb_submit_urb (urb, GFP_ATOMIC); 274 retval = usb_submit_urb (urb, GFP_ATOMIC);
275 if (retval) 275 if (retval)
276 err ("%s - usb_submit_urb failed with result %d", 276 err ("%s - usb_submit_urb failed with result %d",
277 __FUNCTION__, retval); 277 __func__, retval);
278} 278}
279 279
280 280
@@ -358,7 +358,7 @@ static void keyspan_pda_break_ctl (struct usb_serial_port *port, int break_state
358 value, 0, NULL, 0, 2000); 358 value, 0, NULL, 0, 2000);
359 if (result < 0) 359 if (result < 0)
360 dbg("%s - error %d from usb_control_msg", 360 dbg("%s - error %d from usb_control_msg",
361 __FUNCTION__, result); 361 __func__, result);
362 /* there is something funky about this.. the TCSBRK that 'cu' performs 362 /* there is something funky about this.. the TCSBRK that 'cu' performs
363 ought to translate into a break_ctl(-1),break_ctl(0) pair HZ/4 363 ought to translate into a break_ctl(-1),break_ctl(0) pair HZ/4
364 seconds apart, but it feels like the break sent isn't as long as it 364 seconds apart, but it feels like the break sent isn't as long as it
@@ -608,7 +608,7 @@ exit:
608 608
609static void keyspan_pda_write_bulk_callback (struct urb *urb) 609static void keyspan_pda_write_bulk_callback (struct urb *urb)
610{ 610{
611 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 611 struct usb_serial_port *port = urb->context;
612 struct keyspan_pda_private *priv; 612 struct keyspan_pda_private *priv;
613 613
614 port->write_urb_busy = 0; 614 port->write_urb_busy = 0;
@@ -636,14 +636,19 @@ static int keyspan_pda_write_room (struct usb_serial_port *port)
636static int keyspan_pda_chars_in_buffer (struct usb_serial_port *port) 636static int keyspan_pda_chars_in_buffer (struct usb_serial_port *port)
637{ 637{
638 struct keyspan_pda_private *priv; 638 struct keyspan_pda_private *priv;
639 unsigned long flags;
640 int ret = 0;
639 641
640 priv = usb_get_serial_port_data(port); 642 priv = usb_get_serial_port_data(port);
641 643
642 /* when throttled, return at least WAKEUP_CHARS to tell select() (via 644 /* when throttled, return at least WAKEUP_CHARS to tell select() (via
643 n_tty.c:normal_poll() ) that we're not writeable. */ 645 n_tty.c:normal_poll() ) that we're not writeable. */
646
647 spin_lock_irqsave(&port->lock, flags);
644 if (port->write_urb_busy || priv->tx_throttled) 648 if (port->write_urb_busy || priv->tx_throttled)
645 return 256; 649 ret = 256;
646 return 0; 650 spin_unlock_irqrestore(&port->lock, flags);
651 return ret;
647} 652}
648 653
649 654
@@ -665,11 +670,11 @@ static int keyspan_pda_open (struct usb_serial_port *port, struct file *filp)
665 1, 670 1,
666 2000); 671 2000);
667 if (rc < 0) { 672 if (rc < 0) {
668 dbg("%s - roomquery failed", __FUNCTION__); 673 dbg("%s - roomquery failed", __func__);
669 goto error; 674 goto error;
670 } 675 }
671 if (rc == 0) { 676 if (rc == 0) {
672 dbg("%s - roomquery returned 0 bytes", __FUNCTION__); 677 dbg("%s - roomquery returned 0 bytes", __func__);
673 rc = -EIO; 678 rc = -EIO;
674 goto error; 679 goto error;
675 } 680 }
@@ -688,7 +693,7 @@ static int keyspan_pda_open (struct usb_serial_port *port, struct file *filp)
688 port->interrupt_in_urb->dev = serial->dev; 693 port->interrupt_in_urb->dev = serial->dev;
689 rc = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); 694 rc = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
690 if (rc) { 695 if (rc) {
691 dbg("%s - usb_submit_urb(read int) failed", __FUNCTION__); 696 dbg("%s - usb_submit_urb(read int) failed", __func__);
692 goto error; 697 goto error;
693 } 698 }
694 699
@@ -732,7 +737,7 @@ static int keyspan_pda_fake_startup (struct usb_serial *serial)
732 record = &xircom_pgs_firmware[0]; 737 record = &xircom_pgs_firmware[0];
733#endif 738#endif
734 if (record == NULL) { 739 if (record == NULL) {
735 err("%s: unknown vendor, aborting.", __FUNCTION__); 740 err("%s: unknown vendor, aborting.", __func__);
736 return -ENODEV; 741 return -ENODEV;
737 } 742 }
738 743
@@ -779,7 +784,7 @@ static int keyspan_pda_startup (struct usb_serial *serial)
779 784
780static void keyspan_pda_shutdown (struct usb_serial *serial) 785static void keyspan_pda_shutdown (struct usb_serial *serial)
781{ 786{
782 dbg("%s", __FUNCTION__); 787 dbg("%s", __func__);
783 788
784 kfree(usb_get_serial_port_data(serial->port[0])); 789 kfree(usb_get_serial_port_data(serial->port[0]));
785} 790}
@@ -793,9 +798,6 @@ static struct usb_serial_driver keyspan_pda_fake_device = {
793 .description = "Keyspan PDA - (prerenumeration)", 798 .description = "Keyspan PDA - (prerenumeration)",
794 .usb_driver = &keyspan_pda_driver, 799 .usb_driver = &keyspan_pda_driver,
795 .id_table = id_table_fake, 800 .id_table = id_table_fake,
796 .num_interrupt_in = NUM_DONT_CARE,
797 .num_bulk_in = NUM_DONT_CARE,
798 .num_bulk_out = NUM_DONT_CARE,
799 .num_ports = 1, 801 .num_ports = 1,
800 .attach = keyspan_pda_fake_startup, 802 .attach = keyspan_pda_fake_startup,
801}; 803};
@@ -810,9 +812,6 @@ static struct usb_serial_driver xircom_pgs_fake_device = {
810 .description = "Xircom / Entregra PGS - (prerenumeration)", 812 .description = "Xircom / Entregra PGS - (prerenumeration)",
811 .usb_driver = &keyspan_pda_driver, 813 .usb_driver = &keyspan_pda_driver,
812 .id_table = id_table_fake_xircom, 814 .id_table = id_table_fake_xircom,
813 .num_interrupt_in = NUM_DONT_CARE,
814 .num_bulk_in = NUM_DONT_CARE,
815 .num_bulk_out = NUM_DONT_CARE,
816 .num_ports = 1, 815 .num_ports = 1,
817 .attach = keyspan_pda_fake_startup, 816 .attach = keyspan_pda_fake_startup,
818}; 817};
@@ -826,9 +825,6 @@ static struct usb_serial_driver keyspan_pda_device = {
826 .description = "Keyspan PDA", 825 .description = "Keyspan PDA",
827 .usb_driver = &keyspan_pda_driver, 826 .usb_driver = &keyspan_pda_driver,
828 .id_table = id_table_std, 827 .id_table = id_table_std,
829 .num_interrupt_in = 1,
830 .num_bulk_in = 0,
831 .num_bulk_out = 1,
832 .num_ports = 1, 828 .num_ports = 1,
833 .open = keyspan_pda_open, 829 .open = keyspan_pda_open,
834 .close = keyspan_pda_close, 830 .close = keyspan_pda_close,
diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c
index 55736df7d2f..b395ac75988 100644
--- a/drivers/usb/serial/kl5kusb105.c
+++ b/drivers/usb/serial/kl5kusb105.c
@@ -126,9 +126,6 @@ static struct usb_serial_driver kl5kusb105d_device = {
126 .description = "KL5KUSB105D / PalmConnect", 126 .description = "KL5KUSB105D / PalmConnect",
127 .usb_driver = &kl5kusb105d_driver, 127 .usb_driver = &kl5kusb105d_driver,
128 .id_table = id_table, 128 .id_table = id_table,
129 .num_interrupt_in = 1,
130 .num_bulk_in = 1,
131 .num_bulk_out = 1,
132 .num_ports = 1, 129 .num_ports = 1,
133 .open = klsi_105_open, 130 .open = klsi_105_open,
134 .close = klsi_105_close, 131 .close = klsi_105_close,
@@ -194,7 +191,7 @@ static int klsi_105_chg_port_settings(struct usb_serial_port *port,
194 if (rc < 0) 191 if (rc < 0)
195 err("Change port settings failed (error = %d)", rc); 192 err("Change port settings failed (error = %d)", rc);
196 info("%s - %d byte block, baudrate %x, databits %d, u1 %d, u2 %d", 193 info("%s - %d byte block, baudrate %x, databits %d, u1 %d, u2 %d",
197 __FUNCTION__, 194 __func__,
198 settings->pktlen, 195 settings->pktlen,
199 settings->baudrate, settings->databits, 196 settings->baudrate, settings->databits,
200 settings->unknown1, settings->unknown2); 197 settings->unknown1, settings->unknown2);
@@ -225,7 +222,7 @@ static int klsi_105_get_line_state(struct usb_serial_port *port,
225 __u8 status_buf[KLSI_STATUSBUF_LEN] = { -1,-1}; 222 __u8 status_buf[KLSI_STATUSBUF_LEN] = { -1,-1};
226 __u16 status; 223 __u16 status;
227 224
228 info("%s - sending SIO Poll request", __FUNCTION__); 225 info("%s - sending SIO Poll request", __func__);
229 rc = usb_control_msg(port->serial->dev, 226 rc = usb_control_msg(port->serial->dev,
230 usb_rcvctrlpipe(port->serial->dev, 0), 227 usb_rcvctrlpipe(port->serial->dev, 0),
231 KL5KUSB105A_SIO_POLL, 228 KL5KUSB105A_SIO_POLL,
@@ -240,7 +237,7 @@ static int klsi_105_get_line_state(struct usb_serial_port *port,
240 else { 237 else {
241 status = le16_to_cpu(*(u16 *)status_buf); 238 status = le16_to_cpu(*(u16 *)status_buf);
242 239
243 info("%s - read status %x %x", __FUNCTION__, 240 info("%s - read status %x %x", __func__,
244 status_buf[0], status_buf[1]); 241 status_buf[0], status_buf[1]);
245 242
246 *line_state_p = klsi_105_status2linestate(status); 243 *line_state_p = klsi_105_status2linestate(status);
@@ -268,7 +265,7 @@ static int klsi_105_startup (struct usb_serial *serial)
268 priv = kmalloc(sizeof(struct klsi_105_private), 265 priv = kmalloc(sizeof(struct klsi_105_private),
269 GFP_KERNEL); 266 GFP_KERNEL);
270 if (!priv) { 267 if (!priv) {
271 dbg("%skmalloc for klsi_105_private failed.", __FUNCTION__); 268 dbg("%skmalloc for klsi_105_private failed.", __func__);
272 i--; 269 i--;
273 goto err_cleanup; 270 goto err_cleanup;
274 } 271 }
@@ -298,7 +295,7 @@ static int klsi_105_startup (struct usb_serial *serial)
298 urb->transfer_buffer = kmalloc (URB_TRANSFER_BUFFER_SIZE, 295 urb->transfer_buffer = kmalloc (URB_TRANSFER_BUFFER_SIZE,
299 GFP_KERNEL); 296 GFP_KERNEL);
300 if (!urb->transfer_buffer) { 297 if (!urb->transfer_buffer) {
301 err("%s - out of memory for urb buffers.", __FUNCTION__); 298 err("%s - out of memory for urb buffers.", __func__);
302 goto err_cleanup; 299 goto err_cleanup;
303 } 300 }
304 } 301 }
@@ -328,7 +325,7 @@ static void klsi_105_shutdown (struct usb_serial *serial)
328{ 325{
329 int i; 326 int i;
330 327
331 dbg("%s", __FUNCTION__); 328 dbg("%s", __func__);
332 329
333 /* stop reads and writes on all ports */ 330 /* stop reads and writes on all ports */
334 for (i=0; i < serial->num_ports; ++i) { 331 for (i=0; i < serial->num_ports; ++i) {
@@ -373,7 +370,7 @@ static int klsi_105_open (struct usb_serial_port *port, struct file *filp)
373 struct klsi_105_port_settings cfg; 370 struct klsi_105_port_settings cfg;
374 unsigned long flags; 371 unsigned long flags;
375 372
376 dbg("%s port %d", __FUNCTION__, port->number); 373 dbg("%s port %d", __func__, port->number);
377 374
378 /* force low_latency on so that our tty_push actually forces 375 /* force low_latency on so that our tty_push actually forces
379 * the data through 376 * the data through
@@ -419,7 +416,7 @@ static int klsi_105_open (struct usb_serial_port *port, struct file *filp)
419 416
420 rc = usb_submit_urb(port->read_urb, GFP_KERNEL); 417 rc = usb_submit_urb(port->read_urb, GFP_KERNEL);
421 if (rc) { 418 if (rc) {
422 err("%s - failed submitting read urb, error %d", __FUNCTION__, rc); 419 err("%s - failed submitting read urb, error %d", __func__, rc);
423 retval = rc; 420 retval = rc;
424 goto exit; 421 goto exit;
425 } 422 }
@@ -437,14 +434,14 @@ static int klsi_105_open (struct usb_serial_port *port, struct file *filp)
437 err("Enabling read failed (error = %d)", rc); 434 err("Enabling read failed (error = %d)", rc);
438 retval = rc; 435 retval = rc;
439 } else 436 } else
440 dbg("%s - enabled reading", __FUNCTION__); 437 dbg("%s - enabled reading", __func__);
441 438
442 rc = klsi_105_get_line_state(port, &line_state); 439 rc = klsi_105_get_line_state(port, &line_state);
443 if (rc >= 0) { 440 if (rc >= 0) {
444 spin_lock_irqsave (&priv->lock, flags); 441 spin_lock_irqsave (&priv->lock, flags);
445 priv->line_state = line_state; 442 priv->line_state = line_state;
446 spin_unlock_irqrestore (&priv->lock, flags); 443 spin_unlock_irqrestore (&priv->lock, flags);
447 dbg("%s - read line state 0x%lx", __FUNCTION__, line_state); 444 dbg("%s - read line state 0x%lx", __func__, line_state);
448 retval = 0; 445 retval = 0;
449 } else 446 } else
450 retval = rc; 447 retval = rc;
@@ -459,7 +456,7 @@ static void klsi_105_close (struct usb_serial_port *port, struct file *filp)
459 struct klsi_105_private *priv = usb_get_serial_port_data(port); 456 struct klsi_105_private *priv = usb_get_serial_port_data(port);
460 int rc; 457 int rc;
461 458
462 dbg("%s port %d", __FUNCTION__, port->number); 459 dbg("%s port %d", __func__, port->number);
463 460
464 mutex_lock(&port->serial->disc_mutex); 461 mutex_lock(&port->serial->disc_mutex);
465 if (!port->serial->disconnected) { 462 if (!port->serial->disconnected) {
@@ -502,7 +499,7 @@ static int klsi_105_write (struct usb_serial_port *port,
502 int result, size; 499 int result, size;
503 int bytes_sent=0; 500 int bytes_sent=0;
504 501
505 dbg("%s - port %d", __FUNCTION__, port->number); 502 dbg("%s - port %d", __func__, port->number);
506 503
507 while (count > 0) { 504 while (count > 0) {
508 /* try to find a free urb (write 0 bytes if none) */ 505 /* try to find a free urb (write 0 bytes if none) */
@@ -514,21 +511,21 @@ static int klsi_105_write (struct usb_serial_port *port,
514 for (i=0; i<NUM_URBS; i++) { 511 for (i=0; i<NUM_URBS; i++) {
515 if (priv->write_urb_pool[i]->status != -EINPROGRESS) { 512 if (priv->write_urb_pool[i]->status != -EINPROGRESS) {
516 urb = priv->write_urb_pool[i]; 513 urb = priv->write_urb_pool[i];
517 dbg("%s - using pool URB %d", __FUNCTION__, i); 514 dbg("%s - using pool URB %d", __func__, i);
518 break; 515 break;
519 } 516 }
520 } 517 }
521 spin_unlock_irqrestore (&priv->lock, flags); 518 spin_unlock_irqrestore (&priv->lock, flags);
522 519
523 if (urb==NULL) { 520 if (urb==NULL) {
524 dbg("%s - no more free urbs", __FUNCTION__); 521 dbg("%s - no more free urbs", __func__);
525 goto exit; 522 goto exit;
526 } 523 }
527 524
528 if (urb->transfer_buffer == NULL) { 525 if (urb->transfer_buffer == NULL) {
529 urb->transfer_buffer = kmalloc (URB_TRANSFER_BUFFER_SIZE, GFP_ATOMIC); 526 urb->transfer_buffer = kmalloc (URB_TRANSFER_BUFFER_SIZE, GFP_ATOMIC);
530 if (urb->transfer_buffer == NULL) { 527 if (urb->transfer_buffer == NULL) {
531 err("%s - no more kernel memory...", __FUNCTION__); 528 err("%s - no more kernel memory...", __func__);
532 goto exit; 529 goto exit;
533 } 530 }
534 } 531 }
@@ -554,7 +551,7 @@ static int klsi_105_write (struct usb_serial_port *port,
554 /* send the data out the bulk port */ 551 /* send the data out the bulk port */
555 result = usb_submit_urb(urb, GFP_ATOMIC); 552 result = usb_submit_urb(urb, GFP_ATOMIC);
556 if (result) { 553 if (result) {
557 err("%s - failed submitting write urb, error %d", __FUNCTION__, result); 554 err("%s - failed submitting write urb, error %d", __func__, result);
558 goto exit; 555 goto exit;
559 } 556 }
560 buf += size; 557 buf += size;
@@ -570,13 +567,13 @@ exit:
570 567
571static void klsi_105_write_bulk_callback ( struct urb *urb) 568static void klsi_105_write_bulk_callback ( struct urb *urb)
572{ 569{
573 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 570 struct usb_serial_port *port = urb->context;
574 int status = urb->status; 571 int status = urb->status;
575 572
576 dbg("%s - port %d", __FUNCTION__, port->number); 573 dbg("%s - port %d", __func__, port->number);
577 574
578 if (status) { 575 if (status) {
579 dbg("%s - nonzero write bulk status received: %d", __FUNCTION__, 576 dbg("%s - nonzero write bulk status received: %d", __func__,
580 status); 577 status);
581 return; 578 return;
582 } 579 }
@@ -603,7 +600,7 @@ static int klsi_105_chars_in_buffer (struct usb_serial_port *port)
603 600
604 spin_unlock_irqrestore (&priv->lock, flags); 601 spin_unlock_irqrestore (&priv->lock, flags);
605 602
606 dbg("%s - returns %d", __FUNCTION__, chars); 603 dbg("%s - returns %d", __func__, chars);
607 return (chars); 604 return (chars);
608} 605}
609 606
@@ -623,7 +620,7 @@ static int klsi_105_write_room (struct usb_serial_port *port)
623 620
624 spin_unlock_irqrestore (&priv->lock, flags); 621 spin_unlock_irqrestore (&priv->lock, flags);
625 622
626 dbg("%s - returns %d", __FUNCTION__, room); 623 dbg("%s - returns %d", __func__, room);
627 return (room); 624 return (room);
628} 625}
629 626
@@ -631,18 +628,18 @@ static int klsi_105_write_room (struct usb_serial_port *port)
631 628
632static void klsi_105_read_bulk_callback (struct urb *urb) 629static void klsi_105_read_bulk_callback (struct urb *urb)
633{ 630{
634 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 631 struct usb_serial_port *port = urb->context;
635 struct klsi_105_private *priv = usb_get_serial_port_data(port); 632 struct klsi_105_private *priv = usb_get_serial_port_data(port);
636 struct tty_struct *tty; 633 struct tty_struct *tty;
637 unsigned char *data = urb->transfer_buffer; 634 unsigned char *data = urb->transfer_buffer;
638 int rc; 635 int rc;
639 int status = urb->status; 636 int status = urb->status;
640 637
641 dbg("%s - port %d", __FUNCTION__, port->number); 638 dbg("%s - port %d", __func__, port->number);
642 639
643 /* The urb might have been killed. */ 640 /* The urb might have been killed. */
644 if (status) { 641 if (status) {
645 dbg("%s - nonzero read bulk status received: %d", __FUNCTION__, 642 dbg("%s - nonzero read bulk status received: %d", __func__,
646 status); 643 status);
647 return; 644 return;
648 } 645 }
@@ -652,12 +649,12 @@ static void klsi_105_read_bulk_callback (struct urb *urb)
652 */ 649 */
653 if (urb->actual_length == 0) { 650 if (urb->actual_length == 0) {
654 /* empty urbs seem to happen, we ignore them */ 651 /* empty urbs seem to happen, we ignore them */
655 /* dbg("%s - emtpy URB", __FUNCTION__); */ 652 /* dbg("%s - emtpy URB", __func__); */
656 ; 653 ;
657 } else if (urb->actual_length <= 2) { 654 } else if (urb->actual_length <= 2) {
658 dbg("%s - size %d URB not understood", __FUNCTION__, 655 dbg("%s - size %d URB not understood", __func__,
659 urb->actual_length); 656 urb->actual_length);
660 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, 657 usb_serial_debug_data(debug, &port->dev, __func__,
661 urb->actual_length, data); 658 urb->actual_length, data);
662 } else { 659 } else {
663 int bytes_sent = ((__u8 *) data)[0] + 660 int bytes_sent = ((__u8 *) data)[0] +
@@ -669,12 +666,12 @@ static void klsi_105_read_bulk_callback (struct urb *urb)
669 * intermixed tty_flip_buffer_push()s 666 * intermixed tty_flip_buffer_push()s
670 * FIXME 667 * FIXME
671 */ 668 */
672 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, 669 usb_serial_debug_data(debug, &port->dev, __func__,
673 urb->actual_length, data); 670 urb->actual_length, data);
674 671
675 if (bytes_sent + 2 > urb->actual_length) { 672 if (bytes_sent + 2 > urb->actual_length) {
676 dbg("%s - trying to read more data than available" 673 dbg("%s - trying to read more data than available"
677 " (%d vs. %d)", __FUNCTION__, 674 " (%d vs. %d)", __func__,
678 bytes_sent+2, urb->actual_length); 675 bytes_sent+2, urb->actual_length);
679 /* cap at implied limit */ 676 /* cap at implied limit */
680 bytes_sent = urb->actual_length - 2; 677 bytes_sent = urb->actual_length - 2;
@@ -697,7 +694,7 @@ static void klsi_105_read_bulk_callback (struct urb *urb)
697 port); 694 port);
698 rc = usb_submit_urb(port->read_urb, GFP_ATOMIC); 695 rc = usb_submit_urb(port->read_urb, GFP_ATOMIC);
699 if (rc) 696 if (rc)
700 err("%s - failed resubmitting read urb, error %d", __FUNCTION__, rc); 697 err("%s - failed resubmitting read urb, error %d", __func__, rc);
701} /* klsi_105_read_bulk_callback */ 698} /* klsi_105_read_bulk_callback */
702 699
703 700
@@ -705,12 +702,14 @@ static void klsi_105_set_termios (struct usb_serial_port *port,
705 struct ktermios *old_termios) 702 struct ktermios *old_termios)
706{ 703{
707 struct klsi_105_private *priv = usb_get_serial_port_data(port); 704 struct klsi_105_private *priv = usb_get_serial_port_data(port);
708 unsigned int iflag = port->tty->termios->c_iflag; 705 struct tty_struct *tty = port->tty;
706 unsigned int iflag = tty->termios->c_iflag;
709 unsigned int old_iflag = old_termios->c_iflag; 707 unsigned int old_iflag = old_termios->c_iflag;
710 unsigned int cflag = port->tty->termios->c_cflag; 708 unsigned int cflag = tty->termios->c_cflag;
711 unsigned int old_cflag = old_termios->c_cflag; 709 unsigned int old_cflag = old_termios->c_cflag;
712 struct klsi_105_port_settings cfg; 710 struct klsi_105_port_settings cfg;
713 unsigned long flags; 711 unsigned long flags;
712 speed_t baud;
714 713
715 /* lock while we are modifying the settings */ 714 /* lock while we are modifying the settings */
716 spin_lock_irqsave (&priv->lock, flags); 715 spin_lock_irqsave (&priv->lock, flags);
@@ -718,10 +717,12 @@ static void klsi_105_set_termios (struct usb_serial_port *port,
718 /* 717 /*
719 * Update baud rate 718 * Update baud rate
720 */ 719 */
720 baud = tty_get_baud_rate(tty);
721
721 if( (cflag & CBAUD) != (old_cflag & CBAUD) ) { 722 if( (cflag & CBAUD) != (old_cflag & CBAUD) ) {
722 /* reassert DTR and (maybe) RTS on transition from B0 */ 723 /* reassert DTR and (maybe) RTS on transition from B0 */
723 if( (old_cflag & CBAUD) == B0 ) { 724 if( (old_cflag & CBAUD) == B0 ) {
724 dbg("%s: baud was B0", __FUNCTION__); 725 dbg("%s: baud was B0", __func__);
725#if 0 726#if 0
726 priv->control_state |= TIOCM_DTR; 727 priv->control_state |= TIOCM_DTR;
727 /* don't set RTS if using hardware flow control */ 728 /* don't set RTS if using hardware flow control */
@@ -731,8 +732,8 @@ static void klsi_105_set_termios (struct usb_serial_port *port,
731 mct_u232_set_modem_ctrl(serial, priv->control_state); 732 mct_u232_set_modem_ctrl(serial, priv->control_state);
732#endif 733#endif
733 } 734 }
734 735 }
735 switch(tty_get_baud_rate(port->tty)) { 736 switch(baud) {
736 case 0: /* handled below */ 737 case 0: /* handled below */
737 break; 738 break;
738 case 1200: 739 case 1200:
@@ -760,35 +761,36 @@ static void klsi_105_set_termios (struct usb_serial_port *port,
760 priv->cfg.baudrate = kl5kusb105a_sio_b115200; 761 priv->cfg.baudrate = kl5kusb105a_sio_b115200;
761 break; 762 break;
762 default: 763 default:
763 err("KLSI USB->Serial converter:" 764 dbg("KLSI USB->Serial converter:"
764 " unsupported baudrate request, using default" 765 " unsupported baudrate request, using default"
765 " of 9600"); 766 " of 9600");
766 priv->cfg.baudrate = kl5kusb105a_sio_b9600; 767 priv->cfg.baudrate = kl5kusb105a_sio_b9600;
768 baud = 9600;
767 break; 769 break;
768 } 770 }
769 if ((cflag & CBAUD) == B0 ) { 771 if ((cflag & CBAUD) == B0 ) {
770 dbg("%s: baud is B0", __FUNCTION__); 772 dbg("%s: baud is B0", __func__);
771 /* Drop RTS and DTR */ 773 /* Drop RTS and DTR */
772 /* maybe this should be simulated by sending read 774 /* maybe this should be simulated by sending read
773 * disable and read enable messages? 775 * disable and read enable messages?
774 */ 776 */
775 ; 777 ;
776#if 0 778#if 0
777 priv->control_state &= ~(TIOCM_DTR | TIOCM_RTS); 779 priv->control_state &= ~(TIOCM_DTR | TIOCM_RTS);
778 mct_u232_set_modem_ctrl(serial, priv->control_state); 780 mct_u232_set_modem_ctrl(serial, priv->control_state);
779#endif 781#endif
780 }
781 } 782 }
783 tty_encode_baud_rate(tty, baud, baud);
782 784
783 if ((cflag & CSIZE) != (old_cflag & CSIZE)) { 785 if ((cflag & CSIZE) != (old_cflag & CSIZE)) {
784 /* set the number of data bits */ 786 /* set the number of data bits */
785 switch (cflag & CSIZE) { 787 switch (cflag & CSIZE) {
786 case CS5: 788 case CS5:
787 dbg("%s - 5 bits/byte not supported", __FUNCTION__); 789 dbg("%s - 5 bits/byte not supported", __func__);
788 spin_unlock_irqrestore (&priv->lock, flags); 790 spin_unlock_irqrestore (&priv->lock, flags);
789 return ; 791 return ;
790 case CS6: 792 case CS6:
791 dbg("%s - 6 bits/byte not supported", __FUNCTION__); 793 dbg("%s - 6 bits/byte not supported", __func__);
792 spin_unlock_irqrestore (&priv->lock, flags); 794 spin_unlock_irqrestore (&priv->lock, flags);
793 return ; 795 return ;
794 case CS7: 796 case CS7:
@@ -810,6 +812,8 @@ static void klsi_105_set_termios (struct usb_serial_port *port,
810 if ((cflag & (PARENB|PARODD)) != (old_cflag & (PARENB|PARODD)) 812 if ((cflag & (PARENB|PARODD)) != (old_cflag & (PARENB|PARODD))
811 || (cflag & CSTOPB) != (old_cflag & CSTOPB) ) { 813 || (cflag & CSTOPB) != (old_cflag & CSTOPB) ) {
812 814
815 /* Not currently supported */
816 tty->termios->c_cflag &= ~(PARENB|PARODD|CSTOPB);
813#if 0 817#if 0
814 priv->last_lcr = 0; 818 priv->last_lcr = 0;
815 819
@@ -837,6 +841,8 @@ static void klsi_105_set_termios (struct usb_serial_port *port,
837 || (iflag & IXON) != (old_iflag & IXON) 841 || (iflag & IXON) != (old_iflag & IXON)
838 || (cflag & CRTSCTS) != (old_cflag & CRTSCTS) ) { 842 || (cflag & CRTSCTS) != (old_cflag & CRTSCTS) ) {
839 843
844 /* Not currently supported */
845 tty->termios->c_cflag &= ~CRTSCTS;
840 /* Drop DTR/RTS if no flow control otherwise assert */ 846 /* Drop DTR/RTS if no flow control otherwise assert */
841#if 0 847#if 0
842 if ((iflag & IXOFF) || (iflag & IXON) || (cflag & CRTSCTS) ) 848 if ((iflag & IXOFF) || (iflag & IXON) || (cflag & CRTSCTS) )
@@ -862,7 +868,7 @@ static void mct_u232_break_ctl( struct usb_serial_port *port, int break_state )
862 struct mct_u232_private *priv = (struct mct_u232_private *)port->private; 868 struct mct_u232_private *priv = (struct mct_u232_private *)port->private;
863 unsigned char lcr = priv->last_lcr; 869 unsigned char lcr = priv->last_lcr;
864 870
865 dbg("%sstate=%d", __FUNCTION__, break_state); 871 dbg("%sstate=%d", __func__, break_state);
866 872
867 if (break_state) 873 if (break_state)
868 lcr |= MCT_U232_SET_BREAK; 874 lcr |= MCT_U232_SET_BREAK;
@@ -877,7 +883,7 @@ static int klsi_105_tiocmget (struct usb_serial_port *port, struct file *file)
877 unsigned long flags; 883 unsigned long flags;
878 int rc; 884 int rc;
879 unsigned long line_state; 885 unsigned long line_state;
880 dbg("%s - request, just guessing", __FUNCTION__); 886 dbg("%s - request, just guessing", __func__);
881 887
882 rc = klsi_105_get_line_state(port, &line_state); 888 rc = klsi_105_get_line_state(port, &line_state);
883 if (rc < 0) { 889 if (rc < 0) {
@@ -889,7 +895,7 @@ static int klsi_105_tiocmget (struct usb_serial_port *port, struct file *file)
889 spin_lock_irqsave (&priv->lock, flags); 895 spin_lock_irqsave (&priv->lock, flags);
890 priv->line_state = line_state; 896 priv->line_state = line_state;
891 spin_unlock_irqrestore (&priv->lock, flags); 897 spin_unlock_irqrestore (&priv->lock, flags);
892 dbg("%s - read line state 0x%lx", __FUNCTION__, line_state); 898 dbg("%s - read line state 0x%lx", __func__, line_state);
893 return (int)line_state; 899 return (int)line_state;
894} 900}
895 901
@@ -898,7 +904,7 @@ static int klsi_105_tiocmset (struct usb_serial_port *port, struct file *file,
898{ 904{
899 int retval = -EINVAL; 905 int retval = -EINVAL;
900 906
901 dbg("%s", __FUNCTION__); 907 dbg("%s", __func__);
902 908
903/* if this ever gets implemented, it should be done something like this: 909/* if this ever gets implemented, it should be done something like this:
904 struct usb_serial *serial = port->serial; 910 struct usb_serial *serial = port->serial;
@@ -924,7 +930,7 @@ static int klsi_105_tiocmset (struct usb_serial_port *port, struct file *file,
924 930
925static void klsi_105_throttle (struct usb_serial_port *port) 931static void klsi_105_throttle (struct usb_serial_port *port)
926{ 932{
927 dbg("%s - port %d", __FUNCTION__, port->number); 933 dbg("%s - port %d", __func__, port->number);
928 usb_kill_urb(port->read_urb); 934 usb_kill_urb(port->read_urb);
929} 935}
930 936
@@ -932,12 +938,12 @@ static void klsi_105_unthrottle (struct usb_serial_port *port)
932{ 938{
933 int result; 939 int result;
934 940
935 dbg("%s - port %d", __FUNCTION__, port->number); 941 dbg("%s - port %d", __func__, port->number);
936 942
937 port->read_urb->dev = port->serial->dev; 943 port->read_urb->dev = port->serial->dev;
938 result = usb_submit_urb(port->read_urb, GFP_ATOMIC); 944 result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
939 if (result) 945 if (result)
940 err("%s - failed submitting read urb, error %d", __FUNCTION__, 946 err("%s - failed submitting read urb, error %d", __func__,
941 result); 947 result);
942} 948}
943 949
diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c
index 17b3baead4a..693f00da7c0 100644
--- a/drivers/usb/serial/kobil_sct.c
+++ b/drivers/usb/serial/kobil_sct.c
@@ -113,10 +113,6 @@ static struct usb_serial_driver kobil_device = {
113 .description = "KOBIL USB smart card terminal", 113 .description = "KOBIL USB smart card terminal",
114 .usb_driver = &kobil_driver, 114 .usb_driver = &kobil_driver,
115 .id_table = id_table, 115 .id_table = id_table,
116 .num_interrupt_in = NUM_DONT_CARE,
117 .num_interrupt_out = NUM_DONT_CARE,
118 .num_bulk_in = 0,
119 .num_bulk_out = 0,
120 .num_ports = 1, 116 .num_ports = 1,
121 .attach = kobil_startup, 117 .attach = kobil_startup,
122 .shutdown = kobil_shutdown, 118 .shutdown = kobil_shutdown,
@@ -139,7 +135,6 @@ struct kobil_private {
139 int filled; // index of the last char in buf 135 int filled; // index of the last char in buf
140 int cur_pos; // index of the next char to send in buf 136 int cur_pos; // index of the next char to send in buf
141 __u16 device_type; 137 __u16 device_type;
142 int line_state;
143}; 138};
144 139
145 140
@@ -161,7 +156,6 @@ static int kobil_startup (struct usb_serial *serial)
161 priv->filled = 0; 156 priv->filled = 0;
162 priv->cur_pos = 0; 157 priv->cur_pos = 0;
163 priv->device_type = le16_to_cpu(serial->dev->descriptor.idProduct); 158 priv->device_type = le16_to_cpu(serial->dev->descriptor.idProduct);
164 priv->line_state = 0;
165 159
166 switch (priv->device_type){ 160 switch (priv->device_type){
167 case KOBIL_ADAPTER_B_PRODUCT_ID: 161 case KOBIL_ADAPTER_B_PRODUCT_ID:
@@ -189,11 +183,11 @@ static int kobil_startup (struct usb_serial *serial)
189 for (i = 0; i < altsetting->desc.bNumEndpoints; i++) { 183 for (i = 0; i < altsetting->desc.bNumEndpoints; i++) {
190 endpoint = &altsetting->endpoint[i]; 184 endpoint = &altsetting->endpoint[i];
191 if (usb_endpoint_is_int_out(&endpoint->desc)) { 185 if (usb_endpoint_is_int_out(&endpoint->desc)) {
192 dbg("%s Found interrupt out endpoint. Address: %d", __FUNCTION__, endpoint->desc.bEndpointAddress); 186 dbg("%s Found interrupt out endpoint. Address: %d", __func__, endpoint->desc.bEndpointAddress);
193 priv->write_int_endpoint_address = endpoint->desc.bEndpointAddress; 187 priv->write_int_endpoint_address = endpoint->desc.bEndpointAddress;
194 } 188 }
195 if (usb_endpoint_is_int_in(&endpoint->desc)) { 189 if (usb_endpoint_is_int_in(&endpoint->desc)) {
196 dbg("%s Found interrupt in endpoint. Address: %d", __FUNCTION__, endpoint->desc.bEndpointAddress); 190 dbg("%s Found interrupt in endpoint. Address: %d", __func__, endpoint->desc.bEndpointAddress);
197 priv->read_int_endpoint_address = endpoint->desc.bEndpointAddress; 191 priv->read_int_endpoint_address = endpoint->desc.bEndpointAddress;
198 } 192 }
199 } 193 }
@@ -204,7 +198,7 @@ static int kobil_startup (struct usb_serial *serial)
204static void kobil_shutdown (struct usb_serial *serial) 198static void kobil_shutdown (struct usb_serial *serial)
205{ 199{
206 int i; 200 int i;
207 dbg("%s - port %d", __FUNCTION__, serial->port[0]->number); 201 dbg("%s - port %d", __func__, serial->port[0]->number);
208 202
209 for (i=0; i < serial->num_ports; ++i) { 203 for (i=0; i < serial->num_ports; ++i) {
210 while (serial->port[i]->open_count > 0) { 204 while (serial->port[i]->open_count > 0) {
@@ -224,9 +218,8 @@ static int kobil_open (struct usb_serial_port *port, struct file *filp)
224 int transfer_buffer_length = 8; 218 int transfer_buffer_length = 8;
225 int write_urb_transfer_buffer_length = 8; 219 int write_urb_transfer_buffer_length = 8;
226 220
227 dbg("%s - port %d", __FUNCTION__, port->number); 221 dbg("%s - port %d", __func__, port->number);
228 priv = usb_get_serial_port_data(port); 222 priv = usb_get_serial_port_data(port);
229 priv->line_state = 0;
230 223
231 // someone sets the dev to 0 if the close method has been called 224 // someone sets the dev to 0 if the close method has been called
232 port->interrupt_in_urb->dev = port->serial->dev; 225 port->interrupt_in_urb->dev = port->serial->dev;
@@ -252,10 +245,10 @@ static int kobil_open (struct usb_serial_port *port, struct file *filp)
252 245
253 // allocate write_urb 246 // allocate write_urb
254 if (!port->write_urb) { 247 if (!port->write_urb) {
255 dbg("%s - port %d Allocating port->write_urb", __FUNCTION__, port->number); 248 dbg("%s - port %d Allocating port->write_urb", __func__, port->number);
256 port->write_urb = usb_alloc_urb(0, GFP_KERNEL); 249 port->write_urb = usb_alloc_urb(0, GFP_KERNEL);
257 if (!port->write_urb) { 250 if (!port->write_urb) {
258 dbg("%s - port %d usb_alloc_urb failed", __FUNCTION__, port->number); 251 dbg("%s - port %d usb_alloc_urb failed", __func__, port->number);
259 kfree(transfer_buffer); 252 kfree(transfer_buffer);
260 return -ENOMEM; 253 return -ENOMEM;
261 } 254 }
@@ -281,7 +274,7 @@ static int kobil_open (struct usb_serial_port *port, struct file *filp)
281 transfer_buffer_length, 274 transfer_buffer_length,
282 KOBIL_TIMEOUT 275 KOBIL_TIMEOUT
283 ); 276 );
284 dbg("%s - port %d Send get_HW_version URB returns: %i", __FUNCTION__, port->number, result); 277 dbg("%s - port %d Send get_HW_version URB returns: %i", __func__, port->number, result);
285 dbg("Harware version: %i.%i.%i", transfer_buffer[0], transfer_buffer[1], transfer_buffer[2] ); 278 dbg("Harware version: %i.%i.%i", transfer_buffer[0], transfer_buffer[1], transfer_buffer[2] );
286 279
287 // get firmware version 280 // get firmware version
@@ -295,7 +288,7 @@ static int kobil_open (struct usb_serial_port *port, struct file *filp)
295 transfer_buffer_length, 288 transfer_buffer_length,
296 KOBIL_TIMEOUT 289 KOBIL_TIMEOUT
297 ); 290 );
298 dbg("%s - port %d Send get_FW_version URB returns: %i", __FUNCTION__, port->number, result); 291 dbg("%s - port %d Send get_FW_version URB returns: %i", __func__, port->number, result);
299 dbg("Firmware version: %i.%i.%i", transfer_buffer[0], transfer_buffer[1], transfer_buffer[2] ); 292 dbg("Firmware version: %i.%i.%i", transfer_buffer[0], transfer_buffer[1], transfer_buffer[2] );
300 293
301 if (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID || priv->device_type == KOBIL_ADAPTER_K_PRODUCT_ID) { 294 if (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID || priv->device_type == KOBIL_ADAPTER_K_PRODUCT_ID) {
@@ -310,7 +303,7 @@ static int kobil_open (struct usb_serial_port *port, struct file *filp)
310 0, 303 0,
311 KOBIL_TIMEOUT 304 KOBIL_TIMEOUT
312 ); 305 );
313 dbg("%s - port %d Send set_baudrate URB returns: %i", __FUNCTION__, port->number, result); 306 dbg("%s - port %d Send set_baudrate URB returns: %i", __func__, port->number, result);
314 307
315 // reset all queues 308 // reset all queues
316 result = usb_control_msg( port->serial->dev, 309 result = usb_control_msg( port->serial->dev,
@@ -323,13 +316,13 @@ static int kobil_open (struct usb_serial_port *port, struct file *filp)
323 0, 316 0,
324 KOBIL_TIMEOUT 317 KOBIL_TIMEOUT
325 ); 318 );
326 dbg("%s - port %d Send reset_all_queues URB returns: %i", __FUNCTION__, port->number, result); 319 dbg("%s - port %d Send reset_all_queues URB returns: %i", __func__, port->number, result);
327 } 320 }
328 if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID || priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID || 321 if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID || priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID ||
329 priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID) { 322 priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID) {
330 // start reading (Adapter B 'cause PNP string) 323 // start reading (Adapter B 'cause PNP string)
331 result = usb_submit_urb( port->interrupt_in_urb, GFP_ATOMIC ); 324 result = usb_submit_urb( port->interrupt_in_urb, GFP_ATOMIC );
332 dbg("%s - port %d Send read URB returns: %i", __FUNCTION__, port->number, result); 325 dbg("%s - port %d Send read URB returns: %i", __func__, port->number, result);
333 } 326 }
334 327
335 kfree(transfer_buffer); 328 kfree(transfer_buffer);
@@ -339,7 +332,7 @@ static int kobil_open (struct usb_serial_port *port, struct file *filp)
339 332
340static void kobil_close (struct usb_serial_port *port, struct file *filp) 333static void kobil_close (struct usb_serial_port *port, struct file *filp)
341{ 334{
342 dbg("%s - port %d", __FUNCTION__, port->number); 335 dbg("%s - port %d", __func__, port->number);
343 336
344 if (port->write_urb) { 337 if (port->write_urb) {
345 usb_kill_urb(port->write_urb); 338 usb_kill_urb(port->write_urb);
@@ -359,11 +352,11 @@ static void kobil_read_int_callback(struct urb *urb)
359 int status = urb->status; 352 int status = urb->status;
360// char *dbg_data; 353// char *dbg_data;
361 354
362 dbg("%s - port %d", __FUNCTION__, port->number); 355 dbg("%s - port %d", __func__, port->number);
363 356
364 if (status) { 357 if (status) {
365 dbg("%s - port %d Read int status not zero: %d", 358 dbg("%s - port %d Read int status not zero: %d",
366 __FUNCTION__, port->number, status); 359 __func__, port->number, status);
367 return; 360 return;
368 } 361 }
369 362
@@ -393,7 +386,7 @@ static void kobil_read_int_callback(struct urb *urb)
393 port->interrupt_in_urb->dev = port->serial->dev; 386 port->interrupt_in_urb->dev = port->serial->dev;
394 387
395 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); 388 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC);
396 dbg("%s - port %d Send read URB returns: %i", __FUNCTION__, port->number, result); 389 dbg("%s - port %d Send read URB returns: %i", __func__, port->number, result);
397} 390}
398 391
399 392
@@ -411,21 +404,21 @@ static int kobil_write (struct usb_serial_port *port,
411 struct kobil_private * priv; 404 struct kobil_private * priv;
412 405
413 if (count == 0) { 406 if (count == 0) {
414 dbg("%s - port %d write request of 0 bytes", __FUNCTION__, port->number); 407 dbg("%s - port %d write request of 0 bytes", __func__, port->number);
415 return 0; 408 return 0;
416 } 409 }
417 410
418 priv = usb_get_serial_port_data(port); 411 priv = usb_get_serial_port_data(port);
419 412
420 if (count > (KOBIL_BUF_LENGTH - priv->filled)) { 413 if (count > (KOBIL_BUF_LENGTH - priv->filled)) {
421 dbg("%s - port %d Error: write request bigger than buffer size", __FUNCTION__, port->number); 414 dbg("%s - port %d Error: write request bigger than buffer size", __func__, port->number);
422 return -ENOMEM; 415 return -ENOMEM;
423 } 416 }
424 417
425 // Copy data to buffer 418 // Copy data to buffer
426 memcpy (priv->buf + priv->filled, buf, count); 419 memcpy (priv->buf + priv->filled, buf, count);
427 420
428 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count, priv->buf + priv->filled); 421 usb_serial_debug_data(debug, &port->dev, __func__, count, priv->buf + priv->filled);
429 422
430 priv->filled = priv->filled + count; 423 priv->filled = priv->filled + count;
431 424
@@ -457,7 +450,7 @@ static int kobil_write (struct usb_serial_port *port,
457 450
458 priv->cur_pos = priv->cur_pos + length; 451 priv->cur_pos = priv->cur_pos + length;
459 result = usb_submit_urb( port->write_urb, GFP_NOIO ); 452 result = usb_submit_urb( port->write_urb, GFP_NOIO );
460 dbg("%s - port %d Send write URB returns: %i", __FUNCTION__, port->number, result); 453 dbg("%s - port %d Send write URB returns: %i", __func__, port->number, result);
461 todo = priv->filled - priv->cur_pos; 454 todo = priv->filled - priv->cur_pos;
462 455
463 if (todo > 0) { 456 if (todo > 0) {
@@ -478,7 +471,7 @@ static int kobil_write (struct usb_serial_port *port,
478 port->interrupt_in_urb->dev = port->serial->dev; 471 port->interrupt_in_urb->dev = port->serial->dev;
479 472
480 result = usb_submit_urb( port->interrupt_in_urb, GFP_NOIO ); 473 result = usb_submit_urb( port->interrupt_in_urb, GFP_NOIO );
481 dbg("%s - port %d Send read URB returns: %i", __FUNCTION__, port->number, result); 474 dbg("%s - port %d Send read URB returns: %i", __func__, port->number, result);
482 } 475 }
483 } 476 }
484 return count; 477 return count;
@@ -487,7 +480,7 @@ static int kobil_write (struct usb_serial_port *port,
487 480
488static int kobil_write_room (struct usb_serial_port *port) 481static int kobil_write_room (struct usb_serial_port *port)
489{ 482{
490 //dbg("%s - port %d", __FUNCTION__, port->number); 483 //dbg("%s - port %d", __func__, port->number);
491 return 8; 484 return 8;
492} 485}
493 486
@@ -522,16 +515,13 @@ static int kobil_tiocmget(struct usb_serial_port *port, struct file *file)
522 KOBIL_TIMEOUT); 515 KOBIL_TIMEOUT);
523 516
524 dbg("%s - port %d Send get_status_line_state URB returns: %i. Statusline: %02x", 517 dbg("%s - port %d Send get_status_line_state URB returns: %i. Statusline: %02x",
525 __FUNCTION__, port->number, result, transfer_buffer[0]); 518 __func__, port->number, result, transfer_buffer[0]);
526
527 if ((transfer_buffer[0] & SUSBCR_GSL_DSR) != 0) {
528 priv->line_state |= TIOCM_DSR;
529 } else {
530 priv->line_state &= ~TIOCM_DSR;
531 }
532 519
520 result = 0;
521 if ((transfer_buffer[0] & SUSBCR_GSL_DSR) != 0)
522 result = TIOCM_DSR;
533 kfree(transfer_buffer); 523 kfree(transfer_buffer);
534 return priv->line_state; 524 return result;
535} 525}
536 526
537static int kobil_tiocmset(struct usb_serial_port *port, struct file *file, 527static int kobil_tiocmset(struct usb_serial_port *port, struct file *file,
@@ -544,6 +534,7 @@ static int kobil_tiocmset(struct usb_serial_port *port, struct file *file,
544 unsigned char *transfer_buffer; 534 unsigned char *transfer_buffer;
545 int transfer_buffer_length = 8; 535 int transfer_buffer_length = 8;
546 536
537 /* FIXME: locking ? */
547 priv = usb_get_serial_port_data(port); 538 priv = usb_get_serial_port_data(port);
548 if ((priv->device_type == KOBIL_USBTWIN_PRODUCT_ID) || (priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID)) { 539 if ((priv->device_type == KOBIL_USBTWIN_PRODUCT_ID) || (priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID)) {
549 // This device doesn't support ioctl calls 540 // This device doesn't support ioctl calls
@@ -567,9 +558,9 @@ static int kobil_tiocmset(struct usb_serial_port *port, struct file *file,
567 558
568 if (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID) { 559 if (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID) {
569 if (dtr != 0) 560 if (dtr != 0)
570 dbg("%s - port %d Setting DTR", __FUNCTION__, port->number); 561 dbg("%s - port %d Setting DTR", __func__, port->number);
571 else 562 else
572 dbg("%s - port %d Clearing DTR", __FUNCTION__, port->number); 563 dbg("%s - port %d Clearing DTR", __func__, port->number);
573 result = usb_control_msg( port->serial->dev, 564 result = usb_control_msg( port->serial->dev,
574 usb_rcvctrlpipe(port->serial->dev, 0 ), 565 usb_rcvctrlpipe(port->serial->dev, 0 ),
575 SUSBCRequest_SetStatusLinesOrQueues, 566 SUSBCRequest_SetStatusLinesOrQueues,
@@ -581,9 +572,9 @@ static int kobil_tiocmset(struct usb_serial_port *port, struct file *file,
581 KOBIL_TIMEOUT); 572 KOBIL_TIMEOUT);
582 } else { 573 } else {
583 if (rts != 0) 574 if (rts != 0)
584 dbg("%s - port %d Setting RTS", __FUNCTION__, port->number); 575 dbg("%s - port %d Setting RTS", __func__, port->number);
585 else 576 else
586 dbg("%s - port %d Clearing RTS", __FUNCTION__, port->number); 577 dbg("%s - port %d Clearing RTS", __func__, port->number);
587 result = usb_control_msg( port->serial->dev, 578 result = usb_control_msg( port->serial->dev,
588 usb_rcvctrlpipe(port->serial->dev, 0 ), 579 usb_rcvctrlpipe(port->serial->dev, 0 ),
589 SUSBCRequest_SetStatusLinesOrQueues, 580 SUSBCRequest_SetStatusLinesOrQueues,
@@ -594,7 +585,7 @@ static int kobil_tiocmset(struct usb_serial_port *port, struct file *file,
594 0, 585 0,
595 KOBIL_TIMEOUT); 586 KOBIL_TIMEOUT);
596 } 587 }
597 dbg("%s - port %d Send set_status_line URB returns: %i", __FUNCTION__, port->number, result); 588 dbg("%s - port %d Send set_status_line URB returns: %i", __func__, port->number, result);
598 kfree(transfer_buffer); 589 kfree(transfer_buffer);
599 return (result < 0) ? result : 0; 590 return (result < 0) ? result : 0;
600} 591}
@@ -687,7 +678,7 @@ static int kobil_ioctl(struct usb_serial_port *port, struct file * file, unsigne
687 KOBIL_TIMEOUT 678 KOBIL_TIMEOUT
688 ); 679 );
689 680
690 dbg("%s - port %d Send reset_all_queues (FLUSH) URB returns: %i", __FUNCTION__, port->number, result); 681 dbg("%s - port %d Send reset_all_queues (FLUSH) URB returns: %i", __func__, port->number, result);
691 kfree(transfer_buffer); 682 kfree(transfer_buffer);
692 return (result < 0) ? -EFAULT : 0; 683 return (result < 0) ? -EFAULT : 0;
693 default: 684 default:
diff --git a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c
index fc1cea4aba1..5fc2cef30e3 100644
--- a/drivers/usb/serial/mct_u232.c
+++ b/drivers/usb/serial/mct_u232.c
@@ -143,9 +143,6 @@ static struct usb_serial_driver mct_u232_device = {
143 .description = "MCT U232", 143 .description = "MCT U232",
144 .usb_driver = &mct_u232_driver, 144 .usb_driver = &mct_u232_driver,
145 .id_table = id_table_combined, 145 .id_table = id_table_combined,
146 .num_interrupt_in = 2,
147 .num_bulk_in = 0,
148 .num_bulk_out = 1,
149 .num_ports = 1, 146 .num_ports = 1,
150 .open = mct_u232_open, 147 .open = mct_u232_open,
151 .close = mct_u232_close, 148 .close = mct_u232_close,
@@ -402,7 +399,7 @@ static void mct_u232_shutdown (struct usb_serial *serial)
402 struct mct_u232_private *priv; 399 struct mct_u232_private *priv;
403 int i; 400 int i;
404 401
405 dbg("%s", __FUNCTION__); 402 dbg("%s", __func__);
406 403
407 for (i=0; i < serial->num_ports; ++i) { 404 for (i=0; i < serial->num_ports; ++i) {
408 /* My special items, the standard routines free my urbs */ 405 /* My special items, the standard routines free my urbs */
@@ -424,7 +421,7 @@ static int mct_u232_open (struct usb_serial_port *port, struct file *filp)
424 unsigned char last_lcr; 421 unsigned char last_lcr;
425 unsigned char last_msr; 422 unsigned char last_msr;
426 423
427 dbg("%s port %d", __FUNCTION__, port->number); 424 dbg("%s port %d", __func__, port->number);
428 425
429 /* Compensate for a hardware bug: although the Sitecom U232-P25 426 /* Compensate for a hardware bug: although the Sitecom U232-P25
430 * device reports a maximum output packet size of 32 bytes, 427 * device reports a maximum output packet size of 32 bytes,
@@ -489,7 +486,7 @@ static void mct_u232_close (struct usb_serial_port *port, struct file *filp)
489 unsigned int c_cflag; 486 unsigned int c_cflag;
490 unsigned int control_state; 487 unsigned int control_state;
491 struct mct_u232_private *priv = usb_get_serial_port_data(port); 488 struct mct_u232_private *priv = usb_get_serial_port_data(port);
492 dbg("%s port %d", __FUNCTION__, port->number); 489 dbg("%s port %d", __func__, port->number);
493 490
494 if (port->tty) { 491 if (port->tty) {
495 c_cflag = port->tty->termios->c_cflag; 492 c_cflag = port->tty->termios->c_cflag;
@@ -517,7 +514,7 @@ static void mct_u232_close (struct usb_serial_port *port, struct file *filp)
517 514
518static void mct_u232_read_int_callback (struct urb *urb) 515static void mct_u232_read_int_callback (struct urb *urb)
519{ 516{
520 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 517 struct usb_serial_port *port = urb->context;
521 struct mct_u232_private *priv = usb_get_serial_port_data(port); 518 struct mct_u232_private *priv = usb_get_serial_port_data(port);
522 struct usb_serial *serial = port->serial; 519 struct usb_serial *serial = port->serial;
523 struct tty_struct *tty; 520 struct tty_struct *tty;
@@ -535,21 +532,21 @@ static void mct_u232_read_int_callback (struct urb *urb)
535 case -ESHUTDOWN: 532 case -ESHUTDOWN:
536 /* this urb is terminated, clean up */ 533 /* this urb is terminated, clean up */
537 dbg("%s - urb shutting down with status: %d", 534 dbg("%s - urb shutting down with status: %d",
538 __FUNCTION__, status); 535 __func__, status);
539 return; 536 return;
540 default: 537 default:
541 dbg("%s - nonzero urb status received: %d", 538 dbg("%s - nonzero urb status received: %d",
542 __FUNCTION__, status); 539 __func__, status);
543 goto exit; 540 goto exit;
544 } 541 }
545 542
546 if (!serial) { 543 if (!serial) {
547 dbg("%s - bad serial pointer, exiting", __FUNCTION__); 544 dbg("%s - bad serial pointer, exiting", __func__);
548 return; 545 return;
549 } 546 }
550 547
551 dbg("%s - port %d", __FUNCTION__, port->number); 548 dbg("%s - port %d", __func__, port->number);
552 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, urb->actual_length, data); 549 usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data);
553 550
554 /* 551 /*
555 * Work-a-round: handle the 'usual' bulk-in pipe here 552 * Work-a-round: handle the 'usual' bulk-in pipe here
@@ -606,7 +603,7 @@ exit:
606 retval = usb_submit_urb (urb, GFP_ATOMIC); 603 retval = usb_submit_urb (urb, GFP_ATOMIC);
607 if (retval) 604 if (retval)
608 err ("%s - usb_submit_urb failed with result %d", 605 err ("%s - usb_submit_urb failed with result %d",
609 __FUNCTION__, retval); 606 __func__, retval);
610} /* mct_u232_read_int_callback */ 607} /* mct_u232_read_int_callback */
611 608
612static void mct_u232_set_termios (struct usb_serial_port *port, 609static void mct_u232_set_termios (struct usb_serial_port *port,
@@ -636,7 +633,7 @@ static void mct_u232_set_termios (struct usb_serial_port *port,
636 633
637 /* reassert DTR and RTS on transition from B0 */ 634 /* reassert DTR and RTS on transition from B0 */
638 if ((old_cflag & CBAUD) == B0) { 635 if ((old_cflag & CBAUD) == B0) {
639 dbg("%s: baud was B0", __FUNCTION__); 636 dbg("%s: baud was B0", __func__);
640 control_state |= TIOCM_DTR | TIOCM_RTS; 637 control_state |= TIOCM_DTR | TIOCM_RTS;
641 mct_u232_set_modem_ctrl(serial, control_state); 638 mct_u232_set_modem_ctrl(serial, control_state);
642 } 639 }
@@ -644,7 +641,7 @@ static void mct_u232_set_termios (struct usb_serial_port *port,
644 mct_u232_set_baud_rate(serial, port, tty_get_baud_rate(port->tty)); 641 mct_u232_set_baud_rate(serial, port, tty_get_baud_rate(port->tty));
645 642
646 if ((cflag & CBAUD) == B0 ) { 643 if ((cflag & CBAUD) == B0 ) {
647 dbg("%s: baud is B0", __FUNCTION__); 644 dbg("%s: baud is B0", __func__);
648 /* Drop RTS and DTR */ 645 /* Drop RTS and DTR */
649 control_state &= ~(TIOCM_DTR | TIOCM_RTS); 646 control_state &= ~(TIOCM_DTR | TIOCM_RTS);
650 mct_u232_set_modem_ctrl(serial, control_state); 647 mct_u232_set_modem_ctrl(serial, control_state);
@@ -699,7 +696,7 @@ static void mct_u232_break_ctl( struct usb_serial_port *port, int break_state )
699 unsigned char lcr; 696 unsigned char lcr;
700 unsigned long flags; 697 unsigned long flags;
701 698
702 dbg("%sstate=%d", __FUNCTION__, break_state); 699 dbg("%sstate=%d", __func__, break_state);
703 700
704 spin_lock_irqsave(&priv->lock, flags); 701 spin_lock_irqsave(&priv->lock, flags);
705 lcr = priv->last_lcr; 702 lcr = priv->last_lcr;
@@ -718,7 +715,7 @@ static int mct_u232_tiocmget (struct usb_serial_port *port, struct file *file)
718 unsigned int control_state; 715 unsigned int control_state;
719 unsigned long flags; 716 unsigned long flags;
720 717
721 dbg("%s", __FUNCTION__); 718 dbg("%s", __func__);
722 719
723 spin_lock_irqsave(&priv->lock, flags); 720 spin_lock_irqsave(&priv->lock, flags);
724 control_state = priv->control_state; 721 control_state = priv->control_state;
@@ -735,7 +732,7 @@ static int mct_u232_tiocmset (struct usb_serial_port *port, struct file *file,
735 unsigned int control_state; 732 unsigned int control_state;
736 unsigned long flags; 733 unsigned long flags;
737 734
738 dbg("%s", __FUNCTION__); 735 dbg("%s", __func__);
739 736
740 spin_lock_irqsave(&priv->lock, flags); 737 spin_lock_irqsave(&priv->lock, flags);
741 control_state = priv->control_state; 738 control_state = priv->control_state;
@@ -757,7 +754,7 @@ static int mct_u232_tiocmset (struct usb_serial_port *port, struct file *file,
757static int mct_u232_ioctl (struct usb_serial_port *port, struct file * file, 754static int mct_u232_ioctl (struct usb_serial_port *port, struct file * file,
758 unsigned int cmd, unsigned long arg) 755 unsigned int cmd, unsigned long arg)
759{ 756{
760 dbg("%scmd=0x%x", __FUNCTION__, cmd); 757 dbg("%scmd=0x%x", __func__, cmd);
761 758
762 /* Based on code from acm.c and others */ 759 /* Based on code from acm.c and others */
763 switch (cmd) { 760 switch (cmd) {
@@ -772,7 +769,7 @@ static int mct_u232_ioctl (struct usb_serial_port *port, struct file * file,
772 return 0; 769 return 0;
773 770
774 default: 771 default:
775 dbg("%s: arg not supported - 0x%04x", __FUNCTION__,cmd); 772 dbg("%s: arg not supported - 0x%04x", __func__,cmd);
776 return(-ENOIOCTLCMD); 773 return(-ENOIOCTLCMD);
777 break; 774 break;
778 } 775 }
@@ -787,7 +784,7 @@ static void mct_u232_throttle (struct usb_serial_port *port)
787 struct tty_struct *tty; 784 struct tty_struct *tty;
788 785
789 tty = port->tty; 786 tty = port->tty;
790 dbg("%s - port %d", __FUNCTION__, port->number); 787 dbg("%s - port %d", __func__, port->number);
791 788
792 spin_lock_irqsave(&priv->lock, flags); 789 spin_lock_irqsave(&priv->lock, flags);
793 priv->rx_flags |= THROTTLED; 790 priv->rx_flags |= THROTTLED;
@@ -809,7 +806,7 @@ static void mct_u232_unthrottle (struct usb_serial_port *port)
809 unsigned int control_state; 806 unsigned int control_state;
810 struct tty_struct *tty; 807 struct tty_struct *tty;
811 808
812 dbg("%s - port %d", __FUNCTION__, port->number); 809 dbg("%s - port %d", __func__, port->number);
813 810
814 tty = port->tty; 811 tty = port->tty;
815 spin_lock_irqsave(&priv->lock, flags); 812 spin_lock_irqsave(&priv->lock, flags);
diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c
index 40f3a018880..50f1fe26333 100644
--- a/drivers/usb/serial/mos7720.c
+++ b/drivers/usb/serial/mos7720.c
@@ -118,11 +118,11 @@ static void mos7720_interrupt_callback(struct urb *urb)
118 case -ENOENT: 118 case -ENOENT:
119 case -ESHUTDOWN: 119 case -ESHUTDOWN:
120 /* this urb is terminated, clean up */ 120 /* this urb is terminated, clean up */
121 dbg("%s - urb shutting down with status: %d", __FUNCTION__, 121 dbg("%s - urb shutting down with status: %d", __func__,
122 status); 122 status);
123 return; 123 return;
124 default: 124 default:
125 dbg("%s - nonzero urb status received: %d", __FUNCTION__, 125 dbg("%s - nonzero urb status received: %d", __func__,
126 status); 126 status);
127 goto exit; 127 goto exit;
128 } 128 }
@@ -183,7 +183,7 @@ exit:
183 if (result) 183 if (result)
184 dev_err(&urb->dev->dev, 184 dev_err(&urb->dev->dev,
185 "%s - Error %d submitting control urb\n", 185 "%s - Error %d submitting control urb\n",
186 __FUNCTION__, result); 186 __func__, result);
187 return; 187 return;
188} 188}
189 189
@@ -214,7 +214,7 @@ static void mos7720_bulk_in_callback(struct urb *urb)
214 214
215 port = mos7720_port->port; 215 port = mos7720_port->port;
216 216
217 dbg("Entering...%s", __FUNCTION__); 217 dbg("Entering...%s", __func__);
218 218
219 data = urb->transfer_buffer; 219 data = urb->transfer_buffer;
220 220
@@ -362,7 +362,7 @@ static int mos7720_open(struct usb_serial_port *port, struct file * filp)
362 urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE, 362 urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE,
363 GFP_KERNEL); 363 GFP_KERNEL);
364 if (!urb->transfer_buffer) { 364 if (!urb->transfer_buffer) {
365 err("%s-out of memory for urb buffers.", __FUNCTION__); 365 err("%s-out of memory for urb buffers.", __func__);
366 usb_free_urb(mos7720_port->write_urb_pool[j]); 366 usb_free_urb(mos7720_port->write_urb_pool[j]);
367 mos7720_port->write_urb_pool[j] = NULL; 367 mos7720_port->write_urb_pool[j] = NULL;
368 continue; 368 continue;
@@ -479,7 +479,7 @@ static int mos7720_open(struct usb_serial_port *port, struct file * filp)
479 if (response) 479 if (response)
480 dev_err(&port->dev, 480 dev_err(&port->dev,
481 "%s - Error %d submitting control urb\n", 481 "%s - Error %d submitting control urb\n",
482 __FUNCTION__, response); 482 __func__, response);
483 } 483 }
484 484
485 /* set up our bulk in urb */ 485 /* set up our bulk in urb */
@@ -492,7 +492,7 @@ static int mos7720_open(struct usb_serial_port *port, struct file * filp)
492 response = usb_submit_urb(port->read_urb, GFP_KERNEL); 492 response = usb_submit_urb(port->read_urb, GFP_KERNEL);
493 if (response) 493 if (response)
494 dev_err(&port->dev, 494 dev_err(&port->dev,
495 "%s - Error %d submitting read urb\n", __FUNCTION__, response); 495 "%s - Error %d submitting read urb\n", __func__, response);
496 496
497 /* initialize our icount structure */ 497 /* initialize our icount structure */
498 memset(&(mos7720_port->icount), 0x00, sizeof(mos7720_port->icount)); 498 memset(&(mos7720_port->icount), 0x00, sizeof(mos7720_port->icount));
@@ -521,11 +521,11 @@ static int mos7720_chars_in_buffer(struct usb_serial_port *port)
521 int chars = 0; 521 int chars = 0;
522 struct moschip_port *mos7720_port; 522 struct moschip_port *mos7720_port;
523 523
524 dbg("%s:entering ...........", __FUNCTION__); 524 dbg("%s:entering ...........", __func__);
525 525
526 mos7720_port = usb_get_serial_port_data(port); 526 mos7720_port = usb_get_serial_port_data(port);
527 if (mos7720_port == NULL) { 527 if (mos7720_port == NULL) {
528 dbg("%s:leaving ...........", __FUNCTION__); 528 dbg("%s:leaving ...........", __func__);
529 return -ENODEV; 529 return -ENODEV;
530 } 530 }
531 531
@@ -533,7 +533,7 @@ static int mos7720_chars_in_buffer(struct usb_serial_port *port)
533 if (mos7720_port->write_urb_pool[i] && mos7720_port->write_urb_pool[i]->status == -EINPROGRESS) 533 if (mos7720_port->write_urb_pool[i] && mos7720_port->write_urb_pool[i]->status == -EINPROGRESS)
534 chars += URB_TRANSFER_BUFFER_SIZE; 534 chars += URB_TRANSFER_BUFFER_SIZE;
535 } 535 }
536 dbg("%s - returns %d", __FUNCTION__, chars); 536 dbg("%s - returns %d", __func__, chars);
537 return chars; 537 return chars;
538} 538}
539 539
@@ -585,7 +585,7 @@ static void mos7720_close(struct usb_serial_port *port, struct file *filp)
585 mutex_unlock(&serial->disc_mutex); 585 mutex_unlock(&serial->disc_mutex);
586 mos7720_port->open = 0; 586 mos7720_port->open = 0;
587 587
588 dbg("Leaving %s", __FUNCTION__); 588 dbg("Leaving %s", __func__);
589} 589}
590 590
591static void mos7720_break(struct usb_serial_port *port, int break_state) 591static void mos7720_break(struct usb_serial_port *port, int break_state)
@@ -594,7 +594,7 @@ static void mos7720_break(struct usb_serial_port *port, int break_state)
594 struct usb_serial *serial; 594 struct usb_serial *serial;
595 struct moschip_port *mos7720_port; 595 struct moschip_port *mos7720_port;
596 596
597 dbg("Entering %s", __FUNCTION__); 597 dbg("Entering %s", __func__);
598 598
599 serial = port->serial; 599 serial = port->serial;
600 600
@@ -627,20 +627,21 @@ static int mos7720_write_room(struct usb_serial_port *port)
627 int room = 0; 627 int room = 0;
628 int i; 628 int i;
629 629
630 dbg("%s:entering ...........", __FUNCTION__); 630 dbg("%s:entering ...........", __func__);
631 631
632 mos7720_port = usb_get_serial_port_data(port); 632 mos7720_port = usb_get_serial_port_data(port);
633 if (mos7720_port == NULL) { 633 if (mos7720_port == NULL) {
634 dbg("%s:leaving ...........", __FUNCTION__); 634 dbg("%s:leaving ...........", __func__);
635 return -ENODEV; 635 return -ENODEV;
636 } 636 }
637 637
638 /* FIXME: Locking */
638 for (i = 0; i < NUM_URBS; ++i) { 639 for (i = 0; i < NUM_URBS; ++i) {
639 if (mos7720_port->write_urb_pool[i] && mos7720_port->write_urb_pool[i]->status != -EINPROGRESS) 640 if (mos7720_port->write_urb_pool[i] && mos7720_port->write_urb_pool[i]->status != -EINPROGRESS)
640 room += URB_TRANSFER_BUFFER_SIZE; 641 room += URB_TRANSFER_BUFFER_SIZE;
641 } 642 }
642 643
643 dbg("%s - returns %d", __FUNCTION__, room); 644 dbg("%s - returns %d", __func__, room);
644 return room; 645 return room;
645} 646}
646 647
@@ -657,7 +658,7 @@ static int mos7720_write(struct usb_serial_port *port,
657 struct urb *urb; 658 struct urb *urb;
658 const unsigned char *current_position = data; 659 const unsigned char *current_position = data;
659 660
660 dbg("%s:entering ...........", __FUNCTION__); 661 dbg("%s:entering ...........", __func__);
661 662
662 serial = port->serial; 663 serial = port->serial;
663 664
@@ -679,7 +680,7 @@ static int mos7720_write(struct usb_serial_port *port,
679 } 680 }
680 681
681 if (urb == NULL) { 682 if (urb == NULL) {
682 dbg("%s - no more free urbs", __FUNCTION__); 683 dbg("%s - no more free urbs", __func__);
683 goto exit; 684 goto exit;
684 } 685 }
685 686
@@ -687,14 +688,14 @@ static int mos7720_write(struct usb_serial_port *port,
687 urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE, 688 urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE,
688 GFP_KERNEL); 689 GFP_KERNEL);
689 if (urb->transfer_buffer == NULL) { 690 if (urb->transfer_buffer == NULL) {
690 err("%s no more kernel memory...", __FUNCTION__); 691 err("%s no more kernel memory...", __func__);
691 goto exit; 692 goto exit;
692 } 693 }
693 } 694 }
694 transfer_size = min (count, URB_TRANSFER_BUFFER_SIZE); 695 transfer_size = min (count, URB_TRANSFER_BUFFER_SIZE);
695 696
696 memcpy(urb->transfer_buffer, current_position, transfer_size); 697 memcpy(urb->transfer_buffer, current_position, transfer_size);
697 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, transfer_size, 698 usb_serial_debug_data(debug, &port->dev, __func__, transfer_size,
698 urb->transfer_buffer); 699 urb->transfer_buffer);
699 700
700 /* fill urb with data and submit */ 701 /* fill urb with data and submit */
@@ -708,7 +709,7 @@ static int mos7720_write(struct usb_serial_port *port,
708 status = usb_submit_urb(urb,GFP_ATOMIC); 709 status = usb_submit_urb(urb,GFP_ATOMIC);
709 if (status) { 710 if (status) {
710 err("%s - usb_submit_urb(write bulk) failed with status = %d", 711 err("%s - usb_submit_urb(write bulk) failed with status = %d",
711 __FUNCTION__, status); 712 __func__, status);
712 bytes_sent = status; 713 bytes_sent = status;
713 goto exit; 714 goto exit;
714 } 715 }
@@ -724,7 +725,7 @@ static void mos7720_throttle(struct usb_serial_port *port)
724 struct tty_struct *tty; 725 struct tty_struct *tty;
725 int status; 726 int status;
726 727
727 dbg("%s- port %d\n", __FUNCTION__, port->number); 728 dbg("%s- port %d\n", __func__, port->number);
728 729
729 mos7720_port = usb_get_serial_port_data(port); 730 mos7720_port = usb_get_serial_port_data(port);
730 731
@@ -736,11 +737,11 @@ static void mos7720_throttle(struct usb_serial_port *port)
736 return; 737 return;
737 } 738 }
738 739
739 dbg("%s: Entering ..........", __FUNCTION__); 740 dbg("%s: Entering ..........", __func__);
740 741
741 tty = port->tty; 742 tty = port->tty;
742 if (!tty) { 743 if (!tty) {
743 dbg("%s - no tty available", __FUNCTION__); 744 dbg("%s - no tty available", __func__);
744 return; 745 return;
745 } 746 }
746 747
@@ -773,15 +774,15 @@ static void mos7720_unthrottle(struct usb_serial_port *port)
773 return; 774 return;
774 775
775 if (!mos7720_port->open) { 776 if (!mos7720_port->open) {
776 dbg("%s - port not opened", __FUNCTION__); 777 dbg("%s - port not opened", __func__);
777 return; 778 return;
778 } 779 }
779 780
780 dbg("%s: Entering ..........", __FUNCTION__); 781 dbg("%s: Entering ..........", __func__);
781 782
782 tty = port->tty; 783 tty = port->tty;
783 if (!tty) { 784 if (!tty) {
784 dbg("%s - no tty available", __FUNCTION__); 785 dbg("%s - no tty available", __func__);
785 return; 786 return;
786 } 787 }
787 788
@@ -922,7 +923,7 @@ static int calc_baud_rate_divisor(int baudrate, int *divisor)
922 __u16 round; 923 __u16 round;
923 924
924 925
925 dbg("%s - %d", __FUNCTION__, baudrate); 926 dbg("%s - %d", __func__, baudrate);
926 927
927 for (i = 0; i < ARRAY_SIZE(divisor_table); i++) { 928 for (i = 0; i < ARRAY_SIZE(divisor_table); i++) {
928 if (divisor_table[i].baudrate == baudrate) { 929 if (divisor_table[i].baudrate == baudrate) {
@@ -973,15 +974,15 @@ static int send_cmd_write_baud_rate(struct moschip_port *mos7720_port,
973 port = mos7720_port->port; 974 port = mos7720_port->port;
974 serial = port->serial; 975 serial = port->serial;
975 976
976 dbg("%s: Entering ..........", __FUNCTION__); 977 dbg("%s: Entering ..........", __func__);
977 978
978 number = port->number - port->serial->minor; 979 number = port->number - port->serial->minor;
979 dbg("%s - port = %d, baud = %d", __FUNCTION__, port->number, baudrate); 980 dbg("%s - port = %d, baud = %d", __func__, port->number, baudrate);
980 981
981 /* Calculate the Divisor */ 982 /* Calculate the Divisor */
982 status = calc_baud_rate_divisor(baudrate, &divisor); 983 status = calc_baud_rate_divisor(baudrate, &divisor);
983 if (status) { 984 if (status) {
984 err("%s - bad baud rate", __FUNCTION__); 985 err("%s - bad baud rate", __func__);
985 return status; 986 return status;
986 } 987 }
987 988
@@ -1034,16 +1035,16 @@ static void change_port_settings(struct moschip_port *mos7720_port,
1034 serial = port->serial; 1035 serial = port->serial;
1035 port_number = port->number - port->serial->minor; 1036 port_number = port->number - port->serial->minor;
1036 1037
1037 dbg("%s - port %d", __FUNCTION__, port->number); 1038 dbg("%s - port %d", __func__, port->number);
1038 1039
1039 if (!mos7720_port->open) { 1040 if (!mos7720_port->open) {
1040 dbg("%s - port not opened", __FUNCTION__); 1041 dbg("%s - port not opened", __func__);
1041 return; 1042 return;
1042 } 1043 }
1043 1044
1044 tty = mos7720_port->port->tty; 1045 tty = mos7720_port->port->tty;
1045 1046
1046 dbg("%s: Entering ..........", __FUNCTION__); 1047 dbg("%s: Entering ..........", __func__);
1047 1048
1048 lData = UART_LCR_WLEN8; 1049 lData = UART_LCR_WLEN8;
1049 lStop = 0x00; /* 1 stop bit */ 1050 lStop = 0x00; /* 1 stop bit */
@@ -1078,14 +1079,14 @@ static void change_port_settings(struct moschip_port *mos7720_port,
1078 if (cflag & PARENB) { 1079 if (cflag & PARENB) {
1079 if (cflag & PARODD) { 1080 if (cflag & PARODD) {
1080 lParity = UART_LCR_PARITY; 1081 lParity = UART_LCR_PARITY;
1081 dbg("%s - parity = odd", __FUNCTION__); 1082 dbg("%s - parity = odd", __func__);
1082 } else { 1083 } else {
1083 lParity = (UART_LCR_EPAR | UART_LCR_PARITY); 1084 lParity = (UART_LCR_EPAR | UART_LCR_PARITY);
1084 dbg("%s - parity = even", __FUNCTION__); 1085 dbg("%s - parity = even", __func__);
1085 } 1086 }
1086 1087
1087 } else { 1088 } else {
1088 dbg("%s - parity = none", __FUNCTION__); 1089 dbg("%s - parity = none", __func__);
1089 } 1090 }
1090 1091
1091 if (cflag & CMSPAR) 1092 if (cflag & CMSPAR)
@@ -1094,10 +1095,10 @@ static void change_port_settings(struct moschip_port *mos7720_port,
1094 /* Change the Stop bit */ 1095 /* Change the Stop bit */
1095 if (cflag & CSTOPB) { 1096 if (cflag & CSTOPB) {
1096 lStop = UART_LCR_STOP; 1097 lStop = UART_LCR_STOP;
1097 dbg("%s - stop bits = 2", __FUNCTION__); 1098 dbg("%s - stop bits = 2", __func__);
1098 } else { 1099 } else {
1099 lStop = 0x00; 1100 lStop = 0x00;
1100 dbg("%s - stop bits = 1", __FUNCTION__); 1101 dbg("%s - stop bits = 1", __func__);
1101 } 1102 }
1102 1103
1103#define LCR_BITS_MASK 0x03 /* Mask for bits/char field */ 1104#define LCR_BITS_MASK 0x03 /* Mask for bits/char field */
@@ -1171,7 +1172,7 @@ static void change_port_settings(struct moschip_port *mos7720_port,
1171 return; 1172 return;
1172 } 1173 }
1173 1174
1174 dbg("%s - baud rate = %d", __FUNCTION__, baud); 1175 dbg("%s - baud rate = %d", __func__, baud);
1175 status = send_cmd_write_baud_rate(mos7720_port, baud); 1176 status = send_cmd_write_baud_rate(mos7720_port, baud);
1176 /* FIXME: needs to write actual resulting baud back not just 1177 /* FIXME: needs to write actual resulting baud back not just
1177 blindly do so */ 1178 blindly do so */
@@ -1217,7 +1218,7 @@ static void mos7720_set_termios(struct usb_serial_port *port,
1217 1218
1218 1219
1219 if (!mos7720_port->open) { 1220 if (!mos7720_port->open) {
1220 dbg("%s - port not opened", __FUNCTION__); 1221 dbg("%s - port not opened", __func__);
1221 return; 1222 return;
1222 } 1223 }
1223 1224
@@ -1225,15 +1226,15 @@ static void mos7720_set_termios(struct usb_serial_port *port,
1225 1226
1226 cflag = tty->termios->c_cflag; 1227 cflag = tty->termios->c_cflag;
1227 1228
1228 dbg("%s - cflag %08x iflag %08x", __FUNCTION__, 1229 dbg("%s - cflag %08x iflag %08x", __func__,
1229 tty->termios->c_cflag, 1230 tty->termios->c_cflag,
1230 RELEVANT_IFLAG(tty->termios->c_iflag)); 1231 RELEVANT_IFLAG(tty->termios->c_iflag));
1231 1232
1232 dbg("%s - old cflag %08x old iflag %08x", __FUNCTION__, 1233 dbg("%s - old cflag %08x old iflag %08x", __func__,
1233 old_termios->c_cflag, 1234 old_termios->c_cflag,
1234 RELEVANT_IFLAG(old_termios->c_iflag)); 1235 RELEVANT_IFLAG(old_termios->c_iflag));
1235 1236
1236 dbg("%s - port %d", __FUNCTION__, port->number); 1237 dbg("%s - port %d", __func__, port->number);
1237 1238
1238 /* change the port settings to the new ones specified */ 1239 /* change the port settings to the new ones specified */
1239 change_port_settings(mos7720_port, old_termios); 1240 change_port_settings(mos7720_port, old_termios);
@@ -1271,7 +1272,7 @@ static int get_lsr_info(struct moschip_port *mos7720_port,
1271 1272
1272 count = mos7720_chars_in_buffer(mos7720_port->port); 1273 count = mos7720_chars_in_buffer(mos7720_port->port);
1273 if (count == 0) { 1274 if (count == 0) {
1274 dbg("%s -- Empty", __FUNCTION__); 1275 dbg("%s -- Empty", __func__);
1275 result = TIOCSER_TEMT; 1276 result = TIOCSER_TEMT;
1276 } 1277 }
1277 1278
@@ -1296,7 +1297,7 @@ static int get_number_bytes_avail(struct moschip_port *mos7720_port,
1296 1297
1297 result = tty->read_cnt; 1298 result = tty->read_cnt;
1298 1299
1299 dbg("%s(%d) = %d", __FUNCTION__, mos7720_port->port->number, result); 1300 dbg("%s(%d) = %d", __func__, mos7720_port->port->number, result);
1300 if (copy_to_user(value, &result, sizeof(int))) 1301 if (copy_to_user(value, &result, sizeof(int)))
1301 return -EFAULT; 1302 return -EFAULT;
1302 1303
@@ -1374,7 +1375,7 @@ static int get_modem_info(struct moschip_port *mos7720_port,
1374 | ((msr & UART_MSR_DSR) ? TIOCM_DSR: 0); /* 0x100 */ 1375 | ((msr & UART_MSR_DSR) ? TIOCM_DSR: 0); /* 0x100 */
1375 1376
1376 1377
1377 dbg("%s -- %x", __FUNCTION__, result); 1378 dbg("%s -- %x", __func__, result);
1378 1379
1379 if (copy_to_user(value, &result, sizeof(int))) 1380 if (copy_to_user(value, &result, sizeof(int)))
1380 return -EFAULT; 1381 return -EFAULT;
@@ -1418,45 +1419,45 @@ static int mos7720_ioctl(struct usb_serial_port *port, struct file *file,
1418 if (mos7720_port == NULL) 1419 if (mos7720_port == NULL)
1419 return -ENODEV; 1420 return -ENODEV;
1420 1421
1421 dbg("%s - port %d, cmd = 0x%x", __FUNCTION__, port->number, cmd); 1422 dbg("%s - port %d, cmd = 0x%x", __func__, port->number, cmd);
1422 1423
1423 switch (cmd) { 1424 switch (cmd) {
1424 case TIOCINQ: 1425 case TIOCINQ:
1425 /* return number of bytes available */ 1426 /* return number of bytes available */
1426 dbg("%s (%d) TIOCINQ", __FUNCTION__, port->number); 1427 dbg("%s (%d) TIOCINQ", __func__, port->number);
1427 return get_number_bytes_avail(mos7720_port, 1428 return get_number_bytes_avail(mos7720_port,
1428 (unsigned int __user *)arg); 1429 (unsigned int __user *)arg);
1429 break; 1430 break;
1430 1431
1431 case TIOCSERGETLSR: 1432 case TIOCSERGETLSR:
1432 dbg("%s (%d) TIOCSERGETLSR", __FUNCTION__, port->number); 1433 dbg("%s (%d) TIOCSERGETLSR", __func__, port->number);
1433 return get_lsr_info(mos7720_port, (unsigned int __user *)arg); 1434 return get_lsr_info(mos7720_port, (unsigned int __user *)arg);
1434 return 0; 1435 return 0;
1435 1436
1436 case TIOCMBIS: 1437 case TIOCMBIS:
1437 case TIOCMBIC: 1438 case TIOCMBIC:
1438 case TIOCMSET: 1439 case TIOCMSET:
1439 dbg("%s (%d) TIOCMSET/TIOCMBIC/TIOCMSET", __FUNCTION__, 1440 dbg("%s (%d) TIOCMSET/TIOCMBIC/TIOCMSET", __func__,
1440 port->number); 1441 port->number);
1441 return set_modem_info(mos7720_port, cmd, 1442 return set_modem_info(mos7720_port, cmd,
1442 (unsigned int __user *)arg); 1443 (unsigned int __user *)arg);
1443 1444
1444 case TIOCMGET: 1445 case TIOCMGET:
1445 dbg("%s (%d) TIOCMGET", __FUNCTION__, port->number); 1446 dbg("%s (%d) TIOCMGET", __func__, port->number);
1446 return get_modem_info(mos7720_port, 1447 return get_modem_info(mos7720_port,
1447 (unsigned int __user *)arg); 1448 (unsigned int __user *)arg);
1448 1449
1449 case TIOCGSERIAL: 1450 case TIOCGSERIAL:
1450 dbg("%s (%d) TIOCGSERIAL", __FUNCTION__, port->number); 1451 dbg("%s (%d) TIOCGSERIAL", __func__, port->number);
1451 return get_serial_info(mos7720_port, 1452 return get_serial_info(mos7720_port,
1452 (struct serial_struct __user *)arg); 1453 (struct serial_struct __user *)arg);
1453 1454
1454 case TIOCSSERIAL: 1455 case TIOCSSERIAL:
1455 dbg("%s (%d) TIOCSSERIAL", __FUNCTION__, port->number); 1456 dbg("%s (%d) TIOCSSERIAL", __func__, port->number);
1456 break; 1457 break;
1457 1458
1458 case TIOCMIWAIT: 1459 case TIOCMIWAIT:
1459 dbg("%s (%d) TIOCMIWAIT", __FUNCTION__, port->number); 1460 dbg("%s (%d) TIOCMIWAIT", __func__, port->number);
1460 cprev = mos7720_port->icount; 1461 cprev = mos7720_port->icount;
1461 while (1) { 1462 while (1) {
1462 if (signal_pending(current)) 1463 if (signal_pending(current))
@@ -1490,7 +1491,7 @@ static int mos7720_ioctl(struct usb_serial_port *port, struct file *file,
1490 icount.brk = cnow.brk; 1491 icount.brk = cnow.brk;
1491 icount.buf_overrun = cnow.buf_overrun; 1492 icount.buf_overrun = cnow.buf_overrun;
1492 1493
1493 dbg("%s (%d) TIOCGICOUNT RX=%d, TX=%d", __FUNCTION__, 1494 dbg("%s (%d) TIOCGICOUNT RX=%d, TX=%d", __func__,
1494 port->number, icount.rx, icount.tx ); 1495 port->number, icount.rx, icount.tx );
1495 if (copy_to_user((void __user *)arg, &icount, sizeof(icount))) 1496 if (copy_to_user((void __user *)arg, &icount, sizeof(icount)))
1496 return -EFAULT; 1497 return -EFAULT;
@@ -1508,7 +1509,7 @@ static int mos7720_startup(struct usb_serial *serial)
1508 int i; 1509 int i;
1509 char data; 1510 char data;
1510 1511
1511 dbg("%s: Entering ..........", __FUNCTION__); 1512 dbg("%s: Entering ..........", __func__);
1512 1513
1513 if (!serial) { 1514 if (!serial) {
1514 dbg("Invalid Handler"); 1515 dbg("Invalid Handler");
@@ -1520,7 +1521,7 @@ static int mos7720_startup(struct usb_serial *serial)
1520 /* create our private serial structure */ 1521 /* create our private serial structure */
1521 mos7720_serial = kzalloc(sizeof(struct moschip_serial), GFP_KERNEL); 1522 mos7720_serial = kzalloc(sizeof(struct moschip_serial), GFP_KERNEL);
1522 if (mos7720_serial == NULL) { 1523 if (mos7720_serial == NULL) {
1523 err("%s - Out of memory", __FUNCTION__); 1524 err("%s - Out of memory", __func__);
1524 return -ENOMEM; 1525 return -ENOMEM;
1525 } 1526 }
1526 1527
@@ -1533,7 +1534,7 @@ static int mos7720_startup(struct usb_serial *serial)
1533 for (i = 0; i < serial->num_ports; ++i) { 1534 for (i = 0; i < serial->num_ports; ++i) {
1534 mos7720_port = kzalloc(sizeof(struct moschip_port), GFP_KERNEL); 1535 mos7720_port = kzalloc(sizeof(struct moschip_port), GFP_KERNEL);
1535 if (mos7720_port == NULL) { 1536 if (mos7720_port == NULL) {
1536 err("%s - Out of memory", __FUNCTION__); 1537 err("%s - Out of memory", __func__);
1537 usb_set_serial_data(serial, NULL); 1538 usb_set_serial_data(serial, NULL);
1538 kfree(mos7720_serial); 1539 kfree(mos7720_serial);
1539 return -ENOMEM; 1540 return -ENOMEM;
@@ -1596,9 +1597,6 @@ static struct usb_serial_driver moschip7720_2port_driver = {
1596 .description = "Moschip 2 port adapter", 1597 .description = "Moschip 2 port adapter",
1597 .usb_driver = &usb_driver, 1598 .usb_driver = &usb_driver,
1598 .id_table = moschip_port_id_table, 1599 .id_table = moschip_port_id_table,
1599 .num_interrupt_in = 1,
1600 .num_bulk_in = 2,
1601 .num_bulk_out = 2,
1602 .num_ports = 2, 1600 .num_ports = 2,
1603 .open = mos7720_open, 1601 .open = mos7720_open,
1604 .close = mos7720_close, 1602 .close = mos7720_close,
@@ -1620,7 +1618,7 @@ static int __init moschip7720_init(void)
1620{ 1618{
1621 int retval; 1619 int retval;
1622 1620
1623 dbg("%s: Entering ..........", __FUNCTION__); 1621 dbg("%s: Entering ..........", __func__);
1624 1622
1625 /* Register with the usb serial */ 1623 /* Register with the usb serial */
1626 retval = usb_serial_register(&moschip7720_2port_driver); 1624 retval = usb_serial_register(&moschip7720_2port_driver);
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index aeeb9cb2099..6bcb82d3911 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -403,7 +403,7 @@ static void mos7840_handle_new_lsr(struct moschip_port *port, __u8 new_lsr)
403{ 403{
404 struct async_icount *icount; 404 struct async_icount *icount;
405 405
406 dbg("%s - %02x", __FUNCTION__, new_lsr); 406 dbg("%s - %02x", __func__, new_lsr);
407 407
408 if (new_lsr & SERIAL_LSR_BI) { 408 if (new_lsr & SERIAL_LSR_BI) {
409 // 409 //
@@ -449,7 +449,7 @@ static void mos7840_control_callback(struct urb *urb)
449 int result = 0; 449 int result = 0;
450 int status = urb->status; 450 int status = urb->status;
451 451
452 mos7840_port = (struct moschip_port *)urb->context; 452 mos7840_port = urb->context;
453 453
454 switch (status) { 454 switch (status) {
455 case 0: 455 case 0:
@@ -459,21 +459,21 @@ static void mos7840_control_callback(struct urb *urb)
459 case -ENOENT: 459 case -ENOENT:
460 case -ESHUTDOWN: 460 case -ESHUTDOWN:
461 /* this urb is terminated, clean up */ 461 /* this urb is terminated, clean up */
462 dbg("%s - urb shutting down with status: %d", __FUNCTION__, 462 dbg("%s - urb shutting down with status: %d", __func__,
463 status); 463 status);
464 return; 464 return;
465 default: 465 default:
466 dbg("%s - nonzero urb status received: %d", __FUNCTION__, 466 dbg("%s - nonzero urb status received: %d", __func__,
467 status); 467 status);
468 goto exit; 468 goto exit;
469 } 469 }
470 470
471 dbg("%s urb buffer size is %d\n", __FUNCTION__, urb->actual_length); 471 dbg("%s urb buffer size is %d\n", __func__, urb->actual_length);
472 dbg("%s mos7840_port->MsrLsr is %d port %d\n", __FUNCTION__, 472 dbg("%s mos7840_port->MsrLsr is %d port %d\n", __func__,
473 mos7840_port->MsrLsr, mos7840_port->port_num); 473 mos7840_port->MsrLsr, mos7840_port->port_num);
474 data = urb->transfer_buffer; 474 data = urb->transfer_buffer;
475 regval = (__u8) data[0]; 475 regval = (__u8) data[0];
476 dbg("%s data is %x\n", __FUNCTION__, regval); 476 dbg("%s data is %x\n", __func__, regval);
477 if (mos7840_port->MsrLsr == 0) 477 if (mos7840_port->MsrLsr == 0)
478 mos7840_handle_new_msr(mos7840_port, regval); 478 mos7840_handle_new_msr(mos7840_port, regval);
479 else if (mos7840_port->MsrLsr == 1) 479 else if (mos7840_port->MsrLsr == 1)
@@ -487,7 +487,7 @@ exit:
487 if (result) { 487 if (result) {
488 dev_err(&urb->dev->dev, 488 dev_err(&urb->dev->dev,
489 "%s - Error %d submitting interrupt urb\n", 489 "%s - Error %d submitting interrupt urb\n",
490 __FUNCTION__, result); 490 __func__, result);
491 } 491 }
492} 492}
493 493
@@ -542,11 +542,11 @@ static void mos7840_interrupt_callback(struct urb *urb)
542 case -ENOENT: 542 case -ENOENT:
543 case -ESHUTDOWN: 543 case -ESHUTDOWN:
544 /* this urb is terminated, clean up */ 544 /* this urb is terminated, clean up */
545 dbg("%s - urb shutting down with status: %d", __FUNCTION__, 545 dbg("%s - urb shutting down with status: %d", __func__,
546 status); 546 status);
547 return; 547 return;
548 default: 548 default:
549 dbg("%s - nonzero urb status received: %d", __FUNCTION__, 549 dbg("%s - nonzero urb status received: %d", __func__,
550 status); 550 status);
551 goto exit; 551 goto exit;
552 } 552 }
@@ -554,7 +554,7 @@ static void mos7840_interrupt_callback(struct urb *urb)
554 length = urb->actual_length; 554 length = urb->actual_length;
555 data = urb->transfer_buffer; 555 data = urb->transfer_buffer;
556 556
557 serial = (struct usb_serial *)urb->context; 557 serial = urb->context;
558 558
559 /* Moschip get 5 bytes 559 /* Moschip get 5 bytes
560 * Byte 1 IIR Port 1 (port.number is 0) 560 * Byte 1 IIR Port 1 (port.number is 0)
@@ -614,7 +614,7 @@ exit:
614 if (result) { 614 if (result) {
615 dev_err(&urb->dev->dev, 615 dev_err(&urb->dev->dev,
616 "%s - Error %d submitting interrupt urb\n", 616 "%s - Error %d submitting interrupt urb\n",
617 __FUNCTION__, result); 617 __func__, result);
618 } 618 }
619} 619}
620 620
@@ -685,19 +685,19 @@ static void mos7840_bulk_in_callback(struct urb *urb)
685 return; 685 return;
686 } 686 }
687 687
688 mos7840_port = (struct moschip_port *)urb->context; 688 mos7840_port = urb->context;
689 if (!mos7840_port) { 689 if (!mos7840_port) {
690 dbg("%s", "NULL mos7840_port pointer \n"); 690 dbg("%s", "NULL mos7840_port pointer \n");
691 return; 691 return;
692 } 692 }
693 693
694 port = (struct usb_serial_port *)mos7840_port->port; 694 port = (struct usb_serial_port *)mos7840_port->port;
695 if (mos7840_port_paranoia_check(port, __FUNCTION__)) { 695 if (mos7840_port_paranoia_check(port, __func__)) {
696 dbg("%s", "Port Paranoia failed \n"); 696 dbg("%s", "Port Paranoia failed \n");
697 return; 697 return;
698 } 698 }
699 699
700 serial = mos7840_get_usb_serial(port, __FUNCTION__); 700 serial = mos7840_get_usb_serial(port, __func__);
701 if (!serial) { 701 if (!serial) {
702 dbg("%s\n", "Bad serial pointer "); 702 dbg("%s\n", "Bad serial pointer ");
703 return; 703 return;
@@ -752,7 +752,7 @@ static void mos7840_bulk_out_data_callback(struct urb *urb)
752 int status = urb->status; 752 int status = urb->status;
753 int i; 753 int i;
754 754
755 mos7840_port = (struct moschip_port *)urb->context; 755 mos7840_port = urb->context;
756 spin_lock(&mos7840_port->pool_lock); 756 spin_lock(&mos7840_port->pool_lock);
757 for (i = 0; i < NUM_URBS; i++) { 757 for (i = 0; i < NUM_URBS; i++) {
758 if (urb == mos7840_port->write_urb_pool[i]) { 758 if (urb == mos7840_port->write_urb_pool[i]) {
@@ -767,7 +767,7 @@ static void mos7840_bulk_out_data_callback(struct urb *urb)
767 return; 767 return;
768 } 768 }
769 769
770 if (mos7840_port_paranoia_check(mos7840_port->port, __FUNCTION__)) { 770 if (mos7840_port_paranoia_check(mos7840_port->port, __func__)) {
771 dbg("%s", "Port Paranoia failed \n"); 771 dbg("%s", "Port Paranoia failed \n");
772 return; 772 return;
773 } 773 }
@@ -815,14 +815,14 @@ static int mos7840_open(struct usb_serial_port *port, struct file *filp)
815 struct moschip_port *mos7840_port; 815 struct moschip_port *mos7840_port;
816 struct moschip_port *port0; 816 struct moschip_port *port0;
817 817
818 if (mos7840_port_paranoia_check(port, __FUNCTION__)) { 818 if (mos7840_port_paranoia_check(port, __func__)) {
819 dbg("%s", "Port Paranoia failed \n"); 819 dbg("%s", "Port Paranoia failed \n");
820 return -ENODEV; 820 return -ENODEV;
821 } 821 }
822 822
823 serial = port->serial; 823 serial = port->serial;
824 824
825 if (mos7840_serial_paranoia_check(serial, __FUNCTION__)) { 825 if (mos7840_serial_paranoia_check(serial, __func__)) {
826 dbg("%s", "Serial Paranoia failed \n"); 826 dbg("%s", "Serial Paranoia failed \n");
827 return -ENODEV; 827 return -ENODEV;
828 } 828 }
@@ -851,7 +851,7 @@ static int mos7840_open(struct usb_serial_port *port, struct file *filp)
851 if (!urb->transfer_buffer) { 851 if (!urb->transfer_buffer) {
852 usb_free_urb(urb); 852 usb_free_urb(urb);
853 mos7840_port->write_urb_pool[j] = NULL; 853 mos7840_port->write_urb_pool[j] = NULL;
854 err("%s-out of memory for urb buffers.", __FUNCTION__); 854 err("%s-out of memory for urb buffers.", __func__);
855 continue; 855 continue;
856 } 856 }
857 } 857 }
@@ -1039,7 +1039,7 @@ static int mos7840_open(struct usb_serial_port *port, struct file *filp)
1039 GFP_KERNEL); 1039 GFP_KERNEL);
1040 if (response) { 1040 if (response) {
1041 err("%s - Error %d submitting interrupt urb", 1041 err("%s - Error %d submitting interrupt urb",
1042 __FUNCTION__, response); 1042 __func__, response);
1043 } 1043 }
1044 1044
1045 } 1045 }
@@ -1072,7 +1072,7 @@ static int mos7840_open(struct usb_serial_port *port, struct file *filp)
1072 port->bulk_in_endpointAddress); 1072 port->bulk_in_endpointAddress);
1073 response = usb_submit_urb(mos7840_port->read_urb, GFP_KERNEL); 1073 response = usb_submit_urb(mos7840_port->read_urb, GFP_KERNEL);
1074 if (response) { 1074 if (response) {
1075 err("%s - Error %d submitting control urb", __FUNCTION__, 1075 err("%s - Error %d submitting control urb", __func__,
1076 response); 1076 response);
1077 } 1077 }
1078 1078
@@ -1116,7 +1116,7 @@ static int mos7840_chars_in_buffer(struct usb_serial_port *port)
1116 1116
1117 dbg("%s \n", " mos7840_chars_in_buffer:entering ..........."); 1117 dbg("%s \n", " mos7840_chars_in_buffer:entering ...........");
1118 1118
1119 if (mos7840_port_paranoia_check(port, __FUNCTION__)) { 1119 if (mos7840_port_paranoia_check(port, __func__)) {
1120 dbg("%s", "Invalid port \n"); 1120 dbg("%s", "Invalid port \n");
1121 return -1; 1121 return -1;
1122 } 1122 }
@@ -1134,7 +1134,7 @@ static int mos7840_chars_in_buffer(struct usb_serial_port *port)
1134 } 1134 }
1135 } 1135 }
1136 spin_unlock_irqrestore(&mos7840_port->pool_lock,flags); 1136 spin_unlock_irqrestore(&mos7840_port->pool_lock,flags);
1137 dbg("%s - returns %d", __FUNCTION__, chars); 1137 dbg("%s - returns %d", __func__, chars);
1138 return chars; 1138 return chars;
1139 1139
1140} 1140}
@@ -1171,7 +1171,7 @@ static void mos7840_block_until_tx_empty(struct moschip_port *mos7840_port)
1171 /* No activity.. count down section */ 1171 /* No activity.. count down section */
1172 wait--; 1172 wait--;
1173 if (wait == 0) { 1173 if (wait == 0) {
1174 dbg("%s - TIMEOUT", __FUNCTION__); 1174 dbg("%s - TIMEOUT", __func__);
1175 return; 1175 return;
1176 } else { 1176 } else {
1177 /* Reset timeout value back to seconds */ 1177 /* Reset timeout value back to seconds */
@@ -1195,12 +1195,12 @@ static void mos7840_close(struct usb_serial_port *port, struct file *filp)
1195 1195
1196 dbg("%s\n", "mos7840_close:entering..."); 1196 dbg("%s\n", "mos7840_close:entering...");
1197 1197
1198 if (mos7840_port_paranoia_check(port, __FUNCTION__)) { 1198 if (mos7840_port_paranoia_check(port, __func__)) {
1199 dbg("%s", "Port Paranoia failed \n"); 1199 dbg("%s", "Port Paranoia failed \n");
1200 return; 1200 return;
1201 } 1201 }
1202 1202
1203 serial = mos7840_get_usb_serial(port, __FUNCTION__); 1203 serial = mos7840_get_usb_serial(port, __func__);
1204 if (!serial) { 1204 if (!serial) {
1205 dbg("%s", "Serial Paranoia failed \n"); 1205 dbg("%s", "Serial Paranoia failed \n");
1206 return; 1206 return;
@@ -1314,7 +1314,7 @@ static void mos7840_block_until_chase_response(struct moschip_port
1314 /* No activity.. count down section */ 1314 /* No activity.. count down section */
1315 wait--; 1315 wait--;
1316 if (wait == 0) { 1316 if (wait == 0) {
1317 dbg("%s - TIMEOUT", __FUNCTION__); 1317 dbg("%s - TIMEOUT", __func__);
1318 return; 1318 return;
1319 } else { 1319 } else {
1320 /* Reset timeout value back to seconds */ 1320 /* Reset timeout value back to seconds */
@@ -1337,12 +1337,12 @@ static void mos7840_break(struct usb_serial_port *port, int break_state)
1337 dbg("%s \n", "Entering ..........."); 1337 dbg("%s \n", "Entering ...........");
1338 dbg("mos7840_break: Start\n"); 1338 dbg("mos7840_break: Start\n");
1339 1339
1340 if (mos7840_port_paranoia_check(port, __FUNCTION__)) { 1340 if (mos7840_port_paranoia_check(port, __func__)) {
1341 dbg("%s", "Port Paranoia failed \n"); 1341 dbg("%s", "Port Paranoia failed \n");
1342 return; 1342 return;
1343 } 1343 }
1344 1344
1345 serial = mos7840_get_usb_serial(port, __FUNCTION__); 1345 serial = mos7840_get_usb_serial(port, __func__);
1346 if (!serial) { 1346 if (!serial) {
1347 dbg("%s", "Serial Paranoia failed \n"); 1347 dbg("%s", "Serial Paranoia failed \n");
1348 return; 1348 return;
@@ -1392,7 +1392,7 @@ static int mos7840_write_room(struct usb_serial_port *port)
1392 1392
1393 dbg("%s \n", " mos7840_write_room:entering ..........."); 1393 dbg("%s \n", " mos7840_write_room:entering ...........");
1394 1394
1395 if (mos7840_port_paranoia_check(port, __FUNCTION__)) { 1395 if (mos7840_port_paranoia_check(port, __func__)) {
1396 dbg("%s", "Invalid port \n"); 1396 dbg("%s", "Invalid port \n");
1397 dbg("%s \n", " mos7840_write_room:leaving ..........."); 1397 dbg("%s \n", " mos7840_write_room:leaving ...........");
1398 return -1; 1398 return -1;
@@ -1413,7 +1413,7 @@ static int mos7840_write_room(struct usb_serial_port *port)
1413 spin_unlock_irqrestore(&mos7840_port->pool_lock, flags); 1413 spin_unlock_irqrestore(&mos7840_port->pool_lock, flags);
1414 1414
1415 room = (room == 0) ? 0 : room - URB_TRANSFER_BUFFER_SIZE + 1; 1415 room = (room == 0) ? 0 : room - URB_TRANSFER_BUFFER_SIZE + 1;
1416 dbg("%s - returns %d", __FUNCTION__, room); 1416 dbg("%s - returns %d", __func__, room);
1417 return room; 1417 return room;
1418 1418
1419} 1419}
@@ -1480,13 +1480,13 @@ static int mos7840_write(struct usb_serial_port *port,
1480 status = mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data); 1480 status = mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data);
1481#endif 1481#endif
1482 1482
1483 if (mos7840_port_paranoia_check(port, __FUNCTION__)) { 1483 if (mos7840_port_paranoia_check(port, __func__)) {
1484 dbg("%s", "Port Paranoia failed \n"); 1484 dbg("%s", "Port Paranoia failed \n");
1485 return -1; 1485 return -1;
1486 } 1486 }
1487 1487
1488 serial = port->serial; 1488 serial = port->serial;
1489 if (mos7840_serial_paranoia_check(serial, __FUNCTION__)) { 1489 if (mos7840_serial_paranoia_check(serial, __func__)) {
1490 dbg("%s", "Serial Paranoia failed \n"); 1490 dbg("%s", "Serial Paranoia failed \n");
1491 return -1; 1491 return -1;
1492 } 1492 }
@@ -1512,7 +1512,7 @@ static int mos7840_write(struct usb_serial_port *port,
1512 spin_unlock_irqrestore(&mos7840_port->pool_lock, flags); 1512 spin_unlock_irqrestore(&mos7840_port->pool_lock, flags);
1513 1513
1514 if (urb == NULL) { 1514 if (urb == NULL) {
1515 dbg("%s - no more free urbs", __FUNCTION__); 1515 dbg("%s - no more free urbs", __func__);
1516 goto exit; 1516 goto exit;
1517 } 1517 }
1518 1518
@@ -1521,7 +1521,7 @@ static int mos7840_write(struct usb_serial_port *port,
1521 kmalloc(URB_TRANSFER_BUFFER_SIZE, GFP_KERNEL); 1521 kmalloc(URB_TRANSFER_BUFFER_SIZE, GFP_KERNEL);
1522 1522
1523 if (urb->transfer_buffer == NULL) { 1523 if (urb->transfer_buffer == NULL) {
1524 err("%s no more kernel memory...", __FUNCTION__); 1524 err("%s no more kernel memory...", __func__);
1525 goto exit; 1525 goto exit;
1526 } 1526 }
1527 } 1527 }
@@ -1547,7 +1547,7 @@ static int mos7840_write(struct usb_serial_port *port,
1547 if (status) { 1547 if (status) {
1548 mos7840_port->busy[i] = 0; 1548 mos7840_port->busy[i] = 0;
1549 err("%s - usb_submit_urb(write bulk) failed with status = %d", 1549 err("%s - usb_submit_urb(write bulk) failed with status = %d",
1550 __FUNCTION__, status); 1550 __func__, status);
1551 bytes_sent = status; 1551 bytes_sent = status;
1552 goto exit; 1552 goto exit;
1553 } 1553 }
@@ -1573,7 +1573,7 @@ static void mos7840_throttle(struct usb_serial_port *port)
1573 struct tty_struct *tty; 1573 struct tty_struct *tty;
1574 int status; 1574 int status;
1575 1575
1576 if (mos7840_port_paranoia_check(port, __FUNCTION__)) { 1576 if (mos7840_port_paranoia_check(port, __func__)) {
1577 dbg("%s", "Invalid port \n"); 1577 dbg("%s", "Invalid port \n");
1578 return; 1578 return;
1579 } 1579 }
@@ -1594,7 +1594,7 @@ static void mos7840_throttle(struct usb_serial_port *port)
1594 1594
1595 tty = port->tty; 1595 tty = port->tty;
1596 if (!tty) { 1596 if (!tty) {
1597 dbg("%s - no tty available", __FUNCTION__); 1597 dbg("%s - no tty available", __func__);
1598 return; 1598 return;
1599 } 1599 }
1600 1600
@@ -1634,7 +1634,7 @@ static void mos7840_unthrottle(struct usb_serial_port *port)
1634 int status; 1634 int status;
1635 struct moschip_port *mos7840_port = mos7840_get_port_private(port); 1635 struct moschip_port *mos7840_port = mos7840_get_port_private(port);
1636 1636
1637 if (mos7840_port_paranoia_check(port, __FUNCTION__)) { 1637 if (mos7840_port_paranoia_check(port, __func__)) {
1638 dbg("%s", "Invalid port \n"); 1638 dbg("%s", "Invalid port \n");
1639 return; 1639 return;
1640 } 1640 }
@@ -1643,7 +1643,7 @@ static void mos7840_unthrottle(struct usb_serial_port *port)
1643 return; 1643 return;
1644 1644
1645 if (!mos7840_port->open) { 1645 if (!mos7840_port->open) {
1646 dbg("%s - port not opened", __FUNCTION__); 1646 dbg("%s - port not opened", __func__);
1647 return; 1647 return;
1648 } 1648 }
1649 1649
@@ -1651,7 +1651,7 @@ static void mos7840_unthrottle(struct usb_serial_port *port)
1651 1651
1652 tty = port->tty; 1652 tty = port->tty;
1653 if (!tty) { 1653 if (!tty) {
1654 dbg("%s - no tty available", __FUNCTION__); 1654 dbg("%s - no tty available", __func__);
1655 return; 1655 return;
1656 } 1656 }
1657 1657
@@ -1688,7 +1688,7 @@ static int mos7840_tiocmget(struct usb_serial_port *port, struct file *file)
1688 int status = 0; 1688 int status = 0;
1689 mos7840_port = mos7840_get_port_private(port); 1689 mos7840_port = mos7840_get_port_private(port);
1690 1690
1691 dbg("%s - port %d", __FUNCTION__, port->number); 1691 dbg("%s - port %d", __func__, port->number);
1692 1692
1693 if (mos7840_port == NULL) 1693 if (mos7840_port == NULL)
1694 return -ENODEV; 1694 return -ENODEV;
@@ -1703,7 +1703,7 @@ static int mos7840_tiocmget(struct usb_serial_port *port, struct file *file)
1703 | ((msr & MOS7840_MSR_RI) ? TIOCM_RI : 0) 1703 | ((msr & MOS7840_MSR_RI) ? TIOCM_RI : 0)
1704 | ((msr & MOS7840_MSR_DSR) ? TIOCM_DSR : 0); 1704 | ((msr & MOS7840_MSR_DSR) ? TIOCM_DSR : 0);
1705 1705
1706 dbg("%s - 0x%04X", __FUNCTION__, result); 1706 dbg("%s - 0x%04X", __func__, result);
1707 1707
1708 return result; 1708 return result;
1709} 1709}
@@ -1715,13 +1715,14 @@ static int mos7840_tiocmset(struct usb_serial_port *port, struct file *file,
1715 unsigned int mcr; 1715 unsigned int mcr;
1716 unsigned int status; 1716 unsigned int status;
1717 1717
1718 dbg("%s - port %d", __FUNCTION__, port->number); 1718 dbg("%s - port %d", __func__, port->number);
1719 1719
1720 mos7840_port = mos7840_get_port_private(port); 1720 mos7840_port = mos7840_get_port_private(port);
1721 1721
1722 if (mos7840_port == NULL) 1722 if (mos7840_port == NULL)
1723 return -ENODEV; 1723 return -ENODEV;
1724 1724
1725 /* FIXME: What locks the port registers ? */
1725 mcr = mos7840_port->shadowMCR; 1726 mcr = mos7840_port->shadowMCR;
1726 if (clear & TIOCM_RTS) 1727 if (clear & TIOCM_RTS)
1727 mcr &= ~MCR_RTS; 1728 mcr &= ~MCR_RTS;
@@ -1758,7 +1759,7 @@ static int mos7840_calc_baud_rate_divisor(int baudRate, int *divisor,
1758 __u16 * clk_sel_val) 1759 __u16 * clk_sel_val)
1759{ 1760{
1760 1761
1761 dbg("%s - %d", __FUNCTION__, baudRate); 1762 dbg("%s - %d", __func__, baudRate);
1762 1763
1763 if (baudRate <= 115200) { 1764 if (baudRate <= 115200) {
1764 *divisor = 115200 / baudRate; 1765 *divisor = 115200 / baudRate;
@@ -1841,12 +1842,12 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port,
1841 return -1; 1842 return -1;
1842 1843
1843 port = (struct usb_serial_port *)mos7840_port->port; 1844 port = (struct usb_serial_port *)mos7840_port->port;
1844 if (mos7840_port_paranoia_check(port, __FUNCTION__)) { 1845 if (mos7840_port_paranoia_check(port, __func__)) {
1845 dbg("%s", "Invalid port \n"); 1846 dbg("%s", "Invalid port \n");
1846 return -1; 1847 return -1;
1847 } 1848 }
1848 1849
1849 if (mos7840_serial_paranoia_check(port->serial, __FUNCTION__)) { 1850 if (mos7840_serial_paranoia_check(port->serial, __func__)) {
1850 dbg("%s", "Invalid Serial \n"); 1851 dbg("%s", "Invalid Serial \n");
1851 return -1; 1852 return -1;
1852 } 1853 }
@@ -1855,7 +1856,7 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port,
1855 1856
1856 number = mos7840_port->port->number - mos7840_port->port->serial->minor; 1857 number = mos7840_port->port->number - mos7840_port->port->serial->minor;
1857 1858
1858 dbg("%s - port = %d, baud = %d", __FUNCTION__, 1859 dbg("%s - port = %d, baud = %d", __func__,
1859 mos7840_port->port->number, baudRate); 1860 mos7840_port->port->number, baudRate);
1860 //reset clk_uart_sel in spregOffset 1861 //reset clk_uart_sel in spregOffset
1861 if (baudRate > 115200) { 1862 if (baudRate > 115200) {
@@ -1915,7 +1916,7 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port,
1915 /* Calculate the Divisor */ 1916 /* Calculate the Divisor */
1916 1917
1917 if (status) { 1918 if (status) {
1918 err("%s - bad baud rate", __FUNCTION__); 1919 err("%s - bad baud rate", __func__);
1919 dbg("%s\n", "bad baud rate"); 1920 dbg("%s\n", "bad baud rate");
1920 return status; 1921 return status;
1921 } 1922 }
@@ -1969,22 +1970,22 @@ static void mos7840_change_port_settings(struct moschip_port *mos7840_port,
1969 1970
1970 port = (struct usb_serial_port *)mos7840_port->port; 1971 port = (struct usb_serial_port *)mos7840_port->port;
1971 1972
1972 if (mos7840_port_paranoia_check(port, __FUNCTION__)) { 1973 if (mos7840_port_paranoia_check(port, __func__)) {
1973 dbg("%s", "Invalid port \n"); 1974 dbg("%s", "Invalid port \n");
1974 return; 1975 return;
1975 } 1976 }
1976 1977
1977 if (mos7840_serial_paranoia_check(port->serial, __FUNCTION__)) { 1978 if (mos7840_serial_paranoia_check(port->serial, __func__)) {
1978 dbg("%s", "Invalid Serial \n"); 1979 dbg("%s", "Invalid Serial \n");
1979 return; 1980 return;
1980 } 1981 }
1981 1982
1982 serial = port->serial; 1983 serial = port->serial;
1983 1984
1984 dbg("%s - port %d", __FUNCTION__, mos7840_port->port->number); 1985 dbg("%s - port %d", __func__, mos7840_port->port->number);
1985 1986
1986 if (!mos7840_port->open) { 1987 if (!mos7840_port->open) {
1987 dbg("%s - port not opened", __FUNCTION__); 1988 dbg("%s - port not opened", __func__);
1988 return; 1989 return;
1989 } 1990 }
1990 1991
@@ -2023,14 +2024,14 @@ static void mos7840_change_port_settings(struct moschip_port *mos7840_port,
2023 if (cflag & PARENB) { 2024 if (cflag & PARENB) {
2024 if (cflag & PARODD) { 2025 if (cflag & PARODD) {
2025 lParity = LCR_PAR_ODD; 2026 lParity = LCR_PAR_ODD;
2026 dbg("%s - parity = odd", __FUNCTION__); 2027 dbg("%s - parity = odd", __func__);
2027 } else { 2028 } else {
2028 lParity = LCR_PAR_EVEN; 2029 lParity = LCR_PAR_EVEN;
2029 dbg("%s - parity = even", __FUNCTION__); 2030 dbg("%s - parity = even", __func__);
2030 } 2031 }
2031 2032
2032 } else { 2033 } else {
2033 dbg("%s - parity = none", __FUNCTION__); 2034 dbg("%s - parity = none", __func__);
2034 } 2035 }
2035 2036
2036 if (cflag & CMSPAR) { 2037 if (cflag & CMSPAR) {
@@ -2040,10 +2041,10 @@ static void mos7840_change_port_settings(struct moschip_port *mos7840_port,
2040 /* Change the Stop bit */ 2041 /* Change the Stop bit */
2041 if (cflag & CSTOPB) { 2042 if (cflag & CSTOPB) {
2042 lStop = LCR_STOP_2; 2043 lStop = LCR_STOP_2;
2043 dbg("%s - stop bits = 2", __FUNCTION__); 2044 dbg("%s - stop bits = 2", __func__);
2044 } else { 2045 } else {
2045 lStop = LCR_STOP_1; 2046 lStop = LCR_STOP_1;
2046 dbg("%s - stop bits = 1", __FUNCTION__); 2047 dbg("%s - stop bits = 1", __func__);
2047 } 2048 }
2048 2049
2049 /* Update the LCR with the correct value */ 2050 /* Update the LCR with the correct value */
@@ -2100,7 +2101,7 @@ static void mos7840_change_port_settings(struct moschip_port *mos7840_port,
2100 baud = 9600; 2101 baud = 9600;
2101 } 2102 }
2102 2103
2103 dbg("%s - baud rate = %d", __FUNCTION__, baud); 2104 dbg("%s - baud rate = %d", __func__, baud);
2104 status = mos7840_send_cmd_write_baud_rate(mos7840_port, baud); 2105 status = mos7840_send_cmd_write_baud_rate(mos7840_port, baud);
2105 2106
2106 /* Enable Interrupts */ 2107 /* Enable Interrupts */
@@ -2140,14 +2141,14 @@ static void mos7840_set_termios(struct usb_serial_port *port,
2140 struct moschip_port *mos7840_port; 2141 struct moschip_port *mos7840_port;
2141 struct tty_struct *tty; 2142 struct tty_struct *tty;
2142 dbg("mos7840_set_termios: START\n"); 2143 dbg("mos7840_set_termios: START\n");
2143 if (mos7840_port_paranoia_check(port, __FUNCTION__)) { 2144 if (mos7840_port_paranoia_check(port, __func__)) {
2144 dbg("%s", "Invalid port \n"); 2145 dbg("%s", "Invalid port \n");
2145 return; 2146 return;
2146 } 2147 }
2147 2148
2148 serial = port->serial; 2149 serial = port->serial;
2149 2150
2150 if (mos7840_serial_paranoia_check(serial, __FUNCTION__)) { 2151 if (mos7840_serial_paranoia_check(serial, __func__)) {
2151 dbg("%s", "Invalid Serial \n"); 2152 dbg("%s", "Invalid Serial \n");
2152 return; 2153 return;
2153 } 2154 }
@@ -2160,7 +2161,7 @@ static void mos7840_set_termios(struct usb_serial_port *port,
2160 tty = port->tty; 2161 tty = port->tty;
2161 2162
2162 if (!mos7840_port->open) { 2163 if (!mos7840_port->open) {
2163 dbg("%s - port not opened", __FUNCTION__); 2164 dbg("%s - port not opened", __func__);
2164 return; 2165 return;
2165 } 2166 }
2166 2167
@@ -2168,11 +2169,11 @@ static void mos7840_set_termios(struct usb_serial_port *port,
2168 2169
2169 cflag = tty->termios->c_cflag; 2170 cflag = tty->termios->c_cflag;
2170 2171
2171 dbg("%s - clfag %08x iflag %08x", __FUNCTION__, 2172 dbg("%s - clfag %08x iflag %08x", __func__,
2172 tty->termios->c_cflag, RELEVANT_IFLAG(tty->termios->c_iflag)); 2173 tty->termios->c_cflag, RELEVANT_IFLAG(tty->termios->c_iflag));
2173 dbg("%s - old clfag %08x old iflag %08x", __FUNCTION__, 2174 dbg("%s - old clfag %08x old iflag %08x", __func__,
2174 old_termios->c_cflag, RELEVANT_IFLAG(old_termios->c_iflag)); 2175 old_termios->c_cflag, RELEVANT_IFLAG(old_termios->c_iflag));
2175 dbg("%s - port %d", __FUNCTION__, port->number); 2176 dbg("%s - port %d", __func__, port->number);
2176 2177
2177 /* change the port settings to the new ones specified */ 2178 /* change the port settings to the new ones specified */
2178 2179
@@ -2213,7 +2214,7 @@ static int mos7840_get_lsr_info(struct moschip_port *mos7840_port,
2213 2214
2214 count = mos7840_chars_in_buffer(mos7840_port->port); 2215 count = mos7840_chars_in_buffer(mos7840_port->port);
2215 if (count == 0) { 2216 if (count == 0) {
2216 dbg("%s -- Empty", __FUNCTION__); 2217 dbg("%s -- Empty", __func__);
2217 result = TIOCSER_TEMT; 2218 result = TIOCSER_TEMT;
2218 } 2219 }
2219 2220
@@ -2240,7 +2241,7 @@ static int mos7840_set_modem_info(struct moschip_port *mos7840_port,
2240 return -1; 2241 return -1;
2241 2242
2242 port = (struct usb_serial_port *)mos7840_port->port; 2243 port = (struct usb_serial_port *)mos7840_port->port;
2243 if (mos7840_port_paranoia_check(port, __FUNCTION__)) { 2244 if (mos7840_port_paranoia_check(port, __func__)) {
2244 dbg("%s", "Invalid port \n"); 2245 dbg("%s", "Invalid port \n");
2245 return -1; 2246 return -1;
2246 } 2247 }
@@ -2314,7 +2315,7 @@ static int mos7840_get_modem_info(struct moschip_port *mos7840_port,
2314 |((msr & MOS7840_MSR_RI) ? TIOCM_RI : 0) /* 0x080 */ 2315 |((msr & MOS7840_MSR_RI) ? TIOCM_RI : 0) /* 0x080 */
2315 |((msr & MOS7840_MSR_DSR) ? TIOCM_DSR : 0); /* 0x100 */ 2316 |((msr & MOS7840_MSR_DSR) ? TIOCM_DSR : 0); /* 0x100 */
2316 2317
2317 dbg("%s -- %x", __FUNCTION__, result); 2318 dbg("%s -- %x", __func__, result);
2318 2319
2319 if (copy_to_user(value, &result, sizeof(int))) 2320 if (copy_to_user(value, &result, sizeof(int)))
2320 return -EFAULT; 2321 return -EFAULT;
@@ -2371,7 +2372,7 @@ static int mos7840_ioctl(struct usb_serial_port *port, struct file *file,
2371 struct serial_icounter_struct icount; 2372 struct serial_icounter_struct icount;
2372 int mosret = 0; 2373 int mosret = 0;
2373 2374
2374 if (mos7840_port_paranoia_check(port, __FUNCTION__)) { 2375 if (mos7840_port_paranoia_check(port, __func__)) {
2375 dbg("%s", "Invalid port \n"); 2376 dbg("%s", "Invalid port \n");
2376 return -1; 2377 return -1;
2377 } 2378 }
@@ -2383,39 +2384,39 @@ static int mos7840_ioctl(struct usb_serial_port *port, struct file *file,
2383 2384
2384 tty = mos7840_port->port->tty; 2385 tty = mos7840_port->port->tty;
2385 2386
2386 dbg("%s - port %d, cmd = 0x%x", __FUNCTION__, port->number, cmd); 2387 dbg("%s - port %d, cmd = 0x%x", __func__, port->number, cmd);
2387 2388
2388 switch (cmd) { 2389 switch (cmd) {
2389 /* return number of bytes available */ 2390 /* return number of bytes available */
2390 2391
2391 case TIOCSERGETLSR: 2392 case TIOCSERGETLSR:
2392 dbg("%s (%d) TIOCSERGETLSR", __FUNCTION__, port->number); 2393 dbg("%s (%d) TIOCSERGETLSR", __func__, port->number);
2393 return mos7840_get_lsr_info(mos7840_port, argp); 2394 return mos7840_get_lsr_info(mos7840_port, argp);
2394 return 0; 2395 return 0;
2395 2396
2396 case TIOCMBIS: 2397 case TIOCMBIS:
2397 case TIOCMBIC: 2398 case TIOCMBIC:
2398 case TIOCMSET: 2399 case TIOCMSET:
2399 dbg("%s (%d) TIOCMSET/TIOCMBIC/TIOCMSET", __FUNCTION__, 2400 dbg("%s (%d) TIOCMSET/TIOCMBIC/TIOCMSET", __func__,
2400 port->number); 2401 port->number);
2401 mosret = 2402 mosret =
2402 mos7840_set_modem_info(mos7840_port, cmd, argp); 2403 mos7840_set_modem_info(mos7840_port, cmd, argp);
2403 return mosret; 2404 return mosret;
2404 2405
2405 case TIOCMGET: 2406 case TIOCMGET:
2406 dbg("%s (%d) TIOCMGET", __FUNCTION__, port->number); 2407 dbg("%s (%d) TIOCMGET", __func__, port->number);
2407 return mos7840_get_modem_info(mos7840_port, argp); 2408 return mos7840_get_modem_info(mos7840_port, argp);
2408 2409
2409 case TIOCGSERIAL: 2410 case TIOCGSERIAL:
2410 dbg("%s (%d) TIOCGSERIAL", __FUNCTION__, port->number); 2411 dbg("%s (%d) TIOCGSERIAL", __func__, port->number);
2411 return mos7840_get_serial_info(mos7840_port, argp); 2412 return mos7840_get_serial_info(mos7840_port, argp);
2412 2413
2413 case TIOCSSERIAL: 2414 case TIOCSSERIAL:
2414 dbg("%s (%d) TIOCSSERIAL", __FUNCTION__, port->number); 2415 dbg("%s (%d) TIOCSSERIAL", __func__, port->number);
2415 break; 2416 break;
2416 2417
2417 case TIOCMIWAIT: 2418 case TIOCMIWAIT:
2418 dbg("%s (%d) TIOCMIWAIT", __FUNCTION__, port->number); 2419 dbg("%s (%d) TIOCMIWAIT", __func__, port->number);
2419 cprev = mos7840_port->icount; 2420 cprev = mos7840_port->icount;
2420 while (1) { 2421 while (1) {
2421 //interruptible_sleep_on(&mos7840_port->delta_msr_wait); 2422 //interruptible_sleep_on(&mos7840_port->delta_msr_wait);
@@ -2458,7 +2459,7 @@ static int mos7840_ioctl(struct usb_serial_port *port, struct file *file,
2458 icount.brk = cnow.brk; 2459 icount.brk = cnow.brk;
2459 icount.buf_overrun = cnow.buf_overrun; 2460 icount.buf_overrun = cnow.buf_overrun;
2460 2461
2461 dbg("%s (%d) TIOCGICOUNT RX=%d, TX=%d", __FUNCTION__, 2462 dbg("%s (%d) TIOCGICOUNT RX=%d, TX=%d", __func__,
2462 port->number, icount.rx, icount.tx); 2463 port->number, icount.rx, icount.tx);
2463 if (copy_to_user(argp, &icount, sizeof(icount))) 2464 if (copy_to_user(argp, &icount, sizeof(icount)))
2464 return -EFAULT; 2465 return -EFAULT;
@@ -2521,7 +2522,7 @@ static int mos7840_startup(struct usb_serial *serial)
2521 for (i = 0; i < serial->num_ports; ++i) { 2522 for (i = 0; i < serial->num_ports; ++i) {
2522 mos7840_port = kzalloc(sizeof(struct moschip_port), GFP_KERNEL); 2523 mos7840_port = kzalloc(sizeof(struct moschip_port), GFP_KERNEL);
2523 if (mos7840_port == NULL) { 2524 if (mos7840_port == NULL) {
2524 err("%s - Out of memory", __FUNCTION__); 2525 err("%s - Out of memory", __func__);
2525 status = -ENOMEM; 2526 status = -ENOMEM;
2526 i--; /* don't follow NULL pointer cleaning up */ 2527 i--; /* don't follow NULL pointer cleaning up */
2527 goto error; 2528 goto error;
@@ -2799,12 +2800,7 @@ static struct usb_serial_driver moschip7840_4port_device = {
2799 .description = DRIVER_DESC, 2800 .description = DRIVER_DESC,
2800 .usb_driver = &io_driver, 2801 .usb_driver = &io_driver,
2801 .id_table = moschip_port_id_table, 2802 .id_table = moschip_port_id_table,
2802 .num_interrupt_in = 1, //NUM_DONT_CARE,//1,
2803#ifdef check
2804 .num_bulk_in = 4,
2805 .num_bulk_out = 4,
2806 .num_ports = 4, 2803 .num_ports = 4,
2807#endif
2808 .open = mos7840_open, 2804 .open = mos7840_open,
2809 .close = mos7840_close, 2805 .close = mos7840_close,
2810 .write = mos7840_write, 2806 .write = mos7840_write,
diff --git a/drivers/usb/serial/navman.c b/drivers/usb/serial/navman.c
index 7f337c9aeb5..43c8894353b 100644
--- a/drivers/usb/serial/navman.c
+++ b/drivers/usb/serial/navman.c
@@ -6,6 +6,10 @@
6 * This program is free software; you can redistribute it and/or 6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License 7 * modify it under the terms of the GNU General Public License
8 * version 2 as published by the Free Software Foundation. 8 * version 2 as published by the Free Software Foundation.
9 *
10 * TODO:
11 * Add termios method that uses copy_hw but also kills all echo
12 * flags as the navman is rx only so cannot echo.
9 */ 13 */
10 14
11#include <linux/kernel.h> 15#include <linux/kernel.h>
@@ -49,15 +53,15 @@ static void navman_read_int_callback(struct urb *urb)
49 case -ESHUTDOWN: 53 case -ESHUTDOWN:
50 /* this urb is terminated, clean up */ 54 /* this urb is terminated, clean up */
51 dbg("%s - urb shutting down with status: %d", 55 dbg("%s - urb shutting down with status: %d",
52 __FUNCTION__, status); 56 __func__, status);
53 return; 57 return;
54 default: 58 default:
55 dbg("%s - nonzero urb status received: %d", 59 dbg("%s - nonzero urb status received: %d",
56 __FUNCTION__, status); 60 __func__, status);
57 goto exit; 61 goto exit;
58 } 62 }
59 63
60 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, 64 usb_serial_debug_data(debug, &port->dev, __func__,
61 urb->actual_length, data); 65 urb->actual_length, data);
62 66
63 tty = port->tty; 67 tty = port->tty;
@@ -72,29 +76,29 @@ exit:
72 if (result) 76 if (result)
73 dev_err(&urb->dev->dev, 77 dev_err(&urb->dev->dev,
74 "%s - Error %d submitting interrupt urb\n", 78 "%s - Error %d submitting interrupt urb\n",
75 __FUNCTION__, result); 79 __func__, result);
76} 80}
77 81
78static int navman_open(struct usb_serial_port *port, struct file *filp) 82static int navman_open(struct usb_serial_port *port, struct file *filp)
79{ 83{
80 int result = 0; 84 int result = 0;
81 85
82 dbg("%s - port %d", __FUNCTION__, port->number); 86 dbg("%s - port %d", __func__, port->number);
83 87
84 if (port->interrupt_in_urb) { 88 if (port->interrupt_in_urb) {
85 dbg("%s - adding interrupt input for treo", __FUNCTION__); 89 dbg("%s - adding interrupt input for treo", __func__);
86 result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); 90 result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
87 if (result) 91 if (result)
88 dev_err(&port->dev, 92 dev_err(&port->dev,
89 "%s - failed submitting interrupt urb, error %d\n", 93 "%s - failed submitting interrupt urb, error %d\n",
90 __FUNCTION__, result); 94 __func__, result);
91 } 95 }
92 return result; 96 return result;
93} 97}
94 98
95static void navman_close(struct usb_serial_port *port, struct file *filp) 99static void navman_close(struct usb_serial_port *port, struct file *filp)
96{ 100{
97 dbg("%s - port %d", __FUNCTION__, port->number); 101 dbg("%s - port %d", __func__, port->number);
98 102
99 usb_kill_urb(port->interrupt_in_urb); 103 usb_kill_urb(port->interrupt_in_urb);
100} 104}
@@ -102,16 +106,12 @@ static void navman_close(struct usb_serial_port *port, struct file *filp)
102static int navman_write(struct usb_serial_port *port, 106static int navman_write(struct usb_serial_port *port,
103 const unsigned char *buf, int count) 107 const unsigned char *buf, int count)
104{ 108{
105 dbg("%s - port %d", __FUNCTION__, port->number); 109 dbg("%s - port %d", __func__, port->number);
106 110
107 /* 111 /*
108 * This device can't write any data, only read from the device 112 * This device can't write any data, only read from the device
109 * so we just silently eat all data sent to us and say it was
110 * successfully sent.
111 * Evil, I know, but do you have a better idea?
112 */ 113 */
113 114 return -EOPNOTSUPP;
114 return count;
115} 115}
116 116
117static struct usb_serial_driver navman_device = { 117static struct usb_serial_driver navman_device = {
@@ -121,9 +121,6 @@ static struct usb_serial_driver navman_device = {
121 }, 121 },
122 .id_table = id_table, 122 .id_table = id_table,
123 .usb_driver = &navman_driver, 123 .usb_driver = &navman_driver,
124 .num_interrupt_in = NUM_DONT_CARE,
125 .num_bulk_in = NUM_DONT_CARE,
126 .num_bulk_out = NUM_DONT_CARE,
127 .num_ports = 1, 124 .num_ports = 1,
128 .open = navman_open, 125 .open = navman_open,
129 .close = navman_close, 126 .close = navman_close,
diff --git a/drivers/usb/serial/omninet.c b/drivers/usb/serial/omninet.c
index ee94d9616d8..7b7422f4947 100644
--- a/drivers/usb/serial/omninet.c
+++ b/drivers/usb/serial/omninet.c
@@ -95,9 +95,6 @@ static struct usb_serial_driver zyxel_omninet_device = {
95 .description = "ZyXEL - omni.net lcd plus usb", 95 .description = "ZyXEL - omni.net lcd plus usb",
96 .usb_driver = &omninet_driver, 96 .usb_driver = &omninet_driver,
97 .id_table = id_table, 97 .id_table = id_table,
98 .num_interrupt_in = 1,
99 .num_bulk_in = 1,
100 .num_bulk_out = 2,
101 .num_ports = 1, 98 .num_ports = 1,
102 .attach = omninet_attach, 99 .attach = omninet_attach,
103 .open = omninet_open, 100 .open = omninet_open,
@@ -153,7 +150,7 @@ static int omninet_attach (struct usb_serial *serial)
153 150
154 od = kmalloc( sizeof(struct omninet_data), GFP_KERNEL ); 151 od = kmalloc( sizeof(struct omninet_data), GFP_KERNEL );
155 if( !od ) { 152 if( !od ) {
156 err("%s- kmalloc(%Zd) failed.", __FUNCTION__, sizeof(struct omninet_data)); 153 err("%s- kmalloc(%Zd) failed.", __func__, sizeof(struct omninet_data));
157 return -ENOMEM; 154 return -ENOMEM;
158 } 155 }
159 usb_set_serial_port_data(port, od); 156 usb_set_serial_port_data(port, od);
@@ -166,7 +163,7 @@ static int omninet_open (struct usb_serial_port *port, struct file *filp)
166 struct usb_serial_port *wport; 163 struct usb_serial_port *wport;
167 int result = 0; 164 int result = 0;
168 165
169 dbg("%s - port %d", __FUNCTION__, port->number); 166 dbg("%s - port %d", __func__, port->number);
170 167
171 wport = serial->port[1]; 168 wport = serial->port[1];
172 wport->tty = port->tty; 169 wport->tty = port->tty;
@@ -178,7 +175,7 @@ static int omninet_open (struct usb_serial_port *port, struct file *filp)
178 omninet_read_bulk_callback, port); 175 omninet_read_bulk_callback, port);
179 result = usb_submit_urb(port->read_urb, GFP_KERNEL); 176 result = usb_submit_urb(port->read_urb, GFP_KERNEL);
180 if (result) { 177 if (result) {
181 err("%s - failed submitting read urb, error %d", __FUNCTION__, result); 178 err("%s - failed submitting read urb, error %d", __func__, result);
182 } 179 }
183 180
184 return result; 181 return result;
@@ -186,7 +183,7 @@ static int omninet_open (struct usb_serial_port *port, struct file *filp)
186 183
187static void omninet_close (struct usb_serial_port *port, struct file * filp) 184static void omninet_close (struct usb_serial_port *port, struct file * filp)
188{ 185{
189 dbg("%s - port %d", __FUNCTION__, port->number); 186 dbg("%s - port %d", __func__, port->number);
190 usb_kill_urb(port->read_urb); 187 usb_kill_urb(port->read_urb);
191} 188}
192 189
@@ -197,18 +194,18 @@ static void omninet_close (struct usb_serial_port *port, struct file * filp)
197 194
198static void omninet_read_bulk_callback (struct urb *urb) 195static void omninet_read_bulk_callback (struct urb *urb)
199{ 196{
200 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 197 struct usb_serial_port *port = urb->context;
201 unsigned char *data = urb->transfer_buffer; 198 unsigned char *data = urb->transfer_buffer;
202 struct omninet_header *header = (struct omninet_header *) &data[0]; 199 struct omninet_header *header = (struct omninet_header *) &data[0];
203 int status = urb->status; 200 int status = urb->status;
204 int i; 201 int i;
205 int result; 202 int result;
206 203
207 dbg("%s - port %d", __FUNCTION__, port->number); 204 dbg("%s - port %d", __func__, port->number);
208 205
209 if (status) { 206 if (status) {
210 dbg("%s - nonzero read bulk status received: %d", 207 dbg("%s - nonzero read bulk status received: %d",
211 __FUNCTION__, status); 208 __func__, status);
212 return; 209 return;
213 } 210 }
214 211
@@ -236,7 +233,7 @@ static void omninet_read_bulk_callback (struct urb *urb)
236 omninet_read_bulk_callback, port); 233 omninet_read_bulk_callback, port);
237 result = usb_submit_urb(urb, GFP_ATOMIC); 234 result = usb_submit_urb(urb, GFP_ATOMIC);
238 if (result) 235 if (result)
239 err("%s - failed resubmitting read urb, error %d", __FUNCTION__, result); 236 err("%s - failed resubmitting read urb, error %d", __func__, result);
240 237
241 return; 238 return;
242} 239}
@@ -251,17 +248,17 @@ static int omninet_write (struct usb_serial_port *port, const unsigned char *buf
251 248
252 int result; 249 int result;
253 250
254 dbg("%s - port %d", __FUNCTION__, port->number); 251 dbg("%s - port %d", __func__, port->number);
255 252
256 if (count == 0) { 253 if (count == 0) {
257 dbg("%s - write request of 0 bytes", __FUNCTION__); 254 dbg("%s - write request of 0 bytes", __func__);
258 return (0); 255 return (0);
259 } 256 }
260 257
261 spin_lock_bh(&wport->lock); 258 spin_lock_bh(&wport->lock);
262 if (wport->write_urb_busy) { 259 if (wport->write_urb_busy) {
263 spin_unlock_bh(&wport->lock); 260 spin_unlock_bh(&wport->lock);
264 dbg("%s - already writing", __FUNCTION__); 261 dbg("%s - already writing", __func__);
265 return 0; 262 return 0;
266 } 263 }
267 wport->write_urb_busy = 1; 264 wport->write_urb_busy = 1;
@@ -271,7 +268,7 @@ static int omninet_write (struct usb_serial_port *port, const unsigned char *buf
271 268
272 memcpy (wport->write_urb->transfer_buffer + OMNINET_DATAOFFSET, buf, count); 269 memcpy (wport->write_urb->transfer_buffer + OMNINET_DATAOFFSET, buf, count);
273 270
274 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count, wport->write_urb->transfer_buffer); 271 usb_serial_debug_data(debug, &port->dev, __func__, count, wport->write_urb->transfer_buffer);
275 272
276 header->oh_seq = od->od_outseq++; 273 header->oh_seq = od->od_outseq++;
277 header->oh_len = count; 274 header->oh_len = count;
@@ -285,7 +282,7 @@ static int omninet_write (struct usb_serial_port *port, const unsigned char *buf
285 result = usb_submit_urb(wport->write_urb, GFP_ATOMIC); 282 result = usb_submit_urb(wport->write_urb, GFP_ATOMIC);
286 if (result) { 283 if (result) {
287 wport->write_urb_busy = 0; 284 wport->write_urb_busy = 0;
288 err("%s - failed submitting write urb, error %d", __FUNCTION__, result); 285 err("%s - failed submitting write urb, error %d", __func__, result);
289 } else 286 } else
290 result = count; 287 result = count;
291 288
@@ -298,12 +295,13 @@ static int omninet_write_room (struct usb_serial_port *port)
298 struct usb_serial *serial = port->serial; 295 struct usb_serial *serial = port->serial;
299 struct usb_serial_port *wport = serial->port[1]; 296 struct usb_serial_port *wport = serial->port[1];
300 297
301 int room = 0; // Default: no room 298 int room = 0; /* Default: no room */
302 299
300 /* FIXME: no consistent locking for write_urb_busy */
303 if (wport->write_urb_busy) 301 if (wport->write_urb_busy)
304 room = wport->bulk_out_size - OMNINET_HEADERLEN; 302 room = wport->bulk_out_size - OMNINET_HEADERLEN;
305 303
306 dbg("%s - returns %d", __FUNCTION__, room); 304 dbg("%s - returns %d", __func__, room);
307 305
308 return (room); 306 return (room);
309} 307}
@@ -311,15 +309,15 @@ static int omninet_write_room (struct usb_serial_port *port)
311static void omninet_write_bulk_callback (struct urb *urb) 309static void omninet_write_bulk_callback (struct urb *urb)
312{ 310{
313/* struct omninet_header *header = (struct omninet_header *) urb->transfer_buffer; */ 311/* struct omninet_header *header = (struct omninet_header *) urb->transfer_buffer; */
314 struct usb_serial_port *port = (struct usb_serial_port *) urb->context; 312 struct usb_serial_port *port = urb->context;
315 int status = urb->status; 313 int status = urb->status;
316 314
317 dbg("%s - port %0x\n", __FUNCTION__, port->number); 315 dbg("%s - port %0x\n", __func__, port->number);
318 316
319 port->write_urb_busy = 0; 317 port->write_urb_busy = 0;
320 if (status) { 318 if (status) {
321 dbg("%s - nonzero write bulk status received: %d", 319 dbg("%s - nonzero write bulk status received: %d",
322 __FUNCTION__, status); 320 __func__, status);
323 return; 321 return;
324 } 322 }
325 323
@@ -331,7 +329,7 @@ static void omninet_shutdown (struct usb_serial *serial)
331{ 329{
332 struct usb_serial_port *wport = serial->port[1]; 330 struct usb_serial_port *wport = serial->port[1];
333 struct usb_serial_port *port = serial->port[0]; 331 struct usb_serial_port *port = serial->port[0];
334 dbg ("%s", __FUNCTION__); 332 dbg ("%s", __func__);
335 333
336 usb_kill_urb(wport->write_urb); 334 usb_kill_urb(wport->write_urb);
337 kfree(usb_get_serial_port_data(port)); 335 kfree(usb_get_serial_port_data(port));
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index d101025a4c6..e4be2d442b1 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -28,7 +28,7 @@
28 device features. 28 device features.
29*/ 29*/
30 30
31#define DRIVER_VERSION "v0.7.1" 31#define DRIVER_VERSION "v0.7.2"
32#define DRIVER_AUTHOR "Matthias Urlichs <smurf@smurf.noris.de>" 32#define DRIVER_AUTHOR "Matthias Urlichs <smurf@smurf.noris.de>"
33#define DRIVER_DESC "USB Driver for GSM modems" 33#define DRIVER_DESC "USB Driver for GSM modems"
34 34
@@ -325,9 +325,6 @@ static struct usb_serial_driver option_1port_device = {
325 .description = "GSM modem (1-port)", 325 .description = "GSM modem (1-port)",
326 .usb_driver = &option_driver, 326 .usb_driver = &option_driver,
327 .id_table = option_ids, 327 .id_table = option_ids,
328 .num_interrupt_in = NUM_DONT_CARE,
329 .num_bulk_in = NUM_DONT_CARE,
330 .num_bulk_out = NUM_DONT_CARE,
331 .num_ports = 1, 328 .num_ports = 1,
332 .open = option_open, 329 .open = option_open,
333 .close = option_close, 330 .close = option_close,
@@ -411,24 +408,24 @@ module_exit(option_exit);
411 408
412static void option_rx_throttle(struct usb_serial_port *port) 409static void option_rx_throttle(struct usb_serial_port *port)
413{ 410{
414 dbg("%s", __FUNCTION__); 411 dbg("%s", __func__);
415} 412}
416 413
417static void option_rx_unthrottle(struct usb_serial_port *port) 414static void option_rx_unthrottle(struct usb_serial_port *port)
418{ 415{
419 dbg("%s", __FUNCTION__); 416 dbg("%s", __func__);
420} 417}
421 418
422static void option_break_ctl(struct usb_serial_port *port, int break_state) 419static void option_break_ctl(struct usb_serial_port *port, int break_state)
423{ 420{
424 /* Unfortunately, I don't know how to send a break */ 421 /* Unfortunately, I don't know how to send a break */
425 dbg("%s", __FUNCTION__); 422 dbg("%s", __func__);
426} 423}
427 424
428static void option_set_termios(struct usb_serial_port *port, 425static void option_set_termios(struct usb_serial_port *port,
429 struct ktermios *old_termios) 426 struct ktermios *old_termios)
430{ 427{
431 dbg("%s", __FUNCTION__); 428 dbg("%s", __func__);
432 /* Doesn't support option setting */ 429 /* Doesn't support option setting */
433 tty_termios_copy_hw(port->tty->termios, old_termios); 430 tty_termios_copy_hw(port->tty->termios, old_termios);
434 option_send_setup(port); 431 option_send_setup(port);
@@ -458,6 +455,7 @@ static int option_tiocmset(struct usb_serial_port *port, struct file *file,
458 455
459 portdata = usb_get_serial_port_data(port); 456 portdata = usb_get_serial_port_data(port);
460 457
458 /* FIXME: what locks portdata fields ? */
461 if (set & TIOCM_RTS) 459 if (set & TIOCM_RTS)
462 portdata->rts_state = 1; 460 portdata->rts_state = 1;
463 if (set & TIOCM_DTR) 461 if (set & TIOCM_DTR)
@@ -488,7 +486,7 @@ static int option_write(struct usb_serial_port *port,
488 486
489 portdata = usb_get_serial_port_data(port); 487 portdata = usb_get_serial_port_data(port);
490 488
491 dbg("%s: write (%d chars)", __FUNCTION__, count); 489 dbg("%s: write (%d chars)", __func__, count);
492 490
493 i = 0; 491 i = 0;
494 left = count; 492 left = count;
@@ -509,7 +507,7 @@ static int option_write(struct usb_serial_port *port,
509 dbg("usb_write %p failed (err=%d)", 507 dbg("usb_write %p failed (err=%d)",
510 this_urb, this_urb->status); 508 this_urb, this_urb->status);
511 509
512 dbg("%s: endpoint %d buf %d", __FUNCTION__, 510 dbg("%s: endpoint %d buf %d", __func__,
513 usb_pipeendpoint(this_urb->pipe), i); 511 usb_pipeendpoint(this_urb->pipe), i);
514 512
515 /* send the data */ 513 /* send the data */
@@ -531,7 +529,7 @@ static int option_write(struct usb_serial_port *port,
531 } 529 }
532 530
533 count -= left; 531 count -= left;
534 dbg("%s: wrote (did %d)", __FUNCTION__, count); 532 dbg("%s: wrote (did %d)", __func__, count);
535 return count; 533 return count;
536} 534}
537 535
@@ -544,14 +542,14 @@ static void option_indat_callback(struct urb *urb)
544 unsigned char *data = urb->transfer_buffer; 542 unsigned char *data = urb->transfer_buffer;
545 int status = urb->status; 543 int status = urb->status;
546 544
547 dbg("%s: %p", __FUNCTION__, urb); 545 dbg("%s: %p", __func__, urb);
548 546
549 endpoint = usb_pipeendpoint(urb->pipe); 547 endpoint = usb_pipeendpoint(urb->pipe);
550 port = (struct usb_serial_port *) urb->context; 548 port = urb->context;
551 549
552 if (status) { 550 if (status) {
553 dbg("%s: nonzero status: %d on endpoint %02x.", 551 dbg("%s: nonzero status: %d on endpoint %02x.",
554 __FUNCTION__, status, endpoint); 552 __func__, status, endpoint);
555 } else { 553 } else {
556 tty = port->tty; 554 tty = port->tty;
557 if (urb->actual_length) { 555 if (urb->actual_length) {
@@ -559,7 +557,7 @@ static void option_indat_callback(struct urb *urb)
559 tty_insert_flip_string(tty, data, urb->actual_length); 557 tty_insert_flip_string(tty, data, urb->actual_length);
560 tty_flip_buffer_push(tty); 558 tty_flip_buffer_push(tty);
561 } else { 559 } else {
562 dbg("%s: empty read urb received", __FUNCTION__); 560 dbg("%s: empty read urb received", __func__);
563 } 561 }
564 562
565 /* Resubmit urb so we continue receiving */ 563 /* Resubmit urb so we continue receiving */
@@ -567,7 +565,7 @@ static void option_indat_callback(struct urb *urb)
567 err = usb_submit_urb(urb, GFP_ATOMIC); 565 err = usb_submit_urb(urb, GFP_ATOMIC);
568 if (err) 566 if (err)
569 printk(KERN_ERR "%s: resubmit read urb failed. " 567 printk(KERN_ERR "%s: resubmit read urb failed. "
570 "(%d)", __FUNCTION__, err); 568 "(%d)", __func__, err);
571 } 569 }
572 } 570 }
573 return; 571 return;
@@ -579,9 +577,9 @@ static void option_outdat_callback(struct urb *urb)
579 struct option_port_private *portdata; 577 struct option_port_private *portdata;
580 int i; 578 int i;
581 579
582 dbg("%s", __FUNCTION__); 580 dbg("%s", __func__);
583 581
584 port = (struct usb_serial_port *) urb->context; 582 port = urb->context;
585 583
586 usb_serial_port_softint(port); 584 usb_serial_port_softint(port);
587 585
@@ -599,19 +597,19 @@ static void option_instat_callback(struct urb *urb)
599{ 597{
600 int err; 598 int err;
601 int status = urb->status; 599 int status = urb->status;
602 struct usb_serial_port *port = (struct usb_serial_port *) urb->context; 600 struct usb_serial_port *port = urb->context;
603 struct option_port_private *portdata = usb_get_serial_port_data(port); 601 struct option_port_private *portdata = usb_get_serial_port_data(port);
604 struct usb_serial *serial = port->serial; 602 struct usb_serial *serial = port->serial;
605 603
606 dbg("%s", __FUNCTION__); 604 dbg("%s", __func__);
607 dbg("%s: urb %p port %p has data %p", __FUNCTION__,urb,port,portdata); 605 dbg("%s: urb %p port %p has data %p", __func__,urb,port,portdata);
608 606
609 if (status == 0) { 607 if (status == 0) {
610 struct usb_ctrlrequest *req_pkt = 608 struct usb_ctrlrequest *req_pkt =
611 (struct usb_ctrlrequest *)urb->transfer_buffer; 609 (struct usb_ctrlrequest *)urb->transfer_buffer;
612 610
613 if (!req_pkt) { 611 if (!req_pkt) {
614 dbg("%s: NULL req_pkt\n", __FUNCTION__); 612 dbg("%s: NULL req_pkt\n", __func__);
615 return; 613 return;
616 } 614 }
617 if ((req_pkt->bRequestType == 0xA1) && 615 if ((req_pkt->bRequestType == 0xA1) &&
@@ -621,7 +619,7 @@ static void option_instat_callback(struct urb *urb)
621 urb->transfer_buffer + 619 urb->transfer_buffer +
622 sizeof(struct usb_ctrlrequest)); 620 sizeof(struct usb_ctrlrequest));
623 621
624 dbg("%s: signal x%x", __FUNCTION__, signals); 622 dbg("%s: signal x%x", __func__, signals);
625 623
626 old_dcd_state = portdata->dcd_state; 624 old_dcd_state = portdata->dcd_state;
627 portdata->cts_state = 1; 625 portdata->cts_state = 1;
@@ -633,11 +631,11 @@ static void option_instat_callback(struct urb *urb)
633 old_dcd_state && !portdata->dcd_state) 631 old_dcd_state && !portdata->dcd_state)
634 tty_hangup(port->tty); 632 tty_hangup(port->tty);
635 } else { 633 } else {
636 dbg("%s: type %x req %x", __FUNCTION__, 634 dbg("%s: type %x req %x", __func__,
637 req_pkt->bRequestType,req_pkt->bRequest); 635 req_pkt->bRequestType,req_pkt->bRequest);
638 } 636 }
639 } else 637 } else
640 dbg("%s: error %d", __FUNCTION__, status); 638 dbg("%s: error %d", __func__, status);
641 639
642 /* Resubmit urb so we continue receiving IRQ data */ 640 /* Resubmit urb so we continue receiving IRQ data */
643 if (status != -ESHUTDOWN) { 641 if (status != -ESHUTDOWN) {
@@ -645,7 +643,7 @@ static void option_instat_callback(struct urb *urb)
645 err = usb_submit_urb(urb, GFP_ATOMIC); 643 err = usb_submit_urb(urb, GFP_ATOMIC);
646 if (err) 644 if (err)
647 dbg("%s: resubmit intr urb failed. (%d)", 645 dbg("%s: resubmit intr urb failed. (%d)",
648 __FUNCTION__, err); 646 __func__, err);
649 } 647 }
650} 648}
651 649
@@ -658,13 +656,14 @@ static int option_write_room(struct usb_serial_port *port)
658 656
659 portdata = usb_get_serial_port_data(port); 657 portdata = usb_get_serial_port_data(port);
660 658
659
661 for (i=0; i < N_OUT_URB; i++) { 660 for (i=0; i < N_OUT_URB; i++) {
662 this_urb = portdata->out_urbs[i]; 661 this_urb = portdata->out_urbs[i];
663 if (this_urb && !test_bit(i, &portdata->out_busy)) 662 if (this_urb && !test_bit(i, &portdata->out_busy))
664 data_len += OUT_BUFLEN; 663 data_len += OUT_BUFLEN;
665 } 664 }
666 665
667 dbg("%s: %d", __FUNCTION__, data_len); 666 dbg("%s: %d", __func__, data_len);
668 return data_len; 667 return data_len;
669} 668}
670 669
@@ -679,10 +678,12 @@ static int option_chars_in_buffer(struct usb_serial_port *port)
679 678
680 for (i=0; i < N_OUT_URB; i++) { 679 for (i=0; i < N_OUT_URB; i++) {
681 this_urb = portdata->out_urbs[i]; 680 this_urb = portdata->out_urbs[i];
681 /* FIXME: This locking is insufficient as this_urb may
682 go unused during the test */
682 if (this_urb && test_bit(i, &portdata->out_busy)) 683 if (this_urb && test_bit(i, &portdata->out_busy))
683 data_len += this_urb->transfer_buffer_length; 684 data_len += this_urb->transfer_buffer_length;
684 } 685 }
685 dbg("%s: %d", __FUNCTION__, data_len); 686 dbg("%s: %d", __func__, data_len);
686 return data_len; 687 return data_len;
687} 688}
688 689
@@ -695,7 +696,7 @@ static int option_open(struct usb_serial_port *port, struct file *filp)
695 696
696 portdata = usb_get_serial_port_data(port); 697 portdata = usb_get_serial_port_data(port);
697 698
698 dbg("%s", __FUNCTION__); 699 dbg("%s", __func__);
699 700
700 /* Set some sane defaults */ 701 /* Set some sane defaults */
701 portdata->rts_state = 1; 702 portdata->rts_state = 1;
@@ -707,7 +708,7 @@ static int option_open(struct usb_serial_port *port, struct file *filp)
707 if (! urb) 708 if (! urb)
708 continue; 709 continue;
709 if (urb->dev != serial->dev) { 710 if (urb->dev != serial->dev) {
710 dbg("%s: dev %p != %p", __FUNCTION__, 711 dbg("%s: dev %p != %p", __func__,
711 urb->dev, serial->dev); 712 urb->dev, serial->dev);
712 continue; 713 continue;
713 } 714 }
@@ -721,7 +722,7 @@ static int option_open(struct usb_serial_port *port, struct file *filp)
721 err = usb_submit_urb(urb, GFP_KERNEL); 722 err = usb_submit_urb(urb, GFP_KERNEL);
722 if (err) { 723 if (err) {
723 dbg("%s: submit urb %d failed (%d) %d", 724 dbg("%s: submit urb %d failed (%d) %d",
724 __FUNCTION__, i, err, 725 __func__, i, err,
725 urb->transfer_buffer_length); 726 urb->transfer_buffer_length);
726 } 727 }
727 } 728 }
@@ -749,7 +750,7 @@ static void option_close(struct usb_serial_port *port, struct file *filp)
749 struct usb_serial *serial = port->serial; 750 struct usb_serial *serial = port->serial;
750 struct option_port_private *portdata; 751 struct option_port_private *portdata;
751 752
752 dbg("%s", __FUNCTION__); 753 dbg("%s", __func__);
753 portdata = usb_get_serial_port_data(port); 754 portdata = usb_get_serial_port_data(port);
754 755
755 portdata->rts_state = 0; 756 portdata->rts_state = 0;
@@ -782,7 +783,7 @@ static struct urb *option_setup_urb(struct usb_serial *serial, int endpoint,
782 783
783 urb = usb_alloc_urb(0, GFP_KERNEL); /* No ISO */ 784 urb = usb_alloc_urb(0, GFP_KERNEL); /* No ISO */
784 if (urb == NULL) { 785 if (urb == NULL) {
785 dbg("%s: alloc for endpoint %d failed.", __FUNCTION__, endpoint); 786 dbg("%s: alloc for endpoint %d failed.", __func__, endpoint);
786 return NULL; 787 return NULL;
787 } 788 }
788 789
@@ -801,7 +802,7 @@ static void option_setup_urbs(struct usb_serial *serial)
801 struct usb_serial_port *port; 802 struct usb_serial_port *port;
802 struct option_port_private *portdata; 803 struct option_port_private *portdata;
803 804
804 dbg("%s", __FUNCTION__); 805 dbg("%s", __func__);
805 806
806 for (i = 0; i < serial->num_ports; i++) { 807 for (i = 0; i < serial->num_ports; i++) {
807 port = serial->port[i]; 808 port = serial->port[i];
@@ -823,15 +824,18 @@ static void option_setup_urbs(struct usb_serial *serial)
823 } 824 }
824} 825}
825 826
827
828/** send RTS/DTR state to the port.
829 *
830 * This is exactly the same as SET_CONTROL_LINE_STATE from the PSTN
831 * CDC.
832*/
826static int option_send_setup(struct usb_serial_port *port) 833static int option_send_setup(struct usb_serial_port *port)
827{ 834{
828 struct usb_serial *serial = port->serial; 835 struct usb_serial *serial = port->serial;
829 struct option_port_private *portdata; 836 struct option_port_private *portdata;
830 837 int ifNum = serial->interface->cur_altsetting->desc.bInterfaceNumber;
831 dbg("%s", __FUNCTION__); 838 dbg("%s", __func__);
832
833 if (port->number != 0)
834 return 0;
835 839
836 portdata = usb_get_serial_port_data(port); 840 portdata = usb_get_serial_port_data(port);
837 841
@@ -844,7 +848,7 @@ static int option_send_setup(struct usb_serial_port *port)
844 848
845 return usb_control_msg(serial->dev, 849 return usb_control_msg(serial->dev,
846 usb_rcvctrlpipe(serial->dev, 0), 850 usb_rcvctrlpipe(serial->dev, 0),
847 0x22,0x21,val,0,NULL,0,USB_CTRL_SET_TIMEOUT); 851 0x22,0x21,val,ifNum,NULL,0,USB_CTRL_SET_TIMEOUT);
848 } 852 }
849 853
850 return 0; 854 return 0;
@@ -857,7 +861,7 @@ static int option_startup(struct usb_serial *serial)
857 struct option_port_private *portdata; 861 struct option_port_private *portdata;
858 u8 *buffer; 862 u8 *buffer;
859 863
860 dbg("%s", __FUNCTION__); 864 dbg("%s", __func__);
861 865
862 /* Now setup per port private data */ 866 /* Now setup per port private data */
863 for (i = 0; i < serial->num_ports; i++) { 867 for (i = 0; i < serial->num_ports; i++) {
@@ -865,7 +869,7 @@ static int option_startup(struct usb_serial *serial)
865 portdata = kzalloc(sizeof(*portdata), GFP_KERNEL); 869 portdata = kzalloc(sizeof(*portdata), GFP_KERNEL);
866 if (!portdata) { 870 if (!portdata) {
867 dbg("%s: kmalloc for option_port_private (%d) failed!.", 871 dbg("%s: kmalloc for option_port_private (%d) failed!.",
868 __FUNCTION__, i); 872 __func__, i);
869 return (1); 873 return (1);
870 } 874 }
871 875
@@ -890,7 +894,7 @@ static int option_startup(struct usb_serial *serial)
890 err = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); 894 err = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
891 if (err) 895 if (err)
892 dbg("%s: submit irq_in urb failed %d", 896 dbg("%s: submit irq_in urb failed %d",
893 __FUNCTION__, err); 897 __func__, err);
894 } 898 }
895 899
896 option_setup_urbs(serial); 900 option_setup_urbs(serial);
@@ -914,7 +918,7 @@ static void option_shutdown(struct usb_serial *serial)
914 struct usb_serial_port *port; 918 struct usb_serial_port *port;
915 struct option_port_private *portdata; 919 struct option_port_private *portdata;
916 920
917 dbg("%s", __FUNCTION__); 921 dbg("%s", __func__);
918 922
919 /* Stop reading/writing urbs */ 923 /* Stop reading/writing urbs */
920 for (i = 0; i < serial->num_ports; ++i) { 924 for (i = 0; i < serial->num_ports; ++i) {
diff --git a/drivers/usb/serial/oti6858.c b/drivers/usb/serial/oti6858.c
index a3847d6c946..d92bb6501c8 100644
--- a/drivers/usb/serial/oti6858.c
+++ b/drivers/usb/serial/oti6858.c
@@ -179,9 +179,6 @@ static struct usb_serial_driver oti6858_device = {
179 .name = "oti6858", 179 .name = "oti6858",
180 }, 180 },
181 .id_table = id_table, 181 .id_table = id_table,
182 .num_interrupt_in = 1,
183 .num_bulk_in = 1,
184 .num_bulk_out = 1,
185 .num_ports = 1, 182 .num_ports = 1,
186 .open = oti6858_open, 183 .open = oti6858_open,
187 .close = oti6858_close, 184 .close = oti6858_close,
@@ -238,10 +235,10 @@ static void setup_line(struct work_struct *work)
238 unsigned long flags; 235 unsigned long flags;
239 int result; 236 int result;
240 237
241 dbg("%s(port = %d)", __FUNCTION__, port->number); 238 dbg("%s(port = %d)", __func__, port->number);
242 239
243 if ((new_setup = kmalloc(OTI6858_CTRL_PKT_SIZE, GFP_KERNEL)) == NULL) { 240 if ((new_setup = kmalloc(OTI6858_CTRL_PKT_SIZE, GFP_KERNEL)) == NULL) {
244 dev_err(&port->dev, "%s(): out of memory!\n", __FUNCTION__); 241 dev_err(&port->dev, "%s(): out of memory!\n", __func__);
245 /* we will try again */ 242 /* we will try again */
246 schedule_delayed_work(&priv->delayed_setup_work, msecs_to_jiffies(2)); 243 schedule_delayed_work(&priv->delayed_setup_work, msecs_to_jiffies(2));
247 return; 244 return;
@@ -256,7 +253,7 @@ static void setup_line(struct work_struct *work)
256 100); 253 100);
257 254
258 if (result != OTI6858_CTRL_PKT_SIZE) { 255 if (result != OTI6858_CTRL_PKT_SIZE) {
259 dev_err(&port->dev, "%s(): error reading status\n", __FUNCTION__); 256 dev_err(&port->dev, "%s(): error reading status\n", __func__);
260 kfree(new_setup); 257 kfree(new_setup);
261 /* we will try again */ 258 /* we will try again */
262 schedule_delayed_work(&priv->delayed_setup_work, msecs_to_jiffies(2)); 259 schedule_delayed_work(&priv->delayed_setup_work, msecs_to_jiffies(2));
@@ -289,12 +286,12 @@ static void setup_line(struct work_struct *work)
289 priv->setup_done = 1; 286 priv->setup_done = 1;
290 spin_unlock_irqrestore(&priv->lock, flags); 287 spin_unlock_irqrestore(&priv->lock, flags);
291 288
292 dbg("%s(): submitting interrupt urb", __FUNCTION__); 289 dbg("%s(): submitting interrupt urb", __func__);
293 port->interrupt_in_urb->dev = port->serial->dev; 290 port->interrupt_in_urb->dev = port->serial->dev;
294 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); 291 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC);
295 if (result != 0) { 292 if (result != 0) {
296 dev_err(&port->dev, "%s(): usb_submit_urb() failed" 293 dev_err(&port->dev, "%s(): usb_submit_urb() failed"
297 " with error %d\n", __FUNCTION__, result); 294 " with error %d\n", __func__, result);
298 } 295 }
299} 296}
300 297
@@ -306,7 +303,7 @@ void send_data(struct work_struct *work)
306 unsigned long flags; 303 unsigned long flags;
307 unsigned char allow; 304 unsigned char allow;
308 305
309 dbg("%s(port = %d)", __FUNCTION__, port->number); 306 dbg("%s(port = %d)", __func__, port->number);
310 307
311 spin_lock_irqsave(&priv->lock, flags); 308 spin_lock_irqsave(&priv->lock, flags);
312 if (priv->flags.write_urb_in_use) { 309 if (priv->flags.write_urb_in_use) {
@@ -334,12 +331,12 @@ void send_data(struct work_struct *work)
334 if (count == 0) { 331 if (count == 0) {
335 priv->flags.write_urb_in_use = 0; 332 priv->flags.write_urb_in_use = 0;
336 333
337 dbg("%s(): submitting interrupt urb", __FUNCTION__); 334 dbg("%s(): submitting interrupt urb", __func__);
338 port->interrupt_in_urb->dev = port->serial->dev; 335 port->interrupt_in_urb->dev = port->serial->dev;
339 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); 336 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC);
340 if (result != 0) { 337 if (result != 0) {
341 dev_err(&port->dev, "%s(): usb_submit_urb() failed" 338 dev_err(&port->dev, "%s(): usb_submit_urb() failed"
342 " with error %d\n", __FUNCTION__, result); 339 " with error %d\n", __func__, result);
343 } 340 }
344 return; 341 return;
345 } 342 }
@@ -353,7 +350,7 @@ void send_data(struct work_struct *work)
353 result = usb_submit_urb(port->write_urb, GFP_ATOMIC); 350 result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
354 if (result != 0) { 351 if (result != 0) {
355 dev_err(&port->dev, "%s(): usb_submit_urb() failed" 352 dev_err(&port->dev, "%s(): usb_submit_urb() failed"
356 " with error %d\n", __FUNCTION__, result); 353 " with error %d\n", __func__, result);
357 priv->flags.write_urb_in_use = 0; 354 priv->flags.write_urb_in_use = 0;
358 } 355 }
359 356
@@ -404,7 +401,7 @@ static int oti6858_write(struct usb_serial_port *port,
404 struct oti6858_private *priv = usb_get_serial_port_data(port); 401 struct oti6858_private *priv = usb_get_serial_port_data(port);
405 unsigned long flags; 402 unsigned long flags;
406 403
407 dbg("%s(port = %d, count = %d)", __FUNCTION__, port->number, count); 404 dbg("%s(port = %d, count = %d)", __func__, port->number, count);
408 405
409 if (!count) 406 if (!count)
410 return count; 407 return count;
@@ -422,7 +419,7 @@ static int oti6858_write_room(struct usb_serial_port *port)
422 int room = 0; 419 int room = 0;
423 unsigned long flags; 420 unsigned long flags;
424 421
425 dbg("%s(port = %d)", __FUNCTION__, port->number); 422 dbg("%s(port = %d)", __func__, port->number);
426 423
427 spin_lock_irqsave(&priv->lock, flags); 424 spin_lock_irqsave(&priv->lock, flags);
428 room = oti6858_buf_space_avail(priv->buf); 425 room = oti6858_buf_space_avail(priv->buf);
@@ -437,7 +434,7 @@ static int oti6858_chars_in_buffer(struct usb_serial_port *port)
437 int chars = 0; 434 int chars = 0;
438 unsigned long flags; 435 unsigned long flags;
439 436
440 dbg("%s(port = %d)", __FUNCTION__, port->number); 437 dbg("%s(port = %d)", __func__, port->number);
441 438
442 spin_lock_irqsave(&priv->lock, flags); 439 spin_lock_irqsave(&priv->lock, flags);
443 chars = oti6858_buf_data_avail(priv->buf); 440 chars = oti6858_buf_data_avail(priv->buf);
@@ -456,10 +453,10 @@ static void oti6858_set_termios(struct usb_serial_port *port,
456 u16 divisor; 453 u16 divisor;
457 int br; 454 int br;
458 455
459 dbg("%s(port = %d)", __FUNCTION__, port->number); 456 dbg("%s(port = %d)", __func__, port->number);
460 457
461 if (!port->tty || !port->tty->termios) { 458 if (!port->tty || !port->tty->termios) {
462 dbg("%s(): no tty structures", __FUNCTION__); 459 dbg("%s(): no tty structures", __func__);
463 return; 460 return;
464 } 461 }
465 462
@@ -575,7 +572,7 @@ static int oti6858_open(struct usb_serial_port *port, struct file *filp)
575 unsigned long flags; 572 unsigned long flags;
576 int result; 573 int result;
577 574
578 dbg("%s(port = %d)", __FUNCTION__, port->number); 575 dbg("%s(port = %d)", __func__, port->number);
579 576
580 usb_clear_halt(serial->dev, port->write_urb->pipe); 577 usb_clear_halt(serial->dev, port->write_urb->pipe);
581 usb_clear_halt(serial->dev, port->read_urb->pipe); 578 usb_clear_halt(serial->dev, port->read_urb->pipe);
@@ -584,7 +581,7 @@ static int oti6858_open(struct usb_serial_port *port, struct file *filp)
584 return 0; 581 return 0;
585 582
586 if ((buf = kmalloc(OTI6858_CTRL_PKT_SIZE, GFP_KERNEL)) == NULL) { 583 if ((buf = kmalloc(OTI6858_CTRL_PKT_SIZE, GFP_KERNEL)) == NULL) {
587 dev_err(&port->dev, "%s(): out of memory!\n", __FUNCTION__); 584 dev_err(&port->dev, "%s(): out of memory!\n", __func__);
588 return -ENOMEM; 585 return -ENOMEM;
589 } 586 }
590 587
@@ -613,12 +610,12 @@ static int oti6858_open(struct usb_serial_port *port, struct file *filp)
613 spin_unlock_irqrestore(&priv->lock, flags); 610 spin_unlock_irqrestore(&priv->lock, flags);
614 kfree(buf); 611 kfree(buf);
615 612
616 dbg("%s(): submitting interrupt urb", __FUNCTION__); 613 dbg("%s(): submitting interrupt urb", __func__);
617 port->interrupt_in_urb->dev = serial->dev; 614 port->interrupt_in_urb->dev = serial->dev;
618 result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); 615 result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
619 if (result != 0) { 616 if (result != 0) {
620 dev_err(&port->dev, "%s(): usb_submit_urb() failed" 617 dev_err(&port->dev, "%s(): usb_submit_urb() failed"
621 " with error %d\n", __FUNCTION__, result); 618 " with error %d\n", __func__, result);
622 oti6858_close(port, NULL); 619 oti6858_close(port, NULL);
623 return -EPROTO; 620 return -EPROTO;
624 } 621 }
@@ -637,14 +634,14 @@ static void oti6858_close(struct usb_serial_port *port, struct file *filp)
637 long timeout; 634 long timeout;
638 wait_queue_t wait; 635 wait_queue_t wait;
639 636
640 dbg("%s(port = %d)", __FUNCTION__, port->number); 637 dbg("%s(port = %d)", __func__, port->number);
641 638
642 /* wait for data to drain from the buffer */ 639 /* wait for data to drain from the buffer */
643 spin_lock_irqsave(&priv->lock, flags); 640 spin_lock_irqsave(&priv->lock, flags);
644 timeout = 30 * HZ; /* PL2303_CLOSING_WAIT */ 641 timeout = 30 * HZ; /* PL2303_CLOSING_WAIT */
645 init_waitqueue_entry(&wait, current); 642 init_waitqueue_entry(&wait, current);
646 add_wait_queue(&port->tty->write_wait, &wait); 643 add_wait_queue(&port->tty->write_wait, &wait);
647 dbg("%s(): entering wait loop", __FUNCTION__); 644 dbg("%s(): entering wait loop", __func__);
648 for (;;) { 645 for (;;) {
649 set_current_state(TASK_INTERRUPTIBLE); 646 set_current_state(TASK_INTERRUPTIBLE);
650 if (oti6858_buf_data_avail(priv->buf) == 0 647 if (oti6858_buf_data_avail(priv->buf) == 0
@@ -657,7 +654,7 @@ static void oti6858_close(struct usb_serial_port *port, struct file *filp)
657 } 654 }
658 set_current_state(TASK_RUNNING); 655 set_current_state(TASK_RUNNING);
659 remove_wait_queue(&port->tty->write_wait, &wait); 656 remove_wait_queue(&port->tty->write_wait, &wait);
660 dbg("%s(): after wait loop", __FUNCTION__); 657 dbg("%s(): after wait loop", __func__);
661 658
662 /* clear out any remaining data in the buffer */ 659 /* clear out any remaining data in the buffer */
663 oti6858_buf_clear(priv->buf); 660 oti6858_buf_clear(priv->buf);
@@ -678,7 +675,7 @@ static void oti6858_close(struct usb_serial_port *port, struct file *filp)
678 */ 675 */
679 timeout = 2*HZ; 676 timeout = 2*HZ;
680 schedule_timeout_interruptible(timeout); 677 schedule_timeout_interruptible(timeout);
681 dbg("%s(): after schedule_timeout_interruptible()", __FUNCTION__); 678 dbg("%s(): after schedule_timeout_interruptible()", __func__);
682 679
683 /* cancel scheduled setup */ 680 /* cancel scheduled setup */
684 cancel_delayed_work(&priv->delayed_setup_work); 681 cancel_delayed_work(&priv->delayed_setup_work);
@@ -686,7 +683,7 @@ static void oti6858_close(struct usb_serial_port *port, struct file *filp)
686 flush_scheduled_work(); 683 flush_scheduled_work();
687 684
688 /* shutdown our urbs */ 685 /* shutdown our urbs */
689 dbg("%s(): shutting down urbs", __FUNCTION__); 686 dbg("%s(): shutting down urbs", __func__);
690 usb_kill_urb(port->write_urb); 687 usb_kill_urb(port->write_urb);
691 usb_kill_urb(port->read_urb); 688 usb_kill_urb(port->read_urb);
692 usb_kill_urb(port->interrupt_in_urb); 689 usb_kill_urb(port->interrupt_in_urb);
@@ -709,7 +706,7 @@ static int oti6858_tiocmset(struct usb_serial_port *port, struct file *file,
709 u8 control; 706 u8 control;
710 707
711 dbg("%s(port = %d, set = 0x%08x, clear = 0x%08x)", 708 dbg("%s(port = %d, set = 0x%08x, clear = 0x%08x)",
712 __FUNCTION__, port->number, set, clear); 709 __func__, port->number, set, clear);
713 710
714 if (!usb_get_intfdata(port->serial->interface)) 711 if (!usb_get_intfdata(port->serial->interface))
715 return -ENODEV; 712 return -ENODEV;
@@ -741,7 +738,7 @@ static int oti6858_tiocmget(struct usb_serial_port *port, struct file *file)
741 unsigned pin_state; 738 unsigned pin_state;
742 unsigned result = 0; 739 unsigned result = 0;
743 740
744 dbg("%s(port = %d)", __FUNCTION__, port->number); 741 dbg("%s(port = %d)", __func__, port->number);
745 742
746 if (!usb_get_intfdata(port->serial->interface)) 743 if (!usb_get_intfdata(port->serial->interface))
747 return -ENODEV; 744 return -ENODEV;
@@ -764,7 +761,7 @@ static int oti6858_tiocmget(struct usb_serial_port *port, struct file *file)
764 if ((pin_state & PIN_DCD) != 0) 761 if ((pin_state & PIN_DCD) != 0)
765 result |= TIOCM_CD; 762 result |= TIOCM_CD;
766 763
767 dbg("%s() = 0x%08x", __FUNCTION__, result); 764 dbg("%s() = 0x%08x", __func__, result);
768 765
769 return result; 766 return result;
770} 767}
@@ -811,13 +808,9 @@ static int oti6858_ioctl(struct usb_serial_port *port, struct file *file,
811 unsigned int x; 808 unsigned int x;
812 809
813 dbg("%s(port = %d, cmd = 0x%04x, arg = 0x%08lx)", 810 dbg("%s(port = %d, cmd = 0x%04x, arg = 0x%08lx)",
814 __FUNCTION__, port->number, cmd, arg); 811 __func__, port->number, cmd, arg);
815 812
816 switch (cmd) { 813 switch (cmd) {
817 case TCFLSH:
818 /* FIXME */
819 return 0;
820
821 case TIOCMBIS: 814 case TIOCMBIS:
822 if (copy_from_user(&x, user_arg, sizeof(x))) 815 if (copy_from_user(&x, user_arg, sizeof(x)))
823 return -EFAULT; 816 return -EFAULT;
@@ -829,11 +822,11 @@ static int oti6858_ioctl(struct usb_serial_port *port, struct file *file,
829 return oti6858_tiocmset(port, NULL, 0, x); 822 return oti6858_tiocmset(port, NULL, 0, x);
830 823
831 case TIOCMIWAIT: 824 case TIOCMIWAIT:
832 dbg("%s(): TIOCMIWAIT", __FUNCTION__); 825 dbg("%s(): TIOCMIWAIT", __func__);
833 return wait_modem_info(port, arg); 826 return wait_modem_info(port, arg);
834 827
835 default: 828 default:
836 dbg("%s(): 0x%04x not supported", __FUNCTION__, cmd); 829 dbg("%s(): 0x%04x not supported", __func__, cmd);
837 break; 830 break;
838 } 831 }
839 832
@@ -844,10 +837,10 @@ static void oti6858_break_ctl(struct usb_serial_port *port, int break_state)
844{ 837{
845 int state; 838 int state;
846 839
847 dbg("%s(port = %d)", __FUNCTION__, port->number); 840 dbg("%s(port = %d)", __func__, port->number);
848 841
849 state = (break_state == 0) ? 0 : 1; 842 state = (break_state == 0) ? 0 : 1;
850 dbg("%s(): turning break %s", __FUNCTION__, state ? "on" : "off"); 843 dbg("%s(): turning break %s", __func__, state ? "on" : "off");
851 844
852 /* FIXME */ 845 /* FIXME */
853/* 846/*
@@ -855,7 +848,7 @@ static void oti6858_break_ctl(struct usb_serial_port *port, int break_state)
855 BREAK_REQUEST, BREAK_REQUEST_TYPE, state, 848 BREAK_REQUEST, BREAK_REQUEST_TYPE, state,
856 0, NULL, 0, 100); 849 0, NULL, 0, 100);
857 if (result != 0) 850 if (result != 0)
858 dbg("%s(): error sending break", __FUNCTION__); 851 dbg("%s(): error sending break", __func__);
859 */ 852 */
860} 853}
861 854
@@ -864,7 +857,7 @@ static void oti6858_shutdown(struct usb_serial *serial)
864 struct oti6858_private *priv; 857 struct oti6858_private *priv;
865 int i; 858 int i;
866 859
867 dbg("%s()", __FUNCTION__); 860 dbg("%s()", __func__);
868 861
869 for (i = 0; i < serial->num_ports; ++i) { 862 for (i = 0; i < serial->num_ports; ++i) {
870 priv = usb_get_serial_port_data(serial->port[i]); 863 priv = usb_get_serial_port_data(serial->port[i]);
@@ -878,13 +871,13 @@ static void oti6858_shutdown(struct usb_serial *serial)
878 871
879static void oti6858_read_int_callback(struct urb *urb) 872static void oti6858_read_int_callback(struct urb *urb)
880{ 873{
881 struct usb_serial_port *port = (struct usb_serial_port *) urb->context; 874 struct usb_serial_port *port = urb->context;
882 struct oti6858_private *priv = usb_get_serial_port_data(port); 875 struct oti6858_private *priv = usb_get_serial_port_data(port);
883 int transient = 0, can_recv = 0, resubmit = 1; 876 int transient = 0, can_recv = 0, resubmit = 1;
884 int status = urb->status; 877 int status = urb->status;
885 878
886 dbg("%s(port = %d, status = %d)", 879 dbg("%s(port = %d, status = %d)",
887 __FUNCTION__, port->number, status); 880 __func__, port->number, status);
888 881
889 switch (status) { 882 switch (status) {
890 case 0: 883 case 0:
@@ -895,11 +888,11 @@ static void oti6858_read_int_callback(struct urb *urb)
895 case -ESHUTDOWN: 888 case -ESHUTDOWN:
896 /* this urb is terminated, clean up */ 889 /* this urb is terminated, clean up */
897 dbg("%s(): urb shutting down with status: %d", 890 dbg("%s(): urb shutting down with status: %d",
898 __FUNCTION__, status); 891 __func__, status);
899 return; 892 return;
900 default: 893 default:
901 dbg("%s(): nonzero urb status received: %d", 894 dbg("%s(): nonzero urb status received: %d",
902 __FUNCTION__, status); 895 __func__, status);
903 break; 896 break;
904 } 897 }
905 898
@@ -916,7 +909,7 @@ static void oti6858_read_int_callback(struct urb *urb)
916 priv->setup_done = 0; 909 priv->setup_done = 0;
917 resubmit = 0; 910 resubmit = 0;
918 dbg("%s(): scheduling setup_line()", 911 dbg("%s(): scheduling setup_line()",
919 __FUNCTION__); 912 __func__);
920 schedule_delayed_work(&priv->delayed_setup_work, 0); 913 schedule_delayed_work(&priv->delayed_setup_work, 0);
921 } 914 }
922 } 915 }
@@ -931,7 +924,7 @@ static void oti6858_read_int_callback(struct urb *urb)
931 priv->setup_done = 0; 924 priv->setup_done = 0;
932 resubmit = 0; 925 resubmit = 0;
933 dbg("%s(): scheduling setup_line()", 926 dbg("%s(): scheduling setup_line()",
934 __FUNCTION__); 927 __func__);
935 schedule_delayed_work(&priv->delayed_setup_work, 0); 928 schedule_delayed_work(&priv->delayed_setup_work, 0);
936 } 929 }
937 } 930 }
@@ -960,7 +953,7 @@ static void oti6858_read_int_callback(struct urb *urb)
960 if (result != 0) { 953 if (result != 0) {
961 priv->flags.read_urb_in_use = 0; 954 priv->flags.read_urb_in_use = 0;
962 dev_err(&port->dev, "%s(): usb_submit_urb() failed," 955 dev_err(&port->dev, "%s(): usb_submit_urb() failed,"
963 " error %d\n", __FUNCTION__, result); 956 " error %d\n", __func__, result);
964 } else { 957 } else {
965 resubmit = 0; 958 resubmit = 0;
966 } 959 }
@@ -979,20 +972,20 @@ static void oti6858_read_int_callback(struct urb *urb)
979 if (resubmit) { 972 if (resubmit) {
980 int result; 973 int result;
981 974
982// dbg("%s(): submitting interrupt urb", __FUNCTION__); 975// dbg("%s(): submitting interrupt urb", __func__);
983 urb->dev = port->serial->dev; 976 urb->dev = port->serial->dev;
984 result = usb_submit_urb(urb, GFP_ATOMIC); 977 result = usb_submit_urb(urb, GFP_ATOMIC);
985 if (result != 0) { 978 if (result != 0) {
986 dev_err(&urb->dev->dev, 979 dev_err(&urb->dev->dev,
987 "%s(): usb_submit_urb() failed with" 980 "%s(): usb_submit_urb() failed with"
988 " error %d\n", __FUNCTION__, result); 981 " error %d\n", __func__, result);
989 } 982 }
990 } 983 }
991} 984}
992 985
993static void oti6858_read_bulk_callback(struct urb *urb) 986static void oti6858_read_bulk_callback(struct urb *urb)
994{ 987{
995 struct usb_serial_port *port = (struct usb_serial_port *) urb->context; 988 struct usb_serial_port *port = urb->context;
996 struct oti6858_private *priv = usb_get_serial_port_data(port); 989 struct oti6858_private *priv = usb_get_serial_port_data(port);
997 struct tty_struct *tty; 990 struct tty_struct *tty;
998 unsigned char *data = urb->transfer_buffer; 991 unsigned char *data = urb->transfer_buffer;
@@ -1001,7 +994,7 @@ static void oti6858_read_bulk_callback(struct urb *urb)
1001 int result; 994 int result;
1002 995
1003 dbg("%s(port = %d, status = %d)", 996 dbg("%s(port = %d, status = %d)",
1004 __FUNCTION__, port->number, status); 997 __func__, port->number, status);
1005 998
1006 spin_lock_irqsave(&priv->lock, flags); 999 spin_lock_irqsave(&priv->lock, flags);
1007 priv->flags.read_urb_in_use = 0; 1000 priv->flags.read_urb_in_use = 0;
@@ -1009,20 +1002,20 @@ static void oti6858_read_bulk_callback(struct urb *urb)
1009 1002
1010 if (status != 0) { 1003 if (status != 0) {
1011 if (!port->open_count) { 1004 if (!port->open_count) {
1012 dbg("%s(): port is closed, exiting", __FUNCTION__); 1005 dbg("%s(): port is closed, exiting", __func__);
1013 return; 1006 return;
1014 } 1007 }
1015 /* 1008 /*
1016 if (status == -EPROTO) { 1009 if (status == -EPROTO) {
1017 // PL2303 mysteriously fails with -EPROTO reschedule the read 1010 // PL2303 mysteriously fails with -EPROTO reschedule the read
1018 dbg("%s - caught -EPROTO, resubmitting the urb", __FUNCTION__); 1011 dbg("%s - caught -EPROTO, resubmitting the urb", __func__);
1019 result = usb_submit_urb(urb, GFP_ATOMIC); 1012 result = usb_submit_urb(urb, GFP_ATOMIC);
1020 if (result) 1013 if (result)
1021 dev_err(&urb->dev->dev, "%s - failed resubmitting read urb, error %d\n", __FUNCTION__, result); 1014 dev_err(&urb->dev->dev, "%s - failed resubmitting read urb, error %d\n", __func__, result);
1022 return; 1015 return;
1023 } 1016 }
1024 */ 1017 */
1025 dbg("%s(): unable to handle the error, exiting", __FUNCTION__); 1018 dbg("%s(): unable to handle the error, exiting", __func__);
1026 return; 1019 return;
1027 } 1020 }
1028 1021
@@ -1038,20 +1031,20 @@ static void oti6858_read_bulk_callback(struct urb *urb)
1038 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); 1031 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC);
1039 if (result != 0) { 1032 if (result != 0) {
1040 dev_err(&port->dev, "%s(): usb_submit_urb() failed," 1033 dev_err(&port->dev, "%s(): usb_submit_urb() failed,"
1041 " error %d\n", __FUNCTION__, result); 1034 " error %d\n", __func__, result);
1042 } 1035 }
1043 } 1036 }
1044} 1037}
1045 1038
1046static void oti6858_write_bulk_callback(struct urb *urb) 1039static void oti6858_write_bulk_callback(struct urb *urb)
1047{ 1040{
1048 struct usb_serial_port *port = (struct usb_serial_port *) urb->context; 1041 struct usb_serial_port *port = urb->context;
1049 struct oti6858_private *priv = usb_get_serial_port_data(port); 1042 struct oti6858_private *priv = usb_get_serial_port_data(port);
1050 int status = urb->status; 1043 int status = urb->status;
1051 int result; 1044 int result;
1052 1045
1053 dbg("%s(port = %d, status = %d)", 1046 dbg("%s(port = %d, status = %d)",
1054 __FUNCTION__, port->number, status); 1047 __func__, port->number, status);
1055 1048
1056 switch (status) { 1049 switch (status) {
1057 case 0: 1050 case 0:
@@ -1062,21 +1055,21 @@ static void oti6858_write_bulk_callback(struct urb *urb)
1062 case -ESHUTDOWN: 1055 case -ESHUTDOWN:
1063 /* this urb is terminated, clean up */ 1056 /* this urb is terminated, clean up */
1064 dbg("%s(): urb shutting down with status: %d", 1057 dbg("%s(): urb shutting down with status: %d",
1065 __FUNCTION__, status); 1058 __func__, status);
1066 priv->flags.write_urb_in_use = 0; 1059 priv->flags.write_urb_in_use = 0;
1067 return; 1060 return;
1068 default: 1061 default:
1069 /* error in the urb, so we have to resubmit it */ 1062 /* error in the urb, so we have to resubmit it */
1070 dbg("%s(): nonzero write bulk status received: %d", 1063 dbg("%s(): nonzero write bulk status received: %d",
1071 __FUNCTION__, status); 1064 __func__, status);
1072 dbg("%s(): overflow in write", __FUNCTION__); 1065 dbg("%s(): overflow in write", __func__);
1073 1066
1074 port->write_urb->transfer_buffer_length = 1; 1067 port->write_urb->transfer_buffer_length = 1;
1075 port->write_urb->dev = port->serial->dev; 1068 port->write_urb->dev = port->serial->dev;
1076 result = usb_submit_urb(port->write_urb, GFP_ATOMIC); 1069 result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
1077 if (result) { 1070 if (result) {
1078 dev_err(&port->dev, "%s(): usb_submit_urb() failed," 1071 dev_err(&port->dev, "%s(): usb_submit_urb() failed,"
1079 " error %d\n", __FUNCTION__, result); 1072 " error %d\n", __func__, result);
1080 } else { 1073 } else {
1081 return; 1074 return;
1082 } 1075 }
@@ -1086,11 +1079,11 @@ static void oti6858_write_bulk_callback(struct urb *urb)
1086 1079
1087 // schedule the interrupt urb if we are still open */ 1080 // schedule the interrupt urb if we are still open */
1088 port->interrupt_in_urb->dev = port->serial->dev; 1081 port->interrupt_in_urb->dev = port->serial->dev;
1089 dbg("%s(): submitting interrupt urb", __FUNCTION__); 1082 dbg("%s(): submitting interrupt urb", __func__);
1090 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); 1083 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC);
1091 if (result != 0) { 1084 if (result != 0) {
1092 dev_err(&port->dev, "%s(): failed submitting int urb," 1085 dev_err(&port->dev, "%s(): failed submitting int urb,"
1093 " error %d\n", __FUNCTION__, result); 1086 " error %d\n", __func__, result);
1094 } 1087 }
1095} 1088}
1096 1089
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index 2af778555bd..c605fb68f80 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -410,7 +410,7 @@ static int set_control_lines(struct usb_device *dev, u8 value)
410 retval = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 410 retval = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
411 SET_CONTROL_REQUEST, SET_CONTROL_REQUEST_TYPE, 411 SET_CONTROL_REQUEST, SET_CONTROL_REQUEST_TYPE,
412 value, 0, NULL, 0, 100); 412 value, 0, NULL, 0, 100);
413 dbg("%s - value = %d, retval = %d", __FUNCTION__, value, retval); 413 dbg("%s - value = %d, retval = %d", __func__, value, retval);
414 return retval; 414 return retval;
415} 415}
416 416
@@ -420,7 +420,7 @@ static void pl2303_send(struct usb_serial_port *port)
420 struct pl2303_private *priv = usb_get_serial_port_data(port); 420 struct pl2303_private *priv = usb_get_serial_port_data(port);
421 unsigned long flags; 421 unsigned long flags;
422 422
423 dbg("%s - port %d", __FUNCTION__, port->number); 423 dbg("%s - port %d", __func__, port->number);
424 424
425 spin_lock_irqsave(&priv->lock, flags); 425 spin_lock_irqsave(&priv->lock, flags);
426 426
@@ -441,7 +441,7 @@ static void pl2303_send(struct usb_serial_port *port)
441 441
442 spin_unlock_irqrestore(&priv->lock, flags); 442 spin_unlock_irqrestore(&priv->lock, flags);
443 443
444 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count, 444 usb_serial_debug_data(debug, &port->dev, __func__, count,
445 port->write_urb->transfer_buffer); 445 port->write_urb->transfer_buffer);
446 446
447 port->write_urb->transfer_buffer_length = count; 447 port->write_urb->transfer_buffer_length = count;
@@ -449,7 +449,7 @@ static void pl2303_send(struct usb_serial_port *port)
449 result = usb_submit_urb(port->write_urb, GFP_ATOMIC); 449 result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
450 if (result) { 450 if (result) {
451 dev_err(&port->dev, "%s - failed submitting write urb," 451 dev_err(&port->dev, "%s - failed submitting write urb,"
452 " error %d\n", __FUNCTION__, result); 452 " error %d\n", __func__, result);
453 priv->write_urb_in_use = 0; 453 priv->write_urb_in_use = 0;
454 // TODO: reschedule pl2303_send 454 // TODO: reschedule pl2303_send
455 } 455 }
@@ -463,7 +463,7 @@ static int pl2303_write(struct usb_serial_port *port, const unsigned char *buf,
463 struct pl2303_private *priv = usb_get_serial_port_data(port); 463 struct pl2303_private *priv = usb_get_serial_port_data(port);
464 unsigned long flags; 464 unsigned long flags;
465 465
466 dbg("%s - port %d, %d bytes", __FUNCTION__, port->number, count); 466 dbg("%s - port %d, %d bytes", __func__, port->number, count);
467 467
468 if (!count) 468 if (!count)
469 return count; 469 return count;
@@ -483,13 +483,13 @@ static int pl2303_write_room(struct usb_serial_port *port)
483 int room = 0; 483 int room = 0;
484 unsigned long flags; 484 unsigned long flags;
485 485
486 dbg("%s - port %d", __FUNCTION__, port->number); 486 dbg("%s - port %d", __func__, port->number);
487 487
488 spin_lock_irqsave(&priv->lock, flags); 488 spin_lock_irqsave(&priv->lock, flags);
489 room = pl2303_buf_space_avail(priv->buf); 489 room = pl2303_buf_space_avail(priv->buf);
490 spin_unlock_irqrestore(&priv->lock, flags); 490 spin_unlock_irqrestore(&priv->lock, flags);
491 491
492 dbg("%s - returns %d", __FUNCTION__, room); 492 dbg("%s - returns %d", __func__, room);
493 return room; 493 return room;
494} 494}
495 495
@@ -499,13 +499,13 @@ static int pl2303_chars_in_buffer(struct usb_serial_port *port)
499 int chars = 0; 499 int chars = 0;
500 unsigned long flags; 500 unsigned long flags;
501 501
502 dbg("%s - port %d", __FUNCTION__, port->number); 502 dbg("%s - port %d", __func__, port->number);
503 503
504 spin_lock_irqsave(&priv->lock, flags); 504 spin_lock_irqsave(&priv->lock, flags);
505 chars = pl2303_buf_data_avail(priv->buf); 505 chars = pl2303_buf_data_avail(priv->buf);
506 spin_unlock_irqrestore(&priv->lock, flags); 506 spin_unlock_irqrestore(&priv->lock, flags);
507 507
508 dbg("%s - returns %d", __FUNCTION__, chars); 508 dbg("%s - returns %d", __func__, chars);
509 return chars; 509 return chars;
510} 510}
511 511
@@ -521,7 +521,7 @@ static void pl2303_set_termios(struct usb_serial_port *port,
521 int i; 521 int i;
522 u8 control; 522 u8 control;
523 523
524 dbg("%s - port %d", __FUNCTION__, port->number); 524 dbg("%s - port %d", __func__, port->number);
525 525
526 spin_lock_irqsave(&priv->lock, flags); 526 spin_lock_irqsave(&priv->lock, flags);
527 if (!priv->termios_initialized) { 527 if (!priv->termios_initialized) {
@@ -545,7 +545,9 @@ static void pl2303_set_termios(struct usb_serial_port *port,
545 545
546 buf = kzalloc(7, GFP_KERNEL); 546 buf = kzalloc(7, GFP_KERNEL);
547 if (!buf) { 547 if (!buf) {
548 dev_err(&port->dev, "%s - out of memory.\n", __FUNCTION__); 548 dev_err(&port->dev, "%s - out of memory.\n", __func__);
549 /* Report back no change occurred */
550 *port->tty->termios = *old_termios;
549 return; 551 return;
550 } 552 }
551 553
@@ -563,11 +565,11 @@ static void pl2303_set_termios(struct usb_serial_port *port,
563 default: 565 default:
564 case CS8: buf[6] = 8; break; 566 case CS8: buf[6] = 8; break;
565 } 567 }
566 dbg("%s - data bits = %d", __FUNCTION__, buf[6]); 568 dbg("%s - data bits = %d", __func__, buf[6]);
567 } 569 }
568 570
569 baud = tty_get_baud_rate(port->tty);; 571 baud = tty_get_baud_rate(port->tty);;
570 dbg("%s - baud = %d", __FUNCTION__, baud); 572 dbg("%s - baud = %d", __func__, baud);
571 if (baud) { 573 if (baud) {
572 buf[0] = baud & 0xff; 574 buf[0] = baud & 0xff;
573 buf[1] = (baud >> 8) & 0xff; 575 buf[1] = (baud >> 8) & 0xff;
@@ -580,10 +582,10 @@ static void pl2303_set_termios(struct usb_serial_port *port,
580 /* For reference buf[4]=2 is 2 stop bits */ 582 /* For reference buf[4]=2 is 2 stop bits */
581 if (cflag & CSTOPB) { 583 if (cflag & CSTOPB) {
582 buf[4] = 2; 584 buf[4] = 2;
583 dbg("%s - stop bits = 2", __FUNCTION__); 585 dbg("%s - stop bits = 2", __func__);
584 } else { 586 } else {
585 buf[4] = 0; 587 buf[4] = 0;
586 dbg("%s - stop bits = 1", __FUNCTION__); 588 dbg("%s - stop bits = 1", __func__);
587 } 589 }
588 590
589 if (cflag & PARENB) { 591 if (cflag & PARENB) {
@@ -594,14 +596,14 @@ static void pl2303_set_termios(struct usb_serial_port *port,
594 /* For reference buf[5]=4 is space parity */ 596 /* For reference buf[5]=4 is space parity */
595 if (cflag & PARODD) { 597 if (cflag & PARODD) {
596 buf[5] = 1; 598 buf[5] = 1;
597 dbg("%s - parity = odd", __FUNCTION__); 599 dbg("%s - parity = odd", __func__);
598 } else { 600 } else {
599 buf[5] = 2; 601 buf[5] = 2;
600 dbg("%s - parity = even", __FUNCTION__); 602 dbg("%s - parity = even", __func__);
601 } 603 }
602 } else { 604 } else {
603 buf[5] = 0; 605 buf[5] = 0;
604 dbg("%s - parity = none", __FUNCTION__); 606 dbg("%s - parity = none", __func__);
605 } 607 }
606 608
607 i = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 609 i = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
@@ -657,7 +659,7 @@ static void pl2303_close(struct usb_serial_port *port, struct file *filp)
657 long timeout; 659 long timeout;
658 wait_queue_t wait; 660 wait_queue_t wait;
659 661
660 dbg("%s - port %d", __FUNCTION__, port->number); 662 dbg("%s - port %d", __func__, port->number);
661 663
662 /* wait for data to drain from the buffer */ 664 /* wait for data to drain from the buffer */
663 spin_lock_irqsave(&priv->lock, flags); 665 spin_lock_irqsave(&priv->lock, flags);
@@ -695,7 +697,7 @@ static void pl2303_close(struct usb_serial_port *port, struct file *filp)
695 schedule_timeout_interruptible(timeout); 697 schedule_timeout_interruptible(timeout);
696 698
697 /* shutdown our urbs */ 699 /* shutdown our urbs */
698 dbg("%s - shutting down urbs", __FUNCTION__); 700 dbg("%s - shutting down urbs", __func__);
699 usb_kill_urb(port->write_urb); 701 usb_kill_urb(port->write_urb);
700 usb_kill_urb(port->read_urb); 702 usb_kill_urb(port->read_urb);
701 usb_kill_urb(port->interrupt_in_urb); 703 usb_kill_urb(port->interrupt_in_urb);
@@ -719,7 +721,7 @@ static int pl2303_open(struct usb_serial_port *port, struct file *filp)
719 struct pl2303_private *priv = usb_get_serial_port_data(port); 721 struct pl2303_private *priv = usb_get_serial_port_data(port);
720 int result; 722 int result;
721 723
722 dbg("%s - port %d", __FUNCTION__, port->number); 724 dbg("%s - port %d", __func__, port->number);
723 725
724 if (priv->type != HX) { 726 if (priv->type != HX) {
725 usb_clear_halt(serial->dev, port->write_urb->pipe); 727 usb_clear_halt(serial->dev, port->write_urb->pipe);
@@ -737,22 +739,22 @@ static int pl2303_open(struct usb_serial_port *port, struct file *filp)
737 739
738 //FIXME: need to assert RTS and DTR if CRTSCTS off 740 //FIXME: need to assert RTS and DTR if CRTSCTS off
739 741
740 dbg("%s - submitting read urb", __FUNCTION__); 742 dbg("%s - submitting read urb", __func__);
741 port->read_urb->dev = serial->dev; 743 port->read_urb->dev = serial->dev;
742 result = usb_submit_urb(port->read_urb, GFP_KERNEL); 744 result = usb_submit_urb(port->read_urb, GFP_KERNEL);
743 if (result) { 745 if (result) {
744 dev_err(&port->dev, "%s - failed submitting read urb," 746 dev_err(&port->dev, "%s - failed submitting read urb,"
745 " error %d\n", __FUNCTION__, result); 747 " error %d\n", __func__, result);
746 pl2303_close(port, NULL); 748 pl2303_close(port, NULL);
747 return -EPROTO; 749 return -EPROTO;
748 } 750 }
749 751
750 dbg("%s - submitting interrupt urb", __FUNCTION__); 752 dbg("%s - submitting interrupt urb", __func__);
751 port->interrupt_in_urb->dev = serial->dev; 753 port->interrupt_in_urb->dev = serial->dev;
752 result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); 754 result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
753 if (result) { 755 if (result) {
754 dev_err(&port->dev, "%s - failed submitting interrupt urb," 756 dev_err(&port->dev, "%s - failed submitting interrupt urb,"
755 " error %d\n", __FUNCTION__, result); 757 " error %d\n", __func__, result);
756 pl2303_close(port, NULL); 758 pl2303_close(port, NULL);
757 return -EPROTO; 759 return -EPROTO;
758 } 760 }
@@ -792,7 +794,7 @@ static int pl2303_tiocmget(struct usb_serial_port *port, struct file *file)
792 unsigned int status; 794 unsigned int status;
793 unsigned int result; 795 unsigned int result;
794 796
795 dbg("%s (%d)", __FUNCTION__, port->number); 797 dbg("%s (%d)", __func__, port->number);
796 798
797 if (!usb_get_intfdata(port->serial->interface)) 799 if (!usb_get_intfdata(port->serial->interface))
798 return -ENODEV; 800 return -ENODEV;
@@ -809,7 +811,7 @@ static int pl2303_tiocmget(struct usb_serial_port *port, struct file *file)
809 | ((status & UART_RING) ? TIOCM_RI : 0) 811 | ((status & UART_RING) ? TIOCM_RI : 0)
810 | ((status & UART_DCD) ? TIOCM_CD : 0); 812 | ((status & UART_DCD) ? TIOCM_CD : 0);
811 813
812 dbg("%s - result = %x", __FUNCTION__, result); 814 dbg("%s - result = %x", __func__, result);
813 815
814 return result; 816 return result;
815} 817}
@@ -853,15 +855,15 @@ static int wait_modem_info(struct usb_serial_port *port, unsigned int arg)
853static int pl2303_ioctl(struct usb_serial_port *port, struct file *file, 855static int pl2303_ioctl(struct usb_serial_port *port, struct file *file,
854 unsigned int cmd, unsigned long arg) 856 unsigned int cmd, unsigned long arg)
855{ 857{
856 dbg("%s (%d) cmd = 0x%04x", __FUNCTION__, port->number, cmd); 858 dbg("%s (%d) cmd = 0x%04x", __func__, port->number, cmd);
857 859
858 switch (cmd) { 860 switch (cmd) {
859 case TIOCMIWAIT: 861 case TIOCMIWAIT:
860 dbg("%s (%d) TIOCMIWAIT", __FUNCTION__, port->number); 862 dbg("%s (%d) TIOCMIWAIT", __func__, port->number);
861 return wait_modem_info(port, arg); 863 return wait_modem_info(port, arg);
862 864
863 default: 865 default:
864 dbg("%s not supported = 0x%04x", __FUNCTION__, cmd); 866 dbg("%s not supported = 0x%04x", __func__, cmd);
865 break; 867 break;
866 } 868 }
867 869
@@ -874,19 +876,19 @@ static void pl2303_break_ctl(struct usb_serial_port *port, int break_state)
874 u16 state; 876 u16 state;
875 int result; 877 int result;
876 878
877 dbg("%s - port %d", __FUNCTION__, port->number); 879 dbg("%s - port %d", __func__, port->number);
878 880
879 if (break_state == 0) 881 if (break_state == 0)
880 state = BREAK_OFF; 882 state = BREAK_OFF;
881 else 883 else
882 state = BREAK_ON; 884 state = BREAK_ON;
883 dbg("%s - turning break %s", __FUNCTION__, state==BREAK_OFF ? "off" : "on"); 885 dbg("%s - turning break %s", __func__, state==BREAK_OFF ? "off" : "on");
884 886
885 result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 887 result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
886 BREAK_REQUEST, BREAK_REQUEST_TYPE, state, 888 BREAK_REQUEST, BREAK_REQUEST_TYPE, state,
887 0, NULL, 0, 100); 889 0, NULL, 0, 100);
888 if (result) 890 if (result)
889 dbg("%s - error sending break = %d", __FUNCTION__, result); 891 dbg("%s - error sending break = %d", __func__, result);
890} 892}
891 893
892static void pl2303_shutdown(struct usb_serial *serial) 894static void pl2303_shutdown(struct usb_serial *serial)
@@ -894,7 +896,7 @@ static void pl2303_shutdown(struct usb_serial *serial)
894 int i; 896 int i;
895 struct pl2303_private *priv; 897 struct pl2303_private *priv;
896 898
897 dbg("%s", __FUNCTION__); 899 dbg("%s", __func__);
898 900
899 for (i = 0; i < serial->num_ports; ++i) { 901 for (i = 0; i < serial->num_ports; ++i) {
900 priv = usb_get_serial_port_data(serial->port[i]); 902 priv = usb_get_serial_port_data(serial->port[i]);
@@ -943,13 +945,13 @@ static void pl2303_update_line_status(struct usb_serial_port *port,
943 945
944static void pl2303_read_int_callback(struct urb *urb) 946static void pl2303_read_int_callback(struct urb *urb)
945{ 947{
946 struct usb_serial_port *port = (struct usb_serial_port *) urb->context; 948 struct usb_serial_port *port = urb->context;
947 unsigned char *data = urb->transfer_buffer; 949 unsigned char *data = urb->transfer_buffer;
948 unsigned int actual_length = urb->actual_length; 950 unsigned int actual_length = urb->actual_length;
949 int status = urb->status; 951 int status = urb->status;
950 int retval; 952 int retval;
951 953
952 dbg("%s (%d)", __FUNCTION__, port->number); 954 dbg("%s (%d)", __func__, port->number);
953 955
954 switch (status) { 956 switch (status) {
955 case 0: 957 case 0:
@@ -959,16 +961,16 @@ static void pl2303_read_int_callback(struct urb *urb)
959 case -ENOENT: 961 case -ENOENT:
960 case -ESHUTDOWN: 962 case -ESHUTDOWN:
961 /* this urb is terminated, clean up */ 963 /* this urb is terminated, clean up */
962 dbg("%s - urb shutting down with status: %d", __FUNCTION__, 964 dbg("%s - urb shutting down with status: %d", __func__,
963 status); 965 status);
964 return; 966 return;
965 default: 967 default:
966 dbg("%s - nonzero urb status received: %d", __FUNCTION__, 968 dbg("%s - nonzero urb status received: %d", __func__,
967 status); 969 status);
968 goto exit; 970 goto exit;
969 } 971 }
970 972
971 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, 973 usb_serial_debug_data(debug, &port->dev, __func__,
972 urb->actual_length, urb->transfer_buffer); 974 urb->actual_length, urb->transfer_buffer);
973 975
974 pl2303_update_line_status(port, data, actual_length); 976 pl2303_update_line_status(port, data, actual_length);
@@ -978,12 +980,12 @@ exit:
978 if (retval) 980 if (retval)
979 dev_err(&urb->dev->dev, 981 dev_err(&urb->dev->dev,
980 "%s - usb_submit_urb failed with result %d\n", 982 "%s - usb_submit_urb failed with result %d\n",
981 __FUNCTION__, retval); 983 __func__, retval);
982} 984}
983 985
984static void pl2303_read_bulk_callback(struct urb *urb) 986static void pl2303_read_bulk_callback(struct urb *urb)
985{ 987{
986 struct usb_serial_port *port = (struct usb_serial_port *) urb->context; 988 struct usb_serial_port *port = urb->context;
987 struct pl2303_private *priv = usb_get_serial_port_data(port); 989 struct pl2303_private *priv = usb_get_serial_port_data(port);
988 struct tty_struct *tty; 990 struct tty_struct *tty;
989 unsigned char *data = urb->transfer_buffer; 991 unsigned char *data = urb->transfer_buffer;
@@ -994,32 +996,32 @@ static void pl2303_read_bulk_callback(struct urb *urb)
994 u8 line_status; 996 u8 line_status;
995 char tty_flag; 997 char tty_flag;
996 998
997 dbg("%s - port %d", __FUNCTION__, port->number); 999 dbg("%s - port %d", __func__, port->number);
998 1000
999 if (status) { 1001 if (status) {
1000 dbg("%s - urb status = %d", __FUNCTION__, status); 1002 dbg("%s - urb status = %d", __func__, status);
1001 if (!port->open_count) { 1003 if (!port->open_count) {
1002 dbg("%s - port is closed, exiting.", __FUNCTION__); 1004 dbg("%s - port is closed, exiting.", __func__);
1003 return; 1005 return;
1004 } 1006 }
1005 if (status == -EPROTO) { 1007 if (status == -EPROTO) {
1006 /* PL2303 mysteriously fails with -EPROTO reschedule 1008 /* PL2303 mysteriously fails with -EPROTO reschedule
1007 * the read */ 1009 * the read */
1008 dbg("%s - caught -EPROTO, resubmitting the urb", 1010 dbg("%s - caught -EPROTO, resubmitting the urb",
1009 __FUNCTION__); 1011 __func__);
1010 urb->dev = port->serial->dev; 1012 urb->dev = port->serial->dev;
1011 result = usb_submit_urb(urb, GFP_ATOMIC); 1013 result = usb_submit_urb(urb, GFP_ATOMIC);
1012 if (result) 1014 if (result)
1013 dev_err(&urb->dev->dev, "%s - failed" 1015 dev_err(&urb->dev->dev, "%s - failed"
1014 " resubmitting read urb, error %d\n", 1016 " resubmitting read urb, error %d\n",
1015 __FUNCTION__, result); 1017 __func__, result);
1016 return; 1018 return;
1017 } 1019 }
1018 dbg("%s - unable to handle the error, exiting.", __FUNCTION__); 1020 dbg("%s - unable to handle the error, exiting.", __func__);
1019 return; 1021 return;
1020 } 1022 }
1021 1023
1022 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, 1024 usb_serial_debug_data(debug, &port->dev, __func__,
1023 urb->actual_length, data); 1025 urb->actual_length, data);
1024 1026
1025 /* get tty_flag from status */ 1027 /* get tty_flag from status */
@@ -1039,7 +1041,7 @@ static void pl2303_read_bulk_callback(struct urb *urb)
1039 tty_flag = TTY_PARITY; 1041 tty_flag = TTY_PARITY;
1040 else if (line_status & UART_FRAME_ERROR) 1042 else if (line_status & UART_FRAME_ERROR)
1041 tty_flag = TTY_FRAME; 1043 tty_flag = TTY_FRAME;
1042 dbg("%s - tty_flag = %d", __FUNCTION__, tty_flag); 1044 dbg("%s - tty_flag = %d", __func__, tty_flag);
1043 1045
1044 tty = port->tty; 1046 tty = port->tty;
1045 if (tty && urb->actual_length) { 1047 if (tty && urb->actual_length) {
@@ -1058,7 +1060,7 @@ static void pl2303_read_bulk_callback(struct urb *urb)
1058 result = usb_submit_urb(urb, GFP_ATOMIC); 1060 result = usb_submit_urb(urb, GFP_ATOMIC);
1059 if (result) 1061 if (result)
1060 dev_err(&urb->dev->dev, "%s - failed resubmitting" 1062 dev_err(&urb->dev->dev, "%s - failed resubmitting"
1061 " read urb, error %d\n", __FUNCTION__, result); 1063 " read urb, error %d\n", __func__, result);
1062 } 1064 }
1063 1065
1064 return; 1066 return;
@@ -1066,12 +1068,12 @@ static void pl2303_read_bulk_callback(struct urb *urb)
1066 1068
1067static void pl2303_write_bulk_callback(struct urb *urb) 1069static void pl2303_write_bulk_callback(struct urb *urb)
1068{ 1070{
1069 struct usb_serial_port *port = (struct usb_serial_port *) urb->context; 1071 struct usb_serial_port *port = urb->context;
1070 struct pl2303_private *priv = usb_get_serial_port_data(port); 1072 struct pl2303_private *priv = usb_get_serial_port_data(port);
1071 int result; 1073 int result;
1072 int status = urb->status; 1074 int status = urb->status;
1073 1075
1074 dbg("%s - port %d", __FUNCTION__, port->number); 1076 dbg("%s - port %d", __func__, port->number);
1075 1077
1076 switch (status) { 1078 switch (status) {
1077 case 0: 1079 case 0:
@@ -1081,21 +1083,21 @@ static void pl2303_write_bulk_callback(struct urb *urb)
1081 case -ENOENT: 1083 case -ENOENT:
1082 case -ESHUTDOWN: 1084 case -ESHUTDOWN:
1083 /* this urb is terminated, clean up */ 1085 /* this urb is terminated, clean up */
1084 dbg("%s - urb shutting down with status: %d", __FUNCTION__, 1086 dbg("%s - urb shutting down with status: %d", __func__,
1085 status); 1087 status);
1086 priv->write_urb_in_use = 0; 1088 priv->write_urb_in_use = 0;
1087 return; 1089 return;
1088 default: 1090 default:
1089 /* error in the urb, so we have to resubmit it */ 1091 /* error in the urb, so we have to resubmit it */
1090 dbg("%s - Overflow in write", __FUNCTION__); 1092 dbg("%s - Overflow in write", __func__);
1091 dbg("%s - nonzero write bulk status received: %d", __FUNCTION__, 1093 dbg("%s - nonzero write bulk status received: %d", __func__,
1092 status); 1094 status);
1093 port->write_urb->transfer_buffer_length = 1; 1095 port->write_urb->transfer_buffer_length = 1;
1094 port->write_urb->dev = port->serial->dev; 1096 port->write_urb->dev = port->serial->dev;
1095 result = usb_submit_urb(port->write_urb, GFP_ATOMIC); 1097 result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
1096 if (result) 1098 if (result)
1097 dev_err(&urb->dev->dev, "%s - failed resubmitting write" 1099 dev_err(&urb->dev->dev, "%s - failed resubmitting write"
1098 " urb, error %d\n", __FUNCTION__, result); 1100 " urb, error %d\n", __func__, result);
1099 else 1101 else
1100 return; 1102 return;
1101 } 1103 }
@@ -1114,9 +1116,6 @@ static struct usb_serial_driver pl2303_device = {
1114 }, 1116 },
1115 .id_table = id_table, 1117 .id_table = id_table,
1116 .usb_driver = &pl2303_driver, 1118 .usb_driver = &pl2303_driver,
1117 .num_interrupt_in = NUM_DONT_CARE,
1118 .num_bulk_in = 1,
1119 .num_bulk_out = 1,
1120 .num_ports = 1, 1119 .num_ports = 1,
1121 .open = pl2303_open, 1120 .open = pl2303_open,
1122 .close = pl2303_close, 1121 .close = pl2303_close,
diff --git a/drivers/usb/serial/safe_serial.c b/drivers/usb/serial/safe_serial.c
index 4e6dcc199be..94bddf06ea4 100644
--- a/drivers/usb/serial/safe_serial.c
+++ b/drivers/usb/serial/safe_serial.c
@@ -195,18 +195,17 @@ static __u16 __inline__ fcs_compute10 (unsigned char *sp, int len, __u16 fcs)
195 195
196static void safe_read_bulk_callback (struct urb *urb) 196static void safe_read_bulk_callback (struct urb *urb)
197{ 197{
198 struct usb_serial_port *port = (struct usb_serial_port *) urb->context; 198 struct usb_serial_port *port = urb->context;
199 unsigned char *data = urb->transfer_buffer; 199 unsigned char *data = urb->transfer_buffer;
200 unsigned char length = urb->actual_length; 200 unsigned char length = urb->actual_length;
201 int i;
202 int result; 201 int result;
203 int status = urb->status; 202 int status = urb->status;
204 203
205 dbg ("%s", __FUNCTION__); 204 dbg ("%s", __func__);
206 205
207 if (status) { 206 if (status) {
208 dbg("%s - nonzero read bulk status received: %d", 207 dbg("%s - nonzero read bulk status received: %d",
209 __FUNCTION__, status); 208 __func__, status);
210 return; 209 return;
211 } 210 }
212 211
@@ -227,28 +226,20 @@ static void safe_read_bulk_callback (struct urb *urb)
227 if (safe) { 226 if (safe) {
228 __u16 fcs; 227 __u16 fcs;
229 if (!(fcs = fcs_compute10 (data, length, CRC10_INITFCS))) { 228 if (!(fcs = fcs_compute10 (data, length, CRC10_INITFCS))) {
230
231 int actual_length = data[length - 2] >> 2; 229 int actual_length = data[length - 2] >> 2;
232
233 if (actual_length <= (length - 2)) { 230 if (actual_length <= (length - 2)) {
234 231 info ("%s - actual: %d", __func__, actual_length);
235 info ("%s - actual: %d", __FUNCTION__, actual_length); 232 tty_insert_flip_string(port->tty, data, actual_length);
236
237 for (i = 0; i < actual_length; i++) {
238 tty_insert_flip_char (port->tty, data[i], 0);
239 }
240 tty_flip_buffer_push (port->tty); 233 tty_flip_buffer_push (port->tty);
241 } else { 234 } else {
242 err ("%s - inconsistent lengths %d:%d", __FUNCTION__, 235 err ("%s - inconsistent lengths %d:%d", __func__,
243 actual_length, length); 236 actual_length, length);
244 } 237 }
245 } else { 238 } else {
246 err ("%s - bad CRC %x", __FUNCTION__, fcs); 239 err ("%s - bad CRC %x", __func__, fcs);
247 } 240 }
248 } else { 241 } else {
249 for (i = 0; i < length; i++) { 242 tty_insert_flip_string(port->tty, data, length);
250 tty_insert_flip_char (port->tty, data[i], 0);
251 }
252 tty_flip_buffer_push (port->tty); 243 tty_flip_buffer_push (port->tty);
253 } 244 }
254 245
@@ -259,7 +250,8 @@ static void safe_read_bulk_callback (struct urb *urb)
259 safe_read_bulk_callback, port); 250 safe_read_bulk_callback, port);
260 251
261 if ((result = usb_submit_urb (urb, GFP_ATOMIC))) { 252 if ((result = usb_submit_urb (urb, GFP_ATOMIC))) {
262 err ("%s - failed resubmitting read urb, error %d", __FUNCTION__, result); 253 err ("%s - failed resubmitting read urb, error %d", __func__, result);
254 /* FIXME: Need a mechanism to retry later if this happens */
263 } 255 }
264} 256}
265 257
@@ -274,25 +266,25 @@ static int safe_write (struct usb_serial_port *port, const unsigned char *buf, i
274 count); 266 count);
275 267
276 if (!port->write_urb) { 268 if (!port->write_urb) {
277 dbg ("%s - write urb NULL", __FUNCTION__); 269 dbg ("%s - write urb NULL", __func__);
278 return (0); 270 return 0;
279 } 271 }
280 272
281 dbg ("safe_write write_urb: %d transfer_buffer_length", 273 dbg ("safe_write write_urb: %d transfer_buffer_length",
282 port->write_urb->transfer_buffer_length); 274 port->write_urb->transfer_buffer_length);
283 275
284 if (!port->write_urb->transfer_buffer_length) { 276 if (!port->write_urb->transfer_buffer_length) {
285 dbg ("%s - write urb transfer_buffer_length zero", __FUNCTION__); 277 dbg ("%s - write urb transfer_buffer_length zero", __func__);
286 return (0); 278 return 0;
287 } 279 }
288 if (count == 0) { 280 if (count == 0) {
289 dbg ("%s - write request of 0 bytes", __FUNCTION__); 281 dbg ("%s - write request of 0 bytes", __func__);
290 return (0); 282 return 0;
291 } 283 }
292 spin_lock_bh(&port->lock); 284 spin_lock_bh(&port->lock);
293 if (port->write_urb_busy) { 285 if (port->write_urb_busy) {
294 spin_unlock_bh(&port->lock); 286 spin_unlock_bh(&port->lock);
295 dbg("%s - already writing", __FUNCTION__); 287 dbg("%s - already writing", __func__);
296 return 0; 288 return 0;
297 } 289 }
298 port->write_urb_busy = 1; 290 port->write_urb_busy = 1;
@@ -332,7 +324,7 @@ static int safe_write (struct usb_serial_port *port, const unsigned char *buf, i
332 port->write_urb->transfer_buffer_length = count; 324 port->write_urb->transfer_buffer_length = count;
333 } 325 }
334 326
335 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count, port->write_urb->transfer_buffer); 327 usb_serial_debug_data(debug, &port->dev, __func__, count, port->write_urb->transfer_buffer);
336#ifdef ECHO_TX 328#ifdef ECHO_TX
337 { 329 {
338 int i; 330 int i;
@@ -349,28 +341,31 @@ static int safe_write (struct usb_serial_port *port, const unsigned char *buf, i
349 port->write_urb->dev = port->serial->dev; 341 port->write_urb->dev = port->serial->dev;
350 if ((result = usb_submit_urb (port->write_urb, GFP_KERNEL))) { 342 if ((result = usb_submit_urb (port->write_urb, GFP_KERNEL))) {
351 port->write_urb_busy = 0; 343 port->write_urb_busy = 0;
352 err ("%s - failed submitting write urb, error %d", __FUNCTION__, result); 344 err ("%s - failed submitting write urb, error %d", __func__, result);
353 return 0; 345 return 0;
354 } 346 }
355 dbg ("%s urb: %p submitted", __FUNCTION__, port->write_urb); 347 dbg ("%s urb: %p submitted", __func__, port->write_urb);
356 348
357 return (count); 349 return (count);
358} 350}
359 351
360static int safe_write_room (struct usb_serial_port *port) 352static int safe_write_room (struct usb_serial_port *port)
361{ 353{
362 int room = 0; // Default: no room 354 int room = 0; /* Default: no room */
355 unsigned long flags;
363 356
364 dbg ("%s", __FUNCTION__); 357 dbg ("%s", __func__);
365 358
359 spin_lock_irqsave(&port->lock, flags);
366 if (port->write_urb_busy) 360 if (port->write_urb_busy)
367 room = port->bulk_out_size - (safe ? 2 : 0); 361 room = port->bulk_out_size - (safe ? 2 : 0);
362 spin_unlock_irqrestore(&port->lock, flags);
368 363
369 if (room) { 364 if (room) {
370 dbg ("safe_write_room returns %d", room); 365 dbg ("safe_write_room returns %d", room);
371 } 366 }
372 367
373 return (room); 368 return room;
374} 369}
375 370
376static int safe_startup (struct usb_serial *serial) 371static int safe_startup (struct usb_serial *serial)
@@ -394,9 +389,6 @@ static struct usb_serial_driver safe_device = {
394 }, 389 },
395 .id_table = id_table, 390 .id_table = id_table,
396 .usb_driver = &safe_driver, 391 .usb_driver = &safe_driver,
397 .num_interrupt_in = NUM_DONT_CARE,
398 .num_bulk_in = NUM_DONT_CARE,
399 .num_bulk_out = NUM_DONT_CARE,
400 .num_ports = 1, 392 .num_ports = 1,
401 .write = safe_write, 393 .write = safe_write,
402 .write_room = safe_write_room, 394 .write_room = safe_write_room,
diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c
index ed678811e6a..29074c1ba22 100644
--- a/drivers/usb/serial/sierra.c
+++ b/drivers/usb/serial/sierra.c
@@ -1,7 +1,7 @@
1/* 1/*
2 USB Driver for Sierra Wireless 2 USB Driver for Sierra Wireless
3 3
4 Copyright (C) 2006, 2007, 2008 Kevin Lloyd <linux@sierrawireless.com> 4 Copyright (C) 2006, 2007, 2008 Kevin Lloyd <klloyd@sierrawireless.com>
5 5
6 IMPORTANT DISCLAIMER: This driver is not commercially supported by 6 IMPORTANT DISCLAIMER: This driver is not commercially supported by
7 Sierra Wireless. Use at your own risk. 7 Sierra Wireless. Use at your own risk.
@@ -14,8 +14,8 @@
14 Whom based his on the Keyspan driver by Hugh Blemings <hugh@blemings.org> 14 Whom based his on the Keyspan driver by Hugh Blemings <hugh@blemings.org>
15*/ 15*/
16 16
17#define DRIVER_VERSION "v.1.2.8" 17#define DRIVER_VERSION "v.1.2.9c"
18#define DRIVER_AUTHOR "Kevin Lloyd <linux@sierrawireless.com>" 18#define DRIVER_AUTHOR "Kevin Lloyd <klloyd@sierrawireless.com>"
19#define DRIVER_DESC "USB Driver for Sierra Wireless USB modems" 19#define DRIVER_DESC "USB Driver for Sierra Wireless USB modems"
20 20
21#include <linux/kernel.h> 21#include <linux/kernel.h>
@@ -31,7 +31,6 @@
31#define SWIMS_USB_REQUEST_SetPower 0x00 31#define SWIMS_USB_REQUEST_SetPower 0x00
32#define SWIMS_USB_REQUEST_SetNmea 0x07 32#define SWIMS_USB_REQUEST_SetNmea 0x07
33#define SWIMS_USB_REQUEST_SetMode 0x0B 33#define SWIMS_USB_REQUEST_SetMode 0x0B
34#define SWIMS_USB_REQUEST_TYPE_VSC_SET 0x40
35#define SWIMS_SET_MODE_Modem 0x0001 34#define SWIMS_SET_MODE_Modem 0x0001
36 35
37/* per port private data */ 36/* per port private data */
@@ -55,7 +54,7 @@ static int sierra_set_power_state(struct usb_device *udev, __u16 swiState)
55 dev_dbg(&udev->dev, "%s", "SET POWER STATE\n"); 54 dev_dbg(&udev->dev, "%s", "SET POWER STATE\n");
56 result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 55 result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
57 SWIMS_USB_REQUEST_SetPower, /* __u8 request */ 56 SWIMS_USB_REQUEST_SetPower, /* __u8 request */
58 SWIMS_USB_REQUEST_TYPE_VSC_SET, /* __u8 request type */ 57 USB_TYPE_VENDOR, /* __u8 request type */
59 swiState, /* __u16 value */ 58 swiState, /* __u16 value */
60 0, /* __u16 index */ 59 0, /* __u16 index */
61 NULL, /* void *data */ 60 NULL, /* void *data */
@@ -70,7 +69,7 @@ static int sierra_set_ms_mode(struct usb_device *udev, __u16 eSWocMode)
70 dev_dbg(&udev->dev, "%s", "DEVICE MODE SWITCH\n"); 69 dev_dbg(&udev->dev, "%s", "DEVICE MODE SWITCH\n");
71 result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 70 result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
72 SWIMS_USB_REQUEST_SetMode, /* __u8 request */ 71 SWIMS_USB_REQUEST_SetMode, /* __u8 request */
73 SWIMS_USB_REQUEST_TYPE_VSC_SET, /* __u8 request type */ 72 USB_TYPE_VENDOR, /* __u8 request type */
74 eSWocMode, /* __u16 value */ 73 eSWocMode, /* __u16 value */
75 0x0000, /* __u16 index */ 74 0x0000, /* __u16 index */
76 NULL, /* void *data */ 75 NULL, /* void *data */
@@ -85,7 +84,7 @@ static int sierra_vsc_set_nmea(struct usb_device *udev, __u16 enable)
85 dev_dbg(&udev->dev, "%s", "NMEA Enable sent\n"); 84 dev_dbg(&udev->dev, "%s", "NMEA Enable sent\n");
86 result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 85 result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
87 SWIMS_USB_REQUEST_SetNmea, /* __u8 request */ 86 SWIMS_USB_REQUEST_SetNmea, /* __u8 request */
88 SWIMS_USB_REQUEST_TYPE_VSC_SET, /* __u8 request type */ 87 USB_TYPE_VENDOR, /* __u8 request type */
89 enable, /* __u16 value */ 88 enable, /* __u16 value */
90 0x0000, /* __u16 index */ 89 0x0000, /* __u16 index */
91 NULL, /* void *data */ 90 NULL, /* void *data */
@@ -109,6 +108,26 @@ static int sierra_calc_num_ports(struct usb_serial *serial)
109 return result; 108 return result;
110} 109}
111 110
111static int sierra_calc_interface(struct usb_serial *serial)
112{
113 int interface;
114 struct usb_interface *p_interface;
115 struct usb_host_interface *p_host_interface;
116
117 /* Get the interface structure pointer from the serial struct */
118 p_interface = serial->interface;
119
120 /* Get a pointer to the host interface structure */
121 p_host_interface = p_interface->cur_altsetting;
122
123 /* read the interface descriptor for this active altsetting
124 * to find out the interface number we are on
125 */
126 interface = p_host_interface->desc.bInterfaceNumber;
127
128 return interface;
129}
130
112static int sierra_probe(struct usb_serial *serial, 131static int sierra_probe(struct usb_serial *serial,
113 const struct usb_device_id *id) 132 const struct usb_device_id *id)
114{ 133{
@@ -124,6 +143,22 @@ static int sierra_probe(struct usb_serial *serial,
124 ifnum = serial->interface->cur_altsetting->desc.bInterfaceNumber; 143 ifnum = serial->interface->cur_altsetting->desc.bInterfaceNumber;
125 udev = serial->dev; 144 udev = serial->dev;
126 145
146 /* Figure out the interface number from the serial structure */
147 ifnum = sierra_calc_interface(serial);
148
149 /*
150 * If this interface supports more than 1 alternate
151 * select the 2nd one
152 */
153 if (serial->interface->num_altsetting == 2) {
154 dev_dbg(&udev->dev,
155 "Selecting alt setting for interface %d\n",
156 ifnum);
157
158 /* We know the alternate setting is 1 for the MC8785 */
159 usb_set_interface(udev, ifnum, 1);
160 }
161
127 /* Check if in installer mode */ 162 /* Check if in installer mode */
128 if (truinstall && id->driver_info == DEVICE_INSTALLER) { 163 if (truinstall && id->driver_info == DEVICE_INSTALLER) {
129 dev_dbg(&udev->dev, "%s", "FOUND TRU-INSTALL DEVICE(SW)\n"); 164 dev_dbg(&udev->dev, "%s", "FOUND TRU-INSTALL DEVICE(SW)\n");
@@ -156,7 +191,7 @@ static struct usb_device_id id_table [] = {
156 { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */ 191 { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */
157 { USB_DEVICE(0x1199, 0x0021) }, /* Sierra Wireless AirCard 597E */ 192 { USB_DEVICE(0x1199, 0x0021) }, /* Sierra Wireless AirCard 597E */
158 { USB_DEVICE(0x1199, 0x0120) }, /* Sierra Wireless USB Dongle 595U */ 193 { USB_DEVICE(0x1199, 0x0120) }, /* Sierra Wireless USB Dongle 595U */
159 { USB_DEVICE(0x1199, 0x0023) }, /* Sierra Wireless AirCard */ 194 { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x0023, 0xFF, 0xFF, 0xFF) }, /* Sierra Wireless C597 */
160 195
161 { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */ 196 { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */
162 { USB_DEVICE(0x1199, 0x6804) }, /* Sierra Wireless MC8755 */ 197 { USB_DEVICE(0x1199, 0x6804) }, /* Sierra Wireless MC8755 */
@@ -164,15 +199,20 @@ static struct usb_device_id id_table [] = {
164 { USB_DEVICE(0x1199, 0x6812) }, /* Sierra Wireless MC8775 & AC 875U */ 199 { USB_DEVICE(0x1199, 0x6812) }, /* Sierra Wireless MC8775 & AC 875U */
165 { USB_DEVICE(0x1199, 0x6813) }, /* Sierra Wireless MC8775 (Thinkpad internal) */ 200 { USB_DEVICE(0x1199, 0x6813) }, /* Sierra Wireless MC8775 (Thinkpad internal) */
166 { USB_DEVICE(0x1199, 0x6815) }, /* Sierra Wireless MC8775 */ 201 { USB_DEVICE(0x1199, 0x6815) }, /* Sierra Wireless MC8775 */
202 { USB_DEVICE(0x03f0, 0x1e1d) }, /* HP hs2300 a.k.a MC8775 */
167 { USB_DEVICE(0x1199, 0x6820) }, /* Sierra Wireless AirCard 875 */ 203 { USB_DEVICE(0x1199, 0x6820) }, /* Sierra Wireless AirCard 875 */
204 { USB_DEVICE(0x1199, 0x6821) }, /* Sierra Wireless AirCard 875U */
168 { USB_DEVICE(0x1199, 0x6832) }, /* Sierra Wireless MC8780*/ 205 { USB_DEVICE(0x1199, 0x6832) }, /* Sierra Wireless MC8780*/
169 { USB_DEVICE(0x1199, 0x6833) }, /* Sierra Wireless MC8781*/ 206 { USB_DEVICE(0x1199, 0x6833) }, /* Sierra Wireless MC8781*/
207 { USB_DEVICE(0x1199, 0x683B), .driver_info = DEVICE_1_PORT }, /* Sierra Wireless MC8785 Composite*/
170 { USB_DEVICE(0x1199, 0x6850) }, /* Sierra Wireless AirCard 880 */ 208 { USB_DEVICE(0x1199, 0x6850) }, /* Sierra Wireless AirCard 880 */
171 { USB_DEVICE(0x1199, 0x6851) }, /* Sierra Wireless AirCard 881 */ 209 { USB_DEVICE(0x1199, 0x6851) }, /* Sierra Wireless AirCard 881 */
172 { USB_DEVICE(0x1199, 0x6852) }, /* Sierra Wireless AirCard 880 E */ 210 { USB_DEVICE(0x1199, 0x6852) }, /* Sierra Wireless AirCard 880 E */
173 { USB_DEVICE(0x1199, 0x6853) }, /* Sierra Wireless AirCard 881 E */ 211 { USB_DEVICE(0x1199, 0x6853) }, /* Sierra Wireless AirCard 881 E */
174 { USB_DEVICE(0x1199, 0x6855) }, /* Sierra Wireless AirCard 880 U */ 212 { USB_DEVICE(0x1199, 0x6855) }, /* Sierra Wireless AirCard 880 U */
175 { USB_DEVICE(0x1199, 0x6856) }, /* Sierra Wireless AirCard 881 U */ 213 { USB_DEVICE(0x1199, 0x6856) }, /* Sierra Wireless AirCard 881 U */
214 { USB_DEVICE(0x1199, 0x6859), .driver_info = DEVICE_1_PORT }, /* Sierra Wireless AirCard 885 E */
215 { USB_DEVICE(0x1199, 0x685A), .driver_info = DEVICE_1_PORT }, /* Sierra Wireless AirCard 885 E */
176 216
177 { USB_DEVICE(0x1199, 0x6468) }, /* Sierra Wireless MP3G - EVDO */ 217 { USB_DEVICE(0x1199, 0x6468) }, /* Sierra Wireless MP3G - EVDO */
178 { USB_DEVICE(0x1199, 0x6469) }, /* Sierra Wireless MP3G - UMTS/HSPA */ 218 { USB_DEVICE(0x1199, 0x6469) }, /* Sierra Wireless MP3G - UMTS/HSPA */
@@ -216,7 +256,7 @@ static int sierra_send_setup(struct usb_serial_port *port)
216 struct sierra_port_private *portdata; 256 struct sierra_port_private *portdata;
217 __u16 interface = 0; 257 __u16 interface = 0;
218 258
219 dbg("%s", __FUNCTION__); 259 dbg("%s", __func__);
220 260
221 portdata = usb_get_serial_port_data(port); 261 portdata = usb_get_serial_port_data(port);
222 262
@@ -246,24 +286,24 @@ static int sierra_send_setup(struct usb_serial_port *port)
246 286
247static void sierra_rx_throttle(struct usb_serial_port *port) 287static void sierra_rx_throttle(struct usb_serial_port *port)
248{ 288{
249 dbg("%s", __FUNCTION__); 289 dbg("%s", __func__);
250} 290}
251 291
252static void sierra_rx_unthrottle(struct usb_serial_port *port) 292static void sierra_rx_unthrottle(struct usb_serial_port *port)
253{ 293{
254 dbg("%s", __FUNCTION__); 294 dbg("%s", __func__);
255} 295}
256 296
257static void sierra_break_ctl(struct usb_serial_port *port, int break_state) 297static void sierra_break_ctl(struct usb_serial_port *port, int break_state)
258{ 298{
259 /* Unfortunately, I don't know how to send a break */ 299 /* Unfortunately, I don't know how to send a break */
260 dbg("%s", __FUNCTION__); 300 dbg("%s", __func__);
261} 301}
262 302
263static void sierra_set_termios(struct usb_serial_port *port, 303static void sierra_set_termios(struct usb_serial_port *port,
264 struct ktermios *old_termios) 304 struct ktermios *old_termios)
265{ 305{
266 dbg("%s", __FUNCTION__); 306 dbg("%s", __func__);
267 tty_termios_copy_hw(port->tty->termios, old_termios); 307 tty_termios_copy_hw(port->tty->termios, old_termios);
268 sierra_send_setup(port); 308 sierra_send_setup(port);
269} 309}
@@ -317,14 +357,14 @@ static void sierra_outdat_callback(struct urb *urb)
317 int status = urb->status; 357 int status = urb->status;
318 unsigned long flags; 358 unsigned long flags;
319 359
320 dbg("%s - port %d", __FUNCTION__, port->number); 360 dbg("%s - port %d", __func__, port->number);
321 361
322 /* free up the transfer buffer, as usb_free_urb() does not do this */ 362 /* free up the transfer buffer, as usb_free_urb() does not do this */
323 kfree(urb->transfer_buffer); 363 kfree(urb->transfer_buffer);
324 364
325 if (status) 365 if (status)
326 dbg("%s - nonzero write bulk status received: %d", 366 dbg("%s - nonzero write bulk status received: %d",
327 __FUNCTION__, status); 367 __func__, status);
328 368
329 spin_lock_irqsave(&portdata->lock, flags); 369 spin_lock_irqsave(&portdata->lock, flags);
330 --portdata->outstanding_urbs; 370 --portdata->outstanding_urbs;
@@ -346,12 +386,12 @@ static int sierra_write(struct usb_serial_port *port,
346 386
347 portdata = usb_get_serial_port_data(port); 387 portdata = usb_get_serial_port_data(port);
348 388
349 dbg("%s: write (%d chars)", __FUNCTION__, count); 389 dbg("%s: write (%d chars)", __func__, count);
350 390
351 spin_lock_irqsave(&portdata->lock, flags); 391 spin_lock_irqsave(&portdata->lock, flags);
352 if (portdata->outstanding_urbs > N_OUT_URB) { 392 if (portdata->outstanding_urbs > N_OUT_URB) {
353 spin_unlock_irqrestore(&portdata->lock, flags); 393 spin_unlock_irqrestore(&portdata->lock, flags);
354 dbg("%s - write limit hit\n", __FUNCTION__); 394 dbg("%s - write limit hit\n", __func__);
355 return 0; 395 return 0;
356 } 396 }
357 portdata->outstanding_urbs++; 397 portdata->outstanding_urbs++;
@@ -373,7 +413,7 @@ static int sierra_write(struct usb_serial_port *port,
373 413
374 memcpy(buffer, buf, count); 414 memcpy(buffer, buf, count);
375 415
376 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count, buffer); 416 usb_serial_debug_data(debug, &port->dev, __func__, count, buffer);
377 417
378 usb_fill_bulk_urb(urb, serial->dev, 418 usb_fill_bulk_urb(urb, serial->dev,
379 usb_sndbulkpipe(serial->dev, 419 usb_sndbulkpipe(serial->dev,
@@ -384,7 +424,7 @@ static int sierra_write(struct usb_serial_port *port,
384 status = usb_submit_urb(urb, GFP_ATOMIC); 424 status = usb_submit_urb(urb, GFP_ATOMIC);
385 if (status) { 425 if (status) {
386 dev_err(&port->dev, "%s - usb_submit_urb(write bulk) failed " 426 dev_err(&port->dev, "%s - usb_submit_urb(write bulk) failed "
387 "with status = %d\n", __FUNCTION__, status); 427 "with status = %d\n", __func__, status);
388 count = status; 428 count = status;
389 goto error; 429 goto error;
390 } 430 }
@@ -414,14 +454,14 @@ static void sierra_indat_callback(struct urb *urb)
414 unsigned char *data = urb->transfer_buffer; 454 unsigned char *data = urb->transfer_buffer;
415 int status = urb->status; 455 int status = urb->status;
416 456
417 dbg("%s: %p", __FUNCTION__, urb); 457 dbg("%s: %p", __func__, urb);
418 458
419 endpoint = usb_pipeendpoint(urb->pipe); 459 endpoint = usb_pipeendpoint(urb->pipe);
420 port = (struct usb_serial_port *) urb->context; 460 port = urb->context;
421 461
422 if (status) { 462 if (status) {
423 dbg("%s: nonzero status: %d on endpoint %02x.", 463 dbg("%s: nonzero status: %d on endpoint %02x.",
424 __FUNCTION__, status, endpoint); 464 __func__, status, endpoint);
425 } else { 465 } else {
426 tty = port->tty; 466 tty = port->tty;
427 if (urb->actual_length) { 467 if (urb->actual_length) {
@@ -429,7 +469,7 @@ static void sierra_indat_callback(struct urb *urb)
429 tty_insert_flip_string(tty, data, urb->actual_length); 469 tty_insert_flip_string(tty, data, urb->actual_length);
430 tty_flip_buffer_push(tty); 470 tty_flip_buffer_push(tty);
431 } else { 471 } else {
432 dbg("%s: empty read urb received", __FUNCTION__); 472 dbg("%s: empty read urb received", __func__);
433 } 473 }
434 474
435 /* Resubmit urb so we continue receiving */ 475 /* Resubmit urb so we continue receiving */
@@ -447,19 +487,19 @@ static void sierra_instat_callback(struct urb *urb)
447{ 487{
448 int err; 488 int err;
449 int status = urb->status; 489 int status = urb->status;
450 struct usb_serial_port *port = (struct usb_serial_port *) urb->context; 490 struct usb_serial_port *port = urb->context;
451 struct sierra_port_private *portdata = usb_get_serial_port_data(port); 491 struct sierra_port_private *portdata = usb_get_serial_port_data(port);
452 struct usb_serial *serial = port->serial; 492 struct usb_serial *serial = port->serial;
453 493
454 dbg("%s", __FUNCTION__); 494 dbg("%s", __func__);
455 dbg("%s: urb %p port %p has data %p", __FUNCTION__,urb,port,portdata); 495 dbg("%s: urb %p port %p has data %p", __func__, urb, port, portdata);
456 496
457 if (status == 0) { 497 if (status == 0) {
458 struct usb_ctrlrequest *req_pkt = 498 struct usb_ctrlrequest *req_pkt =
459 (struct usb_ctrlrequest *)urb->transfer_buffer; 499 (struct usb_ctrlrequest *)urb->transfer_buffer;
460 500
461 if (!req_pkt) { 501 if (!req_pkt) {
462 dbg("%s: NULL req_pkt\n", __FUNCTION__); 502 dbg("%s: NULL req_pkt\n", __func__);
463 return; 503 return;
464 } 504 }
465 if ((req_pkt->bRequestType == 0xA1) && 505 if ((req_pkt->bRequestType == 0xA1) &&
@@ -469,7 +509,7 @@ static void sierra_instat_callback(struct urb *urb)
469 urb->transfer_buffer + 509 urb->transfer_buffer +
470 sizeof(struct usb_ctrlrequest)); 510 sizeof(struct usb_ctrlrequest));
471 511
472 dbg("%s: signal x%x", __FUNCTION__, signals); 512 dbg("%s: signal x%x", __func__, signals);
473 513
474 old_dcd_state = portdata->dcd_state; 514 old_dcd_state = portdata->dcd_state;
475 portdata->cts_state = 1; 515 portdata->cts_state = 1;
@@ -481,11 +521,11 @@ static void sierra_instat_callback(struct urb *urb)
481 old_dcd_state && !portdata->dcd_state) 521 old_dcd_state && !portdata->dcd_state)
482 tty_hangup(port->tty); 522 tty_hangup(port->tty);
483 } else { 523 } else {
484 dbg("%s: type %x req %x", __FUNCTION__, 524 dbg("%s: type %x req %x", __func__,
485 req_pkt->bRequestType,req_pkt->bRequest); 525 req_pkt->bRequestType, req_pkt->bRequest);
486 } 526 }
487 } else 527 } else
488 dbg("%s: error %d", __FUNCTION__, status); 528 dbg("%s: error %d", __func__, status);
489 529
490 /* Resubmit urb so we continue receiving IRQ data */ 530 /* Resubmit urb so we continue receiving IRQ data */
491 if (status != -ESHUTDOWN) { 531 if (status != -ESHUTDOWN) {
@@ -493,7 +533,7 @@ static void sierra_instat_callback(struct urb *urb)
493 err = usb_submit_urb(urb, GFP_ATOMIC); 533 err = usb_submit_urb(urb, GFP_ATOMIC);
494 if (err) 534 if (err)
495 dbg("%s: resubmit intr urb failed. (%d)", 535 dbg("%s: resubmit intr urb failed. (%d)",
496 __FUNCTION__, err); 536 __func__, err);
497 } 537 }
498} 538}
499 539
@@ -502,14 +542,14 @@ static int sierra_write_room(struct usb_serial_port *port)
502 struct sierra_port_private *portdata = usb_get_serial_port_data(port); 542 struct sierra_port_private *portdata = usb_get_serial_port_data(port);
503 unsigned long flags; 543 unsigned long flags;
504 544
505 dbg("%s - port %d", __FUNCTION__, port->number); 545 dbg("%s - port %d", __func__, port->number);
506 546
507 /* try to give a good number back based on if we have any free urbs at 547 /* try to give a good number back based on if we have any free urbs at
508 * this point in time */ 548 * this point in time */
509 spin_lock_irqsave(&portdata->lock, flags); 549 spin_lock_irqsave(&portdata->lock, flags);
510 if (portdata->outstanding_urbs > N_OUT_URB * 2 / 3) { 550 if (portdata->outstanding_urbs > N_OUT_URB * 2 / 3) {
511 spin_unlock_irqrestore(&portdata->lock, flags); 551 spin_unlock_irqrestore(&portdata->lock, flags);
512 dbg("%s - write limit hit\n", __FUNCTION__); 552 dbg("%s - write limit hit\n", __func__);
513 return 0; 553 return 0;
514 } 554 }
515 spin_unlock_irqrestore(&portdata->lock, flags); 555 spin_unlock_irqrestore(&portdata->lock, flags);
@@ -519,13 +559,15 @@ static int sierra_write_room(struct usb_serial_port *port)
519 559
520static int sierra_chars_in_buffer(struct usb_serial_port *port) 560static int sierra_chars_in_buffer(struct usb_serial_port *port)
521{ 561{
522 dbg("%s - port %d", __FUNCTION__, port->number); 562 dbg("%s - port %d", __func__, port->number);
523 563
524 /* 564 /*
525 * We can't really account for how much data we 565 * We can't really account for how much data we
526 * have sent out, but hasn't made it through to the 566 * have sent out, but hasn't made it through to the
527 * device as we can't see the backend here, so just 567 * device as we can't see the backend here, so just
528 * tell the tty layer that everything is flushed. 568 * tell the tty layer that everything is flushed.
569 *
570 * FIXME: should walk the outstanding urbs info
529 */ 571 */
530 return 0; 572 return 0;
531} 573}
@@ -540,7 +582,7 @@ static int sierra_open(struct usb_serial_port *port, struct file *filp)
540 582
541 portdata = usb_get_serial_port_data(port); 583 portdata = usb_get_serial_port_data(port);
542 584
543 dbg("%s", __FUNCTION__); 585 dbg("%s", __func__);
544 586
545 /* Set some sane defaults */ 587 /* Set some sane defaults */
546 portdata->rts_state = 1; 588 portdata->rts_state = 1;
@@ -552,7 +594,7 @@ static int sierra_open(struct usb_serial_port *port, struct file *filp)
552 if (!urb) 594 if (!urb)
553 continue; 595 continue;
554 if (urb->dev != serial->dev) { 596 if (urb->dev != serial->dev) {
555 dbg("%s: dev %p != %p", __FUNCTION__, 597 dbg("%s: dev %p != %p", __func__,
556 urb->dev, serial->dev); 598 urb->dev, serial->dev);
557 continue; 599 continue;
558 } 600 }
@@ -590,7 +632,7 @@ static void sierra_close(struct usb_serial_port *port, struct file *filp)
590 struct usb_serial *serial = port->serial; 632 struct usb_serial *serial = port->serial;
591 struct sierra_port_private *portdata; 633 struct sierra_port_private *portdata;
592 634
593 dbg("%s", __FUNCTION__); 635 dbg("%s", __func__);
594 portdata = usb_get_serial_port_data(port); 636 portdata = usb_get_serial_port_data(port);
595 637
596 portdata->rts_state = 0; 638 portdata->rts_state = 0;
@@ -620,7 +662,7 @@ static int sierra_startup(struct usb_serial *serial)
620 int i; 662 int i;
621 int j; 663 int j;
622 664
623 dbg("%s", __FUNCTION__); 665 dbg("%s", __func__);
624 666
625 /* Set Device mode to D0 */ 667 /* Set Device mode to D0 */
626 sierra_set_power_state(serial->dev, 0x0000); 668 sierra_set_power_state(serial->dev, 0x0000);
@@ -635,7 +677,7 @@ static int sierra_startup(struct usb_serial *serial)
635 portdata = kzalloc(sizeof(*portdata), GFP_KERNEL); 677 portdata = kzalloc(sizeof(*portdata), GFP_KERNEL);
636 if (!portdata) { 678 if (!portdata) {
637 dbg("%s: kmalloc for sierra_port_private (%d) failed!.", 679 dbg("%s: kmalloc for sierra_port_private (%d) failed!.",
638 __FUNCTION__, i); 680 __func__, i);
639 return -ENOMEM; 681 return -ENOMEM;
640 } 682 }
641 spin_lock_init(&portdata->lock); 683 spin_lock_init(&portdata->lock);
@@ -656,7 +698,7 @@ static int sierra_startup(struct usb_serial *serial)
656 urb = usb_alloc_urb(0, GFP_KERNEL); 698 urb = usb_alloc_urb(0, GFP_KERNEL);
657 if (urb == NULL) { 699 if (urb == NULL) {
658 dbg("%s: alloc for in port failed.", 700 dbg("%s: alloc for in port failed.",
659 __FUNCTION__); 701 __func__);
660 continue; 702 continue;
661 } 703 }
662 /* Fill URB using supplied data. */ 704 /* Fill URB using supplied data. */
@@ -678,7 +720,7 @@ static void sierra_shutdown(struct usb_serial *serial)
678 struct usb_serial_port *port; 720 struct usb_serial_port *port;
679 struct sierra_port_private *portdata; 721 struct sierra_port_private *portdata;
680 722
681 dbg("%s", __FUNCTION__); 723 dbg("%s", __func__);
682 724
683 for (i = 0; i < serial->num_ports; ++i) { 725 for (i = 0; i < serial->num_ports; ++i) {
684 port = serial->port[i]; 726 port = serial->port[i];
@@ -706,9 +748,6 @@ static struct usb_serial_driver sierra_device = {
706 .description = "Sierra USB modem", 748 .description = "Sierra USB modem",
707 .id_table = id_table, 749 .id_table = id_table,
708 .usb_driver = &sierra_driver, 750 .usb_driver = &sierra_driver,
709 .num_interrupt_in = NUM_DONT_CARE,
710 .num_bulk_in = NUM_DONT_CARE,
711 .num_bulk_out = NUM_DONT_CARE,
712 .calc_num_ports = sierra_calc_num_ports, 751 .calc_num_ports = sierra_calc_num_ports,
713 .probe = sierra_probe, 752 .probe = sierra_probe,
714 .open = sierra_open, 753 .open = sierra_open,
diff --git a/drivers/usb/serial/spcp8x5.c b/drivers/usb/serial/spcp8x5.c
new file mode 100644
index 00000000000..2282d620186
--- /dev/null
+++ b/drivers/usb/serial/spcp8x5.c
@@ -0,0 +1,1072 @@
1/*
2 * spcp8x5 USB to serial adaptor driver
3 *
4 * Copyright (C) 2006 Linxb (xubin.lin@worldplus.com.cn)
5 * Copyright (C) 2006 S1 Corp.
6 *
7 * Original driver for 2.6.10 pl2303 driver by
8 * Greg Kroah-Hartman (greg@kroah.com)
9 * Changes for 2.6.20 by Harald Klein <hari@vt100.at>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 *
17 */
18#include <linux/kernel.h>
19#include <linux/errno.h>
20#include <linux/init.h>
21#include <linux/slab.h>
22#include <linux/tty.h>
23#include <linux/tty_driver.h>
24#include <linux/tty_flip.h>
25#include <linux/module.h>
26#include <linux/spinlock.h>
27#include <linux/usb.h>
28#include <linux/usb/serial.h>
29
30
31/* Version Information */
32#define DRIVER_VERSION "v0.04"
33#define DRIVER_DESC "SPCP8x5 USB to serial adaptor driver"
34
35static int debug;
36
37#define SPCP8x5_007_VID 0x04FC
38#define SPCP8x5_007_PID 0x0201
39#define SPCP8x5_008_VID 0x04fc
40#define SPCP8x5_008_PID 0x0235
41#define SPCP8x5_PHILIPS_VID 0x0471
42#define SPCP8x5_PHILIPS_PID 0x081e
43#define SPCP8x5_INTERMATIC_VID 0x04FC
44#define SPCP8x5_INTERMATIC_PID 0x0204
45#define SPCP8x5_835_VID 0x04fc
46#define SPCP8x5_835_PID 0x0231
47
48static 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)},
52 { USB_DEVICE(SPCP8x5_008_VID, SPCP8x5_008_PID)},
53 { USB_DEVICE(SPCP8x5_007_VID, SPCP8x5_007_PID)},
54 { } /* Terminating entry */
55};
56MODULE_DEVICE_TABLE(usb, id_table);
57
58struct spcp8x5_usb_ctrl_arg {
59 u8 type;
60 u8 cmd;
61 u8 cmd_type;
62 u16 value;
63 u16 index;
64 u16 length;
65};
66
67/* wait 30s before close */
68#define SPCP8x5_CLOSING_WAIT (30*HZ)
69
70#define SPCP8x5_BUF_SIZE 1024
71
72
73/* spcp8x5 spec register define */
74#define MCR_CONTROL_LINE_RTS 0x02
75#define MCR_CONTROL_LINE_DTR 0x01
76#define MCR_DTR 0x01
77#define MCR_RTS 0x02
78
79#define MSR_STATUS_LINE_DCD 0x80
80#define MSR_STATUS_LINE_RI 0x40
81#define MSR_STATUS_LINE_DSR 0x20
82#define MSR_STATUS_LINE_CTS 0x10
83
84/* verdor command here , we should define myself */
85#define SET_DEFAULT 0x40
86#define SET_DEFAULT_TYPE 0x20
87
88#define SET_UART_FORMAT 0x40
89#define SET_UART_FORMAT_TYPE 0x21
90#define SET_UART_FORMAT_SIZE_5 0x00
91#define SET_UART_FORMAT_SIZE_6 0x01
92#define SET_UART_FORMAT_SIZE_7 0x02
93#define SET_UART_FORMAT_SIZE_8 0x03
94#define SET_UART_FORMAT_STOP_1 0x00
95#define SET_UART_FORMAT_STOP_2 0x04
96#define SET_UART_FORMAT_PAR_NONE 0x00
97#define SET_UART_FORMAT_PAR_ODD 0x10
98#define SET_UART_FORMAT_PAR_EVEN 0x30
99#define SET_UART_FORMAT_PAR_MASK 0xD0
100#define SET_UART_FORMAT_PAR_SPACE 0x90
101
102#define GET_UART_STATUS_TYPE 0xc0
103#define GET_UART_STATUS 0x22
104#define GET_UART_STATUS_MSR 0x06
105
106#define SET_UART_STATUS 0x40
107#define SET_UART_STATUS_TYPE 0x23
108#define SET_UART_STATUS_MCR 0x0004
109#define SET_UART_STATUS_MCR_DTR 0x01
110#define SET_UART_STATUS_MCR_RTS 0x02
111#define SET_UART_STATUS_MCR_LOOP 0x10
112
113#define SET_WORKING_MODE 0x40
114#define SET_WORKING_MODE_TYPE 0x24
115#define SET_WORKING_MODE_U2C 0x00
116#define SET_WORKING_MODE_RS485 0x01
117#define SET_WORKING_MODE_PDMA 0x02
118#define SET_WORKING_MODE_SPP 0x03
119
120#define SET_FLOWCTL_CHAR 0x40
121#define SET_FLOWCTL_CHAR_TYPE 0x25
122
123#define GET_VERSION 0xc0
124#define GET_VERSION_TYPE 0x26
125
126#define SET_REGISTER 0x40
127#define SET_REGISTER_TYPE 0x27
128
129#define GET_REGISTER 0xc0
130#define GET_REGISTER_TYPE 0x28
131
132#define SET_RAM 0x40
133#define SET_RAM_TYPE 0x31
134
135#define GET_RAM 0xc0
136#define GET_RAM_TYPE 0x32
137
138/* how come ??? */
139#define UART_STATE 0x08
140#define UART_STATE_TRANSIENT_MASK 0x74
141#define UART_DCD 0x01
142#define UART_DSR 0x02
143#define UART_BREAK_ERROR 0x04
144#define UART_RING 0x08
145#define UART_FRAME_ERROR 0x10
146#define UART_PARITY_ERROR 0x20
147#define UART_OVERRUN_ERROR 0x40
148#define UART_CTS 0x80
149
150enum spcp8x5_type {
151 SPCP825_007_TYPE,
152 SPCP825_008_TYPE,
153 SPCP825_PHILIP_TYPE,
154 SPCP825_INTERMATIC_TYPE,
155 SPCP835_TYPE,
156};
157
158/* 1st in 1st out buffer 4 driver */
159struct ringbuf {
160 unsigned int buf_size;
161 char *buf_buf;
162 char *buf_get;
163 char *buf_put;
164};
165
166/* alloc the ring buf and alloc the buffer itself */
167static inline struct ringbuf *alloc_ringbuf(unsigned int size)
168{
169 struct ringbuf *pb;
170
171 if (size == 0)
172 return NULL;
173
174 pb = kmalloc(sizeof(*pb), GFP_KERNEL);
175 if (pb == NULL)
176 return NULL;
177
178 pb->buf_buf = kmalloc(size, GFP_KERNEL);
179 if (pb->buf_buf == NULL) {
180 kfree(pb);
181 return NULL;
182 }
183
184 pb->buf_size = size;
185 pb->buf_get = pb->buf_put = pb->buf_buf;
186
187 return pb;
188}
189
190/* free the ring buf and the buffer itself */
191static inline void free_ringbuf(struct ringbuf *pb)
192{
193 if (pb != NULL) {
194 kfree(pb->buf_buf);
195 kfree(pb);
196 }
197}
198
199/* clear pipo , juest repoint the pointer here */
200static inline void clear_ringbuf(struct ringbuf *pb)
201{
202 if (pb != NULL)
203 pb->buf_get = pb->buf_put;
204}
205
206/* get the number of data in the pipo */
207static inline unsigned int ringbuf_avail_data(struct ringbuf *pb)
208{
209 if (pb == NULL)
210 return 0;
211 return ((pb->buf_size + pb->buf_put - pb->buf_get) % pb->buf_size);
212}
213
214/* get the number of space in the pipo */
215static inline unsigned int ringbuf_avail_space(struct ringbuf *pb)
216{
217 if (pb == NULL)
218 return 0;
219 return ((pb->buf_size + pb->buf_get - pb->buf_put - 1) % pb->buf_size);
220}
221
222/* put count data into pipo */
223static unsigned int put_ringbuf(struct ringbuf *pb, const char *buf,
224 unsigned int count)
225{
226 unsigned int len;
227
228 if (pb == NULL)
229 return 0;
230
231 len = ringbuf_avail_space(pb);
232 if (count > len)
233 count = len;
234
235 if (count == 0)
236 return 0;
237
238 len = pb->buf_buf + pb->buf_size - pb->buf_put;
239 if (count > len) {
240 memcpy(pb->buf_put, buf, len);
241 memcpy(pb->buf_buf, buf+len, count - len);
242 pb->buf_put = pb->buf_buf + count - len;
243 } else {
244 memcpy(pb->buf_put, buf, count);
245 if (count < len)
246 pb->buf_put += count;
247 else /* count == len */
248 pb->buf_put = pb->buf_buf;
249 }
250 return count;
251}
252
253/* get count data from pipo */
254static unsigned int get_ringbuf(struct ringbuf *pb, char *buf,
255 unsigned int count)
256{
257 unsigned int len;
258
259 if (pb == NULL || buf == NULL)
260 return 0;
261
262 len = ringbuf_avail_data(pb);
263 if (count > len)
264 count = len;
265
266 if (count == 0)
267 return 0;
268
269 len = pb->buf_buf + pb->buf_size - pb->buf_get;
270 if (count > len) {
271 memcpy(buf, pb->buf_get, len);
272 memcpy(buf+len, pb->buf_buf, count - len);
273 pb->buf_get = pb->buf_buf + count - len;
274 } else {
275 memcpy(buf, pb->buf_get, count);
276 if (count < len)
277 pb->buf_get += count;
278 else /* count == len */
279 pb->buf_get = pb->buf_buf;
280 }
281
282 return count;
283}
284
285static struct usb_driver spcp8x5_driver = {
286 .name = "spcp8x5",
287 .probe = usb_serial_probe,
288 .disconnect = usb_serial_disconnect,
289 .id_table = id_table,
290 .no_dynamic_id = 1,
291};
292
293
294struct spcp8x5_private {
295 spinlock_t lock;
296 struct ringbuf *buf;
297 int write_urb_in_use;
298 enum spcp8x5_type type;
299 wait_queue_head_t delta_msr_wait;
300 u8 line_control;
301 u8 line_status;
302 u8 termios_initialized;
303};
304
305/* desc : when device plug in,this function would be called.
306 * thanks to usb_serial subsystem,then do almost every things for us. And what
307 * we should do just alloc the buffer */
308static int spcp8x5_startup(struct usb_serial *serial)
309{
310 struct spcp8x5_private *priv;
311 int i;
312 enum spcp8x5_type type = SPCP825_007_TYPE;
313
314 if (serial->dev->descriptor.idProduct == 0x0201)
315 type = SPCP825_007_TYPE;
316 else if (serial->dev->descriptor.idProduct == 0x0231)
317 type = SPCP835_TYPE;
318 else if (serial->dev->descriptor.idProduct == 0x0235)
319 type = SPCP825_008_TYPE;
320 else if (serial->dev->descriptor.idProduct == 0x0204)
321 type = SPCP825_INTERMATIC_TYPE;
322 else if (serial->dev->descriptor.idProduct == 0x0471 &&
323 serial->dev->descriptor.idVendor == 0x081e)
324 type = SPCP825_PHILIP_TYPE;
325 dev_dbg(&serial->dev->dev, "device type = %d\n", (int)type);
326
327 for (i = 0; i < serial->num_ports; ++i) {
328 priv = kzalloc(sizeof(struct spcp8x5_private), GFP_KERNEL);
329 if (!priv)
330 goto cleanup;
331
332 spin_lock_init(&priv->lock);
333 priv->buf = alloc_ringbuf(SPCP8x5_BUF_SIZE);
334 if (priv->buf == NULL)
335 goto cleanup2;
336
337 init_waitqueue_head(&priv->delta_msr_wait);
338 priv->type = type;
339 usb_set_serial_port_data(serial->port[i] , priv);
340
341 }
342
343 return 0;
344
345cleanup2:
346 kfree(priv);
347cleanup:
348 for (--i; i >= 0; --i) {
349 priv = usb_get_serial_port_data(serial->port[i]);
350 free_ringbuf(priv->buf);
351 kfree(priv);
352 usb_set_serial_port_data(serial->port[i] , NULL);
353 }
354 return -ENOMEM;
355}
356
357/* call when the device plug out. free all the memory alloced by probe */
358static void spcp8x5_shutdown(struct usb_serial *serial)
359{
360 int i;
361 struct spcp8x5_private *priv;
362
363 for (i = 0; i < serial->num_ports; i++) {
364 priv = usb_get_serial_port_data(serial->port[i]);
365 if (priv) {
366 free_ringbuf(priv->buf);
367 kfree(priv);
368 usb_set_serial_port_data(serial->port[i] , NULL);
369 }
370 }
371}
372
373/* set the modem control line of the device.
374 * NOTE spcp825-007 not supported this */
375static int spcp8x5_set_ctrlLine(struct usb_device *dev, u8 value,
376 enum spcp8x5_type type)
377{
378 int retval;
379 u8 mcr = 0 ;
380
381 if (type == SPCP825_007_TYPE)
382 return -EPERM;
383
384 mcr = (unsigned short)value;
385 retval = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
386 SET_UART_STATUS_TYPE, SET_UART_STATUS,
387 mcr, 0x04, NULL, 0, 100);
388 if (retval != 0)
389 dev_dbg(&dev->dev, "usb_control_msg return %#x\n", retval);
390 return retval;
391}
392
393/* get the modem status register of the device
394 * NOTE spcp825-007 not supported this */
395static int spcp8x5_get_msr(struct usb_device *dev, u8 *status,
396 enum spcp8x5_type type)
397{
398 u8 *status_buffer;
399 int ret;
400
401 /* I return Permited not support here but seem inval device
402 * is more fix */
403 if (type == SPCP825_007_TYPE)
404 return -EPERM;
405 if (status == NULL)
406 return -EINVAL;
407
408 status_buffer = kmalloc(1, GFP_KERNEL);
409 if (!status_buffer)
410 return -ENOMEM;
411 status_buffer[0] = status[0];
412
413 ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
414 GET_UART_STATUS, GET_UART_STATUS_TYPE,
415 0, GET_UART_STATUS_MSR, status_buffer, 1, 100);
416 if (ret < 0)
417 dev_dbg(&dev->dev, "Get MSR = 0x%p failed (error = %d)",
418 status_buffer, ret);
419
420 dev_dbg(&dev->dev, "0xc0:0x22:0:6 %d - 0x%p ", ret, status_buffer);
421 status[0] = status_buffer[0];
422 kfree(status_buffer);
423
424 return ret;
425}
426
427/* select the work mode.
428 * NOTE this function not supported by spcp825-007 */
429static void spcp8x5_set_workMode(struct usb_device *dev, u16 value,
430 u16 index, enum spcp8x5_type type)
431{
432 int ret;
433
434 /* I return Permited not support here but seem inval device
435 * is more fix */
436 if (type == SPCP825_007_TYPE)
437 return;
438
439 ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
440 SET_WORKING_MODE_TYPE, SET_WORKING_MODE,
441 value, index, NULL, 0, 100);
442 dev_dbg(&dev->dev, "value = %#x , index = %#x\n", value, index);
443 if (ret < 0)
444 dev_dbg(&dev->dev,
445 "RTSCTS usb_control_msg(enable flowctrl) = %d\n", ret);
446}
447
448/* close the serial port. We should wait for data sending to device 1st and
449 * then kill all urb. */
450static void spcp8x5_close(struct usb_serial_port *port, struct file *filp)
451{
452 struct spcp8x5_private *priv = usb_get_serial_port_data(port);
453 unsigned long flags;
454 unsigned int c_cflag;
455 int bps;
456 long timeout;
457 wait_queue_t wait;
458 int result;
459
460 dbg("%s - port %d", __func__, port->number);
461
462 /* wait for data to drain from the buffer */
463 spin_lock_irqsave(&priv->lock, flags);
464 timeout = SPCP8x5_CLOSING_WAIT;
465 init_waitqueue_entry(&wait, current);
466 add_wait_queue(&port->tty->write_wait, &wait);
467 for (;;) {
468 set_current_state(TASK_INTERRUPTIBLE);
469 if (ringbuf_avail_data(priv->buf) == 0 ||
470 timeout == 0 || signal_pending(current))
471 break;
472 spin_unlock_irqrestore(&priv->lock, flags);
473 timeout = schedule_timeout(timeout);
474 spin_lock_irqsave(&priv->lock, flags);
475 }
476 set_current_state(TASK_RUNNING);
477 remove_wait_queue(&port->tty->write_wait, &wait);
478
479 /* clear out any remaining data in the buffer */
480 clear_ringbuf(priv->buf);
481 spin_unlock_irqrestore(&priv->lock, flags);
482
483 /* wait for characters to drain from the device (this is long enough
484 * for the entire all byte spcp8x5 hardware buffer to drain with no
485 * flow control for data rates of 1200 bps or more, for lower rates we
486 * should really know how much data is in the buffer to compute a delay
487 * that is not unnecessarily long) */
488 bps = tty_get_baud_rate(port->tty);
489 if (bps > 1200)
490 timeout = max((HZ*2560) / bps, HZ/10);
491 else
492 timeout = 2*HZ;
493 set_current_state(TASK_INTERRUPTIBLE);
494 schedule_timeout(timeout);
495
496 /* clear control lines */
497 if (port->tty) {
498 c_cflag = port->tty->termios->c_cflag;
499 if (c_cflag & HUPCL) {
500 spin_lock_irqsave(&priv->lock, flags);
501 priv->line_control = 0;
502 spin_unlock_irqrestore(&priv->lock, flags);
503 spcp8x5_set_ctrlLine(port->serial->dev, 0 , priv->type);
504 }
505 }
506
507 /* kill urb */
508 if (port->write_urb != NULL) {
509 result = usb_unlink_urb(port->write_urb);
510 if (result)
511 dev_dbg(&port->dev,
512 "usb_unlink_urb(write_urb) = %d\n", result);
513 }
514 result = usb_unlink_urb(port->read_urb);
515 if (result)
516 dev_dbg(&port->dev, "usb_unlink_urb(read_urb) = %d\n", result);
517}
518
519/* set the serial param for transfer. we should check if we really need to
520 * transfer. then if be set flow contorl we should do this too. */
521static void spcp8x5_set_termios(struct usb_serial_port *port,
522 struct ktermios *old_termios)
523{
524 struct usb_serial *serial = port->serial;
525 struct spcp8x5_private *priv = usb_get_serial_port_data(port);
526 unsigned long flags;
527 unsigned int cflag = port->tty->termios->c_cflag;
528 unsigned int old_cflag = old_termios->c_cflag;
529 unsigned short uartdata;
530 unsigned char buf[2] = {0, 0};
531 int baud;
532 int i;
533 u8 control;
534
535 if ((!port->tty) || (!port->tty->termios))
536 return;
537
538 /* for the 1st time call this function */
539 spin_lock_irqsave(&priv->lock, flags);
540 if (!priv->termios_initialized) {
541 *(port->tty->termios) = tty_std_termios;
542 port->tty->termios->c_cflag = B115200 | CS8 | CREAD |
543 HUPCL | CLOCAL;
544 priv->termios_initialized = 1;
545 }
546 spin_unlock_irqrestore(&priv->lock, flags);
547
548 /* check that they really want us to change something */
549 if (!tty_termios_hw_change(port->tty->termios, old_termios))
550 return;
551
552 /* set DTR/RTS active */
553 spin_lock_irqsave(&priv->lock, flags);
554 control = priv->line_control;
555 if ((old_cflag & CBAUD) == B0) {
556 priv->line_control |= MCR_DTR;
557 if (!(old_cflag & CRTSCTS))
558 priv->line_control |= MCR_RTS;
559 }
560 if (control != priv->line_control) {
561 control = priv->line_control;
562 spin_unlock_irqrestore(&priv->lock, flags);
563 spcp8x5_set_ctrlLine(serial->dev, control , priv->type);
564 } else {
565 spin_unlock_irqrestore(&priv->lock, flags);
566 }
567
568 /* Set Baud Rate */
569 baud = tty_get_baud_rate(port->tty);;
570 switch (baud) {
571 case 300: buf[0] = 0x00; break;
572 case 600: buf[0] = 0x01; break;
573 case 1200: buf[0] = 0x02; break;
574 case 2400: buf[0] = 0x03; break;
575 case 4800: buf[0] = 0x04; break;
576 case 9600: buf[0] = 0x05; break;
577 case 19200: buf[0] = 0x07; break;
578 case 38400: buf[0] = 0x09; break;
579 case 57600: buf[0] = 0x0a; break;
580 case 115200: buf[0] = 0x0b; break;
581 case 230400: buf[0] = 0x0c; break;
582 case 460800: buf[0] = 0x0d; break;
583 case 921600: buf[0] = 0x0e; break;
584/* case 1200000: buf[0] = 0x0f; break; */
585/* case 2400000: buf[0] = 0x10; break; */
586 case 3000000: buf[0] = 0x11; break;
587/* case 6000000: buf[0] = 0x12; break; */
588 case 0:
589 case 1000000:
590 buf[0] = 0x0b; break;
591 default:
592 err("spcp825 driver does not support the baudrate "
593 "requested, using default of 9600.");
594 }
595
596 /* Set Data Length : 00:5bit, 01:6bit, 10:7bit, 11:8bit */
597 if (cflag & CSIZE) {
598 switch (cflag & CSIZE) {
599 case CS5:
600 buf[1] |= SET_UART_FORMAT_SIZE_5;
601 break;
602 case CS6:
603 buf[1] |= SET_UART_FORMAT_SIZE_6;
604 break;
605 case CS7:
606 buf[1] |= SET_UART_FORMAT_SIZE_7;
607 break;
608 default:
609 case CS8:
610 buf[1] |= SET_UART_FORMAT_SIZE_8;
611 break;
612 }
613 }
614
615 /* Set Stop bit2 : 0:1bit 1:2bit */
616 buf[1] |= (cflag & CSTOPB) ? SET_UART_FORMAT_STOP_2 :
617 SET_UART_FORMAT_STOP_1;
618
619 /* Set Parity bit3-4 01:Odd 11:Even */
620 if (cflag & PARENB) {
621 buf[1] |= (cflag & PARODD) ?
622 SET_UART_FORMAT_PAR_ODD : SET_UART_FORMAT_PAR_EVEN ;
623 } else
624 buf[1] |= SET_UART_FORMAT_PAR_NONE;
625
626 uartdata = buf[0] | buf[1]<<8;
627
628 i = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
629 SET_UART_FORMAT_TYPE, SET_UART_FORMAT,
630 uartdata, 0, NULL, 0, 100);
631 if (i < 0)
632 err("Set UART format %#x failed (error = %d)", uartdata, i);
633 dbg("0x21:0x40:0:0 %d\n", i);
634
635 if (cflag & CRTSCTS) {
636 /* enable hardware flow control */
637 spcp8x5_set_workMode(serial->dev, 0x000a,
638 SET_WORKING_MODE_U2C, priv->type);
639 }
640 return;
641}
642
643/* open the serial port. do some usb system call. set termios and get the line
644 * status of the device. then submit the read urb */
645static int spcp8x5_open(struct usb_serial_port *port, struct file *filp)
646{
647 struct ktermios tmp_termios;
648 struct usb_serial *serial = port->serial;
649 struct spcp8x5_private *priv = usb_get_serial_port_data(port);
650 int ret;
651 unsigned long flags;
652 u8 status = 0x30;
653 /* status 0x30 means DSR and CTS = 1 other CDC RI and delta = 0 */
654
655 dbg("%s - port %d", __func__, port->number);
656
657 usb_clear_halt(serial->dev, port->write_urb->pipe);
658 usb_clear_halt(serial->dev, port->read_urb->pipe);
659
660 ret = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
661 0x09, 0x00,
662 0x01, 0x00, NULL, 0x00, 100);
663 if (ret)
664 return ret;
665
666 spin_lock_irqsave(&priv->lock, flags);
667 if (port->tty->termios->c_cflag & CBAUD)
668 priv->line_control = MCR_DTR | MCR_RTS;
669 else
670 priv->line_control = 0;
671 spin_unlock_irqrestore(&priv->lock, flags);
672
673 spcp8x5_set_ctrlLine(serial->dev, priv->line_control , priv->type);
674
675 /* Setup termios */
676 if (port->tty)
677 spcp8x5_set_termios(port, &tmp_termios);
678
679 spcp8x5_get_msr(serial->dev, &status, priv->type);
680
681 /* may be we should update uart status here but now we did not do */
682 spin_lock_irqsave(&priv->lock, flags);
683 priv->line_status = status & 0xf0 ;
684 spin_unlock_irqrestore(&priv->lock, flags);
685
686 /* FIXME: need to assert RTS and DTR if CRTSCTS off */
687
688 dbg("%s - submitting read urb", __func__);
689 port->read_urb->dev = serial->dev;
690 ret = usb_submit_urb(port->read_urb, GFP_KERNEL);
691 if (ret) {
692 spcp8x5_close(port, NULL);
693 return -EPROTO;
694 }
695 return 0;
696}
697
698/* bulk read call back function. check the status of the urb. if transfer
699 * failed return. then update the status and the tty send data to tty subsys.
700 * submit urb again.
701 */
702static void spcp8x5_read_bulk_callback(struct urb *urb)
703{
704 struct usb_serial_port *port = urb->context;
705 struct spcp8x5_private *priv = usb_get_serial_port_data(port);
706 struct tty_struct *tty;
707 unsigned char *data = urb->transfer_buffer;
708 unsigned long flags;
709 int i;
710 int result;
711 u8 status = 0;
712 char tty_flag;
713
714 dev_dbg(&port->dev, "start, urb->status = %d, "
715 "urb->actual_length = %d\n,", urb->status, urb->actual_length);
716
717 /* check the urb status */
718 if (urb->status) {
719 if (!port->open_count)
720 return;
721 if (urb->status == -EPROTO) {
722 /* spcp8x5 mysteriously fails with -EPROTO */
723 /* reschedule the read */
724 urb->status = 0;
725 urb->dev = port->serial->dev;
726 result = usb_submit_urb(urb , GFP_ATOMIC);
727 if (result)
728 dev_dbg(&port->dev,
729 "failed submitting read urb %d\n",
730 result);
731 return;
732 }
733 dev_dbg(&port->dev, "unable to handle the error, exiting.\n");
734 return;
735 }
736
737 /* get tty_flag from status */
738 tty_flag = TTY_NORMAL;
739
740 spin_lock_irqsave(&priv->lock, flags);
741 status = priv->line_status;
742 priv->line_status &= ~UART_STATE_TRANSIENT_MASK;
743 spin_unlock_irqrestore(&priv->lock, flags);
744 /* wake up the wait for termios */
745 wake_up_interruptible(&priv->delta_msr_wait);
746
747 /* break takes precedence over parity, which takes precedence over
748 * framing errors */
749 if (status & UART_BREAK_ERROR)
750 tty_flag = TTY_BREAK;
751 else if (status & UART_PARITY_ERROR)
752 tty_flag = TTY_PARITY;
753 else if (status & UART_FRAME_ERROR)
754 tty_flag = TTY_FRAME;
755 dev_dbg(&port->dev, "tty_flag = %d\n", tty_flag);
756
757 tty = port->tty;
758 if (tty && urb->actual_length) {
759 tty_buffer_request_room(tty, urb->actual_length + 1);
760 /* overrun is special, not associated with a char */
761 if (status & UART_OVERRUN_ERROR)
762 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
763 for (i = 0; i < urb->actual_length; ++i)
764 tty_insert_flip_char(tty, data[i], tty_flag);
765 tty_flip_buffer_push(tty);
766 }
767
768 /* Schedule the next read _if_ we are still open */
769 if (port->open_count) {
770 urb->dev = port->serial->dev;
771 result = usb_submit_urb(urb , GFP_ATOMIC);
772 if (result)
773 dev_dbg(&port->dev, "failed submitting read urb %d\n",
774 result);
775 }
776
777 return;
778}
779
780/* get data from ring buffer and then write to usb bus */
781static void spcp8x5_send(struct usb_serial_port *port)
782{
783 int count, result;
784 struct spcp8x5_private *priv = usb_get_serial_port_data(port);
785 unsigned long flags;
786
787 spin_lock_irqsave(&priv->lock, flags);
788
789 if (priv->write_urb_in_use) {
790 dev_dbg(&port->dev, "write urb still used\n");
791 spin_unlock_irqrestore(&priv->lock, flags);
792 return;
793 }
794
795 /* send the 1st urb for writting */
796 memset(port->write_urb->transfer_buffer , 0x00 , port->bulk_out_size);
797 count = get_ringbuf(priv->buf, port->write_urb->transfer_buffer,
798 port->bulk_out_size);
799
800 if (count == 0) {
801 spin_unlock_irqrestore(&priv->lock, flags);
802 return;
803 }
804
805 /* update the urb status */
806 priv->write_urb_in_use = 1;
807
808 spin_unlock_irqrestore(&priv->lock, flags);
809
810 port->write_urb->transfer_buffer_length = count;
811 port->write_urb->dev = port->serial->dev;
812
813 result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
814 if (result) {
815 dev_dbg(&port->dev, "failed submitting write urb, error %d\n",
816 result);
817 priv->write_urb_in_use = 0;
818 /* TODO: reschedule spcp8x5_send */
819 }
820
821
822 schedule_work(&port->work);
823}
824
825/* this is the call back function for write urb. NOTE we should not sleep in
826 * this routine. check the urb return code and then submit the write urb again
827 * to hold the write loop */
828static void spcp8x5_write_bulk_callback(struct urb *urb)
829{
830 struct usb_serial_port *port = urb->context;
831 struct spcp8x5_private *priv = usb_get_serial_port_data(port);
832 int result;
833
834 switch (urb->status) {
835 case 0:
836 /* success */
837 break;
838 case -ECONNRESET:
839 case -ENOENT:
840 case -ESHUTDOWN:
841 /* this urb is terminated, clean up */
842 dev_dbg(&port->dev, "urb shutting down with status: %d\n",
843 urb->status);
844 priv->write_urb_in_use = 0;
845 return;
846 default:
847 /* error in the urb, so we have to resubmit it */
848 dbg("%s - Overflow in write", __func__);
849 dbg("%s - nonzero write bulk status received: %d",
850 __func__, urb->status);
851 port->write_urb->transfer_buffer_length = 1;
852 port->write_urb->dev = port->serial->dev;
853 result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
854 if (result)
855 dev_dbg(&port->dev,
856 "failed resubmitting write urb %d\n", result);
857 else
858 return;
859 }
860
861 priv->write_urb_in_use = 0;
862
863 /* send any buffered data */
864 spcp8x5_send(port);
865}
866
867/* write data to ring buffer. and then start the write transfer */
868static int spcp8x5_write(struct usb_serial_port *port,
869 const unsigned char *buf, int count)
870{
871 struct spcp8x5_private *priv = usb_get_serial_port_data(port);
872 unsigned long flags;
873
874 dev_dbg(&port->dev, "%d bytes\n", count);
875
876 if (!count)
877 return count;
878
879 spin_lock_irqsave(&priv->lock, flags);
880 count = put_ringbuf(priv->buf, buf, count);
881 spin_unlock_irqrestore(&priv->lock, flags);
882
883 spcp8x5_send(port);
884
885 return count;
886}
887
888static int spcp8x5_wait_modem_info(struct usb_serial_port *port,
889 unsigned int arg)
890{
891 struct spcp8x5_private *priv = usb_get_serial_port_data(port);
892 unsigned long flags;
893 unsigned int prevstatus;
894 unsigned int status;
895 unsigned int changed;
896
897 spin_lock_irqsave(&priv->lock, flags);
898 prevstatus = priv->line_status;
899 spin_unlock_irqrestore(&priv->lock, flags);
900
901 while (1) {
902 /* wake up in bulk read */
903 interruptible_sleep_on(&priv->delta_msr_wait);
904
905 /* see if a signal did it */
906 if (signal_pending(current))
907 return -ERESTARTSYS;
908
909 spin_lock_irqsave(&priv->lock, flags);
910 status = priv->line_status;
911 spin_unlock_irqrestore(&priv->lock, flags);
912
913 changed = prevstatus^status;
914
915 if (((arg & TIOCM_RNG) && (changed & MSR_STATUS_LINE_RI)) ||
916 ((arg & TIOCM_DSR) && (changed & MSR_STATUS_LINE_DSR)) ||
917 ((arg & TIOCM_CD) && (changed & MSR_STATUS_LINE_DCD)) ||
918 ((arg & TIOCM_CTS) && (changed & MSR_STATUS_LINE_CTS)))
919 return 0;
920
921 prevstatus = status;
922 }
923 /* NOTREACHED */
924 return 0;
925}
926
927static int spcp8x5_ioctl(struct usb_serial_port *port, struct file *file,
928 unsigned int cmd, unsigned long arg)
929{
930 dbg("%s (%d) cmd = 0x%04x", __func__, port->number, cmd);
931
932 switch (cmd) {
933 case TIOCMIWAIT:
934 dbg("%s (%d) TIOCMIWAIT", __func__, port->number);
935 return spcp8x5_wait_modem_info(port, arg);
936
937 default:
938 dbg("%s not supported = 0x%04x", __func__, cmd);
939 break;
940 }
941
942 return -ENOIOCTLCMD;
943}
944
945static int spcp8x5_tiocmset(struct usb_serial_port *port, struct file *file,
946 unsigned int set, unsigned int clear)
947{
948 struct spcp8x5_private *priv = usb_get_serial_port_data(port);
949 unsigned long flags;
950 u8 control;
951
952 spin_lock_irqsave(&priv->lock, flags);
953 if (set & TIOCM_RTS)
954 priv->line_control |= MCR_RTS;
955 if (set & TIOCM_DTR)
956 priv->line_control |= MCR_DTR;
957 if (clear & TIOCM_RTS)
958 priv->line_control &= ~MCR_RTS;
959 if (clear & TIOCM_DTR)
960 priv->line_control &= ~MCR_DTR;
961 control = priv->line_control;
962 spin_unlock_irqrestore(&priv->lock, flags);
963
964 return spcp8x5_set_ctrlLine(port->serial->dev, control , priv->type);
965}
966
967static int spcp8x5_tiocmget(struct usb_serial_port *port, struct file *file)
968{
969 struct spcp8x5_private *priv = usb_get_serial_port_data(port);
970 unsigned long flags;
971 unsigned int mcr;
972 unsigned int status;
973 unsigned int result;
974
975 spin_lock_irqsave(&priv->lock, flags);
976 mcr = priv->line_control;
977 status = priv->line_status;
978 spin_unlock_irqrestore(&priv->lock, flags);
979
980 result = ((mcr & MCR_DTR) ? TIOCM_DTR : 0)
981 | ((mcr & MCR_RTS) ? TIOCM_RTS : 0)
982 | ((status & MSR_STATUS_LINE_CTS) ? TIOCM_CTS : 0)
983 | ((status & MSR_STATUS_LINE_DSR) ? TIOCM_DSR : 0)
984 | ((status & MSR_STATUS_LINE_RI) ? TIOCM_RI : 0)
985 | ((status & MSR_STATUS_LINE_DCD) ? TIOCM_CD : 0);
986
987 return result;
988}
989
990/* get the avail space room in ring buffer */
991static int spcp8x5_write_room(struct usb_serial_port *port)
992{
993 struct spcp8x5_private *priv = usb_get_serial_port_data(port);
994 int room = 0;
995 unsigned long flags;
996
997 spin_lock_irqsave(&priv->lock, flags);
998 room = ringbuf_avail_space(priv->buf);
999 spin_unlock_irqrestore(&priv->lock, flags);
1000
1001 return room;
1002}
1003
1004/* get the number of avail data in write ring buffer */
1005static int spcp8x5_chars_in_buffer(struct usb_serial_port *port)
1006{
1007 struct spcp8x5_private *priv = usb_get_serial_port_data(port);
1008 int chars = 0;
1009 unsigned long flags;
1010
1011 spin_lock_irqsave(&priv->lock, flags);
1012 chars = ringbuf_avail_data(priv->buf);
1013 spin_unlock_irqrestore(&priv->lock, flags);
1014
1015 return chars;
1016}
1017
1018/* All of the device info needed for the spcp8x5 SIO serial converter */
1019static struct usb_serial_driver spcp8x5_device = {
1020 .driver = {
1021 .owner = THIS_MODULE,
1022 .name = "SPCP8x5",
1023 },
1024 .id_table = id_table,
1025 .num_ports = 1,
1026 .open = spcp8x5_open,
1027 .close = spcp8x5_close,
1028 .write = spcp8x5_write,
1029 .set_termios = spcp8x5_set_termios,
1030 .ioctl = spcp8x5_ioctl,
1031 .tiocmget = spcp8x5_tiocmget,
1032 .tiocmset = spcp8x5_tiocmset,
1033 .write_room = spcp8x5_write_room,
1034 .read_bulk_callback = spcp8x5_read_bulk_callback,
1035 .write_bulk_callback = spcp8x5_write_bulk_callback,
1036 .chars_in_buffer = spcp8x5_chars_in_buffer,
1037 .attach = spcp8x5_startup,
1038 .shutdown = spcp8x5_shutdown,
1039};
1040
1041static int __init spcp8x5_init(void)
1042{
1043 int retval;
1044 retval = usb_serial_register(&spcp8x5_device);
1045 if (retval)
1046 goto failed_usb_serial_register;
1047 retval = usb_register(&spcp8x5_driver);
1048 if (retval)
1049 goto failed_usb_register;
1050 info(DRIVER_DESC " " DRIVER_VERSION);
1051 return 0;
1052failed_usb_register:
1053 usb_serial_deregister(&spcp8x5_device);
1054failed_usb_serial_register:
1055 return retval;
1056}
1057
1058static void __exit spcp8x5_exit(void)
1059{
1060 usb_deregister(&spcp8x5_driver);
1061 usb_serial_deregister(&spcp8x5_device);
1062}
1063
1064module_init(spcp8x5_init);
1065module_exit(spcp8x5_exit);
1066
1067MODULE_DESCRIPTION(DRIVER_DESC);
1068MODULE_VERSION(DRIVER_VERSION);
1069MODULE_LICENSE("GPL");
1070
1071module_param(debug, bool, S_IRUGO | S_IWUSR);
1072MODULE_PARM_DESC(debug, "Debug enabled or not");
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
index 3a377667733..a1c8aef0141 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -264,9 +264,6 @@ static struct usb_serial_driver ti_1port_device = {
264 .description = "TI USB 3410 1 port adapter", 264 .description = "TI USB 3410 1 port adapter",
265 .usb_driver = &ti_usb_driver, 265 .usb_driver = &ti_usb_driver,
266 .id_table = ti_id_table_3410, 266 .id_table = ti_id_table_3410,
267 .num_interrupt_in = NUM_DONT_CARE,
268 .num_bulk_in = NUM_DONT_CARE,
269 .num_bulk_out = 1,
270 .num_ports = 1, 267 .num_ports = 1,
271 .attach = ti_startup, 268 .attach = ti_startup,
272 .shutdown = ti_shutdown, 269 .shutdown = ti_shutdown,
@@ -295,9 +292,6 @@ static struct usb_serial_driver ti_2port_device = {
295 .description = "TI USB 5052 2 port adapter", 292 .description = "TI USB 5052 2 port adapter",
296 .usb_driver = &ti_usb_driver, 293 .usb_driver = &ti_usb_driver,
297 .id_table = ti_id_table_5052, 294 .id_table = ti_id_table_5052,
298 .num_interrupt_in = 1,
299 .num_bulk_in = 2,
300 .num_bulk_out = 2,
301 .num_ports = 2, 295 .num_ports = 2,
302 .attach = ti_startup, 296 .attach = ti_startup,
303 .shutdown = ti_shutdown, 297 .shutdown = ti_shutdown,
@@ -414,14 +408,14 @@ static int ti_startup(struct usb_serial *serial)
414 408
415 409
416 dbg("%s - product 0x%4X, num configurations %d, configuration value %d", 410 dbg("%s - product 0x%4X, num configurations %d, configuration value %d",
417 __FUNCTION__, le16_to_cpu(dev->descriptor.idProduct), 411 __func__, le16_to_cpu(dev->descriptor.idProduct),
418 dev->descriptor.bNumConfigurations, 412 dev->descriptor.bNumConfigurations,
419 dev->actconfig->desc.bConfigurationValue); 413 dev->actconfig->desc.bConfigurationValue);
420 414
421 /* create device structure */ 415 /* create device structure */
422 tdev = kzalloc(sizeof(struct ti_device), GFP_KERNEL); 416 tdev = kzalloc(sizeof(struct ti_device), GFP_KERNEL);
423 if (tdev == NULL) { 417 if (tdev == NULL) {
424 dev_err(&dev->dev, "%s - out of memory\n", __FUNCTION__); 418 dev_err(&dev->dev, "%s - out of memory\n", __func__);
425 return -ENOMEM; 419 return -ENOMEM;
426 } 420 }
427 mutex_init(&tdev->td_open_close_lock); 421 mutex_init(&tdev->td_open_close_lock);
@@ -431,7 +425,7 @@ static int ti_startup(struct usb_serial *serial)
431 /* determine device type */ 425 /* determine device type */
432 if (usb_match_id(serial->interface, ti_id_table_3410)) 426 if (usb_match_id(serial->interface, ti_id_table_3410))
433 tdev->td_is_3410 = 1; 427 tdev->td_is_3410 = 1;
434 dbg("%s - device type is %s", __FUNCTION__, tdev->td_is_3410 ? "3410" : "5052"); 428 dbg("%s - device type is %s", __func__, tdev->td_is_3410 ? "3410" : "5052");
435 429
436 /* if we have only 1 configuration, download firmware */ 430 /* if we have only 1 configuration, download firmware */
437 if (dev->descriptor.bNumConfigurations == 1) { 431 if (dev->descriptor.bNumConfigurations == 1) {
@@ -465,7 +459,7 @@ static int ti_startup(struct usb_serial *serial)
465 for (i = 0; i < serial->num_ports; ++i) { 459 for (i = 0; i < serial->num_ports; ++i) {
466 tport = kzalloc(sizeof(struct ti_port), GFP_KERNEL); 460 tport = kzalloc(sizeof(struct ti_port), GFP_KERNEL);
467 if (tport == NULL) { 461 if (tport == NULL) {
468 dev_err(&dev->dev, "%s - out of memory\n", __FUNCTION__); 462 dev_err(&dev->dev, "%s - out of memory\n", __func__);
469 status = -ENOMEM; 463 status = -ENOMEM;
470 goto free_tports; 464 goto free_tports;
471 } 465 }
@@ -477,7 +471,7 @@ static int ti_startup(struct usb_serial *serial)
477 init_waitqueue_head(&tport->tp_write_wait); 471 init_waitqueue_head(&tport->tp_write_wait);
478 tport->tp_write_buf = ti_buf_alloc(); 472 tport->tp_write_buf = ti_buf_alloc();
479 if (tport->tp_write_buf == NULL) { 473 if (tport->tp_write_buf == NULL) {
480 dev_err(&dev->dev, "%s - out of memory\n", __FUNCTION__); 474 dev_err(&dev->dev, "%s - out of memory\n", __func__);
481 kfree(tport); 475 kfree(tport);
482 status = -ENOMEM; 476 status = -ENOMEM;
483 goto free_tports; 477 goto free_tports;
@@ -510,7 +504,7 @@ static void ti_shutdown(struct usb_serial *serial)
510 struct ti_device *tdev = usb_get_serial_data(serial); 504 struct ti_device *tdev = usb_get_serial_data(serial);
511 struct ti_port *tport; 505 struct ti_port *tport;
512 506
513 dbg("%s", __FUNCTION__); 507 dbg("%s", __func__);
514 508
515 for (i=0; i < serial->num_ports; ++i) { 509 for (i=0; i < serial->num_ports; ++i) {
516 tport = usb_get_serial_port_data(serial->port[i]); 510 tport = usb_get_serial_port_data(serial->port[i]);
@@ -538,7 +532,7 @@ static int ti_open(struct usb_serial_port *port, struct file *file)
538 TI_PIPE_TIMEOUT_ENABLE | 532 TI_PIPE_TIMEOUT_ENABLE |
539 (TI_TRANSFER_TIMEOUT << 2)); 533 (TI_TRANSFER_TIMEOUT << 2));
540 534
541 dbg("%s - port %d", __FUNCTION__, port->number); 535 dbg("%s - port %d", __func__, port->number);
542 536
543 if (tport == NULL) 537 if (tport == NULL)
544 return -ENODEV; 538 return -ENODEV;
@@ -563,10 +557,10 @@ static int ti_open(struct usb_serial_port *port, struct file *file)
563 557
564 /* start interrupt urb the first time a port is opened on this device */ 558 /* start interrupt urb the first time a port is opened on this device */
565 if (tdev->td_open_port_count == 0) { 559 if (tdev->td_open_port_count == 0) {
566 dbg("%s - start interrupt in urb", __FUNCTION__); 560 dbg("%s - start interrupt in urb", __func__);
567 urb = tdev->td_serial->port[0]->interrupt_in_urb; 561 urb = tdev->td_serial->port[0]->interrupt_in_urb;
568 if (!urb) { 562 if (!urb) {
569 dev_err(&port->dev, "%s - no interrupt urb\n", __FUNCTION__); 563 dev_err(&port->dev, "%s - no interrupt urb\n", __func__);
570 status = -EINVAL; 564 status = -EINVAL;
571 goto release_lock; 565 goto release_lock;
572 } 566 }
@@ -575,40 +569,40 @@ static int ti_open(struct usb_serial_port *port, struct file *file)
575 urb->dev = dev; 569 urb->dev = dev;
576 status = usb_submit_urb(urb, GFP_KERNEL); 570 status = usb_submit_urb(urb, GFP_KERNEL);
577 if (status) { 571 if (status) {
578 dev_err(&port->dev, "%s - submit interrupt urb failed, %d\n", __FUNCTION__, status); 572 dev_err(&port->dev, "%s - submit interrupt urb failed, %d\n", __func__, status);
579 goto release_lock; 573 goto release_lock;
580 } 574 }
581 } 575 }
582 576
583 ti_set_termios(port, port->tty->termios); 577 ti_set_termios(port, port->tty->termios);
584 578
585 dbg("%s - sending TI_OPEN_PORT", __FUNCTION__); 579 dbg("%s - sending TI_OPEN_PORT", __func__);
586 status = ti_command_out_sync(tdev, TI_OPEN_PORT, 580 status = ti_command_out_sync(tdev, TI_OPEN_PORT,
587 (__u8)(TI_UART1_PORT + port_number), open_settings, NULL, 0); 581 (__u8)(TI_UART1_PORT + port_number), open_settings, NULL, 0);
588 if (status) { 582 if (status) {
589 dev_err(&port->dev, "%s - cannot send open command, %d\n", __FUNCTION__, status); 583 dev_err(&port->dev, "%s - cannot send open command, %d\n", __func__, status);
590 goto unlink_int_urb; 584 goto unlink_int_urb;
591 } 585 }
592 586
593 dbg("%s - sending TI_START_PORT", __FUNCTION__); 587 dbg("%s - sending TI_START_PORT", __func__);
594 status = ti_command_out_sync(tdev, TI_START_PORT, 588 status = ti_command_out_sync(tdev, TI_START_PORT,
595 (__u8)(TI_UART1_PORT + port_number), 0, NULL, 0); 589 (__u8)(TI_UART1_PORT + port_number), 0, NULL, 0);
596 if (status) { 590 if (status) {
597 dev_err(&port->dev, "%s - cannot send start command, %d\n", __FUNCTION__, status); 591 dev_err(&port->dev, "%s - cannot send start command, %d\n", __func__, status);
598 goto unlink_int_urb; 592 goto unlink_int_urb;
599 } 593 }
600 594
601 dbg("%s - sending TI_PURGE_PORT", __FUNCTION__); 595 dbg("%s - sending TI_PURGE_PORT", __func__);
602 status = ti_command_out_sync(tdev, TI_PURGE_PORT, 596 status = ti_command_out_sync(tdev, TI_PURGE_PORT,
603 (__u8)(TI_UART1_PORT + port_number), TI_PURGE_INPUT, NULL, 0); 597 (__u8)(TI_UART1_PORT + port_number), TI_PURGE_INPUT, NULL, 0);
604 if (status) { 598 if (status) {
605 dev_err(&port->dev, "%s - cannot clear input buffers, %d\n", __FUNCTION__, status); 599 dev_err(&port->dev, "%s - cannot clear input buffers, %d\n", __func__, status);
606 goto unlink_int_urb; 600 goto unlink_int_urb;
607 } 601 }
608 status = ti_command_out_sync(tdev, TI_PURGE_PORT, 602 status = ti_command_out_sync(tdev, TI_PURGE_PORT,
609 (__u8)(TI_UART1_PORT + port_number), TI_PURGE_OUTPUT, NULL, 0); 603 (__u8)(TI_UART1_PORT + port_number), TI_PURGE_OUTPUT, NULL, 0);
610 if (status) { 604 if (status) {
611 dev_err(&port->dev, "%s - cannot clear output buffers, %d\n", __FUNCTION__, status); 605 dev_err(&port->dev, "%s - cannot clear output buffers, %d\n", __func__, status);
612 goto unlink_int_urb; 606 goto unlink_int_urb;
613 } 607 }
614 608
@@ -619,27 +613,27 @@ static int ti_open(struct usb_serial_port *port, struct file *file)
619 613
620 ti_set_termios(port, port->tty->termios); 614 ti_set_termios(port, port->tty->termios);
621 615
622 dbg("%s - sending TI_OPEN_PORT (2)", __FUNCTION__); 616 dbg("%s - sending TI_OPEN_PORT (2)", __func__);
623 status = ti_command_out_sync(tdev, TI_OPEN_PORT, 617 status = ti_command_out_sync(tdev, TI_OPEN_PORT,
624 (__u8)(TI_UART1_PORT + port_number), open_settings, NULL, 0); 618 (__u8)(TI_UART1_PORT + port_number), open_settings, NULL, 0);
625 if (status) { 619 if (status) {
626 dev_err(&port->dev, "%s - cannot send open command (2), %d\n", __FUNCTION__, status); 620 dev_err(&port->dev, "%s - cannot send open command (2), %d\n", __func__, status);
627 goto unlink_int_urb; 621 goto unlink_int_urb;
628 } 622 }
629 623
630 dbg("%s - sending TI_START_PORT (2)", __FUNCTION__); 624 dbg("%s - sending TI_START_PORT (2)", __func__);
631 status = ti_command_out_sync(tdev, TI_START_PORT, 625 status = ti_command_out_sync(tdev, TI_START_PORT,
632 (__u8)(TI_UART1_PORT + port_number), 0, NULL, 0); 626 (__u8)(TI_UART1_PORT + port_number), 0, NULL, 0);
633 if (status) { 627 if (status) {
634 dev_err(&port->dev, "%s - cannot send start command (2), %d\n", __FUNCTION__, status); 628 dev_err(&port->dev, "%s - cannot send start command (2), %d\n", __func__, status);
635 goto unlink_int_urb; 629 goto unlink_int_urb;
636 } 630 }
637 631
638 /* start read urb */ 632 /* start read urb */
639 dbg("%s - start read urb", __FUNCTION__); 633 dbg("%s - start read urb", __func__);
640 urb = port->read_urb; 634 urb = port->read_urb;
641 if (!urb) { 635 if (!urb) {
642 dev_err(&port->dev, "%s - no read urb\n", __FUNCTION__); 636 dev_err(&port->dev, "%s - no read urb\n", __func__);
643 status = -EINVAL; 637 status = -EINVAL;
644 goto unlink_int_urb; 638 goto unlink_int_urb;
645 } 639 }
@@ -649,7 +643,7 @@ static int ti_open(struct usb_serial_port *port, struct file *file)
649 urb->dev = dev; 643 urb->dev = dev;
650 status = usb_submit_urb(urb, GFP_KERNEL); 644 status = usb_submit_urb(urb, GFP_KERNEL);
651 if (status) { 645 if (status) {
652 dev_err(&port->dev, "%s - submit read urb failed, %d\n", __FUNCTION__, status); 646 dev_err(&port->dev, "%s - submit read urb failed, %d\n", __func__, status);
653 goto unlink_int_urb; 647 goto unlink_int_urb;
654 } 648 }
655 649
@@ -663,7 +657,7 @@ unlink_int_urb:
663 usb_kill_urb(port->serial->port[0]->interrupt_in_urb); 657 usb_kill_urb(port->serial->port[0]->interrupt_in_urb);
664release_lock: 658release_lock:
665 mutex_unlock(&tdev->td_open_close_lock); 659 mutex_unlock(&tdev->td_open_close_lock);
666 dbg("%s - exit %d", __FUNCTION__, status); 660 dbg("%s - exit %d", __func__, status);
667 return status; 661 return status;
668} 662}
669 663
@@ -676,7 +670,7 @@ static void ti_close(struct usb_serial_port *port, struct file *file)
676 int status; 670 int status;
677 int do_unlock; 671 int do_unlock;
678 672
679 dbg("%s - port %d", __FUNCTION__, port->number); 673 dbg("%s - port %d", __func__, port->number);
680 674
681 tdev = usb_get_serial_data(port->serial); 675 tdev = usb_get_serial_data(port->serial);
682 tport = usb_get_serial_port_data(port); 676 tport = usb_get_serial_port_data(port);
@@ -693,11 +687,11 @@ static void ti_close(struct usb_serial_port *port, struct file *file)
693 687
694 port_number = port->number - port->serial->minor; 688 port_number = port->number - port->serial->minor;
695 689
696 dbg("%s - sending TI_CLOSE_PORT", __FUNCTION__); 690 dbg("%s - sending TI_CLOSE_PORT", __func__);
697 status = ti_command_out_sync(tdev, TI_CLOSE_PORT, 691 status = ti_command_out_sync(tdev, TI_CLOSE_PORT,
698 (__u8)(TI_UART1_PORT + port_number), 0, NULL, 0); 692 (__u8)(TI_UART1_PORT + port_number), 0, NULL, 0);
699 if (status) 693 if (status)
700 dev_err(&port->dev, "%s - cannot send close port command, %d\n" , __FUNCTION__, status); 694 dev_err(&port->dev, "%s - cannot send close port command, %d\n" , __func__, status);
701 695
702 /* if mutex_lock is interrupted, continue anyway */ 696 /* if mutex_lock is interrupted, continue anyway */
703 do_unlock = !mutex_lock_interruptible(&tdev->td_open_close_lock); 697 do_unlock = !mutex_lock_interruptible(&tdev->td_open_close_lock);
@@ -710,7 +704,7 @@ static void ti_close(struct usb_serial_port *port, struct file *file)
710 if (do_unlock) 704 if (do_unlock)
711 mutex_unlock(&tdev->td_open_close_lock); 705 mutex_unlock(&tdev->td_open_close_lock);
712 706
713 dbg("%s - exit", __FUNCTION__); 707 dbg("%s - exit", __func__);
714} 708}
715 709
716 710
@@ -720,10 +714,10 @@ static int ti_write(struct usb_serial_port *port, const unsigned char *data,
720 struct ti_port *tport = usb_get_serial_port_data(port); 714 struct ti_port *tport = usb_get_serial_port_data(port);
721 unsigned long flags; 715 unsigned long flags;
722 716
723 dbg("%s - port %d", __FUNCTION__, port->number); 717 dbg("%s - port %d", __func__, port->number);
724 718
725 if (count == 0) { 719 if (count == 0) {
726 dbg("%s - write request of 0 bytes", __FUNCTION__); 720 dbg("%s - write request of 0 bytes", __func__);
727 return 0; 721 return 0;
728 } 722 }
729 723
@@ -746,7 +740,7 @@ static int ti_write_room(struct usb_serial_port *port)
746 int room = 0; 740 int room = 0;
747 unsigned long flags; 741 unsigned long flags;
748 742
749 dbg("%s - port %d", __FUNCTION__, port->number); 743 dbg("%s - port %d", __func__, port->number);
750 744
751 if (tport == NULL) 745 if (tport == NULL)
752 return -ENODEV; 746 return -ENODEV;
@@ -755,7 +749,7 @@ static int ti_write_room(struct usb_serial_port *port)
755 room = ti_buf_space_avail(tport->tp_write_buf); 749 room = ti_buf_space_avail(tport->tp_write_buf);
756 spin_unlock_irqrestore(&tport->tp_lock, flags); 750 spin_unlock_irqrestore(&tport->tp_lock, flags);
757 751
758 dbg("%s - returns %d", __FUNCTION__, room); 752 dbg("%s - returns %d", __func__, room);
759 return room; 753 return room;
760} 754}
761 755
@@ -766,7 +760,7 @@ static int ti_chars_in_buffer(struct usb_serial_port *port)
766 int chars = 0; 760 int chars = 0;
767 unsigned long flags; 761 unsigned long flags;
768 762
769 dbg("%s - port %d", __FUNCTION__, port->number); 763 dbg("%s - port %d", __func__, port->number);
770 764
771 if (tport == NULL) 765 if (tport == NULL)
772 return -ENODEV; 766 return -ENODEV;
@@ -775,7 +769,7 @@ static int ti_chars_in_buffer(struct usb_serial_port *port)
775 chars = ti_buf_data_avail(tport->tp_write_buf); 769 chars = ti_buf_data_avail(tport->tp_write_buf);
776 spin_unlock_irqrestore(&tport->tp_lock, flags); 770 spin_unlock_irqrestore(&tport->tp_lock, flags);
777 771
778 dbg("%s - returns %d", __FUNCTION__, chars); 772 dbg("%s - returns %d", __func__, chars);
779 return chars; 773 return chars;
780} 774}
781 775
@@ -785,14 +779,14 @@ static void ti_throttle(struct usb_serial_port *port)
785 struct ti_port *tport = usb_get_serial_port_data(port); 779 struct ti_port *tport = usb_get_serial_port_data(port);
786 struct tty_struct *tty; 780 struct tty_struct *tty;
787 781
788 dbg("%s - port %d", __FUNCTION__, port->number); 782 dbg("%s - port %d", __func__, port->number);
789 783
790 if (tport == NULL) 784 if (tport == NULL)
791 return; 785 return;
792 786
793 tty = port->tty; 787 tty = port->tty;
794 if (!tty) { 788 if (!tty) {
795 dbg("%s - no tty", __FUNCTION__); 789 dbg("%s - no tty", __func__);
796 return; 790 return;
797 } 791 }
798 792
@@ -808,21 +802,21 @@ static void ti_unthrottle(struct usb_serial_port *port)
808 struct tty_struct *tty; 802 struct tty_struct *tty;
809 int status; 803 int status;
810 804
811 dbg("%s - port %d", __FUNCTION__, port->number); 805 dbg("%s - port %d", __func__, port->number);
812 806
813 if (tport == NULL) 807 if (tport == NULL)
814 return; 808 return;
815 809
816 tty = port->tty; 810 tty = port->tty;
817 if (!tty) { 811 if (!tty) {
818 dbg("%s - no tty", __FUNCTION__); 812 dbg("%s - no tty", __func__);
819 return; 813 return;
820 } 814 }
821 815
822 if (I_IXOFF(tty) || C_CRTSCTS(tty)) { 816 if (I_IXOFF(tty) || C_CRTSCTS(tty)) {
823 status = ti_restart_read(tport, tty); 817 status = ti_restart_read(tport, tty);
824 if (status) 818 if (status)
825 dev_err(&port->dev, "%s - cannot restart read, %d\n", __FUNCTION__, status); 819 dev_err(&port->dev, "%s - cannot restart read, %d\n", __func__, status);
826 } 820 }
827} 821}
828 822
@@ -834,24 +828,24 @@ static int ti_ioctl(struct usb_serial_port *port, struct file *file,
834 struct async_icount cnow; 828 struct async_icount cnow;
835 struct async_icount cprev; 829 struct async_icount cprev;
836 830
837 dbg("%s - port %d, cmd = 0x%04X", __FUNCTION__, port->number, cmd); 831 dbg("%s - port %d, cmd = 0x%04X", __func__, port->number, cmd);
838 832
839 if (tport == NULL) 833 if (tport == NULL)
840 return -ENODEV; 834 return -ENODEV;
841 835
842 switch (cmd) { 836 switch (cmd) {
843 case TIOCGSERIAL: 837 case TIOCGSERIAL:
844 dbg("%s - (%d) TIOCGSERIAL", __FUNCTION__, port->number); 838 dbg("%s - (%d) TIOCGSERIAL", __func__, port->number);
845 return ti_get_serial_info(tport, (struct serial_struct __user *)arg); 839 return ti_get_serial_info(tport, (struct serial_struct __user *)arg);
846 break; 840 break;
847 841
848 case TIOCSSERIAL: 842 case TIOCSSERIAL:
849 dbg("%s - (%d) TIOCSSERIAL", __FUNCTION__, port->number); 843 dbg("%s - (%d) TIOCSSERIAL", __func__, port->number);
850 return ti_set_serial_info(tport, (struct serial_struct __user *)arg); 844 return ti_set_serial_info(tport, (struct serial_struct __user *)arg);
851 break; 845 break;
852 846
853 case TIOCMIWAIT: 847 case TIOCMIWAIT:
854 dbg("%s - (%d) TIOCMIWAIT", __FUNCTION__, port->number); 848 dbg("%s - (%d) TIOCMIWAIT", __func__, port->number);
855 cprev = tport->tp_icount; 849 cprev = tport->tp_icount;
856 while (1) { 850 while (1) {
857 interruptible_sleep_on(&tport->tp_msr_wait); 851 interruptible_sleep_on(&tport->tp_msr_wait);
@@ -872,7 +866,7 @@ static int ti_ioctl(struct usb_serial_port *port, struct file *file,
872 break; 866 break;
873 867
874 case TIOCGICOUNT: 868 case TIOCGICOUNT:
875 dbg("%s - (%d) TIOCGICOUNT RX=%d, TX=%d", __FUNCTION__, port->number, tport->tp_icount.rx, tport->tp_icount.tx); 869 dbg("%s - (%d) TIOCGICOUNT RX=%d, TX=%d", __func__, port->number, tport->tp_icount.rx, tport->tp_icount.tx);
876 if (copy_to_user((void __user *)arg, &tport->tp_icount, sizeof(tport->tp_icount))) 870 if (copy_to_user((void __user *)arg, &tport->tp_icount, sizeof(tport->tp_icount)))
877 return -EFAULT; 871 return -EFAULT;
878 return 0; 872 return 0;
@@ -894,20 +888,20 @@ static void ti_set_termios(struct usb_serial_port *port,
894 int port_number = port->number - port->serial->minor; 888 int port_number = port->number - port->serial->minor;
895 unsigned int mcr; 889 unsigned int mcr;
896 890
897 dbg("%s - port %d", __FUNCTION__, port->number); 891 dbg("%s - port %d", __func__, port->number);
898 892
899 cflag = tty->termios->c_cflag; 893 cflag = tty->termios->c_cflag;
900 iflag = tty->termios->c_iflag; 894 iflag = tty->termios->c_iflag;
901 895
902 dbg("%s - cflag %08x, iflag %08x", __FUNCTION__, cflag, iflag); 896 dbg("%s - cflag %08x, iflag %08x", __func__, cflag, iflag);
903 dbg("%s - old clfag %08x, old iflag %08x", __FUNCTION__, old_termios->c_cflag, old_termios->c_iflag); 897 dbg("%s - old clfag %08x, old iflag %08x", __func__, old_termios->c_cflag, old_termios->c_iflag);
904 898
905 if (tport == NULL) 899 if (tport == NULL)
906 return; 900 return;
907 901
908 config = kmalloc(sizeof(*config), GFP_KERNEL); 902 config = kmalloc(sizeof(*config), GFP_KERNEL);
909 if (!config) { 903 if (!config) {
910 dev_err(&port->dev, "%s - out of memory\n", __FUNCTION__); 904 dev_err(&port->dev, "%s - out of memory\n", __func__);
911 return; 905 return;
912 } 906 }
913 907
@@ -991,7 +985,7 @@ static void ti_set_termios(struct usb_serial_port *port,
991 tty_encode_baud_rate(tty, baud, baud); 985 tty_encode_baud_rate(tty, baud, baud);
992 986
993 dbg("%s - BaudRate=%d, wBaudRate=%d, wFlags=0x%04X, bDataBits=%d, bParity=%d, bStopBits=%d, cXon=%d, cXoff=%d, bUartMode=%d", 987 dbg("%s - BaudRate=%d, wBaudRate=%d, wFlags=0x%04X, bDataBits=%d, bParity=%d, bStopBits=%d, cXon=%d, cXoff=%d, bUartMode=%d",
994 __FUNCTION__, baud, config->wBaudRate, config->wFlags, config->bDataBits, config->bParity, config->bStopBits, config->cXon, config->cXoff, config->bUartMode); 988 __func__, baud, config->wBaudRate, config->wFlags, config->bDataBits, config->bParity, config->bStopBits, config->cXon, config->cXoff, config->bUartMode);
995 989
996 cpu_to_be16s(&config->wBaudRate); 990 cpu_to_be16s(&config->wBaudRate);
997 cpu_to_be16s(&config->wFlags); 991 cpu_to_be16s(&config->wFlags);
@@ -1000,7 +994,7 @@ static void ti_set_termios(struct usb_serial_port *port,
1000 (__u8)(TI_UART1_PORT + port_number), 0, (__u8 *)config, 994 (__u8)(TI_UART1_PORT + port_number), 0, (__u8 *)config,
1001 sizeof(*config)); 995 sizeof(*config));
1002 if (status) 996 if (status)
1003 dev_err(&port->dev, "%s - cannot set config on port %d, %d\n", __FUNCTION__, port_number, status); 997 dev_err(&port->dev, "%s - cannot set config on port %d, %d\n", __func__, port_number, status);
1004 998
1005 /* SET_CONFIG asserts RTS and DTR, reset them correctly */ 999 /* SET_CONFIG asserts RTS and DTR, reset them correctly */
1006 mcr = tport->tp_shadow_mcr; 1000 mcr = tport->tp_shadow_mcr;
@@ -1009,7 +1003,7 @@ static void ti_set_termios(struct usb_serial_port *port,
1009 mcr &= ~(TI_MCR_DTR | TI_MCR_RTS); 1003 mcr &= ~(TI_MCR_DTR | TI_MCR_RTS);
1010 status = ti_set_mcr(tport, mcr); 1004 status = ti_set_mcr(tport, mcr);
1011 if (status) 1005 if (status)
1012 dev_err(&port->dev, "%s - cannot set modem control on port %d, %d\n", __FUNCTION__, port_number, status); 1006 dev_err(&port->dev, "%s - cannot set modem control on port %d, %d\n", __func__, port_number, status);
1013 1007
1014 kfree(config); 1008 kfree(config);
1015} 1009}
@@ -1021,14 +1015,17 @@ static int ti_tiocmget(struct usb_serial_port *port, struct file *file)
1021 unsigned int result; 1015 unsigned int result;
1022 unsigned int msr; 1016 unsigned int msr;
1023 unsigned int mcr; 1017 unsigned int mcr;
1018 unsigned long flags;
1024 1019
1025 dbg("%s - port %d", __FUNCTION__, port->number); 1020 dbg("%s - port %d", __func__, port->number);
1026 1021
1027 if (tport == NULL) 1022 if (tport == NULL)
1028 return -ENODEV; 1023 return -ENODEV;
1029 1024
1025 spin_lock_irqsave(&tport->tp_lock, flags);
1030 msr = tport->tp_msr; 1026 msr = tport->tp_msr;
1031 mcr = tport->tp_shadow_mcr; 1027 mcr = tport->tp_shadow_mcr;
1028 spin_unlock_irqrestore(&tport->tp_lock, flags);
1032 1029
1033 result = ((mcr & TI_MCR_DTR) ? TIOCM_DTR : 0) 1030 result = ((mcr & TI_MCR_DTR) ? TIOCM_DTR : 0)
1034 | ((mcr & TI_MCR_RTS) ? TIOCM_RTS : 0) 1031 | ((mcr & TI_MCR_RTS) ? TIOCM_RTS : 0)
@@ -1038,7 +1035,7 @@ static int ti_tiocmget(struct usb_serial_port *port, struct file *file)
1038 | ((msr & TI_MSR_RI) ? TIOCM_RI : 0) 1035 | ((msr & TI_MSR_RI) ? TIOCM_RI : 0)
1039 | ((msr & TI_MSR_DSR) ? TIOCM_DSR : 0); 1036 | ((msr & TI_MSR_DSR) ? TIOCM_DSR : 0);
1040 1037
1041 dbg("%s - 0x%04X", __FUNCTION__, result); 1038 dbg("%s - 0x%04X", __func__, result);
1042 1039
1043 return result; 1040 return result;
1044} 1041}
@@ -1049,12 +1046,14 @@ static int ti_tiocmset(struct usb_serial_port *port, struct file *file,
1049{ 1046{
1050 struct ti_port *tport = usb_get_serial_port_data(port); 1047 struct ti_port *tport = usb_get_serial_port_data(port);
1051 unsigned int mcr; 1048 unsigned int mcr;
1049 unsigned long flags;
1052 1050
1053 dbg("%s - port %d", __FUNCTION__, port->number); 1051 dbg("%s - port %d", __func__, port->number);
1054 1052
1055 if (tport == NULL) 1053 if (tport == NULL)
1056 return -ENODEV; 1054 return -ENODEV;
1057 1055
1056 spin_lock_irqsave(&tport->tp_lock, flags);
1058 mcr = tport->tp_shadow_mcr; 1057 mcr = tport->tp_shadow_mcr;
1059 1058
1060 if (set & TIOCM_RTS) 1059 if (set & TIOCM_RTS)
@@ -1070,6 +1069,7 @@ static int ti_tiocmset(struct usb_serial_port *port, struct file *file,
1070 mcr &= ~TI_MCR_DTR; 1069 mcr &= ~TI_MCR_DTR;
1071 if (clear & TIOCM_LOOP) 1070 if (clear & TIOCM_LOOP)
1072 mcr &= ~TI_MCR_LOOP; 1071 mcr &= ~TI_MCR_LOOP;
1072 spin_unlock_irqrestore(&tport->tp_lock, flags);
1073 1073
1074 return ti_set_mcr(tport, mcr); 1074 return ti_set_mcr(tport, mcr);
1075} 1075}
@@ -1080,7 +1080,7 @@ static void ti_break(struct usb_serial_port *port, int break_state)
1080 struct ti_port *tport = usb_get_serial_port_data(port); 1080 struct ti_port *tport = usb_get_serial_port_data(port);
1081 int status; 1081 int status;
1082 1082
1083 dbg("%s - state = %d", __FUNCTION__, break_state); 1083 dbg("%s - state = %d", __func__, break_state);
1084 1084
1085 if (tport == NULL) 1085 if (tport == NULL)
1086 return; 1086 return;
@@ -1092,13 +1092,13 @@ static void ti_break(struct usb_serial_port *port, int break_state)
1092 TI_LCR_BREAK, break_state == -1 ? TI_LCR_BREAK : 0); 1092 TI_LCR_BREAK, break_state == -1 ? TI_LCR_BREAK : 0);
1093 1093
1094 if (status) 1094 if (status)
1095 dbg("%s - error setting break, %d", __FUNCTION__, status); 1095 dbg("%s - error setting break, %d", __func__, status);
1096} 1096}
1097 1097
1098 1098
1099static void ti_interrupt_callback(struct urb *urb) 1099static void ti_interrupt_callback(struct urb *urb)
1100{ 1100{
1101 struct ti_device *tdev = (struct ti_device *)urb->context; 1101 struct ti_device *tdev = urb->context;
1102 struct usb_serial_port *port; 1102 struct usb_serial_port *port;
1103 struct usb_serial *serial = tdev->td_serial; 1103 struct usb_serial *serial = tdev->td_serial;
1104 struct ti_port *tport; 1104 struct ti_port *tport;
@@ -1111,7 +1111,7 @@ static void ti_interrupt_callback(struct urb *urb)
1111 int retval; 1111 int retval;
1112 __u8 msr; 1112 __u8 msr;
1113 1113
1114 dbg("%s", __FUNCTION__); 1114 dbg("%s", __func__);
1115 1115
1116 switch (status) { 1116 switch (status) {
1117 case 0: 1117 case 0:
@@ -1119,33 +1119,33 @@ static void ti_interrupt_callback(struct urb *urb)
1119 case -ECONNRESET: 1119 case -ECONNRESET:
1120 case -ENOENT: 1120 case -ENOENT:
1121 case -ESHUTDOWN: 1121 case -ESHUTDOWN:
1122 dbg("%s - urb shutting down, %d", __FUNCTION__, status); 1122 dbg("%s - urb shutting down, %d", __func__, status);
1123 tdev->td_urb_error = 1; 1123 tdev->td_urb_error = 1;
1124 return; 1124 return;
1125 default: 1125 default:
1126 dev_err(dev, "%s - nonzero urb status, %d\n", 1126 dev_err(dev, "%s - nonzero urb status, %d\n",
1127 __FUNCTION__, status); 1127 __func__, status);
1128 tdev->td_urb_error = 1; 1128 tdev->td_urb_error = 1;
1129 goto exit; 1129 goto exit;
1130 } 1130 }
1131 1131
1132 if (length != 2) { 1132 if (length != 2) {
1133 dbg("%s - bad packet size, %d", __FUNCTION__, length); 1133 dbg("%s - bad packet size, %d", __func__, length);
1134 goto exit; 1134 goto exit;
1135 } 1135 }
1136 1136
1137 if (data[0] == TI_CODE_HARDWARE_ERROR) { 1137 if (data[0] == TI_CODE_HARDWARE_ERROR) {
1138 dev_err(dev, "%s - hardware error, %d\n", __FUNCTION__, data[1]); 1138 dev_err(dev, "%s - hardware error, %d\n", __func__, data[1]);
1139 goto exit; 1139 goto exit;
1140 } 1140 }
1141 1141
1142 port_number = TI_GET_PORT_FROM_CODE(data[0]); 1142 port_number = TI_GET_PORT_FROM_CODE(data[0]);
1143 function = TI_GET_FUNC_FROM_CODE(data[0]); 1143 function = TI_GET_FUNC_FROM_CODE(data[0]);
1144 1144
1145 dbg("%s - port_number %d, function %d, data 0x%02X", __FUNCTION__, port_number, function, data[1]); 1145 dbg("%s - port_number %d, function %d, data 0x%02X", __func__, port_number, function, data[1]);
1146 1146
1147 if (port_number >= serial->num_ports) { 1147 if (port_number >= serial->num_ports) {
1148 dev_err(dev, "%s - bad port number, %d\n", __FUNCTION__, port_number); 1148 dev_err(dev, "%s - bad port number, %d\n", __func__, port_number);
1149 goto exit; 1149 goto exit;
1150 } 1150 }
1151 1151
@@ -1157,17 +1157,17 @@ static void ti_interrupt_callback(struct urb *urb)
1157 1157
1158 switch (function) { 1158 switch (function) {
1159 case TI_CODE_DATA_ERROR: 1159 case TI_CODE_DATA_ERROR:
1160 dev_err(dev, "%s - DATA ERROR, port %d, data 0x%02X\n", __FUNCTION__, port_number, data[1]); 1160 dev_err(dev, "%s - DATA ERROR, port %d, data 0x%02X\n", __func__, port_number, data[1]);
1161 break; 1161 break;
1162 1162
1163 case TI_CODE_MODEM_STATUS: 1163 case TI_CODE_MODEM_STATUS:
1164 msr = data[1]; 1164 msr = data[1];
1165 dbg("%s - port %d, msr 0x%02X", __FUNCTION__, port_number, msr); 1165 dbg("%s - port %d, msr 0x%02X", __func__, port_number, msr);
1166 ti_handle_new_msr(tport, msr); 1166 ti_handle_new_msr(tport, msr);
1167 break; 1167 break;
1168 1168
1169 default: 1169 default:
1170 dev_err(dev, "%s - unknown interrupt code, 0x%02X\n", __FUNCTION__, data[1]); 1170 dev_err(dev, "%s - unknown interrupt code, 0x%02X\n", __func__, data[1]);
1171 break; 1171 break;
1172 } 1172 }
1173 1173
@@ -1175,19 +1175,19 @@ exit:
1175 retval = usb_submit_urb(urb, GFP_ATOMIC); 1175 retval = usb_submit_urb(urb, GFP_ATOMIC);
1176 if (retval) 1176 if (retval)
1177 dev_err(dev, "%s - resubmit interrupt urb failed, %d\n", 1177 dev_err(dev, "%s - resubmit interrupt urb failed, %d\n",
1178 __FUNCTION__, retval); 1178 __func__, retval);
1179} 1179}
1180 1180
1181 1181
1182static void ti_bulk_in_callback(struct urb *urb) 1182static void ti_bulk_in_callback(struct urb *urb)
1183{ 1183{
1184 struct ti_port *tport = (struct ti_port *)urb->context; 1184 struct ti_port *tport = urb->context;
1185 struct usb_serial_port *port = tport->tp_port; 1185 struct usb_serial_port *port = tport->tp_port;
1186 struct device *dev = &urb->dev->dev; 1186 struct device *dev = &urb->dev->dev;
1187 int status = urb->status; 1187 int status = urb->status;
1188 int retval = 0; 1188 int retval = 0;
1189 1189
1190 dbg("%s", __FUNCTION__); 1190 dbg("%s", __func__);
1191 1191
1192 switch (status) { 1192 switch (status) {
1193 case 0: 1193 case 0:
@@ -1195,13 +1195,13 @@ static void ti_bulk_in_callback(struct urb *urb)
1195 case -ECONNRESET: 1195 case -ECONNRESET:
1196 case -ENOENT: 1196 case -ENOENT:
1197 case -ESHUTDOWN: 1197 case -ESHUTDOWN:
1198 dbg("%s - urb shutting down, %d", __FUNCTION__, status); 1198 dbg("%s - urb shutting down, %d", __func__, status);
1199 tport->tp_tdev->td_urb_error = 1; 1199 tport->tp_tdev->td_urb_error = 1;
1200 wake_up_interruptible(&tport->tp_write_wait); 1200 wake_up_interruptible(&tport->tp_write_wait);
1201 return; 1201 return;
1202 default: 1202 default:
1203 dev_err(dev, "%s - nonzero urb status, %d\n", 1203 dev_err(dev, "%s - nonzero urb status, %d\n",
1204 __FUNCTION__, status ); 1204 __func__, status );
1205 tport->tp_tdev->td_urb_error = 1; 1205 tport->tp_tdev->td_urb_error = 1;
1206 wake_up_interruptible(&tport->tp_write_wait); 1206 wake_up_interruptible(&tport->tp_write_wait);
1207 } 1207 }
@@ -1210,16 +1210,16 @@ static void ti_bulk_in_callback(struct urb *urb)
1210 goto exit; 1210 goto exit;
1211 1211
1212 if (status) { 1212 if (status) {
1213 dev_err(dev, "%s - stopping read!\n", __FUNCTION__); 1213 dev_err(dev, "%s - stopping read!\n", __func__);
1214 return; 1214 return;
1215 } 1215 }
1216 1216
1217 if (port->tty && urb->actual_length) { 1217 if (port->tty && urb->actual_length) {
1218 usb_serial_debug_data(debug, dev, __FUNCTION__, 1218 usb_serial_debug_data(debug, dev, __func__,
1219 urb->actual_length, urb->transfer_buffer); 1219 urb->actual_length, urb->transfer_buffer);
1220 1220
1221 if (!tport->tp_is_open) 1221 if (!tport->tp_is_open)
1222 dbg("%s - port closed, dropping data", __FUNCTION__); 1222 dbg("%s - port closed, dropping data", __func__);
1223 else 1223 else
1224 ti_recv(&urb->dev->dev, port->tty, urb->transfer_buffer, 1224 ti_recv(&urb->dev->dev, port->tty, urb->transfer_buffer,
1225 urb->actual_length); 1225 urb->actual_length);
@@ -1241,18 +1241,18 @@ exit:
1241 spin_unlock(&tport->tp_lock); 1241 spin_unlock(&tport->tp_lock);
1242 if (retval) 1242 if (retval)
1243 dev_err(dev, "%s - resubmit read urb failed, %d\n", 1243 dev_err(dev, "%s - resubmit read urb failed, %d\n",
1244 __FUNCTION__, retval); 1244 __func__, retval);
1245} 1245}
1246 1246
1247 1247
1248static void ti_bulk_out_callback(struct urb *urb) 1248static void ti_bulk_out_callback(struct urb *urb)
1249{ 1249{
1250 struct ti_port *tport = (struct ti_port *)urb->context; 1250 struct ti_port *tport = urb->context;
1251 struct usb_serial_port *port = tport->tp_port; 1251 struct usb_serial_port *port = tport->tp_port;
1252 struct device *dev = &urb->dev->dev; 1252 struct device *dev = &urb->dev->dev;
1253 int status = urb->status; 1253 int status = urb->status;
1254 1254
1255 dbg("%s - port %d", __FUNCTION__, port->number); 1255 dbg("%s - port %d", __func__, port->number);
1256 1256
1257 tport->tp_write_urb_in_use = 0; 1257 tport->tp_write_urb_in_use = 0;
1258 1258
@@ -1262,13 +1262,13 @@ static void ti_bulk_out_callback(struct urb *urb)
1262 case -ECONNRESET: 1262 case -ECONNRESET:
1263 case -ENOENT: 1263 case -ENOENT:
1264 case -ESHUTDOWN: 1264 case -ESHUTDOWN:
1265 dbg("%s - urb shutting down, %d", __FUNCTION__, status); 1265 dbg("%s - urb shutting down, %d", __func__, status);
1266 tport->tp_tdev->td_urb_error = 1; 1266 tport->tp_tdev->td_urb_error = 1;
1267 wake_up_interruptible(&tport->tp_write_wait); 1267 wake_up_interruptible(&tport->tp_write_wait);
1268 return; 1268 return;
1269 default: 1269 default:
1270 dev_err(dev, "%s - nonzero urb status, %d\n", 1270 dev_err(dev, "%s - nonzero urb status, %d\n",
1271 __FUNCTION__, status); 1271 __func__, status);
1272 tport->tp_tdev->td_urb_error = 1; 1272 tport->tp_tdev->td_urb_error = 1;
1273 wake_up_interruptible(&tport->tp_write_wait); 1273 wake_up_interruptible(&tport->tp_write_wait);
1274 } 1274 }
@@ -1286,7 +1286,7 @@ static void ti_recv(struct device *dev, struct tty_struct *tty,
1286 do { 1286 do {
1287 cnt = tty_buffer_request_room(tty, length); 1287 cnt = tty_buffer_request_room(tty, length);
1288 if (cnt < length) { 1288 if (cnt < length) {
1289 dev_err(dev, "%s - dropping data, %d bytes lost\n", __FUNCTION__, length - cnt); 1289 dev_err(dev, "%s - dropping data, %d bytes lost\n", __func__, length - cnt);
1290 if(cnt == 0) 1290 if(cnt == 0)
1291 break; 1291 break;
1292 } 1292 }
@@ -1307,7 +1307,7 @@ static void ti_send(struct ti_port *tport)
1307 unsigned long flags; 1307 unsigned long flags;
1308 1308
1309 1309
1310 dbg("%s - port %d", __FUNCTION__, port->number); 1310 dbg("%s - port %d", __func__, port->number);
1311 1311
1312 spin_lock_irqsave(&tport->tp_lock, flags); 1312 spin_lock_irqsave(&tport->tp_lock, flags);
1313 1313
@@ -1329,7 +1329,7 @@ static void ti_send(struct ti_port *tport)
1329 1329
1330 spin_unlock_irqrestore(&tport->tp_lock, flags); 1330 spin_unlock_irqrestore(&tport->tp_lock, flags);
1331 1331
1332 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count, port->write_urb->transfer_buffer); 1332 usb_serial_debug_data(debug, &port->dev, __func__, count, port->write_urb->transfer_buffer);
1333 1333
1334 usb_fill_bulk_urb(port->write_urb, port->serial->dev, 1334 usb_fill_bulk_urb(port->write_urb, port->serial->dev,
1335 usb_sndbulkpipe(port->serial->dev, 1335 usb_sndbulkpipe(port->serial->dev,
@@ -1339,7 +1339,7 @@ static void ti_send(struct ti_port *tport)
1339 1339
1340 result = usb_submit_urb(port->write_urb, GFP_ATOMIC); 1340 result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
1341 if (result) { 1341 if (result) {
1342 dev_err(&port->dev, "%s - submit write urb failed, %d\n", __FUNCTION__, result); 1342 dev_err(&port->dev, "%s - submit write urb failed, %d\n", __func__, result);
1343 tport->tp_write_urb_in_use = 0; 1343 tport->tp_write_urb_in_use = 0;
1344 /* TODO: reschedule ti_send */ 1344 /* TODO: reschedule ti_send */
1345 } else { 1345 } else {
@@ -1357,14 +1357,17 @@ static void ti_send(struct ti_port *tport)
1357 1357
1358static int ti_set_mcr(struct ti_port *tport, unsigned int mcr) 1358static int ti_set_mcr(struct ti_port *tport, unsigned int mcr)
1359{ 1359{
1360 unsigned long flags;
1360 int status; 1361 int status;
1361 1362
1362 status = ti_write_byte(tport->tp_tdev, 1363 status = ti_write_byte(tport->tp_tdev,
1363 tport->tp_uart_base_addr + TI_UART_OFFSET_MCR, 1364 tport->tp_uart_base_addr + TI_UART_OFFSET_MCR,
1364 TI_MCR_RTS | TI_MCR_DTR | TI_MCR_LOOP, mcr); 1365 TI_MCR_RTS | TI_MCR_DTR | TI_MCR_LOOP, mcr);
1365 1366
1367 spin_lock_irqsave(&tport->tp_lock, flags);
1366 if (!status) 1368 if (!status)
1367 tport->tp_shadow_mcr = mcr; 1369 tport->tp_shadow_mcr = mcr;
1370 spin_unlock_irqrestore(&tport->tp_lock, flags);
1368 1371
1369 return status; 1372 return status;
1370} 1373}
@@ -1378,23 +1381,23 @@ static int ti_get_lsr(struct ti_port *tport)
1378 int port_number = port->number - port->serial->minor; 1381 int port_number = port->number - port->serial->minor;
1379 struct ti_port_status *data; 1382 struct ti_port_status *data;
1380 1383
1381 dbg("%s - port %d", __FUNCTION__, port->number); 1384 dbg("%s - port %d", __func__, port->number);
1382 1385
1383 size = sizeof(struct ti_port_status); 1386 size = sizeof(struct ti_port_status);
1384 data = kmalloc(size, GFP_KERNEL); 1387 data = kmalloc(size, GFP_KERNEL);
1385 if (!data) { 1388 if (!data) {
1386 dev_err(&port->dev, "%s - out of memory\n", __FUNCTION__); 1389 dev_err(&port->dev, "%s - out of memory\n", __func__);
1387 return -ENOMEM; 1390 return -ENOMEM;
1388 } 1391 }
1389 1392
1390 status = ti_command_in_sync(tdev, TI_GET_PORT_STATUS, 1393 status = ti_command_in_sync(tdev, TI_GET_PORT_STATUS,
1391 (__u8)(TI_UART1_PORT+port_number), 0, (__u8 *)data, size); 1394 (__u8)(TI_UART1_PORT+port_number), 0, (__u8 *)data, size);
1392 if (status) { 1395 if (status) {
1393 dev_err(&port->dev, "%s - get port status command failed, %d\n", __FUNCTION__, status); 1396 dev_err(&port->dev, "%s - get port status command failed, %d\n", __func__, status);
1394 goto free_data; 1397 goto free_data;
1395 } 1398 }
1396 1399
1397 dbg("%s - lsr 0x%02X", __FUNCTION__, data->bLSR); 1400 dbg("%s - lsr 0x%02X", __func__, data->bLSR);
1398 1401
1399 tport->tp_lsr = data->bLSR; 1402 tport->tp_lsr = data->bLSR;
1400 1403
@@ -1455,7 +1458,7 @@ static void ti_handle_new_msr(struct ti_port *tport, __u8 msr)
1455 struct tty_struct *tty; 1458 struct tty_struct *tty;
1456 unsigned long flags; 1459 unsigned long flags;
1457 1460
1458 dbg("%s - msr 0x%02X", __FUNCTION__, msr); 1461 dbg("%s - msr 0x%02X", __func__, msr);
1459 1462
1460 if (msr & TI_MSR_DELTA_MASK) { 1463 if (msr & TI_MSR_DELTA_MASK) {
1461 spin_lock_irqsave(&tport->tp_lock, flags); 1464 spin_lock_irqsave(&tport->tp_lock, flags);
@@ -1493,7 +1496,7 @@ static void ti_drain(struct ti_port *tport, unsigned long timeout, int flush)
1493 struct usb_serial_port *port = tport->tp_port; 1496 struct usb_serial_port *port = tport->tp_port;
1494 wait_queue_t wait; 1497 wait_queue_t wait;
1495 1498
1496 dbg("%s - port %d", __FUNCTION__, port->number); 1499 dbg("%s - port %d", __func__, port->number);
1497 1500
1498 spin_lock_irq(&tport->tp_lock); 1501 spin_lock_irq(&tport->tp_lock);
1499 1502
@@ -1625,12 +1628,12 @@ static int ti_write_byte(struct ti_device *tdev, unsigned long addr,
1625 struct ti_write_data_bytes *data; 1628 struct ti_write_data_bytes *data;
1626 struct device *dev = &tdev->td_serial->dev->dev; 1629 struct device *dev = &tdev->td_serial->dev->dev;
1627 1630
1628 dbg("%s - addr 0x%08lX, mask 0x%02X, byte 0x%02X", __FUNCTION__, addr, mask, byte); 1631 dbg("%s - addr 0x%08lX, mask 0x%02X, byte 0x%02X", __func__, addr, mask, byte);
1629 1632
1630 size = sizeof(struct ti_write_data_bytes) + 2; 1633 size = sizeof(struct ti_write_data_bytes) + 2;
1631 data = kmalloc(size, GFP_KERNEL); 1634 data = kmalloc(size, GFP_KERNEL);
1632 if (!data) { 1635 if (!data) {
1633 dev_err(dev, "%s - out of memory\n", __FUNCTION__); 1636 dev_err(dev, "%s - out of memory\n", __func__);
1634 return -ENOMEM; 1637 return -ENOMEM;
1635 } 1638 }
1636 1639
@@ -1646,7 +1649,7 @@ static int ti_write_byte(struct ti_device *tdev, unsigned long addr,
1646 (__u8 *)data, size); 1649 (__u8 *)data, size);
1647 1650
1648 if (status < 0) 1651 if (status < 0)
1649 dev_err(dev, "%s - failed, %d\n", __FUNCTION__, status); 1652 dev_err(dev, "%s - failed, %d\n", __func__, status);
1650 1653
1651 kfree(data); 1654 kfree(data);
1652 1655
@@ -1673,7 +1676,7 @@ static int ti_download_firmware(struct ti_device *tdev,
1673 buffer_size = TI_FIRMWARE_BUF_SIZE + sizeof(struct ti_firmware_header); 1676 buffer_size = TI_FIRMWARE_BUF_SIZE + sizeof(struct ti_firmware_header);
1674 buffer = kmalloc(buffer_size, GFP_KERNEL); 1677 buffer = kmalloc(buffer_size, GFP_KERNEL);
1675 if (!buffer) { 1678 if (!buffer) {
1676 dev_err(&dev->dev, "%s - out of memory\n", __FUNCTION__); 1679 dev_err(&dev->dev, "%s - out of memory\n", __func__);
1677 return -ENOMEM; 1680 return -ENOMEM;
1678 } 1681 }
1679 1682
@@ -1687,7 +1690,7 @@ static int ti_download_firmware(struct ti_device *tdev,
1687 header->wLength = cpu_to_le16((__u16)(buffer_size - sizeof(struct ti_firmware_header))); 1690 header->wLength = cpu_to_le16((__u16)(buffer_size - sizeof(struct ti_firmware_header)));
1688 header->bCheckSum = cs; 1691 header->bCheckSum = cs;
1689 1692
1690 dbg("%s - downloading firmware", __FUNCTION__); 1693 dbg("%s - downloading firmware", __func__);
1691 for (pos = 0; pos < buffer_size; pos += done) { 1694 for (pos = 0; pos < buffer_size; pos += done) {
1692 len = min(buffer_size - pos, TI_DOWNLOAD_MAX_PACKET_SIZE); 1695 len = min(buffer_size - pos, TI_DOWNLOAD_MAX_PACKET_SIZE);
1693 status = usb_bulk_msg(dev, pipe, buffer+pos, len, &done, 1000); 1696 status = usb_bulk_msg(dev, pipe, buffer+pos, len, &done, 1000);
@@ -1698,11 +1701,11 @@ static int ti_download_firmware(struct ti_device *tdev,
1698 kfree(buffer); 1701 kfree(buffer);
1699 1702
1700 if (status) { 1703 if (status) {
1701 dev_err(&dev->dev, "%s - error downloading firmware, %d\n", __FUNCTION__, status); 1704 dev_err(&dev->dev, "%s - error downloading firmware, %d\n", __func__, status);
1702 return status; 1705 return status;
1703 } 1706 }
1704 1707
1705 dbg("%s - download successful", __FUNCTION__); 1708 dbg("%s - download successful", __func__);
1706 1709
1707 return 0; 1710 return 0;
1708} 1711}
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index 2138ba8aeb6..a9934a3f984 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -81,7 +81,7 @@ static struct usb_serial *get_free_serial (struct usb_serial *serial, int num_po
81 unsigned int i, j; 81 unsigned int i, j;
82 int good_spot; 82 int good_spot;
83 83
84 dbg("%s %d", __FUNCTION__, num_ports); 84 dbg("%s %d", __func__, num_ports);
85 85
86 *minor = 0; 86 *minor = 0;
87 mutex_lock(&table_lock); 87 mutex_lock(&table_lock);
@@ -101,7 +101,7 @@ static struct usb_serial *get_free_serial (struct usb_serial *serial, int num_po
101 101
102 *minor = i; 102 *minor = i;
103 j = 0; 103 j = 0;
104 dbg("%s - minor base = %d", __FUNCTION__, *minor); 104 dbg("%s - minor base = %d", __func__, *minor);
105 for (i = *minor; (i < (*minor + num_ports)) && (i < SERIAL_TTY_MINORS); ++i) { 105 for (i = *minor; (i < (*minor + num_ports)) && (i < SERIAL_TTY_MINORS); ++i) {
106 serial_table[i] = serial; 106 serial_table[i] = serial;
107 serial->port[j++]->number = i; 107 serial->port[j++]->number = i;
@@ -117,7 +117,7 @@ static void return_serial(struct usb_serial *serial)
117{ 117{
118 int i; 118 int i;
119 119
120 dbg("%s", __FUNCTION__); 120 dbg("%s", __func__);
121 121
122 if (serial == NULL) 122 if (serial == NULL)
123 return; 123 return;
@@ -135,7 +135,7 @@ static void destroy_serial(struct kref *kref)
135 135
136 serial = to_usb_serial(kref); 136 serial = to_usb_serial(kref);
137 137
138 dbg("%s - %s", __FUNCTION__, serial->type->description); 138 dbg("%s - %s", __func__, serial->type->description);
139 139
140 serial->type->shutdown(serial); 140 serial->type->shutdown(serial);
141 141
@@ -187,7 +187,7 @@ static int serial_open (struct tty_struct *tty, struct file * filp)
187 unsigned int portNumber; 187 unsigned int portNumber;
188 int retval; 188 int retval;
189 189
190 dbg("%s", __FUNCTION__); 190 dbg("%s", __func__);
191 191
192 /* get the serial object associated with this tty pointer */ 192 /* get the serial object associated with this tty pointer */
193 serial = usb_serial_get_by_index(tty->index); 193 serial = usb_serial_get_by_index(tty->index);
@@ -259,7 +259,7 @@ static void serial_close(struct tty_struct *tty, struct file * filp)
259 if (!port) 259 if (!port)
260 return; 260 return;
261 261
262 dbg("%s - port %d", __FUNCTION__, port->number); 262 dbg("%s - port %d", __func__, port->number);
263 263
264 mutex_lock(&port->mutex); 264 mutex_lock(&port->mutex);
265 265
@@ -299,11 +299,11 @@ static int serial_write (struct tty_struct * tty, const unsigned char *buf, int
299 if (!port || port->serial->dev->state == USB_STATE_NOTATTACHED) 299 if (!port || port->serial->dev->state == USB_STATE_NOTATTACHED)
300 goto exit; 300 goto exit;
301 301
302 dbg("%s - port %d, %d byte(s)", __FUNCTION__, port->number, count); 302 dbg("%s - port %d, %d byte(s)", __func__, port->number, count);
303 303
304 if (!port->open_count) { 304 if (!port->open_count) {
305 retval = -EINVAL; 305 retval = -EINVAL;
306 dbg("%s - port not opened", __FUNCTION__); 306 dbg("%s - port not opened", __func__);
307 goto exit; 307 goto exit;
308 } 308 }
309 309
@@ -322,10 +322,10 @@ static int serial_write_room (struct tty_struct *tty)
322 if (!port) 322 if (!port)
323 goto exit; 323 goto exit;
324 324
325 dbg("%s - port %d", __FUNCTION__, port->number); 325 dbg("%s - port %d", __func__, port->number);
326 326
327 if (!port->open_count) { 327 if (!port->open_count) {
328 dbg("%s - port not open", __FUNCTION__); 328 dbg("%s - port not open", __func__);
329 goto exit; 329 goto exit;
330 } 330 }
331 331
@@ -344,10 +344,10 @@ static int serial_chars_in_buffer (struct tty_struct *tty)
344 if (!port) 344 if (!port)
345 goto exit; 345 goto exit;
346 346
347 dbg("%s = port %d", __FUNCTION__, port->number); 347 dbg("%s = port %d", __func__, port->number);
348 348
349 if (!port->open_count) { 349 if (!port->open_count) {
350 dbg("%s - port not open", __FUNCTION__); 350 dbg("%s - port not open", __func__);
351 goto exit; 351 goto exit;
352 } 352 }
353 353
@@ -365,10 +365,10 @@ static void serial_throttle (struct tty_struct * tty)
365 if (!port) 365 if (!port)
366 return; 366 return;
367 367
368 dbg("%s - port %d", __FUNCTION__, port->number); 368 dbg("%s - port %d", __func__, port->number);
369 369
370 if (!port->open_count) { 370 if (!port->open_count) {
371 dbg ("%s - port not open", __FUNCTION__); 371 dbg ("%s - port not open", __func__);
372 return; 372 return;
373 } 373 }
374 374
@@ -384,10 +384,10 @@ static void serial_unthrottle (struct tty_struct * tty)
384 if (!port) 384 if (!port)
385 return; 385 return;
386 386
387 dbg("%s - port %d", __FUNCTION__, port->number); 387 dbg("%s - port %d", __func__, port->number);
388 388
389 if (!port->open_count) { 389 if (!port->open_count) {
390 dbg("%s - port not open", __FUNCTION__); 390 dbg("%s - port not open", __func__);
391 return; 391 return;
392 } 392 }
393 393
@@ -401,13 +401,15 @@ static int serial_ioctl (struct tty_struct *tty, struct file * file, unsigned in
401 struct usb_serial_port *port = tty->driver_data; 401 struct usb_serial_port *port = tty->driver_data;
402 int retval = -ENODEV; 402 int retval = -ENODEV;
403 403
404 lock_kernel();
404 if (!port) 405 if (!port)
405 goto exit; 406 goto exit;
406 407
407 dbg("%s - port %d, cmd 0x%.4x", __FUNCTION__, port->number, cmd); 408 dbg("%s - port %d, cmd 0x%.4x", __func__, port->number, cmd);
408 409
410 /* Caution - port->open_count is BKL protected */
409 if (!port->open_count) { 411 if (!port->open_count) {
410 dbg ("%s - port not open", __FUNCTION__); 412 dbg ("%s - port not open", __func__);
411 goto exit; 413 goto exit;
412 } 414 }
413 415
@@ -416,8 +418,8 @@ static int serial_ioctl (struct tty_struct *tty, struct file * file, unsigned in
416 retval = port->serial->type->ioctl(port, file, cmd, arg); 418 retval = port->serial->type->ioctl(port, file, cmd, arg);
417 else 419 else
418 retval = -ENOIOCTLCMD; 420 retval = -ENOIOCTLCMD;
419
420exit: 421exit:
422 unlock_kernel();
421 return retval; 423 return retval;
422} 424}
423 425
@@ -428,10 +430,10 @@ static void serial_set_termios (struct tty_struct *tty, struct ktermios * old)
428 if (!port) 430 if (!port)
429 return; 431 return;
430 432
431 dbg("%s - port %d", __FUNCTION__, port->number); 433 dbg("%s - port %d", __func__, port->number);
432 434
433 if (!port->open_count) { 435 if (!port->open_count) {
434 dbg("%s - port not open", __FUNCTION__); 436 dbg("%s - port not open", __func__);
435 return; 437 return;
436 } 438 }
437 439
@@ -446,19 +448,24 @@ static void serial_break (struct tty_struct *tty, int break_state)
446{ 448{
447 struct usb_serial_port *port = tty->driver_data; 449 struct usb_serial_port *port = tty->driver_data;
448 450
449 if (!port) 451 lock_kernel();
452 if (!port) {
453 unlock_kernel();
450 return; 454 return;
455 }
451 456
452 dbg("%s - port %d", __FUNCTION__, port->number); 457 dbg("%s - port %d", __func__, port->number);
453 458
454 if (!port->open_count) { 459 if (!port->open_count) {
455 dbg("%s - port not open", __FUNCTION__); 460 dbg("%s - port not open", __func__);
461 unlock_kernel();
456 return; 462 return;
457 } 463 }
458 464
459 /* pass on to the driver specific version of this function if it is available */ 465 /* pass on to the driver specific version of this function if it is available */
460 if (port->serial->type->break_ctl) 466 if (port->serial->type->break_ctl)
461 port->serial->type->break_ctl(port, break_state); 467 port->serial->type->break_ctl(port, break_state);
468 unlock_kernel();
462} 469}
463 470
464static int serial_read_proc (char *page, char **start, off_t off, int count, int *eof, void *data) 471static int serial_read_proc (char *page, char **start, off_t off, int count, int *eof, void *data)
@@ -469,7 +476,7 @@ static int serial_read_proc (char *page, char **start, off_t off, int count, int
469 off_t begin = 0; 476 off_t begin = 0;
470 char tmp[40]; 477 char tmp[40];
471 478
472 dbg("%s", __FUNCTION__); 479 dbg("%s", __func__);
473 length += sprintf (page, "usbserinfo:1.0 driver:2.0\n"); 480 length += sprintf (page, "usbserinfo:1.0 driver:2.0\n");
474 for (i = 0; i < SERIAL_TTY_MINORS && length < PAGE_SIZE; ++i) { 481 for (i = 0; i < SERIAL_TTY_MINORS && length < PAGE_SIZE; ++i) {
475 serial = usb_serial_get_by_index(i); 482 serial = usb_serial_get_by_index(i);
@@ -515,10 +522,10 @@ static int serial_tiocmget (struct tty_struct *tty, struct file *file)
515 if (!port) 522 if (!port)
516 return -ENODEV; 523 return -ENODEV;
517 524
518 dbg("%s - port %d", __FUNCTION__, port->number); 525 dbg("%s - port %d", __func__, port->number);
519 526
520 if (!port->open_count) { 527 if (!port->open_count) {
521 dbg("%s - port not open", __FUNCTION__); 528 dbg("%s - port not open", __func__);
522 return -ENODEV; 529 return -ENODEV;
523 } 530 }
524 531
@@ -536,10 +543,10 @@ static int serial_tiocmset (struct tty_struct *tty, struct file *file,
536 if (!port) 543 if (!port)
537 return -ENODEV; 544 return -ENODEV;
538 545
539 dbg("%s - port %d", __FUNCTION__, port->number); 546 dbg("%s - port %d", __func__, port->number);
540 547
541 if (!port->open_count) { 548 if (!port->open_count) {
542 dbg("%s - port not open", __FUNCTION__); 549 dbg("%s - port not open", __func__);
543 return -ENODEV; 550 return -ENODEV;
544 } 551 }
545 552
@@ -565,7 +572,7 @@ static void usb_serial_port_work(struct work_struct *work)
565 container_of(work, struct usb_serial_port, work); 572 container_of(work, struct usb_serial_port, work);
566 struct tty_struct *tty; 573 struct tty_struct *tty;
567 574
568 dbg("%s - port %d", __FUNCTION__, port->number); 575 dbg("%s - port %d", __func__, port->number);
569 576
570 if (!port) 577 if (!port)
571 return; 578 return;
@@ -581,7 +588,7 @@ static void port_release(struct device *dev)
581{ 588{
582 struct usb_serial_port *port = to_usb_serial_port(dev); 589 struct usb_serial_port *port = to_usb_serial_port(dev);
583 590
584 dbg ("%s - %s", __FUNCTION__, dev->bus_id); 591 dbg ("%s - %s", __func__, dev->bus_id);
585 port_free(port); 592 port_free(port);
586} 593}
587 594
@@ -627,7 +634,7 @@ static struct usb_serial * create_serial (struct usb_device *dev,
627 634
628 serial = kzalloc(sizeof(*serial), GFP_KERNEL); 635 serial = kzalloc(sizeof(*serial), GFP_KERNEL);
629 if (!serial) { 636 if (!serial) {
630 dev_err(&dev->dev, "%s - out of memory\n", __FUNCTION__); 637 dev_err(&dev->dev, "%s - out of memory\n", __func__);
631 return NULL; 638 return NULL;
632 } 639 }
633 serial->dev = usb_get_dev(dev); 640 serial->dev = usb_get_dev(dev);
@@ -722,7 +729,7 @@ int usb_serial_probe(struct usb_interface *interface,
722 serial = create_serial (dev, interface, type); 729 serial = create_serial (dev, interface, type);
723 if (!serial) { 730 if (!serial) {
724 unlock_kernel(); 731 unlock_kernel();
725 dev_err(&interface->dev, "%s - out of memory\n", __FUNCTION__); 732 dev_err(&interface->dev, "%s - out of memory\n", __func__);
726 return -ENOMEM; 733 return -ENOMEM;
727 } 734 }
728 735
@@ -854,22 +861,6 @@ int usb_serial_probe(struct usb_interface *interface,
854 serial->num_interrupt_in = num_interrupt_in; 861 serial->num_interrupt_in = num_interrupt_in;
855 serial->num_interrupt_out = num_interrupt_out; 862 serial->num_interrupt_out = num_interrupt_out;
856 863
857#if 0
858 /* check that the device meets the driver's requirements */
859 if ((type->num_interrupt_in != NUM_DONT_CARE &&
860 type->num_interrupt_in != num_interrupt_in)
861 || (type->num_interrupt_out != NUM_DONT_CARE &&
862 type->num_interrupt_out != num_interrupt_out)
863 || (type->num_bulk_in != NUM_DONT_CARE &&
864 type->num_bulk_in != num_bulk_in)
865 || (type->num_bulk_out != NUM_DONT_CARE &&
866 type->num_bulk_out != num_bulk_out)) {
867 dbg("wrong number of endpoints");
868 kfree(serial);
869 return -EIO;
870 }
871#endif
872
873 /* found all that we need */ 864 /* found all that we need */
874 dev_info(&interface->dev, "%s converter detected\n", 865 dev_info(&interface->dev, "%s converter detected\n",
875 type->description); 866 type->description);
@@ -883,7 +874,7 @@ int usb_serial_probe(struct usb_interface *interface,
883 serial->num_port_pointers = max_endpoints; 874 serial->num_port_pointers = max_endpoints;
884 unlock_kernel(); 875 unlock_kernel();
885 876
886 dbg("%s - setting up %d port structures for this device", __FUNCTION__, max_endpoints); 877 dbg("%s - setting up %d port structures for this device", __func__, max_endpoints);
887 for (i = 0; i < max_endpoints; ++i) { 878 for (i = 0; i < max_endpoints; ++i) {
888 port = kzalloc(sizeof(struct usb_serial_port), GFP_KERNEL); 879 port = kzalloc(sizeof(struct usb_serial_port), GFP_KERNEL);
889 if (!port) 880 if (!port)
@@ -1031,7 +1022,7 @@ int usb_serial_probe(struct usb_interface *interface,
1031 port->dev.release = &port_release; 1022 port->dev.release = &port_release;
1032 1023
1033 snprintf (&port->dev.bus_id[0], sizeof(port->dev.bus_id), "ttyUSB%d", port->number); 1024 snprintf (&port->dev.bus_id[0], sizeof(port->dev.bus_id), "ttyUSB%d", port->number);
1034 dbg ("%s - registering %s", __FUNCTION__, port->dev.bus_id); 1025 dbg ("%s - registering %s", __func__, port->dev.bus_id);
1035 retval = device_register(&port->dev); 1026 retval = device_register(&port->dev);
1036 if (retval) 1027 if (retval)
1037 dev_err(&port->dev, "Error registering port device, " 1028 dev_err(&port->dev, "Error registering port device, "
@@ -1090,7 +1081,7 @@ void usb_serial_disconnect(struct usb_interface *interface)
1090 struct usb_serial_port *port; 1081 struct usb_serial_port *port;
1091 1082
1092 usb_serial_console_disconnect(serial); 1083 usb_serial_console_disconnect(serial);
1093 dbg ("%s", __FUNCTION__); 1084 dbg ("%s", __func__);
1094 1085
1095 mutex_lock(&serial->disc_mutex); 1086 mutex_lock(&serial->disc_mutex);
1096 usb_set_intfdata (interface, NULL); 1087 usb_set_intfdata (interface, NULL);
@@ -1174,7 +1165,7 @@ static int __init usb_serial_init(void)
1174 1165
1175 result = bus_register(&usb_serial_bus_type); 1166 result = bus_register(&usb_serial_bus_type);
1176 if (result) { 1167 if (result) {
1177 err("%s - registering bus driver failed", __FUNCTION__); 1168 err("%s - registering bus driver failed", __func__);
1178 goto exit_bus; 1169 goto exit_bus;
1179 } 1170 }
1180 1171
@@ -1188,24 +1179,26 @@ static int __init usb_serial_init(void)
1188 usb_serial_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; 1179 usb_serial_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
1189 usb_serial_tty_driver->init_termios = tty_std_termios; 1180 usb_serial_tty_driver->init_termios = tty_std_termios;
1190 usb_serial_tty_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; 1181 usb_serial_tty_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
1182 usb_serial_tty_driver->init_termios.c_ispeed = 9600;
1183 usb_serial_tty_driver->init_termios.c_ospeed = 9600;
1191 tty_set_operations(usb_serial_tty_driver, &serial_ops); 1184 tty_set_operations(usb_serial_tty_driver, &serial_ops);
1192 result = tty_register_driver(usb_serial_tty_driver); 1185 result = tty_register_driver(usb_serial_tty_driver);
1193 if (result) { 1186 if (result) {
1194 err("%s - tty_register_driver failed", __FUNCTION__); 1187 err("%s - tty_register_driver failed", __func__);
1195 goto exit_reg_driver; 1188 goto exit_reg_driver;
1196 } 1189 }
1197 1190
1198 /* register the USB driver */ 1191 /* register the USB driver */
1199 result = usb_register(&usb_serial_driver); 1192 result = usb_register(&usb_serial_driver);
1200 if (result < 0) { 1193 if (result < 0) {
1201 err("%s - usb_register failed", __FUNCTION__); 1194 err("%s - usb_register failed", __func__);
1202 goto exit_tty; 1195 goto exit_tty;
1203 } 1196 }
1204 1197
1205 /* register the generic driver, if we should */ 1198 /* register the generic driver, if we should */
1206 result = usb_serial_generic_register(debug); 1199 result = usb_serial_generic_register(debug);
1207 if (result < 0) { 1200 if (result < 0) {
1208 err("%s - registering generic driver failed", __FUNCTION__); 1201 err("%s - registering generic driver failed", __func__);
1209 goto exit_generic; 1202 goto exit_generic;
1210 } 1203 }
1211 1204
@@ -1223,7 +1216,7 @@ exit_reg_driver:
1223 bus_unregister(&usb_serial_bus_type); 1216 bus_unregister(&usb_serial_bus_type);
1224 1217
1225exit_bus: 1218exit_bus:
1226 err ("%s - returning with error %d", __FUNCTION__, result); 1219 err ("%s - returning with error %d", __func__, result);
1227 put_tty_driver(usb_serial_tty_driver); 1220 put_tty_driver(usb_serial_tty_driver);
1228 return result; 1221 return result;
1229} 1222}
diff --git a/drivers/usb/serial/usb_debug.c b/drivers/usb/serial/usb_debug.c
index 257a5e43687..f9fc926b56d 100644
--- a/drivers/usb/serial/usb_debug.c
+++ b/drivers/usb/serial/usb_debug.c
@@ -35,9 +35,6 @@ static struct usb_serial_driver debug_device = {
35 .name = "debug", 35 .name = "debug",
36 }, 36 },
37 .id_table = id_table, 37 .id_table = id_table,
38 .num_interrupt_in = NUM_DONT_CARE,
39 .num_bulk_in = NUM_DONT_CARE,
40 .num_bulk_out = NUM_DONT_CARE,
41 .num_ports = 1, 38 .num_ports = 1,
42}; 39};
43 40
diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c
index c2b01f7c319..5fc20122145 100644
--- a/drivers/usb/serial/visor.c
+++ b/drivers/usb/serial/visor.c
@@ -189,9 +189,6 @@ static struct usb_serial_driver handspring_device = {
189 .description = "Handspring Visor / Palm OS", 189 .description = "Handspring Visor / Palm OS",
190 .usb_driver = &visor_driver, 190 .usb_driver = &visor_driver,
191 .id_table = id_table, 191 .id_table = id_table,
192 .num_interrupt_in = NUM_DONT_CARE,
193 .num_bulk_in = 2,
194 .num_bulk_out = NUM_DONT_CARE,
195 .num_ports = 2, 192 .num_ports = 2,
196 .open = visor_open, 193 .open = visor_open,
197 .close = visor_close, 194 .close = visor_close,
@@ -219,9 +216,6 @@ static struct usb_serial_driver clie_5_device = {
219 .description = "Sony Clie 5.0", 216 .description = "Sony Clie 5.0",
220 .usb_driver = &visor_driver, 217 .usb_driver = &visor_driver,
221 .id_table = clie_id_5_table, 218 .id_table = clie_id_5_table,
222 .num_interrupt_in = NUM_DONT_CARE,
223 .num_bulk_in = 2,
224 .num_bulk_out = 2,
225 .num_ports = 2, 219 .num_ports = 2,
226 .open = visor_open, 220 .open = visor_open,
227 .close = visor_close, 221 .close = visor_close,
@@ -249,9 +243,6 @@ static struct usb_serial_driver clie_3_5_device = {
249 .description = "Sony Clie 3.5", 243 .description = "Sony Clie 3.5",
250 .usb_driver = &visor_driver, 244 .usb_driver = &visor_driver,
251 .id_table = clie_id_3_5_table, 245 .id_table = clie_id_3_5_table,
252 .num_interrupt_in = 0,
253 .num_bulk_in = 1,
254 .num_bulk_out = 1,
255 .num_ports = 1, 246 .num_ports = 1,
256 .open = visor_open, 247 .open = visor_open,
257 .close = visor_close, 248 .close = visor_close,
@@ -290,7 +281,7 @@ static int visor_open (struct usb_serial_port *port, struct file *filp)
290 unsigned long flags; 281 unsigned long flags;
291 int result = 0; 282 int result = 0;
292 283
293 dbg("%s - port %d", __FUNCTION__, port->number); 284 dbg("%s - port %d", __func__, port->number);
294 285
295 if (!port->read_urb) { 286 if (!port->read_urb) {
296 /* this is needed for some brain dead Sony devices */ 287 /* this is needed for some brain dead Sony devices */
@@ -322,16 +313,16 @@ static int visor_open (struct usb_serial_port *port, struct file *filp)
322 result = usb_submit_urb(port->read_urb, GFP_KERNEL); 313 result = usb_submit_urb(port->read_urb, GFP_KERNEL);
323 if (result) { 314 if (result) {
324 dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", 315 dev_err(&port->dev, "%s - failed submitting read urb, error %d\n",
325 __FUNCTION__, result); 316 __func__, result);
326 goto exit; 317 goto exit;
327 } 318 }
328 319
329 if (port->interrupt_in_urb) { 320 if (port->interrupt_in_urb) {
330 dbg("%s - adding interrupt input for treo", __FUNCTION__); 321 dbg("%s - adding interrupt input for treo", __func__);
331 result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); 322 result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
332 if (result) 323 if (result)
333 dev_err(&port->dev, "%s - failed submitting interrupt urb, error %d\n", 324 dev_err(&port->dev, "%s - failed submitting interrupt urb, error %d\n",
334 __FUNCTION__, result); 325 __func__, result);
335 } 326 }
336exit: 327exit:
337 return result; 328 return result;
@@ -343,7 +334,7 @@ static void visor_close (struct usb_serial_port *port, struct file * filp)
343 struct visor_private *priv = usb_get_serial_port_data(port); 334 struct visor_private *priv = usb_get_serial_port_data(port);
344 unsigned char *transfer_buffer; 335 unsigned char *transfer_buffer;
345 336
346 dbg("%s - port %d", __FUNCTION__, port->number); 337 dbg("%s - port %d", __func__, port->number);
347 338
348 /* shutdown our urbs */ 339 /* shutdown our urbs */
349 usb_kill_urb(port->read_urb); 340 usb_kill_urb(port->read_urb);
@@ -379,12 +370,12 @@ static int visor_write (struct usb_serial_port *port, const unsigned char *buf,
379 unsigned long flags; 370 unsigned long flags;
380 int status; 371 int status;
381 372
382 dbg("%s - port %d", __FUNCTION__, port->number); 373 dbg("%s - port %d", __func__, port->number);
383 374
384 spin_lock_irqsave(&priv->lock, flags); 375 spin_lock_irqsave(&priv->lock, flags);
385 if (priv->outstanding_urbs > URB_UPPER_LIMIT) { 376 if (priv->outstanding_urbs > URB_UPPER_LIMIT) {
386 spin_unlock_irqrestore(&priv->lock, flags); 377 spin_unlock_irqrestore(&priv->lock, flags);
387 dbg("%s - write limit hit\n", __FUNCTION__); 378 dbg("%s - write limit hit\n", __func__);
388 return 0; 379 return 0;
389 } 380 }
390 priv->outstanding_urbs++; 381 priv->outstanding_urbs++;
@@ -406,7 +397,7 @@ static int visor_write (struct usb_serial_port *port, const unsigned char *buf,
406 397
407 memcpy (buffer, buf, count); 398 memcpy (buffer, buf, count);
408 399
409 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count, buffer); 400 usb_serial_debug_data(debug, &port->dev, __func__, count, buffer);
410 401
411 usb_fill_bulk_urb (urb, serial->dev, 402 usb_fill_bulk_urb (urb, serial->dev,
412 usb_sndbulkpipe (serial->dev, 403 usb_sndbulkpipe (serial->dev,
@@ -418,7 +409,7 @@ static int visor_write (struct usb_serial_port *port, const unsigned char *buf,
418 status = usb_submit_urb(urb, GFP_ATOMIC); 409 status = usb_submit_urb(urb, GFP_ATOMIC);
419 if (status) { 410 if (status) {
420 dev_err(&port->dev, "%s - usb_submit_urb(write bulk) failed with status = %d\n", 411 dev_err(&port->dev, "%s - usb_submit_urb(write bulk) failed with status = %d\n",
421 __FUNCTION__, status); 412 __func__, status);
422 count = status; 413 count = status;
423 goto error; 414 goto error;
424 } else { 415 } else {
@@ -449,7 +440,7 @@ static int visor_write_room (struct usb_serial_port *port)
449 struct visor_private *priv = usb_get_serial_port_data(port); 440 struct visor_private *priv = usb_get_serial_port_data(port);
450 unsigned long flags; 441 unsigned long flags;
451 442
452 dbg("%s - port %d", __FUNCTION__, port->number); 443 dbg("%s - port %d", __func__, port->number);
453 444
454 /* 445 /*
455 * We really can take anything the user throws at us 446 * We really can take anything the user throws at us
@@ -460,7 +451,7 @@ static int visor_write_room (struct usb_serial_port *port)
460 spin_lock_irqsave(&priv->lock, flags); 451 spin_lock_irqsave(&priv->lock, flags);
461 if (priv->outstanding_urbs > URB_UPPER_LIMIT * 2 / 3) { 452 if (priv->outstanding_urbs > URB_UPPER_LIMIT * 2 / 3) {
462 spin_unlock_irqrestore(&priv->lock, flags); 453 spin_unlock_irqrestore(&priv->lock, flags);
463 dbg("%s - write limit hit\n", __FUNCTION__); 454 dbg("%s - write limit hit\n", __func__);
464 return 0; 455 return 0;
465 } 456 }
466 spin_unlock_irqrestore(&priv->lock, flags); 457 spin_unlock_irqrestore(&priv->lock, flags);
@@ -471,13 +462,15 @@ static int visor_write_room (struct usb_serial_port *port)
471 462
472static int visor_chars_in_buffer (struct usb_serial_port *port) 463static int visor_chars_in_buffer (struct usb_serial_port *port)
473{ 464{
474 dbg("%s - port %d", __FUNCTION__, port->number); 465 dbg("%s - port %d", __func__, port->number);
475 466
476 /* 467 /*
477 * We can't really account for how much data we 468 * We can't really account for how much data we
478 * have sent out, but hasn't made it through to the 469 * have sent out, but hasn't made it through to the
479 * device, so just tell the tty layer that everything 470 * device, so just tell the tty layer that everything
480 * is flushed. 471 * is flushed.
472 *
473 * FIXME: Should walk outstanding_urbs
481 */ 474 */
482 return 0; 475 return 0;
483} 476}
@@ -485,7 +478,7 @@ static int visor_chars_in_buffer (struct usb_serial_port *port)
485 478
486static void visor_write_bulk_callback (struct urb *urb) 479static void visor_write_bulk_callback (struct urb *urb)
487{ 480{
488 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 481 struct usb_serial_port *port = urb->context;
489 struct visor_private *priv = usb_get_serial_port_data(port); 482 struct visor_private *priv = usb_get_serial_port_data(port);
490 int status = urb->status; 483 int status = urb->status;
491 unsigned long flags; 484 unsigned long flags;
@@ -493,11 +486,11 @@ static void visor_write_bulk_callback (struct urb *urb)
493 /* free up the transfer buffer, as usb_free_urb() does not do this */ 486 /* free up the transfer buffer, as usb_free_urb() does not do this */
494 kfree (urb->transfer_buffer); 487 kfree (urb->transfer_buffer);
495 488
496 dbg("%s - port %d", __FUNCTION__, port->number); 489 dbg("%s - port %d", __func__, port->number);
497 490
498 if (status) 491 if (status)
499 dbg("%s - nonzero write bulk status received: %d", 492 dbg("%s - nonzero write bulk status received: %d",
500 __FUNCTION__, status); 493 __func__, status);
501 494
502 spin_lock_irqsave(&priv->lock, flags); 495 spin_lock_irqsave(&priv->lock, flags);
503 --priv->outstanding_urbs; 496 --priv->outstanding_urbs;
@@ -509,7 +502,7 @@ static void visor_write_bulk_callback (struct urb *urb)
509 502
510static void visor_read_bulk_callback (struct urb *urb) 503static void visor_read_bulk_callback (struct urb *urb)
511{ 504{
512 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 505 struct usb_serial_port *port = urb->context;
513 struct visor_private *priv = usb_get_serial_port_data(port); 506 struct visor_private *priv = usb_get_serial_port_data(port);
514 unsigned char *data = urb->transfer_buffer; 507 unsigned char *data = urb->transfer_buffer;
515 int status = urb->status; 508 int status = urb->status;
@@ -517,15 +510,15 @@ static void visor_read_bulk_callback (struct urb *urb)
517 int result; 510 int result;
518 int available_room; 511 int available_room;
519 512
520 dbg("%s - port %d", __FUNCTION__, port->number); 513 dbg("%s - port %d", __func__, port->number);
521 514
522 if (status) { 515 if (status) {
523 dbg("%s - nonzero read bulk status received: %d", 516 dbg("%s - nonzero read bulk status received: %d",
524 __FUNCTION__, status); 517 __func__, status);
525 return; 518 return;
526 } 519 }
527 520
528 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, urb->actual_length, data); 521 usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data);
529 522
530 tty = port->tty; 523 tty = port->tty;
531 if (tty && urb->actual_length) { 524 if (tty && urb->actual_length) {
@@ -551,7 +544,7 @@ static void visor_read_bulk_callback (struct urb *urb)
551 visor_read_bulk_callback, port); 544 visor_read_bulk_callback, port);
552 result = usb_submit_urb(port->read_urb, GFP_ATOMIC); 545 result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
553 if (result) 546 if (result)
554 dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", __FUNCTION__, result); 547 dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", __func__, result);
555 } else { 548 } else {
556 priv->actually_throttled = 1; 549 priv->actually_throttled = 1;
557 } 550 }
@@ -560,7 +553,7 @@ static void visor_read_bulk_callback (struct urb *urb)
560 553
561static void visor_read_int_callback (struct urb *urb) 554static void visor_read_int_callback (struct urb *urb)
562{ 555{
563 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 556 struct usb_serial_port *port = urb->context;
564 int status = urb->status; 557 int status = urb->status;
565 int result; 558 int result;
566 559
@@ -573,11 +566,11 @@ static void visor_read_int_callback (struct urb *urb)
573 case -ESHUTDOWN: 566 case -ESHUTDOWN:
574 /* this urb is terminated, clean up */ 567 /* this urb is terminated, clean up */
575 dbg("%s - urb shutting down with status: %d", 568 dbg("%s - urb shutting down with status: %d",
576 __FUNCTION__, status); 569 __func__, status);
577 return; 570 return;
578 default: 571 default:
579 dbg("%s - nonzero urb status received: %d", 572 dbg("%s - nonzero urb status received: %d",
580 __FUNCTION__, status); 573 __func__, status);
581 goto exit; 574 goto exit;
582 } 575 }
583 576
@@ -588,14 +581,14 @@ static void visor_read_int_callback (struct urb *urb)
588 * Rumor has it this endpoint is used to notify when data 581 * Rumor has it this endpoint is used to notify when data
589 * is ready to be read from the bulk ones. 582 * is ready to be read from the bulk ones.
590 */ 583 */
591 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, 584 usb_serial_debug_data(debug, &port->dev, __func__,
592 urb->actual_length, urb->transfer_buffer); 585 urb->actual_length, urb->transfer_buffer);
593 586
594exit: 587exit:
595 result = usb_submit_urb (urb, GFP_ATOMIC); 588 result = usb_submit_urb (urb, GFP_ATOMIC);
596 if (result) 589 if (result)
597 dev_err(&urb->dev->dev, "%s - Error %d submitting interrupt urb\n", 590 dev_err(&urb->dev->dev, "%s - Error %d submitting interrupt urb\n",
598 __FUNCTION__, result); 591 __func__, result);
599} 592}
600 593
601static void visor_throttle (struct usb_serial_port *port) 594static void visor_throttle (struct usb_serial_port *port)
@@ -603,7 +596,7 @@ static void visor_throttle (struct usb_serial_port *port)
603 struct visor_private *priv = usb_get_serial_port_data(port); 596 struct visor_private *priv = usb_get_serial_port_data(port);
604 unsigned long flags; 597 unsigned long flags;
605 598
606 dbg("%s - port %d", __FUNCTION__, port->number); 599 dbg("%s - port %d", __func__, port->number);
607 spin_lock_irqsave(&priv->lock, flags); 600 spin_lock_irqsave(&priv->lock, flags);
608 priv->throttled = 1; 601 priv->throttled = 1;
609 spin_unlock_irqrestore(&priv->lock, flags); 602 spin_unlock_irqrestore(&priv->lock, flags);
@@ -616,7 +609,7 @@ static void visor_unthrottle (struct usb_serial_port *port)
616 unsigned long flags; 609 unsigned long flags;
617 int result; 610 int result;
618 611
619 dbg("%s - port %d", __FUNCTION__, port->number); 612 dbg("%s - port %d", __func__, port->number);
620 spin_lock_irqsave(&priv->lock, flags); 613 spin_lock_irqsave(&priv->lock, flags);
621 priv->throttled = 0; 614 priv->throttled = 0;
622 priv->actually_throttled = 0; 615 priv->actually_throttled = 0;
@@ -625,7 +618,7 @@ static void visor_unthrottle (struct usb_serial_port *port)
625 port->read_urb->dev = port->serial->dev; 618 port->read_urb->dev = port->serial->dev;
626 result = usb_submit_urb(port->read_urb, GFP_ATOMIC); 619 result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
627 if (result) 620 if (result)
628 dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", __FUNCTION__, result); 621 dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", __func__, result);
629} 622}
630 623
631static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_id *id) 624static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_id *id)
@@ -638,11 +631,11 @@ static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_i
638 int i; 631 int i;
639 int num_ports = 0; 632 int num_ports = 0;
640 633
641 dbg("%s", __FUNCTION__); 634 dbg("%s", __func__);
642 635
643 transfer_buffer = kmalloc (sizeof (*connection_info), GFP_KERNEL); 636 transfer_buffer = kmalloc (sizeof (*connection_info), GFP_KERNEL);
644 if (!transfer_buffer) { 637 if (!transfer_buffer) {
645 dev_err(dev, "%s - kmalloc(%Zd) failed.\n", __FUNCTION__, 638 dev_err(dev, "%s - kmalloc(%Zd) failed.\n", __func__,
646 sizeof(*connection_info)); 639 sizeof(*connection_info));
647 return -ENOMEM; 640 return -ENOMEM;
648 } 641 }
@@ -655,7 +648,7 @@ static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_i
655 sizeof(*connection_info), 300); 648 sizeof(*connection_info), 300);
656 if (retval < 0) { 649 if (retval < 0) {
657 dev_err(dev, "%s - error %d getting connection information\n", 650 dev_err(dev, "%s - error %d getting connection information\n",
658 __FUNCTION__, retval); 651 __func__, retval);
659 goto exit; 652 goto exit;
660 } 653 }
661 654
@@ -715,7 +708,7 @@ static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_i
715 0x02, 300); 708 0x02, 300);
716 if (retval < 0) 709 if (retval < 0)
717 dev_err(dev, "%s - error %d getting bytes available request\n", 710 dev_err(dev, "%s - error %d getting bytes available request\n",
718 __FUNCTION__, retval); 711 __func__, retval);
719 retval = 0; 712 retval = 0;
720 713
721exit: 714exit:
@@ -731,11 +724,11 @@ static int palm_os_4_probe (struct usb_serial *serial, const struct usb_device_i
731 unsigned char *transfer_buffer; 724 unsigned char *transfer_buffer;
732 int retval; 725 int retval;
733 726
734 dbg("%s", __FUNCTION__); 727 dbg("%s", __func__);
735 728
736 transfer_buffer = kmalloc (sizeof (*connection_info), GFP_KERNEL); 729 transfer_buffer = kmalloc (sizeof (*connection_info), GFP_KERNEL);
737 if (!transfer_buffer) { 730 if (!transfer_buffer) {
738 dev_err(dev, "%s - kmalloc(%Zd) failed.\n", __FUNCTION__, 731 dev_err(dev, "%s - kmalloc(%Zd) failed.\n", __func__,
739 sizeof(*connection_info)); 732 sizeof(*connection_info));
740 return -ENOMEM; 733 return -ENOMEM;
741 } 734 }
@@ -747,9 +740,9 @@ static int palm_os_4_probe (struct usb_serial *serial, const struct usb_device_i
747 sizeof (*connection_info), 300); 740 sizeof (*connection_info), 300);
748 if (retval < 0) 741 if (retval < 0)
749 dev_err(dev, "%s - error %d getting connection info\n", 742 dev_err(dev, "%s - error %d getting connection info\n",
750 __FUNCTION__, retval); 743 __func__, retval);
751 else 744 else
752 usb_serial_debug_data(debug, &serial->dev->dev, __FUNCTION__, 745 usb_serial_debug_data(debug, &serial->dev->dev, __func__,
753 retval, transfer_buffer); 746 retval, transfer_buffer);
754 747
755 kfree (transfer_buffer); 748 kfree (transfer_buffer);
@@ -762,7 +755,7 @@ static int visor_probe (struct usb_serial *serial, const struct usb_device_id *i
762 int retval = 0; 755 int retval = 0;
763 int (*startup) (struct usb_serial *serial, const struct usb_device_id *id); 756 int (*startup) (struct usb_serial *serial, const struct usb_device_id *id);
764 757
765 dbg("%s", __FUNCTION__); 758 dbg("%s", __func__);
766 759
767 if (serial->dev->actconfig->desc.bConfigurationValue != 1) { 760 if (serial->dev->actconfig->desc.bConfigurationValue != 1) {
768 err("active config #%d != 1 ??", 761 err("active config #%d != 1 ??",
@@ -816,7 +809,7 @@ static int clie_3_5_startup (struct usb_serial *serial)
816 int result; 809 int result;
817 u8 data; 810 u8 data;
818 811
819 dbg("%s", __FUNCTION__); 812 dbg("%s", __func__);
820 813
821 /* 814 /*
822 * Note that PEG-300 series devices expect the following two calls. 815 * Note that PEG-300 series devices expect the following two calls.
@@ -827,11 +820,11 @@ static int clie_3_5_startup (struct usb_serial *serial)
827 USB_REQ_GET_CONFIGURATION, USB_DIR_IN, 820 USB_REQ_GET_CONFIGURATION, USB_DIR_IN,
828 0, 0, &data, 1, 3000); 821 0, 0, &data, 1, 3000);
829 if (result < 0) { 822 if (result < 0) {
830 dev_err(dev, "%s: get config number failed: %d\n", __FUNCTION__, result); 823 dev_err(dev, "%s: get config number failed: %d\n", __func__, result);
831 return result; 824 return result;
832 } 825 }
833 if (result != 1) { 826 if (result != 1) {
834 dev_err(dev, "%s: get config number bad return length: %d\n", __FUNCTION__, result); 827 dev_err(dev, "%s: get config number bad return length: %d\n", __func__, result);
835 return -EIO; 828 return -EIO;
836 } 829 }
837 830
@@ -841,11 +834,11 @@ static int clie_3_5_startup (struct usb_serial *serial)
841 USB_DIR_IN | USB_RECIP_INTERFACE, 834 USB_DIR_IN | USB_RECIP_INTERFACE,
842 0, 0, &data, 1, 3000); 835 0, 0, &data, 1, 3000);
843 if (result < 0) { 836 if (result < 0) {
844 dev_err(dev, "%s: get interface number failed: %d\n", __FUNCTION__, result); 837 dev_err(dev, "%s: get interface number failed: %d\n", __func__, result);
845 return result; 838 return result;
846 } 839 }
847 if (result != 1) { 840 if (result != 1) {
848 dev_err(dev, "%s: get interface number bad return length: %d\n", __FUNCTION__, result); 841 dev_err(dev, "%s: get interface number bad return length: %d\n", __func__, result);
849 return -EIO; 842 return -EIO;
850 } 843 }
851 844
@@ -863,7 +856,7 @@ static int treo_attach (struct usb_serial *serial)
863 (serial->num_interrupt_in == 0)) 856 (serial->num_interrupt_in == 0))
864 goto generic_startup; 857 goto generic_startup;
865 858
866 dbg("%s", __FUNCTION__); 859 dbg("%s", __func__);
867 860
868 /* 861 /*
869 * It appears that Treos and Kyoceras want to use the 862 * It appears that Treos and Kyoceras want to use the
@@ -894,7 +887,7 @@ generic_startup:
894 887
895static int clie_5_attach (struct usb_serial *serial) 888static int clie_5_attach (struct usb_serial *serial)
896{ 889{
897 dbg("%s", __FUNCTION__); 890 dbg("%s", __func__);
898 891
899 /* TH55 registers 2 ports. 892 /* TH55 registers 2 ports.
900 Communication in from the UX50/TH55 uses bulk_in_endpointAddress from port 0 893 Communication in from the UX50/TH55 uses bulk_in_endpointAddress from port 0
@@ -918,7 +911,7 @@ static void visor_shutdown (struct usb_serial *serial)
918 struct visor_private *priv; 911 struct visor_private *priv;
919 int i; 912 int i;
920 913
921 dbg("%s", __FUNCTION__); 914 dbg("%s", __func__);
922 915
923 for (i = 0; i < serial->num_ports; i++) { 916 for (i = 0; i < serial->num_ports; i++) {
924 priv = usb_get_serial_port_data(serial->port[i]); 917 priv = usb_get_serial_port_data(serial->port[i]);
@@ -931,7 +924,7 @@ static void visor_shutdown (struct usb_serial *serial)
931 924
932static int visor_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg) 925static int visor_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg)
933{ 926{
934 dbg("%s - port %d, cmd 0x%.4x", __FUNCTION__, port->number, cmd); 927 dbg("%s - port %d, cmd 0x%.4x", __func__, port->number, cmd);
935 928
936 return -ENOIOCTLCMD; 929 return -ENOIOCTLCMD;
937} 930}
diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c
index 38726ef3132..e96bf8663ff 100644
--- a/drivers/usb/serial/whiteheat.c
+++ b/drivers/usb/serial/whiteheat.c
@@ -164,9 +164,6 @@ static struct usb_serial_driver whiteheat_fake_device = {
164 .description = "Connect Tech - WhiteHEAT - (prerenumeration)", 164 .description = "Connect Tech - WhiteHEAT - (prerenumeration)",
165 .usb_driver = &whiteheat_driver, 165 .usb_driver = &whiteheat_driver,
166 .id_table = id_table_prerenumeration, 166 .id_table = id_table_prerenumeration,
167 .num_interrupt_in = NUM_DONT_CARE,
168 .num_bulk_in = NUM_DONT_CARE,
169 .num_bulk_out = NUM_DONT_CARE,
170 .num_ports = 1, 167 .num_ports = 1,
171 .probe = whiteheat_firmware_download, 168 .probe = whiteheat_firmware_download,
172 .attach = whiteheat_firmware_attach, 169 .attach = whiteheat_firmware_attach,
@@ -180,9 +177,6 @@ static struct usb_serial_driver whiteheat_device = {
180 .description = "Connect Tech - WhiteHEAT", 177 .description = "Connect Tech - WhiteHEAT",
181 .usb_driver = &whiteheat_driver, 178 .usb_driver = &whiteheat_driver,
182 .id_table = id_table_std, 179 .id_table = id_table_std,
183 .num_interrupt_in = NUM_DONT_CARE,
184 .num_bulk_in = NUM_DONT_CARE,
185 .num_bulk_out = NUM_DONT_CARE,
186 .num_ports = 4, 180 .num_ports = 4,
187 .attach = whiteheat_attach, 181 .attach = whiteheat_attach,
188 .shutdown = whiteheat_shutdown, 182 .shutdown = whiteheat_shutdown,
@@ -225,7 +219,7 @@ struct whiteheat_urb_wrap {
225struct whiteheat_private { 219struct whiteheat_private {
226 spinlock_t lock; 220 spinlock_t lock;
227 __u8 flags; 221 __u8 flags;
228 __u8 mcr; 222 __u8 mcr; /* FIXME: no locking on mcr */
229 struct list_head rx_urbs_free; 223 struct list_head rx_urbs_free;
230 struct list_head rx_urbs_submitted; 224 struct list_head rx_urbs_submitted;
231 struct list_head rx_urb_q; 225 struct list_head rx_urb_q;
@@ -288,7 +282,7 @@ static int whiteheat_firmware_download (struct usb_serial *serial, const struct
288 int response; 282 int response;
289 const struct whiteheat_hex_record *record; 283 const struct whiteheat_hex_record *record;
290 284
291 dbg("%s", __FUNCTION__); 285 dbg("%s", __func__);
292 286
293 response = ezusb_set_reset (serial, 1); 287 response = ezusb_set_reset (serial, 1);
294 288
@@ -298,7 +292,7 @@ static int whiteheat_firmware_download (struct usb_serial *serial, const struct
298 (unsigned char *)record->data, record->data_size, 0xa0); 292 (unsigned char *)record->data, record->data_size, 0xa0);
299 if (response < 0) { 293 if (response < 0) {
300 err("%s - ezusb_writememory failed for loader (%d %04X %p %d)", 294 err("%s - ezusb_writememory failed for loader (%d %04X %p %d)",
301 __FUNCTION__, response, record->address, record->data, record->data_size); 295 __func__, response, record->address, record->data, record->data_size);
302 break; 296 break;
303 } 297 }
304 ++record; 298 ++record;
@@ -315,7 +309,7 @@ static int whiteheat_firmware_download (struct usb_serial *serial, const struct
315 (unsigned char *)record->data, record->data_size, 0xa3); 309 (unsigned char *)record->data, record->data_size, 0xa3);
316 if (response < 0) { 310 if (response < 0) {
317 err("%s - ezusb_writememory failed for first firmware step (%d %04X %p %d)", 311 err("%s - ezusb_writememory failed for first firmware step (%d %04X %p %d)",
318 __FUNCTION__, response, record->address, record->data, record->data_size); 312 __func__, response, record->address, record->data, record->data_size);
319 break; 313 break;
320 } 314 }
321 ++record; 315 ++record;
@@ -329,7 +323,7 @@ static int whiteheat_firmware_download (struct usb_serial *serial, const struct
329 (unsigned char *)record->data, record->data_size, 0xa0); 323 (unsigned char *)record->data, record->data_size, 0xa0);
330 if (response < 0) { 324 if (response < 0) {
331 err("%s - ezusb_writememory failed for second firmware step (%d %04X %p %d)", 325 err("%s - ezusb_writememory failed for second firmware step (%d %04X %p %d)",
332 __FUNCTION__, response, record->address, record->data, record->data_size); 326 __func__, response, record->address, record->data, record->data_size);
333 break; 327 break;
334 } 328 }
335 ++record; 329 ++record;
@@ -567,7 +561,7 @@ static void whiteheat_shutdown (struct usb_serial *serial)
567 struct list_head *tmp2; 561 struct list_head *tmp2;
568 int i; 562 int i;
569 563
570 dbg("%s", __FUNCTION__); 564 dbg("%s", __func__);
571 565
572 /* free up our private data for our command port */ 566 /* free up our private data for our command port */
573 command_port = serial->port[COMMAND_PORT]; 567 command_port = serial->port[COMMAND_PORT];
@@ -604,7 +598,7 @@ static int whiteheat_open (struct usb_serial_port *port, struct file *filp)
604 int retval = 0; 598 int retval = 0;
605 struct ktermios old_term; 599 struct ktermios old_term;
606 600
607 dbg("%s - port %d", __FUNCTION__, port->number); 601 dbg("%s - port %d", __func__, port->number);
608 602
609 retval = start_command_port(port->serial); 603 retval = start_command_port(port->serial);
610 if (retval) 604 if (retval)
@@ -637,14 +631,14 @@ static int whiteheat_open (struct usb_serial_port *port, struct file *filp)
637 /* Start reading from the device */ 631 /* Start reading from the device */
638 retval = start_port_read(port); 632 retval = start_port_read(port);
639 if (retval) { 633 if (retval) {
640 err("%s - failed submitting read urb, error %d", __FUNCTION__, retval); 634 err("%s - failed submitting read urb, error %d", __func__, retval);
641 firm_close(port); 635 firm_close(port);
642 stop_command_port(port->serial); 636 stop_command_port(port->serial);
643 goto exit; 637 goto exit;
644 } 638 }
645 639
646exit: 640exit:
647 dbg("%s - exit, retval = %d", __FUNCTION__, retval); 641 dbg("%s - exit, retval = %d", __func__, retval);
648 return retval; 642 return retval;
649} 643}
650 644
@@ -657,7 +651,7 @@ static void whiteheat_close(struct usb_serial_port *port, struct file * filp)
657 struct list_head *tmp; 651 struct list_head *tmp;
658 struct list_head *tmp2; 652 struct list_head *tmp2;
659 653
660 dbg("%s - port %d", __FUNCTION__, port->number); 654 dbg("%s - port %d", __func__, port->number);
661 655
662 mutex_lock(&port->serial->disc_mutex); 656 mutex_lock(&port->serial->disc_mutex);
663 /* filp is NULL when called from usb_serial_disconnect */ 657 /* filp is NULL when called from usb_serial_disconnect */
@@ -732,10 +726,10 @@ static int whiteheat_write(struct usb_serial_port *port, const unsigned char *bu
732 unsigned long flags; 726 unsigned long flags;
733 struct list_head *tmp; 727 struct list_head *tmp;
734 728
735 dbg("%s - port %d", __FUNCTION__, port->number); 729 dbg("%s - port %d", __func__, port->number);
736 730
737 if (count == 0) { 731 if (count == 0) {
738 dbg("%s - write request of 0 bytes", __FUNCTION__); 732 dbg("%s - write request of 0 bytes", __func__);
739 return (0); 733 return (0);
740 } 734 }
741 735
@@ -754,13 +748,13 @@ static int whiteheat_write(struct usb_serial_port *port, const unsigned char *bu
754 bytes = (count > port->bulk_out_size) ? port->bulk_out_size : count; 748 bytes = (count > port->bulk_out_size) ? port->bulk_out_size : count;
755 memcpy (urb->transfer_buffer, buf + sent, bytes); 749 memcpy (urb->transfer_buffer, buf + sent, bytes);
756 750
757 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, bytes, urb->transfer_buffer); 751 usb_serial_debug_data(debug, &port->dev, __func__, bytes, urb->transfer_buffer);
758 752
759 urb->dev = serial->dev; 753 urb->dev = serial->dev;
760 urb->transfer_buffer_length = bytes; 754 urb->transfer_buffer_length = bytes;
761 result = usb_submit_urb(urb, GFP_ATOMIC); 755 result = usb_submit_urb(urb, GFP_ATOMIC);
762 if (result) { 756 if (result) {
763 err("%s - failed submitting write urb, error %d", __FUNCTION__, result); 757 err("%s - failed submitting write urb, error %d", __func__, result);
764 sent = result; 758 sent = result;
765 spin_lock_irqsave(&info->lock, flags); 759 spin_lock_irqsave(&info->lock, flags);
766 list_add(tmp, &info->tx_urbs_free); 760 list_add(tmp, &info->tx_urbs_free);
@@ -786,7 +780,7 @@ static int whiteheat_write_room(struct usb_serial_port *port)
786 int room = 0; 780 int room = 0;
787 unsigned long flags; 781 unsigned long flags;
788 782
789 dbg("%s - port %d", __FUNCTION__, port->number); 783 dbg("%s - port %d", __func__, port->number);
790 784
791 spin_lock_irqsave(&info->lock, flags); 785 spin_lock_irqsave(&info->lock, flags);
792 list_for_each(tmp, &info->tx_urbs_free) 786 list_for_each(tmp, &info->tx_urbs_free)
@@ -794,7 +788,7 @@ static int whiteheat_write_room(struct usb_serial_port *port)
794 spin_unlock_irqrestore(&info->lock, flags); 788 spin_unlock_irqrestore(&info->lock, flags);
795 room *= port->bulk_out_size; 789 room *= port->bulk_out_size;
796 790
797 dbg("%s - returns %d", __FUNCTION__, room); 791 dbg("%s - returns %d", __func__, room);
798 return (room); 792 return (room);
799} 793}
800 794
@@ -804,7 +798,7 @@ static int whiteheat_tiocmget (struct usb_serial_port *port, struct file *file)
804 struct whiteheat_private *info = usb_get_serial_port_data(port); 798 struct whiteheat_private *info = usb_get_serial_port_data(port);
805 unsigned int modem_signals = 0; 799 unsigned int modem_signals = 0;
806 800
807 dbg("%s - port %d", __FUNCTION__, port->number); 801 dbg("%s - port %d", __func__, port->number);
808 802
809 firm_get_dtr_rts(port); 803 firm_get_dtr_rts(port);
810 if (info->mcr & UART_MCR_DTR) 804 if (info->mcr & UART_MCR_DTR)
@@ -821,7 +815,7 @@ static int whiteheat_tiocmset (struct usb_serial_port *port, struct file *file,
821{ 815{
822 struct whiteheat_private *info = usb_get_serial_port_data(port); 816 struct whiteheat_private *info = usb_get_serial_port_data(port);
823 817
824 dbg("%s - port %d", __FUNCTION__, port->number); 818 dbg("%s - port %d", __func__, port->number);
825 819
826 if (set & TIOCM_RTS) 820 if (set & TIOCM_RTS)
827 info->mcr |= UART_MCR_RTS; 821 info->mcr |= UART_MCR_RTS;
@@ -844,7 +838,7 @@ static int whiteheat_ioctl (struct usb_serial_port *port, struct file * file, un
844 struct serial_struct serstruct; 838 struct serial_struct serstruct;
845 void __user *user_arg = (void __user *)arg; 839 void __user *user_arg = (void __user *)arg;
846 840
847 dbg("%s - port %d, cmd 0x%.4x", __FUNCTION__, port->number, cmd); 841 dbg("%s - port %d, cmd 0x%.4x", __func__, port->number, cmd);
848 842
849 switch (cmd) { 843 switch (cmd) {
850 case TIOCGSERIAL: 844 case TIOCGSERIAL:
@@ -886,7 +880,7 @@ static int whiteheat_ioctl (struct usb_serial_port *port, struct file * file, un
886 880
887static void whiteheat_set_termios(struct usb_serial_port *port, struct ktermios *old_termios) 881static void whiteheat_set_termios(struct usb_serial_port *port, struct ktermios *old_termios)
888{ 882{
889 dbg("%s -port %d", __FUNCTION__, port->number); 883 dbg("%s -port %d", __func__, port->number);
890 firm_setup_port(port); 884 firm_setup_port(port);
891} 885}
892 886
@@ -904,7 +898,7 @@ static int whiteheat_chars_in_buffer(struct usb_serial_port *port)
904 int chars = 0; 898 int chars = 0;
905 unsigned long flags; 899 unsigned long flags;
906 900
907 dbg("%s - port %d", __FUNCTION__, port->number); 901 dbg("%s - port %d", __func__, port->number);
908 902
909 spin_lock_irqsave(&info->lock, flags); 903 spin_lock_irqsave(&info->lock, flags);
910 list_for_each(tmp, &info->tx_urbs_submitted) { 904 list_for_each(tmp, &info->tx_urbs_submitted) {
@@ -913,7 +907,7 @@ static int whiteheat_chars_in_buffer(struct usb_serial_port *port)
913 } 907 }
914 spin_unlock_irqrestore(&info->lock, flags); 908 spin_unlock_irqrestore(&info->lock, flags);
915 909
916 dbg ("%s - returns %d", __FUNCTION__, chars); 910 dbg ("%s - returns %d", __func__, chars);
917 return chars; 911 return chars;
918} 912}
919 913
@@ -923,7 +917,7 @@ static void whiteheat_throttle (struct usb_serial_port *port)
923 struct whiteheat_private *info = usb_get_serial_port_data(port); 917 struct whiteheat_private *info = usb_get_serial_port_data(port);
924 unsigned long flags; 918 unsigned long flags;
925 919
926 dbg("%s - port %d", __FUNCTION__, port->number); 920 dbg("%s - port %d", __func__, port->number);
927 921
928 spin_lock_irqsave(&info->lock, flags); 922 spin_lock_irqsave(&info->lock, flags);
929 info->flags |= THROTTLED; 923 info->flags |= THROTTLED;
@@ -939,7 +933,7 @@ static void whiteheat_unthrottle (struct usb_serial_port *port)
939 int actually_throttled; 933 int actually_throttled;
940 unsigned long flags; 934 unsigned long flags;
941 935
942 dbg("%s - port %d", __FUNCTION__, port->number); 936 dbg("%s - port %d", __func__, port->number);
943 937
944 spin_lock_irqsave(&info->lock, flags); 938 spin_lock_irqsave(&info->lock, flags);
945 actually_throttled = info->flags & ACTUALLY_THROTTLED; 939 actually_throttled = info->flags & ACTUALLY_THROTTLED;
@@ -960,7 +954,7 @@ static void command_port_write_callback(struct urb *urb)
960{ 954{
961 int status = urb->status; 955 int status = urb->status;
962 956
963 dbg("%s", __FUNCTION__); 957 dbg("%s", __func__);
964 958
965 if (status) { 959 if (status) {
966 dbg("nonzero urb status: %d", status); 960 dbg("nonzero urb status: %d", status);
@@ -971,28 +965,28 @@ static void command_port_write_callback(struct urb *urb)
971 965
972static void command_port_read_callback(struct urb *urb) 966static void command_port_read_callback(struct urb *urb)
973{ 967{
974 struct usb_serial_port *command_port = (struct usb_serial_port *)urb->context; 968 struct usb_serial_port *command_port = urb->context;
975 struct whiteheat_command_private *command_info; 969 struct whiteheat_command_private *command_info;
976 int status = urb->status; 970 int status = urb->status;
977 unsigned char *data = urb->transfer_buffer; 971 unsigned char *data = urb->transfer_buffer;
978 int result; 972 int result;
979 973
980 dbg("%s", __FUNCTION__); 974 dbg("%s", __func__);
981 975
982 command_info = usb_get_serial_port_data(command_port); 976 command_info = usb_get_serial_port_data(command_port);
983 if (!command_info) { 977 if (!command_info) {
984 dbg ("%s - command_info is NULL, exiting.", __FUNCTION__); 978 dbg ("%s - command_info is NULL, exiting.", __func__);
985 return; 979 return;
986 } 980 }
987 if (status) { 981 if (status) {
988 dbg("%s - nonzero urb status: %d", __FUNCTION__, status); 982 dbg("%s - nonzero urb status: %d", __func__, status);
989 if (status != -ENOENT) 983 if (status != -ENOENT)
990 command_info->command_finished = WHITEHEAT_CMD_FAILURE; 984 command_info->command_finished = WHITEHEAT_CMD_FAILURE;
991 wake_up(&command_info->wait_command); 985 wake_up(&command_info->wait_command);
992 return; 986 return;
993 } 987 }
994 988
995 usb_serial_debug_data(debug, &command_port->dev, __FUNCTION__, urb->actual_length, data); 989 usb_serial_debug_data(debug, &command_port->dev, __func__, urb->actual_length, data);
996 990
997 if (data[0] == WHITEHEAT_CMD_COMPLETE) { 991 if (data[0] == WHITEHEAT_CMD_COMPLETE) {
998 command_info->command_finished = WHITEHEAT_CMD_COMPLETE; 992 command_info->command_finished = WHITEHEAT_CMD_COMPLETE;
@@ -1002,38 +996,38 @@ static void command_port_read_callback(struct urb *urb)
1002 wake_up(&command_info->wait_command); 996 wake_up(&command_info->wait_command);
1003 } else if (data[0] == WHITEHEAT_EVENT) { 997 } else if (data[0] == WHITEHEAT_EVENT) {
1004 /* These are unsolicited reports from the firmware, hence no waiting command to wakeup */ 998 /* These are unsolicited reports from the firmware, hence no waiting command to wakeup */
1005 dbg("%s - event received", __FUNCTION__); 999 dbg("%s - event received", __func__);
1006 } else if (data[0] == WHITEHEAT_GET_DTR_RTS) { 1000 } else if (data[0] == WHITEHEAT_GET_DTR_RTS) {
1007 memcpy(command_info->result_buffer, &data[1], urb->actual_length - 1); 1001 memcpy(command_info->result_buffer, &data[1], urb->actual_length - 1);
1008 command_info->command_finished = WHITEHEAT_CMD_COMPLETE; 1002 command_info->command_finished = WHITEHEAT_CMD_COMPLETE;
1009 wake_up(&command_info->wait_command); 1003 wake_up(&command_info->wait_command);
1010 } else { 1004 } else {
1011 dbg("%s - bad reply from firmware", __FUNCTION__); 1005 dbg("%s - bad reply from firmware", __func__);
1012 } 1006 }
1013 1007
1014 /* Continue trying to always read */ 1008 /* Continue trying to always read */
1015 command_port->read_urb->dev = command_port->serial->dev; 1009 command_port->read_urb->dev = command_port->serial->dev;
1016 result = usb_submit_urb(command_port->read_urb, GFP_ATOMIC); 1010 result = usb_submit_urb(command_port->read_urb, GFP_ATOMIC);
1017 if (result) 1011 if (result)
1018 dbg("%s - failed resubmitting read urb, error %d", __FUNCTION__, result); 1012 dbg("%s - failed resubmitting read urb, error %d", __func__, result);
1019} 1013}
1020 1014
1021 1015
1022static void whiteheat_read_callback(struct urb *urb) 1016static void whiteheat_read_callback(struct urb *urb)
1023{ 1017{
1024 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 1018 struct usb_serial_port *port = urb->context;
1025 struct whiteheat_urb_wrap *wrap; 1019 struct whiteheat_urb_wrap *wrap;
1026 unsigned char *data = urb->transfer_buffer; 1020 unsigned char *data = urb->transfer_buffer;
1027 struct whiteheat_private *info = usb_get_serial_port_data(port); 1021 struct whiteheat_private *info = usb_get_serial_port_data(port);
1028 int status = urb->status; 1022 int status = urb->status;
1029 1023
1030 dbg("%s - port %d", __FUNCTION__, port->number); 1024 dbg("%s - port %d", __func__, port->number);
1031 1025
1032 spin_lock(&info->lock); 1026 spin_lock(&info->lock);
1033 wrap = urb_to_wrap(urb, &info->rx_urbs_submitted); 1027 wrap = urb_to_wrap(urb, &info->rx_urbs_submitted);
1034 if (!wrap) { 1028 if (!wrap) {
1035 spin_unlock(&info->lock); 1029 spin_unlock(&info->lock);
1036 err("%s - Not my urb!", __FUNCTION__); 1030 err("%s - Not my urb!", __func__);
1037 return; 1031 return;
1038 } 1032 }
1039 list_del(&wrap->list); 1033 list_del(&wrap->list);
@@ -1041,14 +1035,14 @@ static void whiteheat_read_callback(struct urb *urb)
1041 1035
1042 if (status) { 1036 if (status) {
1043 dbg("%s - nonzero read bulk status received: %d", 1037 dbg("%s - nonzero read bulk status received: %d",
1044 __FUNCTION__, status); 1038 __func__, status);
1045 spin_lock(&info->lock); 1039 spin_lock(&info->lock);
1046 list_add(&wrap->list, &info->rx_urbs_free); 1040 list_add(&wrap->list, &info->rx_urbs_free);
1047 spin_unlock(&info->lock); 1041 spin_unlock(&info->lock);
1048 return; 1042 return;
1049 } 1043 }
1050 1044
1051 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, urb->actual_length, data); 1045 usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data);
1052 1046
1053 spin_lock(&info->lock); 1047 spin_lock(&info->lock);
1054 list_add_tail(&wrap->list, &info->rx_urb_q); 1048 list_add_tail(&wrap->list, &info->rx_urb_q);
@@ -1065,18 +1059,18 @@ static void whiteheat_read_callback(struct urb *urb)
1065 1059
1066static void whiteheat_write_callback(struct urb *urb) 1060static void whiteheat_write_callback(struct urb *urb)
1067{ 1061{
1068 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 1062 struct usb_serial_port *port = urb->context;
1069 struct whiteheat_private *info = usb_get_serial_port_data(port); 1063 struct whiteheat_private *info = usb_get_serial_port_data(port);
1070 struct whiteheat_urb_wrap *wrap; 1064 struct whiteheat_urb_wrap *wrap;
1071 int status = urb->status; 1065 int status = urb->status;
1072 1066
1073 dbg("%s - port %d", __FUNCTION__, port->number); 1067 dbg("%s - port %d", __func__, port->number);
1074 1068
1075 spin_lock(&info->lock); 1069 spin_lock(&info->lock);
1076 wrap = urb_to_wrap(urb, &info->tx_urbs_submitted); 1070 wrap = urb_to_wrap(urb, &info->tx_urbs_submitted);
1077 if (!wrap) { 1071 if (!wrap) {
1078 spin_unlock(&info->lock); 1072 spin_unlock(&info->lock);
1079 err("%s - Not my urb!", __FUNCTION__); 1073 err("%s - Not my urb!", __func__);
1080 return; 1074 return;
1081 } 1075 }
1082 list_move(&wrap->list, &info->tx_urbs_free); 1076 list_move(&wrap->list, &info->tx_urbs_free);
@@ -1084,7 +1078,7 @@ static void whiteheat_write_callback(struct urb *urb)
1084 1078
1085 if (status) { 1079 if (status) {
1086 dbg("%s - nonzero write bulk status received: %d", 1080 dbg("%s - nonzero write bulk status received: %d",
1087 __FUNCTION__, status); 1081 __func__, status);
1088 return; 1082 return;
1089 } 1083 }
1090 1084
@@ -1104,7 +1098,7 @@ static int firm_send_command(struct usb_serial_port *port, __u8 command, __u8 *d
1104 int retval = 0; 1098 int retval = 0;
1105 int t; 1099 int t;
1106 1100
1107 dbg("%s - command %d", __FUNCTION__, command); 1101 dbg("%s - command %d", __func__, command);
1108 1102
1109 command_port = port->serial->port[COMMAND_PORT]; 1103 command_port = port->serial->port[COMMAND_PORT];
1110 command_info = usb_get_serial_port_data(command_port); 1104 command_info = usb_get_serial_port_data(command_port);
@@ -1118,7 +1112,7 @@ static int firm_send_command(struct usb_serial_port *port, __u8 command, __u8 *d
1118 command_port->write_urb->dev = port->serial->dev; 1112 command_port->write_urb->dev = port->serial->dev;
1119 retval = usb_submit_urb (command_port->write_urb, GFP_NOIO); 1113 retval = usb_submit_urb (command_port->write_urb, GFP_NOIO);
1120 if (retval) { 1114 if (retval) {
1121 dbg("%s - submit urb failed", __FUNCTION__); 1115 dbg("%s - submit urb failed", __func__);
1122 goto exit; 1116 goto exit;
1123 } 1117 }
1124 1118
@@ -1129,19 +1123,19 @@ static int firm_send_command(struct usb_serial_port *port, __u8 command, __u8 *d
1129 usb_kill_urb(command_port->write_urb); 1123 usb_kill_urb(command_port->write_urb);
1130 1124
1131 if (command_info->command_finished == false) { 1125 if (command_info->command_finished == false) {
1132 dbg("%s - command timed out.", __FUNCTION__); 1126 dbg("%s - command timed out.", __func__);
1133 retval = -ETIMEDOUT; 1127 retval = -ETIMEDOUT;
1134 goto exit; 1128 goto exit;
1135 } 1129 }
1136 1130
1137 if (command_info->command_finished == WHITEHEAT_CMD_FAILURE) { 1131 if (command_info->command_finished == WHITEHEAT_CMD_FAILURE) {
1138 dbg("%s - command failed.", __FUNCTION__); 1132 dbg("%s - command failed.", __func__);
1139 retval = -EIO; 1133 retval = -EIO;
1140 goto exit; 1134 goto exit;
1141 } 1135 }
1142 1136
1143 if (command_info->command_finished == WHITEHEAT_CMD_COMPLETE) { 1137 if (command_info->command_finished == WHITEHEAT_CMD_COMPLETE) {
1144 dbg("%s - command completed.", __FUNCTION__); 1138 dbg("%s - command completed.", __func__);
1145 switch (command) { 1139 switch (command) {
1146 case WHITEHEAT_GET_DTR_RTS: 1140 case WHITEHEAT_GET_DTR_RTS:
1147 info = usb_get_serial_port_data(port); 1141 info = usb_get_serial_port_data(port);
@@ -1186,7 +1180,7 @@ static int firm_setup_port(struct usb_serial_port *port) {
1186 default: 1180 default:
1187 case CS8: port_settings.bits = 8; break; 1181 case CS8: port_settings.bits = 8; break;
1188 } 1182 }
1189 dbg("%s - data bits = %d", __FUNCTION__, port_settings.bits); 1183 dbg("%s - data bits = %d", __func__, port_settings.bits);
1190 1184
1191 /* determine the parity */ 1185 /* determine the parity */
1192 if (cflag & PARENB) 1186 if (cflag & PARENB)
@@ -1202,21 +1196,21 @@ static int firm_setup_port(struct usb_serial_port *port) {
1202 port_settings.parity = WHITEHEAT_PAR_EVEN; 1196 port_settings.parity = WHITEHEAT_PAR_EVEN;
1203 else 1197 else
1204 port_settings.parity = WHITEHEAT_PAR_NONE; 1198 port_settings.parity = WHITEHEAT_PAR_NONE;
1205 dbg("%s - parity = %c", __FUNCTION__, port_settings.parity); 1199 dbg("%s - parity = %c", __func__, port_settings.parity);
1206 1200
1207 /* figure out the stop bits requested */ 1201 /* figure out the stop bits requested */
1208 if (cflag & CSTOPB) 1202 if (cflag & CSTOPB)
1209 port_settings.stop = 2; 1203 port_settings.stop = 2;
1210 else 1204 else
1211 port_settings.stop = 1; 1205 port_settings.stop = 1;
1212 dbg("%s - stop bits = %d", __FUNCTION__, port_settings.stop); 1206 dbg("%s - stop bits = %d", __func__, port_settings.stop);
1213 1207
1214 /* figure out the flow control settings */ 1208 /* figure out the flow control settings */
1215 if (cflag & CRTSCTS) 1209 if (cflag & CRTSCTS)
1216 port_settings.hflow = (WHITEHEAT_HFLOW_CTS | WHITEHEAT_HFLOW_RTS); 1210 port_settings.hflow = (WHITEHEAT_HFLOW_CTS | WHITEHEAT_HFLOW_RTS);
1217 else 1211 else
1218 port_settings.hflow = WHITEHEAT_HFLOW_NONE; 1212 port_settings.hflow = WHITEHEAT_HFLOW_NONE;
1219 dbg("%s - hardware flow control = %s %s %s %s", __FUNCTION__, 1213 dbg("%s - hardware flow control = %s %s %s %s", __func__,
1220 (port_settings.hflow & WHITEHEAT_HFLOW_CTS) ? "CTS" : "", 1214 (port_settings.hflow & WHITEHEAT_HFLOW_CTS) ? "CTS" : "",
1221 (port_settings.hflow & WHITEHEAT_HFLOW_RTS) ? "RTS" : "", 1215 (port_settings.hflow & WHITEHEAT_HFLOW_RTS) ? "RTS" : "",
1222 (port_settings.hflow & WHITEHEAT_HFLOW_DSR) ? "DSR" : "", 1216 (port_settings.hflow & WHITEHEAT_HFLOW_DSR) ? "DSR" : "",
@@ -1227,15 +1221,15 @@ static int firm_setup_port(struct usb_serial_port *port) {
1227 port_settings.sflow = WHITEHEAT_SFLOW_RXTX; 1221 port_settings.sflow = WHITEHEAT_SFLOW_RXTX;
1228 else 1222 else
1229 port_settings.sflow = WHITEHEAT_SFLOW_NONE; 1223 port_settings.sflow = WHITEHEAT_SFLOW_NONE;
1230 dbg("%s - software flow control = %c", __FUNCTION__, port_settings.sflow); 1224 dbg("%s - software flow control = %c", __func__, port_settings.sflow);
1231 1225
1232 port_settings.xon = START_CHAR(port->tty); 1226 port_settings.xon = START_CHAR(port->tty);
1233 port_settings.xoff = STOP_CHAR(port->tty); 1227 port_settings.xoff = STOP_CHAR(port->tty);
1234 dbg("%s - XON = %2x, XOFF = %2x", __FUNCTION__, port_settings.xon, port_settings.xoff); 1228 dbg("%s - XON = %2x, XOFF = %2x", __func__, port_settings.xon, port_settings.xoff);
1235 1229
1236 /* get the baud rate wanted */ 1230 /* get the baud rate wanted */
1237 port_settings.baud = tty_get_baud_rate(port->tty); 1231 port_settings.baud = tty_get_baud_rate(port->tty);
1238 dbg("%s - baud rate = %d", __FUNCTION__, port_settings.baud); 1232 dbg("%s - baud rate = %d", __func__, port_settings.baud);
1239 1233
1240 /* fixme: should set validated settings */ 1234 /* fixme: should set validated settings */
1241 tty_encode_baud_rate(port->tty, port_settings.baud, port_settings.baud); 1235 tty_encode_baud_rate(port->tty, port_settings.baud, port_settings.baud);
@@ -1318,7 +1312,7 @@ static int start_command_port(struct usb_serial *serial)
1318 command_port->read_urb->dev = serial->dev; 1312 command_port->read_urb->dev = serial->dev;
1319 retval = usb_submit_urb(command_port->read_urb, GFP_KERNEL); 1313 retval = usb_submit_urb(command_port->read_urb, GFP_KERNEL);
1320 if (retval) { 1314 if (retval) {
1321 err("%s - failed submitting read urb, error %d", __FUNCTION__, retval); 1315 err("%s - failed submitting read urb, error %d", __func__, retval);
1322 goto exit; 1316 goto exit;
1323 } 1317 }
1324 } 1318 }
@@ -1454,7 +1448,7 @@ static void rx_data_softint(struct work_struct *work)
1454 urb->dev = port->serial->dev; 1448 urb->dev = port->serial->dev;
1455 result = usb_submit_urb(urb, GFP_ATOMIC); 1449 result = usb_submit_urb(urb, GFP_ATOMIC);
1456 if (result) { 1450 if (result) {
1457 err("%s - failed resubmitting read urb, error %d", __FUNCTION__, result); 1451 err("%s - failed resubmitting read urb, error %d", __func__, result);
1458 spin_lock_irqsave(&info->lock, flags); 1452 spin_lock_irqsave(&info->lock, flags);
1459 list_add(tmp, &info->rx_urbs_free); 1453 list_add(tmp, &info->rx_urbs_free);
1460 continue; 1454 continue;
diff --git a/drivers/usb/storage/Kconfig b/drivers/usb/storage/Kconfig
index 7e53333be01..0f6d234d699 100644
--- a/drivers/usb/storage/Kconfig
+++ b/drivers/usb/storage/Kconfig
@@ -32,8 +32,8 @@ config USB_STORAGE_DEBUG
32 verbose debugging messages. 32 verbose debugging messages.
33 33
34config USB_STORAGE_DATAFAB 34config USB_STORAGE_DATAFAB
35 bool "Datafab Compact Flash Reader support (EXPERIMENTAL)" 35 bool "Datafab Compact Flash Reader support"
36 depends on USB_STORAGE && EXPERIMENTAL 36 depends on USB_STORAGE
37 help 37 help
38 Support for certain Datafab CompactFlash readers. 38 Support for certain Datafab CompactFlash readers.
39 Datafab has a web page at <http://www.datafabusa.com/>. 39 Datafab has a web page at <http://www.datafabusa.com/>.
@@ -69,8 +69,8 @@ config USB_STORAGE_DPCM
69 There is a web page at <http://www.ziocorp.com/products/>. 69 There is a web page at <http://www.ziocorp.com/products/>.
70 70
71config USB_STORAGE_USBAT 71config USB_STORAGE_USBAT
72 bool "USBAT/USBAT02-based storage support (EXPERIMENTAL)" 72 bool "USBAT/USBAT02-based storage support"
73 depends on USB_STORAGE && EXPERIMENTAL 73 depends on USB_STORAGE
74 help 74 help
75 Say Y here to include additional code to support storage devices 75 Say Y here to include additional code to support storage devices
76 based on the SCM/Shuttle USBAT/USBAT02 processors. 76 based on the SCM/Shuttle USBAT/USBAT02 processors.
@@ -90,30 +90,30 @@ config USB_STORAGE_USBAT
90 - Sandisk ImageMate SDDR-05b 90 - Sandisk ImageMate SDDR-05b
91 91
92config USB_STORAGE_SDDR09 92config USB_STORAGE_SDDR09
93 bool "SanDisk SDDR-09 (and other SmartMedia) support (EXPERIMENTAL)" 93 bool "SanDisk SDDR-09 (and other SmartMedia) support"
94 depends on USB_STORAGE && EXPERIMENTAL 94 depends on USB_STORAGE
95 help 95 help
96 Say Y here to include additional code to support the Sandisk SDDR-09 96 Say Y here to include additional code to support the Sandisk SDDR-09
97 SmartMedia reader in the USB Mass Storage driver. 97 SmartMedia reader in the USB Mass Storage driver.
98 Also works for the Microtech Zio! SmartMedia reader. 98 Also works for the Microtech Zio! SmartMedia reader.
99 99
100config USB_STORAGE_SDDR55 100config USB_STORAGE_SDDR55
101 bool "SanDisk SDDR-55 SmartMedia support (EXPERIMENTAL)" 101 bool "SanDisk SDDR-55 SmartMedia support"
102 depends on USB_STORAGE && EXPERIMENTAL 102 depends on USB_STORAGE
103 help 103 help
104 Say Y here to include additional code to support the Sandisk SDDR-55 104 Say Y here to include additional code to support the Sandisk SDDR-55
105 SmartMedia reader in the USB Mass Storage driver. 105 SmartMedia reader in the USB Mass Storage driver.
106 106
107config USB_STORAGE_JUMPSHOT 107config USB_STORAGE_JUMPSHOT
108 bool "Lexar Jumpshot Compact Flash Reader (EXPERIMENTAL)" 108 bool "Lexar Jumpshot Compact Flash Reader"
109 depends on USB_STORAGE && EXPERIMENTAL 109 depends on USB_STORAGE
110 help 110 help
111 Say Y here to include additional code to support the Lexar Jumpshot 111 Say Y here to include additional code to support the Lexar Jumpshot
112 USB CompactFlash reader. 112 USB CompactFlash reader.
113 113
114config USB_STORAGE_ALAUDA 114config USB_STORAGE_ALAUDA
115 bool "Olympus MAUSB-10/Fuji DPC-R1 support (EXPERIMENTAL)" 115 bool "Olympus MAUSB-10/Fuji DPC-R1 support"
116 depends on USB_STORAGE && EXPERIMENTAL 116 depends on USB_STORAGE
117 help 117 help
118 Say Y here to include additional code to support the Olympus MAUSB-10 118 Say Y here to include additional code to support the Olympus MAUSB-10
119 and Fujifilm DPC-R1 USB Card reader/writer devices. 119 and Fujifilm DPC-R1 USB Card reader/writer devices.
@@ -122,8 +122,8 @@ config USB_STORAGE_ALAUDA
122 XD and SmartMedia cards. 122 XD and SmartMedia cards.
123 123
124config USB_STORAGE_ONETOUCH 124config USB_STORAGE_ONETOUCH
125 bool "Support OneTouch Button on Maxtor Hard Drives (EXPERIMENTAL)" 125 bool "Support OneTouch Button on Maxtor Hard Drives"
126 depends on USB_STORAGE && INPUT_EVDEV && EXPERIMENTAL && !PM 126 depends on USB_STORAGE && INPUT_EVDEV
127 help 127 help
128 Say Y here to include additional code to support the Maxtor OneTouch 128 Say Y here to include additional code to support the Maxtor OneTouch
129 USB hard drive's onetouch button. 129 USB hard drive's onetouch button.
@@ -145,6 +145,17 @@ config USB_STORAGE_KARMA
145 on the resulting scsi device node returns the Karma to normal 145 on the resulting scsi device node returns the Karma to normal
146 operation. 146 operation.
147 147
148config USB_STORAGE_CYPRESS_ATACB
149 bool "SAT emulation on Cypress USB/ATA Bridge with ATACB"
150 depends on USB_STORAGE
151 ---help---
152 Say Y here if you want to use SAT (ata pass through) on devices based
153 on the Cypress USB/ATA bridge supporting ATACB. This will allow you
154 to use tools to tune and monitor your drive (like hdparm or smartctl).
155
156 If you say no here your device will still work with the standard usb
157 mass storage class.
158
148config USB_LIBUSUAL 159config USB_LIBUSUAL
149 bool "The shared table of common (or usual) storage devices" 160 bool "The shared table of common (or usual) storage devices"
150 depends on USB 161 depends on USB
diff --git a/drivers/usb/storage/Makefile b/drivers/usb/storage/Makefile
index 023969b4385..4c596c766c5 100644
--- a/drivers/usb/storage/Makefile
+++ b/drivers/usb/storage/Makefile
@@ -21,6 +21,7 @@ usb-storage-obj-$(CONFIG_USB_STORAGE_JUMPSHOT) += jumpshot.o
21usb-storage-obj-$(CONFIG_USB_STORAGE_ALAUDA) += alauda.o 21usb-storage-obj-$(CONFIG_USB_STORAGE_ALAUDA) += alauda.o
22usb-storage-obj-$(CONFIG_USB_STORAGE_ONETOUCH) += onetouch.o 22usb-storage-obj-$(CONFIG_USB_STORAGE_ONETOUCH) += onetouch.o
23usb-storage-obj-$(CONFIG_USB_STORAGE_KARMA) += karma.o 23usb-storage-obj-$(CONFIG_USB_STORAGE_KARMA) += karma.o
24usb-storage-obj-$(CONFIG_USB_STORAGE_CYPRESS_ATACB) += cypress_atacb.o
24 25
25usb-storage-objs := scsiglue.o protocol.o transport.o usb.o \ 26usb-storage-objs := scsiglue.o protocol.o transport.o usb.o \
26 initializers.o $(usb-storage-obj-y) 27 initializers.o $(usb-storage-obj-y)
diff --git a/drivers/usb/storage/cypress_atacb.c b/drivers/usb/storage/cypress_atacb.c
new file mode 100644
index 00000000000..d88824b3511
--- /dev/null
+++ b/drivers/usb/storage/cypress_atacb.c
@@ -0,0 +1,200 @@
1/*
2 * Support for emulating SAT (ata pass through) on devices based
3 * on the Cypress USB/ATA bridge supporting ATACB.
4 *
5 * Copyright (c) 2008 Matthieu Castet (castet.matthieu@free.fr)
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
10 * later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22#include <scsi/scsi.h>
23#include <scsi/scsi_cmnd.h>
24#include <scsi/scsi_eh.h>
25#include <linux/ata.h>
26
27#include "usb.h"
28#include "protocol.h"
29#include "scsiglue.h"
30#include "debug.h"
31
32/*
33 * ATACB is a protocol used on cypress usb<->ata bridge to
34 * send raw ATA command over mass storage
35 * There is a ATACB2 protocol that support LBA48 on newer chip.
36 * More info that be found on cy7c68310_8.pdf and cy7c68300c_8.pdf
37 * datasheet from cypress.com.
38 */
39void cypress_atacb_passthrough(struct scsi_cmnd *srb, struct us_data *us)
40{
41 unsigned char save_cmnd[MAX_COMMAND_SIZE];
42
43 if (likely(srb->cmnd[0] != ATA_16 && srb->cmnd[0] != ATA_12)) {
44 usb_stor_transparent_scsi_command(srb, us);
45 return;
46 }
47
48 memcpy(save_cmnd, srb->cmnd, sizeof(save_cmnd));
49 memset(srb->cmnd, 0, sizeof(srb->cmnd));
50
51 /* check if we support the command */
52 if (save_cmnd[1] >> 5) /* MULTIPLE_COUNT */
53 goto invalid_fld;
54 /* check protocol */
55 switch((save_cmnd[1] >> 1) & 0xf) {
56 case 3: /*no DATA */
57 case 4: /* PIO in */
58 case 5: /* PIO out */
59 break;
60 default:
61 goto invalid_fld;
62 }
63
64 /* first build the ATACB command */
65 srb->cmd_len = 16;
66
67 srb->cmnd[0] = 0x24; /* bVSCBSignature : vendor-specific command
68 this value can change, but most(all ?) manufacturers
69 keep the cypress default : 0x24 */
70 srb->cmnd[1] = 0x24; /* bVSCBSubCommand : 0x24 for ATACB */
71
72 srb->cmnd[3] = 0xff - 1; /* features, sector count, lba low, lba med
73 lba high, device, command are valid */
74 srb->cmnd[4] = 1; /* TransferBlockCount : 512 */
75
76 if (save_cmnd[0] == ATA_16) {
77 srb->cmnd[ 6] = save_cmnd[ 4]; /* features */
78 srb->cmnd[ 7] = save_cmnd[ 6]; /* sector count */
79 srb->cmnd[ 8] = save_cmnd[ 8]; /* lba low */
80 srb->cmnd[ 9] = save_cmnd[10]; /* lba med */
81 srb->cmnd[10] = save_cmnd[12]; /* lba high */
82 srb->cmnd[11] = save_cmnd[13]; /* device */
83 srb->cmnd[12] = save_cmnd[14]; /* command */
84
85 if (save_cmnd[1] & 0x01) {/* extended bit set for LBA48 */
86 /* this could be supported by atacb2 */
87 if (save_cmnd[3] || save_cmnd[5] || save_cmnd[7] || save_cmnd[9]
88 || save_cmnd[11])
89 goto invalid_fld;
90 }
91 }
92 else { /* ATA12 */
93 srb->cmnd[ 6] = save_cmnd[3]; /* features */
94 srb->cmnd[ 7] = save_cmnd[4]; /* sector count */
95 srb->cmnd[ 8] = save_cmnd[5]; /* lba low */
96 srb->cmnd[ 9] = save_cmnd[6]; /* lba med */
97 srb->cmnd[10] = save_cmnd[7]; /* lba high */
98 srb->cmnd[11] = save_cmnd[8]; /* device */
99 srb->cmnd[12] = save_cmnd[9]; /* command */
100
101 }
102 /* Filter SET_FEATURES - XFER MODE command */
103 if ((srb->cmnd[12] == ATA_CMD_SET_FEATURES)
104 && (srb->cmnd[6] == SETFEATURES_XFER))
105 goto invalid_fld;
106
107 if (srb->cmnd[12] == ATA_CMD_ID_ATA || srb->cmnd[12] == ATA_CMD_ID_ATAPI)
108 srb->cmnd[2] |= (1<<7); /* set IdentifyPacketDevice for these cmds */
109
110
111 usb_stor_transparent_scsi_command(srb, us);
112
113 /* if the device doesn't support ATACB
114 */
115 if (srb->result == SAM_STAT_CHECK_CONDITION &&
116 memcmp(srb->sense_buffer, usb_stor_sense_invalidCDB,
117 sizeof(usb_stor_sense_invalidCDB)) == 0) {
118 US_DEBUGP("cypress atacb not supported ???\n");
119 goto end;
120 }
121
122 /* if ck_cond flags is set, and there wasn't critical error,
123 * build the special sense
124 */
125 if ((srb->result != (DID_ERROR << 16) &&
126 srb->result != (DID_ABORT << 16)) &&
127 save_cmnd[2] & 0x20) {
128 struct scsi_eh_save ses;
129 unsigned char regs[8];
130 unsigned char *sb = srb->sense_buffer;
131 unsigned char *desc = sb + 8;
132 int tmp_result;
133
134 /* build the command for
135 * reading the ATA registers */
136 scsi_eh_prep_cmnd(srb, &ses, NULL, 0, 0);
137 srb->sdb.length = sizeof(regs);
138 sg_init_one(&ses.sense_sgl, regs, srb->sdb.length);
139 srb->sdb.table.sgl = &ses.sense_sgl;
140 srb->sc_data_direction = DMA_FROM_DEVICE;
141 srb->sdb.table.nents = 1;
142 /* we use the same command as before, but we set
143 * the read taskfile bit, for not executing atacb command,
144 * but reading register selected in srb->cmnd[4]
145 */
146 srb->cmnd[2] = 1;
147
148 usb_stor_transparent_scsi_command(srb, us);
149 tmp_result = srb->result;
150 scsi_eh_restore_cmnd(srb, &ses);
151 /* we fail to get registers, report invalid command */
152 if (tmp_result != SAM_STAT_GOOD)
153 goto invalid_fld;
154
155 /* build the sense */
156 memset(sb, 0, SCSI_SENSE_BUFFERSIZE);
157
158 /* set sk, asc for a good command */
159 sb[1] = RECOVERED_ERROR;
160 sb[2] = 0; /* ATA PASS THROUGH INFORMATION AVAILABLE */
161 sb[3] = 0x1D;
162
163 /* XXX we should generate sk, asc, ascq from status and error
164 * regs
165 * (see 11.1 Error translation ­ ATA device error to SCSI error map)
166 * and ata_to_sense_error from libata.
167 */
168
169 /* Sense data is current and format is descriptor. */
170 sb[0] = 0x72;
171 desc[0] = 0x09; /* ATA_RETURN_DESCRIPTOR */
172
173 /* set length of additional sense data */
174 sb[7] = 14;
175 desc[1] = 12;
176
177 /* Copy registers into sense buffer. */
178 desc[ 2] = 0x00;
179 desc[ 3] = regs[1]; /* features */
180 desc[ 5] = regs[2]; /* sector count */
181 desc[ 7] = regs[3]; /* lba low */
182 desc[ 9] = regs[4]; /* lba med */
183 desc[11] = regs[5]; /* lba high */
184 desc[12] = regs[6]; /* device */
185 desc[13] = regs[7]; /* command */
186
187 srb->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION;
188 }
189 goto end;
190invalid_fld:
191 srb->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION;
192
193 memcpy(srb->sense_buffer,
194 usb_stor_sense_invalidCDB,
195 sizeof(usb_stor_sense_invalidCDB));
196end:
197 memcpy(srb->cmnd, save_cmnd, sizeof(save_cmnd));
198 if (srb->cmnd[0] == ATA_12)
199 srb->cmd_len = 12;
200}
diff --git a/drivers/usb/storage/cypress_atacb.h b/drivers/usb/storage/cypress_atacb.h
new file mode 100644
index 00000000000..fbada898d56
--- /dev/null
+++ b/drivers/usb/storage/cypress_atacb.h
@@ -0,0 +1,25 @@
1/*
2 * Support for emulating SAT (ata pass through) on devices based
3 * on the Cypress USB/ATA bridge supporting ATACB.
4 *
5 * Copyright (c) 2008 Matthieu Castet (castet.matthieu@free.fr)
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
10 * later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22#ifndef _CYPRESS_ATACB_H_
23#define _CYPRESS_ATACB_H_
24extern void cypress_atacb_passthrough(struct scsi_cmnd*, struct us_data*);
25#endif
diff --git a/drivers/usb/storage/libusual.c b/drivers/usb/storage/libusual.c
index 55b952084f0..a28d49122e7 100644
--- a/drivers/usb/storage/libusual.c
+++ b/drivers/usb/storage/libusual.c
@@ -9,6 +9,7 @@
9#include <linux/usb_usual.h> 9#include <linux/usb_usual.h>
10#include <linux/vmalloc.h> 10#include <linux/vmalloc.h>
11#include <linux/kthread.h> 11#include <linux/kthread.h>
12#include <linux/mutex.h>
12 13
13/* 14/*
14 */ 15 */
@@ -30,7 +31,7 @@ static atomic_t usu_bias = ATOMIC_INIT(USB_US_DEFAULT_BIAS);
30#define BIAS_NAME_SIZE (sizeof("usb-storage")) 31#define BIAS_NAME_SIZE (sizeof("usb-storage"))
31static const char *bias_names[3] = { "none", "usb-storage", "ub" }; 32static const char *bias_names[3] = { "none", "usb-storage", "ub" };
32 33
33static struct semaphore usu_init_notify; 34static DEFINE_MUTEX(usu_probe_mutex);
34static DECLARE_COMPLETION(usu_end_notify); 35static DECLARE_COMPLETION(usu_end_notify);
35static atomic_t total_threads = ATOMIC_INIT(0); 36static atomic_t total_threads = ATOMIC_INIT(0);
36 37
@@ -178,10 +179,7 @@ static int usu_probe_thread(void *arg)
178 int rc; 179 int rc;
179 unsigned long flags; 180 unsigned long flags;
180 181
181 /* A completion does not work here because it's counted. */ 182 mutex_lock(&usu_probe_mutex);
182 down(&usu_init_notify);
183 up(&usu_init_notify);
184
185 rc = request_module(bias_names[type]); 183 rc = request_module(bias_names[type]);
186 spin_lock_irqsave(&usu_lock, flags); 184 spin_lock_irqsave(&usu_lock, flags);
187 if (rc == 0 && (st->fls & USU_MOD_FL_PRESENT) == 0) { 185 if (rc == 0 && (st->fls & USU_MOD_FL_PRESENT) == 0) {
@@ -194,6 +192,7 @@ static int usu_probe_thread(void *arg)
194 } 192 }
195 st->fls &= ~USU_MOD_FL_THREAD; 193 st->fls &= ~USU_MOD_FL_THREAD;
196 spin_unlock_irqrestore(&usu_lock, flags); 194 spin_unlock_irqrestore(&usu_lock, flags);
195 mutex_unlock(&usu_probe_mutex);
197 196
198 complete_and_exit(&usu_end_notify, 0); 197 complete_and_exit(&usu_end_notify, 0);
199} 198}
@@ -204,10 +203,9 @@ static int __init usb_usual_init(void)
204{ 203{
205 int rc; 204 int rc;
206 205
207 sema_init(&usu_init_notify, 0); 206 mutex_lock(&usu_probe_mutex);
208
209 rc = usb_register(&usu_driver); 207 rc = usb_register(&usu_driver);
210 up(&usu_init_notify); 208 mutex_unlock(&usu_probe_mutex);
211 return rc; 209 return rc;
212} 210}
213 211
diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
index 8c1e2954f3b..3fcde9f0fa5 100644
--- a/drivers/usb/storage/scsiglue.c
+++ b/drivers/usb/storage/scsiglue.c
@@ -73,6 +73,7 @@ static const char* host_info(struct Scsi_Host *host)
73static int slave_alloc (struct scsi_device *sdev) 73static int slave_alloc (struct scsi_device *sdev)
74{ 74{
75 struct us_data *us = host_to_us(sdev->host); 75 struct us_data *us = host_to_us(sdev->host);
76 struct usb_host_endpoint *bulk_in_ep;
76 77
77 /* 78 /*
78 * Set the INQUIRY transfer length to 36. We don't use any of 79 * Set the INQUIRY transfer length to 36. We don't use any of
@@ -84,12 +85,13 @@ static int slave_alloc (struct scsi_device *sdev)
84 /* Scatter-gather buffers (all but the last) must have a length 85 /* Scatter-gather buffers (all but the last) must have a length
85 * divisible by the bulk maxpacket size. Otherwise a data packet 86 * divisible by the bulk maxpacket size. Otherwise a data packet
86 * would end up being short, causing a premature end to the data 87 * would end up being short, causing a premature end to the data
87 * transfer. Since high-speed bulk pipes have a maxpacket size 88 * transfer. We'll use the maxpacket value of the bulk-IN pipe
88 * of 512, we'll use that as the scsi device queue's DMA alignment 89 * to set the SCSI device queue's DMA alignment mask.
89 * mask. Guaranteeing proper alignment of the first buffer will 90 */
90 * have the desired effect because, except at the beginning and 91 bulk_in_ep = us->pusb_dev->ep_in[usb_pipeendpoint(us->recv_bulk_pipe)];
91 * the end, scatter-gather buffers follow page boundaries. */ 92 blk_queue_update_dma_alignment(sdev->request_queue,
92 blk_queue_update_dma_alignment(sdev->request_queue, (512 - 1)); 93 le16_to_cpu(bulk_in_ep->desc.wMaxPacketSize) - 1);
94 /* wMaxPacketSize must be a power of 2 */
93 95
94 /* 96 /*
95 * The UFI spec treates the Peripheral Qualifier bits in an 97 * The UFI spec treates the Peripheral Qualifier bits in an
@@ -132,7 +134,7 @@ static int slave_configure(struct scsi_device *sdev)
132 /* Disk-type devices use MODE SENSE(6) if the protocol 134 /* Disk-type devices use MODE SENSE(6) if the protocol
133 * (SubClass) is Transparent SCSI, otherwise they use 135 * (SubClass) is Transparent SCSI, otherwise they use
134 * MODE SENSE(10). */ 136 * MODE SENSE(10). */
135 if (us->subclass != US_SC_SCSI) 137 if (us->subclass != US_SC_SCSI && us->subclass != US_SC_CYP_ATACB)
136 sdev->use_10_for_ms = 1; 138 sdev->use_10_for_ms = 1;
137 139
138 /* Many disks only accept MODE SENSE transfer lengths of 140 /* Many disks only accept MODE SENSE transfer lengths of
@@ -226,12 +228,12 @@ static int queuecommand(struct scsi_cmnd *srb,
226{ 228{
227 struct us_data *us = host_to_us(srb->device->host); 229 struct us_data *us = host_to_us(srb->device->host);
228 230
229 US_DEBUGP("%s called\n", __FUNCTION__); 231 US_DEBUGP("%s called\n", __func__);
230 232
231 /* check for state-transition errors */ 233 /* check for state-transition errors */
232 if (us->srb != NULL) { 234 if (us->srb != NULL) {
233 printk(KERN_ERR USB_STORAGE "Error in %s: us->srb = %p\n", 235 printk(KERN_ERR USB_STORAGE "Error in %s: us->srb = %p\n",
234 __FUNCTION__, us->srb); 236 __func__, us->srb);
235 return SCSI_MLQUEUE_HOST_BUSY; 237 return SCSI_MLQUEUE_HOST_BUSY;
236 } 238 }
237 239
@@ -260,7 +262,7 @@ static int command_abort(struct scsi_cmnd *srb)
260{ 262{
261 struct us_data *us = host_to_us(srb->device->host); 263 struct us_data *us = host_to_us(srb->device->host);
262 264
263 US_DEBUGP("%s called\n", __FUNCTION__); 265 US_DEBUGP("%s called\n", __func__);
264 266
265 /* us->srb together with the TIMED_OUT, RESETTING, and ABORTING 267 /* us->srb together with the TIMED_OUT, RESETTING, and ABORTING
266 * bits are protected by the host lock. */ 268 * bits are protected by the host lock. */
@@ -297,7 +299,7 @@ static int device_reset(struct scsi_cmnd *srb)
297 struct us_data *us = host_to_us(srb->device->host); 299 struct us_data *us = host_to_us(srb->device->host);
298 int result; 300 int result;
299 301
300 US_DEBUGP("%s called\n", __FUNCTION__); 302 US_DEBUGP("%s called\n", __func__);
301 303
302 /* lock the device pointers and do the reset */ 304 /* lock the device pointers and do the reset */
303 mutex_lock(&(us->dev_mutex)); 305 mutex_lock(&(us->dev_mutex));
@@ -313,7 +315,7 @@ static int bus_reset(struct scsi_cmnd *srb)
313 struct us_data *us = host_to_us(srb->device->host); 315 struct us_data *us = host_to_us(srb->device->host);
314 int result; 316 int result;
315 317
316 US_DEBUGP("%s called\n", __FUNCTION__); 318 US_DEBUGP("%s called\n", __func__);
317 result = usb_stor_port_reset(us); 319 result = usb_stor_port_reset(us);
318 return result < 0 ? FAILED : SUCCESS; 320 return result < 0 ? FAILED : SUCCESS;
319} 321}
diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
index bdd4334bed5..6610d2dd1e7 100644
--- a/drivers/usb/storage/transport.c
+++ b/drivers/usb/storage/transport.c
@@ -110,7 +110,7 @@
110 */ 110 */
111static void usb_stor_blocking_completion(struct urb *urb) 111static void usb_stor_blocking_completion(struct urb *urb)
112{ 112{
113 struct completion *urb_done_ptr = (struct completion *)urb->context; 113 struct completion *urb_done_ptr = urb->context;
114 114
115 complete(urb_done_ptr); 115 complete(urb_done_ptr);
116} 116}
@@ -198,7 +198,7 @@ int usb_stor_control_msg(struct us_data *us, unsigned int pipe,
198 int status; 198 int status;
199 199
200 US_DEBUGP("%s: rq=%02x rqtype=%02x value=%04x index=%02x len=%u\n", 200 US_DEBUGP("%s: rq=%02x rqtype=%02x value=%04x index=%02x len=%u\n",
201 __FUNCTION__, request, requesttype, 201 __func__, request, requesttype,
202 value, index, size); 202 value, index, size);
203 203
204 /* fill in the devrequest structure */ 204 /* fill in the devrequest structure */
@@ -250,7 +250,7 @@ int usb_stor_clear_halt(struct us_data *us, unsigned int pipe)
250 usb_settoggle(us->pusb_dev, usb_pipeendpoint(pipe), 250 usb_settoggle(us->pusb_dev, usb_pipeendpoint(pipe),
251 usb_pipeout(pipe), 0); 251 usb_pipeout(pipe), 0);
252 252
253 US_DEBUGP("%s: result = %d\n", __FUNCTION__, result); 253 US_DEBUGP("%s: result = %d\n", __func__, result);
254 return result; 254 return result;
255} 255}
256 256
@@ -332,7 +332,7 @@ int usb_stor_ctrl_transfer(struct us_data *us, unsigned int pipe,
332 int result; 332 int result;
333 333
334 US_DEBUGP("%s: rq=%02x rqtype=%02x value=%04x index=%02x len=%u\n", 334 US_DEBUGP("%s: rq=%02x rqtype=%02x value=%04x index=%02x len=%u\n",
335 __FUNCTION__, request, requesttype, 335 __func__, request, requesttype,
336 value, index, size); 336 value, index, size);
337 337
338 /* fill in the devrequest structure */ 338 /* fill in the devrequest structure */
@@ -366,7 +366,7 @@ static int usb_stor_intr_transfer(struct us_data *us, void *buf,
366 unsigned int pipe = us->recv_intr_pipe; 366 unsigned int pipe = us->recv_intr_pipe;
367 unsigned int maxp; 367 unsigned int maxp;
368 368
369 US_DEBUGP("%s: xfer %u bytes\n", __FUNCTION__, length); 369 US_DEBUGP("%s: xfer %u bytes\n", __func__, length);
370 370
371 /* calculate the max packet size */ 371 /* calculate the max packet size */
372 maxp = usb_maxpacket(us->pusb_dev, pipe, usb_pipeout(pipe)); 372 maxp = usb_maxpacket(us->pusb_dev, pipe, usb_pipeout(pipe));
@@ -393,7 +393,7 @@ int usb_stor_bulk_transfer_buf(struct us_data *us, unsigned int pipe,
393{ 393{
394 int result; 394 int result;
395 395
396 US_DEBUGP("%s: xfer %u bytes\n", __FUNCTION__, length); 396 US_DEBUGP("%s: xfer %u bytes\n", __func__, length);
397 397
398 /* fill and submit the URB */ 398 /* fill and submit the URB */
399 usb_fill_bulk_urb(us->current_urb, us->pusb_dev, pipe, buf, length, 399 usb_fill_bulk_urb(us->current_urb, us->pusb_dev, pipe, buf, length,
@@ -424,7 +424,7 @@ static int usb_stor_bulk_transfer_sglist(struct us_data *us, unsigned int pipe,
424 return USB_STOR_XFER_ERROR; 424 return USB_STOR_XFER_ERROR;
425 425
426 /* initialize the scatter-gather request block */ 426 /* initialize the scatter-gather request block */
427 US_DEBUGP("%s: xfer %u bytes, %d entries\n", __FUNCTION__, 427 US_DEBUGP("%s: xfer %u bytes, %d entries\n", __func__,
428 length, num_sg); 428 length, num_sg);
429 result = usb_sg_init(&us->current_sg, us->pusb_dev, pipe, 0, 429 result = usb_sg_init(&us->current_sg, us->pusb_dev, pipe, 0,
430 sg, num_sg, length, GFP_NOIO); 430 sg, num_sg, length, GFP_NOIO);
@@ -603,7 +603,8 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
603 scsi_eh_prep_cmnd(srb, &ses, NULL, 0, US_SENSE_SIZE); 603 scsi_eh_prep_cmnd(srb, &ses, NULL, 0, US_SENSE_SIZE);
604 604
605 /* FIXME: we must do the protocol translation here */ 605 /* FIXME: we must do the protocol translation here */
606 if (us->subclass == US_SC_RBC || us->subclass == US_SC_SCSI) 606 if (us->subclass == US_SC_RBC || us->subclass == US_SC_SCSI ||
607 us->subclass == US_SC_CYP_ATACB)
607 srb->cmd_len = 6; 608 srb->cmd_len = 6;
608 else 609 else
609 srb->cmd_len = 12; 610 srb->cmd_len = 12;
@@ -700,7 +701,7 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
700/* Stop the current URB transfer */ 701/* Stop the current URB transfer */
701void usb_stor_stop_transport(struct us_data *us) 702void usb_stor_stop_transport(struct us_data *us)
702{ 703{
703 US_DEBUGP("%s called\n", __FUNCTION__); 704 US_DEBUGP("%s called\n", __func__);
704 705
705 /* If the state machine is blocked waiting for an URB, 706 /* If the state machine is blocked waiting for an URB,
706 * let's wake it up. The test_and_clear_bit() call 707 * let's wake it up. The test_and_clear_bit() call
@@ -1134,7 +1135,7 @@ static int usb_stor_reset_common(struct us_data *us,
1134 1135
1135int usb_stor_CB_reset(struct us_data *us) 1136int usb_stor_CB_reset(struct us_data *us)
1136{ 1137{
1137 US_DEBUGP("%s called\n", __FUNCTION__); 1138 US_DEBUGP("%s called\n", __func__);
1138 1139
1139 memset(us->iobuf, 0xFF, CB_RESET_CMD_SIZE); 1140 memset(us->iobuf, 0xFF, CB_RESET_CMD_SIZE);
1140 us->iobuf[0] = SEND_DIAGNOSTIC; 1141 us->iobuf[0] = SEND_DIAGNOSTIC;
@@ -1149,7 +1150,7 @@ int usb_stor_CB_reset(struct us_data *us)
1149 */ 1150 */
1150int usb_stor_Bulk_reset(struct us_data *us) 1151int usb_stor_Bulk_reset(struct us_data *us)
1151{ 1152{
1152 US_DEBUGP("%s called\n", __FUNCTION__); 1153 US_DEBUGP("%s called\n", __func__);
1153 1154
1154 return usb_stor_reset_common(us, US_BULK_RESET_REQUEST, 1155 return usb_stor_reset_common(us, US_BULK_RESET_REQUEST,
1155 USB_TYPE_CLASS | USB_RECIP_INTERFACE, 1156 USB_TYPE_CLASS | USB_RECIP_INTERFACE,
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index 91252075e6e..732bf52a775 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -1719,6 +1719,14 @@ UNUSUAL_DEV( 0xed06, 0x4500, 0x0001, 0x0001,
1719 US_SC_DEVICE, US_PR_DEVICE, NULL, 1719 US_SC_DEVICE, US_PR_DEVICE, NULL,
1720 US_FL_CAPACITY_HEURISTICS), 1720 US_FL_CAPACITY_HEURISTICS),
1721 1721
1722#ifdef CONFIG_USB_STORAGE_CYPRESS_ATACB
1723UNUSUAL_DEV( 0x04b4, 0x6830, 0x0000, 0x9999,
1724 "Cypress",
1725 "Cypress AT2LP",
1726 US_SC_CYP_ATACB, US_PR_BULK, NULL,
1727 0),
1728#endif
1729
1722/* Control/Bulk transport for all SubClass values */ 1730/* Control/Bulk transport for all SubClass values */
1723USUAL_DEV(US_SC_RBC, US_PR_CB, USB_US_TYPE_STOR), 1731USUAL_DEV(US_SC_RBC, US_PR_CB, USB_US_TYPE_STOR),
1724USUAL_DEV(US_SC_8020, US_PR_CB, USB_US_TYPE_STOR), 1732USUAL_DEV(US_SC_8020, US_PR_CB, USB_US_TYPE_STOR),
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index ac6114eea0c..a856effad3b 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -101,6 +101,9 @@
101#ifdef CONFIG_USB_STORAGE_KARMA 101#ifdef CONFIG_USB_STORAGE_KARMA
102#include "karma.h" 102#include "karma.h"
103#endif 103#endif
104#ifdef CONFIG_USB_STORAGE_CYPRESS_ATACB
105#include "cypress_atacb.h"
106#endif
104 107
105/* Some informational data */ 108/* Some informational data */
106MODULE_AUTHOR("Matthew Dharm <mdharm-usb@one-eyed-alien.net>"); 109MODULE_AUTHOR("Matthew Dharm <mdharm-usb@one-eyed-alien.net>");
@@ -187,7 +190,7 @@ static int storage_suspend(struct usb_interface *iface, pm_message_t message)
187 /* Wait until no command is running */ 190 /* Wait until no command is running */
188 mutex_lock(&us->dev_mutex); 191 mutex_lock(&us->dev_mutex);
189 192
190 US_DEBUGP("%s\n", __FUNCTION__); 193 US_DEBUGP("%s\n", __func__);
191 if (us->suspend_resume_hook) 194 if (us->suspend_resume_hook)
192 (us->suspend_resume_hook)(us, US_SUSPEND); 195 (us->suspend_resume_hook)(us, US_SUSPEND);
193 196
@@ -204,7 +207,7 @@ static int storage_resume(struct usb_interface *iface)
204 207
205 mutex_lock(&us->dev_mutex); 208 mutex_lock(&us->dev_mutex);
206 209
207 US_DEBUGP("%s\n", __FUNCTION__); 210 US_DEBUGP("%s\n", __func__);
208 if (us->suspend_resume_hook) 211 if (us->suspend_resume_hook)
209 (us->suspend_resume_hook)(us, US_RESUME); 212 (us->suspend_resume_hook)(us, US_RESUME);
210 213
@@ -216,7 +219,7 @@ static int storage_reset_resume(struct usb_interface *iface)
216{ 219{
217 struct us_data *us = usb_get_intfdata(iface); 220 struct us_data *us = usb_get_intfdata(iface);
218 221
219 US_DEBUGP("%s\n", __FUNCTION__); 222 US_DEBUGP("%s\n", __func__);
220 223
221 /* Report the reset to the SCSI core */ 224 /* Report the reset to the SCSI core */
222 usb_stor_report_bus_reset(us); 225 usb_stor_report_bus_reset(us);
@@ -237,7 +240,7 @@ static int storage_pre_reset(struct usb_interface *iface)
237{ 240{
238 struct us_data *us = usb_get_intfdata(iface); 241 struct us_data *us = usb_get_intfdata(iface);
239 242
240 US_DEBUGP("%s\n", __FUNCTION__); 243 US_DEBUGP("%s\n", __func__);
241 244
242 /* Make sure no command runs during the reset */ 245 /* Make sure no command runs during the reset */
243 mutex_lock(&us->dev_mutex); 246 mutex_lock(&us->dev_mutex);
@@ -248,7 +251,7 @@ static int storage_post_reset(struct usb_interface *iface)
248{ 251{
249 struct us_data *us = usb_get_intfdata(iface); 252 struct us_data *us = usb_get_intfdata(iface);
250 253
251 US_DEBUGP("%s\n", __FUNCTION__); 254 US_DEBUGP("%s\n", __func__);
252 255
253 /* Report the reset to the SCSI core */ 256 /* Report the reset to the SCSI core */
254 usb_stor_report_bus_reset(us); 257 usb_stor_report_bus_reset(us);
@@ -434,7 +437,7 @@ SkipForAbort:
434/* Associate our private data with the USB device */ 437/* Associate our private data with the USB device */
435static int associate_dev(struct us_data *us, struct usb_interface *intf) 438static int associate_dev(struct us_data *us, struct usb_interface *intf)
436{ 439{
437 US_DEBUGP("-- %s\n", __FUNCTION__); 440 US_DEBUGP("-- %s\n", __func__);
438 441
439 /* Fill in the device-related fields */ 442 /* Fill in the device-related fields */
440 us->pusb_dev = interface_to_usbdev(intf); 443 us->pusb_dev = interface_to_usbdev(intf);
@@ -708,6 +711,13 @@ static int get_protocol(struct us_data *us)
708 break; 711 break;
709#endif 712#endif
710 713
714#ifdef CONFIG_USB_STORAGE_CYPRESS_ATACB
715 case US_SC_CYP_ATACB:
716 us->protocol_name = "Transparent SCSI with Cypress ATACB";
717 us->proto_handler = cypress_atacb_passthrough;
718 break;
719#endif
720
711 default: 721 default:
712 return -EIO; 722 return -EIO;
713 } 723 }
@@ -806,7 +816,7 @@ static int usb_stor_acquire_resources(struct us_data *us)
806/* Release all our dynamic resources */ 816/* Release all our dynamic resources */
807static void usb_stor_release_resources(struct us_data *us) 817static void usb_stor_release_resources(struct us_data *us)
808{ 818{
809 US_DEBUGP("-- %s\n", __FUNCTION__); 819 US_DEBUGP("-- %s\n", __func__);
810 820
811 /* Tell the control thread to exit. The SCSI host must 821 /* Tell the control thread to exit. The SCSI host must
812 * already have been removed so it won't try to queue 822 * already have been removed so it won't try to queue
@@ -832,7 +842,7 @@ static void usb_stor_release_resources(struct us_data *us)
832/* Dissociate from the USB device */ 842/* Dissociate from the USB device */
833static void dissociate_dev(struct us_data *us) 843static void dissociate_dev(struct us_data *us)
834{ 844{
835 US_DEBUGP("-- %s\n", __FUNCTION__); 845 US_DEBUGP("-- %s\n", __func__);
836 846
837 kfree(us->sensebuf); 847 kfree(us->sensebuf);
838 848
diff --git a/drivers/usb/usb-skeleton.c b/drivers/usb/usb-skeleton.c
index c815a40e167..be76084c8d7 100644
--- a/drivers/usb/usb-skeleton.c
+++ b/drivers/usb/usb-skeleton.c
@@ -88,7 +88,7 @@ static int skel_open(struct inode *inode, struct file *file)
88 interface = usb_find_interface(&skel_driver, subminor); 88 interface = usb_find_interface(&skel_driver, subminor);
89 if (!interface) { 89 if (!interface) {
90 err ("%s - error, can't find device for minor %d", 90 err ("%s - error, can't find device for minor %d",
91 __FUNCTION__, subminor); 91 __func__, subminor);
92 retval = -ENODEV; 92 retval = -ENODEV;
93 goto exit; 93 goto exit;
94 } 94 }
@@ -212,7 +212,7 @@ static void skel_write_bulk_callback(struct urb *urb)
212{ 212{
213 struct usb_skel *dev; 213 struct usb_skel *dev;
214 214
215 dev = (struct usb_skel *)urb->context; 215 dev = urb->context;
216 216
217 /* sync/async unlink faults aren't errors */ 217 /* sync/async unlink faults aren't errors */
218 if (urb->status) { 218 if (urb->status) {
@@ -220,7 +220,7 @@ static void skel_write_bulk_callback(struct urb *urb)
220 urb->status == -ECONNRESET || 220 urb->status == -ECONNRESET ||
221 urb->status == -ESHUTDOWN)) 221 urb->status == -ESHUTDOWN))
222 err("%s - nonzero write bulk status received: %d", 222 err("%s - nonzero write bulk status received: %d",
223 __FUNCTION__, urb->status); 223 __func__, urb->status);
224 224
225 spin_lock(&dev->err_lock); 225 spin_lock(&dev->err_lock);
226 dev->errors = urb->status; 226 dev->errors = urb->status;
@@ -301,7 +301,7 @@ static ssize_t skel_write(struct file *file, const char *user_buffer, size_t cou
301 retval = usb_submit_urb(urb, GFP_KERNEL); 301 retval = usb_submit_urb(urb, GFP_KERNEL);
302 mutex_unlock(&dev->io_mutex); 302 mutex_unlock(&dev->io_mutex);
303 if (retval) { 303 if (retval) {
304 err("%s - failed submitting write urb, error %d", __FUNCTION__, retval); 304 err("%s - failed submitting write urb, error %d", __func__, retval);
305 goto error_unanchor; 305 goto error_unanchor;
306 } 306 }
307 307
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 583e0481dfa..c08689ea9b4 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -23,6 +23,7 @@
23 23
24struct usb_device; 24struct usb_device;
25struct usb_driver; 25struct usb_driver;
26struct wusb_dev;
26 27
27/*-------------------------------------------------------------------------*/ 28/*-------------------------------------------------------------------------*/
28 29
@@ -341,103 +342,146 @@ struct usb_bus {
341 342
342struct usb_tt; 343struct usb_tt;
343 344
344/* 345/**
345 * struct usb_device - kernel's representation of a USB device 346 * struct usb_device - kernel's representation of a USB device
346 * 347 * @devnum: device number; address on a USB bus
347 * FIXME: Write the kerneldoc! 348 * @devpath: device ID string for use in messages (e.g., /port/...)
348 * 349 * @state: device state: configured, not attached, etc.
350 * @speed: device speed: high/full/low (or error)
351 * @tt: Transaction Translator info; used with low/full speed dev, highspeed hub
352 * @ttport: device port on that tt hub
353 * @toggle: one bit for each endpoint, with ([0] = IN, [1] = OUT) endpoints
354 * @parent: our hub, unless we're the root
355 * @bus: bus we're part of
356 * @ep0: endpoint 0 data (default control pipe)
357 * @dev: generic device interface
358 * @descriptor: USB device descriptor
359 * @config: all of the device's configs
360 * @actconfig: the active configuration
361 * @ep_in: array of IN endpoints
362 * @ep_out: array of OUT endpoints
363 * @rawdescriptors: raw descriptors for each config
364 * @bus_mA: Current available from the bus
365 * @portnum: parent port number (origin 1)
366 * @level: number of USB hub ancestors
367 * @can_submit: URBs may be submitted
368 * @discon_suspended: disconnected while suspended
369 * @persist_enabled: USB_PERSIST enabled for this device
370 * @have_langid: whether string_langid is valid
371 * @authorized: policy has said we can use it;
372 * (user space) policy determines if we authorize this device to be
373 * used or not. By default, wired USB devices are authorized.
374 * WUSB devices are not, until we authorize them from user space.
375 * FIXME -- complete doc
376 * @authenticated: Crypto authentication passed
377 * @wusb: device is Wireless USB
378 * @string_langid: language ID for strings
379 * @product: iProduct string, if present (static)
380 * @manufacturer: iManufacturer string, if present (static)
381 * @serial: iSerialNumber string, if present (static)
382 * @filelist: usbfs files that are open to this device
383 * @usb_classdev: USB class device that was created for usbfs device
384 * access from userspace
385 * @usbfs_dentry: usbfs dentry entry for the device
386 * @maxchild: number of ports if hub
387 * @children: child devices - USB devices that are attached to this hub
388 * @pm_usage_cnt: usage counter for autosuspend
389 * @quirks: quirks of the whole device
390 * @urbnum: number of URBs submitted for the whole device
391 * @active_duration: total time device is not suspended
392 * @autosuspend: for delayed autosuspends
393 * @pm_mutex: protects PM operations
394 * @last_busy: time of last use
395 * @autosuspend_delay: in jiffies
396 * @connect_time: time device was first connected
397 * @auto_pm: autosuspend/resume in progress
398 * @do_remote_wakeup: remote wakeup should be enabled
399 * @reset_resume: needs reset instead of resume
400 * @autosuspend_disabled: autosuspend disabled by the user
401 * @autoresume_disabled: autoresume disabled by the user
402 * @skip_sys_resume: skip the next system resume
403 *
404 * Notes:
349 * Usbcore drivers should not set usbdev->state directly. Instead use 405 * Usbcore drivers should not set usbdev->state directly. Instead use
350 * usb_set_device_state(). 406 * usb_set_device_state().
351 *
352 * @authorized: (user space) policy determines if we authorize this
353 * device to be used or not. By default, wired USB
354 * devices are authorized. WUSB devices are not, until we
355 * authorize them from user space. FIXME -- complete doc
356 */ 407 */
357struct usb_device { 408struct usb_device {
358 int devnum; /* Address on USB bus */ 409 int devnum;
359 char devpath [16]; /* Use in messages: /port/port/... */ 410 char devpath [16];
360 enum usb_device_state state; /* configured, not attached, etc */ 411 enum usb_device_state state;
361 enum usb_device_speed speed; /* high/full/low (or error) */ 412 enum usb_device_speed speed;
362 413
363 struct usb_tt *tt; /* low/full speed dev, highspeed hub */ 414 struct usb_tt *tt;
364 int ttport; /* device port on that tt hub */ 415 int ttport;
365 416
366 unsigned int toggle[2]; /* one bit for each endpoint 417 unsigned int toggle[2];
367 * ([0] = IN, [1] = OUT) */
368 418
369 struct usb_device *parent; /* our hub, unless we're the root */ 419 struct usb_device *parent;
370 struct usb_bus *bus; /* Bus we're part of */ 420 struct usb_bus *bus;
371 struct usb_host_endpoint ep0; 421 struct usb_host_endpoint ep0;
372 422
373 struct device dev; /* Generic device interface */ 423 struct device dev;
374 424
375 struct usb_device_descriptor descriptor;/* Descriptor */ 425 struct usb_device_descriptor descriptor;
376 struct usb_host_config *config; /* All of the configs */ 426 struct usb_host_config *config;
377 427
378 struct usb_host_config *actconfig;/* the active configuration */ 428 struct usb_host_config *actconfig;
379 struct usb_host_endpoint *ep_in[16]; 429 struct usb_host_endpoint *ep_in[16];
380 struct usb_host_endpoint *ep_out[16]; 430 struct usb_host_endpoint *ep_out[16];
381 431
382 char **rawdescriptors; /* Raw descriptors for each config */ 432 char **rawdescriptors;
383 433
384 unsigned short bus_mA; /* Current available from the bus */ 434 unsigned short bus_mA;
385 u8 portnum; /* Parent port number (origin 1) */ 435 u8 portnum;
386 u8 level; /* Number of USB hub ancestors */ 436 u8 level;
387 437
388 unsigned can_submit:1; /* URBs may be submitted */ 438 unsigned can_submit:1;
389 unsigned discon_suspended:1; /* Disconnected while suspended */ 439 unsigned discon_suspended:1;
390 unsigned have_langid:1; /* whether string_langid is valid */ 440 unsigned persist_enabled:1;
391 unsigned authorized:1; /* Policy has said we can use it */ 441 unsigned have_langid:1;
392 unsigned wusb:1; /* Device is Wireless USB */ 442 unsigned authorized:1;
393 int string_langid; /* language ID for strings */ 443 unsigned authenticated:1;
444 unsigned wusb:1;
445 int string_langid;
394 446
395 /* static strings from the device */ 447 /* static strings from the device */
396 char *product; /* iProduct string, if present */ 448 char *product;
397 char *manufacturer; /* iManufacturer string, if present */ 449 char *manufacturer;
398 char *serial; /* iSerialNumber string, if present */ 450 char *serial;
399 451
400 struct list_head filelist; 452 struct list_head filelist;
401#ifdef CONFIG_USB_DEVICE_CLASS 453#ifdef CONFIG_USB_DEVICE_CLASS
402 struct device *usb_classdev; 454 struct device *usb_classdev;
403#endif 455#endif
404#ifdef CONFIG_USB_DEVICEFS 456#ifdef CONFIG_USB_DEVICEFS
405 struct dentry *usbfs_dentry; /* usbfs dentry entry for the device */ 457 struct dentry *usbfs_dentry;
406#endif 458#endif
407 /*
408 * Child devices - these can be either new devices
409 * (if this is a hub device), or different instances
410 * of this same device.
411 *
412 * Each instance needs its own set of data structures.
413 */
414 459
415 int maxchild; /* Number of ports if hub */ 460 int maxchild;
416 struct usb_device *children[USB_MAXCHILDREN]; 461 struct usb_device *children[USB_MAXCHILDREN];
417 462
418 int pm_usage_cnt; /* usage counter for autosuspend */ 463 int pm_usage_cnt;
419 u32 quirks; /* quirks of the whole device */ 464 u32 quirks;
420 atomic_t urbnum; /* number of URBs submitted for 465 atomic_t urbnum;
421 the whole device */
422 466
423 unsigned long active_duration; /* total time device is not suspended */ 467 unsigned long active_duration;
424 468
425#ifdef CONFIG_PM 469#ifdef CONFIG_PM
426 struct delayed_work autosuspend; /* for delayed autosuspends */ 470 struct delayed_work autosuspend;
427 struct mutex pm_mutex; /* protects PM operations */ 471 struct mutex pm_mutex;
428 472
429 unsigned long last_busy; /* time of last use */ 473 unsigned long last_busy;
430 int autosuspend_delay; /* in jiffies */ 474 int autosuspend_delay;
431 unsigned long connect_time; /* time device was first connected */ 475 unsigned long connect_time;
432 476
433 unsigned auto_pm:1; /* autosuspend/resume in progress */ 477 unsigned auto_pm:1;
434 unsigned do_remote_wakeup:1; /* remote wakeup should be enabled */ 478 unsigned do_remote_wakeup:1;
435 unsigned reset_resume:1; /* needs reset instead of resume */ 479 unsigned reset_resume:1;
436 unsigned persist_enabled:1; /* USB_PERSIST enabled for this dev */ 480 unsigned autosuspend_disabled:1;
437 unsigned autosuspend_disabled:1; /* autosuspend and autoresume */ 481 unsigned autoresume_disabled:1;
438 unsigned autoresume_disabled:1; /* disabled by the user */ 482 unsigned skip_sys_resume:1;
439 unsigned skip_sys_resume:1; /* skip the next system resume */
440#endif 483#endif
484 struct wusb_dev *wusb_dev;
441}; 485};
442#define to_usb_device(d) container_of(d, struct usb_device, dev) 486#define to_usb_device(d) container_of(d, struct usb_device, dev)
443 487
@@ -898,10 +942,11 @@ struct usbdrv_wrap {
898 * and should normally be the same as the module name. 942 * and should normally be the same as the module name.
899 * @probe: Called to see if the driver is willing to manage a particular 943 * @probe: Called to see if the driver is willing to manage a particular
900 * interface on a device. If it is, probe returns zero and uses 944 * interface on a device. If it is, probe returns zero and uses
901 * dev_set_drvdata() to associate driver-specific data with the 945 * usb_set_intfdata() to associate driver-specific data with the
902 * interface. It may also use usb_set_interface() to specify the 946 * interface. It may also use usb_set_interface() to specify the
903 * appropriate altsetting. If unwilling to manage the interface, 947 * appropriate altsetting. If unwilling to manage the interface,
904 * return a negative errno value. 948 * return -ENODEV, if genuine IO errors occured, an appropriate
949 * negative errno value.
905 * @disconnect: Called when the interface is no longer accessible, usually 950 * @disconnect: Called when the interface is no longer accessible, usually
906 * because its device has been (or is being) disconnected or the 951 * because its device has been (or is being) disconnected or the
907 * driver module is being unloaded. 952 * driver module is being unloaded.
@@ -916,10 +961,7 @@ struct usbdrv_wrap {
916 * @pre_reset: Called by usb_reset_composite_device() when the device 961 * @pre_reset: Called by usb_reset_composite_device() when the device
917 * is about to be reset. 962 * is about to be reset.
918 * @post_reset: Called by usb_reset_composite_device() after the device 963 * @post_reset: Called by usb_reset_composite_device() after the device
919 * has been reset, or in lieu of @resume following a reset-resume 964 * has been reset
920 * (i.e., the device is reset instead of being resumed, as might
921 * happen if power was lost). The second argument tells which is
922 * the reason.
923 * @id_table: USB drivers use ID table to support hotplugging. 965 * @id_table: USB drivers use ID table to support hotplugging.
924 * Export this with MODULE_DEVICE_TABLE(usb,...). This must be set 966 * Export this with MODULE_DEVICE_TABLE(usb,...). This must be set
925 * or your driver's probe function will never get called. 967 * or your driver's probe function will never get called.
@@ -1411,6 +1453,7 @@ extern int usb_submit_urb(struct urb *urb, gfp_t mem_flags);
1411extern int usb_unlink_urb(struct urb *urb); 1453extern int usb_unlink_urb(struct urb *urb);
1412extern void usb_kill_urb(struct urb *urb); 1454extern void usb_kill_urb(struct urb *urb);
1413extern void usb_kill_anchored_urbs(struct usb_anchor *anchor); 1455extern void usb_kill_anchored_urbs(struct usb_anchor *anchor);
1456extern void usb_unlink_anchored_urbs(struct usb_anchor *anchor);
1414extern void usb_anchor_urb(struct urb *urb, struct usb_anchor *anchor); 1457extern void usb_anchor_urb(struct urb *urb, struct usb_anchor *anchor);
1415extern void usb_unanchor_urb(struct urb *urb); 1458extern void usb_unanchor_urb(struct urb *urb);
1416extern int usb_wait_anchor_empty_timeout(struct usb_anchor *anchor, 1459extern int usb_wait_anchor_empty_timeout(struct usb_anchor *anchor,
@@ -1661,13 +1704,12 @@ extern void usb_unregister_notify(struct notifier_block *nb);
1661#define dbg(format, arg...) do {} while (0) 1704#define dbg(format, arg...) do {} while (0)
1662#endif 1705#endif
1663 1706
1664#define err(format, arg...) printk(KERN_ERR "%s: " format "\n" , \ 1707#define err(format, arg...) printk(KERN_ERR KBUILD_MODNAME ": " \
1665 __FILE__ , ## arg) 1708 format "\n" , ## arg)
1666#define info(format, arg...) printk(KERN_INFO "%s: " format "\n" , \ 1709#define info(format, arg...) printk(KERN_INFO KBUILD_MODNAME ": " \
1667 __FILE__ , ## arg) 1710 format "\n" , ## arg)
1668#define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n" , \ 1711#define warn(format, arg...) printk(KERN_WARNING KBUILD_MODNAME ": " \
1669 __FILE__ , ## arg) 1712 format "\n" , ## arg)
1670
1671 1713
1672#endif /* __KERNEL__ */ 1714#endif /* __KERNEL__ */
1673 1715
diff --git a/include/linux/usb/audio.h b/include/linux/usb/audio.h
index 2dfeef16b22..8cb025fef63 100644
--- a/include/linux/usb/audio.h
+++ b/include/linux/usb/audio.h
@@ -50,4 +50,4 @@ struct usb_ac_header_descriptor_##n { \
50 __u8 baInterfaceNr[n]; \ 50 __u8 baInterfaceNr[n]; \
51} __attribute__ ((packed)) 51} __attribute__ ((packed))
52 52
53#endif 53#endif /* __LINUX_USB_AUDIO_H */
diff --git a/include/linux/usb/cdc.h b/include/linux/usb/cdc.h
index 94ee4ecf056..71e52f2f6a3 100644
--- a/include/linux/usb/cdc.h
+++ b/include/linux/usb/cdc.h
@@ -6,6 +6,9 @@
6 * firmware based USB peripherals. 6 * firmware based USB peripherals.
7 */ 7 */
8 8
9#ifndef __LINUX_USB_CDC_H
10#define __LINUX_USB_CDC_H
11
9#define USB_CDC_SUBCLASS_ACM 0x02 12#define USB_CDC_SUBCLASS_ACM 0x02
10#define USB_CDC_SUBCLASS_ETHERNET 0x06 13#define USB_CDC_SUBCLASS_ETHERNET 0x06
11#define USB_CDC_SUBCLASS_WHCM 0x08 14#define USB_CDC_SUBCLASS_WHCM 0x08
@@ -221,3 +224,4 @@ struct usb_cdc_notification {
221 __le16 wLength; 224 __le16 wLength;
222} __attribute__ ((packed)); 225} __attribute__ ((packed));
223 226
227#endif /* __LINUX_USB_CDC_H */
diff --git a/include/linux/usb/ch9.h b/include/linux/usb/ch9.h
index 6169438ec5a..7e0d3084f76 100644
--- a/include/linux/usb/ch9.h
+++ b/include/linux/usb/ch9.h
@@ -66,8 +66,8 @@
66#define USB_RECIP_ENDPOINT 0x02 66#define USB_RECIP_ENDPOINT 0x02
67#define USB_RECIP_OTHER 0x03 67#define USB_RECIP_OTHER 0x03
68/* From Wireless USB 1.0 */ 68/* From Wireless USB 1.0 */
69#define USB_RECIP_PORT 0x04 69#define USB_RECIP_PORT 0x04
70#define USB_RECIP_RPIPE 0x05 70#define USB_RECIP_RPIPE 0x05
71 71
72/* 72/*
73 * Standard requests, for the bRequest field of a SETUP packet. 73 * Standard requests, for the bRequest field of a SETUP packet.
@@ -102,10 +102,16 @@
102#define USB_REQ_LOOPBACK_DATA_READ 0x16 102#define USB_REQ_LOOPBACK_DATA_READ 0x16
103#define USB_REQ_SET_INTERFACE_DS 0x17 103#define USB_REQ_SET_INTERFACE_DS 0x17
104 104
105/* The Link Power Mangement (LPM) ECN defines USB_REQ_TEST_AND_SET command,
106 * used by hubs to put ports into a new L1 suspend state, except that it
107 * forgot to define its number ...
108 */
109
105/* 110/*
106 * USB feature flags are written using USB_REQ_{CLEAR,SET}_FEATURE, and 111 * USB feature flags are written using USB_REQ_{CLEAR,SET}_FEATURE, and
107 * are read as a bit array returned by USB_REQ_GET_STATUS. (So there 112 * are read as a bit array returned by USB_REQ_GET_STATUS. (So there
108 * are at most sixteen features of each type.) 113 * are at most sixteen features of each type.) Hubs may also support a
114 * new USB_REQ_TEST_AND_SET_FEATURE to put ports into L1 suspend.
109 */ 115 */
110#define USB_DEVICE_SELF_POWERED 0 /* (read only) */ 116#define USB_DEVICE_SELF_POWERED 0 /* (read only) */
111#define USB_DEVICE_REMOTE_WAKEUP 1 /* dev may initiate wakeup */ 117#define USB_DEVICE_REMOTE_WAKEUP 1 /* dev may initiate wakeup */
@@ -180,6 +186,7 @@ struct usb_ctrlrequest {
180#define USB_DT_WIRELESS_ENDPOINT_COMP 0x11 186#define USB_DT_WIRELESS_ENDPOINT_COMP 0x11
181#define USB_DT_WIRE_ADAPTER 0x21 187#define USB_DT_WIRE_ADAPTER 0x21
182#define USB_DT_RPIPE 0x22 188#define USB_DT_RPIPE 0x22
189#define USB_DT_CS_RADIO_CONTROL 0x23
183 190
184/* Conventional codes for class-specific descriptors. The convention is 191/* Conventional codes for class-specific descriptors. The convention is
185 * defined in the USB "Common Class" Spec (3.11). Individual class specs 192 * defined in the USB "Common Class" Spec (3.11). Individual class specs
@@ -574,7 +581,9 @@ enum usb_device_state {
574 /* NOTE: there are actually four different SUSPENDED 581 /* NOTE: there are actually four different SUSPENDED
575 * states, returning to POWERED, DEFAULT, ADDRESS, or 582 * states, returning to POWERED, DEFAULT, ADDRESS, or
576 * CONFIGURED respectively when SOF tokens flow again. 583 * CONFIGURED respectively when SOF tokens flow again.
584 * At this level there's no difference between L1 and L2
585 * suspend states. (L2 being original USB 1.1 suspend.)
577 */ 586 */
578}; 587};
579 588
580#endif /* __LINUX_USB_CH9_H */ 589#endif /* __LINUX_USB_CH9_H */
diff --git a/include/linux/usb/g_printer.h b/include/linux/usb/g_printer.h
index 0c5ea1e3eb9..6178fde50f7 100644
--- a/include/linux/usb/g_printer.h
+++ b/include/linux/usb/g_printer.h
@@ -18,6 +18,8 @@
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20 20
21#ifndef __LINUX_USB_G_PRINTER_H
22#define __LINUX_USB_G_PRINTER_H
21 23
22#define PRINTER_NOT_ERROR 0x08 24#define PRINTER_NOT_ERROR 0x08
23#define PRINTER_SELECTED 0x10 25#define PRINTER_SELECTED 0x10
@@ -29,3 +31,5 @@
29 */ 31 */
30#define GADGET_GET_PRINTER_STATUS _IOR('g', 0x21, unsigned char) 32#define GADGET_GET_PRINTER_STATUS _IOR('g', 0x21, unsigned char)
31#define GADGET_SET_PRINTER_STATUS _IOWR('g', 0x22, unsigned char) 33#define GADGET_SET_PRINTER_STATUS _IOWR('g', 0x22, unsigned char)
34
35#endif /* __LINUX_USB_G_PRINTER_H */
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index f3295296b43..d8128f7102c 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -846,4 +846,4 @@ extern struct usb_ep *usb_ep_autoconfig(struct usb_gadget *,
846 846
847extern void usb_ep_autoconfig_reset(struct usb_gadget *) __devinit; 847extern void usb_ep_autoconfig_reset(struct usb_gadget *) __devinit;
848 848
849#endif /* __LINUX_USB_GADGET_H */ 849#endif /* __LINUX_USB_GADGET_H */
diff --git a/include/linux/usb/gadgetfs.h b/include/linux/usb/gadgetfs.h
index c291ab1af74..ea45f265ec0 100644
--- a/include/linux/usb/gadgetfs.h
+++ b/include/linux/usb/gadgetfs.h
@@ -1,11 +1,3 @@
1#ifndef __LINUX_USB_GADGETFS_H
2#define __LINUX_USB_GADGETFS_H
3
4#include <asm/types.h>
5#include <asm/ioctl.h>
6
7#include <linux/usb/ch9.h>
8
9/* 1/*
10 * Filesystem based user-mode API to USB Gadget controller hardware 2 * Filesystem based user-mode API to USB Gadget controller hardware
11 * 3 *
@@ -23,6 +15,14 @@
23 * then performing data transfers by reading or writing. 15 * then performing data transfers by reading or writing.
24 */ 16 */
25 17
18#ifndef __LINUX_USB_GADGETFS_H
19#define __LINUX_USB_GADGETFS_H
20
21#include <asm/types.h>
22#include <asm/ioctl.h>
23
24#include <linux/usb/ch9.h>
25
26/* 26/*
27 * Events are delivered on the ep0 file descriptor, when the user mode driver 27 * Events are delivered on the ep0 file descriptor, when the user mode driver
28 * reads from this file descriptor after writing the descriptors. Don't 28 * reads from this file descriptor after writing the descriptors. Don't
diff --git a/include/linux/usb/input.h b/include/linux/usb/input.h
index 716e0cc1604..0e010b220e8 100644
--- a/include/linux/usb/input.h
+++ b/include/linux/usb/input.h
@@ -1,6 +1,3 @@
1#ifndef __USB_INPUT_H
2#define __USB_INPUT_H
3
4/* 1/*
5 * Copyright (C) 2005 Dmitry Torokhov 2 * Copyright (C) 2005 Dmitry Torokhov
6 * 3 *
@@ -9,6 +6,9 @@
9 * the Free Software Foundation. 6 * the Free Software Foundation.
10 */ 7 */
11 8
9#ifndef __LINUX_USB_INPUT_H
10#define __LINUX_USB_INPUT_H
11
12#include <linux/usb.h> 12#include <linux/usb.h>
13#include <linux/input.h> 13#include <linux/input.h>
14#include <asm/byteorder.h> 14#include <asm/byteorder.h>
@@ -22,4 +22,4 @@ usb_to_input_id(const struct usb_device *dev, struct input_id *id)
22 id->version = le16_to_cpu(dev->descriptor.bcdDevice); 22 id->version = le16_to_cpu(dev->descriptor.bcdDevice);
23} 23}
24 24
25#endif 25#endif /* __LINUX_USB_INPUT_H */
diff --git a/include/linux/usb/iowarrior.h b/include/linux/usb/iowarrior.h
index de6f380e17a..4fd6513d564 100644
--- a/include/linux/usb/iowarrior.h
+++ b/include/linux/usb/iowarrior.h
@@ -1,5 +1,5 @@
1#ifndef _IOWARRIOR_H_ 1#ifndef __LINUX_USB_IOWARRIOR_H
2#define _IOWARRIOR_H_ 2#define __LINUX_USB_IOWARRIOR_H
3 3
4#define CODEMERCS_MAGIC_NUMBER 0xC0 /* like COde Mercenaries */ 4#define CODEMERCS_MAGIC_NUMBER 0xC0 /* like COde Mercenaries */
5 5
@@ -39,4 +39,4 @@ struct iowarrior_info {
39*/ 39*/
40#define IOW_GETINFO _IOR(CODEMERCS_MAGIC_NUMBER, 3, struct iowarrior_info) 40#define IOW_GETINFO _IOR(CODEMERCS_MAGIC_NUMBER, 3, struct iowarrior_info)
41 41
42#endif /* _IOWARRIOR_H_ */ 42#endif /* __LINUX_USB_IOWARRIOR_H */
diff --git a/include/linux/usb/isp116x.h b/include/linux/usb/isp116x.h
index 67d2826f34f..96ca114e88d 100644
--- a/include/linux/usb/isp116x.h
+++ b/include/linux/usb/isp116x.h
@@ -1,9 +1,11 @@
1
2/* 1/*
3 * Board initialization code should put one of these into dev->platform_data 2 * Board initialization code should put one of these into dev->platform_data
4 * and place the isp116x onto platform_bus. 3 * and place the isp116x onto platform_bus.
5 */ 4 */
6 5
6#ifndef __LINUX_USB_ISP116X_H
7#define __LINUX_USB_ISP116X_H
8
7struct isp116x_platform_data { 9struct isp116x_platform_data {
8 /* Enable internal resistors on downstream ports */ 10 /* Enable internal resistors on downstream ports */
9 unsigned sel15Kres:1; 11 unsigned sel15Kres:1;
@@ -27,3 +29,5 @@ struct isp116x_platform_data {
27 */ 29 */
28 void (*delay) (struct device *dev, int delay); 30 void (*delay) (struct device *dev, int delay);
29}; 31};
32
33#endif /* __LINUX_USB_ISP116X_H */
diff --git a/include/linux/usb/midi.h b/include/linux/usb/midi.h
index 80624c56292..1d104086566 100644
--- a/include/linux/usb/midi.h
+++ b/include/linux/usb/midi.h
@@ -109,4 +109,4 @@ struct usb_ms_endpoint_descriptor_##n { \
109 __u8 baAssocJackID[n]; \ 109 __u8 baAssocJackID[n]; \
110} __attribute__ ((packed)) 110} __attribute__ ((packed))
111 111
112#endif 112#endif /* __LINUX_USB_MIDI_H */
diff --git a/include/linux/usb/net2280.h b/include/linux/usb/net2280.h
index ec897cb844a..96ca549a778 100644
--- a/include/linux/usb/net2280.h
+++ b/include/linux/usb/net2280.h
@@ -1,11 +1,7 @@
1/* 1/*
2 * NetChip 2280 high/full speed USB device controller. 2 * NetChip 2280 high/full speed USB device controller.
3 * Unlike many such controllers, this one talks PCI. 3 * Unlike many such controllers, this one talks PCI.
4 */ 4 *
5#ifndef __LINUX_USB_NET2280_H
6#define __LINUX_USB_NET2280_H
7
8/*
9 * Copyright (C) 2002 NetChip Technology, Inc. (http://www.netchip.com) 5 * Copyright (C) 2002 NetChip Technology, Inc. (http://www.netchip.com)
10 * Copyright (C) 2003 David Brownell 6 * Copyright (C) 2003 David Brownell
11 * 7 *
@@ -24,6 +20,9 @@
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 */ 21 */
26 22
23#ifndef __LINUX_USB_NET2280_H
24#define __LINUX_USB_NET2280_H
25
27/*-------------------------------------------------------------------------*/ 26/*-------------------------------------------------------------------------*/
28 27
29/* NET2280 MEMORY MAPPED REGISTERS 28/* NET2280 MEMORY MAPPED REGISTERS
diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h
index e007074ebe4..1db25d152ad 100644
--- a/include/linux/usb/otg.h
+++ b/include/linux/usb/otg.h
@@ -1,11 +1,13 @@
1/* USB OTG (On The Go) defines */ 1/* USB OTG (On The Go) defines */
2
3/* 2/*
3 *
4 * These APIs may be used between USB controllers. USB device drivers 4 * These APIs may be used between USB controllers. USB device drivers
5 * (for either host or peripheral roles) don't use these calls; they 5 * (for either host or peripheral roles) don't use these calls; they
6 * continue to use just usb_device and usb_gadget. 6 * continue to use just usb_device and usb_gadget.
7 */ 7 */
8 8
9#ifndef __LINUX_USB_OTG_H
10#define __LINUX_USB_OTG_H
9 11
10/* OTG defines lots of enumeration states before device reset */ 12/* OTG defines lots of enumeration states before device reset */
11enum usb_otg_state { 13enum usb_otg_state {
@@ -129,3 +131,5 @@ otg_start_srp(struct otg_transceiver *otg)
129 131
130/* for OTG controller drivers (and maybe other stuff) */ 132/* for OTG controller drivers (and maybe other stuff) */
131extern int usb_bus_start_enum(struct usb_bus *bus, unsigned port_num); 133extern int usb_bus_start_enum(struct usb_bus *bus, unsigned port_num);
134
135#endif /* __LINUX_USB_OTG_H */
diff --git a/include/linux/usb/quirks.h b/include/linux/usb/quirks.h
index 1f999ec8d08..7f6c603db65 100644
--- a/include/linux/usb/quirks.h
+++ b/include/linux/usb/quirks.h
@@ -4,6 +4,9 @@
4 * belong here. 4 * belong here.
5 */ 5 */
6 6
7#ifndef __LINUX_USB_QUIRKS_H
8#define __LINUX_USB_QUIRKS_H
9
7/* string descriptors must not be fetched using a 255-byte read */ 10/* string descriptors must not be fetched using a 255-byte read */
8#define USB_QUIRK_STRING_FETCH_255 0x00000001 11#define USB_QUIRK_STRING_FETCH_255 0x00000001
9 12
@@ -12,3 +15,5 @@
12 15
13/* device can't handle Set-Interface requests */ 16/* device can't handle Set-Interface requests */
14#define USB_QUIRK_NO_SET_INTF 0x00000004 17#define USB_QUIRK_NO_SET_INTF 0x00000004
18
19#endif /* __LINUX_USB_QUIRKS_H */
diff --git a/include/linux/usb/rndis_host.h b/include/linux/usb/rndis_host.h
index edc1d4a0e27..29d6458ecb8 100644
--- a/include/linux/usb/rndis_host.h
+++ b/include/linux/usb/rndis_host.h
@@ -17,10 +17,8 @@
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */ 18 */
19 19
20 20#ifndef __LINUX_USB_RNDIS_HOST_H
21#ifndef __RNDIS_HOST_H 21#define __LINUX_USB_RNDIS_HOST_H
22#define __RNDIS_HOST_H
23
24 22
25/* 23/*
26 * CONTROL uses CDC "encapsulated commands" with funky notifications. 24 * CONTROL uses CDC "encapsulated commands" with funky notifications.
@@ -270,5 +268,4 @@ extern int rndis_rx_fixup(struct usbnet *dev, struct sk_buff *skb);
270extern struct sk_buff * 268extern struct sk_buff *
271rndis_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags); 269rndis_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags);
272 270
273#endif /* __RNDIS_HOST_H */ 271#endif /* __LINUX_USB_RNDIS_HOST_H */
274
diff --git a/include/linux/usb/serial.h b/include/linux/usb/serial.h
index 21b4a1c6f58..8f891cbaf9a 100644
--- a/include/linux/usb/serial.h
+++ b/include/linux/usb/serial.h
@@ -10,7 +10,6 @@
10 * 10 *
11 */ 11 */
12 12
13
14#ifndef __LINUX_USB_SERIAL_H 13#ifndef __LINUX_USB_SERIAL_H
15#define __LINUX_USB_SERIAL_H 14#define __LINUX_USB_SERIAL_H
16 15
@@ -146,8 +145,6 @@ struct usb_serial {
146}; 145};
147#define to_usb_serial(d) container_of(d, struct usb_serial, kref) 146#define to_usb_serial(d) container_of(d, struct usb_serial, kref)
148 147
149#define NUM_DONT_CARE 99
150
151/* get and set the serial private data pointer helper functions */ 148/* get and set the serial private data pointer helper functions */
152static inline void *usb_get_serial_data(struct usb_serial *serial) 149static inline void *usb_get_serial_data(struct usb_serial *serial)
153{ 150{
@@ -165,18 +162,6 @@ static inline void usb_set_serial_data(struct usb_serial *serial, void *data)
165 * used in the syslog messages when a device is inserted or removed. 162 * used in the syslog messages when a device is inserted or removed.
166 * @id_table: pointer to a list of usb_device_id structures that define all 163 * @id_table: pointer to a list of usb_device_id structures that define all
167 * of the devices this structure can support. 164 * of the devices this structure can support.
168 * @num_interrupt_in: If a device doesn't have this many interrupt-in
169 * endpoints, it won't be sent to the driver's attach() method.
170 * (But it might still be sent to the probe() method.)
171 * @num_interrupt_out: If a device doesn't have this many interrupt-out
172 * endpoints, it won't be sent to the driver's attach() method.
173 * (But it might still be sent to the probe() method.)
174 * @num_bulk_in: If a device doesn't have this many bulk-in
175 * endpoints, it won't be sent to the driver's attach() method.
176 * (But it might still be sent to the probe() method.)
177 * @num_bulk_out: If a device doesn't have this many bulk-out
178 * endpoints, it won't be sent to the driver's attach() method.
179 * (But it might still be sent to the probe() method.)
180 * @num_ports: the number of different ports this device will have. 165 * @num_ports: the number of different ports this device will have.
181 * @calc_num_ports: pointer to a function to determine how many ports this 166 * @calc_num_ports: pointer to a function to determine how many ports this
182 * device has dynamically. It will be called after the probe() 167 * device has dynamically. It will be called after the probe()
@@ -212,10 +197,6 @@ static inline void usb_set_serial_data(struct usb_serial *serial, void *data)
212struct usb_serial_driver { 197struct usb_serial_driver {
213 const char *description; 198 const char *description;
214 const struct usb_device_id *id_table; 199 const struct usb_device_id *id_table;
215 char num_interrupt_in;
216 char num_interrupt_out;
217 char num_bulk_in;
218 char num_bulk_out;
219 char num_ports; 200 char num_ports;
220 201
221 struct list_head driver_list; 202 struct list_head driver_list;
@@ -340,5 +321,5 @@ static inline void usb_serial_debug_data(int debug,
340 321
341 322
342 323
343#endif /* ifdef __LINUX_USB_SERIAL_H */ 324#endif /* __LINUX_USB_SERIAL_H */
344 325
diff --git a/include/linux/usb/sl811.h b/include/linux/usb/sl811.h
index 877373da410..3afe4d16fce 100644
--- a/include/linux/usb/sl811.h
+++ b/include/linux/usb/sl811.h
@@ -1,9 +1,11 @@
1
2/* 1/*
3 * board initialization should put one of these into dev->platform_data 2 * board initialization should put one of these into dev->platform_data
4 * and place the sl811hs onto platform_bus named "sl811-hcd". 3 * and place the sl811hs onto platform_bus named "sl811-hcd".
5 */ 4 */
6 5
6#ifndef __LINUX_USB_SL811_H
7#define __LINUX_USB_SL811_H
8
7struct sl811_platform_data { 9struct sl811_platform_data {
8 unsigned can_wakeup:1; 10 unsigned can_wakeup:1;
9 11
@@ -24,3 +26,4 @@ struct sl811_platform_data {
24 /* void (*clock_enable)(struct device *dev, int is_on); */ 26 /* void (*clock_enable)(struct device *dev, int is_on); */
25}; 27};
26 28
29#endif /* __LINUX_USB_SL811_H */
diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h
index e0501da3dd1..ba09fe88add 100644
--- a/include/linux/usb/usbnet.h
+++ b/include/linux/usb/usbnet.h
@@ -19,10 +19,8 @@
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */ 20 */
21 21
22 22#ifndef __LINUX_USB_USBNET_H
23#ifndef __USBNET_H 23#define __LINUX_USB_USBNET_H
24#define __USBNET_H
25
26 24
27/* interface from usbnet core to each USB networking link we handle */ 25/* interface from usbnet core to each USB networking link we handle */
28struct usbnet { 26struct usbnet {
@@ -211,4 +209,4 @@ extern int usbnet_nway_reset(struct net_device *net);
211 printk(KERN_INFO "%s: " fmt "\n" , (usbnet)->net->name , ## arg); \ 209 printk(KERN_INFO "%s: " fmt "\n" , (usbnet)->net->name , ## arg); \
212 210
213 211
214#endif /* __USBNET_H */ 212#endif /* __LINUX_USB_USBNET_H */
diff --git a/include/linux/usb_usual.h b/include/linux/usb_usual.h
index 0a40dfa44c9..d9a3bbe38e6 100644
--- a/include/linux/usb_usual.h
+++ b/include/linux/usb_usual.h
@@ -85,6 +85,7 @@ enum { US_DO_ALL_FLAGS };
85#define US_SC_LOCKABLE 0x07 /* Password-protected */ 85#define US_SC_LOCKABLE 0x07 /* Password-protected */
86 86
87#define US_SC_ISD200 0xf0 /* ISD200 ATA */ 87#define US_SC_ISD200 0xf0 /* ISD200 ATA */
88#define US_SC_CYP_ATACB 0xf1 /* Cypress ATACB */
88#define US_SC_DEVICE 0xff /* Use device's value */ 89#define US_SC_DEVICE 0xff /* Use device's value */
89 90
90/* Protocols */ 91/* Protocols */
diff --git a/include/linux/usbdevice_fs.h b/include/linux/usbdevice_fs.h
index 17cb108b7db..3118ede2c67 100644
--- a/include/linux/usbdevice_fs.h
+++ b/include/linux/usbdevice_fs.h
@@ -77,8 +77,11 @@ struct usbdevfs_connectinfo {
77 unsigned char slow; 77 unsigned char slow;
78}; 78};
79 79
80#define USBDEVFS_URB_SHORT_NOT_OK 1 80#define USBDEVFS_URB_SHORT_NOT_OK 0x01
81#define USBDEVFS_URB_ISO_ASAP 2 81#define USBDEVFS_URB_ISO_ASAP 0x02
82#define USBDEVFS_URB_NO_FSBR 0x20
83#define USBDEVFS_URB_ZERO_PACKET 0x40
84#define USBDEVFS_URB_NO_INTERRUPT 0x80
82 85
83#define USBDEVFS_URB_TYPE_ISO 0 86#define USBDEVFS_URB_TYPE_ISO 0
84#define USBDEVFS_URB_TYPE_INTERRUPT 1 87#define USBDEVFS_URB_TYPE_INTERRUPT 1
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 58a94947d65..64ec4b8a51b 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1889,6 +1889,13 @@ sub process {
1889 WARN("kfree(NULL) is safe this check is probabally not required\n" . $hereprev); 1889 WARN("kfree(NULL) is safe this check is probabally not required\n" . $hereprev);
1890 } 1890 }
1891 } 1891 }
1892# check for needless usb_free_urb() checks
1893 if ($prevline =~ /\bif\s*\(([^\)]*)\)/) {
1894 my $expr = $1;
1895 if ($line =~ /\busb_free_urb\(\Q$expr\E\);/) {
1896 WARN("usb_free_urb(NULL) is safe this check is probabally not required\n" . $hereprev);
1897 }
1898 }
1892 1899
1893# warn about #ifdefs in C files 1900# warn about #ifdefs in C files
1894# if ($line =~ /^.#\s*if(|n)def/ && ($realfile =~ /\.c$/)) { 1901# if ($line =~ /^.#\s*if(|n)def/ && ($realfile =~ /\.c$/)) {