diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-17 18:43:52 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-17 18:43:52 -0400 |
| commit | 0cfd81031a26717fe14380d18275f8e217571615 (patch) | |
| tree | 78a84e4cb97e7f45eb77dc0fbd8857a5dd717869 | |
| parent | f7ea4a4ba84f382e8eb143e435551de0feee5b4b (diff) | |
| parent | 802f389a2cc6e2771b8de915ac241456d41eb79e (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: (94 commits)
USB: remove err() macro from more usb drivers
USB: remove err() macro from usb misc drivers
USB: remove err() macro from usb core code
USB: remove err() macro from usb class drivers
USB: remove use of err() in drivers/usb/serial
USB: remove info() macro from usb mtd drivers
USB: remove info() macro from usb input drivers
USB: remove info() macro from usb network drivers
USB: remove info() macro from remaining usb drivers
USB: remove info() macro from usb/misc drivers
USB: remove info() macro from usb/serial drivers
USB: remove warn macro from HID core
USB: remove warn() macro from usb drivers
USB: remove warn() macro from usb net drivers
USB: remove warn() macro from usb media drivers
USB: remove warn() macro from usb input drivers
usb/fsl_qe_udc: clear data toggle on clear halt request
usb/fsl_qe_udc: fix response to get status request
fsl_usb2_udc: Fix oops on probe failure.
fsl_usb2_udc: Add a wmb before priming endpoint.
...
171 files changed, 8474 insertions, 1533 deletions
diff --git a/Documentation/ABI/stable/sysfs-driver-usb-usbtmc b/Documentation/ABI/stable/sysfs-driver-usb-usbtmc new file mode 100644 index 000000000000..9a75fb22187d --- /dev/null +++ b/Documentation/ABI/stable/sysfs-driver-usb-usbtmc | |||
| @@ -0,0 +1,62 @@ | |||
| 1 | What: /sys/bus/usb/drivers/usbtmc/devices/*/interface_capabilities | ||
| 2 | What: /sys/bus/usb/drivers/usbtmc/devices/*/device_capabilities | ||
| 3 | Date: August 2008 | ||
| 4 | Contact: Greg Kroah-Hartman <gregkh@suse.de> | ||
| 5 | Description: | ||
| 6 | These files show the various USB TMC capabilities as described | ||
| 7 | by the device itself. The full description of the bitfields | ||
| 8 | can be found in the USB TMC documents from the USB-IF entitled | ||
| 9 | "Universal Serial Bus Test and Measurement Class Specification | ||
| 10 | (USBTMC) Revision 1.0" section 4.2.1.8. | ||
| 11 | |||
| 12 | The files are read only. | ||
| 13 | |||
| 14 | |||
| 15 | What: /sys/bus/usb/drivers/usbtmc/devices/*/usb488_interface_capabilities | ||
| 16 | What: /sys/bus/usb/drivers/usbtmc/devices/*/usb488_device_capabilities | ||
| 17 | Date: August 2008 | ||
| 18 | Contact: Greg Kroah-Hartman <gregkh@suse.de> | ||
| 19 | Description: | ||
| 20 | These files show the various USB TMC capabilities as described | ||
| 21 | by the device itself. The full description of the bitfields | ||
| 22 | can be found in the USB TMC documents from the USB-IF entitled | ||
| 23 | "Universal Serial Bus Test and Measurement Class, Subclass | ||
| 24 | USB488 Specification (USBTMC-USB488) Revision 1.0" section | ||
| 25 | 4.2.2. | ||
| 26 | |||
| 27 | The files are read only. | ||
| 28 | |||
| 29 | |||
| 30 | What: /sys/bus/usb/drivers/usbtmc/devices/*/TermChar | ||
| 31 | Date: August 2008 | ||
| 32 | Contact: Greg Kroah-Hartman <gregkh@suse.de> | ||
| 33 | Description: | ||
| 34 | This file is the TermChar value to be sent to the USB TMC | ||
| 35 | device as described by the document, "Universal Serial Bus Test | ||
| 36 | and Measurement Class Specification | ||
| 37 | (USBTMC) Revision 1.0" as published by the USB-IF. | ||
| 38 | |||
| 39 | Note that the TermCharEnabled file determines if this value is | ||
| 40 | sent to the device or not. | ||
| 41 | |||
| 42 | |||
| 43 | What: /sys/bus/usb/drivers/usbtmc/devices/*/TermCharEnabled | ||
| 44 | Date: August 2008 | ||
| 45 | Contact: Greg Kroah-Hartman <gregkh@suse.de> | ||
| 46 | Description: | ||
| 47 | This file determines if the TermChar is to be sent to the | ||
| 48 | device on every transaction or not. For more details about | ||
| 49 | this, please see the document, "Universal Serial Bus Test and | ||
| 50 | Measurement Class Specification (USBTMC) Revision 1.0" as | ||
| 51 | published by the USB-IF. | ||
| 52 | |||
| 53 | |||
| 54 | What: /sys/bus/usb/drivers/usbtmc/devices/*/auto_abort | ||
| 55 | Date: August 2008 | ||
| 56 | Contact: Greg Kroah-Hartman <gregkh@suse.de> | ||
| 57 | Description: | ||
| 58 | This file determines if the the transaction of the USB TMC | ||
| 59 | device is to be automatically aborted if there is any error. | ||
| 60 | For more details about this, please see the document, | ||
| 61 | "Universal Serial Bus Test and Measurement Class Specification | ||
| 62 | (USBTMC) Revision 1.0" as published by the USB-IF. | ||
diff --git a/Documentation/ABI/testing/sysfs-bus-usb b/Documentation/ABI/testing/sysfs-bus-usb index 11a3c1682cec..df6c8a0159f1 100644 --- a/Documentation/ABI/testing/sysfs-bus-usb +++ b/Documentation/ABI/testing/sysfs-bus-usb | |||
| @@ -85,3 +85,19 @@ Description: | |||
| 85 | Users: | 85 | Users: |
| 86 | PowerTOP <power@bughost.org> | 86 | PowerTOP <power@bughost.org> |
| 87 | http://www.lesswatts.org/projects/powertop/ | 87 | http://www.lesswatts.org/projects/powertop/ |
| 88 | |||
| 89 | What: /sys/bus/usb/device/<busnum>-<devnum>...:<config num>-<interface num>/supports_autosuspend | ||
| 90 | Date: January 2008 | ||
| 91 | KernelVersion: 2.6.27 | ||
| 92 | Contact: Sarah Sharp <sarah.a.sharp@intel.com> | ||
| 93 | Description: | ||
| 94 | When read, this file returns 1 if the interface driver | ||
| 95 | for this interface supports autosuspend. It also | ||
| 96 | returns 1 if no driver has claimed this interface, as an | ||
| 97 | unclaimed interface will not stop the device from being | ||
| 98 | autosuspended if all other interface drivers are idle. | ||
| 99 | The file returns 0 if autosuspend support has not been | ||
| 100 | added to the driver. | ||
| 101 | Users: | ||
| 102 | USB PM tool | ||
| 103 | git://git.moblin.org/users/sarah/usb-pm-tool/ | ||
diff --git a/Documentation/ABI/testing/sysfs-bus-usb-devices-usbsevseg b/Documentation/ABI/testing/sysfs-bus-usb-devices-usbsevseg new file mode 100644 index 000000000000..cb830df8777c --- /dev/null +++ b/Documentation/ABI/testing/sysfs-bus-usb-devices-usbsevseg | |||
| @@ -0,0 +1,43 @@ | |||
| 1 | Where: /sys/bus/usb/.../powered | ||
| 2 | Date: August 2008 | ||
| 3 | Kernel Version: 2.6.26 | ||
| 4 | Contact: Harrison Metzger <harrisonmetz@gmail.com> | ||
| 5 | Description: Controls whether the device's display will powered. | ||
| 6 | A value of 0 is off and a non-zero value is on. | ||
| 7 | |||
| 8 | Where: /sys/bus/usb/.../mode_msb | ||
| 9 | Where: /sys/bus/usb/.../mode_lsb | ||
| 10 | Date: August 2008 | ||
| 11 | Kernel Version: 2.6.26 | ||
| 12 | Contact: Harrison Metzger <harrisonmetz@gmail.com> | ||
| 13 | Description: Controls the devices display mode. | ||
| 14 | For a 6 character display the values are | ||
| 15 | MSB 0x06; LSB 0x3F, and | ||
| 16 | for an 8 character display the values are | ||
| 17 | MSB 0x08; LSB 0xFF. | ||
| 18 | |||
| 19 | Where: /sys/bus/usb/.../textmode | ||
| 20 | Date: August 2008 | ||
| 21 | Kernel Version: 2.6.26 | ||
| 22 | Contact: Harrison Metzger <harrisonmetz@gmail.com> | ||
| 23 | Description: Controls the way the device interprets its text buffer. | ||
| 24 | raw: each character controls its segment manually | ||
| 25 | hex: each character is between 0-15 | ||
| 26 | ascii: each character is between '0'-'9' and 'A'-'F'. | ||
| 27 | |||
| 28 | Where: /sys/bus/usb/.../text | ||
| 29 | Date: August 2008 | ||
| 30 | Kernel Version: 2.6.26 | ||
| 31 | Contact: Harrison Metzger <harrisonmetz@gmail.com> | ||
| 32 | Description: The text (or data) for the device to display | ||
| 33 | |||
| 34 | Where: /sys/bus/usb/.../decimals | ||
| 35 | Date: August 2008 | ||
| 36 | Kernel Version: 2.6.26 | ||
| 37 | Contact: Harrison Metzger <harrisonmetz@gmail.com> | ||
| 38 | Description: Controls the decimal places on the device. | ||
| 39 | To set the nth decimal place, give this field | ||
| 40 | the value of 10 ** n. Assume this field has | ||
| 41 | the value k and has 1 or more decimal places set, | ||
| 42 | to set the mth place (where m is not already set), | ||
| 43 | change this fields value to k + 10 ** m. \ No newline at end of file | ||
diff --git a/Documentation/DocBook/gadget.tmpl b/Documentation/DocBook/gadget.tmpl index ea3bc9565e6a..6ef2f0073e5a 100644 --- a/Documentation/DocBook/gadget.tmpl +++ b/Documentation/DocBook/gadget.tmpl | |||
| @@ -557,6 +557,9 @@ Near-term plans include converting all of them, except for "gadgetfs". | |||
| 557 | </para> | 557 | </para> |
| 558 | 558 | ||
| 559 | !Edrivers/usb/gadget/f_acm.c | 559 | !Edrivers/usb/gadget/f_acm.c |
| 560 | !Edrivers/usb/gadget/f_ecm.c | ||
| 561 | !Edrivers/usb/gadget/f_subset.c | ||
| 562 | !Edrivers/usb/gadget/f_obex.c | ||
| 560 | !Edrivers/usb/gadget/f_serial.c | 563 | !Edrivers/usb/gadget/f_serial.c |
| 561 | 564 | ||
| 562 | </sect1> | 565 | </sect1> |
diff --git a/Documentation/devices.txt b/Documentation/devices.txt index 05c80645e4ee..2be08240ee80 100644 --- a/Documentation/devices.txt +++ b/Documentation/devices.txt | |||
| @@ -2571,6 +2571,9 @@ Your cooperation is appreciated. | |||
| 2571 | 160 = /dev/usb/legousbtower0 1st USB Legotower device | 2571 | 160 = /dev/usb/legousbtower0 1st USB Legotower device |
| 2572 | ... | 2572 | ... |
| 2573 | 175 = /dev/usb/legousbtower15 16th USB Legotower device | 2573 | 175 = /dev/usb/legousbtower15 16th USB Legotower device |
| 2574 | 176 = /dev/usb/usbtmc1 First USB TMC device | ||
| 2575 | ... | ||
| 2576 | 192 = /dev/usb/usbtmc16 16th USB TMC device | ||
| 2574 | 240 = /dev/usb/dabusb0 First daubusb device | 2577 | 240 = /dev/usb/dabusb0 First daubusb device |
| 2575 | ... | 2578 | ... |
| 2576 | 243 = /dev/usb/dabusb3 Fourth dabusb device | 2579 | 243 = /dev/usb/dabusb3 Fourth dabusb device |
diff --git a/Documentation/ioctl-number.txt b/Documentation/ioctl-number.txt index 1c6b545635a2..b880ce5dbd33 100644 --- a/Documentation/ioctl-number.txt +++ b/Documentation/ioctl-number.txt | |||
| @@ -92,6 +92,7 @@ Code Seq# Include File Comments | |||
| 92 | 'J' 00-1F drivers/scsi/gdth_ioctl.h | 92 | 'J' 00-1F drivers/scsi/gdth_ioctl.h |
| 93 | 'K' all linux/kd.h | 93 | 'K' all linux/kd.h |
| 94 | 'L' 00-1F linux/loop.h | 94 | 'L' 00-1F linux/loop.h |
| 95 | 'L' 20-2F driver/usb/misc/vstusb.h | ||
| 95 | 'L' E0-FF linux/ppdd.h encrypted disk device driver | 96 | 'L' E0-FF linux/ppdd.h encrypted disk device driver |
| 96 | <http://linux01.gwdg.de/~alatham/ppdd.html> | 97 | <http://linux01.gwdg.de/~alatham/ppdd.html> |
| 97 | 'M' all linux/soundcard.h | 98 | 'M' all linux/soundcard.h |
| @@ -110,6 +111,8 @@ Code Seq# Include File Comments | |||
| 110 | 'W' 00-1F linux/wanrouter.h conflict! | 111 | 'W' 00-1F linux/wanrouter.h conflict! |
| 111 | 'X' all linux/xfs_fs.h | 112 | 'X' all linux/xfs_fs.h |
| 112 | 'Y' all linux/cyclades.h | 113 | 'Y' all linux/cyclades.h |
| 114 | '[' 00-07 linux/usb/usbtmc.h USB Test and Measurement Devices | ||
| 115 | <mailto:gregkh@suse.de> | ||
| 113 | 'a' all ATM on linux | 116 | 'a' all ATM on linux |
| 114 | <http://lrcwww.epfl.ch/linux-atm/magic.html> | 117 | <http://lrcwww.epfl.ch/linux-atm/magic.html> |
| 115 | 'b' 00-FF bit3 vme host bridge | 118 | 'b' 00-FF bit3 vme host bridge |
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index dd28a0d56981..d4f4875fc7c6 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt | |||
| @@ -2253,6 +2253,25 @@ and is between 256 and 4096 characters. It is defined in the file | |||
| 2253 | autosuspended. Devices for which the delay is set | 2253 | autosuspended. Devices for which the delay is set |
| 2254 | to a negative value won't be autosuspended at all. | 2254 | to a negative value won't be autosuspended at all. |
| 2255 | 2255 | ||
| 2256 | usbcore.usbfs_snoop= | ||
| 2257 | [USB] Set to log all usbfs traffic (default 0 = off). | ||
| 2258 | |||
| 2259 | usbcore.blinkenlights= | ||
| 2260 | [USB] Set to cycle leds on hubs (default 0 = off). | ||
| 2261 | |||
| 2262 | usbcore.old_scheme_first= | ||
| 2263 | [USB] Start with the old device initialization | ||
| 2264 | scheme (default 0 = off). | ||
| 2265 | |||
| 2266 | usbcore.use_both_schemes= | ||
| 2267 | [USB] Try the other device initialization scheme | ||
| 2268 | if the first one fails (default 1 = enabled). | ||
| 2269 | |||
| 2270 | usbcore.initial_descriptor_timeout= | ||
| 2271 | [USB] Specifies timeout for the initial 64-byte | ||
| 2272 | USB_REQ_GET_DESCRIPTOR request in milliseconds | ||
| 2273 | (default 5000 = 5.0 seconds). | ||
| 2274 | |||
| 2256 | usbhid.mousepoll= | 2275 | usbhid.mousepoll= |
| 2257 | [USBHID] The interval which mice are to be polled at. | 2276 | [USBHID] The interval which mice are to be polled at. |
| 2258 | 2277 | ||
diff --git a/Documentation/usb/anchors.txt b/Documentation/usb/anchors.txt index 5e6b64c20d25..6f24f566955a 100644 --- a/Documentation/usb/anchors.txt +++ b/Documentation/usb/anchors.txt | |||
| @@ -52,6 +52,11 @@ Therefore no guarantee is made that the URBs have been unlinked when | |||
| 52 | the call returns. They may be unlinked later but will be unlinked in | 52 | the call returns. They may be unlinked later but will be unlinked in |
| 53 | finite time. | 53 | finite time. |
| 54 | 54 | ||
| 55 | usb_scuttle_anchored_urbs() | ||
| 56 | --------------------------- | ||
| 57 | |||
| 58 | All URBs of an anchor are unanchored en masse. | ||
| 59 | |||
| 55 | usb_wait_anchor_empty_timeout() | 60 | usb_wait_anchor_empty_timeout() |
| 56 | ------------------------------- | 61 | ------------------------------- |
| 57 | 62 | ||
| @@ -59,4 +64,16 @@ This function waits for all URBs associated with an anchor to finish | |||
| 59 | or a timeout, whichever comes first. Its return value will tell you | 64 | or a timeout, whichever comes first. Its return value will tell you |
| 60 | whether the timeout was reached. | 65 | whether the timeout was reached. |
| 61 | 66 | ||
| 67 | usb_anchor_empty() | ||
| 68 | ------------------ | ||
| 69 | |||
| 70 | Returns true if no URBs are associated with an anchor. Locking | ||
| 71 | is the caller's responsibility. | ||
| 72 | |||
| 73 | usb_get_from_anchor() | ||
| 74 | --------------------- | ||
| 62 | 75 | ||
| 76 | Returns the oldest anchored URB of an anchor. The URB is unanchored | ||
| 77 | and returned with a reference. As you may mix URBs to several | ||
| 78 | destinations in one anchor you have no guarantee the chronologically | ||
| 79 | first submitted URB is returned. \ No newline at end of file | ||
diff --git a/Documentation/usb/misc_usbsevseg.txt b/Documentation/usb/misc_usbsevseg.txt new file mode 100644 index 000000000000..0f6be4f9930b --- /dev/null +++ b/Documentation/usb/misc_usbsevseg.txt | |||
| @@ -0,0 +1,46 @@ | |||
| 1 | USB 7-Segment Numeric Display | ||
| 2 | Manufactured by Delcom Engineering | ||
| 3 | |||
| 4 | Device Information | ||
| 5 | ------------------ | ||
| 6 | USB VENDOR_ID 0x0fc5 | ||
| 7 | USB PRODUCT_ID 0x1227 | ||
| 8 | Both the 6 character and 8 character displays have PRODUCT_ID, | ||
| 9 | and according to Delcom Engineering no queryable information | ||
| 10 | can be obtained from the device to tell them apart. | ||
| 11 | |||
| 12 | Device Modes | ||
| 13 | ------------ | ||
| 14 | By default, the driver assumes the display is only 6 characters | ||
| 15 | The mode for 6 characters is: | ||
| 16 | MSB 0x06; LSB 0x3f | ||
| 17 | For the 8 character display: | ||
| 18 | MSB 0x08; LSB 0xff | ||
| 19 | The device can accept "text" either in raw, hex, or ascii textmode. | ||
| 20 | raw controls each segment manually, | ||
| 21 | hex expects a value between 0-15 per character, | ||
| 22 | ascii expects a value between '0'-'9' and 'A'-'F'. | ||
| 23 | The default is ascii. | ||
| 24 | |||
| 25 | Device Operation | ||
| 26 | ---------------- | ||
| 27 | 1. Turn on the device: | ||
| 28 | echo 1 > /sys/bus/usb/.../powered | ||
| 29 | 2. Set the device's mode: | ||
| 30 | echo $mode_msb > /sys/bus/usb/.../mode_msb | ||
| 31 | echo $mode_lsb > /sys/bus/usb/.../mode_lsb | ||
| 32 | 3. Set the textmode: | ||
| 33 | echo $textmode > /sys/bus/usb/.../textmode | ||
| 34 | 4. set the text (for example): | ||
| 35 | echo "123ABC" > /sys/bus/usb/.../text (ascii) | ||
| 36 | echo "A1B2" > /sys/bus/usb/.../text (ascii) | ||
| 37 | echo -ne "\x01\x02\x03" > /sys/bus/usb/.../text (hex) | ||
| 38 | 5. Set the decimal places. | ||
| 39 | The device has either 6 or 8 decimal points. | ||
| 40 | to set the nth decimal place calculate 10 ** n | ||
| 41 | and echo it in to /sys/bus/usb/.../decimals | ||
| 42 | To set multiple decimals points sum up each power. | ||
| 43 | For example, to set the 0th and 3rd decimal place | ||
| 44 | echo 1001 > /sys/bus/usb/.../decimals | ||
| 45 | |||
| 46 | |||
diff --git a/Documentation/usb/power-management.txt b/Documentation/usb/power-management.txt index 9d31140e3f5b..e48ea1d51010 100644 --- a/Documentation/usb/power-management.txt +++ b/Documentation/usb/power-management.txt | |||
| @@ -350,12 +350,12 @@ without holding the mutex. | |||
| 350 | 350 | ||
| 351 | There also are a couple of utility routines drivers can use: | 351 | There also are a couple of utility routines drivers can use: |
| 352 | 352 | ||
| 353 | usb_autopm_enable() sets pm_usage_cnt to 1 and then calls | 353 | usb_autopm_enable() sets pm_usage_cnt to 0 and then calls |
| 354 | usb_autopm_set_interface(), which will attempt an autoresume. | ||
| 355 | |||
| 356 | usb_autopm_disable() sets pm_usage_cnt to 0 and then calls | ||
| 357 | usb_autopm_set_interface(), which will attempt an autosuspend. | 354 | usb_autopm_set_interface(), which will attempt an autosuspend. |
| 358 | 355 | ||
| 356 | usb_autopm_disable() sets pm_usage_cnt to 1 and then calls | ||
| 357 | usb_autopm_set_interface(), which will attempt an autoresume. | ||
| 358 | |||
| 359 | The conventional usage pattern is that a driver calls | 359 | The conventional usage pattern is that a driver calls |
| 360 | usb_autopm_get_interface() in its open routine and | 360 | usb_autopm_get_interface() in its open routine and |
| 361 | usb_autopm_put_interface() in its close or release routine. But | 361 | usb_autopm_put_interface() in its close or release routine. But |
diff --git a/drivers/block/ub.c b/drivers/block/ub.c index 3a281ef11ffa..f60e41833f69 100644 --- a/drivers/block/ub.c +++ b/drivers/block/ub.c | |||
| @@ -349,8 +349,6 @@ struct ub_dev { | |||
| 349 | 349 | ||
| 350 | struct work_struct reset_work; | 350 | struct work_struct reset_work; |
| 351 | wait_queue_head_t reset_wait; | 351 | wait_queue_head_t reset_wait; |
| 352 | |||
| 353 | int sg_stat[6]; | ||
| 354 | }; | 352 | }; |
| 355 | 353 | ||
| 356 | /* | 354 | /* |
| @@ -685,7 +683,6 @@ static int ub_request_fn_1(struct ub_lun *lun, struct request *rq) | |||
| 685 | goto drop; | 683 | goto drop; |
| 686 | } | 684 | } |
| 687 | urq->nsg = n_elem; | 685 | urq->nsg = n_elem; |
| 688 | sc->sg_stat[n_elem < 5 ? n_elem : 5]++; | ||
| 689 | 686 | ||
| 690 | if (blk_pc_request(rq)) { | 687 | if (blk_pc_request(rq)) { |
| 691 | ub_cmd_build_packet(sc, lun, cmd, urq); | 688 | ub_cmd_build_packet(sc, lun, cmd, urq); |
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c index 1d3b8a394d46..705a43cdeea4 100644 --- a/drivers/hid/usbhid/hid-core.c +++ b/drivers/hid/usbhid/hid-core.c | |||
| @@ -428,7 +428,7 @@ void usbhid_submit_report(struct hid_device *hid, struct hid_report *report, uns | |||
| 428 | usbhid->out[usbhid->outhead].raw_report = kmalloc(len, GFP_ATOMIC); | 428 | usbhid->out[usbhid->outhead].raw_report = kmalloc(len, GFP_ATOMIC); |
| 429 | if (!usbhid->out[usbhid->outhead].raw_report) { | 429 | if (!usbhid->out[usbhid->outhead].raw_report) { |
| 430 | spin_unlock_irqrestore(&usbhid->outlock, flags); | 430 | spin_unlock_irqrestore(&usbhid->outlock, flags); |
| 431 | warn("output queueing failed"); | 431 | dev_warn(&hid->dev, "output queueing failed\n"); |
| 432 | return; | 432 | return; |
| 433 | } | 433 | } |
| 434 | hid_output_report(report, usbhid->out[usbhid->outhead].raw_report); | 434 | hid_output_report(report, usbhid->out[usbhid->outhead].raw_report); |
| @@ -455,7 +455,7 @@ void usbhid_submit_report(struct hid_device *hid, struct hid_report *report, uns | |||
| 455 | usbhid->ctrl[usbhid->ctrlhead].raw_report = kmalloc(len, GFP_ATOMIC); | 455 | usbhid->ctrl[usbhid->ctrlhead].raw_report = kmalloc(len, GFP_ATOMIC); |
| 456 | if (!usbhid->ctrl[usbhid->ctrlhead].raw_report) { | 456 | if (!usbhid->ctrl[usbhid->ctrlhead].raw_report) { |
| 457 | spin_unlock_irqrestore(&usbhid->ctrllock, flags); | 457 | spin_unlock_irqrestore(&usbhid->ctrllock, flags); |
| 458 | warn("control queueing failed"); | 458 | dev_warn(&hid->dev, "control queueing failed\n"); |
| 459 | return; | 459 | return; |
| 460 | } | 460 | } |
| 461 | hid_output_report(report, usbhid->ctrl[usbhid->ctrlhead].raw_report); | 461 | hid_output_report(report, usbhid->ctrl[usbhid->ctrlhead].raw_report); |
diff --git a/drivers/input/joystick/iforce/iforce-ff.c b/drivers/input/joystick/iforce/iforce-ff.c index 7839b7b6fa96..0de9a0943a9e 100644 --- a/drivers/input/joystick/iforce/iforce-ff.c +++ b/drivers/input/joystick/iforce/iforce-ff.c | |||
| @@ -197,13 +197,16 @@ static unsigned char find_button(struct iforce *iforce, signed short button) | |||
| 197 | * Analyse the changes in an effect, and tell if we need to send an condition | 197 | * Analyse the changes in an effect, and tell if we need to send an condition |
| 198 | * parameter packet | 198 | * parameter packet |
| 199 | */ | 199 | */ |
| 200 | static int need_condition_modifier(struct ff_effect *old, struct ff_effect *new) | 200 | static int need_condition_modifier(struct iforce *iforce, |
| 201 | struct ff_effect *old, | ||
| 202 | struct ff_effect *new) | ||
| 201 | { | 203 | { |
| 202 | int ret = 0; | 204 | int ret = 0; |
| 203 | int i; | 205 | int i; |
| 204 | 206 | ||
| 205 | if (new->type != FF_SPRING && new->type != FF_FRICTION) { | 207 | if (new->type != FF_SPRING && new->type != FF_FRICTION) { |
| 206 | warn("bad effect type in need_condition_modifier"); | 208 | dev_warn(&iforce->dev->dev, "bad effect type in %s\n", |
| 209 | __func__); | ||
| 207 | return 0; | 210 | return 0; |
| 208 | } | 211 | } |
| 209 | 212 | ||
| @@ -222,10 +225,13 @@ static int need_condition_modifier(struct ff_effect *old, struct ff_effect *new) | |||
| 222 | * Analyse the changes in an effect, and tell if we need to send a magnitude | 225 | * Analyse the changes in an effect, and tell if we need to send a magnitude |
| 223 | * parameter packet | 226 | * parameter packet |
| 224 | */ | 227 | */ |
| 225 | static int need_magnitude_modifier(struct ff_effect *old, struct ff_effect *effect) | 228 | static int need_magnitude_modifier(struct iforce *iforce, |
| 229 | struct ff_effect *old, | ||
| 230 | struct ff_effect *effect) | ||
| 226 | { | 231 | { |
| 227 | if (effect->type != FF_CONSTANT) { | 232 | if (effect->type != FF_CONSTANT) { |
| 228 | warn("bad effect type in need_envelope_modifier"); | 233 | dev_warn(&iforce->dev->dev, "bad effect type in %s\n", |
| 234 | __func__); | ||
| 229 | return 0; | 235 | return 0; |
| 230 | } | 236 | } |
| 231 | 237 | ||
| @@ -236,7 +242,8 @@ static int need_magnitude_modifier(struct ff_effect *old, struct ff_effect *effe | |||
| 236 | * Analyse the changes in an effect, and tell if we need to send an envelope | 242 | * Analyse the changes in an effect, and tell if we need to send an envelope |
| 237 | * parameter packet | 243 | * parameter packet |
| 238 | */ | 244 | */ |
| 239 | static int need_envelope_modifier(struct ff_effect *old, struct ff_effect *effect) | 245 | static int need_envelope_modifier(struct iforce *iforce, struct ff_effect *old, |
| 246 | struct ff_effect *effect) | ||
| 240 | { | 247 | { |
| 241 | switch (effect->type) { | 248 | switch (effect->type) { |
| 242 | case FF_CONSTANT: | 249 | case FF_CONSTANT: |
| @@ -256,7 +263,8 @@ static int need_envelope_modifier(struct ff_effect *old, struct ff_effect *effec | |||
| 256 | break; | 263 | break; |
| 257 | 264 | ||
| 258 | default: | 265 | default: |
| 259 | warn("bad effect type in need_envelope_modifier"); | 266 | dev_warn(&iforce->dev->dev, "bad effect type in %s\n", |
| 267 | __func__); | ||
| 260 | } | 268 | } |
| 261 | 269 | ||
| 262 | return 0; | 270 | return 0; |
| @@ -266,10 +274,12 @@ static int need_envelope_modifier(struct ff_effect *old, struct ff_effect *effec | |||
| 266 | * Analyse the changes in an effect, and tell if we need to send a periodic | 274 | * Analyse the changes in an effect, and tell if we need to send a periodic |
| 267 | * parameter effect | 275 | * parameter effect |
| 268 | */ | 276 | */ |
| 269 | static int need_period_modifier(struct ff_effect *old, struct ff_effect *new) | 277 | static int need_period_modifier(struct iforce *iforce, struct ff_effect *old, |
| 278 | struct ff_effect *new) | ||
| 270 | { | 279 | { |
| 271 | if (new->type != FF_PERIODIC) { | 280 | if (new->type != FF_PERIODIC) { |
| 272 | warn("bad effect type in need_period_modifier"); | 281 | dev_warn(&iforce->dev->dev, "bad effect type in %s\n", |
| 282 | __func__); | ||
| 273 | return 0; | 283 | return 0; |
| 274 | } | 284 | } |
| 275 | return (old->u.periodic.period != new->u.periodic.period | 285 | return (old->u.periodic.period != new->u.periodic.period |
| @@ -355,7 +365,7 @@ int iforce_upload_periodic(struct iforce *iforce, struct ff_effect *effect, stru | |||
| 355 | int param2_err = 1; | 365 | int param2_err = 1; |
| 356 | int core_err = 0; | 366 | int core_err = 0; |
| 357 | 367 | ||
| 358 | if (!old || need_period_modifier(old, effect)) { | 368 | if (!old || need_period_modifier(iforce, old, effect)) { |
| 359 | param1_err = make_period_modifier(iforce, mod1_chunk, | 369 | param1_err = make_period_modifier(iforce, mod1_chunk, |
| 360 | old != NULL, | 370 | old != NULL, |
| 361 | effect->u.periodic.magnitude, effect->u.periodic.offset, | 371 | effect->u.periodic.magnitude, effect->u.periodic.offset, |
| @@ -365,7 +375,7 @@ int iforce_upload_periodic(struct iforce *iforce, struct ff_effect *effect, stru | |||
| 365 | set_bit(FF_MOD1_IS_USED, core_effect->flags); | 375 | set_bit(FF_MOD1_IS_USED, core_effect->flags); |
| 366 | } | 376 | } |
| 367 | 377 | ||
| 368 | if (!old || need_envelope_modifier(old, effect)) { | 378 | if (!old || need_envelope_modifier(iforce, old, effect)) { |
| 369 | param2_err = make_envelope_modifier(iforce, mod2_chunk, | 379 | param2_err = make_envelope_modifier(iforce, mod2_chunk, |
| 370 | old !=NULL, | 380 | old !=NULL, |
| 371 | effect->u.periodic.envelope.attack_length, | 381 | effect->u.periodic.envelope.attack_length, |
| @@ -425,7 +435,7 @@ int iforce_upload_constant(struct iforce *iforce, struct ff_effect *effect, stru | |||
| 425 | int param2_err = 1; | 435 | int param2_err = 1; |
| 426 | int core_err = 0; | 436 | int core_err = 0; |
| 427 | 437 | ||
| 428 | if (!old || need_magnitude_modifier(old, effect)) { | 438 | if (!old || need_magnitude_modifier(iforce, old, effect)) { |
| 429 | param1_err = make_magnitude_modifier(iforce, mod1_chunk, | 439 | param1_err = make_magnitude_modifier(iforce, mod1_chunk, |
| 430 | old != NULL, | 440 | old != NULL, |
| 431 | effect->u.constant.level); | 441 | effect->u.constant.level); |
| @@ -434,7 +444,7 @@ int iforce_upload_constant(struct iforce *iforce, struct ff_effect *effect, stru | |||
| 434 | set_bit(FF_MOD1_IS_USED, core_effect->flags); | 444 | set_bit(FF_MOD1_IS_USED, core_effect->flags); |
| 435 | } | 445 | } |
| 436 | 446 | ||
| 437 | if (!old || need_envelope_modifier(old, effect)) { | 447 | if (!old || need_envelope_modifier(iforce, old, effect)) { |
| 438 | param2_err = make_envelope_modifier(iforce, mod2_chunk, | 448 | param2_err = make_envelope_modifier(iforce, mod2_chunk, |
| 439 | old != NULL, | 449 | old != NULL, |
| 440 | effect->u.constant.envelope.attack_length, | 450 | effect->u.constant.envelope.attack_length, |
| @@ -487,7 +497,7 @@ int iforce_upload_condition(struct iforce *iforce, struct ff_effect *effect, str | |||
| 487 | default: return -1; | 497 | default: return -1; |
| 488 | } | 498 | } |
| 489 | 499 | ||
| 490 | if (!old || need_condition_modifier(old, effect)) { | 500 | if (!old || need_condition_modifier(iforce, old, effect)) { |
| 491 | param_err = make_condition_modifier(iforce, mod1_chunk, | 501 | param_err = make_condition_modifier(iforce, mod1_chunk, |
| 492 | old != NULL, | 502 | old != NULL, |
| 493 | effect->u.condition[0].right_saturation, | 503 | effect->u.condition[0].right_saturation, |
diff --git a/drivers/input/joystick/iforce/iforce-main.c b/drivers/input/joystick/iforce/iforce-main.c index 61ee6e38739d..baabf8302645 100644 --- a/drivers/input/joystick/iforce/iforce-main.c +++ b/drivers/input/joystick/iforce/iforce-main.c | |||
| @@ -218,7 +218,9 @@ static void iforce_release(struct input_dev *dev) | |||
| 218 | /* Check: no effects should be present in memory */ | 218 | /* Check: no effects should be present in memory */ |
| 219 | for (i = 0; i < dev->ff->max_effects; i++) { | 219 | for (i = 0; i < dev->ff->max_effects; i++) { |
| 220 | if (test_bit(FF_CORE_IS_USED, iforce->core_effects[i].flags)) { | 220 | if (test_bit(FF_CORE_IS_USED, iforce->core_effects[i].flags)) { |
| 221 | warn("iforce_release: Device still owns effects"); | 221 | dev_warn(&dev->dev, |
| 222 | "%s: Device still owns effects\n", | ||
| 223 | __func__); | ||
| 222 | break; | 224 | break; |
| 223 | } | 225 | } |
| 224 | } | 226 | } |
| @@ -335,26 +337,26 @@ int iforce_init_device(struct iforce *iforce) | |||
| 335 | if (!iforce_get_id_packet(iforce, "M")) | 337 | if (!iforce_get_id_packet(iforce, "M")) |
| 336 | input_dev->id.vendor = (iforce->edata[2] << 8) | iforce->edata[1]; | 338 | input_dev->id.vendor = (iforce->edata[2] << 8) | iforce->edata[1]; |
| 337 | else | 339 | else |
| 338 | warn("Device does not respond to id packet M"); | 340 | dev_warn(&iforce->dev->dev, "Device does not respond to id packet M\n"); |
| 339 | 341 | ||
| 340 | if (!iforce_get_id_packet(iforce, "P")) | 342 | if (!iforce_get_id_packet(iforce, "P")) |
| 341 | input_dev->id.product = (iforce->edata[2] << 8) | iforce->edata[1]; | 343 | input_dev->id.product = (iforce->edata[2] << 8) | iforce->edata[1]; |
| 342 | else | 344 | else |
| 343 | warn("Device does not respond to id packet P"); | 345 | dev_warn(&iforce->dev->dev, "Device does not respond to id packet P\n"); |
| 344 | 346 | ||
| 345 | if (!iforce_get_id_packet(iforce, "B")) | 347 | if (!iforce_get_id_packet(iforce, "B")) |
| 346 | iforce->device_memory.end = (iforce->edata[2] << 8) | iforce->edata[1]; | 348 | iforce->device_memory.end = (iforce->edata[2] << 8) | iforce->edata[1]; |
| 347 | else | 349 | else |
| 348 | warn("Device does not respond to id packet B"); | 350 | dev_warn(&iforce->dev->dev, "Device does not respond to id packet B\n"); |
| 349 | 351 | ||
| 350 | if (!iforce_get_id_packet(iforce, "N")) | 352 | if (!iforce_get_id_packet(iforce, "N")) |
| 351 | ff_effects = iforce->edata[1]; | 353 | ff_effects = iforce->edata[1]; |
| 352 | else | 354 | else |
| 353 | warn("Device does not respond to id packet N"); | 355 | dev_warn(&iforce->dev->dev, "Device does not respond to id packet N\n"); |
| 354 | 356 | ||
| 355 | /* Check if the device can store more effects than the driver can really handle */ | 357 | /* Check if the device can store more effects than the driver can really handle */ |
| 356 | if (ff_effects > IFORCE_EFFECTS_MAX) { | 358 | if (ff_effects > IFORCE_EFFECTS_MAX) { |
| 357 | warn("Limiting number of effects to %d (device reports %d)", | 359 | dev_warn(&iforce->dev->dev, "Limiting number of effects to %d (device reports %d)\n", |
| 358 | IFORCE_EFFECTS_MAX, ff_effects); | 360 | IFORCE_EFFECTS_MAX, ff_effects); |
| 359 | ff_effects = IFORCE_EFFECTS_MAX; | 361 | ff_effects = IFORCE_EFFECTS_MAX; |
| 360 | } | 362 | } |
diff --git a/drivers/input/joystick/iforce/iforce-packets.c b/drivers/input/joystick/iforce/iforce-packets.c index 015b50aa76fc..a17b50016009 100644 --- a/drivers/input/joystick/iforce/iforce-packets.c +++ b/drivers/input/joystick/iforce/iforce-packets.c | |||
| @@ -65,7 +65,8 @@ int iforce_send_packet(struct iforce *iforce, u16 cmd, unsigned char* data) | |||
| 65 | 65 | ||
| 66 | 66 | ||
| 67 | if (CIRC_SPACE(head, tail, XMIT_SIZE) < n+2) { | 67 | if (CIRC_SPACE(head, tail, XMIT_SIZE) < n+2) { |
| 68 | warn("not enough space in xmit buffer to send new packet"); | 68 | dev_warn(&iforce->dev->dev, |
| 69 | "not enough space in xmit buffer to send new packet\n"); | ||
| 69 | spin_unlock_irqrestore(&iforce->xmit_lock, flags); | 70 | spin_unlock_irqrestore(&iforce->xmit_lock, flags); |
| 70 | return -1; | 71 | return -1; |
| 71 | } | 72 | } |
| @@ -148,7 +149,7 @@ static int mark_core_as_ready(struct iforce *iforce, unsigned short addr) | |||
| 148 | return 0; | 149 | return 0; |
| 149 | } | 150 | } |
| 150 | } | 151 | } |
| 151 | warn("unused effect %04x updated !!!", addr); | 152 | dev_warn(&iforce->dev->dev, "unused effect %04x updated !!!\n", addr); |
| 152 | return -1; | 153 | return -1; |
| 153 | } | 154 | } |
| 154 | 155 | ||
| @@ -159,7 +160,8 @@ void iforce_process_packet(struct iforce *iforce, u16 cmd, unsigned char *data) | |||
| 159 | static int being_used = 0; | 160 | static int being_used = 0; |
| 160 | 161 | ||
| 161 | if (being_used) | 162 | if (being_used) |
| 162 | warn("re-entrant call to iforce_process %d", being_used); | 163 | dev_warn(&iforce->dev->dev, |
| 164 | "re-entrant call to iforce_process %d\n", being_used); | ||
| 163 | being_used++; | 165 | being_used++; |
| 164 | 166 | ||
| 165 | #ifdef CONFIG_JOYSTICK_IFORCE_232 | 167 | #ifdef CONFIG_JOYSTICK_IFORCE_232 |
diff --git a/drivers/input/joystick/iforce/iforce-usb.c b/drivers/input/joystick/iforce/iforce-usb.c index 851cc4087c2f..f83185aeb511 100644 --- a/drivers/input/joystick/iforce/iforce-usb.c +++ b/drivers/input/joystick/iforce/iforce-usb.c | |||
| @@ -64,7 +64,7 @@ void iforce_usb_xmit(struct iforce *iforce) | |||
| 64 | 64 | ||
| 65 | if ( (n=usb_submit_urb(iforce->out, GFP_ATOMIC)) ) { | 65 | if ( (n=usb_submit_urb(iforce->out, GFP_ATOMIC)) ) { |
| 66 | clear_bit(IFORCE_XMIT_RUNNING, iforce->xmit_flags); | 66 | clear_bit(IFORCE_XMIT_RUNNING, iforce->xmit_flags); |
| 67 | warn("usb_submit_urb failed %d\n", n); | 67 | dev_warn(&iforce->dev->dev, "usb_submit_urb failed %d\n", n); |
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | /* The IFORCE_XMIT_RUNNING bit is not cleared here. That's intended. | 70 | /* The IFORCE_XMIT_RUNNING bit is not cleared here. That's intended. |
diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c index 839d1c9622f6..b868b8d5fbb3 100644 --- a/drivers/input/joystick/xpad.c +++ b/drivers/input/joystick/xpad.c | |||
| @@ -911,7 +911,7 @@ static int __init usb_xpad_init(void) | |||
| 911 | { | 911 | { |
| 912 | int result = usb_register(&xpad_driver); | 912 | int result = usb_register(&xpad_driver); |
| 913 | if (result == 0) | 913 | if (result == 0) |
| 914 | info(DRIVER_DESC); | 914 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_DESC "\n"); |
| 915 | return result; | 915 | return result; |
| 916 | } | 916 | } |
| 917 | 917 | ||
diff --git a/drivers/input/misc/ati_remote.c b/drivers/input/misc/ati_remote.c index debfc1af9d95..e290fde35e74 100644 --- a/drivers/input/misc/ati_remote.c +++ b/drivers/input/misc/ati_remote.c | |||
| @@ -285,7 +285,6 @@ static const struct { | |||
| 285 | }; | 285 | }; |
| 286 | 286 | ||
| 287 | /* Local function prototypes */ | 287 | /* Local function prototypes */ |
| 288 | static void ati_remote_dump (unsigned char *data, unsigned int actual_length); | ||
| 289 | static int ati_remote_open (struct input_dev *inputdev); | 288 | static int ati_remote_open (struct input_dev *inputdev); |
| 290 | static void ati_remote_close (struct input_dev *inputdev); | 289 | static void ati_remote_close (struct input_dev *inputdev); |
| 291 | static int ati_remote_sendpacket (struct ati_remote *ati_remote, u16 cmd, unsigned char *data); | 290 | static int ati_remote_sendpacket (struct ati_remote *ati_remote, u16 cmd, unsigned char *data); |
| @@ -307,15 +306,16 @@ static struct usb_driver ati_remote_driver = { | |||
| 307 | /* | 306 | /* |
| 308 | * ati_remote_dump_input | 307 | * ati_remote_dump_input |
| 309 | */ | 308 | */ |
| 310 | static void ati_remote_dump(unsigned char *data, unsigned int len) | 309 | static void ati_remote_dump(struct device *dev, unsigned char *data, |
| 310 | unsigned int len) | ||
| 311 | { | 311 | { |
| 312 | if ((len == 1) && (data[0] != (unsigned char)0xff) && (data[0] != 0x00)) | 312 | if ((len == 1) && (data[0] != (unsigned char)0xff) && (data[0] != 0x00)) |
| 313 | warn("Weird byte 0x%02x", data[0]); | 313 | dev_warn(dev, "Weird byte 0x%02x\n", data[0]); |
| 314 | else if (len == 4) | 314 | else if (len == 4) |
| 315 | warn("Weird key %02x %02x %02x %02x", | 315 | dev_warn(dev, "Weird key %02x %02x %02x %02x\n", |
| 316 | data[0], data[1], data[2], data[3]); | 316 | data[0], data[1], data[2], data[3]); |
| 317 | else | 317 | else |
| 318 | warn("Weird data, len=%d %02x %02x %02x %02x %02x %02x ...", | 318 | dev_warn(dev, "Weird data, len=%d %02x %02x %02x %02x %02x %02x ...\n", |
| 319 | len, data[0], data[1], data[2], data[3], data[4], data[5]); | 319 | len, data[0], data[1], data[2], data[3], data[4], data[5]); |
| 320 | } | 320 | } |
| 321 | 321 | ||
| @@ -470,7 +470,7 @@ static void ati_remote_input_report(struct urb *urb) | |||
| 470 | /* Deal with strange looking inputs */ | 470 | /* Deal with strange looking inputs */ |
| 471 | if ( (urb->actual_length != 4) || (data[0] != 0x14) || | 471 | if ( (urb->actual_length != 4) || (data[0] != 0x14) || |
| 472 | ((data[3] & 0x0f) != 0x00) ) { | 472 | ((data[3] & 0x0f) != 0x00) ) { |
| 473 | ati_remote_dump(data, urb->actual_length); | 473 | ati_remote_dump(&urb->dev->dev, data, urb->actual_length); |
| 474 | return; | 474 | return; |
| 475 | } | 475 | } |
| 476 | 476 | ||
| @@ -814,7 +814,7 @@ static void ati_remote_disconnect(struct usb_interface *interface) | |||
| 814 | ati_remote = usb_get_intfdata(interface); | 814 | ati_remote = usb_get_intfdata(interface); |
| 815 | usb_set_intfdata(interface, NULL); | 815 | usb_set_intfdata(interface, NULL); |
| 816 | if (!ati_remote) { | 816 | if (!ati_remote) { |
| 817 | warn("%s - null device?\n", __func__); | 817 | dev_warn(&interface->dev, "%s - null device?\n", __func__); |
| 818 | return; | 818 | return; |
| 819 | } | 819 | } |
| 820 | 820 | ||
| @@ -834,9 +834,11 @@ static int __init ati_remote_init(void) | |||
| 834 | 834 | ||
| 835 | result = usb_register(&ati_remote_driver); | 835 | result = usb_register(&ati_remote_driver); |
| 836 | if (result) | 836 | if (result) |
| 837 | err("usb_register error #%d\n", result); | 837 | printk(KERN_ERR KBUILD_MODNAME |
| 838 | ": usb_register error #%d\n", result); | ||
| 838 | else | 839 | else |
| 839 | info("Registered USB driver " DRIVER_DESC " v. " DRIVER_VERSION); | 840 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
| 841 | DRIVER_DESC "\n"); | ||
| 840 | 842 | ||
| 841 | return result; | 843 | return result; |
| 842 | } | 844 | } |
diff --git a/drivers/input/misc/yealink.c b/drivers/input/misc/yealink.c index 11b5c7e84ed1..93a22ac0f88c 100644 --- a/drivers/input/misc/yealink.c +++ b/drivers/input/misc/yealink.c | |||
| @@ -999,7 +999,8 @@ static int __init yealink_dev_init(void) | |||
| 999 | { | 999 | { |
| 1000 | int ret = usb_register(&yealink_driver); | 1000 | int ret = usb_register(&yealink_driver); |
| 1001 | if (ret == 0) | 1001 | if (ret == 0) |
| 1002 | info(DRIVER_DESC ":" DRIVER_VERSION); | 1002 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
| 1003 | DRIVER_DESC "\n"); | ||
| 1003 | return ret; | 1004 | return ret; |
| 1004 | } | 1005 | } |
| 1005 | 1006 | ||
diff --git a/drivers/input/tablet/acecad.c b/drivers/input/tablet/acecad.c index 570e0e83ac46..670c61c5a516 100644 --- a/drivers/input/tablet/acecad.c +++ b/drivers/input/tablet/acecad.c | |||
| @@ -280,7 +280,8 @@ static int __init usb_acecad_init(void) | |||
| 280 | { | 280 | { |
| 281 | int result = usb_register(&usb_acecad_driver); | 281 | int result = usb_register(&usb_acecad_driver); |
| 282 | if (result == 0) | 282 | if (result == 0) |
| 283 | info(DRIVER_VERSION ":" DRIVER_DESC); | 283 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
| 284 | DRIVER_DESC "\n"); | ||
| 284 | return result; | 285 | return result; |
| 285 | } | 286 | } |
| 286 | 287 | ||
diff --git a/drivers/input/tablet/aiptek.c b/drivers/input/tablet/aiptek.c index e53c838f1866..7d005a3616d7 100644 --- a/drivers/input/tablet/aiptek.c +++ b/drivers/input/tablet/aiptek.c | |||
| @@ -1706,20 +1706,21 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
| 1706 | aiptek = kzalloc(sizeof(struct aiptek), GFP_KERNEL); | 1706 | aiptek = kzalloc(sizeof(struct aiptek), GFP_KERNEL); |
| 1707 | inputdev = input_allocate_device(); | 1707 | inputdev = input_allocate_device(); |
| 1708 | if (!aiptek || !inputdev) { | 1708 | if (!aiptek || !inputdev) { |
| 1709 | warn("aiptek: cannot allocate memory or input device"); | 1709 | dev_warn(&intf->dev, |
| 1710 | "cannot allocate memory or input device\n"); | ||
| 1710 | goto fail1; | 1711 | goto fail1; |
| 1711 | } | 1712 | } |
| 1712 | 1713 | ||
| 1713 | aiptek->data = usb_buffer_alloc(usbdev, AIPTEK_PACKET_LENGTH, | 1714 | aiptek->data = usb_buffer_alloc(usbdev, AIPTEK_PACKET_LENGTH, |
| 1714 | GFP_ATOMIC, &aiptek->data_dma); | 1715 | GFP_ATOMIC, &aiptek->data_dma); |
| 1715 | if (!aiptek->data) { | 1716 | if (!aiptek->data) { |
| 1716 | warn("aiptek: cannot allocate usb buffer"); | 1717 | dev_warn(&intf->dev, "cannot allocate usb buffer\n"); |
| 1717 | goto fail1; | 1718 | goto fail1; |
| 1718 | } | 1719 | } |
| 1719 | 1720 | ||
| 1720 | aiptek->urb = usb_alloc_urb(0, GFP_KERNEL); | 1721 | aiptek->urb = usb_alloc_urb(0, GFP_KERNEL); |
| 1721 | if (!aiptek->urb) { | 1722 | if (!aiptek->urb) { |
| 1722 | warn("aiptek: cannot allocate urb"); | 1723 | dev_warn(&intf->dev, "cannot allocate urb\n"); |
| 1723 | goto fail2; | 1724 | goto fail2; |
| 1724 | } | 1725 | } |
| 1725 | 1726 | ||
| @@ -1843,8 +1844,9 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
| 1843 | aiptek->curSetting.programmableDelay = speeds[i]; | 1844 | aiptek->curSetting.programmableDelay = speeds[i]; |
| 1844 | (void)aiptek_program_tablet(aiptek); | 1845 | (void)aiptek_program_tablet(aiptek); |
| 1845 | if (aiptek->inputdev->absmax[ABS_X] > 0) { | 1846 | if (aiptek->inputdev->absmax[ABS_X] > 0) { |
| 1846 | info("input: Aiptek using %d ms programming speed\n", | 1847 | dev_info(&intf->dev, |
| 1847 | aiptek->curSetting.programmableDelay); | 1848 | "Aiptek using %d ms programming speed\n", |
| 1849 | aiptek->curSetting.programmableDelay); | ||
| 1848 | break; | 1850 | break; |
| 1849 | } | 1851 | } |
| 1850 | } | 1852 | } |
| @@ -1852,7 +1854,8 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
| 1852 | /* Murphy says that some day someone will have a tablet that fails the | 1854 | /* Murphy says that some day someone will have a tablet that fails the |
| 1853 | above test. That's you, Frederic Rodrigo */ | 1855 | above test. That's you, Frederic Rodrigo */ |
| 1854 | if (i == ARRAY_SIZE(speeds)) { | 1856 | if (i == ARRAY_SIZE(speeds)) { |
| 1855 | info("input: Aiptek tried all speeds, no sane response"); | 1857 | dev_info(&intf->dev, |
| 1858 | "Aiptek tried all speeds, no sane response\n"); | ||
| 1856 | goto fail2; | 1859 | goto fail2; |
| 1857 | } | 1860 | } |
| 1858 | 1861 | ||
| @@ -1864,7 +1867,8 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
| 1864 | */ | 1867 | */ |
| 1865 | err = sysfs_create_group(&intf->dev.kobj, &aiptek_attribute_group); | 1868 | err = sysfs_create_group(&intf->dev.kobj, &aiptek_attribute_group); |
| 1866 | if (err) { | 1869 | if (err) { |
| 1867 | warn("aiptek: cannot create sysfs group err: %d", err); | 1870 | dev_warn(&intf->dev, "cannot create sysfs group err: %d\n", |
| 1871 | err); | ||
| 1868 | goto fail3; | 1872 | goto fail3; |
| 1869 | } | 1873 | } |
| 1870 | 1874 | ||
| @@ -1872,7 +1876,8 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
| 1872 | */ | 1876 | */ |
| 1873 | err = input_register_device(aiptek->inputdev); | 1877 | err = input_register_device(aiptek->inputdev); |
| 1874 | if (err) { | 1878 | if (err) { |
| 1875 | warn("aiptek: input_register_device returned err: %d", err); | 1879 | dev_warn(&intf->dev, |
| 1880 | "input_register_device returned err: %d\n", err); | ||
| 1876 | goto fail4; | 1881 | goto fail4; |
| 1877 | } | 1882 | } |
| 1878 | return 0; | 1883 | return 0; |
| @@ -1922,8 +1927,9 @@ static int __init aiptek_init(void) | |||
| 1922 | { | 1927 | { |
| 1923 | int result = usb_register(&aiptek_driver); | 1928 | int result = usb_register(&aiptek_driver); |
| 1924 | if (result == 0) { | 1929 | if (result == 0) { |
| 1925 | info(DRIVER_VERSION ": " DRIVER_AUTHOR); | 1930 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
| 1926 | info(DRIVER_DESC); | 1931 | DRIVER_DESC "\n"); |
| 1932 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_AUTHOR "\n"); | ||
| 1927 | } | 1933 | } |
| 1928 | return result; | 1934 | return result; |
| 1929 | } | 1935 | } |
diff --git a/drivers/input/tablet/gtco.c b/drivers/input/tablet/gtco.c index 7df0228e836e..5524e01dbb1a 100644 --- a/drivers/input/tablet/gtco.c +++ b/drivers/input/tablet/gtco.c | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | GTCO digitizer USB driver | 3 | GTCO digitizer USB driver |
| 4 | 4 | ||
| 5 | Use the err(), dbg() and info() macros from usb.h for system logging | 5 | Use the err() and dbg() macros from usb.h for system logging |
| 6 | 6 | ||
| 7 | TO CHECK: Is pressure done right on report 5? | 7 | TO CHECK: Is pressure done right on report 5? |
| 8 | 8 | ||
| @@ -1010,7 +1010,7 @@ static void gtco_disconnect(struct usb_interface *interface) | |||
| 1010 | kfree(gtco); | 1010 | kfree(gtco); |
| 1011 | } | 1011 | } |
| 1012 | 1012 | ||
| 1013 | info("gtco driver disconnected"); | 1013 | dev_info(&interface->dev, "gtco driver disconnected\n"); |
| 1014 | } | 1014 | } |
| 1015 | 1015 | ||
| 1016 | /* STANDARD MODULE LOAD ROUTINES */ | 1016 | /* STANDARD MODULE LOAD ROUTINES */ |
diff --git a/drivers/input/tablet/kbtab.c b/drivers/input/tablet/kbtab.c index d89112fa6e6b..6682b17bf844 100644 --- a/drivers/input/tablet/kbtab.c +++ b/drivers/input/tablet/kbtab.c | |||
| @@ -215,7 +215,8 @@ static int __init kbtab_init(void) | |||
| 215 | retval = usb_register(&kbtab_driver); | 215 | retval = usb_register(&kbtab_driver); |
| 216 | if (retval) | 216 | if (retval) |
| 217 | goto out; | 217 | goto out; |
| 218 | info(DRIVER_VERSION ":" DRIVER_DESC); | 218 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
| 219 | DRIVER_DESC "\n"); | ||
| 219 | out: | 220 | out: |
| 220 | return retval; | 221 | return retval; |
| 221 | } | 222 | } |
diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c index 5fbc463baf5a..09e227aa0d49 100644 --- a/drivers/input/tablet/wacom_sys.c +++ b/drivers/input/tablet/wacom_sys.c | |||
| @@ -385,7 +385,8 @@ static int __init wacom_init(void) | |||
| 385 | wacom_driver.id_table = get_device_table(); | 385 | wacom_driver.id_table = get_device_table(); |
| 386 | result = usb_register(&wacom_driver); | 386 | result = usb_register(&wacom_driver); |
| 387 | if (result == 0) | 387 | if (result == 0) |
| 388 | info(DRIVER_VERSION ":" DRIVER_DESC); | 388 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
| 389 | DRIVER_DESC "\n"); | ||
| 389 | return result; | 390 | return result; |
| 390 | } | 391 | } |
| 391 | 392 | ||
diff --git a/drivers/media/radio/dsbr100.c b/drivers/media/radio/dsbr100.c index 66783fffe4c1..78f56944e640 100644 --- a/drivers/media/radio/dsbr100.c +++ b/drivers/media/radio/dsbr100.c | |||
| @@ -310,7 +310,7 @@ static int vidioc_s_frequency(struct file *file, void *priv, | |||
| 310 | 310 | ||
| 311 | radio->curfreq = f->frequency; | 311 | radio->curfreq = f->frequency; |
| 312 | if (dsbr100_setfreq(radio, radio->curfreq)==-1) | 312 | if (dsbr100_setfreq(radio, radio->curfreq)==-1) |
| 313 | warn("Set frequency failed"); | 313 | dev_warn(&radio->usbdev->dev, "Set frequency failed\n"); |
| 314 | return 0; | 314 | return 0; |
| 315 | } | 315 | } |
| 316 | 316 | ||
| @@ -361,12 +361,14 @@ static int vidioc_s_ctrl(struct file *file, void *priv, | |||
| 361 | case V4L2_CID_AUDIO_MUTE: | 361 | case V4L2_CID_AUDIO_MUTE: |
| 362 | if (ctrl->value) { | 362 | if (ctrl->value) { |
| 363 | if (dsbr100_stop(radio) == -1) { | 363 | if (dsbr100_stop(radio) == -1) { |
| 364 | warn("Radio did not respond properly"); | 364 | dev_warn(&radio->usbdev->dev, |
| 365 | "Radio did not respond properly\n"); | ||
| 365 | return -EBUSY; | 366 | return -EBUSY; |
| 366 | } | 367 | } |
| 367 | } else { | 368 | } else { |
| 368 | if (dsbr100_start(radio) == -1) { | 369 | if (dsbr100_start(radio) == -1) { |
| 369 | warn("Radio did not respond properly"); | 370 | dev_warn(&radio->usbdev->dev, |
| 371 | "Radio did not respond properly\n"); | ||
| 370 | return -EBUSY; | 372 | return -EBUSY; |
| 371 | } | 373 | } |
| 372 | } | 374 | } |
| @@ -416,7 +418,8 @@ static int usb_dsbr100_open(struct inode *inode, struct file *file) | |||
| 416 | radio->muted = 1; | 418 | radio->muted = 1; |
| 417 | 419 | ||
| 418 | if (dsbr100_start(radio)<0) { | 420 | if (dsbr100_start(radio)<0) { |
| 419 | warn("Radio did not start up properly"); | 421 | dev_warn(&radio->usbdev->dev, |
| 422 | "Radio did not start up properly\n"); | ||
| 420 | radio->users = 0; | 423 | radio->users = 0; |
| 421 | unlock_kernel(); | 424 | unlock_kernel(); |
| 422 | return -EIO; | 425 | return -EIO; |
| @@ -501,7 +504,7 @@ static int usb_dsbr100_probe(struct usb_interface *intf, | |||
| 501 | radio->curfreq = FREQ_MIN*FREQ_MUL; | 504 | radio->curfreq = FREQ_MIN*FREQ_MUL; |
| 502 | video_set_drvdata(radio->videodev, radio); | 505 | video_set_drvdata(radio->videodev, radio); |
| 503 | if (video_register_device(radio->videodev, VFL_TYPE_RADIO, radio_nr) < 0) { | 506 | if (video_register_device(radio->videodev, VFL_TYPE_RADIO, radio_nr) < 0) { |
| 504 | warn("Could not register video device"); | 507 | dev_warn(&intf->dev, "Could not register video device\n"); |
| 505 | video_device_release(radio->videodev); | 508 | video_device_release(radio->videodev); |
| 506 | kfree(radio->transfer_buffer); | 509 | kfree(radio->transfer_buffer); |
| 507 | kfree(radio); | 510 | kfree(radio); |
diff --git a/drivers/media/video/dabusb.c b/drivers/media/video/dabusb.c index 3aa538afcc0b..298810d5262b 100644 --- a/drivers/media/video/dabusb.c +++ b/drivers/media/video/dabusb.c | |||
| @@ -192,7 +192,7 @@ static void dabusb_iso_complete (struct urb *purb) | |||
| 192 | err("dabusb_iso_complete: invalid len %d", len); | 192 | err("dabusb_iso_complete: invalid len %d", len); |
| 193 | } | 193 | } |
| 194 | else | 194 | else |
| 195 | warn("dabusb_iso_complete: corrupted packet status: %d", purb->iso_frame_desc[i].status); | 195 | dev_warn(&purb->dev->dev, "dabusb_iso_complete: corrupted packet status: %d\n", purb->iso_frame_desc[i].status); |
| 196 | if (dst != purb->actual_length) | 196 | if (dst != purb->actual_length) |
| 197 | err("dst!=purb->actual_length:%d!=%d", dst, purb->actual_length); | 197 | err("dst!=purb->actual_length:%d!=%d", dst, purb->actual_length); |
| 198 | } | 198 | } |
| @@ -289,7 +289,7 @@ static int dabusb_bulk (pdabusb_t s, pbulk_transfer_t pb) | |||
| 289 | } | 289 | } |
| 290 | 290 | ||
| 291 | if( ret == -EPIPE ) { | 291 | if( ret == -EPIPE ) { |
| 292 | warn("CLEAR_FEATURE request to remove STALL condition."); | 292 | dev_warn(&s->usbdev->dev, "CLEAR_FEATURE request to remove STALL condition.\n"); |
| 293 | if(usb_clear_halt(s->usbdev, usb_pipeendpoint(pipe))) | 293 | if(usb_clear_halt(s->usbdev, usb_pipeendpoint(pipe))) |
| 294 | err("request failed"); | 294 | err("request failed"); |
| 295 | } | 295 | } |
diff --git a/drivers/media/video/ov511.c b/drivers/media/video/ov511.c index 935d73de57bd..210f1240b331 100644 --- a/drivers/media/video/ov511.c +++ b/drivers/media/video/ov511.c | |||
| @@ -1098,9 +1098,10 @@ ov51x_clear_snapshot(struct usb_ov511 *ov) | |||
| 1098 | reg_w(ov, R51x_SYS_SNAP, 0x02); | 1098 | reg_w(ov, R51x_SYS_SNAP, 0x02); |
| 1099 | reg_w(ov, R51x_SYS_SNAP, 0x00); | 1099 | reg_w(ov, R51x_SYS_SNAP, 0x00); |
| 1100 | } else if (ov->bclass == BCL_OV518) { | 1100 | } else if (ov->bclass == BCL_OV518) { |
| 1101 | warn("snapshot reset not supported yet on OV518(+)"); | 1101 | dev_warn(&ov->dev->dev, |
| 1102 | "snapshot reset not supported yet on OV518(+)\n"); | ||
| 1102 | } else { | 1103 | } else { |
| 1103 | err("clear snap: invalid bridge type"); | 1104 | dev_err(&ov->dev->dev, "clear snap: invalid bridge type\n"); |
| 1104 | } | 1105 | } |
| 1105 | } | 1106 | } |
| 1106 | 1107 | ||
| @@ -1115,14 +1116,16 @@ ov51x_check_snapshot(struct usb_ov511 *ov) | |||
| 1115 | if (ov->bclass == BCL_OV511) { | 1116 | if (ov->bclass == BCL_OV511) { |
| 1116 | ret = reg_r(ov, R51x_SYS_SNAP); | 1117 | ret = reg_r(ov, R51x_SYS_SNAP); |
| 1117 | if (ret < 0) { | 1118 | if (ret < 0) { |
| 1118 | err("Error checking snspshot status (%d)", ret); | 1119 | dev_err(&ov->dev->dev, |
| 1120 | "Error checking snspshot status (%d)\n", ret); | ||
| 1119 | } else if (ret & 0x08) { | 1121 | } else if (ret & 0x08) { |
| 1120 | status = 1; | 1122 | status = 1; |
| 1121 | } | 1123 | } |
| 1122 | } else if (ov->bclass == BCL_OV518) { | 1124 | } else if (ov->bclass == BCL_OV518) { |
| 1123 | warn("snapshot check not supported yet on OV518(+)"); | 1125 | dev_warn(&ov->dev->dev, |
| 1126 | "snapshot check not supported yet on OV518(+)\n"); | ||
| 1124 | } else { | 1127 | } else { |
| 1125 | err("check snap: invalid bridge type"); | 1128 | dev_err(&ov->dev->dev, "clear snap: invalid bridge type\n"); |
| 1126 | } | 1129 | } |
| 1127 | 1130 | ||
| 1128 | return status; | 1131 | return status; |
| @@ -5217,7 +5220,8 @@ saa7111a_configure(struct usb_ov511 *ov) | |||
| 5217 | if (ov->bclass == BCL_OV511) | 5220 | if (ov->bclass == BCL_OV511) |
| 5218 | reg_w(ov, 0x11, 0x00); | 5221 | reg_w(ov, 0x11, 0x00); |
| 5219 | else | 5222 | else |
| 5220 | warn("SAA7111A not yet supported with OV518/OV518+"); | 5223 | dev_warn(&ov->dev->dev, |
| 5224 | "SAA7111A not yet supported with OV518/OV518+\n"); | ||
| 5221 | 5225 | ||
| 5222 | return 0; | 5226 | return 0; |
| 5223 | } | 5227 | } |
| @@ -5456,7 +5460,8 @@ ov518_configure(struct usb_ov511 *ov) | |||
| 5456 | * required. OV518 has no uncompressed mode, to save RAM. */ | 5460 | * required. OV518 has no uncompressed mode, to save RAM. */ |
| 5457 | if (!dumppix && !ov->compress) { | 5461 | if (!dumppix && !ov->compress) { |
| 5458 | ov->compress = 1; | 5462 | ov->compress = 1; |
| 5459 | warn("Compression required with OV518...enabling"); | 5463 | dev_warn(&ov->dev->dev, |
| 5464 | "Compression required with OV518...enabling\n"); | ||
| 5460 | } | 5465 | } |
| 5461 | 5466 | ||
| 5462 | if (ov->bridge == BRG_OV518) { | 5467 | if (ov->bridge == BRG_OV518) { |
diff --git a/drivers/media/video/usbvideo/konicawc.c b/drivers/media/video/usbvideo/konicawc.c index e986c28b7bb0..da27a5287983 100644 --- a/drivers/media/video/usbvideo/konicawc.c +++ b/drivers/media/video/usbvideo/konicawc.c | |||
| @@ -229,7 +229,8 @@ static void konicawc_register_input(struct konicawc *cam, struct usb_device *dev | |||
| 229 | 229 | ||
| 230 | cam->input = input_dev = input_allocate_device(); | 230 | cam->input = input_dev = input_allocate_device(); |
| 231 | if (!input_dev) { | 231 | if (!input_dev) { |
| 232 | warn("Not enough memory for camera's input device\n"); | 232 | dev_warn(&dev->dev, |
| 233 | "Not enough memory for camera's input device\n"); | ||
| 233 | return; | 234 | return; |
| 234 | } | 235 | } |
| 235 | 236 | ||
| @@ -243,8 +244,9 @@ static void konicawc_register_input(struct konicawc *cam, struct usb_device *dev | |||
| 243 | 244 | ||
| 244 | error = input_register_device(cam->input); | 245 | error = input_register_device(cam->input); |
| 245 | if (error) { | 246 | if (error) { |
| 246 | warn("Failed to register camera's input device, err: %d\n", | 247 | dev_warn(&dev->dev, |
| 247 | error); | 248 | "Failed to register camera's input device, err: %d\n", |
| 249 | error); | ||
| 248 | input_free_device(cam->input); | 250 | input_free_device(cam->input); |
| 249 | cam->input = NULL; | 251 | cam->input = NULL; |
| 250 | } | 252 | } |
diff --git a/drivers/media/video/usbvideo/quickcam_messenger.c b/drivers/media/video/usbvideo/quickcam_messenger.c index 05c61b523115..4459b8a7f818 100644 --- a/drivers/media/video/usbvideo/quickcam_messenger.c +++ b/drivers/media/video/usbvideo/quickcam_messenger.c | |||
| @@ -93,7 +93,7 @@ static void qcm_register_input(struct qcm *cam, struct usb_device *dev) | |||
| 93 | 93 | ||
| 94 | cam->input = input_dev = input_allocate_device(); | 94 | cam->input = input_dev = input_allocate_device(); |
| 95 | if (!input_dev) { | 95 | if (!input_dev) { |
| 96 | warn("insufficient mem for cam input device"); | 96 | dev_warn(&dev->dev, "insufficient mem for cam input device\n"); |
| 97 | return; | 97 | return; |
| 98 | } | 98 | } |
| 99 | 99 | ||
| @@ -107,8 +107,9 @@ static void qcm_register_input(struct qcm *cam, struct usb_device *dev) | |||
| 107 | 107 | ||
| 108 | error = input_register_device(cam->input); | 108 | error = input_register_device(cam->input); |
| 109 | if (error) { | 109 | if (error) { |
| 110 | warn("Failed to register camera's input device, err: %d\n", | 110 | dev_warn(&dev->dev, |
| 111 | error); | 111 | "Failed to register camera's input device, err: %d\n", |
| 112 | error); | ||
| 112 | input_free_device(cam->input); | 113 | input_free_device(cam->input); |
| 113 | cam->input = NULL; | 114 | cam->input = NULL; |
| 114 | } | 115 | } |
| @@ -587,8 +588,9 @@ static int qcm_compress_iso(struct uvd *uvd, struct urb *dataurb) | |||
| 587 | dataurb->iso_frame_desc[i].offset; | 588 | dataurb->iso_frame_desc[i].offset; |
| 588 | 589 | ||
| 589 | if (st < 0) { | 590 | if (st < 0) { |
| 590 | warn("Data error: packet=%d. len=%d. status=%d.", | 591 | dev_warn(&uvd->dev->dev, |
| 591 | i, n, st); | 592 | "Data error: packet=%d. len=%d. status=%d.\n", |
| 593 | i, n, st); | ||
| 592 | uvd->stats.iso_err_count++; | 594 | uvd->stats.iso_err_count++; |
| 593 | continue; | 595 | continue; |
| 594 | } | 596 | } |
| @@ -699,7 +701,7 @@ static void qcm_stop_data(struct uvd *uvd) | |||
| 699 | 701 | ||
| 700 | ret = qcm_camera_off(uvd); | 702 | ret = qcm_camera_off(uvd); |
| 701 | if (ret) | 703 | if (ret) |
| 702 | warn("couldn't turn the cam off."); | 704 | dev_warn(&uvd->dev->dev, "couldn't turn the cam off.\n"); |
| 703 | 705 | ||
| 704 | uvd->streaming = 0; | 706 | uvd->streaming = 0; |
| 705 | 707 | ||
diff --git a/drivers/mtd/nand/alauda.c b/drivers/mtd/nand/alauda.c index 257937cd99bf..962380394855 100644 --- a/drivers/mtd/nand/alauda.c +++ b/drivers/mtd/nand/alauda.c | |||
| @@ -691,7 +691,7 @@ static int alauda_probe(struct usb_interface *interface, | |||
| 691 | al[0].port = ALAUDA_PORT_XD; | 691 | al[0].port = ALAUDA_PORT_XD; |
| 692 | al[1].port = ALAUDA_PORT_SM; | 692 | al[1].port = ALAUDA_PORT_SM; |
| 693 | 693 | ||
| 694 | info("alauda probed"); | 694 | dev_info(&interface->dev, "alauda probed\n"); |
| 695 | alauda_check_media(al); | 695 | alauda_check_media(al); |
| 696 | alauda_check_media(al+1); | 696 | alauda_check_media(al+1); |
| 697 | 697 | ||
| @@ -716,7 +716,7 @@ static void alauda_disconnect(struct usb_interface *interface) | |||
| 716 | if (al) | 716 | if (al) |
| 717 | kref_put(&al->kref, alauda_delete); | 717 | kref_put(&al->kref, alauda_delete); |
| 718 | 718 | ||
| 719 | info("alauda gone"); | 719 | dev_info(&interface->dev, "alauda gone"); |
| 720 | } | 720 | } |
| 721 | 721 | ||
| 722 | static struct usb_driver alauda_driver = { | 722 | static struct usb_driver alauda_driver = { |
diff --git a/drivers/net/irda/kingsun-sir.c b/drivers/net/irda/kingsun-sir.c index 73fe83be34fe..e1429fc6d050 100644 --- a/drivers/net/irda/kingsun-sir.c +++ b/drivers/net/irda/kingsun-sir.c | |||
| @@ -540,7 +540,8 @@ static int kingsun_probe(struct usb_interface *intf, | |||
| 540 | if (ret != 0) | 540 | if (ret != 0) |
| 541 | goto free_mem; | 541 | goto free_mem; |
| 542 | 542 | ||
| 543 | info("IrDA: Registered KingSun/DonShine device %s", net->name); | 543 | dev_info(&net->dev, "IrDA: Registered KingSun/DonShine device %s\n", |
| 544 | net->name); | ||
| 544 | 545 | ||
| 545 | usb_set_intfdata(intf, kingsun); | 546 | usb_set_intfdata(intf, kingsun); |
| 546 | 547 | ||
diff --git a/drivers/net/irda/ks959-sir.c b/drivers/net/irda/ks959-sir.c index 8c257a51341a..2482d61662a2 100644 --- a/drivers/net/irda/ks959-sir.c +++ b/drivers/net/irda/ks959-sir.c | |||
| @@ -801,7 +801,8 @@ static int ks959_probe(struct usb_interface *intf, | |||
| 801 | if (ret != 0) | 801 | if (ret != 0) |
| 802 | goto free_mem; | 802 | goto free_mem; |
| 803 | 803 | ||
| 804 | info("IrDA: Registered KingSun KS-959 device %s", net->name); | 804 | dev_info(&net->dev, "IrDA: Registered KingSun KS-959 device %s\n", |
| 805 | net->name); | ||
| 805 | 806 | ||
| 806 | usb_set_intfdata(intf, kingsun); | 807 | usb_set_intfdata(intf, kingsun); |
| 807 | 808 | ||
diff --git a/drivers/net/irda/ksdazzle-sir.c b/drivers/net/irda/ksdazzle-sir.c index d01a28593ce2..1e0de93fd618 100644 --- a/drivers/net/irda/ksdazzle-sir.c +++ b/drivers/net/irda/ksdazzle-sir.c | |||
| @@ -705,7 +705,8 @@ static int ksdazzle_probe(struct usb_interface *intf, | |||
| 705 | if (ret != 0) | 705 | if (ret != 0) |
| 706 | goto free_mem; | 706 | goto free_mem; |
| 707 | 707 | ||
| 708 | info("IrDA: Registered KingSun/Dazzle device %s", net->name); | 708 | dev_info(&net->dev, "IrDA: Registered KingSun/Dazzle device %s\n", |
| 709 | net->name); | ||
| 709 | 710 | ||
| 710 | usb_set_intfdata(intf, kingsun); | 711 | usb_set_intfdata(intf, kingsun); |
| 711 | 712 | ||
diff --git a/drivers/net/irda/stir4200.c b/drivers/net/irda/stir4200.c index 051963782749..3575804fd7c6 100644 --- a/drivers/net/irda/stir4200.c +++ b/drivers/net/irda/stir4200.c | |||
| @@ -506,7 +506,7 @@ static int change_speed(struct stir_cb *stir, unsigned speed) | |||
| 506 | goto found; | 506 | goto found; |
| 507 | } | 507 | } |
| 508 | 508 | ||
| 509 | warn("%s: invalid speed %d", stir->netdev->name, speed); | 509 | dev_warn(&stir->netdev->dev, "invalid speed %d\n", speed); |
| 510 | return -EINVAL; | 510 | return -EINVAL; |
| 511 | 511 | ||
| 512 | found: | 512 | found: |
| @@ -598,8 +598,8 @@ static int fifo_txwait(struct stir_cb *stir, int space) | |||
| 598 | err = read_reg(stir, REG_FIFOCTL, stir->fifo_status, | 598 | err = read_reg(stir, REG_FIFOCTL, stir->fifo_status, |
| 599 | FIFO_REGS_SIZE); | 599 | FIFO_REGS_SIZE); |
| 600 | if (unlikely(err != FIFO_REGS_SIZE)) { | 600 | if (unlikely(err != FIFO_REGS_SIZE)) { |
| 601 | warn("%s: FIFO register read error: %d", | 601 | dev_warn(&stir->netdev->dev, |
| 602 | stir->netdev->name, err); | 602 | "FIFO register read error: %d\n", err); |
| 603 | 603 | ||
| 604 | return err; | 604 | return err; |
| 605 | } | 605 | } |
| @@ -783,8 +783,9 @@ static int stir_transmit_thread(void *arg) | |||
| 783 | 783 | ||
| 784 | if (unlikely(receive_start(stir))) { | 784 | if (unlikely(receive_start(stir))) { |
| 785 | if (net_ratelimit()) | 785 | if (net_ratelimit()) |
| 786 | info("%s: receive usb submit failed", | 786 | dev_info(&dev->dev, |
| 787 | stir->netdev->name); | 787 | "%s: receive usb submit failed\n", |
| 788 | stir->netdev->name); | ||
| 788 | stir->receiving = 0; | 789 | stir->receiving = 0; |
| 789 | msleep(10); | 790 | msleep(10); |
| 790 | continue; | 791 | continue; |
| @@ -836,8 +837,8 @@ static void stir_rcv_irq(struct urb *urb) | |||
| 836 | 837 | ||
| 837 | /* in case of error, the kernel thread will restart us */ | 838 | /* in case of error, the kernel thread will restart us */ |
| 838 | if (err) { | 839 | if (err) { |
| 839 | warn("%s: usb receive submit error: %d", | 840 | dev_warn(&stir->netdev->dev, "usb receive submit error: %d\n", |
| 840 | stir->netdev->name, err); | 841 | err); |
| 841 | stir->receiving = 0; | 842 | stir->receiving = 0; |
| 842 | wake_up_process(stir->thread); | 843 | wake_up_process(stir->thread); |
| 843 | } | 844 | } |
| @@ -1073,7 +1074,8 @@ static int stir_probe(struct usb_interface *intf, | |||
| 1073 | if (ret != 0) | 1074 | if (ret != 0) |
| 1074 | goto err_out2; | 1075 | goto err_out2; |
| 1075 | 1076 | ||
| 1076 | info("IrDA: Registered SigmaTel device %s", net->name); | 1077 | dev_info(&intf->dev, "IrDA: Registered SigmaTel device %s\n", |
| 1078 | net->name); | ||
| 1077 | 1079 | ||
| 1078 | usb_set_intfdata(intf, stir); | 1080 | usb_set_intfdata(intf, stir); |
| 1079 | 1081 | ||
diff --git a/drivers/net/usb/catc.c b/drivers/net/usb/catc.c index 22c17bbacb69..466a89e24444 100644 --- a/drivers/net/usb/catc.c +++ b/drivers/net/usb/catc.c | |||
| @@ -456,7 +456,7 @@ static void catc_tx_timeout(struct net_device *netdev) | |||
| 456 | { | 456 | { |
| 457 | struct catc *catc = netdev_priv(netdev); | 457 | struct catc *catc = netdev_priv(netdev); |
| 458 | 458 | ||
| 459 | warn("Transmit timed out."); | 459 | dev_warn(&netdev->dev, "Transmit timed out.\n"); |
| 460 | usb_unlink_urb(catc->tx_urb); | 460 | usb_unlink_urb(catc->tx_urb); |
| 461 | } | 461 | } |
| 462 | 462 | ||
| @@ -847,7 +847,8 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id | |||
| 847 | dbg("64k Memory\n"); | 847 | dbg("64k Memory\n"); |
| 848 | break; | 848 | break; |
| 849 | default: | 849 | default: |
| 850 | warn("Couldn't detect memory size, assuming 32k"); | 850 | dev_warn(&intf->dev, |
| 851 | "Couldn't detect memory size, assuming 32k\n"); | ||
| 851 | case 0x87654321: | 852 | case 0x87654321: |
| 852 | catc_set_reg(catc, TxBufCount, 4); | 853 | catc_set_reg(catc, TxBufCount, 4); |
| 853 | catc_set_reg(catc, RxBufCount, 16); | 854 | catc_set_reg(catc, RxBufCount, 16); |
| @@ -953,7 +954,8 @@ static int __init catc_init(void) | |||
| 953 | { | 954 | { |
| 954 | int result = usb_register(&catc_driver); | 955 | int result = usb_register(&catc_driver); |
| 955 | if (result == 0) | 956 | if (result == 0) |
| 956 | info(DRIVER_VERSION " " DRIVER_DESC); | 957 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
| 958 | DRIVER_DESC "\n"); | ||
| 957 | return result; | 959 | return result; |
| 958 | } | 960 | } |
| 959 | 961 | ||
diff --git a/drivers/net/usb/kaweth.c b/drivers/net/usb/kaweth.c index d6829db51b45..fdbf3be24fda 100644 --- a/drivers/net/usb/kaweth.c +++ b/drivers/net/usb/kaweth.c | |||
| @@ -832,7 +832,7 @@ static int kaweth_start_xmit(struct sk_buff *skb, struct net_device *net) | |||
| 832 | 832 | ||
| 833 | if((res = usb_submit_urb(kaweth->tx_urb, GFP_ATOMIC))) | 833 | if((res = usb_submit_urb(kaweth->tx_urb, GFP_ATOMIC))) |
| 834 | { | 834 | { |
| 835 | warn("kaweth failed tx_urb %d", res); | 835 | dev_warn(&net->dev, "kaweth failed tx_urb %d\n", res); |
| 836 | skip: | 836 | skip: |
| 837 | kaweth->stats.tx_errors++; | 837 | kaweth->stats.tx_errors++; |
| 838 | 838 | ||
| @@ -924,7 +924,7 @@ static void kaweth_tx_timeout(struct net_device *net) | |||
| 924 | { | 924 | { |
| 925 | struct kaweth_device *kaweth = netdev_priv(net); | 925 | struct kaweth_device *kaweth = netdev_priv(net); |
| 926 | 926 | ||
| 927 | warn("%s: Tx timed out. Resetting.", net->name); | 927 | dev_warn(&net->dev, "%s: Tx timed out. Resetting.\n", net->name); |
| 928 | kaweth->stats.tx_errors++; | 928 | kaweth->stats.tx_errors++; |
| 929 | net->trans_start = jiffies; | 929 | net->trans_start = jiffies; |
| 930 | 930 | ||
| @@ -1016,10 +1016,10 @@ static int kaweth_probe( | |||
| 1016 | */ | 1016 | */ |
| 1017 | 1017 | ||
| 1018 | if (le16_to_cpu(dev->descriptor.bcdDevice) >> 8) { | 1018 | if (le16_to_cpu(dev->descriptor.bcdDevice) >> 8) { |
| 1019 | info("Firmware present in device."); | 1019 | dev_info(&intf->dev, "Firmware present in device.\n"); |
| 1020 | } else { | 1020 | } else { |
| 1021 | /* Download the firmware */ | 1021 | /* Download the firmware */ |
| 1022 | info("Downloading firmware..."); | 1022 | dev_info(&intf->dev, "Downloading firmware...\n"); |
| 1023 | kaweth->firmware_buf = (__u8 *)__get_free_page(GFP_KERNEL); | 1023 | kaweth->firmware_buf = (__u8 *)__get_free_page(GFP_KERNEL); |
| 1024 | if ((result = kaweth_download_firmware(kaweth, | 1024 | if ((result = kaweth_download_firmware(kaweth, |
| 1025 | "kaweth/new_code.bin", | 1025 | "kaweth/new_code.bin", |
| @@ -1061,7 +1061,7 @@ static int kaweth_probe( | |||
| 1061 | } | 1061 | } |
| 1062 | 1062 | ||
| 1063 | /* Device will now disappear for a moment... */ | 1063 | /* Device will now disappear for a moment... */ |
| 1064 | info("Firmware loaded. I'll be back..."); | 1064 | dev_info(&intf->dev, "Firmware loaded. I'll be back...\n"); |
| 1065 | err_fw: | 1065 | err_fw: |
| 1066 | free_page((unsigned long)kaweth->firmware_buf); | 1066 | free_page((unsigned long)kaweth->firmware_buf); |
| 1067 | free_netdev(netdev); | 1067 | free_netdev(netdev); |
| @@ -1075,10 +1075,10 @@ err_fw: | |||
| 1075 | goto err_free_netdev; | 1075 | goto err_free_netdev; |
| 1076 | } | 1076 | } |
| 1077 | 1077 | ||
| 1078 | info("Statistics collection: %x", kaweth->configuration.statistics_mask); | 1078 | dev_info(&intf->dev, "Statistics collection: %x\n", kaweth->configuration.statistics_mask); |
| 1079 | info("Multicast filter limit: %x", kaweth->configuration.max_multicast_filters & ((1 << 15) - 1)); | 1079 | dev_info(&intf->dev, "Multicast filter limit: %x\n", kaweth->configuration.max_multicast_filters & ((1 << 15) - 1)); |
| 1080 | info("MTU: %d", le16_to_cpu(kaweth->configuration.segment_size)); | 1080 | dev_info(&intf->dev, "MTU: %d\n", le16_to_cpu(kaweth->configuration.segment_size)); |
| 1081 | info("Read MAC address %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x", | 1081 | dev_info(&intf->dev, "Read MAC address %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x\n", |
| 1082 | (int)kaweth->configuration.hw_addr[0], | 1082 | (int)kaweth->configuration.hw_addr[0], |
| 1083 | (int)kaweth->configuration.hw_addr[1], | 1083 | (int)kaweth->configuration.hw_addr[1], |
| 1084 | (int)kaweth->configuration.hw_addr[2], | 1084 | (int)kaweth->configuration.hw_addr[2], |
| @@ -1174,7 +1174,8 @@ err_fw: | |||
| 1174 | goto err_intfdata; | 1174 | goto err_intfdata; |
| 1175 | } | 1175 | } |
| 1176 | 1176 | ||
| 1177 | info("kaweth interface created at %s", kaweth->net->name); | 1177 | dev_info(&intf->dev, "kaweth interface created at %s\n", |
| 1178 | kaweth->net->name); | ||
| 1178 | 1179 | ||
| 1179 | dbg("Kaweth probe returning."); | 1180 | dbg("Kaweth probe returning."); |
| 1180 | 1181 | ||
| @@ -1205,11 +1206,11 @@ static void kaweth_disconnect(struct usb_interface *intf) | |||
| 1205 | struct kaweth_device *kaweth = usb_get_intfdata(intf); | 1206 | struct kaweth_device *kaweth = usb_get_intfdata(intf); |
| 1206 | struct net_device *netdev; | 1207 | struct net_device *netdev; |
| 1207 | 1208 | ||
| 1208 | info("Unregistering"); | 1209 | dev_info(&intf->dev, "Unregistering\n"); |
| 1209 | 1210 | ||
| 1210 | usb_set_intfdata(intf, NULL); | 1211 | usb_set_intfdata(intf, NULL); |
| 1211 | if (!kaweth) { | 1212 | if (!kaweth) { |
| 1212 | warn("unregistering non-existant device"); | 1213 | dev_warn(&intf->dev, "unregistering non-existant device\n"); |
| 1213 | return; | 1214 | return; |
| 1214 | } | 1215 | } |
| 1215 | netdev = kaweth->net; | 1216 | netdev = kaweth->net; |
| @@ -1269,7 +1270,7 @@ static int usb_start_wait_urb(struct urb *urb, int timeout, int* actual_length) | |||
| 1269 | 1270 | ||
| 1270 | if (!wait_event_timeout(awd.wqh, awd.done, timeout)) { | 1271 | if (!wait_event_timeout(awd.wqh, awd.done, timeout)) { |
| 1271 | // timeout | 1272 | // timeout |
| 1272 | warn("usb_control/bulk_msg: timeout"); | 1273 | dev_warn(&urb->dev->dev, "usb_control/bulk_msg: timeout\n"); |
| 1273 | usb_kill_urb(urb); // remove urb safely | 1274 | usb_kill_urb(urb); // remove urb safely |
| 1274 | status = -ETIMEDOUT; | 1275 | status = -ETIMEDOUT; |
| 1275 | } | 1276 | } |
diff --git a/drivers/net/usb/rtl8150.c b/drivers/net/usb/rtl8150.c index df56a518691c..6133401ebc67 100644 --- a/drivers/net/usb/rtl8150.c +++ b/drivers/net/usb/rtl8150.c | |||
| @@ -221,7 +221,7 @@ static void ctrl_callback(struct urb *urb) | |||
| 221 | case -ENOENT: | 221 | case -ENOENT: |
| 222 | break; | 222 | break; |
| 223 | default: | 223 | default: |
| 224 | warn("ctrl urb status %d", urb->status); | 224 | dev_warn(&urb->dev->dev, "ctrl urb status %d\n", urb->status); |
| 225 | } | 225 | } |
| 226 | dev = urb->context; | 226 | dev = urb->context; |
| 227 | clear_bit(RX_REG_SET, &dev->flags); | 227 | clear_bit(RX_REG_SET, &dev->flags); |
| @@ -441,10 +441,10 @@ static void read_bulk_callback(struct urb *urb) | |||
| 441 | case -ENOENT: | 441 | case -ENOENT: |
| 442 | return; /* the urb is in unlink state */ | 442 | return; /* the urb is in unlink state */ |
| 443 | case -ETIME: | 443 | case -ETIME: |
| 444 | warn("may be reset is needed?.."); | 444 | dev_warn(&urb->dev->dev, "may be reset is needed?..\n"); |
| 445 | goto goon; | 445 | goto goon; |
| 446 | default: | 446 | default: |
| 447 | warn("Rx status %d", urb->status); | 447 | dev_warn(&urb->dev->dev, "Rx status %d\n", urb->status); |
| 448 | goto goon; | 448 | goto goon; |
| 449 | } | 449 | } |
| 450 | 450 | ||
| @@ -538,7 +538,8 @@ static void write_bulk_callback(struct urb *urb) | |||
| 538 | if (!netif_device_present(dev->netdev)) | 538 | if (!netif_device_present(dev->netdev)) |
| 539 | return; | 539 | return; |
| 540 | if (urb->status) | 540 | if (urb->status) |
| 541 | info("%s: Tx status %d", dev->netdev->name, urb->status); | 541 | dev_info(&urb->dev->dev, "%s: Tx status %d\n", |
| 542 | dev->netdev->name, urb->status); | ||
| 542 | dev->netdev->trans_start = jiffies; | 543 | dev->netdev->trans_start = jiffies; |
| 543 | netif_wake_queue(dev->netdev); | 544 | netif_wake_queue(dev->netdev); |
| 544 | } | 545 | } |
| @@ -561,7 +562,8 @@ static void intr_callback(struct urb *urb) | |||
| 561 | return; | 562 | return; |
| 562 | /* -EPIPE: should clear the halt */ | 563 | /* -EPIPE: should clear the halt */ |
| 563 | default: | 564 | default: |
| 564 | info("%s: intr status %d", dev->netdev->name, urb->status); | 565 | dev_info(&urb->dev->dev, "%s: intr status %d\n", |
| 566 | dev->netdev->name, urb->status); | ||
| 565 | goto resubmit; | 567 | goto resubmit; |
| 566 | } | 568 | } |
| 567 | 569 | ||
| @@ -665,7 +667,7 @@ static int enable_net_traffic(rtl8150_t * dev) | |||
| 665 | u8 cr, tcr, rcr, msr; | 667 | u8 cr, tcr, rcr, msr; |
| 666 | 668 | ||
| 667 | if (!rtl8150_reset(dev)) { | 669 | if (!rtl8150_reset(dev)) { |
| 668 | warn("%s - device reset failed", __FUNCTION__); | 670 | dev_warn(&dev->udev->dev, "device reset failed\n"); |
| 669 | } | 671 | } |
| 670 | /* RCR bit7=1 attach Rx info at the end; =0 HW CRC (which is broken) */ | 672 | /* RCR bit7=1 attach Rx info at the end; =0 HW CRC (which is broken) */ |
| 671 | rcr = 0x9e; | 673 | rcr = 0x9e; |
| @@ -699,7 +701,7 @@ static struct net_device_stats *rtl8150_netdev_stats(struct net_device *dev) | |||
| 699 | static void rtl8150_tx_timeout(struct net_device *netdev) | 701 | static void rtl8150_tx_timeout(struct net_device *netdev) |
| 700 | { | 702 | { |
| 701 | rtl8150_t *dev = netdev_priv(netdev); | 703 | rtl8150_t *dev = netdev_priv(netdev); |
| 702 | warn("%s: Tx timeout.", netdev->name); | 704 | dev_warn(&netdev->dev, "Tx timeout.\n"); |
| 703 | usb_unlink_urb(dev->tx_urb); | 705 | usb_unlink_urb(dev->tx_urb); |
| 704 | dev->stats.tx_errors++; | 706 | dev->stats.tx_errors++; |
| 705 | } | 707 | } |
| @@ -710,12 +712,12 @@ static void rtl8150_set_multicast(struct net_device *netdev) | |||
| 710 | netif_stop_queue(netdev); | 712 | netif_stop_queue(netdev); |
| 711 | if (netdev->flags & IFF_PROMISC) { | 713 | if (netdev->flags & IFF_PROMISC) { |
| 712 | dev->rx_creg |= cpu_to_le16(0x0001); | 714 | dev->rx_creg |= cpu_to_le16(0x0001); |
| 713 | info("%s: promiscuous mode", netdev->name); | 715 | dev_info(&netdev->dev, "%s: promiscuous mode\n", netdev->name); |
| 714 | } else if (netdev->mc_count || | 716 | } else if (netdev->mc_count || |
| 715 | (netdev->flags & IFF_ALLMULTI)) { | 717 | (netdev->flags & IFF_ALLMULTI)) { |
| 716 | dev->rx_creg &= cpu_to_le16(0xfffe); | 718 | dev->rx_creg &= cpu_to_le16(0xfffe); |
| 717 | dev->rx_creg |= cpu_to_le16(0x0002); | 719 | dev->rx_creg |= cpu_to_le16(0x0002); |
| 718 | info("%s: allmulti set", netdev->name); | 720 | dev_info(&netdev->dev, "%s: allmulti set\n", netdev->name); |
| 719 | } else { | 721 | } else { |
| 720 | /* ~RX_MULTICAST, ~RX_PROMISCUOUS */ | 722 | /* ~RX_MULTICAST, ~RX_PROMISCUOUS */ |
| 721 | dev->rx_creg &= cpu_to_le16(0x00fc); | 723 | dev->rx_creg &= cpu_to_le16(0x00fc); |
| @@ -740,7 +742,7 @@ static int rtl8150_start_xmit(struct sk_buff *skb, struct net_device *netdev) | |||
| 740 | if (res == -ENODEV) | 742 | if (res == -ENODEV) |
| 741 | netif_device_detach(dev->netdev); | 743 | netif_device_detach(dev->netdev); |
| 742 | else { | 744 | else { |
| 743 | warn("failed tx_urb %d\n", res); | 745 | dev_warn(&netdev->dev, "failed tx_urb %d\n", res); |
| 744 | dev->stats.tx_errors++; | 746 | dev->stats.tx_errors++; |
| 745 | netif_start_queue(netdev); | 747 | netif_start_queue(netdev); |
| 746 | } | 748 | } |
| @@ -783,7 +785,7 @@ static int rtl8150_open(struct net_device *netdev) | |||
| 783 | if ((res = usb_submit_urb(dev->rx_urb, GFP_KERNEL))) { | 785 | if ((res = usb_submit_urb(dev->rx_urb, GFP_KERNEL))) { |
| 784 | if (res == -ENODEV) | 786 | if (res == -ENODEV) |
| 785 | netif_device_detach(dev->netdev); | 787 | netif_device_detach(dev->netdev); |
| 786 | warn("%s: rx_urb submit failed: %d", __FUNCTION__, res); | 788 | dev_warn(&netdev->dev, "rx_urb submit failed: %d\n", res); |
| 787 | return res; | 789 | return res; |
| 788 | } | 790 | } |
| 789 | usb_fill_int_urb(dev->intr_urb, dev->udev, usb_rcvintpipe(dev->udev, 3), | 791 | usb_fill_int_urb(dev->intr_urb, dev->udev, usb_rcvintpipe(dev->udev, 3), |
| @@ -792,7 +794,7 @@ static int rtl8150_open(struct net_device *netdev) | |||
| 792 | if ((res = usb_submit_urb(dev->intr_urb, GFP_KERNEL))) { | 794 | if ((res = usb_submit_urb(dev->intr_urb, GFP_KERNEL))) { |
| 793 | if (res == -ENODEV) | 795 | if (res == -ENODEV) |
| 794 | netif_device_detach(dev->netdev); | 796 | netif_device_detach(dev->netdev); |
| 795 | warn("%s: intr_urb submit failed: %d", __FUNCTION__, res); | 797 | dev_warn(&netdev->dev, "intr_urb submit failed: %d\n", res); |
| 796 | usb_kill_urb(dev->rx_urb); | 798 | usb_kill_urb(dev->rx_urb); |
| 797 | return res; | 799 | return res; |
| 798 | } | 800 | } |
| @@ -947,7 +949,7 @@ static int rtl8150_probe(struct usb_interface *intf, | |||
| 947 | goto out2; | 949 | goto out2; |
| 948 | } | 950 | } |
| 949 | 951 | ||
| 950 | info("%s: rtl8150 is detected", netdev->name); | 952 | dev_info(&intf->dev, "%s: rtl8150 is detected\n", netdev->name); |
| 951 | 953 | ||
| 952 | return 0; | 954 | return 0; |
| 953 | 955 | ||
| @@ -984,7 +986,8 @@ static void rtl8150_disconnect(struct usb_interface *intf) | |||
| 984 | 986 | ||
| 985 | static int __init usb_rtl8150_init(void) | 987 | static int __init usb_rtl8150_init(void) |
| 986 | { | 988 | { |
| 987 | info(DRIVER_DESC " " DRIVER_VERSION); | 989 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
| 990 | DRIVER_DESC "\n"); | ||
| 988 | return usb_register(&rtl8150_driver); | 991 | return usb_register(&rtl8150_driver); |
| 989 | } | 992 | } |
| 990 | 993 | ||
diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c index 0da2c25bab3b..06dd114910d4 100644 --- a/drivers/usb/atm/usbatm.c +++ b/drivers/usb/atm/usbatm.c | |||
| @@ -344,7 +344,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char | |||
| 344 | __func__, sarb->len, vcc); | 344 | __func__, sarb->len, vcc); |
| 345 | /* discard cells already received */ | 345 | /* discard cells already received */ |
| 346 | skb_trim(sarb, 0); | 346 | skb_trim(sarb, 0); |
| 347 | UDSL_ASSERT(sarb->tail + ATM_CELL_PAYLOAD <= sarb->end); | 347 | UDSL_ASSERT(instance, sarb->tail + ATM_CELL_PAYLOAD <= sarb->end); |
| 348 | } | 348 | } |
| 349 | 349 | ||
| 350 | memcpy(skb_tail_pointer(sarb), source + ATM_CELL_HEADER, ATM_CELL_PAYLOAD); | 350 | memcpy(skb_tail_pointer(sarb), source + ATM_CELL_HEADER, ATM_CELL_PAYLOAD); |
| @@ -432,7 +432,7 @@ static void usbatm_extract_cells(struct usbatm_data *instance, | |||
| 432 | unsigned char *cell_buf = instance->cell_buf; | 432 | unsigned char *cell_buf = instance->cell_buf; |
| 433 | unsigned int space_left = stride - buf_usage; | 433 | unsigned int space_left = stride - buf_usage; |
| 434 | 434 | ||
| 435 | UDSL_ASSERT(buf_usage <= stride); | 435 | UDSL_ASSERT(instance, buf_usage <= stride); |
| 436 | 436 | ||
| 437 | if (avail_data >= space_left) { | 437 | if (avail_data >= space_left) { |
| 438 | /* add new data and process cell */ | 438 | /* add new data and process cell */ |
| @@ -475,7 +475,7 @@ static unsigned int usbatm_write_cells(struct usbatm_data *instance, | |||
| 475 | unsigned int stride = instance->tx_channel.stride; | 475 | unsigned int stride = instance->tx_channel.stride; |
| 476 | 476 | ||
| 477 | vdbg("%s: skb->len=%d, avail_space=%u", __func__, skb->len, avail_space); | 477 | vdbg("%s: skb->len=%d, avail_space=%u", __func__, skb->len, avail_space); |
| 478 | UDSL_ASSERT(!(avail_space % stride)); | 478 | UDSL_ASSERT(instance, !(avail_space % stride)); |
| 479 | 479 | ||
| 480 | for (bytes_written = 0; bytes_written < avail_space && ctrl->len; | 480 | for (bytes_written = 0; bytes_written < avail_space && ctrl->len; |
| 481 | bytes_written += stride, target += stride) { | 481 | bytes_written += stride, target += stride) { |
| @@ -547,7 +547,7 @@ static void usbatm_rx_process(unsigned long data) | |||
| 547 | if (!urb->iso_frame_desc[i].status) { | 547 | if (!urb->iso_frame_desc[i].status) { |
| 548 | unsigned int actual_length = urb->iso_frame_desc[i].actual_length; | 548 | unsigned int actual_length = urb->iso_frame_desc[i].actual_length; |
| 549 | 549 | ||
| 550 | UDSL_ASSERT(actual_length <= packet_size); | 550 | UDSL_ASSERT(instance, actual_length <= packet_size); |
| 551 | 551 | ||
| 552 | if (!merge_length) | 552 | if (!merge_length) |
| 553 | merge_start = (unsigned char *)urb->transfer_buffer + urb->iso_frame_desc[i].offset; | 553 | merge_start = (unsigned char *)urb->transfer_buffer + urb->iso_frame_desc[i].offset; |
| @@ -1188,7 +1188,7 @@ int usbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id, | |||
| 1188 | struct urb *urb; | 1188 | struct urb *urb; |
| 1189 | unsigned int iso_packets = usb_pipeisoc(channel->endpoint) ? channel->buf_size / channel->packet_size : 0; | 1189 | unsigned int iso_packets = usb_pipeisoc(channel->endpoint) ? channel->buf_size / channel->packet_size : 0; |
| 1190 | 1190 | ||
| 1191 | UDSL_ASSERT(!usb_pipeisoc(channel->endpoint) || usb_pipein(channel->endpoint)); | 1191 | UDSL_ASSERT(instance, !usb_pipeisoc(channel->endpoint) || usb_pipein(channel->endpoint)); |
| 1192 | 1192 | ||
| 1193 | urb = usb_alloc_urb(iso_packets, GFP_KERNEL); | 1193 | urb = usb_alloc_urb(iso_packets, GFP_KERNEL); |
| 1194 | if (!urb) { | 1194 | if (!urb) { |
diff --git a/drivers/usb/atm/usbatm.h b/drivers/usb/atm/usbatm.h index e6887c6cf3cf..f6f4508a9d42 100644 --- a/drivers/usb/atm/usbatm.h +++ b/drivers/usb/atm/usbatm.h | |||
| @@ -40,9 +40,15 @@ | |||
| 40 | */ | 40 | */ |
| 41 | 41 | ||
| 42 | #ifdef DEBUG | 42 | #ifdef DEBUG |
| 43 | #define UDSL_ASSERT(x) BUG_ON(!(x)) | 43 | #define UDSL_ASSERT(instance, x) BUG_ON(!(x)) |
| 44 | #else | 44 | #else |
| 45 | #define UDSL_ASSERT(x) do { if (!(x)) warn("failed assertion '%s' at line %d", __stringify(x), __LINE__); } while(0) | 45 | #define UDSL_ASSERT(instance, x) \ |
| 46 | do { \ | ||
| 47 | if (!(x)) \ | ||
| 48 | dev_warn(&(instance)->usb_intf->dev, \ | ||
| 49 | "failed assertion '%s' at line %d", \ | ||
| 50 | __stringify(x), __LINE__); \ | ||
| 51 | } while(0) | ||
| 46 | #endif | 52 | #endif |
| 47 | 53 | ||
| 48 | #define usb_err(instance, format, arg...) \ | 54 | #define usb_err(instance, format, arg...) \ |
diff --git a/drivers/usb/atm/xusbatm.c b/drivers/usb/atm/xusbatm.c index 8472543eee81..17d167bbd2dc 100644 --- a/drivers/usb/atm/xusbatm.c +++ b/drivers/usb/atm/xusbatm.c | |||
| @@ -193,7 +193,7 @@ static int __init xusbatm_init(void) | |||
| 193 | num_vendor != num_product || | 193 | num_vendor != num_product || |
| 194 | num_vendor != num_rx_endpoint || | 194 | num_vendor != num_rx_endpoint || |
| 195 | num_vendor != num_tx_endpoint) { | 195 | num_vendor != num_tx_endpoint) { |
| 196 | warn("malformed module parameters"); | 196 | printk(KERN_WARNING "xusbatm: malformed module parameters\n"); |
| 197 | return -EINVAL; | 197 | return -EINVAL; |
| 198 | } | 198 | } |
| 199 | 199 | ||
diff --git a/drivers/usb/class/Kconfig b/drivers/usb/class/Kconfig index 66f17ed88cb5..2519e320098f 100644 --- a/drivers/usb/class/Kconfig +++ b/drivers/usb/class/Kconfig | |||
| @@ -40,3 +40,13 @@ config USB_WDM | |||
| 40 | To compile this driver as a module, choose M here: the | 40 | To compile this driver as a module, choose M here: the |
| 41 | module will be called cdc-wdm. | 41 | module will be called cdc-wdm. |
| 42 | 42 | ||
| 43 | config USB_TMC | ||
| 44 | tristate "USB Test and Measurement Class support" | ||
| 45 | depends on USB | ||
| 46 | help | ||
| 47 | Say Y here if you want to connect a USB device that follows | ||
| 48 | the USB.org specification for USB Test and Measurement devices | ||
| 49 | to your computer's USB port. | ||
| 50 | |||
| 51 | To compile this driver as a module, choose M here: the | ||
| 52 | module will be called usbtmc. | ||
diff --git a/drivers/usb/class/Makefile b/drivers/usb/class/Makefile index 535d59a30600..32e85277b5cf 100644 --- a/drivers/usb/class/Makefile +++ b/drivers/usb/class/Makefile | |||
| @@ -6,3 +6,4 @@ | |||
| 6 | obj-$(CONFIG_USB_ACM) += cdc-acm.o | 6 | obj-$(CONFIG_USB_ACM) += cdc-acm.o |
| 7 | obj-$(CONFIG_USB_PRINTER) += usblp.o | 7 | obj-$(CONFIG_USB_PRINTER) += usblp.o |
| 8 | obj-$(CONFIG_USB_WDM) += cdc-wdm.o | 8 | obj-$(CONFIG_USB_WDM) += cdc-wdm.o |
| 9 | obj-$(CONFIG_USB_TMC) += usbtmc.o | ||
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c index c257453fa9de..fab23ee8702b 100644 --- a/drivers/usb/class/cdc-acm.c +++ b/drivers/usb/class/cdc-acm.c | |||
| @@ -326,8 +326,8 @@ exit: | |||
| 326 | usb_mark_last_busy(acm->dev); | 326 | usb_mark_last_busy(acm->dev); |
| 327 | retval = usb_submit_urb (urb, GFP_ATOMIC); | 327 | retval = usb_submit_urb (urb, GFP_ATOMIC); |
| 328 | if (retval) | 328 | if (retval) |
| 329 | err ("%s - usb_submit_urb failed with result %d", | 329 | dev_err(&urb->dev->dev, "%s - usb_submit_urb failed with " |
| 330 | __func__, retval); | 330 | "result %d", __func__, retval); |
| 331 | } | 331 | } |
| 332 | 332 | ||
| 333 | /* data interface returns incoming bytes, or we got unthrottled */ | 333 | /* data interface returns incoming bytes, or we got unthrottled */ |
| @@ -514,7 +514,7 @@ static void acm_waker(struct work_struct *waker) | |||
| 514 | 514 | ||
| 515 | rv = usb_autopm_get_interface(acm->control); | 515 | rv = usb_autopm_get_interface(acm->control); |
| 516 | if (rv < 0) { | 516 | if (rv < 0) { |
| 517 | err("Autopm failure in %s", __func__); | 517 | dev_err(&acm->dev->dev, "Autopm failure in %s\n", __func__); |
| 518 | return; | 518 | return; |
| 519 | } | 519 | } |
| 520 | if (acm->delayed_wb) { | 520 | if (acm->delayed_wb) { |
| @@ -924,7 +924,7 @@ static int acm_probe (struct usb_interface *intf, | |||
| 924 | 924 | ||
| 925 | /* normal probing*/ | 925 | /* normal probing*/ |
| 926 | if (!buffer) { | 926 | if (!buffer) { |
| 927 | err("Weird descriptor references\n"); | 927 | dev_err(&intf->dev, "Weird descriptor references\n"); |
| 928 | return -EINVAL; | 928 | return -EINVAL; |
| 929 | } | 929 | } |
| 930 | 930 | ||
| @@ -934,21 +934,24 @@ static int acm_probe (struct usb_interface *intf, | |||
| 934 | buflen = intf->cur_altsetting->endpoint->extralen; | 934 | buflen = intf->cur_altsetting->endpoint->extralen; |
| 935 | buffer = intf->cur_altsetting->endpoint->extra; | 935 | buffer = intf->cur_altsetting->endpoint->extra; |
| 936 | } else { | 936 | } else { |
| 937 | err("Zero length descriptor references\n"); | 937 | dev_err(&intf->dev, |
| 938 | "Zero length descriptor references\n"); | ||
| 938 | return -EINVAL; | 939 | return -EINVAL; |
| 939 | } | 940 | } |
| 940 | } | 941 | } |
| 941 | 942 | ||
| 942 | while (buflen > 0) { | 943 | while (buflen > 0) { |
| 943 | if (buffer [1] != USB_DT_CS_INTERFACE) { | 944 | if (buffer [1] != USB_DT_CS_INTERFACE) { |
| 944 | err("skipping garbage\n"); | 945 | dev_err(&intf->dev, "skipping garbage\n"); |
| 945 | goto next_desc; | 946 | goto next_desc; |
| 946 | } | 947 | } |
| 947 | 948 | ||
| 948 | switch (buffer [2]) { | 949 | switch (buffer [2]) { |
| 949 | case USB_CDC_UNION_TYPE: /* we've found it */ | 950 | case USB_CDC_UNION_TYPE: /* we've found it */ |
| 950 | if (union_header) { | 951 | if (union_header) { |
| 951 | err("More than one union descriptor, skipping ..."); | 952 | dev_err(&intf->dev, "More than one " |
| 953 | "union descriptor, " | ||
| 954 | "skipping ...\n"); | ||
| 952 | goto next_desc; | 955 | goto next_desc; |
| 953 | } | 956 | } |
| 954 | union_header = (struct usb_cdc_union_desc *) | 957 | union_header = (struct usb_cdc_union_desc *) |
| @@ -966,7 +969,9 @@ static int acm_probe (struct usb_interface *intf, | |||
| 966 | call_management_function = buffer[3]; | 969 | call_management_function = buffer[3]; |
| 967 | call_interface_num = buffer[4]; | 970 | call_interface_num = buffer[4]; |
| 968 | if ((call_management_function & 3) != 3) | 971 | if ((call_management_function & 3) != 3) |
| 969 | err("This device cannot do calls on its own. It is no modem."); | 972 | dev_err(&intf->dev, "This device " |
| 973 | "cannot do calls on its own. " | ||
| 974 | "It is no modem.\n"); | ||
| 970 | break; | 975 | break; |
| 971 | default: | 976 | default: |
| 972 | /* there are LOTS more CDC descriptors that | 977 | /* there are LOTS more CDC descriptors that |
| @@ -1051,7 +1056,7 @@ skip_normal_probe: | |||
| 1051 | for (minor = 0; minor < ACM_TTY_MINORS && acm_table[minor]; minor++); | 1056 | for (minor = 0; minor < ACM_TTY_MINORS && acm_table[minor]; minor++); |
| 1052 | 1057 | ||
| 1053 | if (minor == ACM_TTY_MINORS) { | 1058 | if (minor == ACM_TTY_MINORS) { |
| 1054 | err("no more free acm devices"); | 1059 | dev_err(&intf->dev, "no more free acm devices\n"); |
| 1055 | return -ENODEV; | 1060 | return -ENODEV; |
| 1056 | } | 1061 | } |
| 1057 | 1062 | ||
| @@ -1454,7 +1459,8 @@ static int __init acm_init(void) | |||
| 1454 | return retval; | 1459 | return retval; |
| 1455 | } | 1460 | } |
| 1456 | 1461 | ||
| 1457 | info(DRIVER_VERSION ":" DRIVER_DESC); | 1462 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
| 1463 | DRIVER_DESC "\n"); | ||
| 1458 | 1464 | ||
| 1459 | return 0; | 1465 | return 0; |
| 1460 | } | 1466 | } |
diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c index 7e8e1235e4e5..7429f70b9d06 100644 --- a/drivers/usb/class/cdc-wdm.c +++ b/drivers/usb/class/cdc-wdm.c | |||
| @@ -132,10 +132,12 @@ static void wdm_in_callback(struct urb *urb) | |||
| 132 | "nonzero urb status received: -ESHUTDOWN"); | 132 | "nonzero urb status received: -ESHUTDOWN"); |
| 133 | break; | 133 | break; |
| 134 | case -EPIPE: | 134 | case -EPIPE: |
| 135 | err("nonzero urb status received: -EPIPE"); | 135 | dev_err(&desc->intf->dev, |
| 136 | "nonzero urb status received: -EPIPE\n"); | ||
| 136 | break; | 137 | break; |
| 137 | default: | 138 | default: |
| 138 | err("Unexpected error %d", status); | 139 | dev_err(&desc->intf->dev, |
| 140 | "Unexpected error %d\n", status); | ||
| 139 | break; | 141 | break; |
| 140 | } | 142 | } |
| 141 | } | 143 | } |
| @@ -170,16 +172,18 @@ static void wdm_int_callback(struct urb *urb) | |||
| 170 | return; /* unplug */ | 172 | return; /* unplug */ |
| 171 | case -EPIPE: | 173 | case -EPIPE: |
| 172 | set_bit(WDM_INT_STALL, &desc->flags); | 174 | set_bit(WDM_INT_STALL, &desc->flags); |
| 173 | err("Stall on int endpoint"); | 175 | dev_err(&desc->intf->dev, "Stall on int endpoint\n"); |
| 174 | goto sw; /* halt is cleared in work */ | 176 | goto sw; /* halt is cleared in work */ |
| 175 | default: | 177 | default: |
| 176 | err("nonzero urb status received: %d", status); | 178 | dev_err(&desc->intf->dev, |
| 179 | "nonzero urb status received: %d\n", status); | ||
| 177 | break; | 180 | break; |
| 178 | } | 181 | } |
| 179 | } | 182 | } |
| 180 | 183 | ||
| 181 | if (urb->actual_length < sizeof(struct usb_cdc_notification)) { | 184 | if (urb->actual_length < sizeof(struct usb_cdc_notification)) { |
| 182 | err("wdm_int_callback - %d bytes", urb->actual_length); | 185 | dev_err(&desc->intf->dev, "wdm_int_callback - %d bytes\n", |
| 186 | urb->actual_length); | ||
| 183 | goto exit; | 187 | goto exit; |
| 184 | } | 188 | } |
| 185 | 189 | ||
| @@ -198,7 +202,8 @@ static void wdm_int_callback(struct urb *urb) | |||
| 198 | goto exit; | 202 | goto exit; |
| 199 | default: | 203 | default: |
| 200 | clear_bit(WDM_POLL_RUNNING, &desc->flags); | 204 | clear_bit(WDM_POLL_RUNNING, &desc->flags); |
| 201 | err("unknown notification %d received: index %d len %d", | 205 | dev_err(&desc->intf->dev, |
| 206 | "unknown notification %d received: index %d len %d\n", | ||
| 202 | dr->bNotificationType, dr->wIndex, dr->wLength); | 207 | dr->bNotificationType, dr->wIndex, dr->wLength); |
| 203 | goto exit; | 208 | goto exit; |
| 204 | } | 209 | } |
| @@ -236,14 +241,16 @@ static void wdm_int_callback(struct urb *urb) | |||
| 236 | sw: | 241 | sw: |
| 237 | rv = schedule_work(&desc->rxwork); | 242 | rv = schedule_work(&desc->rxwork); |
| 238 | if (rv) | 243 | if (rv) |
| 239 | err("Cannot schedule work"); | 244 | dev_err(&desc->intf->dev, |
| 245 | "Cannot schedule work\n"); | ||
| 240 | } | 246 | } |
| 241 | } | 247 | } |
| 242 | exit: | 248 | exit: |
| 243 | rv = usb_submit_urb(urb, GFP_ATOMIC); | 249 | rv = usb_submit_urb(urb, GFP_ATOMIC); |
| 244 | if (rv) | 250 | if (rv) |
| 245 | err("%s - usb_submit_urb failed with result %d", | 251 | dev_err(&desc->intf->dev, |
| 246 | __func__, rv); | 252 | "%s - usb_submit_urb failed with result %d\n", |
| 253 | __func__, rv); | ||
| 247 | 254 | ||
| 248 | } | 255 | } |
| 249 | 256 | ||
| @@ -353,7 +360,7 @@ static ssize_t wdm_write | |||
| 353 | if (rv < 0) { | 360 | if (rv < 0) { |
| 354 | kfree(buf); | 361 | kfree(buf); |
| 355 | clear_bit(WDM_IN_USE, &desc->flags); | 362 | clear_bit(WDM_IN_USE, &desc->flags); |
| 356 | err("Tx URB error: %d", rv); | 363 | dev_err(&desc->intf->dev, "Tx URB error: %d\n", rv); |
| 357 | } else { | 364 | } else { |
| 358 | dev_dbg(&desc->intf->dev, "Tx URB has been submitted index=%d", | 365 | dev_dbg(&desc->intf->dev, "Tx URB has been submitted index=%d", |
| 359 | req->wIndex); | 366 | req->wIndex); |
| @@ -401,7 +408,8 @@ retry: | |||
| 401 | int t = desc->rerr; | 408 | int t = desc->rerr; |
| 402 | desc->rerr = 0; | 409 | desc->rerr = 0; |
| 403 | spin_unlock_irq(&desc->iuspin); | 410 | spin_unlock_irq(&desc->iuspin); |
| 404 | err("reading had resulted in %d", t); | 411 | dev_err(&desc->intf->dev, |
| 412 | "reading had resulted in %d\n", t); | ||
| 405 | rv = -EIO; | 413 | rv = -EIO; |
| 406 | goto err; | 414 | goto err; |
| 407 | } | 415 | } |
| @@ -440,7 +448,7 @@ retry: | |||
| 440 | err: | 448 | err: |
| 441 | mutex_unlock(&desc->rlock); | 449 | mutex_unlock(&desc->rlock); |
| 442 | if (rv < 0) | 450 | if (rv < 0) |
| 443 | err("wdm_read: exit error"); | 451 | dev_err(&desc->intf->dev, "wdm_read: exit error\n"); |
| 444 | return rv; | 452 | return rv; |
| 445 | } | 453 | } |
| 446 | 454 | ||
| @@ -450,7 +458,8 @@ static int wdm_flush(struct file *file, fl_owner_t id) | |||
| 450 | 458 | ||
| 451 | wait_event(desc->wait, !test_bit(WDM_IN_USE, &desc->flags)); | 459 | wait_event(desc->wait, !test_bit(WDM_IN_USE, &desc->flags)); |
| 452 | if (desc->werr < 0) | 460 | if (desc->werr < 0) |
| 453 | err("Error in flush path: %d", desc->werr); | 461 | dev_err(&desc->intf->dev, "Error in flush path: %d\n", |
| 462 | desc->werr); | ||
| 454 | 463 | ||
| 455 | return desc->werr; | 464 | return desc->werr; |
| 456 | } | 465 | } |
| @@ -502,7 +511,7 @@ static int wdm_open(struct inode *inode, struct file *file) | |||
| 502 | 511 | ||
| 503 | rv = usb_autopm_get_interface(desc->intf); | 512 | rv = usb_autopm_get_interface(desc->intf); |
| 504 | if (rv < 0) { | 513 | if (rv < 0) { |
| 505 | err("Error autopm - %d", rv); | 514 | dev_err(&desc->intf->dev, "Error autopm - %d\n", rv); |
| 506 | goto out; | 515 | goto out; |
| 507 | } | 516 | } |
| 508 | intf->needs_remote_wakeup = 1; | 517 | intf->needs_remote_wakeup = 1; |
| @@ -512,7 +521,8 @@ static int wdm_open(struct inode *inode, struct file *file) | |||
| 512 | rv = usb_submit_urb(desc->validity, GFP_KERNEL); | 521 | rv = usb_submit_urb(desc->validity, GFP_KERNEL); |
| 513 | if (rv < 0) { | 522 | if (rv < 0) { |
| 514 | desc->count--; | 523 | desc->count--; |
| 515 | err("Error submitting int urb - %d", rv); | 524 | dev_err(&desc->intf->dev, |
| 525 | "Error submitting int urb - %d\n", rv); | ||
| 516 | } | 526 | } |
| 517 | } else { | 527 | } else { |
| 518 | rv = 0; | 528 | rv = 0; |
| @@ -600,7 +610,7 @@ static int wdm_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
| 600 | 610 | ||
| 601 | while (buflen > 0) { | 611 | while (buflen > 0) { |
| 602 | if (buffer [1] != USB_DT_CS_INTERFACE) { | 612 | if (buffer [1] != USB_DT_CS_INTERFACE) { |
| 603 | err("skipping garbage"); | 613 | dev_err(&intf->dev, "skipping garbage\n"); |
| 604 | goto next_desc; | 614 | goto next_desc; |
| 605 | } | 615 | } |
| 606 | 616 | ||
| @@ -614,7 +624,8 @@ static int wdm_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
| 614 | "Finding maximum buffer length: %d", maxcom); | 624 | "Finding maximum buffer length: %d", maxcom); |
| 615 | break; | 625 | break; |
| 616 | default: | 626 | default: |
| 617 | err("Ignoring extra header, type %d, length %d", | 627 | dev_err(&intf->dev, |
| 628 | "Ignoring extra header, type %d, length %d\n", | ||
| 618 | buffer[2], buffer[0]); | 629 | buffer[2], buffer[0]); |
| 619 | break; | 630 | break; |
| 620 | } | 631 | } |
| @@ -772,7 +783,8 @@ static int recover_from_urb_loss(struct wdm_device *desc) | |||
| 772 | if (desc->count) { | 783 | if (desc->count) { |
| 773 | rv = usb_submit_urb(desc->validity, GFP_NOIO); | 784 | rv = usb_submit_urb(desc->validity, GFP_NOIO); |
| 774 | if (rv < 0) | 785 | if (rv < 0) |
| 775 | err("Error resume submitting int urb - %d", rv); | 786 | dev_err(&desc->intf->dev, |
| 787 | "Error resume submitting int urb - %d\n", rv); | ||
| 776 | } | 788 | } |
| 777 | return rv; | 789 | return rv; |
| 778 | } | 790 | } |
diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c index 0647164d36db..b5775af3ba26 100644 --- a/drivers/usb/class/usblp.c +++ b/drivers/usb/class/usblp.c | |||
| @@ -593,8 +593,9 @@ static long usblp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
| 593 | err = usblp_hp_channel_change_request(usblp, | 593 | err = usblp_hp_channel_change_request(usblp, |
| 594 | arg, &newChannel); | 594 | arg, &newChannel); |
| 595 | if (err < 0) { | 595 | if (err < 0) { |
| 596 | err("usblp%d: error = %d setting " | 596 | dev_err(&usblp->dev->dev, |
| 597 | "HP channel", | 597 | "usblp%d: error = %d setting " |
| 598 | "HP channel\n", | ||
| 598 | usblp->minor, err); | 599 | usblp->minor, err); |
| 599 | retval = -EIO; | 600 | retval = -EIO; |
| 600 | goto done; | 601 | goto done; |
| @@ -1076,15 +1077,16 @@ static int usblp_probe(struct usb_interface *intf, | |||
| 1076 | const struct usb_device_id *id) | 1077 | const struct usb_device_id *id) |
| 1077 | { | 1078 | { |
| 1078 | struct usb_device *dev = interface_to_usbdev (intf); | 1079 | struct usb_device *dev = interface_to_usbdev (intf); |
| 1079 | struct usblp *usblp = NULL; | 1080 | struct usblp *usblp; |
| 1080 | int protocol; | 1081 | int protocol; |
| 1081 | int retval; | 1082 | int retval; |
| 1082 | 1083 | ||
| 1083 | /* Malloc and start initializing usblp structure so we can use it | 1084 | /* Malloc and start initializing usblp structure so we can use it |
| 1084 | * directly. */ | 1085 | * directly. */ |
| 1085 | if (!(usblp = kzalloc(sizeof(struct usblp), GFP_KERNEL))) { | 1086 | usblp = kzalloc(sizeof(struct usblp), GFP_KERNEL); |
| 1087 | if (!usblp) { | ||
| 1086 | retval = -ENOMEM; | 1088 | retval = -ENOMEM; |
| 1087 | goto abort; | 1089 | goto abort_ret; |
| 1088 | } | 1090 | } |
| 1089 | usblp->dev = dev; | 1091 | usblp->dev = dev; |
| 1090 | mutex_init(&usblp->wmut); | 1092 | mutex_init(&usblp->wmut); |
| @@ -1179,12 +1181,11 @@ abort_intfdata: | |||
| 1179 | usb_set_intfdata (intf, NULL); | 1181 | usb_set_intfdata (intf, NULL); |
| 1180 | device_remove_file(&intf->dev, &dev_attr_ieee1284_id); | 1182 | device_remove_file(&intf->dev, &dev_attr_ieee1284_id); |
| 1181 | abort: | 1183 | abort: |
| 1182 | if (usblp) { | 1184 | kfree(usblp->readbuf); |
| 1183 | kfree(usblp->readbuf); | 1185 | kfree(usblp->statusbuf); |
| 1184 | kfree(usblp->statusbuf); | 1186 | kfree(usblp->device_id_string); |
| 1185 | kfree(usblp->device_id_string); | 1187 | kfree(usblp); |
| 1186 | kfree(usblp); | 1188 | abort_ret: |
| 1187 | } | ||
| 1188 | return retval; | 1189 | return retval; |
| 1189 | } | 1190 | } |
| 1190 | 1191 | ||
| @@ -1345,7 +1346,7 @@ static void usblp_disconnect(struct usb_interface *intf) | |||
| 1345 | usb_deregister_dev(intf, &usblp_class); | 1346 | usb_deregister_dev(intf, &usblp_class); |
| 1346 | 1347 | ||
| 1347 | if (!usblp || !usblp->dev) { | 1348 | if (!usblp || !usblp->dev) { |
| 1348 | err("bogus disconnect"); | 1349 | dev_err(&intf->dev, "bogus disconnect\n"); |
| 1349 | BUG (); | 1350 | BUG (); |
| 1350 | } | 1351 | } |
| 1351 | 1352 | ||
diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c new file mode 100644 index 000000000000..543811f6e6e8 --- /dev/null +++ b/drivers/usb/class/usbtmc.c | |||
| @@ -0,0 +1,1087 @@ | |||
| 1 | /** | ||
| 2 | * drivers/usb/class/usbtmc.c - USB Test & Measurment class driver | ||
| 3 | * | ||
| 4 | * Copyright (C) 2007 Stefan Kopp, Gechingen, Germany | ||
| 5 | * Copyright (C) 2008 Novell, Inc. | ||
| 6 | * Copyright (C) 2008 Greg Kroah-Hartman <gregkh@suse.de> | ||
| 7 | * | ||
| 8 | * This program is free software; you can redistribute it and/or | ||
| 9 | * modify it under the terms of the GNU General Public License | ||
| 10 | * as published by the Free Software Foundation; either version 2 | ||
| 11 | * of the License, or (at your option) any later version. | ||
| 12 | * | ||
| 13 | * This program is distributed in the hope that it will be useful, | ||
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 16 | * GNU General Public License for more details. | ||
| 17 | * | ||
| 18 | * The GNU General Public License is available at | ||
| 19 | * http://www.gnu.org/copyleft/gpl.html. | ||
| 20 | */ | ||
| 21 | |||
| 22 | #include <linux/init.h> | ||
| 23 | #include <linux/module.h> | ||
| 24 | #include <linux/fs.h> | ||
| 25 | #include <linux/uaccess.h> | ||
| 26 | #include <linux/kref.h> | ||
| 27 | #include <linux/mutex.h> | ||
| 28 | #include <linux/usb.h> | ||
| 29 | #include <linux/usb/tmc.h> | ||
| 30 | |||
| 31 | |||
| 32 | #define USBTMC_MINOR_BASE 176 | ||
| 33 | |||
| 34 | /* | ||
| 35 | * Size of driver internal IO buffer. Must be multiple of 4 and at least as | ||
| 36 | * large as wMaxPacketSize (which is usually 512 bytes). | ||
| 37 | */ | ||
| 38 | #define USBTMC_SIZE_IOBUFFER 2048 | ||
| 39 | |||
| 40 | /* Default USB timeout (in milliseconds) */ | ||
| 41 | #define USBTMC_TIMEOUT 10 | ||
| 42 | |||
| 43 | /* | ||
| 44 | * Maximum number of read cycles to empty bulk in endpoint during CLEAR and | ||
| 45 | * ABORT_BULK_IN requests. Ends the loop if (for whatever reason) a short | ||
| 46 | * packet is never read. | ||
| 47 | */ | ||
| 48 | #define USBTMC_MAX_READS_TO_CLEAR_BULK_IN 100 | ||
| 49 | |||
| 50 | static struct usb_device_id usbtmc_devices[] = { | ||
| 51 | { USB_INTERFACE_INFO(USB_CLASS_APP_SPEC, 3, 0), }, | ||
| 52 | { 0, } /* terminating entry */ | ||
| 53 | }; | ||
| 54 | |||
| 55 | /* | ||
| 56 | * This structure is the capabilities for the device | ||
| 57 | * See section 4.2.1.8 of the USBTMC specification for details. | ||
| 58 | */ | ||
| 59 | struct usbtmc_dev_capabilities { | ||
| 60 | __u8 interface_capabilities; | ||
| 61 | __u8 device_capabilities; | ||
| 62 | __u8 usb488_interface_capabilities; | ||
| 63 | __u8 usb488_device_capabilities; | ||
| 64 | }; | ||
| 65 | |||
| 66 | /* This structure holds private data for each USBTMC device. One copy is | ||
| 67 | * allocated for each USBTMC device in the driver's probe function. | ||
| 68 | */ | ||
| 69 | struct usbtmc_device_data { | ||
| 70 | const struct usb_device_id *id; | ||
| 71 | struct usb_device *usb_dev; | ||
| 72 | struct usb_interface *intf; | ||
| 73 | |||
| 74 | unsigned int bulk_in; | ||
| 75 | unsigned int bulk_out; | ||
| 76 | |||
| 77 | u8 bTag; | ||
| 78 | u8 bTag_last_write; /* needed for abort */ | ||
| 79 | u8 bTag_last_read; /* needed for abort */ | ||
| 80 | |||
| 81 | /* attributes from the USB TMC spec for this device */ | ||
| 82 | u8 TermChar; | ||
| 83 | bool TermCharEnabled; | ||
| 84 | bool auto_abort; | ||
| 85 | |||
| 86 | struct usbtmc_dev_capabilities capabilities; | ||
| 87 | struct kref kref; | ||
| 88 | struct mutex io_mutex; /* only one i/o function running at a time */ | ||
| 89 | }; | ||
| 90 | #define to_usbtmc_data(d) container_of(d, struct usbtmc_device_data, kref) | ||
| 91 | |||
| 92 | /* Forward declarations */ | ||
| 93 | static struct usb_driver usbtmc_driver; | ||
| 94 | |||
| 95 | static void usbtmc_delete(struct kref *kref) | ||
| 96 | { | ||
| 97 | struct usbtmc_device_data *data = to_usbtmc_data(kref); | ||
| 98 | |||
| 99 | usb_put_dev(data->usb_dev); | ||
| 100 | kfree(data); | ||
| 101 | } | ||
| 102 | |||
| 103 | static int usbtmc_open(struct inode *inode, struct file *filp) | ||
| 104 | { | ||
| 105 | struct usb_interface *intf; | ||
| 106 | struct usbtmc_device_data *data; | ||
| 107 | int retval = -ENODEV; | ||
| 108 | |||
| 109 | intf = usb_find_interface(&usbtmc_driver, iminor(inode)); | ||
| 110 | if (!intf) { | ||
| 111 | printk(KERN_ERR KBUILD_MODNAME | ||
| 112 | ": can not find device for minor %d", iminor(inode)); | ||
| 113 | goto exit; | ||
| 114 | } | ||
| 115 | |||
| 116 | data = usb_get_intfdata(intf); | ||
| 117 | kref_get(&data->kref); | ||
| 118 | |||
| 119 | /* Store pointer in file structure's private data field */ | ||
| 120 | filp->private_data = data; | ||
| 121 | |||
| 122 | exit: | ||
| 123 | return retval; | ||
| 124 | } | ||
| 125 | |||
| 126 | static int usbtmc_release(struct inode *inode, struct file *file) | ||
| 127 | { | ||
| 128 | struct usbtmc_device_data *data = file->private_data; | ||
| 129 | |||
| 130 | kref_put(&data->kref, usbtmc_delete); | ||
| 131 | return 0; | ||
| 132 | } | ||
| 133 | |||
| 134 | static int usbtmc_ioctl_abort_bulk_in(struct usbtmc_device_data *data) | ||
| 135 | { | ||
| 136 | char *buffer; | ||
| 137 | struct device *dev; | ||
| 138 | int rv; | ||
| 139 | int n; | ||
| 140 | int actual; | ||
| 141 | struct usb_host_interface *current_setting; | ||
| 142 | int max_size; | ||
| 143 | |||
| 144 | dev = &data->intf->dev; | ||
| 145 | buffer = kmalloc(USBTMC_SIZE_IOBUFFER, GFP_KERNEL); | ||
| 146 | if (!buffer) | ||
| 147 | return -ENOMEM; | ||
| 148 | |||
| 149 | rv = usb_control_msg(data->usb_dev, | ||
| 150 | usb_rcvctrlpipe(data->usb_dev, 0), | ||
| 151 | USBTMC_REQUEST_INITIATE_ABORT_BULK_IN, | ||
| 152 | USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_ENDPOINT, | ||
| 153 | data->bTag_last_read, data->bulk_in, | ||
| 154 | buffer, 2, USBTMC_TIMEOUT); | ||
| 155 | |||
| 156 | if (rv < 0) { | ||
| 157 | dev_err(dev, "usb_control_msg returned %d\n", rv); | ||
| 158 | goto exit; | ||
| 159 | } | ||
| 160 | |||
| 161 | dev_dbg(dev, "INITIATE_ABORT_BULK_IN returned %x\n", buffer[0]); | ||
| 162 | |||
| 163 | if (buffer[0] == USBTMC_STATUS_FAILED) { | ||
| 164 | rv = 0; | ||
| 165 | goto exit; | ||
| 166 | } | ||
| 167 | |||
| 168 | if (buffer[0] != USBTMC_STATUS_SUCCESS) { | ||
| 169 | dev_err(dev, "INITIATE_ABORT_BULK_IN returned %x\n", | ||
| 170 | buffer[0]); | ||
| 171 | rv = -EPERM; | ||
| 172 | goto exit; | ||
| 173 | } | ||
| 174 | |||
| 175 | max_size = 0; | ||
| 176 | current_setting = data->intf->cur_altsetting; | ||
| 177 | for (n = 0; n < current_setting->desc.bNumEndpoints; n++) | ||
| 178 | if (current_setting->endpoint[n].desc.bEndpointAddress == | ||
| 179 | data->bulk_in) | ||
| 180 | max_size = le16_to_cpu(current_setting->endpoint[n]. | ||
| 181 | desc.wMaxPacketSize); | ||
| 182 | |||
| 183 | if (max_size == 0) { | ||
| 184 | dev_err(dev, "Couldn't get wMaxPacketSize\n"); | ||
| 185 | rv = -EPERM; | ||
| 186 | goto exit; | ||
| 187 | } | ||
| 188 | |||
| 189 | dev_dbg(&data->intf->dev, "wMaxPacketSize is %d\n", max_size); | ||
| 190 | |||
| 191 | n = 0; | ||
| 192 | |||
| 193 | do { | ||
| 194 | dev_dbg(dev, "Reading from bulk in EP\n"); | ||
| 195 | |||
| 196 | rv = usb_bulk_msg(data->usb_dev, | ||
| 197 | usb_rcvbulkpipe(data->usb_dev, | ||
| 198 | data->bulk_in), | ||
| 199 | buffer, USBTMC_SIZE_IOBUFFER, | ||
| 200 | &actual, USBTMC_TIMEOUT); | ||
| 201 | |||
| 202 | n++; | ||
| 203 | |||
| 204 | if (rv < 0) { | ||
| 205 | dev_err(dev, "usb_bulk_msg returned %d\n", rv); | ||
| 206 | goto exit; | ||
| 207 | } | ||
| 208 | } while ((actual == max_size) && | ||
| 209 | (n < USBTMC_MAX_READS_TO_CLEAR_BULK_IN)); | ||
| 210 | |||
| 211 | if (actual == max_size) { | ||
| 212 | dev_err(dev, "Couldn't clear device buffer within %d cycles\n", | ||
| 213 | USBTMC_MAX_READS_TO_CLEAR_BULK_IN); | ||
| 214 | rv = -EPERM; | ||
| 215 | goto exit; | ||
| 216 | } | ||
| 217 | |||
| 218 | n = 0; | ||
| 219 | |||
| 220 | usbtmc_abort_bulk_in_status: | ||
| 221 | rv = usb_control_msg(data->usb_dev, | ||
| 222 | usb_rcvctrlpipe(data->usb_dev, 0), | ||
| 223 | USBTMC_REQUEST_CHECK_ABORT_BULK_IN_STATUS, | ||
| 224 | USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_ENDPOINT, | ||
| 225 | 0, data->bulk_in, buffer, 0x08, | ||
| 226 | USBTMC_TIMEOUT); | ||
| 227 | |||
| 228 | if (rv < 0) { | ||
| 229 | dev_err(dev, "usb_control_msg returned %d\n", rv); | ||
| 230 | goto exit; | ||
| 231 | } | ||
| 232 | |||
| 233 | dev_dbg(dev, "INITIATE_ABORT_BULK_IN returned %x\n", buffer[0]); | ||
| 234 | |||
| 235 | if (buffer[0] == USBTMC_STATUS_SUCCESS) { | ||
| 236 | rv = 0; | ||
| 237 | goto exit; | ||
| 238 | } | ||
| 239 | |||
| 240 | if (buffer[0] != USBTMC_STATUS_PENDING) { | ||
| 241 | dev_err(dev, "INITIATE_ABORT_BULK_IN returned %x\n", buffer[0]); | ||
| 242 | rv = -EPERM; | ||
| 243 | goto exit; | ||
| 244 | } | ||
| 245 | |||
| 246 | if (buffer[1] == 1) | ||
| 247 | do { | ||
| 248 | dev_dbg(dev, "Reading from bulk in EP\n"); | ||
| 249 | |||
| 250 | rv = usb_bulk_msg(data->usb_dev, | ||
| 251 | usb_rcvbulkpipe(data->usb_dev, | ||
| 252 | data->bulk_in), | ||
| 253 | buffer, USBTMC_SIZE_IOBUFFER, | ||
| 254 | &actual, USBTMC_TIMEOUT); | ||
| 255 | |||
| 256 | n++; | ||
| 257 | |||
| 258 | if (rv < 0) { | ||
| 259 | dev_err(dev, "usb_bulk_msg returned %d\n", rv); | ||
| 260 | goto exit; | ||
| 261 | } | ||
| 262 | } while ((actual = max_size) && | ||
| 263 | (n < USBTMC_MAX_READS_TO_CLEAR_BULK_IN)); | ||
| 264 | |||
| 265 | if (actual == max_size) { | ||
| 266 | dev_err(dev, "Couldn't clear device buffer within %d cycles\n", | ||
| 267 | USBTMC_MAX_READS_TO_CLEAR_BULK_IN); | ||
| 268 | rv = -EPERM; | ||
| 269 | goto exit; | ||
| 270 | } | ||
| 271 | |||
| 272 | goto usbtmc_abort_bulk_in_status; | ||
| 273 | |||
| 274 | exit: | ||
| 275 | kfree(buffer); | ||
| 276 | return rv; | ||
| 277 | |||
| 278 | } | ||
| 279 | |||
| 280 | static int usbtmc_ioctl_abort_bulk_out(struct usbtmc_device_data *data) | ||
| 281 | { | ||
| 282 | struct device *dev; | ||
| 283 | u8 *buffer; | ||
| 284 | int rv; | ||
| 285 | int n; | ||
| 286 | |||
| 287 | dev = &data->intf->dev; | ||
| 288 | |||
| 289 | buffer = kmalloc(8, GFP_KERNEL); | ||
| 290 | if (!buffer) | ||
| 291 | return -ENOMEM; | ||
| 292 | |||
| 293 | rv = usb_control_msg(data->usb_dev, | ||
| 294 | usb_rcvctrlpipe(data->usb_dev, 0), | ||
| 295 | USBTMC_REQUEST_INITIATE_ABORT_BULK_OUT, | ||
| 296 | USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_ENDPOINT, | ||
| 297 | data->bTag_last_write, data->bulk_out, | ||
| 298 | buffer, 2, USBTMC_TIMEOUT); | ||
| 299 | |||
| 300 | if (rv < 0) { | ||
| 301 | dev_err(dev, "usb_control_msg returned %d\n", rv); | ||
| 302 | goto exit; | ||
| 303 | } | ||
| 304 | |||
| 305 | dev_dbg(dev, "INITIATE_ABORT_BULK_OUT returned %x\n", buffer[0]); | ||
| 306 | |||
| 307 | if (buffer[0] != USBTMC_STATUS_SUCCESS) { | ||
| 308 | dev_err(dev, "INITIATE_ABORT_BULK_OUT returned %x\n", | ||
| 309 | buffer[0]); | ||
| 310 | rv = -EPERM; | ||
| 311 | goto exit; | ||
| 312 | } | ||
| 313 | |||
| 314 | n = 0; | ||
| 315 | |||
| 316 | usbtmc_abort_bulk_out_check_status: | ||
| 317 | rv = usb_control_msg(data->usb_dev, | ||
| 318 | usb_rcvctrlpipe(data->usb_dev, 0), | ||
| 319 | USBTMC_REQUEST_CHECK_ABORT_BULK_OUT_STATUS, | ||
| 320 | USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_ENDPOINT, | ||
| 321 | 0, data->bulk_out, buffer, 0x08, | ||
| 322 | USBTMC_TIMEOUT); | ||
| 323 | n++; | ||
| 324 | if (rv < 0) { | ||
| 325 | dev_err(dev, "usb_control_msg returned %d\n", rv); | ||
| 326 | goto exit; | ||
| 327 | } | ||
| 328 | |||
| 329 | dev_dbg(dev, "CHECK_ABORT_BULK_OUT returned %x\n", buffer[0]); | ||
| 330 | |||
| 331 | if (buffer[0] == USBTMC_STATUS_SUCCESS) | ||
| 332 | goto usbtmc_abort_bulk_out_clear_halt; | ||
| 333 | |||
| 334 | if ((buffer[0] == USBTMC_STATUS_PENDING) && | ||
| 335 | (n < USBTMC_MAX_READS_TO_CLEAR_BULK_IN)) | ||
| 336 | goto usbtmc_abort_bulk_out_check_status; | ||
| 337 | |||
| 338 | rv = -EPERM; | ||
| 339 | goto exit; | ||
| 340 | |||
| 341 | usbtmc_abort_bulk_out_clear_halt: | ||
| 342 | rv = usb_control_msg(data->usb_dev, | ||
| 343 | usb_sndctrlpipe(data->usb_dev, 0), | ||
| 344 | USB_REQ_CLEAR_FEATURE, | ||
| 345 | USB_DIR_OUT | USB_TYPE_STANDARD | | ||
| 346 | USB_RECIP_ENDPOINT, | ||
| 347 | USB_ENDPOINT_HALT, data->bulk_out, buffer, | ||
| 348 | 0, USBTMC_TIMEOUT); | ||
| 349 | |||
| 350 | if (rv < 0) { | ||
| 351 | dev_err(dev, "usb_control_msg returned %d\n", rv); | ||
| 352 | goto exit; | ||
| 353 | } | ||
| 354 | rv = 0; | ||
| 355 | |||
| 356 | exit: | ||
| 357 | kfree(buffer); | ||
| 358 | return rv; | ||
| 359 | } | ||
| 360 | |||
| 361 | static ssize_t usbtmc_read(struct file *filp, char __user *buf, | ||
| 362 | size_t count, loff_t *f_pos) | ||
| 363 | { | ||
| 364 | struct usbtmc_device_data *data; | ||
| 365 | struct device *dev; | ||
| 366 | unsigned long int n_characters; | ||
| 367 | u8 *buffer; | ||
| 368 | int actual; | ||
| 369 | int done; | ||
| 370 | int remaining; | ||
| 371 | int retval; | ||
| 372 | int this_part; | ||
| 373 | |||
| 374 | /* Get pointer to private data structure */ | ||
| 375 | data = filp->private_data; | ||
| 376 | dev = &data->intf->dev; | ||
| 377 | |||
| 378 | buffer = kmalloc(USBTMC_SIZE_IOBUFFER, GFP_KERNEL); | ||
| 379 | if (!buffer) | ||
| 380 | return -ENOMEM; | ||
| 381 | |||
| 382 | mutex_lock(&data->io_mutex); | ||
| 383 | |||
| 384 | remaining = count; | ||
| 385 | done = 0; | ||
| 386 | |||
| 387 | while (remaining > 0) { | ||
| 388 | if (remaining > USBTMC_SIZE_IOBUFFER - 12 - 3) | ||
| 389 | this_part = USBTMC_SIZE_IOBUFFER - 12 - 3; | ||
| 390 | else | ||
| 391 | this_part = remaining; | ||
| 392 | |||
| 393 | /* Setup IO buffer for DEV_DEP_MSG_IN message | ||
| 394 | * Refer to class specs for details | ||
| 395 | */ | ||
| 396 | buffer[0] = 2; | ||
| 397 | buffer[1] = data->bTag; | ||
| 398 | buffer[2] = ~(data->bTag); | ||
| 399 | buffer[3] = 0; /* Reserved */ | ||
| 400 | buffer[4] = (this_part - 12 - 3) & 255; | ||
| 401 | buffer[5] = ((this_part - 12 - 3) >> 8) & 255; | ||
| 402 | buffer[6] = ((this_part - 12 - 3) >> 16) & 255; | ||
| 403 | buffer[7] = ((this_part - 12 - 3) >> 24) & 255; | ||
| 404 | buffer[8] = data->TermCharEnabled * 2; | ||
| 405 | /* Use term character? */ | ||
| 406 | buffer[9] = data->TermChar; | ||
| 407 | buffer[10] = 0; /* Reserved */ | ||
| 408 | buffer[11] = 0; /* Reserved */ | ||
| 409 | |||
| 410 | /* Send bulk URB */ | ||
| 411 | retval = usb_bulk_msg(data->usb_dev, | ||
| 412 | usb_sndbulkpipe(data->usb_dev, | ||
| 413 | data->bulk_out), | ||
| 414 | buffer, 12, &actual, USBTMC_TIMEOUT); | ||
| 415 | |||
| 416 | /* Store bTag (in case we need to abort) */ | ||
| 417 | data->bTag_last_write = data->bTag; | ||
| 418 | |||
| 419 | /* Increment bTag -- and increment again if zero */ | ||
| 420 | data->bTag++; | ||
| 421 | if (!data->bTag) | ||
| 422 | (data->bTag)++; | ||
| 423 | |||
| 424 | if (retval < 0) { | ||
| 425 | dev_err(dev, "usb_bulk_msg returned %d\n", retval); | ||
| 426 | if (data->auto_abort) | ||
| 427 | usbtmc_ioctl_abort_bulk_out(data); | ||
| 428 | goto exit; | ||
| 429 | } | ||
| 430 | |||
| 431 | /* Send bulk URB */ | ||
| 432 | retval = usb_bulk_msg(data->usb_dev, | ||
| 433 | usb_rcvbulkpipe(data->usb_dev, | ||
| 434 | data->bulk_in), | ||
| 435 | buffer, USBTMC_SIZE_IOBUFFER, &actual, | ||
| 436 | USBTMC_TIMEOUT); | ||
| 437 | |||
| 438 | /* Store bTag (in case we need to abort) */ | ||
| 439 | data->bTag_last_read = data->bTag; | ||
| 440 | |||
| 441 | if (retval < 0) { | ||
| 442 | dev_err(dev, "Unable to read data, error %d\n", retval); | ||
| 443 | if (data->auto_abort) | ||
| 444 | usbtmc_ioctl_abort_bulk_in(data); | ||
| 445 | goto exit; | ||
| 446 | } | ||
| 447 | |||
| 448 | /* How many characters did the instrument send? */ | ||
| 449 | n_characters = buffer[4] + | ||
| 450 | (buffer[5] << 8) + | ||
| 451 | (buffer[6] << 16) + | ||
| 452 | (buffer[7] << 24); | ||
| 453 | |||
| 454 | /* Copy buffer to user space */ | ||
| 455 | if (copy_to_user(buf + done, &buffer[12], n_characters)) { | ||
| 456 | /* There must have been an addressing problem */ | ||
| 457 | retval = -EFAULT; | ||
| 458 | goto exit; | ||
| 459 | } | ||
| 460 | |||
| 461 | done += n_characters; | ||
| 462 | if (n_characters < USBTMC_SIZE_IOBUFFER) | ||
| 463 | remaining = 0; | ||
| 464 | } | ||
| 465 | |||
| 466 | /* Update file position value */ | ||
| 467 | *f_pos = *f_pos + done; | ||
| 468 | retval = done; | ||
| 469 | |||
| 470 | exit: | ||
| 471 | mutex_unlock(&data->io_mutex); | ||
| 472 | kfree(buffer); | ||
| 473 | return retval; | ||
| 474 | } | ||
| 475 | |||
| 476 | static ssize_t usbtmc_write(struct file *filp, const char __user *buf, | ||
| 477 | size_t count, loff_t *f_pos) | ||
| 478 | { | ||
| 479 | struct usbtmc_device_data *data; | ||
| 480 | u8 *buffer; | ||
| 481 | int retval; | ||
| 482 | int actual; | ||
| 483 | unsigned long int n_bytes; | ||
| 484 | int n; | ||
| 485 | int remaining; | ||
| 486 | int done; | ||
| 487 | int this_part; | ||
| 488 | |||
| 489 | data = filp->private_data; | ||
| 490 | |||
| 491 | buffer = kmalloc(USBTMC_SIZE_IOBUFFER, GFP_KERNEL); | ||
| 492 | if (!buffer) | ||
| 493 | return -ENOMEM; | ||
| 494 | |||
| 495 | mutex_lock(&data->io_mutex); | ||
| 496 | |||
| 497 | remaining = count; | ||
| 498 | done = 0; | ||
| 499 | |||
| 500 | while (remaining > 0) { | ||
| 501 | if (remaining > USBTMC_SIZE_IOBUFFER - 12) { | ||
| 502 | this_part = USBTMC_SIZE_IOBUFFER - 12; | ||
| 503 | buffer[8] = 0; | ||
| 504 | } else { | ||
| 505 | this_part = remaining; | ||
| 506 | buffer[8] = 1; | ||
| 507 | } | ||
| 508 | |||
| 509 | /* Setup IO buffer for DEV_DEP_MSG_OUT message */ | ||
| 510 | buffer[0] = 1; | ||
| 511 | buffer[1] = data->bTag; | ||
| 512 | buffer[2] = ~(data->bTag); | ||
| 513 | buffer[3] = 0; /* Reserved */ | ||
| 514 | buffer[4] = this_part & 255; | ||
| 515 | buffer[5] = (this_part >> 8) & 255; | ||
| 516 | buffer[6] = (this_part >> 16) & 255; | ||
| 517 | buffer[7] = (this_part >> 24) & 255; | ||
| 518 | /* buffer[8] is set above... */ | ||
| 519 | buffer[9] = 0; /* Reserved */ | ||
| 520 | buffer[10] = 0; /* Reserved */ | ||
| 521 | buffer[11] = 0; /* Reserved */ | ||
| 522 | |||
| 523 | if (copy_from_user(&buffer[12], buf + done, this_part)) { | ||
| 524 | retval = -EFAULT; | ||
| 525 | goto exit; | ||
| 526 | } | ||
| 527 | |||
| 528 | n_bytes = 12 + this_part; | ||
| 529 | if (this_part % 4) | ||
| 530 | n_bytes += 4 - this_part % 4; | ||
| 531 | for (n = 12 + this_part; n < n_bytes; n++) | ||
| 532 | buffer[n] = 0; | ||
| 533 | |||
| 534 | retval = usb_bulk_msg(data->usb_dev, | ||
| 535 | usb_sndbulkpipe(data->usb_dev, | ||
| 536 | data->bulk_out), | ||
| 537 | buffer, n_bytes, &actual, USBTMC_TIMEOUT); | ||
| 538 | |||
| 539 | data->bTag_last_write = data->bTag; | ||
| 540 | data->bTag++; | ||
| 541 | |||
| 542 | if (!data->bTag) | ||
| 543 | data->bTag++; | ||
| 544 | |||
| 545 | if (retval < 0) { | ||
| 546 | dev_err(&data->intf->dev, | ||
| 547 | "Unable to send data, error %d\n", retval); | ||
| 548 | if (data->auto_abort) | ||
| 549 | usbtmc_ioctl_abort_bulk_out(data); | ||
| 550 | goto exit; | ||
| 551 | } | ||
| 552 | |||
| 553 | remaining -= this_part; | ||
| 554 | done += this_part; | ||
| 555 | } | ||
| 556 | |||
| 557 | retval = count; | ||
| 558 | exit: | ||
| 559 | mutex_unlock(&data->io_mutex); | ||
| 560 | kfree(buffer); | ||
| 561 | return retval; | ||
| 562 | } | ||
| 563 | |||
| 564 | static int usbtmc_ioctl_clear(struct usbtmc_device_data *data) | ||
| 565 | { | ||
| 566 | struct usb_host_interface *current_setting; | ||
| 567 | struct usb_endpoint_descriptor *desc; | ||
| 568 | struct device *dev; | ||
| 569 | u8 *buffer; | ||
| 570 | int rv; | ||
| 571 | int n; | ||
| 572 | int actual; | ||
| 573 | int max_size; | ||
| 574 | |||
| 575 | dev = &data->intf->dev; | ||
| 576 | |||
| 577 | dev_dbg(dev, "Sending INITIATE_CLEAR request\n"); | ||
| 578 | |||
| 579 | buffer = kmalloc(USBTMC_SIZE_IOBUFFER, GFP_KERNEL); | ||
| 580 | if (!buffer) | ||
| 581 | return -ENOMEM; | ||
| 582 | |||
| 583 | rv = usb_control_msg(data->usb_dev, | ||
| 584 | usb_rcvctrlpipe(data->usb_dev, 0), | ||
| 585 | USBTMC_REQUEST_INITIATE_CLEAR, | ||
| 586 | USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE, | ||
| 587 | 0, 0, buffer, 1, USBTMC_TIMEOUT); | ||
| 588 | if (rv < 0) { | ||
| 589 | dev_err(dev, "usb_control_msg returned %d\n", rv); | ||
| 590 | goto exit; | ||
| 591 | } | ||
| 592 | |||
| 593 | dev_dbg(dev, "INITIATE_CLEAR returned %x\n", buffer[0]); | ||
| 594 | |||
| 595 | if (buffer[0] != USBTMC_STATUS_SUCCESS) { | ||
| 596 | dev_err(dev, "INITIATE_CLEAR returned %x\n", buffer[0]); | ||
| 597 | rv = -EPERM; | ||
| 598 | goto exit; | ||
| 599 | } | ||
| 600 | |||
| 601 | max_size = 0; | ||
| 602 | current_setting = data->intf->cur_altsetting; | ||
| 603 | for (n = 0; n < current_setting->desc.bNumEndpoints; n++) { | ||
| 604 | desc = ¤t_setting->endpoint[n].desc; | ||
| 605 | if (desc->bEndpointAddress == data->bulk_in) | ||
| 606 | max_size = le16_to_cpu(desc->wMaxPacketSize); | ||
| 607 | } | ||
| 608 | |||
| 609 | if (max_size == 0) { | ||
| 610 | dev_err(dev, "Couldn't get wMaxPacketSize\n"); | ||
| 611 | rv = -EPERM; | ||
| 612 | goto exit; | ||
| 613 | } | ||
| 614 | |||
| 615 | dev_dbg(dev, "wMaxPacketSize is %d\n", max_size); | ||
| 616 | |||
| 617 | n = 0; | ||
| 618 | |||
| 619 | usbtmc_clear_check_status: | ||
| 620 | |||
| 621 | dev_dbg(dev, "Sending CHECK_CLEAR_STATUS request\n"); | ||
| 622 | |||
| 623 | rv = usb_control_msg(data->usb_dev, | ||
| 624 | usb_rcvctrlpipe(data->usb_dev, 0), | ||
| 625 | USBTMC_REQUEST_CHECK_CLEAR_STATUS, | ||
| 626 | USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE, | ||
| 627 | 0, 0, buffer, 2, USBTMC_TIMEOUT); | ||
| 628 | if (rv < 0) { | ||
| 629 | dev_err(dev, "usb_control_msg returned %d\n", rv); | ||
| 630 | goto exit; | ||
| 631 | } | ||
| 632 | |||
| 633 | dev_dbg(dev, "CHECK_CLEAR_STATUS returned %x\n", buffer[0]); | ||
| 634 | |||
| 635 | if (buffer[0] == USBTMC_STATUS_SUCCESS) | ||
| 636 | goto usbtmc_clear_bulk_out_halt; | ||
| 637 | |||
| 638 | if (buffer[0] != USBTMC_STATUS_PENDING) { | ||
| 639 | dev_err(dev, "CHECK_CLEAR_STATUS returned %x\n", buffer[0]); | ||
| 640 | rv = -EPERM; | ||
| 641 | goto exit; | ||
| 642 | } | ||
| 643 | |||
| 644 | if (buffer[1] == 1) | ||
| 645 | do { | ||
| 646 | dev_dbg(dev, "Reading from bulk in EP\n"); | ||
| 647 | |||
| 648 | rv = usb_bulk_msg(data->usb_dev, | ||
| 649 | usb_rcvbulkpipe(data->usb_dev, | ||
| 650 | data->bulk_in), | ||
| 651 | buffer, USBTMC_SIZE_IOBUFFER, | ||
| 652 | &actual, USBTMC_TIMEOUT); | ||
| 653 | n++; | ||
| 654 | |||
| 655 | if (rv < 0) { | ||
| 656 | dev_err(dev, "usb_control_msg returned %d\n", | ||
| 657 | rv); | ||
| 658 | goto exit; | ||
| 659 | } | ||
| 660 | } while ((actual == max_size) && | ||
| 661 | (n < USBTMC_MAX_READS_TO_CLEAR_BULK_IN)); | ||
| 662 | |||
| 663 | if (actual == max_size) { | ||
| 664 | dev_err(dev, "Couldn't clear device buffer within %d cycles\n", | ||
| 665 | USBTMC_MAX_READS_TO_CLEAR_BULK_IN); | ||
| 666 | rv = -EPERM; | ||
| 667 | goto exit; | ||
| 668 | } | ||
| 669 | |||
| 670 | goto usbtmc_clear_check_status; | ||
| 671 | |||
| 672 | usbtmc_clear_bulk_out_halt: | ||
| 673 | |||
| 674 | rv = usb_control_msg(data->usb_dev, | ||
| 675 | usb_sndctrlpipe(data->usb_dev, 0), | ||
| 676 | USB_REQ_CLEAR_FEATURE, | ||
| 677 | USB_DIR_OUT | USB_TYPE_STANDARD | | ||
| 678 | USB_RECIP_ENDPOINT, | ||
| 679 | USB_ENDPOINT_HALT, | ||
| 680 | data->bulk_out, buffer, 0, | ||
| 681 | USBTMC_TIMEOUT); | ||
| 682 | if (rv < 0) { | ||
| 683 | dev_err(dev, "usb_control_msg returned %d\n", rv); | ||
| 684 | goto exit; | ||
| 685 | } | ||
| 686 | rv = 0; | ||
| 687 | |||
| 688 | exit: | ||
| 689 | kfree(buffer); | ||
| 690 | return rv; | ||
| 691 | } | ||
| 692 | |||
| 693 | static int usbtmc_ioctl_clear_out_halt(struct usbtmc_device_data *data) | ||
| 694 | { | ||
| 695 | u8 *buffer; | ||
| 696 | int rv; | ||
| 697 | |||
| 698 | buffer = kmalloc(2, GFP_KERNEL); | ||
| 699 | if (!buffer) | ||
| 700 | return -ENOMEM; | ||
| 701 | |||
| 702 | rv = usb_control_msg(data->usb_dev, | ||
| 703 | usb_sndctrlpipe(data->usb_dev, 0), | ||
| 704 | USB_REQ_CLEAR_FEATURE, | ||
| 705 | USB_DIR_OUT | USB_TYPE_STANDARD | | ||
| 706 | USB_RECIP_ENDPOINT, | ||
| 707 | USB_ENDPOINT_HALT, data->bulk_out, | ||
| 708 | buffer, 0, USBTMC_TIMEOUT); | ||
| 709 | |||
| 710 | if (rv < 0) { | ||
| 711 | dev_err(&data->usb_dev->dev, "usb_control_msg returned %d\n", | ||
| 712 | rv); | ||
| 713 | goto exit; | ||
| 714 | } | ||
| 715 | rv = 0; | ||
| 716 | |||
| 717 | exit: | ||
| 718 | kfree(buffer); | ||
| 719 | return rv; | ||
| 720 | } | ||
| 721 | |||
| 722 | static int usbtmc_ioctl_clear_in_halt(struct usbtmc_device_data *data) | ||
| 723 | { | ||
| 724 | u8 *buffer; | ||
| 725 | int rv; | ||
| 726 | |||
| 727 | buffer = kmalloc(2, GFP_KERNEL); | ||
| 728 | if (!buffer) | ||
| 729 | return -ENOMEM; | ||
| 730 | |||
| 731 | rv = usb_control_msg(data->usb_dev, usb_sndctrlpipe(data->usb_dev, 0), | ||
| 732 | USB_REQ_CLEAR_FEATURE, | ||
| 733 | USB_DIR_OUT | USB_TYPE_STANDARD | | ||
| 734 | USB_RECIP_ENDPOINT, | ||
| 735 | USB_ENDPOINT_HALT, data->bulk_in, buffer, 0, | ||
| 736 | USBTMC_TIMEOUT); | ||
| 737 | |||
| 738 | if (rv < 0) { | ||
| 739 | dev_err(&data->usb_dev->dev, "usb_control_msg returned %d\n", | ||
| 740 | rv); | ||
| 741 | goto exit; | ||
| 742 | } | ||
| 743 | rv = 0; | ||
| 744 | |||
| 745 | exit: | ||
| 746 | kfree(buffer); | ||
| 747 | return rv; | ||
| 748 | } | ||
| 749 | |||
| 750 | static int get_capabilities(struct usbtmc_device_data *data) | ||
| 751 | { | ||
| 752 | struct device *dev = &data->usb_dev->dev; | ||
| 753 | char *buffer; | ||
| 754 | int rv; | ||
| 755 | |||
| 756 | buffer = kmalloc(0x18, GFP_KERNEL); | ||
| 757 | if (!buffer) | ||
| 758 | return -ENOMEM; | ||
| 759 | |||
| 760 | rv = usb_control_msg(data->usb_dev, usb_rcvctrlpipe(data->usb_dev, 0), | ||
| 761 | USBTMC_REQUEST_GET_CAPABILITIES, | ||
| 762 | USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE, | ||
| 763 | 0, 0, buffer, 0x18, USBTMC_TIMEOUT); | ||
| 764 | if (rv < 0) { | ||
| 765 | dev_err(dev, "usb_control_msg returned %d\n", rv); | ||
| 766 | return rv; | ||
| 767 | } | ||
| 768 | |||
| 769 | dev_dbg(dev, "GET_CAPABILITIES returned %x\n", buffer[0]); | ||
| 770 | dev_dbg(dev, "Interface capabilities are %x\n", buffer[4]); | ||
| 771 | dev_dbg(dev, "Device capabilities are %x\n", buffer[5]); | ||
| 772 | dev_dbg(dev, "USB488 interface capabilities are %x\n", buffer[14]); | ||
| 773 | dev_dbg(dev, "USB488 device capabilities are %x\n", buffer[15]); | ||
| 774 | if (buffer[0] != USBTMC_STATUS_SUCCESS) { | ||
| 775 | dev_err(dev, "GET_CAPABILITIES returned %x\n", buffer[0]); | ||
| 776 | return -EPERM; | ||
| 777 | } | ||
| 778 | |||
| 779 | data->capabilities.interface_capabilities = buffer[4]; | ||
| 780 | data->capabilities.device_capabilities = buffer[5]; | ||
| 781 | data->capabilities.usb488_interface_capabilities = buffer[14]; | ||
| 782 | data->capabilities.usb488_device_capabilities = buffer[15]; | ||
| 783 | |||
| 784 | kfree(buffer); | ||
| 785 | return 0; | ||
| 786 | } | ||
| 787 | |||
| 788 | #define capability_attribute(name) \ | ||
| 789 | static ssize_t show_##name(struct device *dev, \ | ||
| 790 | struct device_attribute *attr, char *buf) \ | ||
| 791 | { \ | ||
| 792 | struct usb_interface *intf = to_usb_interface(dev); \ | ||
| 793 | struct usbtmc_device_data *data = usb_get_intfdata(intf); \ | ||
| 794 | \ | ||
| 795 | return sprintf(buf, "%d\n", data->capabilities.name); \ | ||
| 796 | } \ | ||
| 797 | static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL) | ||
| 798 | |||
| 799 | capability_attribute(interface_capabilities); | ||
| 800 | capability_attribute(device_capabilities); | ||
| 801 | capability_attribute(usb488_interface_capabilities); | ||
| 802 | capability_attribute(usb488_device_capabilities); | ||
| 803 | |||
| 804 | static struct attribute *capability_attrs[] = { | ||
| 805 | &dev_attr_interface_capabilities.attr, | ||
| 806 | &dev_attr_device_capabilities.attr, | ||
| 807 | &dev_attr_usb488_interface_capabilities.attr, | ||
| 808 | &dev_attr_usb488_device_capabilities.attr, | ||
| 809 | NULL, | ||
| 810 | }; | ||
| 811 | |||
| 812 | static struct attribute_group capability_attr_grp = { | ||
| 813 | .attrs = capability_attrs, | ||
| 814 | }; | ||
| 815 | |||
| 816 | static ssize_t show_TermChar(struct device *dev, | ||
| 817 | struct device_attribute *attr, char *buf) | ||
| 818 | { | ||
| 819 | struct usb_interface *intf = to_usb_interface(dev); | ||
| 820 | struct usbtmc_device_data *data = usb_get_intfdata(intf); | ||
| 821 | |||
| 822 | return sprintf(buf, "%c\n", data->TermChar); | ||
| 823 | } | ||
| 824 | |||
| 825 | static ssize_t store_TermChar(struct device *dev, | ||
| 826 | struct device_attribute *attr, | ||
| 827 | const char *buf, size_t count) | ||
| 828 | { | ||
| 829 | struct usb_interface *intf = to_usb_interface(dev); | ||
| 830 | struct usbtmc_device_data *data = usb_get_intfdata(intf); | ||
| 831 | |||
| 832 | if (count < 1) | ||
| 833 | return -EINVAL; | ||
| 834 | data->TermChar = buf[0]; | ||
| 835 | return count; | ||
| 836 | } | ||
| 837 | static DEVICE_ATTR(TermChar, S_IRUGO, show_TermChar, store_TermChar); | ||
| 838 | |||
| 839 | #define data_attribute(name) \ | ||
| 840 | static ssize_t show_##name(struct device *dev, \ | ||
| 841 | struct device_attribute *attr, char *buf) \ | ||
| 842 | { \ | ||
| 843 | struct usb_interface *intf = to_usb_interface(dev); \ | ||
| 844 | struct usbtmc_device_data *data = usb_get_intfdata(intf); \ | ||
| 845 | \ | ||
| 846 | return sprintf(buf, "%d\n", data->name); \ | ||
| 847 | } \ | ||
| 848 | static ssize_t store_##name(struct device *dev, \ | ||
| 849 | struct device_attribute *attr, \ | ||
| 850 | const char *buf, size_t count) \ | ||
| 851 | { \ | ||
| 852 | struct usb_interface *intf = to_usb_interface(dev); \ | ||
| 853 | struct usbtmc_device_data *data = usb_get_intfdata(intf); \ | ||
| 854 | ssize_t result; \ | ||
| 855 | unsigned val; \ | ||
| 856 | \ | ||
| 857 | result = sscanf(buf, "%u\n", &val); \ | ||
| 858 | if (result != 1) \ | ||
| 859 | result = -EINVAL; \ | ||
| 860 | data->name = val; \ | ||
| 861 | if (result < 0) \ | ||
| 862 | return result; \ | ||
| 863 | else \ | ||
| 864 | return count; \ | ||
| 865 | } \ | ||
| 866 | static DEVICE_ATTR(name, S_IRUGO, show_##name, store_##name) | ||
| 867 | |||
| 868 | data_attribute(TermCharEnabled); | ||
| 869 | data_attribute(auto_abort); | ||
| 870 | |||
| 871 | static struct attribute *data_attrs[] = { | ||
| 872 | &dev_attr_TermChar.attr, | ||
| 873 | &dev_attr_TermCharEnabled.attr, | ||
| 874 | &dev_attr_auto_abort.attr, | ||
| 875 | NULL, | ||
| 876 | }; | ||
| 877 | |||
| 878 | static struct attribute_group data_attr_grp = { | ||
| 879 | .attrs = data_attrs, | ||
| 880 | }; | ||
| 881 | |||
| 882 | static int usbtmc_ioctl_indicator_pulse(struct usbtmc_device_data *data) | ||
| 883 | { | ||
| 884 | struct device *dev; | ||
| 885 | u8 *buffer; | ||
| 886 | int rv; | ||
| 887 | |||
| 888 | dev = &data->intf->dev; | ||
| 889 | |||
| 890 | buffer = kmalloc(2, GFP_KERNEL); | ||
| 891 | if (!buffer) | ||
| 892 | return -ENOMEM; | ||
| 893 | |||
| 894 | rv = usb_control_msg(data->usb_dev, | ||
| 895 | usb_rcvctrlpipe(data->usb_dev, 0), | ||
| 896 | USBTMC_REQUEST_INDICATOR_PULSE, | ||
| 897 | USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE, | ||
| 898 | 0, 0, buffer, 0x01, USBTMC_TIMEOUT); | ||
| 899 | |||
| 900 | if (rv < 0) { | ||
| 901 | dev_err(dev, "usb_control_msg returned %d\n", rv); | ||
| 902 | goto exit; | ||
| 903 | } | ||
| 904 | |||
| 905 | dev_dbg(dev, "INDICATOR_PULSE returned %x\n", buffer[0]); | ||
| 906 | |||
| 907 | if (buffer[0] != USBTMC_STATUS_SUCCESS) { | ||
| 908 | dev_err(dev, "INDICATOR_PULSE returned %x\n", buffer[0]); | ||
| 909 | rv = -EPERM; | ||
| 910 | goto exit; | ||
| 911 | } | ||
| 912 | rv = 0; | ||
| 913 | |||
| 914 | exit: | ||
| 915 | kfree(buffer); | ||
| 916 | return rv; | ||
| 917 | } | ||
| 918 | |||
| 919 | static long usbtmc_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | ||
| 920 | { | ||
| 921 | struct usbtmc_device_data *data; | ||
| 922 | int retval = -EBADRQC; | ||
| 923 | |||
| 924 | data = file->private_data; | ||
| 925 | mutex_lock(&data->io_mutex); | ||
| 926 | |||
| 927 | switch (cmd) { | ||
| 928 | case USBTMC_IOCTL_CLEAR_OUT_HALT: | ||
| 929 | retval = usbtmc_ioctl_clear_out_halt(data); | ||
| 930 | |||
| 931 | case USBTMC_IOCTL_CLEAR_IN_HALT: | ||
| 932 | retval = usbtmc_ioctl_clear_in_halt(data); | ||
| 933 | |||
| 934 | case USBTMC_IOCTL_INDICATOR_PULSE: | ||
| 935 | retval = usbtmc_ioctl_indicator_pulse(data); | ||
| 936 | |||
| 937 | case USBTMC_IOCTL_CLEAR: | ||
| 938 | retval = usbtmc_ioctl_clear(data); | ||
| 939 | |||
| 940 | case USBTMC_IOCTL_ABORT_BULK_OUT: | ||
| 941 | retval = usbtmc_ioctl_abort_bulk_out(data); | ||
| 942 | |||
| 943 | case USBTMC_IOCTL_ABORT_BULK_IN: | ||
| 944 | retval = usbtmc_ioctl_abort_bulk_in(data); | ||
| 945 | } | ||
| 946 | |||
| 947 | mutex_unlock(&data->io_mutex); | ||
| 948 | return retval; | ||
| 949 | } | ||
| 950 | |||
| 951 | static struct file_operations fops = { | ||
| 952 | .owner = THIS_MODULE, | ||
| 953 | .read = usbtmc_read, | ||
| 954 | .write = usbtmc_write, | ||
| 955 | .open = usbtmc_open, | ||
| 956 | .release = usbtmc_release, | ||
| 957 | .unlocked_ioctl = usbtmc_ioctl, | ||
| 958 | }; | ||
| 959 | |||
| 960 | static struct usb_class_driver usbtmc_class = { | ||
| 961 | .name = "usbtmc%d", | ||
| 962 | .fops = &fops, | ||
| 963 | .minor_base = USBTMC_MINOR_BASE, | ||
| 964 | }; | ||
| 965 | |||
| 966 | |||
| 967 | static int usbtmc_probe(struct usb_interface *intf, | ||
| 968 | const struct usb_device_id *id) | ||
| 969 | { | ||
| 970 | struct usbtmc_device_data *data; | ||
| 971 | struct usb_host_interface *iface_desc; | ||
| 972 | struct usb_endpoint_descriptor *endpoint; | ||
| 973 | int n; | ||
| 974 | int retcode; | ||
| 975 | |||
| 976 | dev_dbg(&intf->dev, "%s called\n", __func__); | ||
| 977 | |||
| 978 | data = kmalloc(sizeof(struct usbtmc_device_data), GFP_KERNEL); | ||
| 979 | if (!data) { | ||
| 980 | dev_err(&intf->dev, "Unable to allocate kernel memory\n"); | ||
| 981 | return -ENOMEM; | ||
| 982 | } | ||
| 983 | |||
| 984 | data->intf = intf; | ||
| 985 | data->id = id; | ||
| 986 | data->usb_dev = usb_get_dev(interface_to_usbdev(intf)); | ||
| 987 | usb_set_intfdata(intf, data); | ||
| 988 | kref_init(&data->kref); | ||
| 989 | mutex_init(&data->io_mutex); | ||
| 990 | |||
| 991 | /* Initialize USBTMC bTag and other fields */ | ||
| 992 | data->bTag = 1; | ||
| 993 | data->TermCharEnabled = 0; | ||
| 994 | data->TermChar = '\n'; | ||
| 995 | |||
| 996 | /* USBTMC devices have only one setting, so use that */ | ||
| 997 | iface_desc = data->intf->cur_altsetting; | ||
| 998 | |||
| 999 | /* Find bulk in endpoint */ | ||
| 1000 | for (n = 0; n < iface_desc->desc.bNumEndpoints; n++) { | ||
| 1001 | endpoint = &iface_desc->endpoint[n].desc; | ||
| 1002 | |||
| 1003 | if (usb_endpoint_is_bulk_in(endpoint)) { | ||
| 1004 | data->bulk_in = endpoint->bEndpointAddress; | ||
| 1005 | dev_dbg(&intf->dev, "Found bulk in endpoint at %u\n", | ||
| 1006 | data->bulk_in); | ||
| 1007 | break; | ||
| 1008 | } | ||
| 1009 | } | ||
| 1010 | |||
| 1011 | /* Find bulk out endpoint */ | ||
| 1012 | for (n = 0; n < iface_desc->desc.bNumEndpoints; n++) { | ||
| 1013 | endpoint = &iface_desc->endpoint[n].desc; | ||
| 1014 | |||
| 1015 | if (usb_endpoint_is_bulk_out(endpoint)) { | ||
| 1016 | data->bulk_out = endpoint->bEndpointAddress; | ||
| 1017 | dev_dbg(&intf->dev, "Found Bulk out endpoint at %u\n", | ||
| 1018 | data->bulk_out); | ||
| 1019 | break; | ||
| 1020 | } | ||
| 1021 | } | ||
| 1022 | |||
| 1023 | retcode = get_capabilities(data); | ||
| 1024 | if (retcode) | ||
| 1025 | dev_err(&intf->dev, "can't read capabilities\n"); | ||
| 1026 | else | ||
| 1027 | retcode = sysfs_create_group(&intf->dev.kobj, | ||
| 1028 | &capability_attr_grp); | ||
| 1029 | |||
| 1030 | retcode = sysfs_create_group(&intf->dev.kobj, &data_attr_grp); | ||
| 1031 | |||
| 1032 | retcode = usb_register_dev(intf, &usbtmc_class); | ||
| 1033 | if (retcode) { | ||
| 1034 | dev_err(&intf->dev, "Not able to get a minor" | ||
| 1035 | " (base %u, slice default): %d\n", USBTMC_MINOR_BASE, | ||
| 1036 | retcode); | ||
| 1037 | goto error_register; | ||
| 1038 | } | ||
| 1039 | dev_dbg(&intf->dev, "Using minor number %d\n", intf->minor); | ||
| 1040 | |||
| 1041 | return 0; | ||
| 1042 | |||
| 1043 | error_register: | ||
| 1044 | sysfs_remove_group(&intf->dev.kobj, &capability_attr_grp); | ||
| 1045 | sysfs_remove_group(&intf->dev.kobj, &data_attr_grp); | ||
| 1046 | kref_put(&data->kref, usbtmc_delete); | ||
| 1047 | return retcode; | ||
| 1048 | } | ||
| 1049 | |||
| 1050 | static void usbtmc_disconnect(struct usb_interface *intf) | ||
| 1051 | { | ||
| 1052 | struct usbtmc_device_data *data; | ||
| 1053 | |||
| 1054 | dev_dbg(&intf->dev, "usbtmc_disconnect called\n"); | ||
| 1055 | |||
| 1056 | data = usb_get_intfdata(intf); | ||
| 1057 | usb_deregister_dev(intf, &usbtmc_class); | ||
| 1058 | sysfs_remove_group(&intf->dev.kobj, &capability_attr_grp); | ||
| 1059 | sysfs_remove_group(&intf->dev.kobj, &data_attr_grp); | ||
| 1060 | kref_put(&data->kref, usbtmc_delete); | ||
| 1061 | } | ||
| 1062 | |||
| 1063 | static struct usb_driver usbtmc_driver = { | ||
| 1064 | .name = "usbtmc", | ||
| 1065 | .id_table = usbtmc_devices, | ||
| 1066 | .probe = usbtmc_probe, | ||
| 1067 | .disconnect = usbtmc_disconnect | ||
| 1068 | }; | ||
| 1069 | |||
| 1070 | static int __init usbtmc_init(void) | ||
| 1071 | { | ||
| 1072 | int retcode; | ||
| 1073 | |||
| 1074 | retcode = usb_register(&usbtmc_driver); | ||
| 1075 | if (retcode) | ||
| 1076 | printk(KERN_ERR KBUILD_MODNAME": Unable to register driver\n"); | ||
| 1077 | return retcode; | ||
| 1078 | } | ||
| 1079 | module_init(usbtmc_init); | ||
| 1080 | |||
| 1081 | static void __exit usbtmc_exit(void) | ||
| 1082 | { | ||
| 1083 | usb_deregister(&usbtmc_driver); | ||
| 1084 | } | ||
| 1085 | module_exit(usbtmc_exit); | ||
| 1086 | |||
| 1087 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/usb/core/Kconfig b/drivers/usb/core/Kconfig index cc9f397e8398..e1759d17ac5d 100644 --- a/drivers/usb/core/Kconfig +++ b/drivers/usb/core/Kconfig | |||
| @@ -134,5 +134,5 @@ config USB_OTG_BLACKLIST_HUB | |||
| 134 | If you say Y here, then Linux will refuse to enumerate | 134 | If you say Y here, then Linux will refuse to enumerate |
| 135 | external hubs. OTG hosts are allowed to reduce hardware | 135 | external hubs. OTG hosts are allowed to reduce hardware |
| 136 | and software costs by not supporting external hubs. So | 136 | and software costs by not supporting external hubs. So |
| 137 | are "Emedded Hosts" that don't offer OTG support. | 137 | are "Embedded Hosts" that don't offer OTG support. |
| 138 | 138 | ||
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c index 7a4fa791dc19..2bccefebff1b 100644 --- a/drivers/usb/core/devio.c +++ b/drivers/usb/core/devio.c | |||
| @@ -413,7 +413,8 @@ static void driver_disconnect(struct usb_interface *intf) | |||
| 413 | if (likely(ifnum < 8*sizeof(ps->ifclaimed))) | 413 | if (likely(ifnum < 8*sizeof(ps->ifclaimed))) |
| 414 | clear_bit(ifnum, &ps->ifclaimed); | 414 | clear_bit(ifnum, &ps->ifclaimed); |
| 415 | else | 415 | else |
| 416 | warn("interface number %u out of range", ifnum); | 416 | dev_warn(&intf->dev, "interface number %u out of range\n", |
| 417 | ifnum); | ||
| 417 | 418 | ||
| 418 | usb_set_intfdata(intf, NULL); | 419 | usb_set_intfdata(intf, NULL); |
| 419 | 420 | ||
| @@ -624,6 +625,8 @@ static int usbdev_open(struct inode *inode, struct file *file) | |||
| 624 | smp_wmb(); | 625 | smp_wmb(); |
| 625 | list_add_tail(&ps->list, &dev->filelist); | 626 | list_add_tail(&ps->list, &dev->filelist); |
| 626 | file->private_data = ps; | 627 | file->private_data = ps; |
| 628 | snoop(&dev->dev, "opened by process %d: %s\n", task_pid_nr(current), | ||
| 629 | current->comm); | ||
| 627 | out: | 630 | out: |
| 628 | if (ret) { | 631 | if (ret) { |
| 629 | kfree(ps); | 632 | kfree(ps); |
| @@ -1774,19 +1777,20 @@ int __init usb_devio_init(void) | |||
| 1774 | retval = register_chrdev_region(USB_DEVICE_DEV, USB_DEVICE_MAX, | 1777 | retval = register_chrdev_region(USB_DEVICE_DEV, USB_DEVICE_MAX, |
| 1775 | "usb_device"); | 1778 | "usb_device"); |
| 1776 | if (retval) { | 1779 | if (retval) { |
| 1777 | err("unable to register minors for usb_device"); | 1780 | printk(KERN_ERR "Unable to register minors for usb_device\n"); |
| 1778 | goto out; | 1781 | goto out; |
| 1779 | } | 1782 | } |
| 1780 | cdev_init(&usb_device_cdev, &usbdev_file_operations); | 1783 | cdev_init(&usb_device_cdev, &usbdev_file_operations); |
| 1781 | retval = cdev_add(&usb_device_cdev, USB_DEVICE_DEV, USB_DEVICE_MAX); | 1784 | retval = cdev_add(&usb_device_cdev, USB_DEVICE_DEV, USB_DEVICE_MAX); |
| 1782 | if (retval) { | 1785 | if (retval) { |
| 1783 | err("unable to get usb_device major %d", USB_DEVICE_MAJOR); | 1786 | printk(KERN_ERR "Unable to get usb_device major %d\n", |
| 1787 | USB_DEVICE_MAJOR); | ||
| 1784 | goto error_cdev; | 1788 | goto error_cdev; |
| 1785 | } | 1789 | } |
| 1786 | #ifdef CONFIG_USB_DEVICE_CLASS | 1790 | #ifdef CONFIG_USB_DEVICE_CLASS |
| 1787 | usb_classdev_class = class_create(THIS_MODULE, "usb_device"); | 1791 | usb_classdev_class = class_create(THIS_MODULE, "usb_device"); |
| 1788 | if (IS_ERR(usb_classdev_class)) { | 1792 | if (IS_ERR(usb_classdev_class)) { |
| 1789 | err("unable to register usb_device class"); | 1793 | printk(KERN_ERR "Unable to register usb_device class\n"); |
| 1790 | retval = PTR_ERR(usb_classdev_class); | 1794 | retval = PTR_ERR(usb_classdev_class); |
| 1791 | cdev_del(&usb_device_cdev); | 1795 | cdev_del(&usb_device_cdev); |
| 1792 | usb_classdev_class = NULL; | 1796 | usb_classdev_class = NULL; |
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c index 5a7fa6f09958..e935be7eb468 100644 --- a/drivers/usb/core/driver.c +++ b/drivers/usb/core/driver.c | |||
| @@ -1070,7 +1070,8 @@ static int autosuspend_check(struct usb_device *udev, int reschedule) | |||
| 1070 | struct usb_driver *driver; | 1070 | struct usb_driver *driver; |
| 1071 | 1071 | ||
| 1072 | driver = to_usb_driver(intf->dev.driver); | 1072 | driver = to_usb_driver(intf->dev.driver); |
| 1073 | if (!driver->reset_resume) | 1073 | if (!driver->reset_resume || |
| 1074 | intf->needs_remote_wakeup) | ||
| 1074 | return -EOPNOTSUPP; | 1075 | return -EOPNOTSUPP; |
| 1075 | } | 1076 | } |
| 1076 | } | 1077 | } |
diff --git a/drivers/usb/core/endpoint.c b/drivers/usb/core/endpoint.c index 22912136fc14..946fae43d622 100644 --- a/drivers/usb/core/endpoint.c +++ b/drivers/usb/core/endpoint.c | |||
| @@ -169,7 +169,8 @@ static int usb_endpoint_major_init(void) | |||
| 169 | error = alloc_chrdev_region(&dev, 0, MAX_ENDPOINT_MINORS, | 169 | error = alloc_chrdev_region(&dev, 0, MAX_ENDPOINT_MINORS, |
| 170 | "usb_endpoint"); | 170 | "usb_endpoint"); |
| 171 | if (error) { | 171 | if (error) { |
| 172 | err("unable to get a dynamic major for usb endpoints"); | 172 | printk(KERN_ERR "Unable to get a dynamic major for " |
| 173 | "usb endpoints.\n"); | ||
| 173 | return error; | 174 | return error; |
| 174 | } | 175 | } |
| 175 | usb_endpoint_major = MAJOR(dev); | 176 | usb_endpoint_major = MAJOR(dev); |
diff --git a/drivers/usb/core/file.c b/drivers/usb/core/file.c index 55f7f310924b..997e659ff693 100644 --- a/drivers/usb/core/file.c +++ b/drivers/usb/core/file.c | |||
| @@ -86,7 +86,7 @@ static int init_usb_class(void) | |||
| 86 | usb_class->class = class_create(THIS_MODULE, "usb"); | 86 | usb_class->class = class_create(THIS_MODULE, "usb"); |
| 87 | if (IS_ERR(usb_class->class)) { | 87 | if (IS_ERR(usb_class->class)) { |
| 88 | result = IS_ERR(usb_class->class); | 88 | result = IS_ERR(usb_class->class); |
| 89 | err("class_create failed for usb devices"); | 89 | printk(KERN_ERR "class_create failed for usb devices\n"); |
| 90 | kfree(usb_class); | 90 | kfree(usb_class); |
| 91 | usb_class = NULL; | 91 | usb_class = NULL; |
| 92 | } | 92 | } |
| @@ -115,7 +115,8 @@ int usb_major_init(void) | |||
| 115 | 115 | ||
| 116 | error = register_chrdev(USB_MAJOR, "usb", &usb_fops); | 116 | error = register_chrdev(USB_MAJOR, "usb", &usb_fops); |
| 117 | if (error) | 117 | if (error) |
| 118 | err("unable to get major %d for usb devices", USB_MAJOR); | 118 | printk(KERN_ERR "Unable to get major %d for usb devices\n", |
| 119 | USB_MAJOR); | ||
| 119 | 120 | ||
| 120 | return error; | 121 | return error; |
| 121 | } | 122 | } |
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index c8035a8216bd..fc9018e72a09 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c | |||
| @@ -81,6 +81,10 @@ | |||
| 81 | 81 | ||
| 82 | /*-------------------------------------------------------------------------*/ | 82 | /*-------------------------------------------------------------------------*/ |
| 83 | 83 | ||
| 84 | /* Keep track of which host controller drivers are loaded */ | ||
| 85 | unsigned long usb_hcds_loaded; | ||
| 86 | EXPORT_SYMBOL_GPL(usb_hcds_loaded); | ||
| 87 | |||
| 84 | /* host controllers we manage */ | 88 | /* host controllers we manage */ |
| 85 | LIST_HEAD (usb_bus_list); | 89 | LIST_HEAD (usb_bus_list); |
| 86 | EXPORT_SYMBOL_GPL (usb_bus_list); | 90 | EXPORT_SYMBOL_GPL (usb_bus_list); |
diff --git a/drivers/usb/core/hcd.h b/drivers/usb/core/hcd.h index e710ce04e228..2dcde61c465e 100644 --- a/drivers/usb/core/hcd.h +++ b/drivers/usb/core/hcd.h | |||
| @@ -482,4 +482,10 @@ static inline void usbmon_urb_complete(struct usb_bus *bus, struct urb *urb, | |||
| 482 | */ | 482 | */ |
| 483 | extern struct rw_semaphore ehci_cf_port_reset_rwsem; | 483 | extern struct rw_semaphore ehci_cf_port_reset_rwsem; |
| 484 | 484 | ||
| 485 | /* Keep track of which host controller drivers are loaded */ | ||
| 486 | #define USB_UHCI_LOADED 0 | ||
| 487 | #define USB_OHCI_LOADED 1 | ||
| 488 | #define USB_EHCI_LOADED 2 | ||
| 489 | extern unsigned long usb_hcds_loaded; | ||
| 490 | |||
| 485 | #endif /* __KERNEL__ */ | 491 | #endif /* __KERNEL__ */ |
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index d99963873e37..d73ce262c365 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c | |||
| @@ -77,6 +77,7 @@ struct usb_hub { | |||
| 77 | unsigned has_indicators:1; | 77 | unsigned has_indicators:1; |
| 78 | u8 indicator[USB_MAXCHILDREN]; | 78 | u8 indicator[USB_MAXCHILDREN]; |
| 79 | struct delayed_work leds; | 79 | struct delayed_work leds; |
| 80 | struct delayed_work init_work; | ||
| 80 | }; | 81 | }; |
| 81 | 82 | ||
| 82 | 83 | ||
| @@ -100,6 +101,15 @@ module_param (blinkenlights, bool, S_IRUGO); | |||
| 100 | MODULE_PARM_DESC (blinkenlights, "true to cycle leds on hubs"); | 101 | MODULE_PARM_DESC (blinkenlights, "true to cycle leds on hubs"); |
| 101 | 102 | ||
| 102 | /* | 103 | /* |
| 104 | * Device SATA8000 FW1.0 from DATAST0R Technology Corp requires about | ||
| 105 | * 10 seconds to send reply for the initial 64-byte descriptor request. | ||
| 106 | */ | ||
| 107 | /* define initial 64-byte descriptor request timeout in milliseconds */ | ||
| 108 | static int initial_descriptor_timeout = USB_CTRL_GET_TIMEOUT; | ||
| 109 | module_param(initial_descriptor_timeout, int, S_IRUGO|S_IWUSR); | ||
| 110 | MODULE_PARM_DESC(initial_descriptor_timeout, "initial 64-byte descriptor request timeout in milliseconds (default 5000 - 5.0 seconds)"); | ||
| 111 | |||
| 112 | /* | ||
| 103 | * As of 2.6.10 we introduce a new USB device initialization scheme which | 113 | * As of 2.6.10 we introduce a new USB device initialization scheme which |
| 104 | * closely resembles the way Windows works. Hopefully it will be compatible | 114 | * closely resembles the way Windows works. Hopefully it will be compatible |
| 105 | * with a wider range of devices than the old scheme. However some previously | 115 | * with a wider range of devices than the old scheme. However some previously |
| @@ -515,10 +525,14 @@ void usb_hub_tt_clear_buffer (struct usb_device *udev, int pipe) | |||
| 515 | } | 525 | } |
| 516 | EXPORT_SYMBOL_GPL(usb_hub_tt_clear_buffer); | 526 | EXPORT_SYMBOL_GPL(usb_hub_tt_clear_buffer); |
| 517 | 527 | ||
| 518 | static void hub_power_on(struct usb_hub *hub) | 528 | /* If do_delay is false, return the number of milliseconds the caller |
| 529 | * needs to delay. | ||
| 530 | */ | ||
| 531 | static unsigned hub_power_on(struct usb_hub *hub, bool do_delay) | ||
| 519 | { | 532 | { |
| 520 | int port1; | 533 | int port1; |
| 521 | unsigned pgood_delay = hub->descriptor->bPwrOn2PwrGood * 2; | 534 | unsigned pgood_delay = hub->descriptor->bPwrOn2PwrGood * 2; |
| 535 | unsigned delay; | ||
| 522 | u16 wHubCharacteristics = | 536 | u16 wHubCharacteristics = |
| 523 | le16_to_cpu(hub->descriptor->wHubCharacteristics); | 537 | le16_to_cpu(hub->descriptor->wHubCharacteristics); |
| 524 | 538 | ||
| @@ -537,7 +551,10 @@ static void hub_power_on(struct usb_hub *hub) | |||
| 537 | set_port_feature(hub->hdev, port1, USB_PORT_FEAT_POWER); | 551 | set_port_feature(hub->hdev, port1, USB_PORT_FEAT_POWER); |
| 538 | 552 | ||
| 539 | /* Wait at least 100 msec for power to become stable */ | 553 | /* Wait at least 100 msec for power to become stable */ |
| 540 | msleep(max(pgood_delay, (unsigned) 100)); | 554 | delay = max(pgood_delay, (unsigned) 100); |
| 555 | if (do_delay) | ||
| 556 | msleep(delay); | ||
| 557 | return delay; | ||
| 541 | } | 558 | } |
| 542 | 559 | ||
| 543 | static int hub_hub_status(struct usb_hub *hub, | 560 | static int hub_hub_status(struct usb_hub *hub, |
| @@ -599,21 +616,55 @@ static void hub_port_logical_disconnect(struct usb_hub *hub, int port1) | |||
| 599 | } | 616 | } |
| 600 | 617 | ||
| 601 | enum hub_activation_type { | 618 | enum hub_activation_type { |
| 602 | HUB_INIT, HUB_POST_RESET, HUB_RESUME, HUB_RESET_RESUME | 619 | HUB_INIT, HUB_INIT2, HUB_INIT3, |
| 620 | HUB_POST_RESET, HUB_RESUME, HUB_RESET_RESUME, | ||
| 603 | }; | 621 | }; |
| 604 | 622 | ||
| 623 | static void hub_init_func2(struct work_struct *ws); | ||
| 624 | static void hub_init_func3(struct work_struct *ws); | ||
| 625 | |||
| 605 | static void hub_activate(struct usb_hub *hub, enum hub_activation_type type) | 626 | static void hub_activate(struct usb_hub *hub, enum hub_activation_type type) |
| 606 | { | 627 | { |
| 607 | struct usb_device *hdev = hub->hdev; | 628 | struct usb_device *hdev = hub->hdev; |
| 608 | int port1; | 629 | int port1; |
| 609 | int status; | 630 | int status; |
| 610 | bool need_debounce_delay = false; | 631 | bool need_debounce_delay = false; |
| 632 | unsigned delay; | ||
| 633 | |||
| 634 | /* Continue a partial initialization */ | ||
| 635 | if (type == HUB_INIT2) | ||
| 636 | goto init2; | ||
| 637 | if (type == HUB_INIT3) | ||
| 638 | goto init3; | ||
| 611 | 639 | ||
| 612 | /* After a resume, port power should still be on. | 640 | /* After a resume, port power should still be on. |
| 613 | * For any other type of activation, turn it on. | 641 | * For any other type of activation, turn it on. |
| 614 | */ | 642 | */ |
| 615 | if (type != HUB_RESUME) | 643 | if (type != HUB_RESUME) { |
| 616 | hub_power_on(hub); | 644 | |
| 645 | /* Speed up system boot by using a delayed_work for the | ||
| 646 | * hub's initial power-up delays. This is pretty awkward | ||
| 647 | * and the implementation looks like a home-brewed sort of | ||
| 648 | * setjmp/longjmp, but it saves at least 100 ms for each | ||
| 649 | * root hub (assuming usbcore is compiled into the kernel | ||
| 650 | * rather than as a module). It adds up. | ||
| 651 | * | ||
| 652 | * This can't be done for HUB_RESUME or HUB_RESET_RESUME | ||
| 653 | * because for those activation types the ports have to be | ||
| 654 | * operational when we return. In theory this could be done | ||
| 655 | * for HUB_POST_RESET, but it's easier not to. | ||
| 656 | */ | ||
| 657 | if (type == HUB_INIT) { | ||
| 658 | delay = hub_power_on(hub, false); | ||
| 659 | PREPARE_DELAYED_WORK(&hub->init_work, hub_init_func2); | ||
| 660 | schedule_delayed_work(&hub->init_work, | ||
| 661 | msecs_to_jiffies(delay)); | ||
| 662 | return; /* Continues at init2: below */ | ||
| 663 | } else { | ||
| 664 | hub_power_on(hub, true); | ||
| 665 | } | ||
| 666 | } | ||
| 667 | init2: | ||
| 617 | 668 | ||
| 618 | /* Check each port and set hub->change_bits to let khubd know | 669 | /* Check each port and set hub->change_bits to let khubd know |
| 619 | * which ports need attention. | 670 | * which ports need attention. |
| @@ -692,9 +743,20 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type) | |||
| 692 | * If any port-status changes do occur during this delay, khubd | 743 | * If any port-status changes do occur during this delay, khubd |
| 693 | * will see them later and handle them normally. | 744 | * will see them later and handle them normally. |
| 694 | */ | 745 | */ |
| 695 | if (need_debounce_delay) | 746 | if (need_debounce_delay) { |
| 696 | msleep(HUB_DEBOUNCE_STABLE); | 747 | delay = HUB_DEBOUNCE_STABLE; |
| 697 | 748 | ||
| 749 | /* Don't do a long sleep inside a workqueue routine */ | ||
| 750 | if (type == HUB_INIT2) { | ||
| 751 | PREPARE_DELAYED_WORK(&hub->init_work, hub_init_func3); | ||
| 752 | schedule_delayed_work(&hub->init_work, | ||
| 753 | msecs_to_jiffies(delay)); | ||
| 754 | return; /* Continues at init3: below */ | ||
| 755 | } else { | ||
| 756 | msleep(delay); | ||
| 757 | } | ||
| 758 | } | ||
| 759 | init3: | ||
| 698 | hub->quiescing = 0; | 760 | hub->quiescing = 0; |
| 699 | 761 | ||
| 700 | status = usb_submit_urb(hub->urb, GFP_NOIO); | 762 | status = usb_submit_urb(hub->urb, GFP_NOIO); |
| @@ -707,6 +769,21 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type) | |||
| 707 | kick_khubd(hub); | 769 | kick_khubd(hub); |
| 708 | } | 770 | } |
| 709 | 771 | ||
| 772 | /* Implement the continuations for the delays above */ | ||
| 773 | static void hub_init_func2(struct work_struct *ws) | ||
| 774 | { | ||
| 775 | struct usb_hub *hub = container_of(ws, struct usb_hub, init_work.work); | ||
| 776 | |||
| 777 | hub_activate(hub, HUB_INIT2); | ||
| 778 | } | ||
| 779 | |||
| 780 | static void hub_init_func3(struct work_struct *ws) | ||
| 781 | { | ||
| 782 | struct usb_hub *hub = container_of(ws, struct usb_hub, init_work.work); | ||
| 783 | |||
| 784 | hub_activate(hub, HUB_INIT3); | ||
| 785 | } | ||
| 786 | |||
| 710 | enum hub_quiescing_type { | 787 | enum hub_quiescing_type { |
| 711 | HUB_DISCONNECT, HUB_PRE_RESET, HUB_SUSPEND | 788 | HUB_DISCONNECT, HUB_PRE_RESET, HUB_SUSPEND |
| 712 | }; | 789 | }; |
| @@ -716,6 +793,8 @@ static void hub_quiesce(struct usb_hub *hub, enum hub_quiescing_type type) | |||
| 716 | struct usb_device *hdev = hub->hdev; | 793 | struct usb_device *hdev = hub->hdev; |
| 717 | int i; | 794 | int i; |
| 718 | 795 | ||
| 796 | cancel_delayed_work_sync(&hub->init_work); | ||
| 797 | |||
| 719 | /* khubd and related activity won't re-trigger */ | 798 | /* khubd and related activity won't re-trigger */ |
| 720 | hub->quiescing = 1; | 799 | hub->quiescing = 1; |
| 721 | 800 | ||
| @@ -1099,6 +1178,7 @@ descriptor_error: | |||
| 1099 | hub->intfdev = &intf->dev; | 1178 | hub->intfdev = &intf->dev; |
| 1100 | hub->hdev = hdev; | 1179 | hub->hdev = hdev; |
| 1101 | INIT_DELAYED_WORK(&hub->leds, led_work); | 1180 | INIT_DELAYED_WORK(&hub->leds, led_work); |
| 1181 | INIT_DELAYED_WORK(&hub->init_work, NULL); | ||
| 1102 | usb_get_intf(intf); | 1182 | usb_get_intf(intf); |
| 1103 | 1183 | ||
| 1104 | usb_set_intfdata (intf, hub); | 1184 | usb_set_intfdata (intf, hub); |
| @@ -2467,7 +2547,7 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1, | |||
| 2467 | USB_REQ_GET_DESCRIPTOR, USB_DIR_IN, | 2547 | USB_REQ_GET_DESCRIPTOR, USB_DIR_IN, |
| 2468 | USB_DT_DEVICE << 8, 0, | 2548 | USB_DT_DEVICE << 8, 0, |
| 2469 | buf, GET_DESCRIPTOR_BUFSIZE, | 2549 | buf, GET_DESCRIPTOR_BUFSIZE, |
| 2470 | USB_CTRL_GET_TIMEOUT); | 2550 | initial_descriptor_timeout); |
| 2471 | switch (buf->bMaxPacketSize0) { | 2551 | switch (buf->bMaxPacketSize0) { |
| 2472 | case 8: case 16: case 32: case 64: case 255: | 2552 | case 8: case 16: case 32: case 64: case 255: |
| 2473 | if (buf->bDescriptorType == | 2553 | if (buf->bDescriptorType == |
| @@ -3035,7 +3115,7 @@ static void hub_events(void) | |||
| 3035 | i); | 3115 | i); |
| 3036 | clear_port_feature(hdev, i, | 3116 | clear_port_feature(hdev, i, |
| 3037 | USB_PORT_FEAT_C_OVER_CURRENT); | 3117 | USB_PORT_FEAT_C_OVER_CURRENT); |
| 3038 | hub_power_on(hub); | 3118 | hub_power_on(hub, true); |
| 3039 | } | 3119 | } |
| 3040 | 3120 | ||
| 3041 | if (portchange & USB_PORT_STAT_C_RESET) { | 3121 | if (portchange & USB_PORT_STAT_C_RESET) { |
| @@ -3070,7 +3150,7 @@ static void hub_events(void) | |||
| 3070 | dev_dbg (hub_dev, "overcurrent change\n"); | 3150 | dev_dbg (hub_dev, "overcurrent change\n"); |
| 3071 | msleep(500); /* Cool down */ | 3151 | msleep(500); /* Cool down */ |
| 3072 | clear_hub_feature(hdev, C_HUB_OVER_CURRENT); | 3152 | clear_hub_feature(hdev, C_HUB_OVER_CURRENT); |
| 3073 | hub_power_on(hub); | 3153 | hub_power_on(hub, true); |
| 3074 | } | 3154 | } |
| 3075 | } | 3155 | } |
| 3076 | 3156 | ||
diff --git a/drivers/usb/core/inode.c b/drivers/usb/core/inode.c index 77fa7a080801..94632264dccf 100644 --- a/drivers/usb/core/inode.c +++ b/drivers/usb/core/inode.c | |||
| @@ -180,8 +180,8 @@ static int parse_options(struct super_block *s, char *data) | |||
| 180 | listmode = option & S_IRWXUGO; | 180 | listmode = option & S_IRWXUGO; |
| 181 | break; | 181 | break; |
| 182 | default: | 182 | default: |
| 183 | err("usbfs: unrecognised mount option \"%s\" " | 183 | printk(KERN_ERR "usbfs: unrecognised mount option " |
| 184 | "or missing value\n", p); | 184 | "\"%s\" or missing value\n", p); |
| 185 | return -EINVAL; | 185 | return -EINVAL; |
| 186 | } | 186 | } |
| 187 | } | 187 | } |
| @@ -240,7 +240,9 @@ static void update_sb(struct super_block *sb) | |||
| 240 | update_special(bus); | 240 | update_special(bus); |
| 241 | break; | 241 | break; |
| 242 | default: | 242 | default: |
| 243 | warn("Unknown node %s mode %x found on remount!\n",bus->d_name.name,bus->d_inode->i_mode); | 243 | printk(KERN_WARNING "usbfs: Unknown node %s " |
| 244 | "mode %x found on remount!\n", | ||
| 245 | bus->d_name.name, bus->d_inode->i_mode); | ||
| 244 | break; | 246 | break; |
| 245 | } | 247 | } |
| 246 | } | 248 | } |
| @@ -259,7 +261,7 @@ static int remount(struct super_block *sb, int *flags, char *data) | |||
| 259 | return 0; | 261 | return 0; |
| 260 | 262 | ||
| 261 | if (parse_options(sb, data)) { | 263 | if (parse_options(sb, data)) { |
| 262 | warn("usbfs: mount parameter error:"); | 264 | printk(KERN_WARNING "usbfs: mount parameter error.\n"); |
| 263 | return -EINVAL; | 265 | return -EINVAL; |
| 264 | } | 266 | } |
| 265 | 267 | ||
| @@ -599,7 +601,7 @@ static int create_special_files (void) | |||
| 599 | /* create the devices special file */ | 601 | /* create the devices special file */ |
| 600 | retval = simple_pin_fs(&usb_fs_type, &usbfs_mount, &usbfs_mount_count); | 602 | retval = simple_pin_fs(&usb_fs_type, &usbfs_mount, &usbfs_mount_count); |
| 601 | if (retval) { | 603 | if (retval) { |
| 602 | err ("Unable to get usbfs mount"); | 604 | printk(KERN_ERR "Unable to get usbfs mount\n"); |
| 603 | goto exit; | 605 | goto exit; |
| 604 | } | 606 | } |
| 605 | 607 | ||
| @@ -611,7 +613,7 @@ static int create_special_files (void) | |||
| 611 | NULL, &usbfs_devices_fops, | 613 | NULL, &usbfs_devices_fops, |
| 612 | listuid, listgid); | 614 | listuid, listgid); |
| 613 | if (devices_usbfs_dentry == NULL) { | 615 | if (devices_usbfs_dentry == NULL) { |
| 614 | err ("Unable to create devices usbfs file"); | 616 | printk(KERN_ERR "Unable to create devices usbfs file\n"); |
| 615 | retval = -ENODEV; | 617 | retval = -ENODEV; |
| 616 | goto error_clean_mounts; | 618 | goto error_clean_mounts; |
| 617 | } | 619 | } |
| @@ -663,7 +665,7 @@ static void usbfs_add_bus(struct usb_bus *bus) | |||
| 663 | bus->usbfs_dentry = fs_create_file (name, busmode | S_IFDIR, parent, | 665 | bus->usbfs_dentry = fs_create_file (name, busmode | S_IFDIR, parent, |
| 664 | bus, NULL, busuid, busgid); | 666 | bus, NULL, busuid, busgid); |
| 665 | if (bus->usbfs_dentry == NULL) { | 667 | if (bus->usbfs_dentry == NULL) { |
| 666 | err ("error creating usbfs bus entry"); | 668 | printk(KERN_ERR "Error creating usbfs bus entry\n"); |
| 667 | return; | 669 | return; |
| 668 | } | 670 | } |
| 669 | } | 671 | } |
| @@ -694,7 +696,7 @@ static void usbfs_add_device(struct usb_device *dev) | |||
| 694 | &usbdev_file_operations, | 696 | &usbdev_file_operations, |
| 695 | devuid, devgid); | 697 | devuid, devgid); |
| 696 | if (dev->usbfs_dentry == NULL) { | 698 | if (dev->usbfs_dentry == NULL) { |
| 697 | err ("error creating usbfs device entry"); | 699 | printk(KERN_ERR "Error creating usbfs device entry\n"); |
| 698 | return; | 700 | return; |
| 699 | } | 701 | } |
| 700 | 702 | ||
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index 286b4431a097..887738577b28 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c | |||
| @@ -1204,7 +1204,8 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate) | |||
| 1204 | 1204 | ||
| 1205 | alt = usb_altnum_to_altsetting(iface, alternate); | 1205 | alt = usb_altnum_to_altsetting(iface, alternate); |
| 1206 | if (!alt) { | 1206 | if (!alt) { |
| 1207 | warn("selecting invalid altsetting %d", alternate); | 1207 | dev_warn(&dev->dev, "selecting invalid altsetting %d", |
| 1208 | alternate); | ||
| 1208 | return -EINVAL; | 1209 | return -EINVAL; |
| 1209 | } | 1210 | } |
| 1210 | 1211 | ||
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c index 5e1f5d55bf04..f66fba11fbd5 100644 --- a/drivers/usb/core/sysfs.c +++ b/drivers/usb/core/sysfs.c | |||
| @@ -743,6 +743,29 @@ static ssize_t show_modalias(struct device *dev, | |||
| 743 | } | 743 | } |
| 744 | static DEVICE_ATTR(modalias, S_IRUGO, show_modalias, NULL); | 744 | static DEVICE_ATTR(modalias, S_IRUGO, show_modalias, NULL); |
| 745 | 745 | ||
| 746 | static ssize_t show_supports_autosuspend(struct device *dev, | ||
| 747 | struct device_attribute *attr, char *buf) | ||
| 748 | { | ||
| 749 | struct usb_interface *intf; | ||
| 750 | struct usb_device *udev; | ||
| 751 | int ret; | ||
| 752 | |||
| 753 | intf = to_usb_interface(dev); | ||
| 754 | udev = interface_to_usbdev(intf); | ||
| 755 | |||
| 756 | usb_lock_device(udev); | ||
| 757 | /* Devices will be autosuspended even when an interface isn't claimed */ | ||
| 758 | if (!intf->dev.driver || | ||
| 759 | to_usb_driver(intf->dev.driver)->supports_autosuspend) | ||
| 760 | ret = sprintf(buf, "%u\n", 1); | ||
| 761 | else | ||
| 762 | ret = sprintf(buf, "%u\n", 0); | ||
| 763 | usb_unlock_device(udev); | ||
| 764 | |||
| 765 | return ret; | ||
| 766 | } | ||
| 767 | static DEVICE_ATTR(supports_autosuspend, S_IRUGO, show_supports_autosuspend, NULL); | ||
| 768 | |||
| 746 | static struct attribute *intf_attrs[] = { | 769 | static struct attribute *intf_attrs[] = { |
| 747 | &dev_attr_bInterfaceNumber.attr, | 770 | &dev_attr_bInterfaceNumber.attr, |
| 748 | &dev_attr_bAlternateSetting.attr, | 771 | &dev_attr_bAlternateSetting.attr, |
| @@ -751,6 +774,7 @@ static struct attribute *intf_attrs[] = { | |||
| 751 | &dev_attr_bInterfaceSubClass.attr, | 774 | &dev_attr_bInterfaceSubClass.attr, |
| 752 | &dev_attr_bInterfaceProtocol.attr, | 775 | &dev_attr_bInterfaceProtocol.attr, |
| 753 | &dev_attr_modalias.attr, | 776 | &dev_attr_modalias.attr, |
| 777 | &dev_attr_supports_autosuspend.attr, | ||
| 754 | NULL, | 778 | NULL, |
| 755 | }; | 779 | }; |
| 756 | static struct attribute_group intf_attr_grp = { | 780 | static struct attribute_group intf_attr_grp = { |
diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c index 47111e88f791..f2638009a464 100644 --- a/drivers/usb/core/urb.c +++ b/drivers/usb/core/urb.c | |||
| @@ -10,6 +10,8 @@ | |||
| 10 | 10 | ||
| 11 | #define to_urb(d) container_of(d, struct urb, kref) | 11 | #define to_urb(d) container_of(d, struct urb, kref) |
| 12 | 12 | ||
| 13 | static DEFINE_SPINLOCK(usb_reject_lock); | ||
| 14 | |||
| 13 | static void urb_destroy(struct kref *kref) | 15 | static void urb_destroy(struct kref *kref) |
| 14 | { | 16 | { |
| 15 | struct urb *urb = to_urb(kref); | 17 | struct urb *urb = to_urb(kref); |
| @@ -68,7 +70,7 @@ struct urb *usb_alloc_urb(int iso_packets, gfp_t mem_flags) | |||
| 68 | iso_packets * sizeof(struct usb_iso_packet_descriptor), | 70 | iso_packets * sizeof(struct usb_iso_packet_descriptor), |
| 69 | mem_flags); | 71 | mem_flags); |
| 70 | if (!urb) { | 72 | if (!urb) { |
| 71 | err("alloc_urb: kmalloc failed"); | 73 | printk(KERN_ERR "alloc_urb: kmalloc failed\n"); |
| 72 | return NULL; | 74 | return NULL; |
| 73 | } | 75 | } |
| 74 | usb_init_urb(urb); | 76 | usb_init_urb(urb); |
| @@ -127,6 +129,13 @@ void usb_anchor_urb(struct urb *urb, struct usb_anchor *anchor) | |||
| 127 | usb_get_urb(urb); | 129 | usb_get_urb(urb); |
| 128 | list_add_tail(&urb->anchor_list, &anchor->urb_list); | 130 | list_add_tail(&urb->anchor_list, &anchor->urb_list); |
| 129 | urb->anchor = anchor; | 131 | urb->anchor = anchor; |
| 132 | |||
| 133 | if (unlikely(anchor->poisoned)) { | ||
| 134 | spin_lock(&usb_reject_lock); | ||
| 135 | urb->reject++; | ||
| 136 | spin_unlock(&usb_reject_lock); | ||
| 137 | } | ||
| 138 | |||
| 130 | spin_unlock_irqrestore(&anchor->lock, flags); | 139 | spin_unlock_irqrestore(&anchor->lock, flags); |
| 131 | } | 140 | } |
| 132 | EXPORT_SYMBOL_GPL(usb_anchor_urb); | 141 | EXPORT_SYMBOL_GPL(usb_anchor_urb); |
| @@ -398,7 +407,7 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags) | |||
| 398 | 407 | ||
| 399 | /* fail if submitter gave bogus flags */ | 408 | /* fail if submitter gave bogus flags */ |
| 400 | if (urb->transfer_flags != orig_flags) { | 409 | if (urb->transfer_flags != orig_flags) { |
| 401 | err("BOGUS urb flags, %x --> %x", | 410 | dev_err(&dev->dev, "BOGUS urb flags, %x --> %x\n", |
| 402 | orig_flags, urb->transfer_flags); | 411 | orig_flags, urb->transfer_flags); |
| 403 | return -EINVAL; | 412 | return -EINVAL; |
| 404 | } | 413 | } |
| @@ -544,25 +553,70 @@ EXPORT_SYMBOL_GPL(usb_unlink_urb); | |||
| 544 | */ | 553 | */ |
| 545 | void usb_kill_urb(struct urb *urb) | 554 | void usb_kill_urb(struct urb *urb) |
| 546 | { | 555 | { |
| 547 | static DEFINE_MUTEX(reject_mutex); | ||
| 548 | |||
| 549 | might_sleep(); | 556 | might_sleep(); |
| 550 | if (!(urb && urb->dev && urb->ep)) | 557 | if (!(urb && urb->dev && urb->ep)) |
| 551 | return; | 558 | return; |
| 552 | mutex_lock(&reject_mutex); | 559 | spin_lock_irq(&usb_reject_lock); |
| 553 | ++urb->reject; | 560 | ++urb->reject; |
| 554 | mutex_unlock(&reject_mutex); | 561 | spin_unlock_irq(&usb_reject_lock); |
| 555 | 562 | ||
| 556 | usb_hcd_unlink_urb(urb, -ENOENT); | 563 | usb_hcd_unlink_urb(urb, -ENOENT); |
| 557 | wait_event(usb_kill_urb_queue, atomic_read(&urb->use_count) == 0); | 564 | wait_event(usb_kill_urb_queue, atomic_read(&urb->use_count) == 0); |
| 558 | 565 | ||
| 559 | mutex_lock(&reject_mutex); | 566 | spin_lock_irq(&usb_reject_lock); |
| 560 | --urb->reject; | 567 | --urb->reject; |
| 561 | mutex_unlock(&reject_mutex); | 568 | spin_unlock_irq(&usb_reject_lock); |
| 562 | } | 569 | } |
| 563 | EXPORT_SYMBOL_GPL(usb_kill_urb); | 570 | EXPORT_SYMBOL_GPL(usb_kill_urb); |
| 564 | 571 | ||
| 565 | /** | 572 | /** |
| 573 | * usb_poison_urb - reliably kill a transfer and prevent further use of an URB | ||
| 574 | * @urb: pointer to URB describing a previously submitted request, | ||
| 575 | * may be NULL | ||
| 576 | * | ||
| 577 | * This routine cancels an in-progress request. It is guaranteed that | ||
| 578 | * upon return all completion handlers will have finished and the URB | ||
| 579 | * will be totally idle and cannot be reused. These features make | ||
| 580 | * this an ideal way to stop I/O in a disconnect() callback. | ||
| 581 | * If the request has not already finished or been unlinked | ||
| 582 | * the completion handler will see urb->status == -ENOENT. | ||
| 583 | * | ||
| 584 | * After and while the routine runs, attempts to resubmit the URB will fail | ||
| 585 | * with error -EPERM. Thus even if the URB's completion handler always | ||
| 586 | * tries to resubmit, it will not succeed and the URB will become idle. | ||
| 587 | * | ||
| 588 | * This routine may not be used in an interrupt context (such as a bottom | ||
| 589 | * half or a completion handler), or when holding a spinlock, or in other | ||
| 590 | * situations where the caller can't schedule(). | ||
| 591 | */ | ||
| 592 | void usb_poison_urb(struct urb *urb) | ||
| 593 | { | ||
| 594 | might_sleep(); | ||
| 595 | if (!(urb && urb->dev && urb->ep)) | ||
| 596 | return; | ||
| 597 | spin_lock_irq(&usb_reject_lock); | ||
| 598 | ++urb->reject; | ||
| 599 | spin_unlock_irq(&usb_reject_lock); | ||
| 600 | |||
| 601 | usb_hcd_unlink_urb(urb, -ENOENT); | ||
| 602 | wait_event(usb_kill_urb_queue, atomic_read(&urb->use_count) == 0); | ||
| 603 | } | ||
| 604 | EXPORT_SYMBOL_GPL(usb_poison_urb); | ||
| 605 | |||
| 606 | void usb_unpoison_urb(struct urb *urb) | ||
| 607 | { | ||
| 608 | unsigned long flags; | ||
| 609 | |||
| 610 | if (!urb) | ||
| 611 | return; | ||
| 612 | |||
| 613 | spin_lock_irqsave(&usb_reject_lock, flags); | ||
| 614 | --urb->reject; | ||
| 615 | spin_unlock_irqrestore(&usb_reject_lock, flags); | ||
| 616 | } | ||
| 617 | EXPORT_SYMBOL_GPL(usb_unpoison_urb); | ||
| 618 | |||
| 619 | /** | ||
| 566 | * usb_kill_anchored_urbs - cancel transfer requests en masse | 620 | * usb_kill_anchored_urbs - cancel transfer requests en masse |
| 567 | * @anchor: anchor the requests are bound to | 621 | * @anchor: anchor the requests are bound to |
| 568 | * | 622 | * |
| @@ -589,6 +643,35 @@ void usb_kill_anchored_urbs(struct usb_anchor *anchor) | |||
| 589 | } | 643 | } |
| 590 | EXPORT_SYMBOL_GPL(usb_kill_anchored_urbs); | 644 | EXPORT_SYMBOL_GPL(usb_kill_anchored_urbs); |
| 591 | 645 | ||
| 646 | |||
| 647 | /** | ||
| 648 | * usb_poison_anchored_urbs - cease all traffic from an anchor | ||
| 649 | * @anchor: anchor the requests are bound to | ||
| 650 | * | ||
| 651 | * this allows all outstanding URBs to be poisoned starting | ||
| 652 | * from the back of the queue. Newly added URBs will also be | ||
| 653 | * poisoned | ||
| 654 | */ | ||
| 655 | void usb_poison_anchored_urbs(struct usb_anchor *anchor) | ||
| 656 | { | ||
| 657 | struct urb *victim; | ||
| 658 | |||
| 659 | spin_lock_irq(&anchor->lock); | ||
| 660 | anchor->poisoned = 1; | ||
| 661 | while (!list_empty(&anchor->urb_list)) { | ||
| 662 | victim = list_entry(anchor->urb_list.prev, struct urb, | ||
| 663 | anchor_list); | ||
| 664 | /* we must make sure the URB isn't freed before we kill it*/ | ||
| 665 | usb_get_urb(victim); | ||
| 666 | spin_unlock_irq(&anchor->lock); | ||
| 667 | /* this will unanchor the URB */ | ||
| 668 | usb_poison_urb(victim); | ||
| 669 | usb_put_urb(victim); | ||
| 670 | spin_lock_irq(&anchor->lock); | ||
| 671 | } | ||
| 672 | spin_unlock_irq(&anchor->lock); | ||
| 673 | } | ||
| 674 | EXPORT_SYMBOL_GPL(usb_poison_anchored_urbs); | ||
| 592 | /** | 675 | /** |
| 593 | * usb_unlink_anchored_urbs - asynchronously cancel transfer requests en masse | 676 | * usb_unlink_anchored_urbs - asynchronously cancel transfer requests en masse |
| 594 | * @anchor: anchor the requests are bound to | 677 | * @anchor: anchor the requests are bound to |
| @@ -633,3 +716,73 @@ int usb_wait_anchor_empty_timeout(struct usb_anchor *anchor, | |||
| 633 | msecs_to_jiffies(timeout)); | 716 | msecs_to_jiffies(timeout)); |
| 634 | } | 717 | } |
| 635 | EXPORT_SYMBOL_GPL(usb_wait_anchor_empty_timeout); | 718 | EXPORT_SYMBOL_GPL(usb_wait_anchor_empty_timeout); |
| 719 | |||
| 720 | /** | ||
| 721 | * usb_get_from_anchor - get an anchor's oldest urb | ||
| 722 | * @anchor: the anchor whose urb you want | ||
| 723 | * | ||
| 724 | * this will take the oldest urb from an anchor, | ||
| 725 | * unanchor and return it | ||
| 726 | */ | ||
| 727 | struct urb *usb_get_from_anchor(struct usb_anchor *anchor) | ||
| 728 | { | ||
| 729 | struct urb *victim; | ||
| 730 | unsigned long flags; | ||
| 731 | |||
| 732 | spin_lock_irqsave(&anchor->lock, flags); | ||
| 733 | if (!list_empty(&anchor->urb_list)) { | ||
| 734 | victim = list_entry(anchor->urb_list.next, struct urb, | ||
| 735 | anchor_list); | ||
| 736 | usb_get_urb(victim); | ||
| 737 | spin_unlock_irqrestore(&anchor->lock, flags); | ||
| 738 | usb_unanchor_urb(victim); | ||
| 739 | } else { | ||
| 740 | spin_unlock_irqrestore(&anchor->lock, flags); | ||
| 741 | victim = NULL; | ||
| 742 | } | ||
| 743 | |||
| 744 | return victim; | ||
| 745 | } | ||
| 746 | |||
| 747 | EXPORT_SYMBOL_GPL(usb_get_from_anchor); | ||
| 748 | |||
| 749 | /** | ||
| 750 | * usb_scuttle_anchored_urbs - unanchor all an anchor's urbs | ||
| 751 | * @anchor: the anchor whose urbs you want to unanchor | ||
| 752 | * | ||
| 753 | * use this to get rid of all an anchor's urbs | ||
| 754 | */ | ||
| 755 | void usb_scuttle_anchored_urbs(struct usb_anchor *anchor) | ||
| 756 | { | ||
| 757 | struct urb *victim; | ||
| 758 | unsigned long flags; | ||
| 759 | |||
| 760 | spin_lock_irqsave(&anchor->lock, flags); | ||
| 761 | while (!list_empty(&anchor->urb_list)) { | ||
| 762 | victim = list_entry(anchor->urb_list.prev, struct urb, | ||
| 763 | anchor_list); | ||
| 764 | usb_get_urb(victim); | ||
| 765 | spin_unlock_irqrestore(&anchor->lock, flags); | ||
| 766 | /* this may free the URB */ | ||
| 767 | usb_unanchor_urb(victim); | ||
| 768 | usb_put_urb(victim); | ||
| 769 | spin_lock_irqsave(&anchor->lock, flags); | ||
| 770 | } | ||
| 771 | spin_unlock_irqrestore(&anchor->lock, flags); | ||
| 772 | } | ||
| 773 | |||
| 774 | EXPORT_SYMBOL_GPL(usb_scuttle_anchored_urbs); | ||
| 775 | |||
| 776 | /** | ||
| 777 | * usb_anchor_empty - is an anchor empty | ||
| 778 | * @anchor: the anchor you want to query | ||
| 779 | * | ||
| 780 | * returns 1 if the anchor has no urbs associated with it | ||
| 781 | */ | ||
| 782 | int usb_anchor_empty(struct usb_anchor *anchor) | ||
| 783 | { | ||
| 784 | return list_empty(&anchor->urb_list); | ||
| 785 | } | ||
| 786 | |||
| 787 | EXPORT_SYMBOL_GPL(usb_anchor_empty); | ||
| 788 | |||
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index acc95b2ac6f8..dd4cd5a51370 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig | |||
| @@ -45,7 +45,7 @@ if USB_GADGET | |||
| 45 | 45 | ||
| 46 | config USB_GADGET_DEBUG | 46 | config USB_GADGET_DEBUG |
| 47 | boolean "Debugging messages (DEVELOPMENT)" | 47 | boolean "Debugging messages (DEVELOPMENT)" |
| 48 | depends on USB_GADGET && DEBUG_KERNEL | 48 | depends on 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. |
| @@ -59,7 +59,7 @@ config USB_GADGET_DEBUG | |||
| 59 | 59 | ||
| 60 | config USB_GADGET_DEBUG_FILES | 60 | config USB_GADGET_DEBUG_FILES |
| 61 | boolean "Debugging information files (DEVELOPMENT)" | 61 | boolean "Debugging information files (DEVELOPMENT)" |
| 62 | depends on USB_GADGET && PROC_FS | 62 | depends on 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 |
| 65 | debugging information in files such as /proc/driver/udc | 65 | debugging information in files such as /proc/driver/udc |
| @@ -70,7 +70,7 @@ config USB_GADGET_DEBUG_FILES | |||
| 70 | 70 | ||
| 71 | config USB_GADGET_DEBUG_FS | 71 | config USB_GADGET_DEBUG_FS |
| 72 | boolean "Debugging information files in debugfs (DEVELOPMENT)" | 72 | boolean "Debugging information files in debugfs (DEVELOPMENT)" |
| 73 | depends on USB_GADGET && DEBUG_FS | 73 | depends on 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 |
| 76 | debugging information in files under /sys/kernel/debug/. | 76 | debugging information in files under /sys/kernel/debug/. |
| @@ -79,12 +79,36 @@ config USB_GADGET_DEBUG_FS | |||
| 79 | Enable these files by choosing "Y" here. If in doubt, or | 79 | Enable these files by choosing "Y" here. If in doubt, or |
| 80 | to conserve kernel memory, say "N". | 80 | to conserve kernel memory, say "N". |
| 81 | 81 | ||
| 82 | config USB_GADGET_VBUS_DRAW | ||
| 83 | int "Maximum VBUS Power usage (2-500 mA)" | ||
| 84 | range 2 500 | ||
| 85 | default 2 | ||
| 86 | help | ||
| 87 | Some devices need to draw power from USB when they are | ||
| 88 | configured, perhaps to operate circuitry or to recharge | ||
| 89 | batteries. This is in addition to any local power supply, | ||
| 90 | such as an AC adapter or batteries. | ||
| 91 | |||
| 92 | Enter the maximum power your device draws through USB, in | ||
| 93 | milliAmperes. The permitted range of values is 2 - 500 mA; | ||
| 94 | 0 mA would be legal, but can make some hosts misbehave. | ||
| 95 | |||
| 96 | This value will be used except for system-specific gadget | ||
| 97 | drivers that have more specific information. | ||
| 98 | |||
| 82 | config USB_GADGET_SELECTED | 99 | config USB_GADGET_SELECTED |
| 83 | boolean | 100 | boolean |
| 84 | 101 | ||
| 85 | # | 102 | # |
| 86 | # USB Peripheral Controller Support | 103 | # USB Peripheral Controller Support |
| 87 | # | 104 | # |
| 105 | # The order here is alphabetical, except that integrated controllers go | ||
| 106 | # before discrete ones so they will be the initial/default value: | ||
| 107 | # - integrated/SOC controllers first | ||
| 108 | # - licensed IP used in both SOC and discrete versions | ||
| 109 | # - discrete ones (including all PCI-only controllers) | ||
| 110 | # - debug/dummy gadget+hcd is last. | ||
| 111 | # | ||
| 88 | choice | 112 | choice |
| 89 | prompt "USB Peripheral Controller" | 113 | prompt "USB Peripheral Controller" |
| 90 | depends on USB_GADGET | 114 | depends on USB_GADGET |
| @@ -94,26 +118,27 @@ choice | |||
| 94 | Many controller drivers are platform-specific; these | 118 | Many controller drivers are platform-specific; these |
| 95 | often need board-specific hooks. | 119 | often need board-specific hooks. |
| 96 | 120 | ||
| 97 | config USB_GADGET_AMD5536UDC | 121 | # |
| 98 | boolean "AMD5536 UDC" | 122 | # Integrated controllers |
| 99 | depends on PCI | 123 | # |
| 100 | select USB_GADGET_DUALSPEED | 124 | |
| 125 | config USB_GADGET_AT91 | ||
| 126 | boolean "Atmel AT91 USB Device Port" | ||
| 127 | depends on ARCH_AT91 && !ARCH_AT91SAM9RL && !ARCH_AT91CAP9 | ||
| 128 | select USB_GADGET_SELECTED | ||
| 101 | help | 129 | help |
| 102 | The AMD5536 UDC is part of the AMD Geode CS5536, an x86 southbridge. | 130 | Many Atmel AT91 processors (such as the AT91RM2000) have a |
| 103 | It is a USB Highspeed DMA capable USB device controller. Beside ep0 | 131 | full speed USB Device Port with support for five configurable |
| 104 | it provides 4 IN and 4 OUT endpoints (bulk or interrupt type). | 132 | endpoints (plus endpoint zero). |
| 105 | The UDC port supports OTG operation, and may be used as a host port | ||
| 106 | if it's not being used to implement peripheral or OTG roles. | ||
| 107 | 133 | ||
| 108 | Say "y" to link the driver statically, or "m" to build a | 134 | Say "y" to link the driver statically, or "m" to build a |
| 109 | dynamically linked module called "amd5536udc" and force all | 135 | dynamically linked module called "at91_udc" and force all |
| 110 | gadget drivers to also be dynamically linked. | 136 | gadget drivers to also be dynamically linked. |
| 111 | 137 | ||
| 112 | config USB_AMD5536UDC | 138 | config USB_AT91 |
| 113 | tristate | 139 | tristate |
| 114 | depends on USB_GADGET_AMD5536UDC | 140 | depends on USB_GADGET_AT91 |
| 115 | default USB_GADGET | 141 | default USB_GADGET |
| 116 | select USB_GADGET_SELECTED | ||
| 117 | 142 | ||
| 118 | config USB_GADGET_ATMEL_USBA | 143 | config USB_GADGET_ATMEL_USBA |
| 119 | boolean "Atmel USBA" | 144 | boolean "Atmel USBA" |
| @@ -150,28 +175,50 @@ config USB_FSL_USB2 | |||
| 150 | default USB_GADGET | 175 | default USB_GADGET |
| 151 | select USB_GADGET_SELECTED | 176 | select USB_GADGET_SELECTED |
| 152 | 177 | ||
| 153 | config USB_GADGET_NET2280 | 178 | config USB_GADGET_LH7A40X |
| 154 | boolean "NetChip 228x" | 179 | boolean "LH7A40X" |
| 155 | depends on PCI | 180 | depends on ARCH_LH7A40X |
| 156 | select USB_GADGET_DUALSPEED | ||
| 157 | help | 181 | help |
| 158 | NetChip 2280 / 2282 is a PCI based USB peripheral controller which | 182 | This driver provides USB Device Controller driver for LH7A40x |
| 159 | supports both full and high speed USB 2.0 data transfers. | 183 | |
| 160 | 184 | config USB_LH7A40X | |
| 161 | It has six configurable endpoints, as well as endpoint zero | 185 | tristate |
| 162 | (for control transfers) and several endpoints with dedicated | 186 | depends on USB_GADGET_LH7A40X |
| 163 | functions. | 187 | default USB_GADGET |
| 188 | select USB_GADGET_SELECTED | ||
| 189 | |||
| 190 | config USB_GADGET_OMAP | ||
| 191 | boolean "OMAP USB Device Controller" | ||
| 192 | depends on ARCH_OMAP | ||
| 193 | select ISP1301_OMAP if MACH_OMAP_H2 || MACH_OMAP_H3 || MACH_OMAP_H4_OTG | ||
| 194 | help | ||
| 195 | Many Texas Instruments OMAP processors have flexible full | ||
| 196 | speed USB device controllers, with support for up to 30 | ||
| 197 | endpoints (plus endpoint zero). This driver supports the | ||
| 198 | controller in the OMAP 1611, and should work with controllers | ||
| 199 | in other OMAP processors too, given minor tweaks. | ||
| 164 | 200 | ||
| 165 | Say "y" to link the driver statically, or "m" to build a | 201 | Say "y" to link the driver statically, or "m" to build a |
| 166 | dynamically linked module called "net2280" and force all | 202 | dynamically linked module called "omap_udc" and force all |
| 167 | gadget drivers to also be dynamically linked. | 203 | gadget drivers to also be dynamically linked. |
| 168 | 204 | ||
| 169 | config USB_NET2280 | 205 | config USB_OMAP |
| 170 | tristate | 206 | tristate |
| 171 | depends on USB_GADGET_NET2280 | 207 | depends on USB_GADGET_OMAP |
| 172 | default USB_GADGET | 208 | default USB_GADGET |
| 173 | select USB_GADGET_SELECTED | 209 | select USB_GADGET_SELECTED |
| 174 | 210 | ||
| 211 | config USB_OTG | ||
| 212 | boolean "OTG Support" | ||
| 213 | depends on USB_GADGET_OMAP && ARCH_OMAP_OTG && USB_OHCI_HCD | ||
| 214 | help | ||
| 215 | The most notable feature of USB OTG is support for a | ||
| 216 | "Dual-Role" device, which can act as either a device | ||
| 217 | or a host. The initial role choice can be changed | ||
| 218 | later, when two dual-role devices talk to each other. | ||
| 219 | |||
| 220 | Select this only if your OMAP board has a Mini-AB connector. | ||
| 221 | |||
| 175 | config USB_GADGET_PXA25X | 222 | config USB_GADGET_PXA25X |
| 176 | boolean "PXA 25x or IXP 4xx" | 223 | boolean "PXA 25x or IXP 4xx" |
| 177 | depends on (ARCH_PXA && PXA25x) || ARCH_IXP4XX | 224 | depends on (ARCH_PXA && PXA25x) || ARCH_IXP4XX |
| @@ -203,34 +250,6 @@ config USB_PXA25X_SMALL | |||
| 203 | default y if USB_ETH | 250 | default y if USB_ETH |
| 204 | default y if USB_G_SERIAL | 251 | default y if USB_G_SERIAL |
| 205 | 252 | ||
| 206 | config USB_GADGET_M66592 | ||
| 207 | boolean "Renesas M66592 USB Peripheral Controller" | ||
| 208 | select USB_GADGET_DUALSPEED | ||
| 209 | help | ||
| 210 | M66592 is a discrete USB peripheral controller chip that | ||
| 211 | supports both full and high speed USB 2.0 data transfers. | ||
| 212 | It has seven configurable endpoints, and endpoint zero. | ||
| 213 | |||
| 214 | Say "y" to link the driver statically, or "m" to build a | ||
| 215 | dynamically linked module called "m66592_udc" and force all | ||
| 216 | gadget drivers to also be dynamically linked. | ||
| 217 | |||
| 218 | config USB_M66592 | ||
| 219 | tristate | ||
| 220 | depends on USB_GADGET_M66592 | ||
| 221 | default USB_GADGET | ||
| 222 | select USB_GADGET_SELECTED | ||
| 223 | |||
| 224 | config SUPERH_BUILT_IN_M66592 | ||
| 225 | boolean "Enable SuperH built-in USB like the M66592" | ||
| 226 | depends on USB_GADGET_M66592 && CPU_SUBTYPE_SH7722 | ||
| 227 | help | ||
| 228 | SH7722 has USB like the M66592. | ||
| 229 | |||
| 230 | The transfer rate is very slow when use "Ethernet Gadget". | ||
| 231 | However, this problem is improved if change a value of | ||
| 232 | NET_IP_ALIGN to 4. | ||
| 233 | |||
| 234 | config USB_GADGET_PXA27X | 253 | config USB_GADGET_PXA27X |
| 235 | boolean "PXA 27x" | 254 | boolean "PXA 27x" |
| 236 | depends on ARCH_PXA && PXA27x | 255 | depends on ARCH_PXA && PXA27x |
| @@ -251,40 +270,32 @@ config USB_PXA27X | |||
| 251 | default USB_GADGET | 270 | default USB_GADGET |
| 252 | select USB_GADGET_SELECTED | 271 | select USB_GADGET_SELECTED |
| 253 | 272 | ||
| 254 | config USB_GADGET_GOKU | 273 | config USB_GADGET_S3C2410 |
| 255 | boolean "Toshiba TC86C001 'Goku-S'" | 274 | boolean "S3C2410 USB Device Controller" |
| 256 | depends on PCI | 275 | depends on ARCH_S3C2410 |
| 257 | help | 276 | help |
| 258 | The Toshiba TC86C001 is a PCI device which includes controllers | 277 | Samsung's S3C2410 is an ARM-4 processor with an integrated |
| 259 | for full speed USB devices, IDE, I2C, SIO, plus a USB host (OHCI). | 278 | full speed USB 1.1 device controller. It has 4 configurable |
| 260 | 279 | endpoints, as well as endpoint zero (for control transfers). | |
| 261 | The device controller has three configurable (bulk or interrupt) | ||
| 262 | endpoints, plus endpoint zero (for control transfers). | ||
| 263 | 280 | ||
| 264 | Say "y" to link the driver statically, or "m" to build a | 281 | This driver has been tested on the S3C2410, S3C2412, and |
| 265 | dynamically linked module called "goku_udc" and to force all | 282 | S3C2440 processors. |
| 266 | gadget drivers to also be dynamically linked. | ||
| 267 | 283 | ||
| 268 | config USB_GOKU | 284 | config USB_S3C2410 |
| 269 | tristate | 285 | tristate |
| 270 | depends on USB_GADGET_GOKU | 286 | depends on USB_GADGET_S3C2410 |
| 271 | default USB_GADGET | 287 | default USB_GADGET |
| 272 | select USB_GADGET_SELECTED | 288 | select USB_GADGET_SELECTED |
| 273 | 289 | ||
| 290 | config USB_S3C2410_DEBUG | ||
| 291 | boolean "S3C2410 udc debug messages" | ||
| 292 | depends on USB_GADGET_S3C2410 | ||
| 274 | 293 | ||
| 275 | config USB_GADGET_LH7A40X | 294 | # |
| 276 | boolean "LH7A40X" | 295 | # Controllers available in both integrated and discrete versions |
| 277 | depends on ARCH_LH7A40X | 296 | # |
| 278 | help | ||
| 279 | This driver provides USB Device Controller driver for LH7A40x | ||
| 280 | |||
| 281 | config USB_LH7A40X | ||
| 282 | tristate | ||
| 283 | depends on USB_GADGET_LH7A40X | ||
| 284 | default USB_GADGET | ||
| 285 | select USB_GADGET_SELECTED | ||
| 286 | 297 | ||
| 287 | # built in ../musb along with host support | 298 | # musb builds in ../musb along with host support |
| 288 | config USB_GADGET_MUSB_HDRC | 299 | config USB_GADGET_MUSB_HDRC |
| 289 | boolean "Inventra HDRC USB Peripheral (TI, ...)" | 300 | boolean "Inventra HDRC USB Peripheral (TI, ...)" |
| 290 | depends on USB_MUSB_HDRC && (USB_MUSB_PERIPHERAL || USB_MUSB_OTG) | 301 | depends on USB_MUSB_HDRC && (USB_MUSB_PERIPHERAL || USB_MUSB_OTG) |
| @@ -294,76 +305,124 @@ config USB_GADGET_MUSB_HDRC | |||
| 294 | This OTG-capable silicon IP is used in dual designs including | 305 | This OTG-capable silicon IP is used in dual designs including |
| 295 | the TI DaVinci, OMAP 243x, OMAP 343x, and TUSB 6010. | 306 | the TI DaVinci, OMAP 243x, OMAP 343x, and TUSB 6010. |
| 296 | 307 | ||
| 297 | config USB_GADGET_OMAP | 308 | config USB_GADGET_M66592 |
| 298 | boolean "OMAP USB Device Controller" | 309 | boolean "Renesas M66592 USB Peripheral Controller" |
| 299 | depends on ARCH_OMAP | 310 | select USB_GADGET_DUALSPEED |
| 300 | select ISP1301_OMAP if MACH_OMAP_H2 || MACH_OMAP_H3 | ||
| 301 | help | 311 | help |
| 302 | Many Texas Instruments OMAP processors have flexible full | 312 | M66592 is a discrete USB peripheral controller chip that |
| 303 | speed USB device controllers, with support for up to 30 | 313 | supports both full and high speed USB 2.0 data transfers. |
| 304 | endpoints (plus endpoint zero). This driver supports the | 314 | It has seven configurable endpoints, and endpoint zero. |
| 305 | controller in the OMAP 1611, and should work with controllers | ||
| 306 | in other OMAP processors too, given minor tweaks. | ||
| 307 | 315 | ||
| 308 | Say "y" to link the driver statically, or "m" to build a | 316 | Say "y" to link the driver statically, or "m" to build a |
| 309 | dynamically linked module called "omap_udc" and force all | 317 | dynamically linked module called "m66592_udc" and force all |
| 310 | gadget drivers to also be dynamically linked. | 318 | gadget drivers to also be dynamically linked. |
| 311 | 319 | ||
| 312 | config USB_OMAP | 320 | config USB_M66592 |
| 313 | tristate | 321 | tristate |
| 314 | depends on USB_GADGET_OMAP | 322 | depends on USB_GADGET_M66592 |
| 315 | default USB_GADGET | 323 | default USB_GADGET |
| 316 | select USB_GADGET_SELECTED | 324 | select USB_GADGET_SELECTED |
| 317 | 325 | ||
| 318 | config USB_OTG | 326 | config SUPERH_BUILT_IN_M66592 |
| 319 | boolean "OTG Support" | 327 | boolean "Enable SuperH built-in USB like the M66592" |
| 320 | depends on USB_GADGET_OMAP && ARCH_OMAP_OTG && USB_OHCI_HCD | 328 | depends on USB_GADGET_M66592 && CPU_SUBTYPE_SH7722 |
| 321 | help | 329 | help |
| 322 | The most notable feature of USB OTG is support for a | 330 | SH7722 has USB like the M66592. |
| 323 | "Dual-Role" device, which can act as either a device | ||
| 324 | or a host. The initial role choice can be changed | ||
| 325 | later, when two dual-role devices talk to each other. | ||
| 326 | 331 | ||
| 327 | Select this only if your OMAP board has a Mini-AB connector. | 332 | The transfer rate is very slow when use "Ethernet Gadget". |
| 333 | However, this problem is improved if change a value of | ||
| 334 | NET_IP_ALIGN to 4. | ||
| 328 | 335 | ||
| 329 | config USB_GADGET_S3C2410 | 336 | # |
| 330 | boolean "S3C2410 USB Device Controller" | 337 | # Controllers available only in discrete form (and all PCI controllers) |
| 331 | depends on ARCH_S3C2410 | 338 | # |
| 339 | |||
| 340 | config USB_GADGET_AMD5536UDC | ||
| 341 | boolean "AMD5536 UDC" | ||
| 342 | depends on PCI | ||
| 343 | select USB_GADGET_DUALSPEED | ||
| 332 | help | 344 | help |
| 333 | Samsung's S3C2410 is an ARM-4 processor with an integrated | 345 | The AMD5536 UDC is part of the AMD Geode CS5536, an x86 southbridge. |
| 334 | full speed USB 1.1 device controller. It has 4 configurable | 346 | It is a USB Highspeed DMA capable USB device controller. Beside ep0 |
| 335 | endpoints, as well as endpoint zero (for control transfers). | 347 | it provides 4 IN and 4 OUT endpoints (bulk or interrupt type). |
| 348 | The UDC port supports OTG operation, and may be used as a host port | ||
| 349 | if it's not being used to implement peripheral or OTG roles. | ||
| 336 | 350 | ||
| 337 | This driver has been tested on the S3C2410, S3C2412, and | 351 | Say "y" to link the driver statically, or "m" to build a |
| 338 | S3C2440 processors. | 352 | dynamically linked module called "amd5536udc" and force all |
| 353 | gadget drivers to also be dynamically linked. | ||
| 339 | 354 | ||
| 340 | config USB_S3C2410 | 355 | config USB_AMD5536UDC |
| 341 | tristate | 356 | tristate |
| 342 | depends on USB_GADGET_S3C2410 | 357 | depends on USB_GADGET_AMD5536UDC |
| 343 | default USB_GADGET | 358 | default USB_GADGET |
| 344 | select USB_GADGET_SELECTED | 359 | select USB_GADGET_SELECTED |
| 345 | 360 | ||
| 346 | config USB_S3C2410_DEBUG | 361 | config USB_GADGET_FSL_QE |
| 347 | boolean "S3C2410 udc debug messages" | 362 | boolean "Freescale QE/CPM USB Device Controller" |
| 348 | depends on USB_GADGET_S3C2410 | 363 | depends on FSL_SOC && (QUICC_ENGINE || CPM) |
| 364 | help | ||
| 365 | Some of Freescale PowerPC processors have a Full Speed | ||
| 366 | QE/CPM2 USB controller, which support device mode with 4 | ||
| 367 | programmable endpoints. This driver supports the | ||
| 368 | controller in the MPC8360 and MPC8272, and should work with | ||
| 369 | controllers having QE or CPM2, given minor tweaks. | ||
| 349 | 370 | ||
| 350 | config USB_GADGET_AT91 | 371 | Set CONFIG_USB_GADGET to "m" to build this driver as a |
| 351 | boolean "AT91 USB Device Port" | 372 | dynmically linked module called "fsl_qe_udc". |
| 352 | depends on ARCH_AT91 && !ARCH_AT91SAM9RL && !ARCH_AT91CAP9 | 373 | |
| 374 | config USB_FSL_QE | ||
| 375 | tristate | ||
| 376 | depends on USB_GADGET_FSL_QE | ||
| 377 | default USB_GADGET | ||
| 353 | select USB_GADGET_SELECTED | 378 | select USB_GADGET_SELECTED |
| 379 | |||
| 380 | config USB_GADGET_NET2280 | ||
| 381 | boolean "NetChip 228x" | ||
| 382 | depends on PCI | ||
| 383 | select USB_GADGET_DUALSPEED | ||
| 354 | help | 384 | help |
| 355 | Many Atmel AT91 processors (such as the AT91RM2000) have a | 385 | NetChip 2280 / 2282 is a PCI based USB peripheral controller which |
| 356 | full speed USB Device Port with support for five configurable | 386 | supports both full and high speed USB 2.0 data transfers. |
| 357 | endpoints (plus endpoint zero). | 387 | |
| 388 | It has six configurable endpoints, as well as endpoint zero | ||
| 389 | (for control transfers) and several endpoints with dedicated | ||
| 390 | functions. | ||
| 358 | 391 | ||
| 359 | Say "y" to link the driver statically, or "m" to build a | 392 | Say "y" to link the driver statically, or "m" to build a |
| 360 | dynamically linked module called "at91_udc" and force all | 393 | dynamically linked module called "net2280" and force all |
| 361 | gadget drivers to also be dynamically linked. | 394 | gadget drivers to also be dynamically linked. |
| 362 | 395 | ||
| 363 | config USB_AT91 | 396 | config USB_NET2280 |
| 364 | tristate | 397 | tristate |
| 365 | depends on USB_GADGET_AT91 | 398 | depends on USB_GADGET_NET2280 |
| 399 | default USB_GADGET | ||
| 400 | select USB_GADGET_SELECTED | ||
| 401 | |||
| 402 | config USB_GADGET_GOKU | ||
| 403 | boolean "Toshiba TC86C001 'Goku-S'" | ||
| 404 | depends on PCI | ||
| 405 | help | ||
| 406 | The Toshiba TC86C001 is a PCI device which includes controllers | ||
| 407 | for full speed USB devices, IDE, I2C, SIO, plus a USB host (OHCI). | ||
| 408 | |||
| 409 | The device controller has three configurable (bulk or interrupt) | ||
| 410 | endpoints, plus endpoint zero (for control transfers). | ||
| 411 | |||
| 412 | Say "y" to link the driver statically, or "m" to build a | ||
| 413 | dynamically linked module called "goku_udc" and to force all | ||
| 414 | gadget drivers to also be dynamically linked. | ||
| 415 | |||
| 416 | config USB_GOKU | ||
| 417 | tristate | ||
| 418 | depends on USB_GADGET_GOKU | ||
| 366 | default USB_GADGET | 419 | default USB_GADGET |
| 420 | select USB_GADGET_SELECTED | ||
| 421 | |||
| 422 | |||
| 423 | # | ||
| 424 | # LAST -- dummy/emulated controller | ||
| 425 | # | ||
| 367 | 426 | ||
| 368 | config USB_GADGET_DUMMY_HCD | 427 | config USB_GADGET_DUMMY_HCD |
| 369 | boolean "Dummy HCD (DEVELOPMENT)" | 428 | boolean "Dummy HCD (DEVELOPMENT)" |
| @@ -553,19 +612,23 @@ config USB_FILE_STORAGE_TEST | |||
| 553 | normal operation. | 612 | normal operation. |
| 554 | 613 | ||
| 555 | config USB_G_SERIAL | 614 | config USB_G_SERIAL |
| 556 | tristate "Serial Gadget (with CDC ACM support)" | 615 | tristate "Serial Gadget (with CDC ACM and CDC OBEX support)" |
| 557 | help | 616 | help |
| 558 | The Serial Gadget talks to the Linux-USB generic serial driver. | 617 | The Serial Gadget talks to the Linux-USB generic serial driver. |
| 559 | This driver supports a CDC-ACM module option, which can be used | 618 | This driver supports a CDC-ACM module option, which can be used |
| 560 | to interoperate with MS-Windows hosts or with the Linux-USB | 619 | to interoperate with MS-Windows hosts or with the Linux-USB |
| 561 | "cdc-acm" driver. | 620 | "cdc-acm" driver. |
| 562 | 621 | ||
| 622 | This driver also supports a CDC-OBEX option. You will need a | ||
| 623 | user space OBEX server talking to /dev/ttyGS*, since the kernel | ||
| 624 | itself doesn't implement the OBEX protocol. | ||
| 625 | |||
| 563 | Say "y" to link the driver statically, or "m" to build a | 626 | Say "y" to link the driver statically, or "m" to build a |
| 564 | dynamically linked module called "g_serial". | 627 | dynamically linked module called "g_serial". |
| 565 | 628 | ||
| 566 | For more information, see Documentation/usb/gadget_serial.txt | 629 | For more information, see Documentation/usb/gadget_serial.txt |
| 567 | which includes instructions and a "driver info file" needed to | 630 | which includes instructions and a "driver info file" needed to |
| 568 | make MS-Windows work with this driver. | 631 | make MS-Windows work with CDC ACM. |
| 569 | 632 | ||
| 570 | config USB_MIDI_GADGET | 633 | config USB_MIDI_GADGET |
| 571 | tristate "MIDI Gadget (EXPERIMENTAL)" | 634 | tristate "MIDI Gadget (EXPERIMENTAL)" |
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile index 2267fa0b51b2..bd4041b47dce 100644 --- a/drivers/usb/gadget/Makefile +++ b/drivers/usb/gadget/Makefile | |||
| @@ -18,6 +18,7 @@ obj-$(CONFIG_USB_AT91) += at91_udc.o | |||
| 18 | obj-$(CONFIG_USB_ATMEL_USBA) += atmel_usba_udc.o | 18 | obj-$(CONFIG_USB_ATMEL_USBA) += atmel_usba_udc.o |
| 19 | obj-$(CONFIG_USB_FSL_USB2) += fsl_usb2_udc.o | 19 | obj-$(CONFIG_USB_FSL_USB2) += fsl_usb2_udc.o |
| 20 | obj-$(CONFIG_USB_M66592) += m66592-udc.o | 20 | obj-$(CONFIG_USB_M66592) += m66592-udc.o |
| 21 | obj-$(CONFIG_USB_FSL_QE) += fsl_qe_udc.o | ||
| 21 | 22 | ||
| 22 | # | 23 | # |
| 23 | # USB gadget drivers | 24 | # USB gadget drivers |
diff --git a/drivers/usb/gadget/cdc2.c b/drivers/usb/gadget/cdc2.c index a724fc149850..5495b171cf29 100644 --- a/drivers/usb/gadget/cdc2.c +++ b/drivers/usb/gadget/cdc2.c | |||
| @@ -155,7 +155,6 @@ static struct usb_configuration cdc_config_driver = { | |||
| 155 | .bConfigurationValue = 1, | 155 | .bConfigurationValue = 1, |
| 156 | /* .iConfiguration = DYNAMIC */ | 156 | /* .iConfiguration = DYNAMIC */ |
| 157 | .bmAttributes = USB_CONFIG_ATT_SELFPOWER, | 157 | .bmAttributes = USB_CONFIG_ATT_SELFPOWER, |
| 158 | .bMaxPower = 1, /* 2 mA, minimal */ | ||
| 159 | }; | 158 | }; |
| 160 | 159 | ||
| 161 | /*-------------------------------------------------------------------------*/ | 160 | /*-------------------------------------------------------------------------*/ |
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 85c876c1f150..f2da0269e1b1 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c | |||
| @@ -128,6 +128,70 @@ done: | |||
| 128 | } | 128 | } |
| 129 | 129 | ||
| 130 | /** | 130 | /** |
| 131 | * usb_function_deactivate - prevent function and gadget enumeration | ||
| 132 | * @function: the function that isn't yet ready to respond | ||
| 133 | * | ||
| 134 | * Blocks response of the gadget driver to host enumeration by | ||
| 135 | * preventing the data line pullup from being activated. This is | ||
| 136 | * normally called during @bind() processing to change from the | ||
| 137 | * initial "ready to respond" state, or when a required resource | ||
| 138 | * becomes available. | ||
| 139 | * | ||
| 140 | * For example, drivers that serve as a passthrough to a userspace | ||
| 141 | * daemon can block enumeration unless that daemon (such as an OBEX, | ||
| 142 | * MTP, or print server) is ready to handle host requests. | ||
| 143 | * | ||
| 144 | * Not all systems support software control of their USB peripheral | ||
| 145 | * data pullups. | ||
| 146 | * | ||
| 147 | * Returns zero on success, else negative errno. | ||
| 148 | */ | ||
| 149 | int usb_function_deactivate(struct usb_function *function) | ||
| 150 | { | ||
| 151 | struct usb_composite_dev *cdev = function->config->cdev; | ||
| 152 | int status = 0; | ||
| 153 | |||
| 154 | spin_lock(&cdev->lock); | ||
| 155 | |||
| 156 | if (cdev->deactivations == 0) | ||
| 157 | status = usb_gadget_disconnect(cdev->gadget); | ||
| 158 | if (status == 0) | ||
| 159 | cdev->deactivations++; | ||
| 160 | |||
| 161 | spin_unlock(&cdev->lock); | ||
| 162 | return status; | ||
| 163 | } | ||
| 164 | |||
| 165 | /** | ||
| 166 | * usb_function_activate - allow function and gadget enumeration | ||
| 167 | * @function: function on which usb_function_activate() was called | ||
| 168 | * | ||
| 169 | * Reverses effect of usb_function_deactivate(). If no more functions | ||
| 170 | * are delaying their activation, the gadget driver will respond to | ||
| 171 | * host enumeration procedures. | ||
| 172 | * | ||
| 173 | * Returns zero on success, else negative errno. | ||
| 174 | */ | ||
| 175 | int usb_function_activate(struct usb_function *function) | ||
| 176 | { | ||
| 177 | struct usb_composite_dev *cdev = function->config->cdev; | ||
| 178 | int status = 0; | ||
| 179 | |||
| 180 | spin_lock(&cdev->lock); | ||
| 181 | |||
| 182 | if (WARN_ON(cdev->deactivations == 0)) | ||
| 183 | status = -EINVAL; | ||
| 184 | else { | ||
| 185 | cdev->deactivations--; | ||
| 186 | if (cdev->deactivations == 0) | ||
| 187 | status = usb_gadget_connect(cdev->gadget); | ||
| 188 | } | ||
| 189 | |||
| 190 | spin_unlock(&cdev->lock); | ||
| 191 | return status; | ||
| 192 | } | ||
| 193 | |||
| 194 | /** | ||
| 131 | * usb_interface_id() - allocate an unused interface ID | 195 | * usb_interface_id() - allocate an unused interface ID |
| 132 | * @config: configuration associated with the interface | 196 | * @config: configuration associated with the interface |
| 133 | * @function: function handling the interface | 197 | * @function: function handling the interface |
| @@ -181,7 +245,7 @@ static int config_buf(struct usb_configuration *config, | |||
| 181 | c->bConfigurationValue = config->bConfigurationValue; | 245 | c->bConfigurationValue = config->bConfigurationValue; |
| 182 | c->iConfiguration = config->iConfiguration; | 246 | c->iConfiguration = config->iConfiguration; |
| 183 | c->bmAttributes = USB_CONFIG_ATT_ONE | config->bmAttributes; | 247 | c->bmAttributes = USB_CONFIG_ATT_ONE | config->bmAttributes; |
| 184 | c->bMaxPower = config->bMaxPower; | 248 | c->bMaxPower = config->bMaxPower ? : (CONFIG_USB_GADGET_VBUS_DRAW / 2); |
| 185 | 249 | ||
| 186 | /* There may be e.g. OTG descriptors */ | 250 | /* There may be e.g. OTG descriptors */ |
| 187 | if (config->descriptors) { | 251 | if (config->descriptors) { |
| @@ -368,7 +432,7 @@ static int set_config(struct usb_composite_dev *cdev, | |||
| 368 | } | 432 | } |
| 369 | 433 | ||
| 370 | /* when we return, be sure our power usage is valid */ | 434 | /* when we return, be sure our power usage is valid */ |
| 371 | power = 2 * c->bMaxPower; | 435 | power = c->bMaxPower ? (2 * c->bMaxPower) : CONFIG_USB_GADGET_VBUS_DRAW; |
| 372 | done: | 436 | done: |
| 373 | usb_gadget_vbus_draw(gadget, power); | 437 | usb_gadget_vbus_draw(gadget, power); |
| 374 | return result; | 438 | return result; |
diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c index 7600a0c78753..9064696636ac 100644 --- a/drivers/usb/gadget/dummy_hcd.c +++ b/drivers/usb/gadget/dummy_hcd.c | |||
| @@ -82,6 +82,7 @@ struct dummy_ep { | |||
| 82 | const struct usb_endpoint_descriptor *desc; | 82 | const struct usb_endpoint_descriptor *desc; |
| 83 | struct usb_ep ep; | 83 | struct usb_ep ep; |
| 84 | unsigned halted : 1; | 84 | unsigned halted : 1; |
| 85 | unsigned wedged : 1; | ||
| 85 | unsigned already_seen : 1; | 86 | unsigned already_seen : 1; |
| 86 | unsigned setup_stage : 1; | 87 | unsigned setup_stage : 1; |
| 87 | }; | 88 | }; |
| @@ -436,6 +437,7 @@ dummy_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc) | |||
| 436 | /* at this point real hardware should be NAKing transfers | 437 | /* at this point real hardware should be NAKing transfers |
| 437 | * to that endpoint, until a buffer is queued to it. | 438 | * to that endpoint, until a buffer is queued to it. |
| 438 | */ | 439 | */ |
| 440 | ep->halted = ep->wedged = 0; | ||
| 439 | retval = 0; | 441 | retval = 0; |
| 440 | done: | 442 | done: |
| 441 | return retval; | 443 | return retval; |
| @@ -597,7 +599,7 @@ static int dummy_dequeue (struct usb_ep *_ep, struct usb_request *_req) | |||
| 597 | } | 599 | } |
| 598 | 600 | ||
| 599 | static int | 601 | static int |
| 600 | dummy_set_halt (struct usb_ep *_ep, int value) | 602 | dummy_set_halt_and_wedge(struct usb_ep *_ep, int value, int wedged) |
| 601 | { | 603 | { |
| 602 | struct dummy_ep *ep; | 604 | struct dummy_ep *ep; |
| 603 | struct dummy *dum; | 605 | struct dummy *dum; |
| @@ -609,16 +611,32 @@ dummy_set_halt (struct usb_ep *_ep, int value) | |||
| 609 | if (!dum->driver) | 611 | if (!dum->driver) |
| 610 | return -ESHUTDOWN; | 612 | return -ESHUTDOWN; |
| 611 | if (!value) | 613 | if (!value) |
| 612 | ep->halted = 0; | 614 | ep->halted = ep->wedged = 0; |
| 613 | else if (ep->desc && (ep->desc->bEndpointAddress & USB_DIR_IN) && | 615 | else if (ep->desc && (ep->desc->bEndpointAddress & USB_DIR_IN) && |
| 614 | !list_empty (&ep->queue)) | 616 | !list_empty (&ep->queue)) |
| 615 | return -EAGAIN; | 617 | return -EAGAIN; |
| 616 | else | 618 | else { |
| 617 | ep->halted = 1; | 619 | ep->halted = 1; |
| 620 | if (wedged) | ||
| 621 | ep->wedged = 1; | ||
| 622 | } | ||
| 618 | /* FIXME clear emulated data toggle too */ | 623 | /* FIXME clear emulated data toggle too */ |
| 619 | return 0; | 624 | return 0; |
| 620 | } | 625 | } |
| 621 | 626 | ||
| 627 | static int | ||
| 628 | dummy_set_halt(struct usb_ep *_ep, int value) | ||
| 629 | { | ||
| 630 | return dummy_set_halt_and_wedge(_ep, value, 0); | ||
| 631 | } | ||
| 632 | |||
| 633 | static int dummy_set_wedge(struct usb_ep *_ep) | ||
| 634 | { | ||
| 635 | if (!_ep || _ep->name == ep0name) | ||
| 636 | return -EINVAL; | ||
| 637 | return dummy_set_halt_and_wedge(_ep, 1, 1); | ||
| 638 | } | ||
| 639 | |||
| 622 | static const struct usb_ep_ops dummy_ep_ops = { | 640 | static const struct usb_ep_ops dummy_ep_ops = { |
| 623 | .enable = dummy_enable, | 641 | .enable = dummy_enable, |
| 624 | .disable = dummy_disable, | 642 | .disable = dummy_disable, |
| @@ -630,6 +648,7 @@ static const struct usb_ep_ops dummy_ep_ops = { | |||
| 630 | .dequeue = dummy_dequeue, | 648 | .dequeue = dummy_dequeue, |
| 631 | 649 | ||
| 632 | .set_halt = dummy_set_halt, | 650 | .set_halt = dummy_set_halt, |
| 651 | .set_wedge = dummy_set_wedge, | ||
| 633 | }; | 652 | }; |
| 634 | 653 | ||
| 635 | /*-------------------------------------------------------------------------*/ | 654 | /*-------------------------------------------------------------------------*/ |
| @@ -760,7 +779,8 @@ usb_gadget_register_driver (struct usb_gadget_driver *driver) | |||
| 760 | ep->ep.name = ep_name [i]; | 779 | ep->ep.name = ep_name [i]; |
| 761 | ep->ep.ops = &dummy_ep_ops; | 780 | ep->ep.ops = &dummy_ep_ops; |
| 762 | list_add_tail (&ep->ep.ep_list, &dum->gadget.ep_list); | 781 | list_add_tail (&ep->ep.ep_list, &dum->gadget.ep_list); |
| 763 | ep->halted = ep->already_seen = ep->setup_stage = 0; | 782 | ep->halted = ep->wedged = ep->already_seen = |
| 783 | ep->setup_stage = 0; | ||
| 764 | ep->ep.maxpacket = ~0; | 784 | ep->ep.maxpacket = ~0; |
| 765 | ep->last_io = jiffies; | 785 | ep->last_io = jiffies; |
| 766 | ep->gadget = &dum->gadget; | 786 | ep->gadget = &dum->gadget; |
| @@ -1351,7 +1371,7 @@ restart: | |||
| 1351 | } else if (setup.bRequestType == Ep_Request) { | 1371 | } else if (setup.bRequestType == Ep_Request) { |
| 1352 | // endpoint halt | 1372 | // endpoint halt |
| 1353 | ep2 = find_endpoint (dum, w_index); | 1373 | ep2 = find_endpoint (dum, w_index); |
| 1354 | if (!ep2) { | 1374 | if (!ep2 || ep2->ep.name == ep0name) { |
| 1355 | value = -EOPNOTSUPP; | 1375 | value = -EOPNOTSUPP; |
| 1356 | break; | 1376 | break; |
| 1357 | } | 1377 | } |
| @@ -1380,7 +1400,8 @@ restart: | |||
| 1380 | value = -EOPNOTSUPP; | 1400 | value = -EOPNOTSUPP; |
| 1381 | break; | 1401 | break; |
| 1382 | } | 1402 | } |
| 1383 | ep2->halted = 0; | 1403 | if (!ep2->wedged) |
| 1404 | ep2->halted = 0; | ||
| 1384 | value = 0; | 1405 | value = 0; |
| 1385 | status = 0; | 1406 | status = 0; |
| 1386 | } | 1407 | } |
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index 944c8e889ab4..37252d0012a7 100644 --- a/drivers/usb/gadget/ether.c +++ b/drivers/usb/gadget/ether.c | |||
| @@ -242,7 +242,6 @@ static struct usb_configuration rndis_config_driver = { | |||
| 242 | .bConfigurationValue = 2, | 242 | .bConfigurationValue = 2, |
| 243 | /* .iConfiguration = DYNAMIC */ | 243 | /* .iConfiguration = DYNAMIC */ |
| 244 | .bmAttributes = USB_CONFIG_ATT_SELFPOWER, | 244 | .bmAttributes = USB_CONFIG_ATT_SELFPOWER, |
| 245 | .bMaxPower = 1, /* 2 mA, minimal */ | ||
| 246 | }; | 245 | }; |
| 247 | 246 | ||
| 248 | /*-------------------------------------------------------------------------*/ | 247 | /*-------------------------------------------------------------------------*/ |
| @@ -271,7 +270,6 @@ static struct usb_configuration eth_config_driver = { | |||
| 271 | .bConfigurationValue = 1, | 270 | .bConfigurationValue = 1, |
| 272 | /* .iConfiguration = DYNAMIC */ | 271 | /* .iConfiguration = DYNAMIC */ |
| 273 | .bmAttributes = USB_CONFIG_ATT_SELFPOWER, | 272 | .bmAttributes = USB_CONFIG_ATT_SELFPOWER, |
| 274 | .bMaxPower = 1, /* 2 mA, minimal */ | ||
| 275 | }; | 273 | }; |
| 276 | 274 | ||
| 277 | /*-------------------------------------------------------------------------*/ | 275 | /*-------------------------------------------------------------------------*/ |
diff --git a/drivers/usb/gadget/f_loopback.c b/drivers/usb/gadget/f_loopback.c index 87dde012dacc..8affe1dfc2c1 100644 --- a/drivers/usb/gadget/f_loopback.c +++ b/drivers/usb/gadget/f_loopback.c | |||
| @@ -352,7 +352,6 @@ static struct usb_configuration loopback_driver = { | |||
| 352 | .bind = loopback_bind_config, | 352 | .bind = loopback_bind_config, |
| 353 | .bConfigurationValue = 2, | 353 | .bConfigurationValue = 2, |
| 354 | .bmAttributes = USB_CONFIG_ATT_SELFPOWER, | 354 | .bmAttributes = USB_CONFIG_ATT_SELFPOWER, |
| 355 | .bMaxPower = 1, /* 2 mA, minimal */ | ||
| 356 | /* .iConfiguration = DYNAMIC */ | 355 | /* .iConfiguration = DYNAMIC */ |
| 357 | }; | 356 | }; |
| 358 | 357 | ||
diff --git a/drivers/usb/gadget/f_obex.c b/drivers/usb/gadget/f_obex.c new file mode 100644 index 000000000000..80c2e7e9622f --- /dev/null +++ b/drivers/usb/gadget/f_obex.c | |||
| @@ -0,0 +1,493 @@ | |||
| 1 | /* | ||
| 2 | * f_obex.c -- USB CDC OBEX function driver | ||
| 3 | * | ||
| 4 | * Copyright (C) 2008 Nokia Corporation | ||
| 5 | * Contact: Felipe Balbi <felipe.balbi@nokia.com> | ||
| 6 | * | ||
| 7 | * Based on f_acm.c by Al Borchers and David Brownell. | ||
| 8 | * | ||
| 9 | * This program is free software; you can redistribute it and/or modify | ||
| 10 | * it under the terms of the GNU General Public License as published by | ||
| 11 | * the Free Software Foundation; either version 2 of the License, or | ||
| 12 | * (at your option) any later version. | ||
| 13 | * | ||
| 14 | * This program is distributed in the hope that it will be useful, | ||
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 17 | * GNU General Public License for more details. | ||
| 18 | * | ||
| 19 | * You should have received a copy of the GNU General Public License | ||
| 20 | * along with this program; if not, write to the Free Software | ||
| 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| 22 | */ | ||
| 23 | |||
| 24 | /* #define VERBOSE_DEBUG */ | ||
| 25 | |||
| 26 | #include <linux/kernel.h> | ||
| 27 | #include <linux/utsname.h> | ||
| 28 | #include <linux/device.h> | ||
| 29 | |||
| 30 | #include "u_serial.h" | ||
| 31 | #include "gadget_chips.h" | ||
| 32 | |||
| 33 | |||
| 34 | /* | ||
| 35 | * This CDC OBEX function support just packages a TTY-ish byte stream. | ||
| 36 | * A user mode server will put it into "raw" mode and handle all the | ||
| 37 | * relevant protocol details ... this is just a kernel passthrough. | ||
| 38 | * When possible, we prevent gadget enumeration until that server is | ||
| 39 | * ready to handle the commands. | ||
| 40 | */ | ||
| 41 | |||
| 42 | struct obex_ep_descs { | ||
| 43 | struct usb_endpoint_descriptor *obex_in; | ||
| 44 | struct usb_endpoint_descriptor *obex_out; | ||
| 45 | }; | ||
| 46 | |||
| 47 | struct f_obex { | ||
| 48 | struct gserial port; | ||
| 49 | u8 ctrl_id; | ||
| 50 | u8 data_id; | ||
| 51 | u8 port_num; | ||
| 52 | u8 can_activate; | ||
| 53 | |||
| 54 | struct obex_ep_descs fs; | ||
| 55 | struct obex_ep_descs hs; | ||
| 56 | }; | ||
| 57 | |||
| 58 | static inline struct f_obex *func_to_obex(struct usb_function *f) | ||
| 59 | { | ||
| 60 | return container_of(f, struct f_obex, port.func); | ||
| 61 | } | ||
| 62 | |||
| 63 | static inline struct f_obex *port_to_obex(struct gserial *p) | ||
| 64 | { | ||
| 65 | return container_of(p, struct f_obex, port); | ||
| 66 | } | ||
| 67 | |||
| 68 | /*-------------------------------------------------------------------------*/ | ||
| 69 | |||
| 70 | #define OBEX_CTRL_IDX 0 | ||
| 71 | #define OBEX_DATA_IDX 1 | ||
| 72 | |||
| 73 | static struct usb_string obex_string_defs[] = { | ||
| 74 | [OBEX_CTRL_IDX].s = "CDC Object Exchange (OBEX)", | ||
| 75 | [OBEX_DATA_IDX].s = "CDC OBEX Data", | ||
| 76 | { }, /* end of list */ | ||
| 77 | }; | ||
| 78 | |||
| 79 | static struct usb_gadget_strings obex_string_table = { | ||
| 80 | .language = 0x0409, /* en-US */ | ||
| 81 | .strings = obex_string_defs, | ||
| 82 | }; | ||
| 83 | |||
| 84 | static struct usb_gadget_strings *obex_strings[] = { | ||
| 85 | &obex_string_table, | ||
| 86 | NULL, | ||
| 87 | }; | ||
| 88 | |||
| 89 | /*-------------------------------------------------------------------------*/ | ||
| 90 | |||
| 91 | static struct usb_interface_descriptor obex_control_intf __initdata = { | ||
| 92 | .bLength = sizeof(obex_control_intf), | ||
| 93 | .bDescriptorType = USB_DT_INTERFACE, | ||
| 94 | .bInterfaceNumber = 0, | ||
| 95 | |||
| 96 | .bAlternateSetting = 0, | ||
| 97 | .bNumEndpoints = 0, | ||
| 98 | .bInterfaceClass = USB_CLASS_COMM, | ||
| 99 | .bInterfaceSubClass = USB_CDC_SUBCLASS_OBEX, | ||
| 100 | }; | ||
| 101 | |||
| 102 | static struct usb_interface_descriptor obex_data_nop_intf __initdata = { | ||
| 103 | .bLength = sizeof(obex_data_nop_intf), | ||
| 104 | .bDescriptorType = USB_DT_INTERFACE, | ||
| 105 | .bInterfaceNumber = 1, | ||
| 106 | |||
| 107 | .bAlternateSetting = 0, | ||
| 108 | .bNumEndpoints = 0, | ||
| 109 | .bInterfaceClass = USB_CLASS_CDC_DATA, | ||
| 110 | }; | ||
| 111 | |||
| 112 | static struct usb_interface_descriptor obex_data_intf __initdata = { | ||
| 113 | .bLength = sizeof(obex_data_intf), | ||
| 114 | .bDescriptorType = USB_DT_INTERFACE, | ||
| 115 | .bInterfaceNumber = 2, | ||
| 116 | |||
| 117 | .bAlternateSetting = 1, | ||
| 118 | .bNumEndpoints = 2, | ||
| 119 | .bInterfaceClass = USB_CLASS_CDC_DATA, | ||
| 120 | }; | ||
| 121 | |||
| 122 | static struct usb_cdc_header_desc obex_cdc_header_desc __initdata = { | ||
| 123 | .bLength = sizeof(obex_cdc_header_desc), | ||
| 124 | .bDescriptorType = USB_DT_CS_INTERFACE, | ||
| 125 | .bDescriptorSubType = USB_CDC_HEADER_TYPE, | ||
| 126 | .bcdCDC = __constant_cpu_to_le16(0x0120), | ||
| 127 | }; | ||
| 128 | |||
| 129 | static struct usb_cdc_union_desc obex_cdc_union_desc __initdata = { | ||
| 130 | .bLength = sizeof(obex_cdc_union_desc), | ||
| 131 | .bDescriptorType = USB_DT_CS_INTERFACE, | ||
| 132 | .bDescriptorSubType = USB_CDC_UNION_TYPE, | ||
| 133 | .bMasterInterface0 = 1, | ||
| 134 | .bSlaveInterface0 = 2, | ||
| 135 | }; | ||
| 136 | |||
| 137 | static struct usb_cdc_obex_desc obex_desc __initdata = { | ||
| 138 | .bLength = sizeof(obex_desc), | ||
| 139 | .bDescriptorType = USB_DT_CS_INTERFACE, | ||
| 140 | .bDescriptorSubType = USB_CDC_OBEX_TYPE, | ||
| 141 | .bcdVersion = __constant_cpu_to_le16(0x0100), | ||
| 142 | }; | ||
| 143 | |||
| 144 | /* High-Speed Support */ | ||
| 145 | |||
| 146 | static struct usb_endpoint_descriptor obex_hs_ep_out_desc __initdata = { | ||
| 147 | .bLength = USB_DT_ENDPOINT_SIZE, | ||
| 148 | .bDescriptorType = USB_DT_ENDPOINT, | ||
| 149 | |||
| 150 | .bEndpointAddress = USB_DIR_OUT, | ||
| 151 | .bmAttributes = USB_ENDPOINT_XFER_BULK, | ||
| 152 | .wMaxPacketSize = __constant_cpu_to_le16(512), | ||
| 153 | }; | ||
| 154 | |||
| 155 | static struct usb_endpoint_descriptor obex_hs_ep_in_desc __initdata = { | ||
| 156 | .bLength = USB_DT_ENDPOINT_SIZE, | ||
| 157 | .bDescriptorType = USB_DT_ENDPOINT, | ||
| 158 | |||
| 159 | .bEndpointAddress = USB_DIR_IN, | ||
| 160 | .bmAttributes = USB_ENDPOINT_XFER_BULK, | ||
| 161 | .wMaxPacketSize = __constant_cpu_to_le16(512), | ||
| 162 | }; | ||
| 163 | |||
| 164 | static struct usb_descriptor_header *hs_function[] __initdata = { | ||
| 165 | (struct usb_descriptor_header *) &obex_control_intf, | ||
| 166 | (struct usb_descriptor_header *) &obex_cdc_header_desc, | ||
| 167 | (struct usb_descriptor_header *) &obex_desc, | ||
| 168 | (struct usb_descriptor_header *) &obex_cdc_union_desc, | ||
| 169 | |||
| 170 | (struct usb_descriptor_header *) &obex_data_nop_intf, | ||
| 171 | (struct usb_descriptor_header *) &obex_data_intf, | ||
| 172 | (struct usb_descriptor_header *) &obex_hs_ep_in_desc, | ||
| 173 | (struct usb_descriptor_header *) &obex_hs_ep_out_desc, | ||
| 174 | NULL, | ||
| 175 | }; | ||
| 176 | |||
| 177 | /* Full-Speed Support */ | ||
| 178 | |||
| 179 | static struct usb_endpoint_descriptor obex_fs_ep_in_desc __initdata = { | ||
| 180 | .bLength = USB_DT_ENDPOINT_SIZE, | ||
| 181 | .bDescriptorType = USB_DT_ENDPOINT, | ||
| 182 | |||
| 183 | .bEndpointAddress = USB_DIR_IN, | ||
| 184 | .bmAttributes = USB_ENDPOINT_XFER_BULK, | ||
| 185 | }; | ||
| 186 | |||
| 187 | static struct usb_endpoint_descriptor obex_fs_ep_out_desc __initdata = { | ||
| 188 | .bLength = USB_DT_ENDPOINT_SIZE, | ||
| 189 | .bDescriptorType = USB_DT_ENDPOINT, | ||
| 190 | |||
| 191 | .bEndpointAddress = USB_DIR_OUT, | ||
| 192 | .bmAttributes = USB_ENDPOINT_XFER_BULK, | ||
| 193 | }; | ||
| 194 | |||
| 195 | static struct usb_descriptor_header *fs_function[] __initdata = { | ||
| 196 | (struct usb_descriptor_header *) &obex_control_intf, | ||
| 197 | (struct usb_descriptor_header *) &obex_cdc_header_desc, | ||
| 198 | (struct usb_descriptor_header *) &obex_desc, | ||
| 199 | (struct usb_descriptor_header *) &obex_cdc_union_desc, | ||
| 200 | |||
| 201 | (struct usb_descriptor_header *) &obex_data_nop_intf, | ||
| 202 | (struct usb_descriptor_header *) &obex_data_intf, | ||
| 203 | (struct usb_descriptor_header *) &obex_fs_ep_in_desc, | ||
| 204 | (struct usb_descriptor_header *) &obex_fs_ep_out_desc, | ||
| 205 | NULL, | ||
| 206 | }; | ||
| 207 | |||
| 208 | /*-------------------------------------------------------------------------*/ | ||
| 209 | |||
| 210 | static int obex_set_alt(struct usb_function *f, unsigned intf, unsigned alt) | ||
| 211 | { | ||
| 212 | struct f_obex *obex = func_to_obex(f); | ||
| 213 | struct usb_composite_dev *cdev = f->config->cdev; | ||
| 214 | |||
| 215 | if (intf == obex->ctrl_id) { | ||
| 216 | if (alt != 0) | ||
| 217 | goto fail; | ||
| 218 | /* NOP */ | ||
| 219 | DBG(cdev, "reset obex ttyGS%d control\n", obex->port_num); | ||
| 220 | |||
| 221 | } else if (intf == obex->data_id) { | ||
| 222 | if (alt > 1) | ||
| 223 | goto fail; | ||
| 224 | |||
| 225 | if (obex->port.in->driver_data) { | ||
| 226 | DBG(cdev, "reset obex ttyGS%d\n", obex->port_num); | ||
| 227 | gserial_disconnect(&obex->port); | ||
| 228 | } | ||
| 229 | |||
| 230 | if (!obex->port.in_desc) { | ||
| 231 | DBG(cdev, "init obex ttyGS%d\n", obex->port_num); | ||
| 232 | obex->port.in_desc = ep_choose(cdev->gadget, | ||
| 233 | obex->hs.obex_in, obex->fs.obex_in); | ||
| 234 | obex->port.out_desc = ep_choose(cdev->gadget, | ||
| 235 | obex->hs.obex_out, obex->fs.obex_out); | ||
| 236 | } | ||
| 237 | |||
| 238 | if (alt == 1) { | ||
| 239 | DBG(cdev, "activate obex ttyGS%d\n", obex->port_num); | ||
| 240 | gserial_connect(&obex->port, obex->port_num); | ||
| 241 | } | ||
| 242 | |||
| 243 | } else | ||
| 244 | goto fail; | ||
| 245 | |||
| 246 | return 0; | ||
| 247 | |||
| 248 | fail: | ||
| 249 | return -EINVAL; | ||
| 250 | } | ||
| 251 | |||
| 252 | static int obex_get_alt(struct usb_function *f, unsigned intf) | ||
| 253 | { | ||
| 254 | struct f_obex *obex = func_to_obex(f); | ||
| 255 | |||
| 256 | if (intf == obex->ctrl_id) | ||
| 257 | return 0; | ||
| 258 | |||
| 259 | return obex->port.in->driver_data ? 1 : 0; | ||
| 260 | } | ||
| 261 | |||
| 262 | static void obex_disable(struct usb_function *f) | ||
| 263 | { | ||
| 264 | struct f_obex *obex = func_to_obex(f); | ||
| 265 | struct usb_composite_dev *cdev = f->config->cdev; | ||
| 266 | |||
| 267 | DBG(cdev, "obex ttyGS%d disable\n", obex->port_num); | ||
| 268 | gserial_disconnect(&obex->port); | ||
| 269 | } | ||
| 270 | |||
| 271 | /*-------------------------------------------------------------------------*/ | ||
| 272 | |||
| 273 | static void obex_connect(struct gserial *g) | ||
| 274 | { | ||
| 275 | struct f_obex *obex = port_to_obex(g); | ||
| 276 | struct usb_composite_dev *cdev = g->func.config->cdev; | ||
| 277 | int status; | ||
| 278 | |||
| 279 | if (!obex->can_activate) | ||
| 280 | return; | ||
| 281 | |||
| 282 | status = usb_function_activate(&g->func); | ||
| 283 | if (status) | ||
| 284 | DBG(cdev, "obex ttyGS%d function activate --> %d\n", | ||
| 285 | obex->port_num, status); | ||
| 286 | } | ||
| 287 | |||
| 288 | static void obex_disconnect(struct gserial *g) | ||
| 289 | { | ||
| 290 | struct f_obex *obex = port_to_obex(g); | ||
| 291 | struct usb_composite_dev *cdev = g->func.config->cdev; | ||
| 292 | int status; | ||
| 293 | |||
| 294 | if (!obex->can_activate) | ||
| 295 | return; | ||
| 296 | |||
| 297 | status = usb_function_deactivate(&g->func); | ||
| 298 | if (status) | ||
| 299 | DBG(cdev, "obex ttyGS%d function deactivate --> %d\n", | ||
| 300 | obex->port_num, status); | ||
| 301 | } | ||
| 302 | |||
| 303 | /*-------------------------------------------------------------------------*/ | ||
| 304 | |||
| 305 | static int __init | ||
| 306 | obex_bind(struct usb_configuration *c, struct usb_function *f) | ||
| 307 | { | ||
| 308 | struct usb_composite_dev *cdev = c->cdev; | ||
| 309 | struct f_obex *obex = func_to_obex(f); | ||
| 310 | int status; | ||
| 311 | struct usb_ep *ep; | ||
| 312 | |||
| 313 | /* allocate instance-specific interface IDs, and patch descriptors */ | ||
| 314 | |||
| 315 | status = usb_interface_id(c, f); | ||
| 316 | if (status < 0) | ||
| 317 | goto fail; | ||
| 318 | obex->ctrl_id = status; | ||
| 319 | |||
| 320 | obex_control_intf.bInterfaceNumber = status; | ||
| 321 | obex_cdc_union_desc.bMasterInterface0 = status; | ||
| 322 | |||
| 323 | status = usb_interface_id(c, f); | ||
| 324 | if (status < 0) | ||
| 325 | goto fail; | ||
| 326 | obex->data_id = status; | ||
| 327 | |||
| 328 | obex_data_nop_intf.bInterfaceNumber = status; | ||
| 329 | obex_data_intf.bInterfaceNumber = status; | ||
| 330 | obex_cdc_union_desc.bSlaveInterface0 = status; | ||
| 331 | |||
| 332 | /* allocate instance-specific endpoints */ | ||
| 333 | |||
| 334 | ep = usb_ep_autoconfig(cdev->gadget, &obex_fs_ep_in_desc); | ||
| 335 | if (!ep) | ||
| 336 | goto fail; | ||
| 337 | obex->port.in = ep; | ||
| 338 | ep->driver_data = cdev; /* claim */ | ||
| 339 | |||
| 340 | ep = usb_ep_autoconfig(cdev->gadget, &obex_fs_ep_out_desc); | ||
| 341 | if (!ep) | ||
| 342 | goto fail; | ||
| 343 | obex->port.out = ep; | ||
| 344 | ep->driver_data = cdev; /* claim */ | ||
| 345 | |||
| 346 | /* copy descriptors, and track endpoint copies */ | ||
| 347 | f->descriptors = usb_copy_descriptors(fs_function); | ||
| 348 | |||
| 349 | obex->fs.obex_in = usb_find_endpoint(fs_function, | ||
| 350 | f->descriptors, &obex_fs_ep_in_desc); | ||
| 351 | obex->fs.obex_out = usb_find_endpoint(fs_function, | ||
| 352 | f->descriptors, &obex_fs_ep_out_desc); | ||
| 353 | |||
| 354 | /* support all relevant hardware speeds... we expect that when | ||
| 355 | * hardware is dual speed, all bulk-capable endpoints work at | ||
| 356 | * both speeds | ||
| 357 | */ | ||
| 358 | if (gadget_is_dualspeed(c->cdev->gadget)) { | ||
| 359 | |||
| 360 | obex_hs_ep_in_desc.bEndpointAddress = | ||
| 361 | obex_fs_ep_in_desc.bEndpointAddress; | ||
| 362 | obex_hs_ep_out_desc.bEndpointAddress = | ||
| 363 | obex_fs_ep_out_desc.bEndpointAddress; | ||
| 364 | |||
| 365 | /* copy descriptors, and track endpoint copies */ | ||
| 366 | f->hs_descriptors = usb_copy_descriptors(hs_function); | ||
| 367 | |||
| 368 | obex->hs.obex_in = usb_find_endpoint(hs_function, | ||
| 369 | f->descriptors, &obex_hs_ep_in_desc); | ||
| 370 | obex->hs.obex_out = usb_find_endpoint(hs_function, | ||
| 371 | f->descriptors, &obex_hs_ep_out_desc); | ||
| 372 | } | ||
| 373 | |||
| 374 | /* Avoid letting this gadget enumerate until the userspace | ||
| 375 | * OBEX server is active. | ||
| 376 | */ | ||
| 377 | status = usb_function_deactivate(f); | ||
| 378 | if (status < 0) | ||
| 379 | WARNING(cdev, "obex ttyGS%d: can't prevent enumeration, %d\n", | ||
| 380 | obex->port_num, status); | ||
| 381 | else | ||
| 382 | obex->can_activate = true; | ||
| 383 | |||
| 384 | |||
| 385 | DBG(cdev, "obex ttyGS%d: %s speed IN/%s OUT/%s\n", | ||
| 386 | obex->port_num, | ||
| 387 | gadget_is_dualspeed(c->cdev->gadget) ? "dual" : "full", | ||
| 388 | obex->port.in->name, obex->port.out->name); | ||
| 389 | |||
| 390 | return 0; | ||
| 391 | |||
| 392 | fail: | ||
| 393 | /* we might as well release our claims on endpoints */ | ||
| 394 | if (obex->port.out) | ||
| 395 | obex->port.out->driver_data = NULL; | ||
| 396 | if (obex->port.in) | ||
| 397 | obex->port.in->driver_data = NULL; | ||
| 398 | |||
| 399 | ERROR(cdev, "%s/%p: can't bind, err %d\n", f->name, f, status); | ||
| 400 | |||
| 401 | return status; | ||
| 402 | } | ||
| 403 | |||
| 404 | static void | ||
| 405 | obex_unbind(struct usb_configuration *c, struct usb_function *f) | ||
| 406 | { | ||
| 407 | if (gadget_is_dualspeed(c->cdev->gadget)) | ||
| 408 | usb_free_descriptors(f->hs_descriptors); | ||
| 409 | usb_free_descriptors(f->descriptors); | ||
| 410 | kfree(func_to_obex(f)); | ||
| 411 | } | ||
| 412 | |||
| 413 | /* Some controllers can't support CDC OBEX ... */ | ||
| 414 | static inline bool can_support_obex(struct usb_configuration *c) | ||
| 415 | { | ||
| 416 | /* Since the first interface is a NOP, we can ignore the | ||
| 417 | * issue of multi-interface support on most controllers. | ||
| 418 | * | ||
| 419 | * Altsettings are mandatory, however... | ||
| 420 | */ | ||
| 421 | if (!gadget_supports_altsettings(c->cdev->gadget)) | ||
| 422 | return false; | ||
| 423 | |||
| 424 | /* everything else is *probably* fine ... */ | ||
| 425 | return true; | ||
| 426 | } | ||
| 427 | |||
| 428 | /** | ||
| 429 | * obex_bind_config - add a CDC OBEX function to a configuration | ||
| 430 | * @c: the configuration to support the CDC OBEX instance | ||
| 431 | * @port_num: /dev/ttyGS* port this interface will use | ||
| 432 | * Context: single threaded during gadget setup | ||
| 433 | * | ||
| 434 | * Returns zero on success, else negative errno. | ||
| 435 | * | ||
| 436 | * Caller must have called @gserial_setup() with enough ports to | ||
| 437 | * handle all the ones it binds. Caller is also responsible | ||
| 438 | * for calling @gserial_cleanup() before module unload. | ||
| 439 | */ | ||
| 440 | int __init obex_bind_config(struct usb_configuration *c, u8 port_num) | ||
| 441 | { | ||
| 442 | struct f_obex *obex; | ||
| 443 | int status; | ||
| 444 | |||
| 445 | if (!can_support_obex(c)) | ||
| 446 | return -EINVAL; | ||
| 447 | |||
| 448 | /* maybe allocate device-global string IDs, and patch descriptors */ | ||
| 449 | if (obex_string_defs[OBEX_CTRL_IDX].id == 0) { | ||
| 450 | status = usb_string_id(c->cdev); | ||
| 451 | if (status < 0) | ||
| 452 | return status; | ||
| 453 | obex_string_defs[OBEX_CTRL_IDX].id = status; | ||
| 454 | |||
| 455 | obex_control_intf.iInterface = status; | ||
| 456 | |||
| 457 | status = usb_string_id(c->cdev); | ||
| 458 | if (status < 0) | ||
| 459 | return status; | ||
| 460 | obex_string_defs[OBEX_DATA_IDX].id = status; | ||
| 461 | |||
| 462 | obex_data_nop_intf.iInterface = | ||
| 463 | obex_data_intf.iInterface = status; | ||
| 464 | } | ||
| 465 | |||
| 466 | /* allocate and initialize one new instance */ | ||
| 467 | obex = kzalloc(sizeof *obex, GFP_KERNEL); | ||
| 468 | if (!obex) | ||
| 469 | return -ENOMEM; | ||
| 470 | |||
| 471 | obex->port_num = port_num; | ||
| 472 | |||
| 473 | obex->port.connect = obex_connect; | ||
| 474 | obex->port.disconnect = obex_disconnect; | ||
| 475 | |||
| 476 | obex->port.func.name = "obex"; | ||
| 477 | obex->port.func.strings = obex_strings; | ||
| 478 | /* descriptors are per-instance copies */ | ||
| 479 | obex->port.func.bind = obex_bind; | ||
| 480 | obex->port.func.unbind = obex_unbind; | ||
| 481 | obex->port.func.set_alt = obex_set_alt; | ||
| 482 | obex->port.func.get_alt = obex_get_alt; | ||
| 483 | obex->port.func.disable = obex_disable; | ||
| 484 | |||
| 485 | status = usb_add_function(c, &obex->port.func); | ||
| 486 | if (status) | ||
| 487 | kfree(obex); | ||
| 488 | |||
| 489 | return status; | ||
| 490 | } | ||
| 491 | |||
| 492 | MODULE_AUTHOR("Felipe Balbi"); | ||
| 493 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/usb/gadget/f_sourcesink.c b/drivers/usb/gadget/f_sourcesink.c index f18c3a14d72a..dc84d26d2835 100644 --- a/drivers/usb/gadget/f_sourcesink.c +++ b/drivers/usb/gadget/f_sourcesink.c | |||
| @@ -552,7 +552,6 @@ static struct usb_configuration sourcesink_driver = { | |||
| 552 | .setup = sourcesink_setup, | 552 | .setup = sourcesink_setup, |
| 553 | .bConfigurationValue = 3, | 553 | .bConfigurationValue = 3, |
| 554 | .bmAttributes = USB_CONFIG_ATT_SELFPOWER, | 554 | .bmAttributes = USB_CONFIG_ATT_SELFPOWER, |
| 555 | .bMaxPower = 1, /* 2 mA, minimal */ | ||
| 556 | /* .iConfiguration = DYNAMIC */ | 555 | /* .iConfiguration = DYNAMIC */ |
| 557 | }; | 556 | }; |
| 558 | 557 | ||
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c index 0c632d22a631..c4e62a6297d7 100644 --- a/drivers/usb/gadget/file_storage.c +++ b/drivers/usb/gadget/file_storage.c | |||
| @@ -851,7 +851,7 @@ config_desc = { | |||
| 851 | .bConfigurationValue = CONFIG_VALUE, | 851 | .bConfigurationValue = CONFIG_VALUE, |
| 852 | .iConfiguration = STRING_CONFIG, | 852 | .iConfiguration = STRING_CONFIG, |
| 853 | .bmAttributes = USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER, | 853 | .bmAttributes = USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER, |
| 854 | .bMaxPower = 1, // self-powered | 854 | .bMaxPower = CONFIG_USB_GADGET_VBUS_DRAW / 2, |
| 855 | }; | 855 | }; |
| 856 | 856 | ||
| 857 | static struct usb_otg_descriptor | 857 | static struct usb_otg_descriptor |
| @@ -2676,11 +2676,24 @@ static int check_command(struct fsg_dev *fsg, int cmnd_size, | |||
| 2676 | /* Verify the length of the command itself */ | 2676 | /* Verify the length of the command itself */ |
| 2677 | if (cmnd_size != fsg->cmnd_size) { | 2677 | if (cmnd_size != fsg->cmnd_size) { |
| 2678 | 2678 | ||
| 2679 | /* Special case workaround: MS-Windows issues REQUEST SENSE | 2679 | /* Special case workaround: There are plenty of buggy SCSI |
| 2680 | * with cbw->Length == 12 (it should be 6). */ | 2680 | * implementations. Many have issues with cbw->Length |
| 2681 | if (fsg->cmnd[0] == SC_REQUEST_SENSE && fsg->cmnd_size == 12) | 2681 | * field passing a wrong command size. For those cases we |
| 2682 | * always try to work around the problem by using the length | ||
| 2683 | * sent by the host side provided it is at least as large | ||
| 2684 | * as the correct command length. | ||
| 2685 | * Examples of such cases would be MS-Windows, which issues | ||
| 2686 | * REQUEST SENSE with cbw->Length == 12 where it should | ||
| 2687 | * be 6, and xbox360 issuing INQUIRY, TEST UNIT READY and | ||
| 2688 | * REQUEST SENSE with cbw->Length == 10 where it should | ||
| 2689 | * be 6 as well. | ||
| 2690 | */ | ||
| 2691 | if (cmnd_size <= fsg->cmnd_size) { | ||
| 2692 | DBG(fsg, "%s is buggy! Expected length %d " | ||
| 2693 | "but we got %d\n", name, | ||
| 2694 | cmnd_size, fsg->cmnd_size); | ||
| 2682 | cmnd_size = fsg->cmnd_size; | 2695 | cmnd_size = fsg->cmnd_size; |
| 2683 | else { | 2696 | } else { |
| 2684 | fsg->phase_error = 1; | 2697 | fsg->phase_error = 1; |
| 2685 | return -EINVAL; | 2698 | return -EINVAL; |
| 2686 | } | 2699 | } |
diff --git a/drivers/usb/gadget/fsl_qe_udc.c b/drivers/usb/gadget/fsl_qe_udc.c new file mode 100644 index 000000000000..1fe8b44787b3 --- /dev/null +++ b/drivers/usb/gadget/fsl_qe_udc.c | |||
| @@ -0,0 +1,2760 @@ | |||
| 1 | /* | ||
| 2 | * driver/usb/gadget/fsl_qe_udc.c | ||
| 3 | * | ||
| 4 | * Copyright (c) 2006-2008 Freescale Semiconductor, Inc. All rights reserved. | ||
| 5 | * | ||
| 6 | * Xie Xiaobo <X.Xie@freescale.com> | ||
| 7 | * Li Yang <leoli@freescale.com> | ||
| 8 | * Based on bareboard code from Shlomi Gridish. | ||
| 9 | * | ||
| 10 | * Description: | ||
| 11 | * Freescle QE/CPM USB Pheripheral Controller Driver | ||
| 12 | * The controller can be found on MPC8360, MPC8272, and etc. | ||
| 13 | * MPC8360 Rev 1.1 may need QE mircocode update | ||
| 14 | * | ||
| 15 | * This program is free software; you can redistribute it and/or modify it | ||
| 16 | * under the terms of the GNU General Public License as published by the | ||
| 17 | * Free Software Foundation; either version 2 of the License, or (at your | ||
| 18 | * option) any later version. | ||
| 19 | */ | ||
| 20 | |||
| 21 | #undef USB_TRACE | ||
| 22 | |||
| 23 | #include <linux/module.h> | ||
| 24 | #include <linux/kernel.h> | ||
| 25 | #include <linux/init.h> | ||
| 26 | #include <linux/ioport.h> | ||
| 27 | #include <linux/types.h> | ||
| 28 | #include <linux/errno.h> | ||
| 29 | #include <linux/slab.h> | ||
| 30 | #include <linux/list.h> | ||
| 31 | #include <linux/interrupt.h> | ||
| 32 | #include <linux/io.h> | ||
| 33 | #include <linux/moduleparam.h> | ||
| 34 | #include <linux/of_platform.h> | ||
| 35 | #include <linux/dma-mapping.h> | ||
| 36 | #include <linux/usb/ch9.h> | ||
| 37 | #include <linux/usb/gadget.h> | ||
| 38 | #include <linux/usb/otg.h> | ||
| 39 | #include <asm/qe.h> | ||
| 40 | #include <asm/cpm.h> | ||
| 41 | #include <asm/dma.h> | ||
| 42 | #include <asm/reg.h> | ||
| 43 | #include "fsl_qe_udc.h" | ||
| 44 | |||
| 45 | #define DRIVER_DESC "Freescale QE/CPM USB Device Controller driver" | ||
| 46 | #define DRIVER_AUTHOR "Xie XiaoBo" | ||
| 47 | #define DRIVER_VERSION "1.0" | ||
| 48 | |||
| 49 | #define DMA_ADDR_INVALID (~(dma_addr_t)0) | ||
| 50 | |||
| 51 | static const char driver_name[] = "fsl_qe_udc"; | ||
| 52 | static const char driver_desc[] = DRIVER_DESC; | ||
| 53 | |||
| 54 | /*ep name is important in gadget, it should obey the convention of ep_match()*/ | ||
| 55 | static const char *const ep_name[] = { | ||
| 56 | "ep0-control", /* everyone has ep0 */ | ||
| 57 | /* 3 configurable endpoints */ | ||
| 58 | "ep1", | ||
| 59 | "ep2", | ||
| 60 | "ep3", | ||
| 61 | }; | ||
| 62 | |||
| 63 | static struct usb_endpoint_descriptor qe_ep0_desc = { | ||
| 64 | .bLength = USB_DT_ENDPOINT_SIZE, | ||
| 65 | .bDescriptorType = USB_DT_ENDPOINT, | ||
| 66 | |||
| 67 | .bEndpointAddress = 0, | ||
| 68 | .bmAttributes = USB_ENDPOINT_XFER_CONTROL, | ||
| 69 | .wMaxPacketSize = USB_MAX_CTRL_PAYLOAD, | ||
| 70 | }; | ||
| 71 | |||
| 72 | /* it is initialized in probe() */ | ||
| 73 | static struct qe_udc *udc_controller; | ||
| 74 | |||
| 75 | /******************************************************************** | ||
| 76 | * Internal Used Function Start | ||
| 77 | ********************************************************************/ | ||
| 78 | /*----------------------------------------------------------------- | ||
| 79 | * done() - retire a request; caller blocked irqs | ||
| 80 | *--------------------------------------------------------------*/ | ||
| 81 | static void done(struct qe_ep *ep, struct qe_req *req, int status) | ||
| 82 | { | ||
| 83 | struct qe_udc *udc = ep->udc; | ||
| 84 | unsigned char stopped = ep->stopped; | ||
| 85 | |||
| 86 | /* the req->queue pointer is used by ep_queue() func, in which | ||
| 87 | * the request will be added into a udc_ep->queue 'd tail | ||
| 88 | * so here the req will be dropped from the ep->queue | ||
| 89 | */ | ||
| 90 | list_del_init(&req->queue); | ||
| 91 | |||
| 92 | /* req.status should be set as -EINPROGRESS in ep_queue() */ | ||
| 93 | if (req->req.status == -EINPROGRESS) | ||
| 94 | req->req.status = status; | ||
| 95 | else | ||
| 96 | status = req->req.status; | ||
| 97 | |||
| 98 | if (req->mapped) { | ||
| 99 | dma_unmap_single(udc->gadget.dev.parent, | ||
| 100 | req->req.dma, req->req.length, | ||
| 101 | ep_is_in(ep) | ||
| 102 | ? DMA_TO_DEVICE | ||
| 103 | : DMA_FROM_DEVICE); | ||
| 104 | req->req.dma = DMA_ADDR_INVALID; | ||
| 105 | req->mapped = 0; | ||
| 106 | } else | ||
| 107 | dma_sync_single_for_cpu(udc->gadget.dev.parent, | ||
| 108 | req->req.dma, req->req.length, | ||
| 109 | ep_is_in(ep) | ||
| 110 | ? DMA_TO_DEVICE | ||
| 111 | : DMA_FROM_DEVICE); | ||
| 112 | |||
| 113 | if (status && (status != -ESHUTDOWN)) | ||
| 114 | dev_vdbg(udc->dev, "complete %s req %p stat %d len %u/%u\n", | ||
| 115 | ep->ep.name, &req->req, status, | ||
| 116 | req->req.actual, req->req.length); | ||
| 117 | |||
| 118 | /* don't modify queue heads during completion callback */ | ||
| 119 | ep->stopped = 1; | ||
| 120 | spin_unlock(&udc->lock); | ||
| 121 | |||
| 122 | /* this complete() should a func implemented by gadget layer, | ||
| 123 | * eg fsg->bulk_in_complete() */ | ||
| 124 | if (req->req.complete) | ||
| 125 | req->req.complete(&ep->ep, &req->req); | ||
| 126 | |||
| 127 | spin_lock(&udc->lock); | ||
| 128 | |||
| 129 | ep->stopped = stopped; | ||
| 130 | } | ||
| 131 | |||
| 132 | /*----------------------------------------------------------------- | ||
| 133 | * nuke(): delete all requests related to this ep | ||
| 134 | *--------------------------------------------------------------*/ | ||
| 135 | static void nuke(struct qe_ep *ep, int status) | ||
| 136 | { | ||
| 137 | /* Whether this eq has request linked */ | ||
| 138 | while (!list_empty(&ep->queue)) { | ||
| 139 | struct qe_req *req = NULL; | ||
| 140 | req = list_entry(ep->queue.next, struct qe_req, queue); | ||
| 141 | |||
| 142 | done(ep, req, status); | ||
| 143 | } | ||
| 144 | } | ||
| 145 | |||
| 146 | /*---------------------------------------------------------------------------* | ||
| 147 | * USB and Endpoint manipulate process, include parameter and register * | ||
| 148 | *---------------------------------------------------------------------------*/ | ||
| 149 | /* @value: 1--set stall 0--clean stall */ | ||
| 150 | static int qe_eprx_stall_change(struct qe_ep *ep, int value) | ||
| 151 | { | ||
| 152 | u16 tem_usep; | ||
| 153 | u8 epnum = ep->epnum; | ||
| 154 | struct qe_udc *udc = ep->udc; | ||
| 155 | |||
| 156 | tem_usep = in_be16(&udc->usb_regs->usb_usep[epnum]); | ||
| 157 | tem_usep = tem_usep & ~USB_RHS_MASK; | ||
| 158 | if (value == 1) | ||
| 159 | tem_usep |= USB_RHS_STALL; | ||
| 160 | else if (ep->dir == USB_DIR_IN) | ||
| 161 | tem_usep |= USB_RHS_IGNORE_OUT; | ||
| 162 | |||
| 163 | out_be16(&udc->usb_regs->usb_usep[epnum], tem_usep); | ||
| 164 | return 0; | ||
| 165 | } | ||
| 166 | |||
| 167 | static int qe_eptx_stall_change(struct qe_ep *ep, int value) | ||
| 168 | { | ||
| 169 | u16 tem_usep; | ||
| 170 | u8 epnum = ep->epnum; | ||
| 171 | struct qe_udc *udc = ep->udc; | ||
| 172 | |||
| 173 | tem_usep = in_be16(&udc->usb_regs->usb_usep[epnum]); | ||
| 174 | tem_usep = tem_usep & ~USB_THS_MASK; | ||
| 175 | if (value == 1) | ||
| 176 | tem_usep |= USB_THS_STALL; | ||
| 177 | else if (ep->dir == USB_DIR_OUT) | ||
| 178 | tem_usep |= USB_THS_IGNORE_IN; | ||
| 179 | |||
| 180 | out_be16(&udc->usb_regs->usb_usep[epnum], tem_usep); | ||
| 181 | |||
| 182 | return 0; | ||
| 183 | } | ||
| 184 | |||
| 185 | static int qe_ep0_stall(struct qe_udc *udc) | ||
| 186 | { | ||
| 187 | qe_eptx_stall_change(&udc->eps[0], 1); | ||
| 188 | qe_eprx_stall_change(&udc->eps[0], 1); | ||
| 189 | udc_controller->ep0_state = WAIT_FOR_SETUP; | ||
| 190 | udc_controller->ep0_dir = 0; | ||
| 191 | return 0; | ||
| 192 | } | ||
| 193 | |||
| 194 | static int qe_eprx_nack(struct qe_ep *ep) | ||
| 195 | { | ||
| 196 | u8 epnum = ep->epnum; | ||
| 197 | struct qe_udc *udc = ep->udc; | ||
| 198 | |||
| 199 | if (ep->state == EP_STATE_IDLE) { | ||
| 200 | /* Set the ep's nack */ | ||
| 201 | clrsetbits_be16(&udc->usb_regs->usb_usep[epnum], | ||
| 202 | USB_RHS_MASK, USB_RHS_NACK); | ||
| 203 | |||
| 204 | /* Mask Rx and Busy interrupts */ | ||
| 205 | clrbits16(&udc->usb_regs->usb_usbmr, | ||
| 206 | (USB_E_RXB_MASK | USB_E_BSY_MASK)); | ||
| 207 | |||
| 208 | ep->state = EP_STATE_NACK; | ||
| 209 | } | ||
| 210 | return 0; | ||
| 211 | } | ||
| 212 | |||
| 213 | static int qe_eprx_normal(struct qe_ep *ep) | ||
| 214 | { | ||
| 215 | struct qe_udc *udc = ep->udc; | ||
| 216 | |||
| 217 | if (ep->state == EP_STATE_NACK) { | ||
| 218 | clrsetbits_be16(&udc->usb_regs->usb_usep[ep->epnum], | ||
| 219 | USB_RTHS_MASK, USB_THS_IGNORE_IN); | ||
| 220 | |||
| 221 | /* Unmask RX interrupts */ | ||
| 222 | out_be16(&udc->usb_regs->usb_usber, | ||
| 223 | USB_E_BSY_MASK | USB_E_RXB_MASK); | ||
| 224 | setbits16(&udc->usb_regs->usb_usbmr, | ||
| 225 | (USB_E_RXB_MASK | USB_E_BSY_MASK)); | ||
| 226 | |||
| 227 | ep->state = EP_STATE_IDLE; | ||
| 228 | ep->has_data = 0; | ||
| 229 | } | ||
| 230 | |||
| 231 | return 0; | ||
| 232 | } | ||
| 233 | |||
| 234 | static int qe_ep_cmd_stoptx(struct qe_ep *ep) | ||
| 235 | { | ||
| 236 | if (ep->udc->soc_type == PORT_CPM) | ||
| 237 | cpm_command(CPM_USB_STOP_TX | (ep->epnum << CPM_USB_EP_SHIFT), | ||
| 238 | CPM_USB_STOP_TX_OPCODE); | ||
| 239 | else | ||
| 240 | qe_issue_cmd(QE_USB_STOP_TX, QE_CR_SUBBLOCK_USB, | ||
| 241 | ep->epnum, 0); | ||
| 242 | |||
| 243 | return 0; | ||
| 244 | } | ||
| 245 | |||
| 246 | static int qe_ep_cmd_restarttx(struct qe_ep *ep) | ||
| 247 | { | ||
| 248 | if (ep->udc->soc_type == PORT_CPM) | ||
| 249 | cpm_command(CPM_USB_RESTART_TX | (ep->epnum << | ||
| 250 | CPM_USB_EP_SHIFT), CPM_USB_RESTART_TX_OPCODE); | ||
| 251 | else | ||
| 252 | qe_issue_cmd(QE_USB_RESTART_TX, QE_CR_SUBBLOCK_USB, | ||
| 253 | ep->epnum, 0); | ||
| 254 | |||
| 255 | return 0; | ||
| 256 | } | ||
| 257 | |||
| 258 | static int qe_ep_flushtxfifo(struct qe_ep *ep) | ||
| 259 | { | ||
| 260 | struct qe_udc *udc = ep->udc; | ||
| 261 | int i; | ||
| 262 | |||
| 263 | i = (int)ep->epnum; | ||
| 264 | |||
| 265 | qe_ep_cmd_stoptx(ep); | ||
| 266 | out_8(&udc->usb_regs->usb_uscom, | ||
| 267 | USB_CMD_FLUSH_FIFO | (USB_CMD_EP_MASK & (ep->epnum))); | ||
| 268 | out_be16(&udc->ep_param[i]->tbptr, in_be16(&udc->ep_param[i]->tbase)); | ||
| 269 | out_be32(&udc->ep_param[i]->tstate, 0); | ||
| 270 | out_be16(&udc->ep_param[i]->tbcnt, 0); | ||
| 271 | |||
| 272 | ep->c_txbd = ep->txbase; | ||
| 273 | ep->n_txbd = ep->txbase; | ||
| 274 | qe_ep_cmd_restarttx(ep); | ||
| 275 | return 0; | ||
| 276 | } | ||
| 277 | |||
| 278 | static int qe_ep_filltxfifo(struct qe_ep *ep) | ||
| 279 | { | ||
| 280 | struct qe_udc *udc = ep->udc; | ||
| 281 | |||
| 282 | out_8(&udc->usb_regs->usb_uscom, | ||
| 283 | USB_CMD_STR_FIFO | (USB_CMD_EP_MASK & (ep->epnum))); | ||
| 284 | return 0; | ||
| 285 | } | ||
| 286 | |||
| 287 | static int qe_epbds_reset(struct qe_udc *udc, int pipe_num) | ||
| 288 | { | ||
| 289 | struct qe_ep *ep; | ||
| 290 | u32 bdring_len; | ||
| 291 | struct qe_bd __iomem *bd; | ||
| 292 | int i; | ||
| 293 | |||
| 294 | ep = &udc->eps[pipe_num]; | ||
| 295 | |||
| 296 | if (ep->dir == USB_DIR_OUT) | ||
| 297 | bdring_len = USB_BDRING_LEN_RX; | ||
| 298 | else | ||
| 299 | bdring_len = USB_BDRING_LEN; | ||
| 300 | |||
| 301 | bd = ep->rxbase; | ||
| 302 | for (i = 0; i < (bdring_len - 1); i++) { | ||
| 303 | out_be32((u32 __iomem *)bd, R_E | R_I); | ||
| 304 | bd++; | ||
| 305 | } | ||
| 306 | out_be32((u32 __iomem *)bd, R_E | R_I | R_W); | ||
| 307 | |||
| 308 | bd = ep->txbase; | ||
| 309 | for (i = 0; i < USB_BDRING_LEN_TX - 1; i++) { | ||
| 310 | out_be32(&bd->buf, 0); | ||
| 311 | out_be32((u32 __iomem *)bd, 0); | ||
| 312 | bd++; | ||
| 313 | } | ||
| 314 | out_be32((u32 __iomem *)bd, T_W); | ||
| 315 | |||
| 316 | return 0; | ||
| 317 | } | ||
| 318 | |||
| 319 | static int qe_ep_reset(struct qe_udc *udc, int pipe_num) | ||
| 320 | { | ||
| 321 | struct qe_ep *ep; | ||
| 322 | u16 tmpusep; | ||
| 323 | |||
| 324 | ep = &udc->eps[pipe_num]; | ||
| 325 | tmpusep = in_be16(&udc->usb_regs->usb_usep[pipe_num]); | ||
| 326 | tmpusep &= ~USB_RTHS_MASK; | ||
| 327 | |||
| 328 | switch (ep->dir) { | ||
| 329 | case USB_DIR_BOTH: | ||
| 330 | qe_ep_flushtxfifo(ep); | ||
| 331 | break; | ||
| 332 | case USB_DIR_OUT: | ||
| 333 | tmpusep |= USB_THS_IGNORE_IN; | ||
| 334 | break; | ||
| 335 | case USB_DIR_IN: | ||
| 336 | qe_ep_flushtxfifo(ep); | ||
| 337 | tmpusep |= USB_RHS_IGNORE_OUT; | ||
| 338 | break; | ||
| 339 | default: | ||
| 340 | break; | ||
| 341 | } | ||
| 342 | out_be16(&udc->usb_regs->usb_usep[pipe_num], tmpusep); | ||
| 343 | |||
| 344 | qe_epbds_reset(udc, pipe_num); | ||
| 345 | |||
| 346 | return 0; | ||
| 347 | } | ||
| 348 | |||
| 349 | static int qe_ep_toggledata01(struct qe_ep *ep) | ||
| 350 | { | ||
| 351 | ep->data01 ^= 0x1; | ||
| 352 | return 0; | ||
| 353 | } | ||
| 354 | |||
| 355 | static int qe_ep_bd_init(struct qe_udc *udc, unsigned char pipe_num) | ||
| 356 | { | ||
| 357 | struct qe_ep *ep = &udc->eps[pipe_num]; | ||
| 358 | unsigned long tmp_addr = 0; | ||
| 359 | struct usb_ep_para __iomem *epparam; | ||
| 360 | int i; | ||
| 361 | struct qe_bd __iomem *bd; | ||
| 362 | int bdring_len; | ||
| 363 | |||
| 364 | if (ep->dir == USB_DIR_OUT) | ||
| 365 | bdring_len = USB_BDRING_LEN_RX; | ||
| 366 | else | ||
| 367 | bdring_len = USB_BDRING_LEN; | ||
| 368 | |||
| 369 | epparam = udc->ep_param[pipe_num]; | ||
| 370 | /* alloc multi-ram for BD rings and set the ep parameters */ | ||
| 371 | tmp_addr = cpm_muram_alloc(sizeof(struct qe_bd) * (bdring_len + | ||
| 372 | USB_BDRING_LEN_TX), QE_ALIGNMENT_OF_BD); | ||
| 373 | out_be16(&epparam->rbase, (u16)tmp_addr); | ||
| 374 | out_be16(&epparam->tbase, (u16)(tmp_addr + | ||
| 375 | (sizeof(struct qe_bd) * bdring_len))); | ||
| 376 | |||
| 377 | out_be16(&epparam->rbptr, in_be16(&epparam->rbase)); | ||
| 378 | out_be16(&epparam->tbptr, in_be16(&epparam->tbase)); | ||
| 379 | |||
| 380 | ep->rxbase = cpm_muram_addr(tmp_addr); | ||
| 381 | ep->txbase = cpm_muram_addr(tmp_addr + (sizeof(struct qe_bd) | ||
| 382 | * bdring_len)); | ||
| 383 | ep->n_rxbd = ep->rxbase; | ||
| 384 | ep->e_rxbd = ep->rxbase; | ||
| 385 | ep->n_txbd = ep->txbase; | ||
| 386 | ep->c_txbd = ep->txbase; | ||
| 387 | ep->data01 = 0; /* data0 */ | ||
| 388 | |||
| 389 | /* Init TX and RX bds */ | ||
| 390 | bd = ep->rxbase; | ||
| 391 | for (i = 0; i < bdring_len - 1; i++) { | ||
| 392 | out_be32(&bd->buf, 0); | ||
| 393 | out_be32((u32 __iomem *)bd, 0); | ||
| 394 | bd++; | ||
| 395 | } | ||
| 396 | out_be32(&bd->buf, 0); | ||
| 397 | out_be32((u32 __iomem *)bd, R_W); | ||
| 398 | |||
| 399 | bd = ep->txbase; | ||
| 400 | for (i = 0; i < USB_BDRING_LEN_TX - 1; i++) { | ||
| 401 | out_be32(&bd->buf, 0); | ||
| 402 | out_be32((u32 __iomem *)bd, 0); | ||
| 403 | bd++; | ||
| 404 | } | ||
| 405 | out_be32(&bd->buf, 0); | ||
| 406 | out_be32((u32 __iomem *)bd, T_W); | ||
| 407 | |||
| 408 | return 0; | ||
| 409 | } | ||
| 410 | |||
| 411 | static int qe_ep_rxbd_update(struct qe_ep *ep) | ||
| 412 | { | ||
| 413 | unsigned int size; | ||
| 414 | int i; | ||
| 415 | unsigned int tmp; | ||
| 416 | struct qe_bd __iomem *bd; | ||
| 417 | unsigned int bdring_len; | ||
| 418 | |||
| 419 | if (ep->rxbase == NULL) | ||
| 420 | return -EINVAL; | ||
| 421 | |||
| 422 | bd = ep->rxbase; | ||
| 423 | |||
| 424 | ep->rxframe = kmalloc(sizeof(*ep->rxframe), GFP_ATOMIC); | ||
| 425 | if (ep->rxframe == NULL) { | ||
| 426 | dev_err(ep->udc->dev, "malloc rxframe failed\n"); | ||
| 427 | return -ENOMEM; | ||
| 428 | } | ||
| 429 | |||
| 430 | qe_frame_init(ep->rxframe); | ||
| 431 | |||
| 432 | if (ep->dir == USB_DIR_OUT) | ||
| 433 | bdring_len = USB_BDRING_LEN_RX; | ||
| 434 | else | ||
| 435 | bdring_len = USB_BDRING_LEN; | ||
| 436 | |||
| 437 | size = (ep->ep.maxpacket + USB_CRC_SIZE + 2) * (bdring_len + 1); | ||
| 438 | ep->rxbuffer = kzalloc(size, GFP_ATOMIC); | ||
| 439 | if (ep->rxbuffer == NULL) { | ||
| 440 | dev_err(ep->udc->dev, "malloc rxbuffer failed,size=%d\n", | ||
| 441 | size); | ||
| 442 | kfree(ep->rxframe); | ||
| 443 | return -ENOMEM; | ||
| 444 | } | ||
| 445 | |||
| 446 | ep->rxbuf_d = virt_to_phys((void *)ep->rxbuffer); | ||
| 447 | if (ep->rxbuf_d == DMA_ADDR_INVALID) { | ||
| 448 | ep->rxbuf_d = dma_map_single(udc_controller->gadget.dev.parent, | ||
| 449 | ep->rxbuffer, | ||
| 450 | size, | ||
| 451 | DMA_FROM_DEVICE); | ||
| 452 | ep->rxbufmap = 1; | ||
| 453 | } else { | ||
| 454 | dma_sync_single_for_device(udc_controller->gadget.dev.parent, | ||
| 455 | ep->rxbuf_d, size, | ||
| 456 | DMA_FROM_DEVICE); | ||
| 457 | ep->rxbufmap = 0; | ||
| 458 | } | ||
| 459 | |||
| 460 | size = ep->ep.maxpacket + USB_CRC_SIZE + 2; | ||
| 461 | tmp = ep->rxbuf_d; | ||
| 462 | tmp = (u32)(((tmp >> 2) << 2) + 4); | ||
| 463 | |||
| 464 | for (i = 0; i < bdring_len - 1; i++) { | ||
| 465 | out_be32(&bd->buf, tmp); | ||
| 466 | out_be32((u32 __iomem *)bd, (R_E | R_I)); | ||
| 467 | tmp = tmp + size; | ||
| 468 | bd++; | ||
| 469 | } | ||
| 470 | out_be32(&bd->buf, tmp); | ||
| 471 | out_be32((u32 __iomem *)bd, (R_E | R_I | R_W)); | ||
| 472 | |||
| 473 | return 0; | ||
| 474 | } | ||
| 475 | |||
| 476 | static int qe_ep_register_init(struct qe_udc *udc, unsigned char pipe_num) | ||
| 477 | { | ||
| 478 | struct qe_ep *ep = &udc->eps[pipe_num]; | ||
| 479 | struct usb_ep_para __iomem *epparam; | ||
| 480 | u16 usep, logepnum; | ||
| 481 | u16 tmp; | ||
| 482 | u8 rtfcr = 0; | ||
| 483 | |||
| 484 | epparam = udc->ep_param[pipe_num]; | ||
| 485 | |||
| 486 | usep = 0; | ||
| 487 | logepnum = (ep->desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); | ||
| 488 | usep |= (logepnum << USB_EPNUM_SHIFT); | ||
| 489 | |||
| 490 | switch (ep->desc->bmAttributes & 0x03) { | ||
| 491 | case USB_ENDPOINT_XFER_BULK: | ||
| 492 | usep |= USB_TRANS_BULK; | ||
| 493 | break; | ||
| 494 | case USB_ENDPOINT_XFER_ISOC: | ||
| 495 | usep |= USB_TRANS_ISO; | ||
| 496 | break; | ||
| 497 | case USB_ENDPOINT_XFER_INT: | ||
| 498 | usep |= USB_TRANS_INT; | ||
| 499 | break; | ||
| 500 | default: | ||
| 501 | usep |= USB_TRANS_CTR; | ||
| 502 | break; | ||
| 503 | } | ||
| 504 | |||
| 505 | switch (ep->dir) { | ||
| 506 | case USB_DIR_OUT: | ||
| 507 | usep |= USB_THS_IGNORE_IN; | ||
| 508 | break; | ||
| 509 | case USB_DIR_IN: | ||
| 510 | usep |= USB_RHS_IGNORE_OUT; | ||
| 511 | break; | ||
| 512 | default: | ||
| 513 | break; | ||
| 514 | } | ||
| 515 | out_be16(&udc->usb_regs->usb_usep[pipe_num], usep); | ||
| 516 | |||
| 517 | rtfcr = 0x30; | ||
| 518 | out_8(&epparam->rbmr, rtfcr); | ||
| 519 | out_8(&epparam->tbmr, rtfcr); | ||
| 520 | |||
| 521 | tmp = (u16)(ep->ep.maxpacket + USB_CRC_SIZE); | ||
| 522 | /* MRBLR must be divisble by 4 */ | ||
| 523 | tmp = (u16)(((tmp >> 2) << 2) + 4); | ||
| 524 | out_be16(&epparam->mrblr, tmp); | ||
| 525 | |||
| 526 | return 0; | ||
| 527 | } | ||
| 528 | |||
| 529 | static int qe_ep_init(struct qe_udc *udc, | ||
| 530 | unsigned char pipe_num, | ||
| 531 | const struct usb_endpoint_descriptor *desc) | ||
| 532 | { | ||
| 533 | struct qe_ep *ep = &udc->eps[pipe_num]; | ||
| 534 | unsigned long flags; | ||
| 535 | int reval = 0; | ||
| 536 | u16 max = 0; | ||
| 537 | |||
| 538 | max = le16_to_cpu(desc->wMaxPacketSize); | ||
| 539 | |||
| 540 | /* check the max package size validate for this endpoint */ | ||
| 541 | /* Refer to USB2.0 spec table 9-13, | ||
| 542 | */ | ||
| 543 | if (pipe_num != 0) { | ||
| 544 | switch (desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) { | ||
| 545 | case USB_ENDPOINT_XFER_BULK: | ||
| 546 | if (strstr(ep->ep.name, "-iso") | ||
| 547 | || strstr(ep->ep.name, "-int")) | ||
| 548 | goto en_done; | ||
| 549 | switch (udc->gadget.speed) { | ||
| 550 | case USB_SPEED_HIGH: | ||
| 551 | if ((max == 128) || (max == 256) || (max == 512)) | ||
| 552 | break; | ||
| 553 | default: | ||
| 554 | switch (max) { | ||
| 555 | case 4: | ||
| 556 | case 8: | ||
| 557 | case 16: | ||
| 558 | case 32: | ||
| 559 | case 64: | ||
| 560 | break; | ||
| 561 | default: | ||
| 562 | case USB_SPEED_LOW: | ||
| 563 | goto en_done; | ||
| 564 | } | ||
| 565 | } | ||
| 566 | break; | ||
| 567 | case USB_ENDPOINT_XFER_INT: | ||
| 568 | if (strstr(ep->ep.name, "-iso")) /* bulk is ok */ | ||
| 569 | goto en_done; | ||
| 570 | switch (udc->gadget.speed) { | ||
| 571 | case USB_SPEED_HIGH: | ||
| 572 | if (max <= 1024) | ||
| 573 | break; | ||
| 574 | case USB_SPEED_FULL: | ||
| 575 | if (max <= 64) | ||
| 576 | break; | ||
| 577 | default: | ||
| 578 | if (max <= 8) | ||
| 579 | break; | ||
| 580 | goto en_done; | ||
| 581 | } | ||
| 582 | break; | ||
| 583 | case USB_ENDPOINT_XFER_ISOC: | ||
| 584 | if (strstr(ep->ep.name, "-bulk") | ||
| 585 | || strstr(ep->ep.name, "-int")) | ||
| 586 | goto en_done; | ||
| 587 | switch (udc->gadget.speed) { | ||
| 588 | case USB_SPEED_HIGH: | ||
| 589 | if (max <= 1024) | ||
| 590 | break; | ||
| 591 | case USB_SPEED_FULL: | ||
| 592 | if (max <= 1023) | ||
| 593 | break; | ||
| 594 | default: | ||
| 595 | goto en_done; | ||
| 596 | } | ||
| 597 | break; | ||
| 598 | case USB_ENDPOINT_XFER_CONTROL: | ||
| 599 | if (strstr(ep->ep.name, "-iso") | ||
| 600 | || strstr(ep->ep.name, "-int")) | ||
| 601 | goto en_done; | ||
| 602 | switch (udc->gadget.speed) { | ||
| 603 | case USB_SPEED_HIGH: | ||
| 604 | case USB_SPEED_FULL: | ||
| 605 | switch (max) { | ||
| 606 | case 1: | ||
| 607 | case 2: | ||
| 608 | case 4: | ||
| 609 | case 8: | ||
| 610 | case 16: | ||
| 611 | case 32: | ||
| 612 | case 64: | ||
| 613 | break; | ||
| 614 | default: | ||
| 615 | goto en_done; | ||
| 616 | } | ||
| 617 | case USB_SPEED_LOW: | ||
| 618 | switch (max) { | ||
| 619 | case 1: | ||
| 620 | case 2: | ||
| 621 | case 4: | ||
| 622 | case 8: | ||
| 623 | break; | ||
| 624 | default: | ||
| 625 | goto en_done; | ||
| 626 | } | ||
| 627 | default: | ||
| 628 | goto en_done; | ||
| 629 | } | ||
| 630 | break; | ||
| 631 | |||
| 632 | default: | ||
| 633 | goto en_done; | ||
| 634 | } | ||
| 635 | } /* if ep0*/ | ||
| 636 | |||
| 637 | spin_lock_irqsave(&udc->lock, flags); | ||
| 638 | |||
| 639 | /* initialize ep structure */ | ||
| 640 | ep->ep.maxpacket = max; | ||
| 641 | ep->tm = (u8)(desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK); | ||
| 642 | ep->desc = desc; | ||
| 643 | ep->stopped = 0; | ||
| 644 | ep->init = 1; | ||
| 645 | |||
| 646 | if (pipe_num == 0) { | ||
| 647 | ep->dir = USB_DIR_BOTH; | ||
| 648 | udc->ep0_dir = USB_DIR_OUT; | ||
| 649 | udc->ep0_state = WAIT_FOR_SETUP; | ||
| 650 | } else { | ||
| 651 | switch (desc->bEndpointAddress & USB_ENDPOINT_DIR_MASK) { | ||
| 652 | case USB_DIR_OUT: | ||
| 653 | ep->dir = USB_DIR_OUT; | ||
| 654 | break; | ||
| 655 | case USB_DIR_IN: | ||
| 656 | ep->dir = USB_DIR_IN; | ||
| 657 | default: | ||
| 658 | break; | ||
| 659 | } | ||
| 660 | } | ||
| 661 | |||
| 662 | /* hardware special operation */ | ||
| 663 | qe_ep_bd_init(udc, pipe_num); | ||
| 664 | if ((ep->tm == USBP_TM_CTL) || (ep->dir == USB_DIR_OUT)) { | ||
| 665 | reval = qe_ep_rxbd_update(ep); | ||
| 666 | if (reval) | ||
| 667 | goto en_done1; | ||
| 668 | } | ||
| 669 | |||
| 670 | if ((ep->tm == USBP_TM_CTL) || (ep->dir == USB_DIR_IN)) { | ||
| 671 | ep->txframe = kmalloc(sizeof(*ep->txframe), GFP_ATOMIC); | ||
| 672 | if (ep->txframe == NULL) { | ||
| 673 | dev_err(udc->dev, "malloc txframe failed\n"); | ||
| 674 | goto en_done2; | ||
| 675 | } | ||
| 676 | qe_frame_init(ep->txframe); | ||
| 677 | } | ||
| 678 | |||
| 679 | qe_ep_register_init(udc, pipe_num); | ||
| 680 | |||
| 681 | /* Now HW will be NAKing transfers to that EP, | ||
| 682 | * until a buffer is queued to it. */ | ||
| 683 | spin_unlock_irqrestore(&udc->lock, flags); | ||
| 684 | |||
| 685 | return 0; | ||
| 686 | en_done2: | ||
| 687 | kfree(ep->rxbuffer); | ||
| 688 | kfree(ep->rxframe); | ||
| 689 | en_done1: | ||
| 690 | spin_unlock_irqrestore(&udc->lock, flags); | ||
| 691 | en_done: | ||
| 692 | dev_dbg(udc->dev, "failed to initialize %s\n", ep->ep.name); | ||
| 693 | return -ENODEV; | ||
| 694 | } | ||
| 695 | |||
| 696 | static inline void qe_usb_enable(void) | ||
| 697 | { | ||
| 698 | setbits8(&udc_controller->usb_regs->usb_usmod, USB_MODE_EN); | ||
| 699 | } | ||
| 700 | |||
| 701 | static inline void qe_usb_disable(void) | ||
| 702 | { | ||
| 703 | clrbits8(&udc_controller->usb_regs->usb_usmod, USB_MODE_EN); | ||
| 704 | } | ||
| 705 | |||
| 706 | /*----------------------------------------------------------------------------* | ||
| 707 | * USB and EP basic manipulate function end * | ||
| 708 | *----------------------------------------------------------------------------*/ | ||
| 709 | |||
| 710 | |||
| 711 | /****************************************************************************** | ||
| 712 | UDC transmit and receive process | ||
| 713 | ******************************************************************************/ | ||
| 714 | static void recycle_one_rxbd(struct qe_ep *ep) | ||
| 715 | { | ||
| 716 | u32 bdstatus; | ||
| 717 | |||
| 718 | bdstatus = in_be32((u32 __iomem *)ep->e_rxbd); | ||
| 719 | bdstatus = R_I | R_E | (bdstatus & R_W); | ||
| 720 | out_be32((u32 __iomem *)ep->e_rxbd, bdstatus); | ||
| 721 | |||
| 722 | if (bdstatus & R_W) | ||
| 723 | ep->e_rxbd = ep->rxbase; | ||
| 724 | else | ||
| 725 | ep->e_rxbd++; | ||
| 726 | } | ||
| 727 | |||
| 728 | static void recycle_rxbds(struct qe_ep *ep, unsigned char stopatnext) | ||
| 729 | { | ||
| 730 | u32 bdstatus; | ||
| 731 | struct qe_bd __iomem *bd, *nextbd; | ||
| 732 | unsigned char stop = 0; | ||
| 733 | |||
| 734 | nextbd = ep->n_rxbd; | ||
| 735 | bd = ep->e_rxbd; | ||
| 736 | bdstatus = in_be32((u32 __iomem *)bd); | ||
| 737 | |||
| 738 | while (!(bdstatus & R_E) && !(bdstatus & BD_LENGTH_MASK) && !stop) { | ||
| 739 | bdstatus = R_E | R_I | (bdstatus & R_W); | ||
| 740 | out_be32((u32 __iomem *)bd, bdstatus); | ||
| 741 | |||
| 742 | if (bdstatus & R_W) | ||
| 743 | bd = ep->rxbase; | ||
| 744 | else | ||
| 745 | bd++; | ||
| 746 | |||
| 747 | bdstatus = in_be32((u32 __iomem *)bd); | ||
| 748 | if (stopatnext && (bd == nextbd)) | ||
| 749 | stop = 1; | ||
| 750 | } | ||
| 751 | |||
| 752 | ep->e_rxbd = bd; | ||
| 753 | } | ||
| 754 | |||
| 755 | static void ep_recycle_rxbds(struct qe_ep *ep) | ||
| 756 | { | ||
| 757 | struct qe_bd __iomem *bd = ep->n_rxbd; | ||
| 758 | u32 bdstatus; | ||
| 759 | u8 epnum = ep->epnum; | ||
| 760 | struct qe_udc *udc = ep->udc; | ||
| 761 | |||
| 762 | bdstatus = in_be32((u32 __iomem *)bd); | ||
| 763 | if (!(bdstatus & R_E) && !(bdstatus & BD_LENGTH_MASK)) { | ||
| 764 | bd = ep->rxbase + | ||
| 765 | ((in_be16(&udc->ep_param[epnum]->rbptr) - | ||
| 766 | in_be16(&udc->ep_param[epnum]->rbase)) | ||
| 767 | >> 3); | ||
| 768 | bdstatus = in_be32((u32 __iomem *)bd); | ||
| 769 | |||
| 770 | if (bdstatus & R_W) | ||
| 771 | bd = ep->rxbase; | ||
| 772 | else | ||
| 773 | bd++; | ||
| 774 | |||
| 775 | ep->e_rxbd = bd; | ||
| 776 | recycle_rxbds(ep, 0); | ||
| 777 | ep->e_rxbd = ep->n_rxbd; | ||
| 778 | } else | ||
| 779 | recycle_rxbds(ep, 1); | ||
| 780 | |||
| 781 | if (in_be16(&udc->usb_regs->usb_usber) & USB_E_BSY_MASK) | ||
| 782 | out_be16(&udc->usb_regs->usb_usber, USB_E_BSY_MASK); | ||
| 783 | |||
| 784 | if (ep->has_data <= 0 && (!list_empty(&ep->queue))) | ||
| 785 | qe_eprx_normal(ep); | ||
| 786 | |||
| 787 | ep->localnack = 0; | ||
| 788 | } | ||
| 789 | |||
| 790 | static void setup_received_handle(struct qe_udc *udc, | ||
| 791 | struct usb_ctrlrequest *setup); | ||
| 792 | static int qe_ep_rxframe_handle(struct qe_ep *ep); | ||
| 793 | static void ep0_req_complete(struct qe_udc *udc, struct qe_req *req); | ||
| 794 | /* when BD PID is setup, handle the packet */ | ||
| 795 | static int ep0_setup_handle(struct qe_udc *udc) | ||
| 796 | { | ||
| 797 | struct qe_ep *ep = &udc->eps[0]; | ||
| 798 | struct qe_frame *pframe; | ||
| 799 | unsigned int fsize; | ||
| 800 | u8 *cp; | ||
| 801 | |||
| 802 | pframe = ep->rxframe; | ||
| 803 | if ((frame_get_info(pframe) & PID_SETUP) | ||
| 804 | && (udc->ep0_state == WAIT_FOR_SETUP)) { | ||
| 805 | fsize = frame_get_length(pframe); | ||
| 806 | if (unlikely(fsize != 8)) | ||
| 807 | return -EINVAL; | ||
| 808 | cp = (u8 *)&udc->local_setup_buff; | ||
| 809 | memcpy(cp, pframe->data, fsize); | ||
| 810 | ep->data01 = 1; | ||
| 811 | |||
| 812 | /* handle the usb command base on the usb_ctrlrequest */ | ||
| 813 | setup_received_handle(udc, &udc->local_setup_buff); | ||
| 814 | return 0; | ||
| 815 | } | ||
| 816 | return -EINVAL; | ||
| 817 | } | ||
| 818 | |||
| 819 | static int qe_ep0_rx(struct qe_udc *udc) | ||
| 820 | { | ||
| 821 | struct qe_ep *ep = &udc->eps[0]; | ||
| 822 | struct qe_frame *pframe; | ||
| 823 | struct qe_bd __iomem *bd; | ||
| 824 | u32 bdstatus, length; | ||
| 825 | u32 vaddr; | ||
| 826 | |||
| 827 | pframe = ep->rxframe; | ||
| 828 | |||
| 829 | if (ep->dir == USB_DIR_IN) { | ||
| 830 | dev_err(udc->dev, "ep0 not a control endpoint\n"); | ||
| 831 | return -EINVAL; | ||
| 832 | } | ||
| 833 | |||
| 834 | bd = ep->n_rxbd; | ||
| 835 | bdstatus = in_be32((u32 __iomem *)bd); | ||
| 836 | length = bdstatus & BD_LENGTH_MASK; | ||
| 837 | |||
| 838 | while (!(bdstatus & R_E) && length) { | ||
| 839 | if ((bdstatus & R_F) && (bdstatus & R_L) | ||
| 840 | && !(bdstatus & R_ERROR)) { | ||
| 841 | if (length == USB_CRC_SIZE) { | ||
| 842 | udc->ep0_state = WAIT_FOR_SETUP; | ||
| 843 | dev_vdbg(udc->dev, | ||
| 844 | "receive a ZLP in status phase\n"); | ||
| 845 | } else { | ||
| 846 | qe_frame_clean(pframe); | ||
| 847 | vaddr = (u32)phys_to_virt(in_be32(&bd->buf)); | ||
| 848 | frame_set_data(pframe, (u8 *)vaddr); | ||
| 849 | frame_set_length(pframe, | ||
| 850 | (length - USB_CRC_SIZE)); | ||
| 851 | frame_set_status(pframe, FRAME_OK); | ||
| 852 | switch (bdstatus & R_PID) { | ||
| 853 | case R_PID_SETUP: | ||
| 854 | frame_set_info(pframe, PID_SETUP); | ||
| 855 | break; | ||
| 856 | case R_PID_DATA1: | ||
| 857 | frame_set_info(pframe, PID_DATA1); | ||
| 858 | break; | ||
| 859 | default: | ||
| 860 | frame_set_info(pframe, PID_DATA0); | ||
| 861 | break; | ||
| 862 | } | ||
| 863 | |||
| 864 | if ((bdstatus & R_PID) == R_PID_SETUP) | ||
| 865 | ep0_setup_handle(udc); | ||
| 866 | else | ||
| 867 | qe_ep_rxframe_handle(ep); | ||
| 868 | } | ||
| 869 | } else { | ||
| 870 | dev_err(udc->dev, "The receive frame with error!\n"); | ||
| 871 | } | ||
| 872 | |||
| 873 | /* note: don't clear the rxbd's buffer address */ | ||
| 874 | recycle_one_rxbd(ep); | ||
| 875 | |||
| 876 | /* Get next BD */ | ||
| 877 | if (bdstatus & R_W) | ||
| 878 | bd = ep->rxbase; | ||
| 879 | else | ||
| 880 | bd++; | ||
| 881 | |||
| 882 | bdstatus = in_be32((u32 __iomem *)bd); | ||
| 883 | length = bdstatus & BD_LENGTH_MASK; | ||
| 884 | |||
| 885 | } | ||
| 886 | |||
| 887 | ep->n_rxbd = bd; | ||
| 888 | |||
| 889 | return 0; | ||
| 890 | } | ||
| 891 | |||
| 892 | static int qe_ep_rxframe_handle(struct qe_ep *ep) | ||
| 893 | { | ||
| 894 | struct qe_frame *pframe; | ||
| 895 | u8 framepid = 0; | ||
| 896 | unsigned int fsize; | ||
| 897 | u8 *cp; | ||
| 898 | struct qe_req *req; | ||
| 899 | |||
| 900 | pframe = ep->rxframe; | ||
| 901 | |||
| 902 | if (frame_get_info(pframe) & PID_DATA1) | ||
| 903 | framepid = 0x1; | ||
| 904 | |||
| 905 | if (framepid != ep->data01) { | ||
| 906 | dev_err(ep->udc->dev, "the data01 error!\n"); | ||
| 907 | return -EIO; | ||
| 908 | } | ||
| 909 | |||
| 910 | fsize = frame_get_length(pframe); | ||
| 911 | if (list_empty(&ep->queue)) { | ||
| 912 | dev_err(ep->udc->dev, "the %s have no requeue!\n", ep->name); | ||
| 913 | } else { | ||
| 914 | req = list_entry(ep->queue.next, struct qe_req, queue); | ||
| 915 | |||
| 916 | cp = (u8 *)(req->req.buf) + req->req.actual; | ||
| 917 | if (cp) { | ||
| 918 | memcpy(cp, pframe->data, fsize); | ||
| 919 | req->req.actual += fsize; | ||
| 920 | if ((fsize < ep->ep.maxpacket) || | ||
| 921 | (req->req.actual >= req->req.length)) { | ||
| 922 | if (ep->epnum == 0) | ||
| 923 | ep0_req_complete(ep->udc, req); | ||
| 924 | else | ||
| 925 | done(ep, req, 0); | ||
| 926 | if (list_empty(&ep->queue) && ep->epnum != 0) | ||
| 927 | qe_eprx_nack(ep); | ||
| 928 | } | ||
| 929 | } | ||
| 930 | } | ||
| 931 | |||
| 932 | qe_ep_toggledata01(ep); | ||
| 933 | |||
| 934 | return 0; | ||
| 935 | } | ||
| 936 | |||
| 937 | static void ep_rx_tasklet(unsigned long data) | ||
| 938 | { | ||
| 939 | struct qe_udc *udc = (struct qe_udc *)data; | ||
| 940 | struct qe_ep *ep; | ||
| 941 | struct qe_frame *pframe; | ||
| 942 | struct qe_bd __iomem *bd; | ||
| 943 | unsigned long flags; | ||
| 944 | u32 bdstatus, length; | ||
| 945 | u32 vaddr, i; | ||
| 946 | |||
| 947 | spin_lock_irqsave(&udc->lock, flags); | ||
| 948 | |||
| 949 | for (i = 1; i < USB_MAX_ENDPOINTS; i++) { | ||
| 950 | ep = &udc->eps[i]; | ||
| 951 | |||
| 952 | if (ep->dir == USB_DIR_IN || ep->enable_tasklet == 0) { | ||
| 953 | dev_dbg(udc->dev, | ||
| 954 | "This is a transmit ep or disable tasklet!\n"); | ||
| 955 | continue; | ||
| 956 | } | ||
| 957 | |||
| 958 | pframe = ep->rxframe; | ||
| 959 | bd = ep->n_rxbd; | ||
| 960 | bdstatus = in_be32((u32 __iomem *)bd); | ||
| 961 | length = bdstatus & BD_LENGTH_MASK; | ||
| 962 | |||
| 963 | while (!(bdstatus & R_E) && length) { | ||
| 964 | if (list_empty(&ep->queue)) { | ||
| 965 | qe_eprx_nack(ep); | ||
| 966 | dev_dbg(udc->dev, | ||
| 967 | "The rxep have noreq %d\n", | ||
| 968 | ep->has_data); | ||
| 969 | break; | ||
| 970 | } | ||
| 971 | |||
| 972 | if ((bdstatus & R_F) && (bdstatus & R_L) | ||
| 973 | && !(bdstatus & R_ERROR)) { | ||
| 974 | qe_frame_clean(pframe); | ||
| 975 | vaddr = (u32)phys_to_virt(in_be32(&bd->buf)); | ||
| 976 | frame_set_data(pframe, (u8 *)vaddr); | ||
| 977 | frame_set_length(pframe, | ||
| 978 | (length - USB_CRC_SIZE)); | ||
| 979 | frame_set_status(pframe, FRAME_OK); | ||
| 980 | switch (bdstatus & R_PID) { | ||
| 981 | case R_PID_DATA1: | ||
| 982 | frame_set_info(pframe, PID_DATA1); | ||
| 983 | break; | ||
| 984 | case R_PID_SETUP: | ||
| 985 | frame_set_info(pframe, PID_SETUP); | ||
| 986 | break; | ||
| 987 | default: | ||
| 988 | frame_set_info(pframe, PID_DATA0); | ||
| 989 | break; | ||
| 990 | } | ||
| 991 | /* handle the rx frame */ | ||
| 992 | qe_ep_rxframe_handle(ep); | ||
| 993 | } else { | ||
| 994 | dev_err(udc->dev, | ||
| 995 | "error in received frame\n"); | ||
| 996 | } | ||
| 997 | /* note: don't clear the rxbd's buffer address */ | ||
| 998 | /*clear the length */ | ||
| 999 | out_be32((u32 __iomem *)bd, bdstatus & BD_STATUS_MASK); | ||
| 1000 | ep->has_data--; | ||
| 1001 | if (!(ep->localnack)) | ||
| 1002 | recycle_one_rxbd(ep); | ||
| 1003 | |||
| 1004 | /* Get next BD */ | ||
| 1005 | if (bdstatus & R_W) | ||
| 1006 | bd = ep->rxbase; | ||
| 1007 | else | ||
| 1008 | bd++; | ||
| 1009 | |||
| 1010 | bdstatus = in_be32((u32 __iomem *)bd); | ||
| 1011 | length = bdstatus & BD_LENGTH_MASK; | ||
| 1012 | } | ||
| 1013 | |||
| 1014 | ep->n_rxbd = bd; | ||
| 1015 | |||
| 1016 | if (ep->localnack) | ||
| 1017 | ep_recycle_rxbds(ep); | ||
| 1018 | |||
| 1019 | ep->enable_tasklet = 0; | ||
| 1020 | } /* for i=1 */ | ||
| 1021 | |||
| 1022 | spin_unlock_irqrestore(&udc->lock, flags); | ||
| 1023 | } | ||
| 1024 | |||
| 1025 | static int qe_ep_rx(struct qe_ep *ep) | ||
| 1026 | { | ||
| 1027 | struct qe_udc *udc; | ||
| 1028 | struct qe_frame *pframe; | ||
| 1029 | struct qe_bd __iomem *bd; | ||
| 1030 | u16 swoffs, ucoffs, emptybds; | ||
| 1031 | |||
| 1032 | udc = ep->udc; | ||
| 1033 | pframe = ep->rxframe; | ||
| 1034 | |||
| 1035 | if (ep->dir == USB_DIR_IN) { | ||
| 1036 | dev_err(udc->dev, "transmit ep in rx function\n"); | ||
| 1037 | return -EINVAL; | ||
| 1038 | } | ||
| 1039 | |||
| 1040 | bd = ep->n_rxbd; | ||
| 1041 | |||
| 1042 | swoffs = (u16)(bd - ep->rxbase); | ||
| 1043 | ucoffs = (u16)((in_be16(&udc->ep_param[ep->epnum]->rbptr) - | ||
| 1044 | in_be16(&udc->ep_param[ep->epnum]->rbase)) >> 3); | ||
| 1045 | if (swoffs < ucoffs) | ||
| 1046 | emptybds = USB_BDRING_LEN_RX - ucoffs + swoffs; | ||
| 1047 | else | ||
| 1048 | emptybds = swoffs - ucoffs; | ||
| 1049 | |||
| 1050 | if (emptybds < MIN_EMPTY_BDS) { | ||
| 1051 | qe_eprx_nack(ep); | ||
| 1052 | ep->localnack = 1; | ||
| 1053 | dev_vdbg(udc->dev, "%d empty bds, send NACK\n", emptybds); | ||
| 1054 | } | ||
| 1055 | ep->has_data = USB_BDRING_LEN_RX - emptybds; | ||
| 1056 | |||
| 1057 | if (list_empty(&ep->queue)) { | ||
| 1058 | qe_eprx_nack(ep); | ||
| 1059 | dev_vdbg(udc->dev, "The rxep have no req queued with %d BDs\n", | ||
| 1060 | ep->has_data); | ||
| 1061 | return 0; | ||
| 1062 | } | ||
| 1063 | |||
| 1064 | tasklet_schedule(&udc->rx_tasklet); | ||
| 1065 | ep->enable_tasklet = 1; | ||
| 1066 | |||
| 1067 | return 0; | ||
| 1068 | } | ||
| 1069 | |||
| 1070 | /* send data from a frame, no matter what tx_req */ | ||
| 1071 | static int qe_ep_tx(struct qe_ep *ep, struct qe_frame *frame) | ||
| 1072 | { | ||
| 1073 | struct qe_udc *udc = ep->udc; | ||
| 1074 | struct qe_bd __iomem *bd; | ||
| 1075 | u16 saveusbmr; | ||
| 1076 | u32 bdstatus, pidmask; | ||
| 1077 | u32 paddr; | ||
| 1078 | |||
| 1079 | if (ep->dir == USB_DIR_OUT) { | ||
| 1080 | dev_err(udc->dev, "receive ep passed to tx function\n"); | ||
| 1081 | return -EINVAL; | ||
| 1082 | } | ||
| 1083 | |||
| 1084 | /* Disable the Tx interrupt */ | ||
| 1085 | saveusbmr = in_be16(&udc->usb_regs->usb_usbmr); | ||
| 1086 | out_be16(&udc->usb_regs->usb_usbmr, | ||
| 1087 | saveusbmr & ~(USB_E_TXB_MASK | USB_E_TXE_MASK)); | ||
| 1088 | |||
| 1089 | bd = ep->n_txbd; | ||
| 1090 | bdstatus = in_be32((u32 __iomem *)bd); | ||
| 1091 | |||
| 1092 | if (!(bdstatus & (T_R | BD_LENGTH_MASK))) { | ||
| 1093 | if (frame_get_length(frame) == 0) { | ||
| 1094 | frame_set_data(frame, udc->nullbuf); | ||
| 1095 | frame_set_length(frame, 2); | ||
| 1096 | frame->info |= (ZLP | NO_CRC); | ||
| 1097 | dev_vdbg(udc->dev, "the frame size = 0\n"); | ||
| 1098 | } | ||
| 1099 | paddr = virt_to_phys((void *)frame->data); | ||
| 1100 | out_be32(&bd->buf, paddr); | ||
| 1101 | bdstatus = (bdstatus&T_W); | ||
| 1102 | if (!(frame_get_info(frame) & NO_CRC)) | ||
| 1103 | bdstatus |= T_R | T_I | T_L | T_TC | ||
| 1104 | | frame_get_length(frame); | ||
| 1105 | else | ||
| 1106 | bdstatus |= T_R | T_I | T_L | frame_get_length(frame); | ||
| 1107 | |||
| 1108 | /* if the packet is a ZLP in status phase */ | ||
| 1109 | if ((ep->epnum == 0) && (udc->ep0_state == DATA_STATE_NEED_ZLP)) | ||
| 1110 | ep->data01 = 0x1; | ||
| 1111 | |||
| 1112 | if (ep->data01) { | ||
| 1113 | pidmask = T_PID_DATA1; | ||
| 1114 | frame->info |= PID_DATA1; | ||
| 1115 | } else { | ||
| 1116 | pidmask = T_PID_DATA0; | ||
| 1117 | frame->info |= PID_DATA0; | ||
| 1118 | } | ||
| 1119 | bdstatus |= T_CNF; | ||
| 1120 | bdstatus |= pidmask; | ||
| 1121 | out_be32((u32 __iomem *)bd, bdstatus); | ||
| 1122 | qe_ep_filltxfifo(ep); | ||
| 1123 | |||
| 1124 | /* enable the TX interrupt */ | ||
| 1125 | out_be16(&udc->usb_regs->usb_usbmr, saveusbmr); | ||
| 1126 | |||
| 1127 | qe_ep_toggledata01(ep); | ||
| 1128 | if (bdstatus & T_W) | ||
| 1129 | ep->n_txbd = ep->txbase; | ||
| 1130 | else | ||
| 1131 | ep->n_txbd++; | ||
| 1132 | |||
| 1133 | return 0; | ||
| 1134 | } else { | ||
| 1135 | out_be16(&udc->usb_regs->usb_usbmr, saveusbmr); | ||
| 1136 | dev_vdbg(udc->dev, "The tx bd is not ready!\n"); | ||
| 1137 | return -EBUSY; | ||
| 1138 | } | ||
| 1139 | } | ||
| 1140 | |||
| 1141 | /* when a bd was transmitted, the function can | ||
| 1142 | * handle the tx_req, not include ep0 */ | ||
| 1143 | static int txcomplete(struct qe_ep *ep, unsigned char restart) | ||
| 1144 | { | ||
| 1145 | if (ep->tx_req != NULL) { | ||
| 1146 | if (!restart) { | ||
| 1147 | int asent = ep->last; | ||
| 1148 | ep->sent += asent; | ||
| 1149 | ep->last -= asent; | ||
| 1150 | } else { | ||
| 1151 | ep->last = 0; | ||
| 1152 | } | ||
| 1153 | |||
| 1154 | /* a request already were transmitted completely */ | ||
| 1155 | if ((ep->tx_req->req.length - ep->sent) <= 0) { | ||
| 1156 | ep->tx_req->req.actual = (unsigned int)ep->sent; | ||
| 1157 | done(ep, ep->tx_req, 0); | ||
| 1158 | ep->tx_req = NULL; | ||
| 1159 | ep->last = 0; | ||
| 1160 | ep->sent = 0; | ||
| 1161 | } | ||
| 1162 | } | ||
| 1163 | |||
| 1164 | /* we should gain a new tx_req fot this endpoint */ | ||
| 1165 | if (ep->tx_req == NULL) { | ||
| 1166 | if (!list_empty(&ep->queue)) { | ||
| 1167 | ep->tx_req = list_entry(ep->queue.next, struct qe_req, | ||
| 1168 | queue); | ||
| 1169 | ep->last = 0; | ||
| 1170 | ep->sent = 0; | ||
| 1171 | } | ||
| 1172 | } | ||
| 1173 | |||
| 1174 | return 0; | ||
| 1175 | } | ||
| 1176 | |||
| 1177 | /* give a frame and a tx_req, send some data */ | ||
| 1178 | static int qe_usb_senddata(struct qe_ep *ep, struct qe_frame *frame) | ||
| 1179 | { | ||
| 1180 | unsigned int size; | ||
| 1181 | u8 *buf; | ||
| 1182 | |||
| 1183 | qe_frame_clean(frame); | ||
| 1184 | size = min_t(u32, (ep->tx_req->req.length - ep->sent), | ||
| 1185 | ep->ep.maxpacket); | ||
| 1186 | buf = (u8 *)ep->tx_req->req.buf + ep->sent; | ||
| 1187 | if (buf && size) { | ||
| 1188 | ep->last = size; | ||
| 1189 | frame_set_data(frame, buf); | ||
| 1190 | frame_set_length(frame, size); | ||
| 1191 | frame_set_status(frame, FRAME_OK); | ||
| 1192 | frame_set_info(frame, 0); | ||
| 1193 | return qe_ep_tx(ep, frame); | ||
| 1194 | } | ||
| 1195 | return -EIO; | ||
| 1196 | } | ||
| 1197 | |||
| 1198 | /* give a frame struct,send a ZLP */ | ||
| 1199 | static int sendnulldata(struct qe_ep *ep, struct qe_frame *frame, uint infor) | ||
| 1200 | { | ||
| 1201 | struct qe_udc *udc = ep->udc; | ||
| 1202 | |||
| 1203 | if (frame == NULL) | ||
| 1204 | return -ENODEV; | ||
| 1205 | |||
| 1206 | qe_frame_clean(frame); | ||
| 1207 | frame_set_data(frame, (u8 *)udc->nullbuf); | ||
| 1208 | frame_set_length(frame, 2); | ||
| 1209 | frame_set_status(frame, FRAME_OK); | ||
| 1210 | frame_set_info(frame, (ZLP | NO_CRC | infor)); | ||
| 1211 | |||
| 1212 | return qe_ep_tx(ep, frame); | ||
| 1213 | } | ||
| 1214 | |||
| 1215 | static int frame_create_tx(struct qe_ep *ep, struct qe_frame *frame) | ||
| 1216 | { | ||
| 1217 | struct qe_req *req = ep->tx_req; | ||
| 1218 | int reval; | ||
| 1219 | |||
| 1220 | if (req == NULL) | ||
| 1221 | return -ENODEV; | ||
| 1222 | |||
| 1223 | if ((req->req.length - ep->sent) > 0) | ||
| 1224 | reval = qe_usb_senddata(ep, frame); | ||
| 1225 | else | ||
| 1226 | reval = sendnulldata(ep, frame, 0); | ||
| 1227 | |||
| 1228 | return reval; | ||
| 1229 | } | ||
| 1230 | |||
| 1231 | /* if direction is DIR_IN, the status is Device->Host | ||
| 1232 | * if direction is DIR_OUT, the status transaction is Device<-Host | ||
| 1233 | * in status phase, udc create a request and gain status */ | ||
| 1234 | static int ep0_prime_status(struct qe_udc *udc, int direction) | ||
| 1235 | { | ||
| 1236 | |||
| 1237 | struct qe_ep *ep = &udc->eps[0]; | ||
| 1238 | |||
| 1239 | if (direction == USB_DIR_IN) { | ||
| 1240 | udc->ep0_state = DATA_STATE_NEED_ZLP; | ||
| 1241 | udc->ep0_dir = USB_DIR_IN; | ||
| 1242 | sendnulldata(ep, ep->txframe, SETUP_STATUS | NO_REQ); | ||
| 1243 | } else { | ||
| 1244 | udc->ep0_dir = USB_DIR_OUT; | ||
| 1245 | udc->ep0_state = WAIT_FOR_OUT_STATUS; | ||
| 1246 | } | ||
| 1247 | |||
| 1248 | return 0; | ||
| 1249 | } | ||
| 1250 | |||
| 1251 | /* a request complete in ep0, whether gadget request or udc request */ | ||
| 1252 | static void ep0_req_complete(struct qe_udc *udc, struct qe_req *req) | ||
| 1253 | { | ||
| 1254 | struct qe_ep *ep = &udc->eps[0]; | ||
| 1255 | /* because usb and ep's status already been set in ch9setaddress() */ | ||
| 1256 | |||
| 1257 | switch (udc->ep0_state) { | ||
| 1258 | case DATA_STATE_XMIT: | ||
| 1259 | done(ep, req, 0); | ||
| 1260 | /* receive status phase */ | ||
| 1261 | if (ep0_prime_status(udc, USB_DIR_OUT)) | ||
| 1262 | qe_ep0_stall(udc); | ||
| 1263 | break; | ||
| 1264 | |||
| 1265 | case DATA_STATE_NEED_ZLP: | ||
| 1266 | done(ep, req, 0); | ||
| 1267 | udc->ep0_state = WAIT_FOR_SETUP; | ||
| 1268 | break; | ||
| 1269 | |||
| 1270 | case DATA_STATE_RECV: | ||
| 1271 | done(ep, req, 0); | ||
| 1272 | /* send status phase */ | ||
| 1273 | if (ep0_prime_status(udc, USB_DIR_IN)) | ||
| 1274 | qe_ep0_stall(udc); | ||
| 1275 | break; | ||
| 1276 | |||
| 1277 | case WAIT_FOR_OUT_STATUS: | ||
| 1278 | done(ep, req, 0); | ||
| 1279 | udc->ep0_state = WAIT_FOR_SETUP; | ||
| 1280 | break; | ||
| 1281 | |||
| 1282 | case WAIT_FOR_SETUP: | ||
| 1283 | dev_vdbg(udc->dev, "Unexpected interrupt\n"); | ||
| 1284 | break; | ||
| 1285 | |||
| 1286 | default: | ||
| 1287 | qe_ep0_stall(udc); | ||
| 1288 | break; | ||
| 1289 | } | ||
| 1290 | } | ||
| 1291 | |||
| 1292 | static int ep0_txcomplete(struct qe_ep *ep, unsigned char restart) | ||
| 1293 | { | ||
| 1294 | struct qe_req *tx_req = NULL; | ||
| 1295 | struct qe_frame *frame = ep->txframe; | ||
| 1296 | |||
| 1297 | if ((frame_get_info(frame) & (ZLP | NO_REQ)) == (ZLP | NO_REQ)) { | ||
| 1298 | if (!restart) | ||
| 1299 | ep->udc->ep0_state = WAIT_FOR_SETUP; | ||
| 1300 | else | ||
| 1301 | sendnulldata(ep, ep->txframe, SETUP_STATUS | NO_REQ); | ||
| 1302 | return 0; | ||
| 1303 | } | ||
| 1304 | |||
| 1305 | tx_req = ep->tx_req; | ||
| 1306 | if (tx_req != NULL) { | ||
| 1307 | if (!restart) { | ||
| 1308 | int asent = ep->last; | ||
| 1309 | ep->sent += asent; | ||
| 1310 | ep->last -= asent; | ||
| 1311 | } else { | ||
| 1312 | ep->last = 0; | ||
| 1313 | } | ||
| 1314 | |||
| 1315 | /* a request already were transmitted completely */ | ||
| 1316 | if ((ep->tx_req->req.length - ep->sent) <= 0) { | ||
| 1317 | ep->tx_req->req.actual = (unsigned int)ep->sent; | ||
| 1318 | ep0_req_complete(ep->udc, ep->tx_req); | ||
| 1319 | ep->tx_req = NULL; | ||
| 1320 | ep->last = 0; | ||
| 1321 | ep->sent = 0; | ||
| 1322 | } | ||
| 1323 | } else { | ||
| 1324 | dev_vdbg(ep->udc->dev, "the ep0_controller have no req\n"); | ||
| 1325 | } | ||
| 1326 | |||
| 1327 | return 0; | ||
| 1328 | } | ||
| 1329 | |||
| 1330 | static int ep0_txframe_handle(struct qe_ep *ep) | ||
| 1331 | { | ||
| 1332 | /* if have error, transmit again */ | ||
| 1333 | if (frame_get_status(ep->txframe) & FRAME_ERROR) { | ||
| 1334 | qe_ep_flushtxfifo(ep); | ||
| 1335 | dev_vdbg(ep->udc->dev, "The EP0 transmit data have error!\n"); | ||
| 1336 | if (frame_get_info(ep->txframe) & PID_DATA0) | ||
| 1337 | ep->data01 = 0; | ||
| 1338 | else | ||
| 1339 | ep->data01 = 1; | ||
| 1340 | |||
| 1341 | ep0_txcomplete(ep, 1); | ||
| 1342 | } else | ||
| 1343 | ep0_txcomplete(ep, 0); | ||
| 1344 | |||
| 1345 | frame_create_tx(ep, ep->txframe); | ||
| 1346 | return 0; | ||
| 1347 | } | ||
| 1348 | |||
| 1349 | static int qe_ep0_txconf(struct qe_ep *ep) | ||
| 1350 | { | ||
| 1351 | struct qe_bd __iomem *bd; | ||
| 1352 | struct qe_frame *pframe; | ||
| 1353 | u32 bdstatus; | ||
| 1354 | |||
| 1355 | bd = ep->c_txbd; | ||
| 1356 | bdstatus = in_be32((u32 __iomem *)bd); | ||
| 1357 | while (!(bdstatus & T_R) && (bdstatus & ~T_W)) { | ||
| 1358 | pframe = ep->txframe; | ||
| 1359 | |||
| 1360 | /* clear and recycle the BD */ | ||
| 1361 | out_be32((u32 __iomem *)bd, bdstatus & T_W); | ||
| 1362 | out_be32(&bd->buf, 0); | ||
| 1363 | if (bdstatus & T_W) | ||
| 1364 | ep->c_txbd = ep->txbase; | ||
| 1365 | else | ||
| 1366 | ep->c_txbd++; | ||
| 1367 | |||
| 1368 | if (ep->c_txbd == ep->n_txbd) { | ||
| 1369 | if (bdstatus & DEVICE_T_ERROR) { | ||
| 1370 | frame_set_status(pframe, FRAME_ERROR); | ||
| 1371 | if (bdstatus & T_TO) | ||
| 1372 | pframe->status |= TX_ER_TIMEOUT; | ||
| 1373 | if (bdstatus & T_UN) | ||
| 1374 | pframe->status |= TX_ER_UNDERUN; | ||
| 1375 | } | ||
| 1376 | ep0_txframe_handle(ep); | ||
| 1377 | } | ||
| 1378 | |||
| 1379 | bd = ep->c_txbd; | ||
| 1380 | bdstatus = in_be32((u32 __iomem *)bd); | ||
| 1381 | } | ||
| 1382 | |||
| 1383 | return 0; | ||
| 1384 | } | ||
| 1385 | |||
| 1386 | static int ep_txframe_handle(struct qe_ep *ep) | ||
| 1387 | { | ||
| 1388 | if (frame_get_status(ep->txframe) & FRAME_ERROR) { | ||
| 1389 | qe_ep_flushtxfifo(ep); | ||
| 1390 | dev_vdbg(ep->udc->dev, "The EP0 transmit data have error!\n"); | ||
| 1391 | if (frame_get_info(ep->txframe) & PID_DATA0) | ||
| 1392 | ep->data01 = 0; | ||
| 1393 | else | ||
| 1394 | ep->data01 = 1; | ||
| 1395 | |||
| 1396 | txcomplete(ep, 1); | ||
| 1397 | } else | ||
| 1398 | txcomplete(ep, 0); | ||
| 1399 | |||
| 1400 | frame_create_tx(ep, ep->txframe); /* send the data */ | ||
| 1401 | return 0; | ||
| 1402 | } | ||
| 1403 | |||
| 1404 | /* confirm the already trainsmited bd */ | ||
| 1405 | static int qe_ep_txconf(struct qe_ep *ep) | ||
| 1406 | { | ||
| 1407 | struct qe_bd __iomem *bd; | ||
| 1408 | struct qe_frame *pframe = NULL; | ||
| 1409 | u32 bdstatus; | ||
| 1410 | unsigned char breakonrxinterrupt = 0; | ||
| 1411 | |||
| 1412 | bd = ep->c_txbd; | ||
| 1413 | bdstatus = in_be32((u32 __iomem *)bd); | ||
| 1414 | while (!(bdstatus & T_R) && (bdstatus & ~T_W)) { | ||
| 1415 | pframe = ep->txframe; | ||
| 1416 | if (bdstatus & DEVICE_T_ERROR) { | ||
| 1417 | frame_set_status(pframe, FRAME_ERROR); | ||
| 1418 | if (bdstatus & T_TO) | ||
| 1419 | pframe->status |= TX_ER_TIMEOUT; | ||
| 1420 | if (bdstatus & T_UN) | ||
| 1421 | pframe->status |= TX_ER_UNDERUN; | ||
| 1422 | } | ||
| 1423 | |||
| 1424 | /* clear and recycle the BD */ | ||
| 1425 | out_be32((u32 __iomem *)bd, bdstatus & T_W); | ||
| 1426 | out_be32(&bd->buf, 0); | ||
| 1427 | if (bdstatus & T_W) | ||
| 1428 | ep->c_txbd = ep->txbase; | ||
| 1429 | else | ||
| 1430 | ep->c_txbd++; | ||
| 1431 | |||
| 1432 | /* handle the tx frame */ | ||
| 1433 | ep_txframe_handle(ep); | ||
| 1434 | bd = ep->c_txbd; | ||
| 1435 | bdstatus = in_be32((u32 __iomem *)bd); | ||
| 1436 | } | ||
| 1437 | if (breakonrxinterrupt) | ||
| 1438 | return -EIO; | ||
| 1439 | else | ||
| 1440 | return 0; | ||
| 1441 | } | ||
| 1442 | |||
| 1443 | /* Add a request in queue, and try to transmit a packet */ | ||
| 1444 | static int ep_req_send(struct qe_ep *ep, struct qe_req *req) | ||
| 1445 | { | ||
| 1446 | int reval = 0; | ||
| 1447 | |||
| 1448 | if (ep->tx_req == NULL) { | ||
| 1449 | ep->sent = 0; | ||
| 1450 | ep->last = 0; | ||
| 1451 | txcomplete(ep, 0); /* can gain a new tx_req */ | ||
| 1452 | reval = frame_create_tx(ep, ep->txframe); | ||
| 1453 | } | ||
| 1454 | return reval; | ||
| 1455 | } | ||
| 1456 | |||
| 1457 | /* Maybe this is a good ideal */ | ||
| 1458 | static int ep_req_rx(struct qe_ep *ep, struct qe_req *req) | ||
| 1459 | { | ||
| 1460 | struct qe_udc *udc = ep->udc; | ||
| 1461 | struct qe_frame *pframe = NULL; | ||
| 1462 | struct qe_bd __iomem *bd; | ||
| 1463 | u32 bdstatus, length; | ||
| 1464 | u32 vaddr, fsize; | ||
| 1465 | u8 *cp; | ||
| 1466 | u8 finish_req = 0; | ||
| 1467 | u8 framepid; | ||
| 1468 | |||
| 1469 | if (list_empty(&ep->queue)) { | ||
| 1470 | dev_vdbg(udc->dev, "the req already finish!\n"); | ||
| 1471 | return 0; | ||
| 1472 | } | ||
| 1473 | pframe = ep->rxframe; | ||
| 1474 | |||
| 1475 | bd = ep->n_rxbd; | ||
| 1476 | bdstatus = in_be32((u32 __iomem *)bd); | ||
| 1477 | length = bdstatus & BD_LENGTH_MASK; | ||
| 1478 | |||
| 1479 | while (!(bdstatus & R_E) && length) { | ||
| 1480 | if (finish_req) | ||
| 1481 | break; | ||
| 1482 | if ((bdstatus & R_F) && (bdstatus & R_L) | ||
| 1483 | && !(bdstatus & R_ERROR)) { | ||
| 1484 | qe_frame_clean(pframe); | ||
| 1485 | vaddr = (u32)phys_to_virt(in_be32(&bd->buf)); | ||
| 1486 | frame_set_data(pframe, (u8 *)vaddr); | ||
| 1487 | frame_set_length(pframe, (length - USB_CRC_SIZE)); | ||
| 1488 | frame_set_status(pframe, FRAME_OK); | ||
| 1489 | switch (bdstatus & R_PID) { | ||
| 1490 | case R_PID_DATA1: | ||
| 1491 | frame_set_info(pframe, PID_DATA1); break; | ||
| 1492 | default: | ||
| 1493 | frame_set_info(pframe, PID_DATA0); break; | ||
| 1494 | } | ||
| 1495 | /* handle the rx frame */ | ||
| 1496 | |||
| 1497 | if (frame_get_info(pframe) & PID_DATA1) | ||
| 1498 | framepid = 0x1; | ||
| 1499 | else | ||
| 1500 | framepid = 0; | ||
| 1501 | |||
| 1502 | if (framepid != ep->data01) { | ||
| 1503 | dev_vdbg(udc->dev, "the data01 error!\n"); | ||
| 1504 | } else { | ||
| 1505 | fsize = frame_get_length(pframe); | ||
| 1506 | |||
| 1507 | cp = (u8 *)(req->req.buf) + req->req.actual; | ||
| 1508 | if (cp) { | ||
| 1509 | memcpy(cp, pframe->data, fsize); | ||
| 1510 | req->req.actual += fsize; | ||
| 1511 | if ((fsize < ep->ep.maxpacket) | ||
| 1512 | || (req->req.actual >= | ||
| 1513 | req->req.length)) { | ||
| 1514 | finish_req = 1; | ||
| 1515 | done(ep, req, 0); | ||
| 1516 | if (list_empty(&ep->queue)) | ||
| 1517 | qe_eprx_nack(ep); | ||
| 1518 | } | ||
| 1519 | } | ||
| 1520 | qe_ep_toggledata01(ep); | ||
| 1521 | } | ||
| 1522 | } else { | ||
| 1523 | dev_err(udc->dev, "The receive frame with error!\n"); | ||
| 1524 | } | ||
| 1525 | |||
| 1526 | /* note: don't clear the rxbd's buffer address * | ||
| 1527 | * only Clear the length */ | ||
| 1528 | out_be32((u32 __iomem *)bd, (bdstatus & BD_STATUS_MASK)); | ||
| 1529 | ep->has_data--; | ||
| 1530 | |||
| 1531 | /* Get next BD */ | ||
| 1532 | if (bdstatus & R_W) | ||
| 1533 | bd = ep->rxbase; | ||
| 1534 | else | ||
| 1535 | bd++; | ||
| 1536 | |||
| 1537 | bdstatus = in_be32((u32 __iomem *)bd); | ||
| 1538 | length = bdstatus & BD_LENGTH_MASK; | ||
| 1539 | } | ||
| 1540 | |||
| 1541 | ep->n_rxbd = bd; | ||
| 1542 | ep_recycle_rxbds(ep); | ||
| 1543 | |||
| 1544 | return 0; | ||
| 1545 | } | ||
| 1546 | |||
| 1547 | /* only add the request in queue */ | ||
| 1548 | static int ep_req_receive(struct qe_ep *ep, struct qe_req *req) | ||
| 1549 | { | ||
| 1550 | if (ep->state == EP_STATE_NACK) { | ||
| 1551 | if (ep->has_data <= 0) { | ||
| 1552 | /* Enable rx and unmask rx interrupt */ | ||
| 1553 | qe_eprx_normal(ep); | ||
| 1554 | } else { | ||
| 1555 | /* Copy the exist BD data */ | ||
| 1556 | ep_req_rx(ep, req); | ||
| 1557 | } | ||
| 1558 | } | ||
| 1559 | |||
| 1560 | return 0; | ||
| 1561 | } | ||
| 1562 | |||
| 1563 | /******************************************************************** | ||
| 1564 | Internal Used Function End | ||
| 1565 | ********************************************************************/ | ||
| 1566 | |||
| 1567 | /*----------------------------------------------------------------------- | ||
| 1568 | Endpoint Management Functions For Gadget | ||
| 1569 | -----------------------------------------------------------------------*/ | ||
| 1570 | static int qe_ep_enable(struct usb_ep *_ep, | ||
| 1571 | const struct usb_endpoint_descriptor *desc) | ||
| 1572 | { | ||
| 1573 | struct qe_udc *udc; | ||
| 1574 | struct qe_ep *ep; | ||
| 1575 | int retval = 0; | ||
| 1576 | unsigned char epnum; | ||
| 1577 | |||
| 1578 | ep = container_of(_ep, struct qe_ep, ep); | ||
| 1579 | |||
| 1580 | /* catch various bogus parameters */ | ||
| 1581 | if (!_ep || !desc || ep->desc || _ep->name == ep_name[0] || | ||
| 1582 | (desc->bDescriptorType != USB_DT_ENDPOINT)) | ||
| 1583 | return -EINVAL; | ||
| 1584 | |||
| 1585 | udc = ep->udc; | ||
| 1586 | if (!udc->driver || (udc->gadget.speed == USB_SPEED_UNKNOWN)) | ||
| 1587 | return -ESHUTDOWN; | ||
| 1588 | |||
| 1589 | epnum = (u8)desc->bEndpointAddress & 0xF; | ||
| 1590 | |||
| 1591 | retval = qe_ep_init(udc, epnum, desc); | ||
| 1592 | if (retval != 0) { | ||
| 1593 | cpm_muram_free(cpm_muram_offset(ep->rxbase)); | ||
| 1594 | dev_dbg(udc->dev, "enable ep%d failed\n", ep->epnum); | ||
| 1595 | return -EINVAL; | ||
| 1596 | } | ||
| 1597 | dev_dbg(udc->dev, "enable ep%d successful\n", ep->epnum); | ||
| 1598 | return 0; | ||
| 1599 | } | ||
| 1600 | |||
| 1601 | static int qe_ep_disable(struct usb_ep *_ep) | ||
| 1602 | { | ||
| 1603 | struct qe_udc *udc; | ||
| 1604 | struct qe_ep *ep; | ||
| 1605 | unsigned long flags; | ||
| 1606 | unsigned int size; | ||
| 1607 | |||
| 1608 | ep = container_of(_ep, struct qe_ep, ep); | ||
| 1609 | udc = ep->udc; | ||
| 1610 | |||
| 1611 | if (!_ep || !ep->desc) { | ||
| 1612 | dev_dbg(udc->dev, "%s not enabled\n", _ep ? ep->ep.name : NULL); | ||
| 1613 | return -EINVAL; | ||
| 1614 | } | ||
| 1615 | |||
| 1616 | spin_lock_irqsave(&udc->lock, flags); | ||
| 1617 | /* Nuke all pending requests (does flush) */ | ||
| 1618 | nuke(ep, -ESHUTDOWN); | ||
| 1619 | ep->desc = NULL; | ||
| 1620 | ep->stopped = 1; | ||
| 1621 | spin_unlock_irqrestore(&udc->lock, flags); | ||
| 1622 | |||
| 1623 | cpm_muram_free(cpm_muram_offset(ep->rxbase)); | ||
| 1624 | |||
| 1625 | if (ep->dir == USB_DIR_OUT) | ||
| 1626 | size = (ep->ep.maxpacket + USB_CRC_SIZE + 2) * | ||
| 1627 | (USB_BDRING_LEN_RX + 1); | ||
| 1628 | else | ||
| 1629 | size = (ep->ep.maxpacket + USB_CRC_SIZE + 2) * | ||
| 1630 | (USB_BDRING_LEN + 1); | ||
| 1631 | |||
| 1632 | if (ep->dir != USB_DIR_IN) { | ||
| 1633 | kfree(ep->rxframe); | ||
| 1634 | if (ep->rxbufmap) { | ||
| 1635 | dma_unmap_single(udc_controller->gadget.dev.parent, | ||
| 1636 | ep->rxbuf_d, size, | ||
| 1637 | DMA_FROM_DEVICE); | ||
| 1638 | ep->rxbuf_d = DMA_ADDR_INVALID; | ||
| 1639 | } else { | ||
| 1640 | dma_sync_single_for_cpu( | ||
| 1641 | udc_controller->gadget.dev.parent, | ||
| 1642 | ep->rxbuf_d, size, | ||
| 1643 | DMA_FROM_DEVICE); | ||
| 1644 | } | ||
| 1645 | kfree(ep->rxbuffer); | ||
| 1646 | } | ||
| 1647 | |||
| 1648 | if (ep->dir != USB_DIR_OUT) | ||
| 1649 | kfree(ep->txframe); | ||
| 1650 | |||
| 1651 | dev_dbg(udc->dev, "disabled %s OK\n", _ep->name); | ||
| 1652 | return 0; | ||
| 1653 | } | ||
| 1654 | |||
| 1655 | static struct usb_request *qe_alloc_request(struct usb_ep *_ep, gfp_t gfp_flags) | ||
| 1656 | { | ||
| 1657 | struct qe_req *req; | ||
| 1658 | |||
| 1659 | req = kzalloc(sizeof(*req), gfp_flags); | ||
| 1660 | if (!req) | ||
| 1661 | return NULL; | ||
| 1662 | |||
| 1663 | req->req.dma = DMA_ADDR_INVALID; | ||
| 1664 | |||
| 1665 | INIT_LIST_HEAD(&req->queue); | ||
| 1666 | |||
| 1667 | return &req->req; | ||
| 1668 | } | ||
| 1669 | |||
| 1670 | static void qe_free_request(struct usb_ep *_ep, struct usb_request *_req) | ||
| 1671 | { | ||
| 1672 | struct qe_req *req; | ||
| 1673 | |||
| 1674 | req = container_of(_req, struct qe_req, req); | ||
| 1675 | |||
| 1676 | if (_req) | ||
| 1677 | kfree(req); | ||
| 1678 | } | ||
| 1679 | |||
| 1680 | /* queues (submits) an I/O request to an endpoint */ | ||
| 1681 | static int qe_ep_queue(struct usb_ep *_ep, struct usb_request *_req, | ||
| 1682 | gfp_t gfp_flags) | ||
| 1683 | { | ||
| 1684 | struct qe_ep *ep = container_of(_ep, struct qe_ep, ep); | ||
| 1685 | struct qe_req *req = container_of(_req, struct qe_req, req); | ||
| 1686 | struct qe_udc *udc; | ||
| 1687 | unsigned long flags; | ||
| 1688 | int reval; | ||
| 1689 | |||
| 1690 | udc = ep->udc; | ||
| 1691 | /* catch various bogus parameters */ | ||
| 1692 | if (!_req || !req->req.complete || !req->req.buf | ||
| 1693 | || !list_empty(&req->queue)) { | ||
| 1694 | dev_dbg(udc->dev, "bad params\n"); | ||
| 1695 | return -EINVAL; | ||
| 1696 | } | ||
| 1697 | if (!_ep || (!ep->desc && ep_index(ep))) { | ||
| 1698 | dev_dbg(udc->dev, "bad ep\n"); | ||
| 1699 | return -EINVAL; | ||
| 1700 | } | ||
| 1701 | |||
| 1702 | if (!udc->driver || udc->gadget.speed == USB_SPEED_UNKNOWN) | ||
| 1703 | return -ESHUTDOWN; | ||
| 1704 | |||
| 1705 | req->ep = ep; | ||
| 1706 | |||
| 1707 | /* map virtual address to hardware */ | ||
| 1708 | if (req->req.dma == DMA_ADDR_INVALID) { | ||
| 1709 | req->req.dma = dma_map_single(ep->udc->gadget.dev.parent, | ||
| 1710 | req->req.buf, | ||
| 1711 | req->req.length, | ||
| 1712 | ep_is_in(ep) | ||
| 1713 | ? DMA_TO_DEVICE : | ||
| 1714 | DMA_FROM_DEVICE); | ||
| 1715 | req->mapped = 1; | ||
| 1716 | } else { | ||
| 1717 | dma_sync_single_for_device(ep->udc->gadget.dev.parent, | ||
| 1718 | req->req.dma, req->req.length, | ||
| 1719 | ep_is_in(ep) | ||
| 1720 | ? DMA_TO_DEVICE : | ||
| 1721 | DMA_FROM_DEVICE); | ||
| 1722 | req->mapped = 0; | ||
| 1723 | } | ||
| 1724 | |||
| 1725 | req->req.status = -EINPROGRESS; | ||
| 1726 | req->req.actual = 0; | ||
| 1727 | |||
| 1728 | list_add_tail(&req->queue, &ep->queue); | ||
| 1729 | dev_vdbg(udc->dev, "gadget have request in %s! %d\n", | ||
| 1730 | ep->name, req->req.length); | ||
| 1731 | spin_lock_irqsave(&udc->lock, flags); | ||
| 1732 | /* push the request to device */ | ||
| 1733 | if (ep_is_in(ep)) | ||
| 1734 | reval = ep_req_send(ep, req); | ||
| 1735 | |||
| 1736 | /* EP0 */ | ||
| 1737 | if (ep_index(ep) == 0 && req->req.length > 0) { | ||
| 1738 | if (ep_is_in(ep)) | ||
| 1739 | udc->ep0_state = DATA_STATE_XMIT; | ||
| 1740 | else | ||
| 1741 | udc->ep0_state = DATA_STATE_RECV; | ||
| 1742 | } | ||
| 1743 | |||
| 1744 | if (ep->dir == USB_DIR_OUT) | ||
| 1745 | reval = ep_req_receive(ep, req); | ||
| 1746 | |||
| 1747 | spin_unlock_irqrestore(&udc->lock, flags); | ||
| 1748 | |||
| 1749 | return 0; | ||
| 1750 | } | ||
| 1751 | |||
| 1752 | /* dequeues (cancels, unlinks) an I/O request from an endpoint */ | ||
| 1753 | static int qe_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req) | ||
| 1754 | { | ||
| 1755 | struct qe_ep *ep = container_of(_ep, struct qe_ep, ep); | ||
| 1756 | struct qe_req *req; | ||
| 1757 | unsigned long flags; | ||
| 1758 | |||
| 1759 | if (!_ep || !_req) | ||
| 1760 | return -EINVAL; | ||
| 1761 | |||
| 1762 | spin_lock_irqsave(&ep->udc->lock, flags); | ||
| 1763 | |||
| 1764 | /* make sure it's actually queued on this endpoint */ | ||
| 1765 | list_for_each_entry(req, &ep->queue, queue) { | ||
| 1766 | if (&req->req == _req) | ||
| 1767 | break; | ||
| 1768 | } | ||
| 1769 | |||
| 1770 | if (&req->req != _req) { | ||
| 1771 | spin_unlock_irqrestore(&ep->udc->lock, flags); | ||
| 1772 | return -EINVAL; | ||
| 1773 | } | ||
| 1774 | |||
| 1775 | done(ep, req, -ECONNRESET); | ||
| 1776 | |||
| 1777 | spin_unlock_irqrestore(&ep->udc->lock, flags); | ||
| 1778 | return 0; | ||
| 1779 | } | ||
| 1780 | |||
| 1781 | /*----------------------------------------------------------------- | ||
| 1782 | * modify the endpoint halt feature | ||
| 1783 | * @ep: the non-isochronous endpoint being stalled | ||
| 1784 | * @value: 1--set halt 0--clear halt | ||
| 1785 | * Returns zero, or a negative error code. | ||
| 1786 | *----------------------------------------------------------------*/ | ||
| 1787 | static int qe_ep_set_halt(struct usb_ep *_ep, int value) | ||
| 1788 | { | ||
| 1789 | struct qe_ep *ep; | ||
| 1790 | unsigned long flags; | ||
| 1791 | int status = -EOPNOTSUPP; | ||
| 1792 | struct qe_udc *udc; | ||
| 1793 | |||
| 1794 | ep = container_of(_ep, struct qe_ep, ep); | ||
| 1795 | if (!_ep || !ep->desc) { | ||
| 1796 | status = -EINVAL; | ||
| 1797 | goto out; | ||
| 1798 | } | ||
| 1799 | |||
| 1800 | udc = ep->udc; | ||
| 1801 | /* Attempt to halt IN ep will fail if any transfer requests | ||
| 1802 | * are still queue */ | ||
| 1803 | if (value && ep_is_in(ep) && !list_empty(&ep->queue)) { | ||
| 1804 | status = -EAGAIN; | ||
| 1805 | goto out; | ||
| 1806 | } | ||
| 1807 | |||
| 1808 | status = 0; | ||
| 1809 | spin_lock_irqsave(&ep->udc->lock, flags); | ||
| 1810 | qe_eptx_stall_change(ep, value); | ||
| 1811 | qe_eprx_stall_change(ep, value); | ||
| 1812 | spin_unlock_irqrestore(&ep->udc->lock, flags); | ||
| 1813 | |||
| 1814 | if (ep->epnum == 0) { | ||
| 1815 | udc->ep0_state = WAIT_FOR_SETUP; | ||
| 1816 | udc->ep0_dir = 0; | ||
| 1817 | } | ||
| 1818 | |||
| 1819 | /* set data toggle to DATA0 on clear halt */ | ||
| 1820 | if (value == 0) | ||
| 1821 | ep->data01 = 0; | ||
| 1822 | out: | ||
| 1823 | dev_vdbg(udc->dev, "%s %s halt stat %d\n", ep->ep.name, | ||
| 1824 | value ? "set" : "clear", status); | ||
| 1825 | |||
| 1826 | return status; | ||
| 1827 | } | ||
| 1828 | |||
| 1829 | static struct usb_ep_ops qe_ep_ops = { | ||
| 1830 | .enable = qe_ep_enable, | ||
| 1831 | .disable = qe_ep_disable, | ||
| 1832 | |||
| 1833 | .alloc_request = qe_alloc_request, | ||
| 1834 | .free_request = qe_free_request, | ||
| 1835 | |||
| 1836 | .queue = qe_ep_queue, | ||
| 1837 | .dequeue = qe_ep_dequeue, | ||
| 1838 | |||
| 1839 | .set_halt = qe_ep_set_halt, | ||
| 1840 | }; | ||
| 1841 | |||
| 1842 | /*------------------------------------------------------------------------ | ||
| 1843 | Gadget Driver Layer Operations | ||
| 1844 | ------------------------------------------------------------------------*/ | ||
| 1845 | |||
| 1846 | /* Get the current frame number */ | ||
| 1847 | static int qe_get_frame(struct usb_gadget *gadget) | ||
| 1848 | { | ||
| 1849 | u16 tmp; | ||
| 1850 | |||
| 1851 | tmp = in_be16(&udc_controller->usb_param->frame_n); | ||
| 1852 | if (tmp & 0x8000) | ||
| 1853 | tmp = tmp & 0x07ff; | ||
| 1854 | else | ||
| 1855 | tmp = -EINVAL; | ||
| 1856 | |||
| 1857 | return (int)tmp; | ||
| 1858 | } | ||
| 1859 | |||
| 1860 | /* Tries to wake up the host connected to this gadget | ||
| 1861 | * | ||
| 1862 | * Return : 0-success | ||
| 1863 | * Negative-this feature not enabled by host or not supported by device hw | ||
| 1864 | */ | ||
| 1865 | static int qe_wakeup(struct usb_gadget *gadget) | ||
| 1866 | { | ||
| 1867 | return -ENOTSUPP; | ||
| 1868 | } | ||
| 1869 | |||
| 1870 | /* Notify controller that VBUS is powered, Called by whatever | ||
| 1871 | detects VBUS sessions */ | ||
| 1872 | static int qe_vbus_session(struct usb_gadget *gadget, int is_active) | ||
| 1873 | { | ||
| 1874 | return -ENOTSUPP; | ||
| 1875 | } | ||
| 1876 | |||
| 1877 | /* constrain controller's VBUS power usage | ||
| 1878 | * This call is used by gadget drivers during SET_CONFIGURATION calls, | ||
| 1879 | * reporting how much power the device may consume. For example, this | ||
| 1880 | * could affect how quickly batteries are recharged. | ||
| 1881 | * | ||
| 1882 | * Returns zero on success, else negative errno. | ||
| 1883 | */ | ||
| 1884 | static int qe_vbus_draw(struct usb_gadget *gadget, unsigned mA) | ||
| 1885 | { | ||
| 1886 | return -ENOTSUPP; | ||
| 1887 | } | ||
| 1888 | |||
| 1889 | /* Change Data+ pullup status | ||
| 1890 | * this func is used by usb_gadget_connect/disconnect | ||
| 1891 | */ | ||
| 1892 | static int qe_pullup(struct usb_gadget *gadget, int is_on) | ||
| 1893 | { | ||
| 1894 | return -ENOTSUPP; | ||
| 1895 | } | ||
| 1896 | |||
| 1897 | /* defined in usb_gadget.h */ | ||
| 1898 | static struct usb_gadget_ops qe_gadget_ops = { | ||
| 1899 | .get_frame = qe_get_frame, | ||
| 1900 | .wakeup = qe_wakeup, | ||
| 1901 | /* .set_selfpowered = qe_set_selfpowered,*/ /* always selfpowered */ | ||
| 1902 | .vbus_session = qe_vbus_session, | ||
| 1903 | .vbus_draw = qe_vbus_draw, | ||
| 1904 | .pullup = qe_pullup, | ||
| 1905 | }; | ||
| 1906 | |||
| 1907 | /*------------------------------------------------------------------------- | ||
| 1908 | USB ep0 Setup process in BUS Enumeration | ||
| 1909 | -------------------------------------------------------------------------*/ | ||
| 1910 | static int udc_reset_ep_queue(struct qe_udc *udc, u8 pipe) | ||
| 1911 | { | ||
| 1912 | struct qe_ep *ep = &udc->eps[pipe]; | ||
| 1913 | |||
| 1914 | nuke(ep, -ECONNRESET); | ||
| 1915 | ep->tx_req = NULL; | ||
| 1916 | return 0; | ||
| 1917 | } | ||
| 1918 | |||
| 1919 | static int reset_queues(struct qe_udc *udc) | ||
| 1920 | { | ||
| 1921 | u8 pipe; | ||
| 1922 | |||
| 1923 | for (pipe = 0; pipe < USB_MAX_ENDPOINTS; pipe++) | ||
| 1924 | udc_reset_ep_queue(udc, pipe); | ||
| 1925 | |||
| 1926 | /* report disconnect; the driver is already quiesced */ | ||
| 1927 | spin_unlock(&udc->lock); | ||
| 1928 | udc->driver->disconnect(&udc->gadget); | ||
| 1929 | spin_lock(&udc->lock); | ||
| 1930 | |||
| 1931 | return 0; | ||
| 1932 | } | ||
| 1933 | |||
| 1934 | static void ch9setaddress(struct qe_udc *udc, u16 value, u16 index, | ||
| 1935 | u16 length) | ||
| 1936 | { | ||
| 1937 | /* Save the new address to device struct */ | ||
| 1938 | udc->device_address = (u8) value; | ||
| 1939 | /* Update usb state */ | ||
| 1940 | udc->usb_state = USB_STATE_ADDRESS; | ||
| 1941 | |||
| 1942 | /* Status phase , send a ZLP */ | ||
| 1943 | if (ep0_prime_status(udc, USB_DIR_IN)) | ||
| 1944 | qe_ep0_stall(udc); | ||
| 1945 | } | ||
| 1946 | |||
| 1947 | static void ownercomplete(struct usb_ep *_ep, struct usb_request *_req) | ||
| 1948 | { | ||
| 1949 | struct qe_req *req = container_of(_req, struct qe_req, req); | ||
| 1950 | |||
| 1951 | req->req.buf = NULL; | ||
| 1952 | kfree(req); | ||
| 1953 | } | ||
| 1954 | |||
| 1955 | static void ch9getstatus(struct qe_udc *udc, u8 request_type, u16 value, | ||
| 1956 | u16 index, u16 length) | ||
| 1957 | { | ||
| 1958 | u16 usb_status = 0; | ||
| 1959 | struct qe_req *req; | ||
| 1960 | struct qe_ep *ep; | ||
| 1961 | int status = 0; | ||
| 1962 | |||
| 1963 | ep = &udc->eps[0]; | ||
| 1964 | if ((request_type & USB_RECIP_MASK) == USB_RECIP_DEVICE) { | ||
| 1965 | /* Get device status */ | ||
| 1966 | usb_status = 1 << USB_DEVICE_SELF_POWERED; | ||
| 1967 | } else if ((request_type & USB_RECIP_MASK) == USB_RECIP_INTERFACE) { | ||
| 1968 | /* Get interface status */ | ||
| 1969 | /* We don't have interface information in udc driver */ | ||
| 1970 | usb_status = 0; | ||
| 1971 | } else if ((request_type & USB_RECIP_MASK) == USB_RECIP_ENDPOINT) { | ||
| 1972 | /* Get endpoint status */ | ||
| 1973 | int pipe = index & USB_ENDPOINT_NUMBER_MASK; | ||
| 1974 | struct qe_ep *target_ep = &udc->eps[pipe]; | ||
| 1975 | u16 usep; | ||
| 1976 | |||
| 1977 | /* stall if endpoint doesn't exist */ | ||
| 1978 | if (!target_ep->desc) | ||
| 1979 | goto stall; | ||
| 1980 | |||
| 1981 | usep = in_be16(&udc->usb_regs->usb_usep[pipe]); | ||
| 1982 | if (index & USB_DIR_IN) { | ||
| 1983 | if (target_ep->dir != USB_DIR_IN) | ||
| 1984 | goto stall; | ||
| 1985 | if ((usep & USB_THS_MASK) == USB_THS_STALL) | ||
| 1986 | usb_status = 1 << USB_ENDPOINT_HALT; | ||
| 1987 | } else { | ||
| 1988 | if (target_ep->dir != USB_DIR_OUT) | ||
| 1989 | goto stall; | ||
| 1990 | if ((usep & USB_RHS_MASK) == USB_RHS_STALL) | ||
| 1991 | usb_status = 1 << USB_ENDPOINT_HALT; | ||
| 1992 | } | ||
| 1993 | } | ||
| 1994 | |||
| 1995 | req = container_of(qe_alloc_request(&ep->ep, GFP_KERNEL), | ||
| 1996 | struct qe_req, req); | ||
| 1997 | req->req.length = 2; | ||
| 1998 | req->req.buf = udc->statusbuf; | ||
| 1999 | *(u16 *)req->req.buf = cpu_to_le16(usb_status); | ||
| 2000 | req->req.status = -EINPROGRESS; | ||
| 2001 | req->req.actual = 0; | ||
| 2002 | req->req.complete = ownercomplete; | ||
| 2003 | |||
| 2004 | udc->ep0_dir = USB_DIR_IN; | ||
| 2005 | |||
| 2006 | /* data phase */ | ||
| 2007 | status = qe_ep_queue(&ep->ep, &req->req, GFP_ATOMIC); | ||
| 2008 | |||
| 2009 | if (status == 0) | ||
| 2010 | return; | ||
| 2011 | stall: | ||
| 2012 | dev_err(udc->dev, "Can't respond to getstatus request \n"); | ||
| 2013 | qe_ep0_stall(udc); | ||
| 2014 | } | ||
| 2015 | |||
| 2016 | /* only handle the setup request, suppose the device in normal status */ | ||
| 2017 | static void setup_received_handle(struct qe_udc *udc, | ||
| 2018 | struct usb_ctrlrequest *setup) | ||
| 2019 | { | ||
| 2020 | /* Fix Endian (udc->local_setup_buff is cpu Endian now)*/ | ||
| 2021 | u16 wValue = le16_to_cpu(setup->wValue); | ||
| 2022 | u16 wIndex = le16_to_cpu(setup->wIndex); | ||
| 2023 | u16 wLength = le16_to_cpu(setup->wLength); | ||
| 2024 | |||
| 2025 | /* clear the previous request in the ep0 */ | ||
| 2026 | udc_reset_ep_queue(udc, 0); | ||
| 2027 | |||
| 2028 | if (setup->bRequestType & USB_DIR_IN) | ||
| 2029 | udc->ep0_dir = USB_DIR_IN; | ||
| 2030 | else | ||
| 2031 | udc->ep0_dir = USB_DIR_OUT; | ||
| 2032 | |||
| 2033 | switch (setup->bRequest) { | ||
| 2034 | case USB_REQ_GET_STATUS: | ||
| 2035 | /* Data+Status phase form udc */ | ||
| 2036 | if ((setup->bRequestType & (USB_DIR_IN | USB_TYPE_MASK)) | ||
| 2037 | != (USB_DIR_IN | USB_TYPE_STANDARD)) | ||
| 2038 | break; | ||
| 2039 | ch9getstatus(udc, setup->bRequestType, wValue, wIndex, | ||
| 2040 | wLength); | ||
| 2041 | return; | ||
| 2042 | |||
| 2043 | case USB_REQ_SET_ADDRESS: | ||
| 2044 | /* Status phase from udc */ | ||
| 2045 | if (setup->bRequestType != (USB_DIR_OUT | USB_TYPE_STANDARD | | ||
| 2046 | USB_RECIP_DEVICE)) | ||
| 2047 | break; | ||
| 2048 | ch9setaddress(udc, wValue, wIndex, wLength); | ||
| 2049 | return; | ||
| 2050 | |||
| 2051 | case USB_REQ_CLEAR_FEATURE: | ||
| 2052 | case USB_REQ_SET_FEATURE: | ||
| 2053 | /* Requests with no data phase, status phase from udc */ | ||
| 2054 | if ((setup->bRequestType & USB_TYPE_MASK) | ||
| 2055 | != USB_TYPE_STANDARD) | ||
| 2056 | break; | ||
| 2057 | |||
| 2058 | if ((setup->bRequestType & USB_RECIP_MASK) | ||
| 2059 | == USB_RECIP_ENDPOINT) { | ||
| 2060 | int pipe = wIndex & USB_ENDPOINT_NUMBER_MASK; | ||
| 2061 | struct qe_ep *ep; | ||
| 2062 | |||
| 2063 | if (wValue != 0 || wLength != 0 | ||
| 2064 | || pipe > USB_MAX_ENDPOINTS) | ||
| 2065 | break; | ||
| 2066 | ep = &udc->eps[pipe]; | ||
| 2067 | |||
| 2068 | spin_unlock(&udc->lock); | ||
| 2069 | qe_ep_set_halt(&ep->ep, | ||
| 2070 | (setup->bRequest == USB_REQ_SET_FEATURE) | ||
| 2071 | ? 1 : 0); | ||
| 2072 | spin_lock(&udc->lock); | ||
| 2073 | } | ||
| 2074 | |||
| 2075 | ep0_prime_status(udc, USB_DIR_IN); | ||
| 2076 | |||
| 2077 | return; | ||
| 2078 | |||
| 2079 | default: | ||
| 2080 | break; | ||
| 2081 | } | ||
| 2082 | |||
| 2083 | if (wLength) { | ||
| 2084 | /* Data phase from gadget, status phase from udc */ | ||
| 2085 | if (setup->bRequestType & USB_DIR_IN) { | ||
| 2086 | udc->ep0_state = DATA_STATE_XMIT; | ||
| 2087 | udc->ep0_dir = USB_DIR_IN; | ||
| 2088 | } else { | ||
| 2089 | udc->ep0_state = DATA_STATE_RECV; | ||
| 2090 | udc->ep0_dir = USB_DIR_OUT; | ||
| 2091 | } | ||
| 2092 | spin_unlock(&udc->lock); | ||
| 2093 | if (udc->driver->setup(&udc->gadget, | ||
| 2094 | &udc->local_setup_buff) < 0) | ||
| 2095 | qe_ep0_stall(udc); | ||
| 2096 | spin_lock(&udc->lock); | ||
| 2097 | } else { | ||
| 2098 | /* No data phase, IN status from gadget */ | ||
| 2099 | udc->ep0_dir = USB_DIR_IN; | ||
| 2100 | spin_unlock(&udc->lock); | ||
| 2101 | if (udc->driver->setup(&udc->gadget, | ||
| 2102 | &udc->local_setup_buff) < 0) | ||
| 2103 | qe_ep0_stall(udc); | ||
| 2104 | spin_lock(&udc->lock); | ||
| 2105 | udc->ep0_state = DATA_STATE_NEED_ZLP; | ||
| 2106 | } | ||
| 2107 | } | ||
| 2108 | |||
| 2109 | /*------------------------------------------------------------------------- | ||
| 2110 | USB Interrupt handlers | ||
| 2111 | -------------------------------------------------------------------------*/ | ||
| 2112 | static void suspend_irq(struct qe_udc *udc) | ||
| 2113 | { | ||
| 2114 | udc->resume_state = udc->usb_state; | ||
| 2115 | udc->usb_state = USB_STATE_SUSPENDED; | ||
| 2116 | |||
| 2117 | /* report suspend to the driver ,serial.c not support this*/ | ||
| 2118 | if (udc->driver->suspend) | ||
| 2119 | udc->driver->suspend(&udc->gadget); | ||
| 2120 | } | ||
| 2121 | |||
| 2122 | static void resume_irq(struct qe_udc *udc) | ||
| 2123 | { | ||
| 2124 | udc->usb_state = udc->resume_state; | ||
| 2125 | udc->resume_state = 0; | ||
| 2126 | |||
| 2127 | /* report resume to the driver , serial.c not support this*/ | ||
| 2128 | if (udc->driver->resume) | ||
| 2129 | udc->driver->resume(&udc->gadget); | ||
| 2130 | } | ||
| 2131 | |||
| 2132 | static void idle_irq(struct qe_udc *udc) | ||
| 2133 | { | ||
| 2134 | u8 usbs; | ||
| 2135 | |||
| 2136 | usbs = in_8(&udc->usb_regs->usb_usbs); | ||
| 2137 | if (usbs & USB_IDLE_STATUS_MASK) { | ||
| 2138 | if ((udc->usb_state) != USB_STATE_SUSPENDED) | ||
| 2139 | suspend_irq(udc); | ||
| 2140 | } else { | ||
| 2141 | if (udc->usb_state == USB_STATE_SUSPENDED) | ||
| 2142 | resume_irq(udc); | ||
| 2143 | } | ||
| 2144 | } | ||
| 2145 | |||
| 2146 | static int reset_irq(struct qe_udc *udc) | ||
| 2147 | { | ||
| 2148 | unsigned char i; | ||
| 2149 | |||
| 2150 | qe_usb_disable(); | ||
| 2151 | out_8(&udc->usb_regs->usb_usadr, 0); | ||
| 2152 | |||
| 2153 | for (i = 0; i < USB_MAX_ENDPOINTS; i++) { | ||
| 2154 | if (udc->eps[i].init) | ||
| 2155 | qe_ep_reset(udc, i); | ||
| 2156 | } | ||
| 2157 | |||
| 2158 | reset_queues(udc); | ||
| 2159 | udc->usb_state = USB_STATE_DEFAULT; | ||
| 2160 | udc->ep0_state = WAIT_FOR_SETUP; | ||
| 2161 | udc->ep0_dir = USB_DIR_OUT; | ||
| 2162 | qe_usb_enable(); | ||
| 2163 | return 0; | ||
| 2164 | } | ||
| 2165 | |||
| 2166 | static int bsy_irq(struct qe_udc *udc) | ||
| 2167 | { | ||
| 2168 | return 0; | ||
| 2169 | } | ||
| 2170 | |||
| 2171 | static int txe_irq(struct qe_udc *udc) | ||
| 2172 | { | ||
| 2173 | return 0; | ||
| 2174 | } | ||
| 2175 | |||
| 2176 | /* ep0 tx interrupt also in here */ | ||
| 2177 | static int tx_irq(struct qe_udc *udc) | ||
| 2178 | { | ||
| 2179 | struct qe_ep *ep; | ||
| 2180 | struct qe_bd __iomem *bd; | ||
| 2181 | int i, res = 0; | ||
| 2182 | |||
| 2183 | if ((udc->usb_state == USB_STATE_ADDRESS) | ||
| 2184 | && (in_8(&udc->usb_regs->usb_usadr) == 0)) | ||
| 2185 | out_8(&udc->usb_regs->usb_usadr, udc->device_address); | ||
| 2186 | |||
| 2187 | for (i = (USB_MAX_ENDPOINTS-1); ((i >= 0) && (res == 0)); i--) { | ||
| 2188 | ep = &udc->eps[i]; | ||
| 2189 | if (ep && ep->init && (ep->dir != USB_DIR_OUT)) { | ||
| 2190 | bd = ep->c_txbd; | ||
| 2191 | if (!(in_be32((u32 __iomem *)bd) & T_R) | ||
| 2192 | && (in_be32(&bd->buf))) { | ||
| 2193 | /* confirm the transmitted bd */ | ||
| 2194 | if (ep->epnum == 0) | ||
| 2195 | res = qe_ep0_txconf(ep); | ||
| 2196 | else | ||
| 2197 | res = qe_ep_txconf(ep); | ||
| 2198 | } | ||
| 2199 | } | ||
| 2200 | } | ||
| 2201 | return res; | ||
| 2202 | } | ||
| 2203 | |||
| 2204 | |||
| 2205 | /* setup packect's rx is handle in the function too */ | ||
| 2206 | static void rx_irq(struct qe_udc *udc) | ||
| 2207 | { | ||
| 2208 | struct qe_ep *ep; | ||
| 2209 | struct qe_bd __iomem *bd; | ||
| 2210 | int i; | ||
| 2211 | |||
| 2212 | for (i = 0; i < USB_MAX_ENDPOINTS; i++) { | ||
| 2213 | ep = &udc->eps[i]; | ||
| 2214 | if (ep && ep->init && (ep->dir != USB_DIR_IN)) { | ||
| 2215 | bd = ep->n_rxbd; | ||
| 2216 | if (!(in_be32((u32 __iomem *)bd) & R_E) | ||
| 2217 | && (in_be32(&bd->buf))) { | ||
| 2218 | if (ep->epnum == 0) { | ||
| 2219 | qe_ep0_rx(udc); | ||
| 2220 | } else { | ||
| 2221 | /*non-setup package receive*/ | ||
| 2222 | qe_ep_rx(ep); | ||
| 2223 | } | ||
| 2224 | } | ||
| 2225 | } | ||
| 2226 | } | ||
| 2227 | } | ||
| 2228 | |||
| 2229 | static irqreturn_t qe_udc_irq(int irq, void *_udc) | ||
| 2230 | { | ||
| 2231 | struct qe_udc *udc = (struct qe_udc *)_udc; | ||
| 2232 | u16 irq_src; | ||
| 2233 | irqreturn_t status = IRQ_NONE; | ||
| 2234 | unsigned long flags; | ||
| 2235 | |||
| 2236 | spin_lock_irqsave(&udc->lock, flags); | ||
| 2237 | |||
| 2238 | irq_src = in_be16(&udc->usb_regs->usb_usber) & | ||
| 2239 | in_be16(&udc->usb_regs->usb_usbmr); | ||
| 2240 | /* Clear notification bits */ | ||
| 2241 | out_be16(&udc->usb_regs->usb_usber, irq_src); | ||
| 2242 | /* USB Interrupt */ | ||
| 2243 | if (irq_src & USB_E_IDLE_MASK) { | ||
| 2244 | idle_irq(udc); | ||
| 2245 | irq_src &= ~USB_E_IDLE_MASK; | ||
| 2246 | status = IRQ_HANDLED; | ||
| 2247 | } | ||
| 2248 | |||
| 2249 | if (irq_src & USB_E_TXB_MASK) { | ||
| 2250 | tx_irq(udc); | ||
| 2251 | irq_src &= ~USB_E_TXB_MASK; | ||
| 2252 | status = IRQ_HANDLED; | ||
| 2253 | } | ||
| 2254 | |||
| 2255 | if (irq_src & USB_E_RXB_MASK) { | ||
| 2256 | rx_irq(udc); | ||
| 2257 | irq_src &= ~USB_E_RXB_MASK; | ||
| 2258 | status = IRQ_HANDLED; | ||
| 2259 | } | ||
| 2260 | |||
| 2261 | if (irq_src & USB_E_RESET_MASK) { | ||
| 2262 | reset_irq(udc); | ||
| 2263 | irq_src &= ~USB_E_RESET_MASK; | ||
| 2264 | status = IRQ_HANDLED; | ||
| 2265 | } | ||
| 2266 | |||
| 2267 | if (irq_src & USB_E_BSY_MASK) { | ||
| 2268 | bsy_irq(udc); | ||
| 2269 | irq_src &= ~USB_E_BSY_MASK; | ||
| 2270 | status = IRQ_HANDLED; | ||
| 2271 | } | ||
| 2272 | |||
| 2273 | if (irq_src & USB_E_TXE_MASK) { | ||
| 2274 | txe_irq(udc); | ||
| 2275 | irq_src &= ~USB_E_TXE_MASK; | ||
| 2276 | status = IRQ_HANDLED; | ||
| 2277 | } | ||
| 2278 | |||
| 2279 | spin_unlock_irqrestore(&udc->lock, flags); | ||
| 2280 | |||
| 2281 | return status; | ||
| 2282 | } | ||
| 2283 | |||
| 2284 | /*------------------------------------------------------------------------- | ||
| 2285 | Gadget driver register and unregister. | ||
| 2286 | --------------------------------------------------------------------------*/ | ||
| 2287 | int usb_gadget_register_driver(struct usb_gadget_driver *driver) | ||
| 2288 | { | ||
| 2289 | int retval; | ||
| 2290 | unsigned long flags = 0; | ||
| 2291 | |||
| 2292 | /* standard operations */ | ||
| 2293 | if (!udc_controller) | ||
| 2294 | return -ENODEV; | ||
| 2295 | |||
| 2296 | if (!driver || (driver->speed != USB_SPEED_FULL | ||
| 2297 | && driver->speed != USB_SPEED_HIGH) | ||
| 2298 | || !driver->bind || !driver->disconnect | ||
| 2299 | || !driver->setup) | ||
| 2300 | return -EINVAL; | ||
| 2301 | |||
| 2302 | if (udc_controller->driver) | ||
| 2303 | return -EBUSY; | ||
| 2304 | |||
| 2305 | /* lock is needed but whether should use this lock or another */ | ||
| 2306 | spin_lock_irqsave(&udc_controller->lock, flags); | ||
| 2307 | |||
| 2308 | driver->driver.bus = NULL; | ||
| 2309 | /* hook up the driver */ | ||
| 2310 | udc_controller->driver = driver; | ||
| 2311 | udc_controller->gadget.dev.driver = &driver->driver; | ||
| 2312 | udc_controller->gadget.speed = (enum usb_device_speed)(driver->speed); | ||
| 2313 | spin_unlock_irqrestore(&udc_controller->lock, flags); | ||
| 2314 | |||
| 2315 | retval = driver->bind(&udc_controller->gadget); | ||
| 2316 | if (retval) { | ||
| 2317 | dev_err(udc_controller->dev, "bind to %s --> %d", | ||
| 2318 | driver->driver.name, retval); | ||
| 2319 | udc_controller->gadget.dev.driver = NULL; | ||
| 2320 | udc_controller->driver = NULL; | ||
| 2321 | return retval; | ||
| 2322 | } | ||
| 2323 | |||
| 2324 | /* Enable IRQ reg and Set usbcmd reg EN bit */ | ||
| 2325 | qe_usb_enable(); | ||
| 2326 | |||
| 2327 | out_be16(&udc_controller->usb_regs->usb_usber, 0xffff); | ||
| 2328 | out_be16(&udc_controller->usb_regs->usb_usbmr, USB_E_DEFAULT_DEVICE); | ||
| 2329 | udc_controller->usb_state = USB_STATE_ATTACHED; | ||
| 2330 | udc_controller->ep0_state = WAIT_FOR_SETUP; | ||
| 2331 | udc_controller->ep0_dir = USB_DIR_OUT; | ||
| 2332 | dev_info(udc_controller->dev, "%s bind to driver %s \n", | ||
| 2333 | udc_controller->gadget.name, driver->driver.name); | ||
| 2334 | return 0; | ||
| 2335 | } | ||
| 2336 | EXPORT_SYMBOL(usb_gadget_register_driver); | ||
| 2337 | |||
| 2338 | int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) | ||
| 2339 | { | ||
| 2340 | struct qe_ep *loop_ep; | ||
| 2341 | unsigned long flags; | ||
| 2342 | |||
| 2343 | if (!udc_controller) | ||
| 2344 | return -ENODEV; | ||
| 2345 | |||
| 2346 | if (!driver || driver != udc_controller->driver) | ||
| 2347 | return -EINVAL; | ||
| 2348 | |||
| 2349 | /* stop usb controller, disable intr */ | ||
| 2350 | qe_usb_disable(); | ||
| 2351 | |||
| 2352 | /* in fact, no needed */ | ||
| 2353 | udc_controller->usb_state = USB_STATE_ATTACHED; | ||
| 2354 | udc_controller->ep0_state = WAIT_FOR_SETUP; | ||
| 2355 | udc_controller->ep0_dir = 0; | ||
| 2356 | |||
| 2357 | /* stand operation */ | ||
| 2358 | spin_lock_irqsave(&udc_controller->lock, flags); | ||
| 2359 | udc_controller->gadget.speed = USB_SPEED_UNKNOWN; | ||
| 2360 | nuke(&udc_controller->eps[0], -ESHUTDOWN); | ||
| 2361 | list_for_each_entry(loop_ep, &udc_controller->gadget.ep_list, | ||
| 2362 | ep.ep_list) | ||
| 2363 | nuke(loop_ep, -ESHUTDOWN); | ||
| 2364 | spin_unlock_irqrestore(&udc_controller->lock, flags); | ||
| 2365 | |||
| 2366 | /* unbind gadget and unhook driver. */ | ||
| 2367 | driver->unbind(&udc_controller->gadget); | ||
| 2368 | udc_controller->gadget.dev.driver = NULL; | ||
| 2369 | udc_controller->driver = NULL; | ||
| 2370 | |||
| 2371 | dev_info(udc_controller->dev, "unregistered gadget driver '%s'\r\n", | ||
| 2372 | driver->driver.name); | ||
| 2373 | return 0; | ||
| 2374 | } | ||
| 2375 | EXPORT_SYMBOL(usb_gadget_unregister_driver); | ||
| 2376 | |||
| 2377 | /* udc structure's alloc and setup, include ep-param alloc */ | ||
| 2378 | static struct qe_udc __devinit *qe_udc_config(struct of_device *ofdev) | ||
| 2379 | { | ||
| 2380 | struct qe_udc *udc; | ||
| 2381 | struct device_node *np = ofdev->node; | ||
| 2382 | unsigned int tmp_addr = 0; | ||
| 2383 | struct usb_device_para __iomem *usbpram; | ||
| 2384 | unsigned int i; | ||
| 2385 | u64 size; | ||
| 2386 | u32 offset; | ||
| 2387 | |||
| 2388 | udc = kzalloc(sizeof(*udc), GFP_KERNEL); | ||
| 2389 | if (udc == NULL) { | ||
| 2390 | dev_err(&ofdev->dev, "malloc udc failed\n"); | ||
| 2391 | goto cleanup; | ||
| 2392 | } | ||
| 2393 | |||
| 2394 | udc->dev = &ofdev->dev; | ||
| 2395 | |||
| 2396 | /* get default address of usb parameter in MURAM from device tree */ | ||
| 2397 | offset = *of_get_address(np, 1, &size, NULL); | ||
| 2398 | udc->usb_param = cpm_muram_addr(offset); | ||
| 2399 | memset_io(udc->usb_param, 0, size); | ||
| 2400 | |||
| 2401 | usbpram = udc->usb_param; | ||
| 2402 | out_be16(&usbpram->frame_n, 0); | ||
| 2403 | out_be32(&usbpram->rstate, 0); | ||
| 2404 | |||
| 2405 | tmp_addr = cpm_muram_alloc((USB_MAX_ENDPOINTS * | ||
| 2406 | sizeof(struct usb_ep_para)), | ||
| 2407 | USB_EP_PARA_ALIGNMENT); | ||
| 2408 | |||
| 2409 | for (i = 0; i < USB_MAX_ENDPOINTS; i++) { | ||
| 2410 | out_be16(&usbpram->epptr[i], (u16)tmp_addr); | ||
| 2411 | udc->ep_param[i] = cpm_muram_addr(tmp_addr); | ||
| 2412 | tmp_addr += 32; | ||
| 2413 | } | ||
| 2414 | |||
| 2415 | memset_io(udc->ep_param[0], 0, | ||
| 2416 | USB_MAX_ENDPOINTS * sizeof(struct usb_ep_para)); | ||
| 2417 | |||
| 2418 | udc->resume_state = USB_STATE_NOTATTACHED; | ||
| 2419 | udc->usb_state = USB_STATE_POWERED; | ||
| 2420 | udc->ep0_dir = 0; | ||
| 2421 | |||
| 2422 | spin_lock_init(&udc->lock); | ||
| 2423 | return udc; | ||
| 2424 | |||
| 2425 | cleanup: | ||
| 2426 | kfree(udc); | ||
| 2427 | return NULL; | ||
| 2428 | } | ||
| 2429 | |||
| 2430 | /* USB Controller register init */ | ||
| 2431 | static int __devinit qe_udc_reg_init(struct qe_udc *udc) | ||
| 2432 | { | ||
| 2433 | struct usb_ctlr __iomem *qe_usbregs; | ||
| 2434 | qe_usbregs = udc->usb_regs; | ||
| 2435 | |||
| 2436 | /* Init the usb register */ | ||
| 2437 | out_8(&qe_usbregs->usb_usmod, 0x01); | ||
| 2438 | out_be16(&qe_usbregs->usb_usbmr, 0); | ||
| 2439 | out_8(&qe_usbregs->usb_uscom, 0); | ||
| 2440 | out_be16(&qe_usbregs->usb_usber, USBER_ALL_CLEAR); | ||
| 2441 | |||
| 2442 | return 0; | ||
| 2443 | } | ||
| 2444 | |||
| 2445 | static int __devinit qe_ep_config(struct qe_udc *udc, unsigned char pipe_num) | ||
| 2446 | { | ||
| 2447 | struct qe_ep *ep = &udc->eps[pipe_num]; | ||
| 2448 | |||
| 2449 | ep->udc = udc; | ||
| 2450 | strcpy(ep->name, ep_name[pipe_num]); | ||
| 2451 | ep->ep.name = ep_name[pipe_num]; | ||
| 2452 | |||
| 2453 | ep->ep.ops = &qe_ep_ops; | ||
| 2454 | ep->stopped = 1; | ||
| 2455 | ep->ep.maxpacket = (unsigned short) ~0; | ||
| 2456 | ep->desc = NULL; | ||
| 2457 | ep->dir = 0xff; | ||
| 2458 | ep->epnum = (u8)pipe_num; | ||
| 2459 | ep->sent = 0; | ||
| 2460 | ep->last = 0; | ||
| 2461 | ep->init = 0; | ||
| 2462 | ep->rxframe = NULL; | ||
| 2463 | ep->txframe = NULL; | ||
| 2464 | ep->tx_req = NULL; | ||
| 2465 | ep->state = EP_STATE_IDLE; | ||
| 2466 | ep->has_data = 0; | ||
| 2467 | |||
| 2468 | /* the queue lists any req for this ep */ | ||
| 2469 | INIT_LIST_HEAD(&ep->queue); | ||
| 2470 | |||
| 2471 | /* gagdet.ep_list used for ep_autoconfig so no ep0*/ | ||
| 2472 | if (pipe_num != 0) | ||
| 2473 | list_add_tail(&ep->ep.ep_list, &udc->gadget.ep_list); | ||
| 2474 | |||
| 2475 | ep->gadget = &udc->gadget; | ||
| 2476 | |||
| 2477 | return 0; | ||
| 2478 | } | ||
| 2479 | |||
| 2480 | /*----------------------------------------------------------------------- | ||
| 2481 | * UDC device Driver operation functions * | ||
| 2482 | *----------------------------------------------------------------------*/ | ||
| 2483 | static void qe_udc_release(struct device *dev) | ||
| 2484 | { | ||
| 2485 | int i = 0; | ||
| 2486 | |||
| 2487 | complete(udc_controller->done); | ||
| 2488 | cpm_muram_free(cpm_muram_offset(udc_controller->ep_param[0])); | ||
| 2489 | for (i = 0; i < USB_MAX_ENDPOINTS; i++) | ||
| 2490 | udc_controller->ep_param[i] = NULL; | ||
| 2491 | |||
| 2492 | kfree(udc_controller); | ||
| 2493 | udc_controller = NULL; | ||
| 2494 | } | ||
| 2495 | |||
| 2496 | /* Driver probe functions */ | ||
| 2497 | static int __devinit qe_udc_probe(struct of_device *ofdev, | ||
| 2498 | const struct of_device_id *match) | ||
| 2499 | { | ||
| 2500 | struct device_node *np = ofdev->node; | ||
| 2501 | struct qe_ep *ep; | ||
| 2502 | unsigned int ret = 0; | ||
| 2503 | unsigned int i; | ||
| 2504 | const void *prop; | ||
| 2505 | |||
| 2506 | prop = of_get_property(np, "mode", NULL); | ||
| 2507 | if (!prop || strcmp(prop, "peripheral")) | ||
| 2508 | return -ENODEV; | ||
| 2509 | |||
| 2510 | /* Initialize the udc structure including QH member and other member */ | ||
| 2511 | udc_controller = qe_udc_config(ofdev); | ||
| 2512 | if (!udc_controller) { | ||
| 2513 | dev_dbg(&ofdev->dev, "udc_controll is NULL\n"); | ||
| 2514 | return -ENOMEM; | ||
| 2515 | } | ||
| 2516 | |||
| 2517 | udc_controller->soc_type = (unsigned long)match->data; | ||
| 2518 | udc_controller->usb_regs = of_iomap(np, 0); | ||
| 2519 | if (!udc_controller->usb_regs) { | ||
| 2520 | ret = -ENOMEM; | ||
| 2521 | goto err1; | ||
| 2522 | } | ||
| 2523 | |||
| 2524 | /* initialize usb hw reg except for regs for EP, | ||
| 2525 | * leave usbintr reg untouched*/ | ||
| 2526 | qe_udc_reg_init(udc_controller); | ||
| 2527 | |||
| 2528 | /* here comes the stand operations for probe | ||
| 2529 | * set the qe_udc->gadget.xxx */ | ||
| 2530 | udc_controller->gadget.ops = &qe_gadget_ops; | ||
| 2531 | |||
| 2532 | /* gadget.ep0 is a pointer */ | ||
| 2533 | udc_controller->gadget.ep0 = &udc_controller->eps[0].ep; | ||
| 2534 | |||
| 2535 | INIT_LIST_HEAD(&udc_controller->gadget.ep_list); | ||
| 2536 | |||
| 2537 | /* modify in register gadget process */ | ||
| 2538 | udc_controller->gadget.speed = USB_SPEED_UNKNOWN; | ||
| 2539 | |||
| 2540 | /* name: Identifies the controller hardware type. */ | ||
| 2541 | udc_controller->gadget.name = driver_name; | ||
| 2542 | |||
| 2543 | device_initialize(&udc_controller->gadget.dev); | ||
| 2544 | |||
| 2545 | strcpy(udc_controller->gadget.dev.bus_id, "gadget"); | ||
| 2546 | |||
| 2547 | udc_controller->gadget.dev.release = qe_udc_release; | ||
| 2548 | udc_controller->gadget.dev.parent = &ofdev->dev; | ||
| 2549 | |||
| 2550 | /* initialize qe_ep struct */ | ||
| 2551 | for (i = 0; i < USB_MAX_ENDPOINTS ; i++) { | ||
| 2552 | /* because the ep type isn't decide here so | ||
| 2553 | * qe_ep_init() should be called in ep_enable() */ | ||
| 2554 | |||
| 2555 | /* setup the qe_ep struct and link ep.ep.list | ||
| 2556 | * into gadget.ep_list */ | ||
| 2557 | qe_ep_config(udc_controller, (unsigned char)i); | ||
| 2558 | } | ||
| 2559 | |||
| 2560 | /* ep0 initialization in here */ | ||
| 2561 | ret = qe_ep_init(udc_controller, 0, &qe_ep0_desc); | ||
| 2562 | if (ret) | ||
| 2563 | goto err2; | ||
| 2564 | |||
| 2565 | /* create a buf for ZLP send, need to remain zeroed */ | ||
| 2566 | udc_controller->nullbuf = kzalloc(256, GFP_KERNEL); | ||
| 2567 | if (udc_controller->nullbuf == NULL) { | ||
| 2568 | dev_dbg(udc_controller->dev, "cannot alloc nullbuf\n"); | ||
| 2569 | ret = -ENOMEM; | ||
| 2570 | goto err3; | ||
| 2571 | } | ||
| 2572 | |||
| 2573 | /* buffer for data of get_status request */ | ||
| 2574 | udc_controller->statusbuf = kzalloc(2, GFP_KERNEL); | ||
| 2575 | if (udc_controller->statusbuf == NULL) { | ||
| 2576 | ret = -ENOMEM; | ||
| 2577 | goto err4; | ||
| 2578 | } | ||
| 2579 | |||
| 2580 | udc_controller->nullp = virt_to_phys((void *)udc_controller->nullbuf); | ||
| 2581 | if (udc_controller->nullp == DMA_ADDR_INVALID) { | ||
| 2582 | udc_controller->nullp = dma_map_single( | ||
| 2583 | udc_controller->gadget.dev.parent, | ||
| 2584 | udc_controller->nullbuf, | ||
| 2585 | 256, | ||
| 2586 | DMA_TO_DEVICE); | ||
| 2587 | udc_controller->nullmap = 1; | ||
| 2588 | } else { | ||
| 2589 | dma_sync_single_for_device(udc_controller->gadget.dev.parent, | ||
| 2590 | udc_controller->nullp, 256, | ||
| 2591 | DMA_TO_DEVICE); | ||
| 2592 | } | ||
| 2593 | |||
| 2594 | tasklet_init(&udc_controller->rx_tasklet, ep_rx_tasklet, | ||
| 2595 | (unsigned long)udc_controller); | ||
| 2596 | /* request irq and disable DR */ | ||
| 2597 | udc_controller->usb_irq = irq_of_parse_and_map(np, 0); | ||
| 2598 | |||
| 2599 | ret = request_irq(udc_controller->usb_irq, qe_udc_irq, 0, | ||
| 2600 | driver_name, udc_controller); | ||
| 2601 | if (ret) { | ||
| 2602 | dev_err(udc_controller->dev, "cannot request irq %d err %d \n", | ||
| 2603 | udc_controller->usb_irq, ret); | ||
| 2604 | goto err5; | ||
| 2605 | } | ||
| 2606 | |||
| 2607 | ret = device_add(&udc_controller->gadget.dev); | ||
| 2608 | if (ret) | ||
| 2609 | goto err6; | ||
| 2610 | |||
| 2611 | dev_info(udc_controller->dev, | ||
| 2612 | "%s USB controller initialized as device\n", | ||
| 2613 | (udc_controller->soc_type == PORT_QE) ? "QE" : "CPM"); | ||
| 2614 | return 0; | ||
| 2615 | |||
| 2616 | err6: | ||
| 2617 | free_irq(udc_controller->usb_irq, udc_controller); | ||
| 2618 | err5: | ||
| 2619 | if (udc_controller->nullmap) { | ||
| 2620 | dma_unmap_single(udc_controller->gadget.dev.parent, | ||
| 2621 | udc_controller->nullp, 256, | ||
| 2622 | DMA_TO_DEVICE); | ||
| 2623 | udc_controller->nullp = DMA_ADDR_INVALID; | ||
| 2624 | } else { | ||
| 2625 | dma_sync_single_for_cpu(udc_controller->gadget.dev.parent, | ||
| 2626 | udc_controller->nullp, 256, | ||
| 2627 | DMA_TO_DEVICE); | ||
| 2628 | } | ||
| 2629 | kfree(udc_controller->statusbuf); | ||
| 2630 | err4: | ||
| 2631 | kfree(udc_controller->nullbuf); | ||
| 2632 | err3: | ||
| 2633 | ep = &udc_controller->eps[0]; | ||
| 2634 | cpm_muram_free(cpm_muram_offset(ep->rxbase)); | ||
| 2635 | kfree(ep->rxframe); | ||
| 2636 | kfree(ep->rxbuffer); | ||
| 2637 | kfree(ep->txframe); | ||
| 2638 | err2: | ||
| 2639 | iounmap(udc_controller->usb_regs); | ||
| 2640 | err1: | ||
| 2641 | kfree(udc_controller); | ||
| 2642 | |||
| 2643 | return ret; | ||
| 2644 | } | ||
| 2645 | |||
| 2646 | #ifdef CONFIG_PM | ||
| 2647 | static int qe_udc_suspend(struct of_device *dev, pm_message_t state) | ||
| 2648 | { | ||
| 2649 | return -ENOTSUPP; | ||
| 2650 | } | ||
| 2651 | |||
| 2652 | static int qe_udc_resume(struct of_device *dev) | ||
| 2653 | { | ||
| 2654 | return -ENOTSUPP; | ||
| 2655 | } | ||
| 2656 | #endif | ||
| 2657 | |||
| 2658 | static int __devexit qe_udc_remove(struct of_device *ofdev) | ||
| 2659 | { | ||
| 2660 | struct qe_ep *ep; | ||
| 2661 | unsigned int size; | ||
| 2662 | |||
| 2663 | DECLARE_COMPLETION(done); | ||
| 2664 | |||
| 2665 | if (!udc_controller) | ||
| 2666 | return -ENODEV; | ||
| 2667 | |||
| 2668 | udc_controller->done = &done; | ||
| 2669 | tasklet_disable(&udc_controller->rx_tasklet); | ||
| 2670 | |||
| 2671 | if (udc_controller->nullmap) { | ||
| 2672 | dma_unmap_single(udc_controller->gadget.dev.parent, | ||
| 2673 | udc_controller->nullp, 256, | ||
| 2674 | DMA_TO_DEVICE); | ||
| 2675 | udc_controller->nullp = DMA_ADDR_INVALID; | ||
| 2676 | } else { | ||
| 2677 | dma_sync_single_for_cpu(udc_controller->gadget.dev.parent, | ||
| 2678 | udc_controller->nullp, 256, | ||
| 2679 | DMA_TO_DEVICE); | ||
| 2680 | } | ||
| 2681 | kfree(udc_controller->statusbuf); | ||
| 2682 | kfree(udc_controller->nullbuf); | ||
| 2683 | |||
| 2684 | ep = &udc_controller->eps[0]; | ||
| 2685 | cpm_muram_free(cpm_muram_offset(ep->rxbase)); | ||
| 2686 | size = (ep->ep.maxpacket + USB_CRC_SIZE + 2) * (USB_BDRING_LEN + 1); | ||
| 2687 | |||
| 2688 | kfree(ep->rxframe); | ||
| 2689 | if (ep->rxbufmap) { | ||
| 2690 | dma_unmap_single(udc_controller->gadget.dev.parent, | ||
| 2691 | ep->rxbuf_d, size, | ||
| 2692 | DMA_FROM_DEVICE); | ||
| 2693 | ep->rxbuf_d = DMA_ADDR_INVALID; | ||
| 2694 | } else { | ||
| 2695 | dma_sync_single_for_cpu(udc_controller->gadget.dev.parent, | ||
| 2696 | ep->rxbuf_d, size, | ||
| 2697 | DMA_FROM_DEVICE); | ||
| 2698 | } | ||
| 2699 | |||
| 2700 | kfree(ep->rxbuffer); | ||
| 2701 | kfree(ep->txframe); | ||
| 2702 | |||
| 2703 | free_irq(udc_controller->usb_irq, udc_controller); | ||
| 2704 | |||
| 2705 | tasklet_kill(&udc_controller->rx_tasklet); | ||
| 2706 | |||
| 2707 | iounmap(udc_controller->usb_regs); | ||
| 2708 | |||
| 2709 | device_unregister(&udc_controller->gadget.dev); | ||
| 2710 | /* wait for release() of gadget.dev to free udc */ | ||
| 2711 | wait_for_completion(&done); | ||
| 2712 | |||
| 2713 | return 0; | ||
| 2714 | } | ||
| 2715 | |||
| 2716 | /*-------------------------------------------------------------------------*/ | ||
| 2717 | static struct of_device_id __devinitdata qe_udc_match[] = { | ||
| 2718 | { | ||
| 2719 | .compatible = "fsl,mpc8360-qe-usb", | ||
| 2720 | .data = (void *)PORT_QE, | ||
| 2721 | }, | ||
| 2722 | { | ||
| 2723 | .compatible = "fsl,mpc8272-cpm-usb", | ||
| 2724 | .data = (void *)PORT_CPM, | ||
| 2725 | }, | ||
| 2726 | {}, | ||
| 2727 | }; | ||
| 2728 | |||
| 2729 | MODULE_DEVICE_TABLE(of, qe_udc_match); | ||
| 2730 | |||
| 2731 | static struct of_platform_driver udc_driver = { | ||
| 2732 | .name = (char *)driver_name, | ||
| 2733 | .match_table = qe_udc_match, | ||
| 2734 | .probe = qe_udc_probe, | ||
| 2735 | .remove = __devexit_p(qe_udc_remove), | ||
| 2736 | #ifdef CONFIG_PM | ||
| 2737 | .suspend = qe_udc_suspend, | ||
| 2738 | .resume = qe_udc_resume, | ||
| 2739 | #endif | ||
| 2740 | }; | ||
| 2741 | |||
| 2742 | static int __init qe_udc_init(void) | ||
| 2743 | { | ||
| 2744 | printk(KERN_INFO "%s: %s, %s\n", driver_name, driver_desc, | ||
| 2745 | DRIVER_VERSION); | ||
| 2746 | return of_register_platform_driver(&udc_driver); | ||
| 2747 | } | ||
| 2748 | |||
| 2749 | static void __exit qe_udc_exit(void) | ||
| 2750 | { | ||
| 2751 | of_unregister_platform_driver(&udc_driver); | ||
| 2752 | } | ||
| 2753 | |||
| 2754 | module_init(qe_udc_init); | ||
| 2755 | module_exit(qe_udc_exit); | ||
| 2756 | |||
| 2757 | MODULE_DESCRIPTION(DRIVER_DESC); | ||
| 2758 | MODULE_AUTHOR(DRIVER_AUTHOR); | ||
| 2759 | MODULE_LICENSE("GPL"); | ||
| 2760 | |||
diff --git a/drivers/usb/gadget/fsl_qe_udc.h b/drivers/usb/gadget/fsl_qe_udc.h new file mode 100644 index 000000000000..31b2710882e4 --- /dev/null +++ b/drivers/usb/gadget/fsl_qe_udc.h | |||
| @@ -0,0 +1,437 @@ | |||
| 1 | /* | ||
| 2 | * drivers/usb/gadget/qe_udc.h | ||
| 3 | * | ||
| 4 | * Copyright (C) 2006-2008 Freescale Semiconductor, Inc. All rights reserved. | ||
| 5 | * | ||
| 6 | * Xiaobo Xie <X.Xie@freescale.com> | ||
| 7 | * Li Yang <leoli@freescale.com> | ||
| 8 | * | ||
| 9 | * Description: | ||
| 10 | * Freescale USB device/endpoint management registers | ||
| 11 | * | ||
| 12 | * This program is free software; you can redistribute it and/or modify | ||
| 13 | * it under the terms of the GNU General Public License as published by | ||
| 14 | * the Free Software Foundation; either version 2 of the License, or (at | ||
| 15 | * your option) any later version. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #ifndef __FSL_QE_UDC_H | ||
| 19 | #define __FSL_QE_UDC_H | ||
| 20 | |||
| 21 | /* SoC type */ | ||
| 22 | #define PORT_CPM 0 | ||
| 23 | #define PORT_QE 1 | ||
| 24 | |||
| 25 | #define USB_MAX_ENDPOINTS 4 | ||
| 26 | #define USB_MAX_PIPES USB_MAX_ENDPOINTS | ||
| 27 | #define USB_EP0_MAX_SIZE 64 | ||
| 28 | #define USB_MAX_CTRL_PAYLOAD 0x4000 | ||
| 29 | #define USB_BDRING_LEN 16 | ||
| 30 | #define USB_BDRING_LEN_RX 256 | ||
| 31 | #define USB_BDRING_LEN_TX 16 | ||
| 32 | #define MIN_EMPTY_BDS 128 | ||
| 33 | #define MAX_DATA_BDS 8 | ||
| 34 | #define USB_CRC_SIZE 2 | ||
| 35 | #define USB_DIR_BOTH 0x88 | ||
| 36 | #define R_BUF_MAXSIZE 0x800 | ||
| 37 | #define USB_EP_PARA_ALIGNMENT 32 | ||
| 38 | |||
| 39 | /* USB Mode Register bit define */ | ||
| 40 | #define USB_MODE_EN 0x01 | ||
| 41 | #define USB_MODE_HOST 0x02 | ||
| 42 | #define USB_MODE_TEST 0x04 | ||
| 43 | #define USB_MODE_SFTE 0x08 | ||
| 44 | #define USB_MODE_RESUME 0x40 | ||
| 45 | #define USB_MODE_LSS 0x80 | ||
| 46 | |||
| 47 | /* USB Slave Address Register Mask */ | ||
| 48 | #define USB_SLVADDR_MASK 0x7F | ||
| 49 | |||
| 50 | /* USB Endpoint register define */ | ||
| 51 | #define USB_EPNUM_MASK 0xF000 | ||
| 52 | #define USB_EPNUM_SHIFT 12 | ||
| 53 | |||
| 54 | #define USB_TRANS_MODE_SHIFT 8 | ||
| 55 | #define USB_TRANS_CTR 0x0000 | ||
| 56 | #define USB_TRANS_INT 0x0100 | ||
| 57 | #define USB_TRANS_BULK 0x0200 | ||
| 58 | #define USB_TRANS_ISO 0x0300 | ||
| 59 | |||
| 60 | #define USB_EP_MF 0x0020 | ||
| 61 | #define USB_EP_RTE 0x0010 | ||
| 62 | |||
| 63 | #define USB_THS_SHIFT 2 | ||
| 64 | #define USB_THS_MASK 0x000c | ||
| 65 | #define USB_THS_NORMAL 0x0 | ||
| 66 | #define USB_THS_IGNORE_IN 0x0004 | ||
| 67 | #define USB_THS_NACK 0x0008 | ||
| 68 | #define USB_THS_STALL 0x000c | ||
| 69 | |||
| 70 | #define USB_RHS_SHIFT 0 | ||
| 71 | #define USB_RHS_MASK 0x0003 | ||
| 72 | #define USB_RHS_NORMAL 0x0 | ||
| 73 | #define USB_RHS_IGNORE_OUT 0x0001 | ||
| 74 | #define USB_RHS_NACK 0x0002 | ||
| 75 | #define USB_RHS_STALL 0x0003 | ||
| 76 | |||
| 77 | #define USB_RTHS_MASK 0x000f | ||
| 78 | |||
| 79 | /* USB Command Register define */ | ||
| 80 | #define USB_CMD_STR_FIFO 0x80 | ||
| 81 | #define USB_CMD_FLUSH_FIFO 0x40 | ||
| 82 | #define USB_CMD_ISFT 0x20 | ||
| 83 | #define USB_CMD_DSFT 0x10 | ||
| 84 | #define USB_CMD_EP_MASK 0x03 | ||
| 85 | |||
| 86 | /* USB Event and Mask Register define */ | ||
| 87 | #define USB_E_MSF_MASK 0x0800 | ||
| 88 | #define USB_E_SFT_MASK 0x0400 | ||
| 89 | #define USB_E_RESET_MASK 0x0200 | ||
| 90 | #define USB_E_IDLE_MASK 0x0100 | ||
| 91 | #define USB_E_TXE4_MASK 0x0080 | ||
| 92 | #define USB_E_TXE3_MASK 0x0040 | ||
| 93 | #define USB_E_TXE2_MASK 0x0020 | ||
| 94 | #define USB_E_TXE1_MASK 0x0010 | ||
| 95 | #define USB_E_SOF_MASK 0x0008 | ||
| 96 | #define USB_E_BSY_MASK 0x0004 | ||
| 97 | #define USB_E_TXB_MASK 0x0002 | ||
| 98 | #define USB_E_RXB_MASK 0x0001 | ||
| 99 | #define USBER_ALL_CLEAR 0x0fff | ||
| 100 | |||
| 101 | #define USB_E_DEFAULT_DEVICE (USB_E_RESET_MASK | USB_E_TXE4_MASK | \ | ||
| 102 | USB_E_TXE3_MASK | USB_E_TXE2_MASK | \ | ||
| 103 | USB_E_TXE1_MASK | USB_E_BSY_MASK | \ | ||
| 104 | USB_E_TXB_MASK | USB_E_RXB_MASK) | ||
| 105 | |||
| 106 | #define USB_E_TXE_MASK (USB_E_TXE4_MASK | USB_E_TXE3_MASK|\ | ||
| 107 | USB_E_TXE2_MASK | USB_E_TXE1_MASK) | ||
| 108 | /* USB Status Register define */ | ||
| 109 | #define USB_IDLE_STATUS_MASK 0x01 | ||
| 110 | |||
| 111 | /* USB Start of Frame Timer */ | ||
| 112 | #define USB_USSFT_MASK 0x3FFF | ||
| 113 | |||
| 114 | /* USB Frame Number Register */ | ||
| 115 | #define USB_USFRN_MASK 0xFFFF | ||
| 116 | |||
| 117 | struct usb_device_para{ | ||
| 118 | u16 epptr[4]; | ||
| 119 | u32 rstate; | ||
| 120 | u32 rptr; | ||
| 121 | u16 frame_n; | ||
| 122 | u16 rbcnt; | ||
| 123 | u32 rtemp; | ||
| 124 | u32 rxusb_data; | ||
| 125 | u16 rxuptr; | ||
| 126 | u8 reso[2]; | ||
| 127 | u32 softbl; | ||
| 128 | u8 sofucrctemp; | ||
| 129 | }; | ||
| 130 | |||
| 131 | struct usb_ep_para{ | ||
| 132 | u16 rbase; | ||
| 133 | u16 tbase; | ||
| 134 | u8 rbmr; | ||
| 135 | u8 tbmr; | ||
| 136 | u16 mrblr; | ||
| 137 | u16 rbptr; | ||
| 138 | u16 tbptr; | ||
| 139 | u32 tstate; | ||
| 140 | u32 tptr; | ||
| 141 | u16 tcrc; | ||
| 142 | u16 tbcnt; | ||
| 143 | u32 ttemp; | ||
| 144 | u16 txusbu_ptr; | ||
| 145 | u8 reserve[2]; | ||
| 146 | }; | ||
| 147 | |||
| 148 | #define USB_BUSMODE_GBL 0x20 | ||
| 149 | #define USB_BUSMODE_BO_MASK 0x18 | ||
| 150 | #define USB_BUSMODE_BO_SHIFT 0x3 | ||
| 151 | #define USB_BUSMODE_BE 0x2 | ||
| 152 | #define USB_BUSMODE_CETM 0x04 | ||
| 153 | #define USB_BUSMODE_DTB 0x02 | ||
| 154 | |||
| 155 | /* Endpoint basic handle */ | ||
| 156 | #define ep_index(EP) ((EP)->desc->bEndpointAddress & 0xF) | ||
| 157 | #define ep_maxpacket(EP) ((EP)->ep.maxpacket) | ||
| 158 | #define ep_is_in(EP) ((ep_index(EP) == 0) ? (EP->udc->ep0_dir == \ | ||
| 159 | USB_DIR_IN) : ((EP)->desc->bEndpointAddress \ | ||
| 160 | & USB_DIR_IN) == USB_DIR_IN) | ||
| 161 | |||
| 162 | /* ep0 transfer state */ | ||
| 163 | #define WAIT_FOR_SETUP 0 | ||
| 164 | #define DATA_STATE_XMIT 1 | ||
| 165 | #define DATA_STATE_NEED_ZLP 2 | ||
| 166 | #define WAIT_FOR_OUT_STATUS 3 | ||
| 167 | #define DATA_STATE_RECV 4 | ||
| 168 | |||
| 169 | /* ep tramsfer mode */ | ||
| 170 | #define USBP_TM_CTL 0 | ||
| 171 | #define USBP_TM_ISO 1 | ||
| 172 | #define USBP_TM_BULK 2 | ||
| 173 | #define USBP_TM_INT 3 | ||
| 174 | |||
| 175 | /*----------------------------------------------------------------------------- | ||
| 176 | USB RX And TX DATA Frame | ||
| 177 | -----------------------------------------------------------------------------*/ | ||
| 178 | struct qe_frame{ | ||
| 179 | u8 *data; | ||
| 180 | u32 len; | ||
| 181 | u32 status; | ||
| 182 | u32 info; | ||
| 183 | |||
| 184 | void *privdata; | ||
| 185 | struct list_head node; | ||
| 186 | }; | ||
| 187 | |||
| 188 | /* Frame structure, info field. */ | ||
| 189 | #define PID_DATA0 0x80000000 /* Data toggle zero */ | ||
| 190 | #define PID_DATA1 0x40000000 /* Data toggle one */ | ||
| 191 | #define PID_SETUP 0x20000000 /* setup bit */ | ||
| 192 | #define SETUP_STATUS 0x10000000 /* setup status bit */ | ||
| 193 | #define SETADDR_STATUS 0x08000000 /* setupup address status bit */ | ||
| 194 | #define NO_REQ 0x04000000 /* Frame without request */ | ||
| 195 | #define HOST_DATA 0x02000000 /* Host data frame */ | ||
| 196 | #define FIRST_PACKET_IN_FRAME 0x01000000 /* first packet in the frame */ | ||
| 197 | #define TOKEN_FRAME 0x00800000 /* Host token frame */ | ||
| 198 | #define ZLP 0x00400000 /* Zero length packet */ | ||
| 199 | #define IN_TOKEN_FRAME 0x00200000 /* In token package */ | ||
| 200 | #define OUT_TOKEN_FRAME 0x00100000 /* Out token package */ | ||
| 201 | #define SETUP_TOKEN_FRAME 0x00080000 /* Setup token package */ | ||
| 202 | #define STALL_FRAME 0x00040000 /* Stall handshake */ | ||
| 203 | #define NACK_FRAME 0x00020000 /* Nack handshake */ | ||
| 204 | #define NO_PID 0x00010000 /* No send PID */ | ||
| 205 | #define NO_CRC 0x00008000 /* No send CRC */ | ||
| 206 | #define HOST_COMMAND 0x00004000 /* Host command frame */ | ||
| 207 | |||
| 208 | /* Frame status field */ | ||
| 209 | /* Receive side */ | ||
| 210 | #define FRAME_OK 0x00000000 /* Frame tranmitted or received OK */ | ||
| 211 | #define FRAME_ERROR 0x80000000 /* Error occured on frame */ | ||
| 212 | #define START_FRAME_LOST 0x40000000 /* START_FRAME_LOST */ | ||
| 213 | #define END_FRAME_LOST 0x20000000 /* END_FRAME_LOST */ | ||
| 214 | #define RX_ER_NONOCT 0x10000000 /* Rx Non Octet Aligned Packet */ | ||
| 215 | #define RX_ER_BITSTUFF 0x08000000 /* Frame Aborted --Received packet | ||
| 216 | with bit stuff error */ | ||
| 217 | #define RX_ER_CRC 0x04000000 /* Received packet with CRC error */ | ||
| 218 | #define RX_ER_OVERUN 0x02000000 /* Over-run occured on reception */ | ||
| 219 | #define RX_ER_PID 0x01000000 /* Wrong PID received */ | ||
| 220 | /* Tranmit side */ | ||
| 221 | #define TX_ER_NAK 0x00800000 /* Received NAK handshake */ | ||
| 222 | #define TX_ER_STALL 0x00400000 /* Received STALL handshake */ | ||
| 223 | #define TX_ER_TIMEOUT 0x00200000 /* Transmit time out */ | ||
| 224 | #define TX_ER_UNDERUN 0x00100000 /* Transmit underrun */ | ||
| 225 | #define FRAME_INPROGRESS 0x00080000 /* Frame is being transmitted */ | ||
| 226 | #define ER_DATA_UNDERUN 0x00040000 /* Frame is shorter then expected */ | ||
| 227 | #define ER_DATA_OVERUN 0x00020000 /* Frame is longer then expected */ | ||
| 228 | |||
| 229 | /* QE USB frame operation functions */ | ||
| 230 | #define frame_get_length(frm) (frm->len) | ||
| 231 | #define frame_set_length(frm, leng) (frm->len = leng) | ||
| 232 | #define frame_get_data(frm) (frm->data) | ||
| 233 | #define frame_set_data(frm, dat) (frm->data = dat) | ||
| 234 | #define frame_get_info(frm) (frm->info) | ||
| 235 | #define frame_set_info(frm, inf) (frm->info = inf) | ||
| 236 | #define frame_get_status(frm) (frm->status) | ||
| 237 | #define frame_set_status(frm, stat) (frm->status = stat) | ||
| 238 | #define frame_get_privdata(frm) (frm->privdata) | ||
| 239 | #define frame_set_privdata(frm, dat) (frm->privdata = dat) | ||
| 240 | |||
| 241 | static inline void qe_frame_clean(struct qe_frame *frm) | ||
| 242 | { | ||
| 243 | frame_set_data(frm, NULL); | ||
| 244 | frame_set_length(frm, 0); | ||
| 245 | frame_set_status(frm, FRAME_OK); | ||
| 246 | frame_set_info(frm, 0); | ||
| 247 | frame_set_privdata(frm, NULL); | ||
| 248 | } | ||
| 249 | |||
| 250 | static inline void qe_frame_init(struct qe_frame *frm) | ||
| 251 | { | ||
| 252 | qe_frame_clean(frm); | ||
| 253 | INIT_LIST_HEAD(&(frm->node)); | ||
| 254 | } | ||
| 255 | |||
| 256 | struct qe_req { | ||
| 257 | struct usb_request req; | ||
| 258 | struct list_head queue; | ||
| 259 | /* ep_queue() func will add | ||
| 260 | a request->queue into a udc_ep->queue 'd tail */ | ||
| 261 | struct qe_ep *ep; | ||
| 262 | unsigned mapped:1; | ||
| 263 | }; | ||
| 264 | |||
| 265 | struct qe_ep { | ||
| 266 | struct usb_ep ep; | ||
| 267 | struct list_head queue; | ||
| 268 | struct qe_udc *udc; | ||
| 269 | const struct usb_endpoint_descriptor *desc; | ||
| 270 | struct usb_gadget *gadget; | ||
| 271 | |||
| 272 | u8 state; | ||
| 273 | |||
| 274 | struct qe_bd __iomem *rxbase; | ||
| 275 | struct qe_bd __iomem *n_rxbd; | ||
| 276 | struct qe_bd __iomem *e_rxbd; | ||
| 277 | |||
| 278 | struct qe_bd __iomem *txbase; | ||
| 279 | struct qe_bd __iomem *n_txbd; | ||
| 280 | struct qe_bd __iomem *c_txbd; | ||
| 281 | |||
| 282 | struct qe_frame *rxframe; | ||
| 283 | u8 *rxbuffer; | ||
| 284 | dma_addr_t rxbuf_d; | ||
| 285 | u8 rxbufmap; | ||
| 286 | unsigned char localnack; | ||
| 287 | int has_data; | ||
| 288 | |||
| 289 | struct qe_frame *txframe; | ||
| 290 | struct qe_req *tx_req; | ||
| 291 | int sent; /*data already sent */ | ||
| 292 | int last; /*data sent in the last time*/ | ||
| 293 | |||
| 294 | u8 dir; | ||
| 295 | u8 epnum; | ||
| 296 | u8 tm; /* transfer mode */ | ||
| 297 | u8 data01; | ||
| 298 | u8 init; | ||
| 299 | |||
| 300 | u8 already_seen; | ||
| 301 | u8 enable_tasklet; | ||
| 302 | u8 setup_stage; | ||
| 303 | u32 last_io; /* timestamp */ | ||
| 304 | |||
| 305 | char name[14]; | ||
| 306 | |||
| 307 | unsigned double_buf:1; | ||
| 308 | unsigned stopped:1; | ||
| 309 | unsigned fnf:1; | ||
| 310 | unsigned has_dma:1; | ||
| 311 | |||
| 312 | u8 ackwait; | ||
| 313 | u8 dma_channel; | ||
| 314 | u16 dma_counter; | ||
| 315 | int lch; | ||
| 316 | |||
| 317 | struct timer_list timer; | ||
| 318 | }; | ||
| 319 | |||
| 320 | struct qe_udc { | ||
| 321 | struct usb_gadget gadget; | ||
| 322 | struct usb_gadget_driver *driver; | ||
| 323 | struct device *dev; | ||
| 324 | struct qe_ep eps[USB_MAX_ENDPOINTS]; | ||
| 325 | struct usb_ctrlrequest local_setup_buff; | ||
| 326 | spinlock_t lock; /* lock for set/config qe_udc */ | ||
| 327 | unsigned long soc_type; /* QE or CPM soc */ | ||
| 328 | |||
| 329 | struct qe_req *status_req; /* ep0 status request */ | ||
| 330 | |||
| 331 | /* USB and EP Parameter Block pointer */ | ||
| 332 | struct usb_device_para __iomem *usb_param; | ||
| 333 | struct usb_ep_para __iomem *ep_param[4]; | ||
| 334 | |||
| 335 | u32 max_pipes; /* Device max pipes */ | ||
| 336 | u32 max_use_endpts; /* Max endpointes to be used */ | ||
| 337 | u32 bus_reset; /* Device is bus reseting */ | ||
| 338 | u32 resume_state; /* USB state to resume*/ | ||
| 339 | u32 usb_state; /* USB current state */ | ||
| 340 | u32 usb_next_state; /* USB next state */ | ||
| 341 | u32 ep0_state; /* Enpoint zero state */ | ||
| 342 | u32 ep0_dir; /* Enpoint zero direction: can be | ||
| 343 | USB_DIR_IN or USB_DIR_OUT*/ | ||
| 344 | u32 usb_sof_count; /* SOF count */ | ||
| 345 | u32 errors; /* USB ERRORs count */ | ||
| 346 | |||
| 347 | u8 *tmpbuf; | ||
| 348 | u32 c_start; | ||
| 349 | u32 c_end; | ||
| 350 | |||
| 351 | u8 *nullbuf; | ||
| 352 | u8 *statusbuf; | ||
| 353 | dma_addr_t nullp; | ||
| 354 | u8 nullmap; | ||
| 355 | u8 device_address; /* Device USB address */ | ||
| 356 | |||
| 357 | unsigned int usb_clock; | ||
| 358 | unsigned int usb_irq; | ||
| 359 | struct usb_ctlr __iomem *usb_regs; | ||
| 360 | |||
| 361 | struct tasklet_struct rx_tasklet; | ||
| 362 | |||
| 363 | struct completion *done; /* to make sure release() is done */ | ||
| 364 | }; | ||
| 365 | |||
| 366 | #define EP_STATE_IDLE 0 | ||
| 367 | #define EP_STATE_NACK 1 | ||
| 368 | #define EP_STATE_STALL 2 | ||
| 369 | |||
| 370 | /* | ||
| 371 | * transmit BD's status | ||
| 372 | */ | ||
| 373 | #define T_R 0x80000000 /* ready bit */ | ||
| 374 | #define T_W 0x20000000 /* wrap bit */ | ||
| 375 | #define T_I 0x10000000 /* interrupt on completion */ | ||
| 376 | #define T_L 0x08000000 /* last */ | ||
| 377 | #define T_TC 0x04000000 /* transmit CRC */ | ||
| 378 | #define T_CNF 0x02000000 /* wait for transmit confirm */ | ||
| 379 | #define T_LSP 0x01000000 /* Low-speed transaction */ | ||
| 380 | #define T_PID 0x00c00000 /* packet id */ | ||
| 381 | #define T_NAK 0x00100000 /* No ack. */ | ||
| 382 | #define T_STAL 0x00080000 /* Stall recieved */ | ||
| 383 | #define T_TO 0x00040000 /* time out */ | ||
| 384 | #define T_UN 0x00020000 /* underrun */ | ||
| 385 | |||
| 386 | #define DEVICE_T_ERROR (T_UN | T_TO) | ||
| 387 | #define HOST_T_ERROR (T_UN | T_TO | T_NAK | T_STAL) | ||
| 388 | #define DEVICE_T_BD_MASK DEVICE_T_ERROR | ||
| 389 | #define HOST_T_BD_MASK HOST_T_ERROR | ||
| 390 | |||
| 391 | #define T_PID_SHIFT 6 | ||
| 392 | #define T_PID_DATA0 0x00800000 /* Data 0 toggle */ | ||
| 393 | #define T_PID_DATA1 0x00c00000 /* Data 1 toggle */ | ||
| 394 | |||
| 395 | /* | ||
| 396 | * receive BD's status | ||
| 397 | */ | ||
| 398 | #define R_E 0x80000000 /* buffer empty */ | ||
| 399 | #define R_W 0x20000000 /* wrap bit */ | ||
| 400 | #define R_I 0x10000000 /* interrupt on reception */ | ||
| 401 | #define R_L 0x08000000 /* last */ | ||
| 402 | #define R_F 0x04000000 /* first */ | ||
| 403 | #define R_PID 0x00c00000 /* packet id */ | ||
| 404 | #define R_NO 0x00100000 /* Rx Non Octet Aligned Packet */ | ||
| 405 | #define R_AB 0x00080000 /* Frame Aborted */ | ||
| 406 | #define R_CR 0x00040000 /* CRC Error */ | ||
| 407 | #define R_OV 0x00020000 /* Overrun */ | ||
| 408 | |||
| 409 | #define R_ERROR (R_NO | R_AB | R_CR | R_OV) | ||
| 410 | #define R_BD_MASK R_ERROR | ||
| 411 | |||
| 412 | #define R_PID_DATA0 0x00000000 | ||
| 413 | #define R_PID_DATA1 0x00400000 | ||
| 414 | #define R_PID_SETUP 0x00800000 | ||
| 415 | |||
| 416 | #define CPM_USB_STOP_TX 0x2e600000 | ||
| 417 | #define CPM_USB_RESTART_TX 0x2e600000 | ||
| 418 | #define CPM_USB_STOP_TX_OPCODE 0x0a | ||
| 419 | #define CPM_USB_RESTART_TX_OPCODE 0x0b | ||
| 420 | #define CPM_USB_EP_SHIFT 5 | ||
| 421 | |||
| 422 | #ifndef CONFIG_CPM | ||
| 423 | inline int cpm_command(u32 command, u8 opcode) | ||
| 424 | { | ||
| 425 | return -EOPNOTSUPP; | ||
| 426 | } | ||
| 427 | #endif | ||
| 428 | |||
| 429 | #ifndef CONFIG_QUICC_ENGINE | ||
| 430 | inline int qe_issue_cmd(u32 cmd, u32 device, u8 mcn_protocol, | ||
| 431 | u32 cmd_input) | ||
| 432 | { | ||
| 433 | return -EOPNOTSUPP; | ||
| 434 | } | ||
| 435 | #endif | ||
| 436 | |||
| 437 | #endif /* __FSL_QE_UDC_H */ | ||
diff --git a/drivers/usb/gadget/fsl_usb2_udc.c b/drivers/usb/gadget/fsl_usb2_udc.c index 45ad556169f1..091bb55c9aa7 100644 --- a/drivers/usb/gadget/fsl_usb2_udc.c +++ b/drivers/usb/gadget/fsl_usb2_udc.c | |||
| @@ -23,11 +23,8 @@ | |||
| 23 | #include <linux/ioport.h> | 23 | #include <linux/ioport.h> |
| 24 | #include <linux/types.h> | 24 | #include <linux/types.h> |
| 25 | #include <linux/errno.h> | 25 | #include <linux/errno.h> |
| 26 | #include <linux/delay.h> | ||
| 27 | #include <linux/sched.h> | ||
| 28 | #include <linux/slab.h> | 26 | #include <linux/slab.h> |
| 29 | #include <linux/init.h> | 27 | #include <linux/init.h> |
| 30 | #include <linux/timer.h> | ||
| 31 | #include <linux/list.h> | 28 | #include <linux/list.h> |
| 32 | #include <linux/interrupt.h> | 29 | #include <linux/interrupt.h> |
| 33 | #include <linux/proc_fs.h> | 30 | #include <linux/proc_fs.h> |
| @@ -44,11 +41,9 @@ | |||
| 44 | 41 | ||
| 45 | #include <asm/byteorder.h> | 42 | #include <asm/byteorder.h> |
| 46 | #include <asm/io.h> | 43 | #include <asm/io.h> |
| 47 | #include <asm/irq.h> | ||
| 48 | #include <asm/system.h> | 44 | #include <asm/system.h> |
| 49 | #include <asm/unaligned.h> | 45 | #include <asm/unaligned.h> |
| 50 | #include <asm/dma.h> | 46 | #include <asm/dma.h> |
| 51 | #include <asm/cacheflush.h> | ||
| 52 | 47 | ||
| 53 | #include "fsl_usb2_udc.h" | 48 | #include "fsl_usb2_udc.h" |
| 54 | 49 | ||
| @@ -61,8 +56,8 @@ | |||
| 61 | static const char driver_name[] = "fsl-usb2-udc"; | 56 | static const char driver_name[] = "fsl-usb2-udc"; |
| 62 | static const char driver_desc[] = DRIVER_DESC; | 57 | static const char driver_desc[] = DRIVER_DESC; |
| 63 | 58 | ||
| 64 | volatile static struct usb_dr_device *dr_regs = NULL; | 59 | static struct usb_dr_device *dr_regs; |
| 65 | volatile static struct usb_sys_interface *usb_sys_regs = NULL; | 60 | static struct usb_sys_interface *usb_sys_regs; |
| 66 | 61 | ||
| 67 | /* it is initialized in probe() */ | 62 | /* it is initialized in probe() */ |
| 68 | static struct fsl_udc *udc_controller = NULL; | 63 | static struct fsl_udc *udc_controller = NULL; |
| @@ -76,16 +71,14 @@ fsl_ep0_desc = { | |||
| 76 | .wMaxPacketSize = USB_MAX_CTRL_PAYLOAD, | 71 | .wMaxPacketSize = USB_MAX_CTRL_PAYLOAD, |
| 77 | }; | 72 | }; |
| 78 | 73 | ||
| 79 | static int fsl_udc_suspend(struct platform_device *pdev, pm_message_t state); | ||
| 80 | static int fsl_udc_resume(struct platform_device *pdev); | ||
| 81 | static void fsl_ep_fifo_flush(struct usb_ep *_ep); | 74 | static void fsl_ep_fifo_flush(struct usb_ep *_ep); |
| 82 | 75 | ||
| 83 | #ifdef CONFIG_PPC32 | 76 | #ifdef CONFIG_PPC32 |
| 84 | #define fsl_readl(addr) in_le32(addr) | 77 | #define fsl_readl(addr) in_le32(addr) |
| 85 | #define fsl_writel(addr, val32) out_le32(val32, addr) | 78 | #define fsl_writel(val32, addr) out_le32(addr, val32) |
| 86 | #else | 79 | #else |
| 87 | #define fsl_readl(addr) readl(addr) | 80 | #define fsl_readl(addr) readl(addr) |
| 88 | #define fsl_writel(addr, val32) writel(addr, val32) | 81 | #define fsl_writel(val32, addr) writel(val32, addr) |
| 89 | #endif | 82 | #endif |
| 90 | 83 | ||
| 91 | /******************************************************************** | 84 | /******************************************************************** |
| @@ -185,10 +178,6 @@ static int dr_controller_setup(struct fsl_udc *udc) | |||
| 185 | unsigned long timeout; | 178 | unsigned long timeout; |
| 186 | #define FSL_UDC_RESET_TIMEOUT 1000 | 179 | #define FSL_UDC_RESET_TIMEOUT 1000 |
| 187 | 180 | ||
| 188 | /* before here, make sure dr_regs has been initialized */ | ||
| 189 | if (!udc) | ||
| 190 | return -EINVAL; | ||
| 191 | |||
| 192 | /* Stop and reset the usb controller */ | 181 | /* Stop and reset the usb controller */ |
| 193 | tmp = fsl_readl(&dr_regs->usbcmd); | 182 | tmp = fsl_readl(&dr_regs->usbcmd); |
| 194 | tmp &= ~USB_CMD_RUN_STOP; | 183 | tmp &= ~USB_CMD_RUN_STOP; |
| @@ -202,7 +191,7 @@ static int dr_controller_setup(struct fsl_udc *udc) | |||
| 202 | timeout = jiffies + FSL_UDC_RESET_TIMEOUT; | 191 | timeout = jiffies + FSL_UDC_RESET_TIMEOUT; |
| 203 | while (fsl_readl(&dr_regs->usbcmd) & USB_CMD_CTRL_RESET) { | 192 | while (fsl_readl(&dr_regs->usbcmd) & USB_CMD_CTRL_RESET) { |
| 204 | if (time_after(jiffies, timeout)) { | 193 | if (time_after(jiffies, timeout)) { |
| 205 | ERR("udc reset timeout! \n"); | 194 | ERR("udc reset timeout!\n"); |
| 206 | return -ETIMEDOUT; | 195 | return -ETIMEDOUT; |
| 207 | } | 196 | } |
| 208 | cpu_relax(); | 197 | cpu_relax(); |
| @@ -315,7 +304,8 @@ static void dr_controller_stop(struct fsl_udc *udc) | |||
| 315 | return; | 304 | return; |
| 316 | } | 305 | } |
| 317 | 306 | ||
| 318 | void dr_ep_setup(unsigned char ep_num, unsigned char dir, unsigned char ep_type) | 307 | static void dr_ep_setup(unsigned char ep_num, unsigned char dir, |
| 308 | unsigned char ep_type) | ||
| 319 | { | 309 | { |
| 320 | unsigned int tmp_epctrl = 0; | 310 | unsigned int tmp_epctrl = 0; |
| 321 | 311 | ||
| @@ -563,7 +553,7 @@ static int fsl_ep_disable(struct usb_ep *_ep) | |||
| 563 | /* nuke all pending requests (does flush) */ | 553 | /* nuke all pending requests (does flush) */ |
| 564 | nuke(ep, -ESHUTDOWN); | 554 | nuke(ep, -ESHUTDOWN); |
| 565 | 555 | ||
| 566 | ep->desc = 0; | 556 | ep->desc = NULL; |
| 567 | ep->stopped = 1; | 557 | ep->stopped = 1; |
| 568 | spin_unlock_irqrestore(&udc->lock, flags); | 558 | spin_unlock_irqrestore(&udc->lock, flags); |
| 569 | 559 | ||
| @@ -602,7 +592,7 @@ static void fsl_free_request(struct usb_ep *_ep, struct usb_request *_req) | |||
| 602 | } | 592 | } |
| 603 | 593 | ||
| 604 | /*-------------------------------------------------------------------------*/ | 594 | /*-------------------------------------------------------------------------*/ |
| 605 | static int fsl_queue_td(struct fsl_ep *ep, struct fsl_req *req) | 595 | static void fsl_queue_td(struct fsl_ep *ep, struct fsl_req *req) |
| 606 | { | 596 | { |
| 607 | int i = ep_index(ep) * 2 + ep_is_in(ep); | 597 | int i = ep_index(ep) * 2 + ep_is_in(ep); |
| 608 | u32 temp, bitmask, tmp_stat; | 598 | u32 temp, bitmask, tmp_stat; |
| @@ -653,13 +643,16 @@ static int fsl_queue_td(struct fsl_ep *ep, struct fsl_req *req) | |||
| 653 | | EP_QUEUE_HEAD_STATUS_HALT)); | 643 | | EP_QUEUE_HEAD_STATUS_HALT)); |
| 654 | dQH->size_ioc_int_sts &= temp; | 644 | dQH->size_ioc_int_sts &= temp; |
| 655 | 645 | ||
| 646 | /* Ensure that updates to the QH will occure before priming. */ | ||
| 647 | wmb(); | ||
| 648 | |||
| 656 | /* Prime endpoint by writing 1 to ENDPTPRIME */ | 649 | /* Prime endpoint by writing 1 to ENDPTPRIME */ |
| 657 | temp = ep_is_in(ep) | 650 | temp = ep_is_in(ep) |
| 658 | ? (1 << (ep_index(ep) + 16)) | 651 | ? (1 << (ep_index(ep) + 16)) |
| 659 | : (1 << (ep_index(ep))); | 652 | : (1 << (ep_index(ep))); |
| 660 | fsl_writel(temp, &dr_regs->endpointprime); | 653 | fsl_writel(temp, &dr_regs->endpointprime); |
| 661 | out: | 654 | out: |
| 662 | return 0; | 655 | return; |
| 663 | } | 656 | } |
| 664 | 657 | ||
| 665 | /* Fill in the dTD structure | 658 | /* Fill in the dTD structure |
| @@ -710,7 +703,7 @@ static struct ep_td_struct *fsl_build_dtd(struct fsl_req *req, unsigned *length, | |||
| 710 | *is_last = 0; | 703 | *is_last = 0; |
| 711 | 704 | ||
| 712 | if ((*is_last) == 0) | 705 | if ((*is_last) == 0) |
| 713 | VDBG("multi-dtd request!\n"); | 706 | VDBG("multi-dtd request!"); |
| 714 | /* Fill in the transfer size; set active bit */ | 707 | /* Fill in the transfer size; set active bit */ |
| 715 | swap_temp = ((*length << DTD_LENGTH_BIT_POS) | DTD_STATUS_ACTIVE); | 708 | swap_temp = ((*length << DTD_LENGTH_BIT_POS) | DTD_STATUS_ACTIVE); |
| 716 | 709 | ||
| @@ -773,11 +766,11 @@ fsl_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags) | |||
| 773 | /* catch various bogus parameters */ | 766 | /* catch various bogus parameters */ |
| 774 | if (!_req || !req->req.complete || !req->req.buf | 767 | if (!_req || !req->req.complete || !req->req.buf |
| 775 | || !list_empty(&req->queue)) { | 768 | || !list_empty(&req->queue)) { |
| 776 | VDBG("%s, bad params\n", __func__); | 769 | VDBG("%s, bad params", __func__); |
| 777 | return -EINVAL; | 770 | return -EINVAL; |
| 778 | } | 771 | } |
| 779 | if (unlikely(!_ep || !ep->desc)) { | 772 | if (unlikely(!_ep || !ep->desc)) { |
| 780 | VDBG("%s, bad ep\n", __func__); | 773 | VDBG("%s, bad ep", __func__); |
| 781 | return -EINVAL; | 774 | return -EINVAL; |
| 782 | } | 775 | } |
| 783 | if (ep->desc->bmAttributes == USB_ENDPOINT_XFER_ISOC) { | 776 | if (ep->desc->bmAttributes == USB_ENDPOINT_XFER_ISOC) { |
| @@ -1069,7 +1062,7 @@ static int fsl_vbus_session(struct usb_gadget *gadget, int is_active) | |||
| 1069 | 1062 | ||
| 1070 | udc = container_of(gadget, struct fsl_udc, gadget); | 1063 | udc = container_of(gadget, struct fsl_udc, gadget); |
| 1071 | spin_lock_irqsave(&udc->lock, flags); | 1064 | spin_lock_irqsave(&udc->lock, flags); |
| 1072 | VDBG("VBUS %s\n", is_active ? "on" : "off"); | 1065 | VDBG("VBUS %s", is_active ? "on" : "off"); |
| 1073 | udc->vbus_active = (is_active != 0); | 1066 | udc->vbus_active = (is_active != 0); |
| 1074 | if (can_pullup(udc)) | 1067 | if (can_pullup(udc)) |
| 1075 | fsl_writel((fsl_readl(&dr_regs->usbcmd) | USB_CMD_RUN_STOP), | 1068 | fsl_writel((fsl_readl(&dr_regs->usbcmd) | USB_CMD_RUN_STOP), |
| @@ -1146,7 +1139,6 @@ static int ep0_prime_status(struct fsl_udc *udc, int direction) | |||
| 1146 | { | 1139 | { |
| 1147 | struct fsl_req *req = udc->status_req; | 1140 | struct fsl_req *req = udc->status_req; |
| 1148 | struct fsl_ep *ep; | 1141 | struct fsl_ep *ep; |
| 1149 | int status = 0; | ||
| 1150 | 1142 | ||
| 1151 | if (direction == EP_DIR_IN) | 1143 | if (direction == EP_DIR_IN) |
| 1152 | udc->ep0_dir = USB_DIR_IN; | 1144 | udc->ep0_dir = USB_DIR_IN; |
| @@ -1164,27 +1156,21 @@ static int ep0_prime_status(struct fsl_udc *udc, int direction) | |||
| 1164 | req->dtd_count = 0; | 1156 | req->dtd_count = 0; |
| 1165 | 1157 | ||
| 1166 | if (fsl_req_to_dtd(req) == 0) | 1158 | if (fsl_req_to_dtd(req) == 0) |
| 1167 | status = fsl_queue_td(ep, req); | 1159 | fsl_queue_td(ep, req); |
| 1168 | else | 1160 | else |
| 1169 | return -ENOMEM; | 1161 | return -ENOMEM; |
| 1170 | 1162 | ||
| 1171 | if (status) | ||
| 1172 | ERR("Can't queue ep0 status request \n"); | ||
| 1173 | list_add_tail(&req->queue, &ep->queue); | 1163 | list_add_tail(&req->queue, &ep->queue); |
| 1174 | 1164 | ||
| 1175 | return status; | 1165 | return 0; |
| 1176 | } | 1166 | } |
| 1177 | 1167 | ||
| 1178 | static inline int udc_reset_ep_queue(struct fsl_udc *udc, u8 pipe) | 1168 | static void udc_reset_ep_queue(struct fsl_udc *udc, u8 pipe) |
| 1179 | { | 1169 | { |
| 1180 | struct fsl_ep *ep = get_ep_by_pipe(udc, pipe); | 1170 | struct fsl_ep *ep = get_ep_by_pipe(udc, pipe); |
| 1181 | 1171 | ||
| 1182 | if (!ep->name) | 1172 | if (ep->name) |
| 1183 | return 0; | 1173 | nuke(ep, -ESHUTDOWN); |
| 1184 | |||
| 1185 | nuke(ep, -ESHUTDOWN); | ||
| 1186 | |||
| 1187 | return 0; | ||
| 1188 | } | 1174 | } |
| 1189 | 1175 | ||
| 1190 | /* | 1176 | /* |
| @@ -1208,10 +1194,8 @@ static void ch9getstatus(struct fsl_udc *udc, u8 request_type, u16 value, | |||
| 1208 | u16 index, u16 length) | 1194 | u16 index, u16 length) |
| 1209 | { | 1195 | { |
| 1210 | u16 tmp = 0; /* Status, cpu endian */ | 1196 | u16 tmp = 0; /* Status, cpu endian */ |
| 1211 | |||
| 1212 | struct fsl_req *req; | 1197 | struct fsl_req *req; |
| 1213 | struct fsl_ep *ep; | 1198 | struct fsl_ep *ep; |
| 1214 | int status = 0; | ||
| 1215 | 1199 | ||
| 1216 | ep = &udc->eps[0]; | 1200 | ep = &udc->eps[0]; |
| 1217 | 1201 | ||
| @@ -1250,14 +1234,10 @@ static void ch9getstatus(struct fsl_udc *udc, u8 request_type, u16 value, | |||
| 1250 | 1234 | ||
| 1251 | /* prime the data phase */ | 1235 | /* prime the data phase */ |
| 1252 | if ((fsl_req_to_dtd(req) == 0)) | 1236 | if ((fsl_req_to_dtd(req) == 0)) |
| 1253 | status = fsl_queue_td(ep, req); | 1237 | fsl_queue_td(ep, req); |
| 1254 | else /* no mem */ | 1238 | else /* no mem */ |
| 1255 | goto stall; | 1239 | goto stall; |
| 1256 | 1240 | ||
| 1257 | if (status) { | ||
| 1258 | ERR("Can't respond to getstatus request \n"); | ||
| 1259 | goto stall; | ||
| 1260 | } | ||
| 1261 | list_add_tail(&req->queue, &ep->queue); | 1241 | list_add_tail(&req->queue, &ep->queue); |
| 1262 | udc->ep0_state = DATA_STATE_XMIT; | 1242 | udc->ep0_state = DATA_STATE_XMIT; |
| 1263 | return; | 1243 | return; |
| @@ -1397,7 +1377,7 @@ static void ep0_req_complete(struct fsl_udc *udc, struct fsl_ep *ep0, | |||
| 1397 | udc->ep0_state = WAIT_FOR_SETUP; | 1377 | udc->ep0_state = WAIT_FOR_SETUP; |
| 1398 | break; | 1378 | break; |
| 1399 | case WAIT_FOR_SETUP: | 1379 | case WAIT_FOR_SETUP: |
| 1400 | ERR("Unexpect ep0 packets \n"); | 1380 | ERR("Unexpect ep0 packets\n"); |
| 1401 | break; | 1381 | break; |
| 1402 | default: | 1382 | default: |
| 1403 | ep0stall(udc); | 1383 | ep0stall(udc); |
| @@ -1476,7 +1456,7 @@ static int process_ep_req(struct fsl_udc *udc, int pipe, | |||
| 1476 | status = -EILSEQ; | 1456 | status = -EILSEQ; |
| 1477 | break; | 1457 | break; |
| 1478 | } else | 1458 | } else |
| 1479 | ERR("Unknown error has occured (0x%x)!\r\n", | 1459 | ERR("Unknown error has occured (0x%x)!\n", |
| 1480 | errors); | 1460 | errors); |
| 1481 | 1461 | ||
| 1482 | } else if (le32_to_cpu(curr_td->size_ioc_sts) | 1462 | } else if (le32_to_cpu(curr_td->size_ioc_sts) |
| @@ -1495,7 +1475,7 @@ static int process_ep_req(struct fsl_udc *udc, int pipe, | |||
| 1495 | } | 1475 | } |
| 1496 | } else { | 1476 | } else { |
| 1497 | td_complete++; | 1477 | td_complete++; |
| 1498 | VDBG("dTD transmitted successful "); | 1478 | VDBG("dTD transmitted successful"); |
| 1499 | } | 1479 | } |
| 1500 | 1480 | ||
| 1501 | if (j != curr_req->dtd_count - 1) | 1481 | if (j != curr_req->dtd_count - 1) |
| @@ -1568,9 +1548,6 @@ static void port_change_irq(struct fsl_udc *udc) | |||
| 1568 | { | 1548 | { |
| 1569 | u32 speed; | 1549 | u32 speed; |
| 1570 | 1550 | ||
| 1571 | if (udc->bus_reset) | ||
| 1572 | udc->bus_reset = 0; | ||
| 1573 | |||
| 1574 | /* Bus resetting is finished */ | 1551 | /* Bus resetting is finished */ |
| 1575 | if (!(fsl_readl(&dr_regs->portsc1) & PORTSCX_PORT_RESET)) { | 1552 | if (!(fsl_readl(&dr_regs->portsc1) & PORTSCX_PORT_RESET)) { |
| 1576 | /* Get the speed */ | 1553 | /* Get the speed */ |
| @@ -1678,8 +1655,6 @@ static void reset_irq(struct fsl_udc *udc) | |||
| 1678 | 1655 | ||
| 1679 | if (fsl_readl(&dr_regs->portsc1) & PORTSCX_PORT_RESET) { | 1656 | if (fsl_readl(&dr_regs->portsc1) & PORTSCX_PORT_RESET) { |
| 1680 | VDBG("Bus reset"); | 1657 | VDBG("Bus reset"); |
| 1681 | /* Bus is reseting */ | ||
| 1682 | udc->bus_reset = 1; | ||
| 1683 | /* Reset all the queues, include XD, dTD, EP queue | 1658 | /* Reset all the queues, include XD, dTD, EP queue |
| 1684 | * head and TR Queue */ | 1659 | * head and TR Queue */ |
| 1685 | reset_queues(udc); | 1660 | reset_queues(udc); |
| @@ -1768,7 +1743,7 @@ static irqreturn_t fsl_udc_irq(int irq, void *_udc) | |||
| 1768 | } | 1743 | } |
| 1769 | 1744 | ||
| 1770 | if (irq_src & (USB_STS_ERR | USB_STS_SYS_ERR)) { | 1745 | if (irq_src & (USB_STS_ERR | USB_STS_SYS_ERR)) { |
| 1771 | VDBG("Error IRQ %x ", irq_src); | 1746 | VDBG("Error IRQ %x", irq_src); |
| 1772 | } | 1747 | } |
| 1773 | 1748 | ||
| 1774 | spin_unlock_irqrestore(&udc->lock, flags); | 1749 | spin_unlock_irqrestore(&udc->lock, flags); |
| @@ -1799,7 +1774,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver) | |||
| 1799 | /* lock is needed but whether should use this lock or another */ | 1774 | /* lock is needed but whether should use this lock or another */ |
| 1800 | spin_lock_irqsave(&udc_controller->lock, flags); | 1775 | spin_lock_irqsave(&udc_controller->lock, flags); |
| 1801 | 1776 | ||
| 1802 | driver->driver.bus = 0; | 1777 | driver->driver.bus = NULL; |
| 1803 | /* hook up the driver */ | 1778 | /* hook up the driver */ |
| 1804 | udc_controller->driver = driver; | 1779 | udc_controller->driver = driver; |
| 1805 | udc_controller->gadget.dev.driver = &driver->driver; | 1780 | udc_controller->gadget.dev.driver = &driver->driver; |
| @@ -1809,8 +1784,8 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver) | |||
| 1809 | retval = driver->bind(&udc_controller->gadget); | 1784 | retval = driver->bind(&udc_controller->gadget); |
| 1810 | if (retval) { | 1785 | if (retval) { |
| 1811 | VDBG("bind to %s --> %d", driver->driver.name, retval); | 1786 | VDBG("bind to %s --> %d", driver->driver.name, retval); |
| 1812 | udc_controller->gadget.dev.driver = 0; | 1787 | udc_controller->gadget.dev.driver = NULL; |
| 1813 | udc_controller->driver = 0; | 1788 | udc_controller->driver = NULL; |
| 1814 | goto out; | 1789 | goto out; |
| 1815 | } | 1790 | } |
| 1816 | 1791 | ||
| @@ -1819,12 +1794,12 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver) | |||
| 1819 | udc_controller->usb_state = USB_STATE_ATTACHED; | 1794 | udc_controller->usb_state = USB_STATE_ATTACHED; |
| 1820 | udc_controller->ep0_state = WAIT_FOR_SETUP; | 1795 | udc_controller->ep0_state = WAIT_FOR_SETUP; |
| 1821 | udc_controller->ep0_dir = 0; | 1796 | udc_controller->ep0_dir = 0; |
| 1822 | printk(KERN_INFO "%s: bind to driver %s \n", | 1797 | printk(KERN_INFO "%s: bind to driver %s\n", |
| 1823 | udc_controller->gadget.name, driver->driver.name); | 1798 | udc_controller->gadget.name, driver->driver.name); |
| 1824 | 1799 | ||
| 1825 | out: | 1800 | out: |
| 1826 | if (retval) | 1801 | if (retval) |
| 1827 | printk("retval %d \n", retval); | 1802 | printk("gadget driver register failed %d\n", retval); |
| 1828 | return retval; | 1803 | return retval; |
| 1829 | } | 1804 | } |
| 1830 | EXPORT_SYMBOL(usb_gadget_register_driver); | 1805 | EXPORT_SYMBOL(usb_gadget_register_driver); |
| @@ -1842,7 +1817,7 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) | |||
| 1842 | return -EINVAL; | 1817 | return -EINVAL; |
| 1843 | 1818 | ||
| 1844 | if (udc_controller->transceiver) | 1819 | if (udc_controller->transceiver) |
| 1845 | (void)otg_set_peripheral(udc_controller->transceiver, 0); | 1820 | otg_set_peripheral(udc_controller->transceiver, NULL); |
| 1846 | 1821 | ||
| 1847 | /* stop DR, disable intr */ | 1822 | /* stop DR, disable intr */ |
| 1848 | dr_controller_stop(udc_controller); | 1823 | dr_controller_stop(udc_controller); |
| @@ -1863,10 +1838,10 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) | |||
| 1863 | 1838 | ||
| 1864 | /* unbind gadget and unhook driver. */ | 1839 | /* unbind gadget and unhook driver. */ |
| 1865 | driver->unbind(&udc_controller->gadget); | 1840 | driver->unbind(&udc_controller->gadget); |
| 1866 | udc_controller->gadget.dev.driver = 0; | 1841 | udc_controller->gadget.dev.driver = NULL; |
| 1867 | udc_controller->driver = 0; | 1842 | udc_controller->driver = NULL; |
| 1868 | 1843 | ||
| 1869 | printk("unregistered gadget driver '%s'\r\n", driver->driver.name); | 1844 | printk("unregistered gadget driver '%s'\n", driver->driver.name); |
| 1870 | return 0; | 1845 | return 0; |
| 1871 | } | 1846 | } |
| 1872 | EXPORT_SYMBOL(usb_gadget_unregister_driver); | 1847 | EXPORT_SYMBOL(usb_gadget_unregister_driver); |
| @@ -1922,7 +1897,7 @@ static int fsl_proc_read(char *page, char **start, off_t off, int count, | |||
| 1922 | tmp_reg = fsl_readl(&dr_regs->usbsts); | 1897 | tmp_reg = fsl_readl(&dr_regs->usbsts); |
| 1923 | t = scnprintf(next, size, | 1898 | t = scnprintf(next, size, |
| 1924 | "USB Status Reg:\n" | 1899 | "USB Status Reg:\n" |
| 1925 | "Dr Suspend: %d" "Reset Received: %d" "System Error: %s" | 1900 | "Dr Suspend: %d Reset Received: %d System Error: %s " |
| 1926 | "USB Error Interrupt: %s\n\n", | 1901 | "USB Error Interrupt: %s\n\n", |
| 1927 | (tmp_reg & USB_STS_SUSPEND) ? 1 : 0, | 1902 | (tmp_reg & USB_STS_SUSPEND) ? 1 : 0, |
| 1928 | (tmp_reg & USB_STS_RESET) ? 1 : 0, | 1903 | (tmp_reg & USB_STS_RESET) ? 1 : 0, |
| @@ -1934,11 +1909,11 @@ static int fsl_proc_read(char *page, char **start, off_t off, int count, | |||
| 1934 | tmp_reg = fsl_readl(&dr_regs->usbintr); | 1909 | tmp_reg = fsl_readl(&dr_regs->usbintr); |
| 1935 | t = scnprintf(next, size, | 1910 | t = scnprintf(next, size, |
| 1936 | "USB Intrrupt Enable Reg:\n" | 1911 | "USB Intrrupt Enable Reg:\n" |
| 1937 | "Sleep Enable: %d" "SOF Received Enable: %d" | 1912 | "Sleep Enable: %d SOF Received Enable: %d " |
| 1938 | "Reset Enable: %d\n" | 1913 | "Reset Enable: %d\n" |
| 1939 | "System Error Enable: %d" | 1914 | "System Error Enable: %d " |
| 1940 | "Port Change Dectected Enable: %d\n" | 1915 | "Port Change Dectected Enable: %d\n" |
| 1941 | "USB Error Intr Enable: %d" "USB Intr Enable: %d\n\n", | 1916 | "USB Error Intr Enable: %d USB Intr Enable: %d\n\n", |
| 1942 | (tmp_reg & USB_INTR_DEVICE_SUSPEND) ? 1 : 0, | 1917 | (tmp_reg & USB_INTR_DEVICE_SUSPEND) ? 1 : 0, |
| 1943 | (tmp_reg & USB_INTR_SOF_EN) ? 1 : 0, | 1918 | (tmp_reg & USB_INTR_SOF_EN) ? 1 : 0, |
| 1944 | (tmp_reg & USB_INTR_RESET_EN) ? 1 : 0, | 1919 | (tmp_reg & USB_INTR_RESET_EN) ? 1 : 0, |
| @@ -1951,21 +1926,21 @@ static int fsl_proc_read(char *page, char **start, off_t off, int count, | |||
| 1951 | 1926 | ||
| 1952 | tmp_reg = fsl_readl(&dr_regs->frindex); | 1927 | tmp_reg = fsl_readl(&dr_regs->frindex); |
| 1953 | t = scnprintf(next, size, | 1928 | t = scnprintf(next, size, |
| 1954 | "USB Frame Index Reg:" "Frame Number is 0x%x\n\n", | 1929 | "USB Frame Index Reg: Frame Number is 0x%x\n\n", |
| 1955 | (tmp_reg & USB_FRINDEX_MASKS)); | 1930 | (tmp_reg & USB_FRINDEX_MASKS)); |
| 1956 | size -= t; | 1931 | size -= t; |
| 1957 | next += t; | 1932 | next += t; |
| 1958 | 1933 | ||
| 1959 | tmp_reg = fsl_readl(&dr_regs->deviceaddr); | 1934 | tmp_reg = fsl_readl(&dr_regs->deviceaddr); |
| 1960 | t = scnprintf(next, size, | 1935 | t = scnprintf(next, size, |
| 1961 | "USB Device Address Reg:" "Device Addr is 0x%x\n\n", | 1936 | "USB Device Address Reg: Device Addr is 0x%x\n\n", |
| 1962 | (tmp_reg & USB_DEVICE_ADDRESS_MASK)); | 1937 | (tmp_reg & USB_DEVICE_ADDRESS_MASK)); |
| 1963 | size -= t; | 1938 | size -= t; |
| 1964 | next += t; | 1939 | next += t; |
| 1965 | 1940 | ||
| 1966 | tmp_reg = fsl_readl(&dr_regs->endpointlistaddr); | 1941 | tmp_reg = fsl_readl(&dr_regs->endpointlistaddr); |
| 1967 | t = scnprintf(next, size, | 1942 | t = scnprintf(next, size, |
| 1968 | "USB Endpoint List Address Reg:" | 1943 | "USB Endpoint List Address Reg: " |
| 1969 | "Device Addr is 0x%x\n\n", | 1944 | "Device Addr is 0x%x\n\n", |
| 1970 | (tmp_reg & USB_EP_LIST_ADDRESS_MASK)); | 1945 | (tmp_reg & USB_EP_LIST_ADDRESS_MASK)); |
| 1971 | size -= t; | 1946 | size -= t; |
| @@ -1974,11 +1949,12 @@ static int fsl_proc_read(char *page, char **start, off_t off, int count, | |||
| 1974 | tmp_reg = fsl_readl(&dr_regs->portsc1); | 1949 | tmp_reg = fsl_readl(&dr_regs->portsc1); |
| 1975 | t = scnprintf(next, size, | 1950 | t = scnprintf(next, size, |
| 1976 | "USB Port Status&Control Reg:\n" | 1951 | "USB Port Status&Control Reg:\n" |
| 1977 | "Port Transceiver Type : %s" "Port Speed: %s \n" | 1952 | "Port Transceiver Type : %s Port Speed: %s\n" |
| 1978 | "PHY Low Power Suspend: %s" "Port Reset: %s" | 1953 | "PHY Low Power Suspend: %s Port Reset: %s " |
| 1979 | "Port Suspend Mode: %s \n" "Over-current Change: %s" | 1954 | "Port Suspend Mode: %s\n" |
| 1955 | "Over-current Change: %s " | ||
| 1980 | "Port Enable/Disable Change: %s\n" | 1956 | "Port Enable/Disable Change: %s\n" |
| 1981 | "Port Enabled/Disabled: %s" | 1957 | "Port Enabled/Disabled: %s " |
| 1982 | "Current Connect Status: %s\n\n", ( { | 1958 | "Current Connect Status: %s\n\n", ( { |
| 1983 | char *s; | 1959 | char *s; |
| 1984 | switch (tmp_reg & PORTSCX_PTS_FSLS) { | 1960 | switch (tmp_reg & PORTSCX_PTS_FSLS) { |
| @@ -2023,7 +1999,7 @@ static int fsl_proc_read(char *page, char **start, off_t off, int count, | |||
| 2023 | 1999 | ||
| 2024 | tmp_reg = fsl_readl(&dr_regs->usbmode); | 2000 | tmp_reg = fsl_readl(&dr_regs->usbmode); |
| 2025 | t = scnprintf(next, size, | 2001 | t = scnprintf(next, size, |
| 2026 | "USB Mode Reg:" "Controller Mode is : %s\n\n", ( { | 2002 | "USB Mode Reg: Controller Mode is: %s\n\n", ( { |
| 2027 | char *s; | 2003 | char *s; |
| 2028 | switch (tmp_reg & USB_MODE_CTRL_MODE_HOST) { | 2004 | switch (tmp_reg & USB_MODE_CTRL_MODE_HOST) { |
| 2029 | case USB_MODE_CTRL_MODE_IDLE: | 2005 | case USB_MODE_CTRL_MODE_IDLE: |
| @@ -2042,7 +2018,7 @@ static int fsl_proc_read(char *page, char **start, off_t off, int count, | |||
| 2042 | 2018 | ||
| 2043 | tmp_reg = fsl_readl(&dr_regs->endptsetupstat); | 2019 | tmp_reg = fsl_readl(&dr_regs->endptsetupstat); |
| 2044 | t = scnprintf(next, size, | 2020 | t = scnprintf(next, size, |
| 2045 | "Endpoint Setup Status Reg:" "SETUP on ep 0x%x\n\n", | 2021 | "Endpoint Setup Status Reg: SETUP on ep 0x%x\n\n", |
| 2046 | (tmp_reg & EP_SETUP_STATUS_MASK)); | 2022 | (tmp_reg & EP_SETUP_STATUS_MASK)); |
| 2047 | size -= t; | 2023 | size -= t; |
| 2048 | next += t; | 2024 | next += t; |
| @@ -2055,12 +2031,12 @@ static int fsl_proc_read(char *page, char **start, off_t off, int count, | |||
| 2055 | next += t; | 2031 | next += t; |
| 2056 | } | 2032 | } |
| 2057 | tmp_reg = fsl_readl(&dr_regs->endpointprime); | 2033 | tmp_reg = fsl_readl(&dr_regs->endpointprime); |
| 2058 | t = scnprintf(next, size, "EP Prime Reg = [0x%x]\n", tmp_reg); | 2034 | t = scnprintf(next, size, "EP Prime Reg = [0x%x]\n\n", tmp_reg); |
| 2059 | size -= t; | 2035 | size -= t; |
| 2060 | next += t; | 2036 | next += t; |
| 2061 | 2037 | ||
| 2062 | tmp_reg = usb_sys_regs->snoop1; | 2038 | tmp_reg = usb_sys_regs->snoop1; |
| 2063 | t = scnprintf(next, size, "\nSnoop1 Reg : = [0x%x]\n\n", tmp_reg); | 2039 | t = scnprintf(next, size, "Snoop1 Reg : = [0x%x]\n\n", tmp_reg); |
| 2064 | size -= t; | 2040 | size -= t; |
| 2065 | next += t; | 2041 | next += t; |
| 2066 | 2042 | ||
| @@ -2084,7 +2060,7 @@ static int fsl_proc_read(char *page, char **start, off_t off, int count, | |||
| 2084 | } else { | 2060 | } else { |
| 2085 | list_for_each_entry(req, &ep->queue, queue) { | 2061 | list_for_each_entry(req, &ep->queue, queue) { |
| 2086 | t = scnprintf(next, size, | 2062 | t = scnprintf(next, size, |
| 2087 | "req %p actual 0x%x length 0x%x buf %p\n", | 2063 | "req %p actual 0x%x length 0x%x buf %p\n", |
| 2088 | &req->req, req->req.actual, | 2064 | &req->req, req->req.actual, |
| 2089 | req->req.length, req->req.buf); | 2065 | req->req.length, req->req.buf); |
| 2090 | size -= t; | 2066 | size -= t; |
| @@ -2110,7 +2086,7 @@ static int fsl_proc_read(char *page, char **start, off_t off, int count, | |||
| 2110 | } else { | 2086 | } else { |
| 2111 | list_for_each_entry(req, &ep->queue, queue) { | 2087 | list_for_each_entry(req, &ep->queue, queue) { |
| 2112 | t = scnprintf(next, size, | 2088 | t = scnprintf(next, size, |
| 2113 | "req %p actual 0x%x length" | 2089 | "req %p actual 0x%x length " |
| 2114 | "0x%x buf %p\n", | 2090 | "0x%x buf %p\n", |
| 2115 | &req->req, req->req.actual, | 2091 | &req->req, req->req.actual, |
| 2116 | req->req.length, req->req.buf); | 2092 | req->req.length, req->req.buf); |
| @@ -2202,7 +2178,6 @@ static int __init struct_udc_setup(struct fsl_udc *udc, | |||
| 2202 | udc->usb_state = USB_STATE_POWERED; | 2178 | udc->usb_state = USB_STATE_POWERED; |
| 2203 | udc->ep0_dir = 0; | 2179 | udc->ep0_dir = 0; |
| 2204 | udc->remote_wakeup = 0; /* default to 0 on reset */ | 2180 | udc->remote_wakeup = 0; /* default to 0 on reset */ |
| 2205 | spin_lock_init(&udc->lock); | ||
| 2206 | 2181 | ||
| 2207 | return 0; | 2182 | return 0; |
| 2208 | } | 2183 | } |
| @@ -2254,7 +2229,7 @@ static int __init fsl_udc_probe(struct platform_device *pdev) | |||
| 2254 | u32 dccparams; | 2229 | u32 dccparams; |
| 2255 | 2230 | ||
| 2256 | if (strcmp(pdev->name, driver_name)) { | 2231 | if (strcmp(pdev->name, driver_name)) { |
| 2257 | VDBG("Wrong device\n"); | 2232 | VDBG("Wrong device"); |
| 2258 | return -ENODEV; | 2233 | return -ENODEV; |
| 2259 | } | 2234 | } |
| 2260 | 2235 | ||
| @@ -2264,23 +2239,26 @@ static int __init fsl_udc_probe(struct platform_device *pdev) | |||
| 2264 | return -ENOMEM; | 2239 | return -ENOMEM; |
| 2265 | } | 2240 | } |
| 2266 | 2241 | ||
| 2242 | spin_lock_init(&udc_controller->lock); | ||
| 2243 | udc_controller->stopped = 1; | ||
| 2244 | |||
| 2267 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 2245 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 2268 | if (!res) { | 2246 | if (!res) { |
| 2269 | kfree(udc_controller); | 2247 | ret = -ENXIO; |
| 2270 | return -ENXIO; | 2248 | goto err_kfree; |
| 2271 | } | 2249 | } |
| 2272 | 2250 | ||
| 2273 | if (!request_mem_region(res->start, res->end - res->start + 1, | 2251 | if (!request_mem_region(res->start, res->end - res->start + 1, |
| 2274 | driver_name)) { | 2252 | driver_name)) { |
| 2275 | ERR("request mem region for %s failed \n", pdev->name); | 2253 | ERR("request mem region for %s failed\n", pdev->name); |
| 2276 | kfree(udc_controller); | 2254 | ret = -EBUSY; |
| 2277 | return -EBUSY; | 2255 | goto err_kfree; |
| 2278 | } | 2256 | } |
| 2279 | 2257 | ||
| 2280 | dr_regs = ioremap(res->start, res->end - res->start + 1); | 2258 | dr_regs = ioremap(res->start, res->end - res->start + 1); |
| 2281 | if (!dr_regs) { | 2259 | if (!dr_regs) { |
| 2282 | ret = -ENOMEM; | 2260 | ret = -ENOMEM; |
| 2283 | goto err1; | 2261 | goto err_release_mem_region; |
| 2284 | } | 2262 | } |
| 2285 | 2263 | ||
| 2286 | usb_sys_regs = (struct usb_sys_interface *) | 2264 | usb_sys_regs = (struct usb_sys_interface *) |
| @@ -2291,7 +2269,7 @@ static int __init fsl_udc_probe(struct platform_device *pdev) | |||
| 2291 | if (!(dccparams & DCCPARAMS_DC)) { | 2269 | if (!(dccparams & DCCPARAMS_DC)) { |
| 2292 | ERR("This SOC doesn't support device role\n"); | 2270 | ERR("This SOC doesn't support device role\n"); |
| 2293 | ret = -ENODEV; | 2271 | ret = -ENODEV; |
| 2294 | goto err2; | 2272 | goto err_iounmap; |
| 2295 | } | 2273 | } |
| 2296 | /* Get max device endpoints */ | 2274 | /* Get max device endpoints */ |
| 2297 | /* DEN is bidirectional ep number, max_ep doubles the number */ | 2275 | /* DEN is bidirectional ep number, max_ep doubles the number */ |
| @@ -2300,22 +2278,22 @@ static int __init fsl_udc_probe(struct platform_device *pdev) | |||
| 2300 | udc_controller->irq = platform_get_irq(pdev, 0); | 2278 | udc_controller->irq = platform_get_irq(pdev, 0); |
| 2301 | if (!udc_controller->irq) { | 2279 | if (!udc_controller->irq) { |
| 2302 | ret = -ENODEV; | 2280 | ret = -ENODEV; |
| 2303 | goto err2; | 2281 | goto err_iounmap; |
| 2304 | } | 2282 | } |
| 2305 | 2283 | ||
| 2306 | ret = request_irq(udc_controller->irq, fsl_udc_irq, IRQF_SHARED, | 2284 | ret = request_irq(udc_controller->irq, fsl_udc_irq, IRQF_SHARED, |
| 2307 | driver_name, udc_controller); | 2285 | driver_name, udc_controller); |
| 2308 | if (ret != 0) { | 2286 | if (ret != 0) { |
| 2309 | ERR("cannot request irq %d err %d \n", | 2287 | ERR("cannot request irq %d err %d\n", |
| 2310 | udc_controller->irq, ret); | 2288 | udc_controller->irq, ret); |
| 2311 | goto err2; | 2289 | goto err_iounmap; |
| 2312 | } | 2290 | } |
| 2313 | 2291 | ||
| 2314 | /* Initialize the udc structure including QH member and other member */ | 2292 | /* Initialize the udc structure including QH member and other member */ |
| 2315 | if (struct_udc_setup(udc_controller, pdev)) { | 2293 | if (struct_udc_setup(udc_controller, pdev)) { |
| 2316 | ERR("Can't initialize udc data structure\n"); | 2294 | ERR("Can't initialize udc data structure\n"); |
| 2317 | ret = -ENOMEM; | 2295 | ret = -ENOMEM; |
| 2318 | goto err3; | 2296 | goto err_free_irq; |
| 2319 | } | 2297 | } |
| 2320 | 2298 | ||
| 2321 | /* initialize usb hw reg except for regs for EP, | 2299 | /* initialize usb hw reg except for regs for EP, |
| @@ -2336,7 +2314,7 @@ static int __init fsl_udc_probe(struct platform_device *pdev) | |||
| 2336 | udc_controller->gadget.dev.parent = &pdev->dev; | 2314 | udc_controller->gadget.dev.parent = &pdev->dev; |
| 2337 | ret = device_register(&udc_controller->gadget.dev); | 2315 | ret = device_register(&udc_controller->gadget.dev); |
| 2338 | if (ret < 0) | 2316 | if (ret < 0) |
| 2339 | goto err3; | 2317 | goto err_free_irq; |
| 2340 | 2318 | ||
| 2341 | /* setup QH and epctrl for ep0 */ | 2319 | /* setup QH and epctrl for ep0 */ |
| 2342 | ep0_setup(udc_controller); | 2320 | ep0_setup(udc_controller); |
| @@ -2366,20 +2344,22 @@ static int __init fsl_udc_probe(struct platform_device *pdev) | |||
| 2366 | DTD_ALIGNMENT, UDC_DMA_BOUNDARY); | 2344 | DTD_ALIGNMENT, UDC_DMA_BOUNDARY); |
| 2367 | if (udc_controller->td_pool == NULL) { | 2345 | if (udc_controller->td_pool == NULL) { |
| 2368 | ret = -ENOMEM; | 2346 | ret = -ENOMEM; |
| 2369 | goto err4; | 2347 | goto err_unregister; |
| 2370 | } | 2348 | } |
| 2371 | create_proc_file(); | 2349 | create_proc_file(); |
| 2372 | return 0; | 2350 | return 0; |
| 2373 | 2351 | ||
| 2374 | err4: | 2352 | err_unregister: |
| 2375 | device_unregister(&udc_controller->gadget.dev); | 2353 | device_unregister(&udc_controller->gadget.dev); |
| 2376 | err3: | 2354 | err_free_irq: |
| 2377 | free_irq(udc_controller->irq, udc_controller); | 2355 | free_irq(udc_controller->irq, udc_controller); |
| 2378 | err2: | 2356 | err_iounmap: |
| 2379 | iounmap(dr_regs); | 2357 | iounmap(dr_regs); |
| 2380 | err1: | 2358 | err_release_mem_region: |
| 2381 | release_mem_region(res->start, res->end - res->start + 1); | 2359 | release_mem_region(res->start, res->end - res->start + 1); |
| 2360 | err_kfree: | ||
| 2382 | kfree(udc_controller); | 2361 | kfree(udc_controller); |
| 2362 | udc_controller = NULL; | ||
| 2383 | return ret; | 2363 | return ret; |
| 2384 | } | 2364 | } |
| 2385 | 2365 | ||
| @@ -2469,7 +2449,7 @@ module_init(udc_init); | |||
| 2469 | static void __exit udc_exit(void) | 2449 | static void __exit udc_exit(void) |
| 2470 | { | 2450 | { |
| 2471 | platform_driver_unregister(&udc_driver); | 2451 | platform_driver_unregister(&udc_driver); |
| 2472 | printk("%s unregistered \n", driver_desc); | 2452 | printk("%s unregistered\n", driver_desc); |
| 2473 | } | 2453 | } |
| 2474 | 2454 | ||
| 2475 | module_exit(udc_exit); | 2455 | module_exit(udc_exit); |
diff --git a/drivers/usb/gadget/fsl_usb2_udc.h b/drivers/usb/gadget/fsl_usb2_udc.h index 6131752a38bc..e63ef12645f5 100644 --- a/drivers/usb/gadget/fsl_usb2_udc.h +++ b/drivers/usb/gadget/fsl_usb2_udc.h | |||
| @@ -424,16 +424,6 @@ struct ep_td_struct { | |||
| 424 | /* Controller dma boundary */ | 424 | /* Controller dma boundary */ |
| 425 | #define UDC_DMA_BOUNDARY 0x1000 | 425 | #define UDC_DMA_BOUNDARY 0x1000 |
| 426 | 426 | ||
| 427 | /* -----------------------------------------------------------------------*/ | ||
| 428 | /* ##### enum data | ||
| 429 | */ | ||
| 430 | typedef enum { | ||
| 431 | e_ULPI, | ||
| 432 | e_UTMI_8BIT, | ||
| 433 | e_UTMI_16BIT, | ||
| 434 | e_SERIAL | ||
| 435 | } e_PhyInterface; | ||
| 436 | |||
| 437 | /*-------------------------------------------------------------------------*/ | 427 | /*-------------------------------------------------------------------------*/ |
| 438 | 428 | ||
| 439 | /* ### driver private data | 429 | /* ### driver private data |
| @@ -469,9 +459,9 @@ struct fsl_ep { | |||
| 469 | #define EP_DIR_OUT 0 | 459 | #define EP_DIR_OUT 0 |
| 470 | 460 | ||
| 471 | struct fsl_udc { | 461 | struct fsl_udc { |
| 472 | |||
| 473 | struct usb_gadget gadget; | 462 | struct usb_gadget gadget; |
| 474 | struct usb_gadget_driver *driver; | 463 | struct usb_gadget_driver *driver; |
| 464 | struct completion *done; /* to make sure release() is done */ | ||
| 475 | struct fsl_ep *eps; | 465 | struct fsl_ep *eps; |
| 476 | unsigned int max_ep; | 466 | unsigned int max_ep; |
| 477 | unsigned int irq; | 467 | unsigned int irq; |
| @@ -492,20 +482,13 @@ struct fsl_udc { | |||
| 492 | size_t ep_qh_size; /* size after alignment adjustment*/ | 482 | size_t ep_qh_size; /* size after alignment adjustment*/ |
| 493 | dma_addr_t ep_qh_dma; /* dma address of QH */ | 483 | dma_addr_t ep_qh_dma; /* dma address of QH */ |
| 494 | 484 | ||
| 495 | u32 max_pipes; /* Device max pipes */ | 485 | u32 max_pipes; /* Device max pipes */ |
| 496 | u32 max_use_endpts; /* Max endpointes to be used */ | ||
| 497 | u32 bus_reset; /* Device is bus reseting */ | ||
| 498 | u32 resume_state; /* USB state to resume */ | 486 | u32 resume_state; /* USB state to resume */ |
| 499 | u32 usb_state; /* USB current state */ | 487 | u32 usb_state; /* USB current state */ |
| 500 | u32 usb_next_state; /* USB next state */ | ||
| 501 | u32 ep0_state; /* Endpoint zero state */ | 488 | u32 ep0_state; /* Endpoint zero state */ |
| 502 | u32 ep0_dir; /* Endpoint zero direction: can be | 489 | u32 ep0_dir; /* Endpoint zero direction: can be |
| 503 | USB_DIR_IN or USB_DIR_OUT */ | 490 | USB_DIR_IN or USB_DIR_OUT */ |
| 504 | u32 usb_sof_count; /* SOF count */ | ||
| 505 | u32 errors; /* USB ERRORs count */ | ||
| 506 | u8 device_address; /* Device USB address */ | 491 | u8 device_address; /* Device USB address */ |
| 507 | |||
| 508 | struct completion *done; /* to make sure release() is done */ | ||
| 509 | }; | 492 | }; |
| 510 | 493 | ||
| 511 | /*-------------------------------------------------------------------------*/ | 494 | /*-------------------------------------------------------------------------*/ |
diff --git a/drivers/usb/gadget/gadget_chips.h b/drivers/usb/gadget/gadget_chips.h index 17d9905101b7..4e3107dd2f34 100644 --- a/drivers/usb/gadget/gadget_chips.h +++ b/drivers/usb/gadget/gadget_chips.h | |||
| @@ -151,6 +151,13 @@ | |||
| 151 | #define gadget_is_m66592(g) 0 | 151 | #define gadget_is_m66592(g) 0 |
| 152 | #endif | 152 | #endif |
| 153 | 153 | ||
| 154 | /* Freescale CPM/QE UDC SUPPORT */ | ||
| 155 | #ifdef CONFIG_USB_GADGET_FSL_QE | ||
| 156 | #define gadget_is_fsl_qe(g) !strcmp("fsl_qe_udc", (g)->name) | ||
| 157 | #else | ||
| 158 | #define gadget_is_fsl_qe(g) 0 | ||
| 159 | #endif | ||
| 160 | |||
| 154 | 161 | ||
| 155 | // CONFIG_USB_GADGET_SX2 | 162 | // CONFIG_USB_GADGET_SX2 |
| 156 | // CONFIG_USB_GADGET_AU1X00 | 163 | // CONFIG_USB_GADGET_AU1X00 |
| @@ -216,6 +223,8 @@ static inline int usb_gadget_controller_number(struct usb_gadget *gadget) | |||
| 216 | return 0x20; | 223 | return 0x20; |
| 217 | else if (gadget_is_m66592(gadget)) | 224 | else if (gadget_is_m66592(gadget)) |
| 218 | return 0x21; | 225 | return 0x21; |
| 226 | else if (gadget_is_fsl_qe(gadget)) | ||
| 227 | return 0x22; | ||
| 219 | return -ENOENT; | 228 | return -ENOENT; |
| 220 | } | 229 | } |
| 221 | 230 | ||
diff --git a/drivers/usb/gadget/gmidi.c b/drivers/usb/gadget/gmidi.c index 6eee760410d6..60d3f9e9b51f 100644 --- a/drivers/usb/gadget/gmidi.c +++ b/drivers/usb/gadget/gmidi.c | |||
| @@ -222,7 +222,7 @@ static struct usb_config_descriptor config_desc = { | |||
| 222 | * power properties of the device. Is it selfpowered? | 222 | * power properties of the device. Is it selfpowered? |
| 223 | */ | 223 | */ |
| 224 | .bmAttributes = USB_CONFIG_ATT_ONE, | 224 | .bmAttributes = USB_CONFIG_ATT_ONE, |
| 225 | .bMaxPower = 1, | 225 | .bMaxPower = CONFIG_USB_GADGET_VBUS_DRAW / 2, |
| 226 | }; | 226 | }; |
| 227 | 227 | ||
| 228 | /* B.3.1 Standard AC Interface Descriptor */ | 228 | /* B.3.1 Standard AC Interface Descriptor */ |
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c index 5cfb5ebf3881..8ae70de2c37d 100644 --- a/drivers/usb/gadget/net2280.c +++ b/drivers/usb/gadget/net2280.c | |||
| @@ -178,6 +178,7 @@ net2280_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc) | |||
| 178 | 178 | ||
| 179 | /* ep_reset() has already been called */ | 179 | /* ep_reset() has already been called */ |
| 180 | ep->stopped = 0; | 180 | ep->stopped = 0; |
| 181 | ep->wedged = 0; | ||
| 181 | ep->out_overflow = 0; | 182 | ep->out_overflow = 0; |
| 182 | 183 | ||
| 183 | /* set speed-dependent max packet; may kick in high bandwidth */ | 184 | /* set speed-dependent max packet; may kick in high bandwidth */ |
| @@ -1218,7 +1219,7 @@ static int net2280_dequeue (struct usb_ep *_ep, struct usb_request *_req) | |||
| 1218 | static int net2280_fifo_status (struct usb_ep *_ep); | 1219 | static int net2280_fifo_status (struct usb_ep *_ep); |
| 1219 | 1220 | ||
| 1220 | static int | 1221 | static int |
| 1221 | net2280_set_halt (struct usb_ep *_ep, int value) | 1222 | net2280_set_halt_and_wedge(struct usb_ep *_ep, int value, int wedged) |
| 1222 | { | 1223 | { |
| 1223 | struct net2280_ep *ep; | 1224 | struct net2280_ep *ep; |
| 1224 | unsigned long flags; | 1225 | unsigned long flags; |
| @@ -1239,16 +1240,21 @@ net2280_set_halt (struct usb_ep *_ep, int value) | |||
| 1239 | else if (ep->is_in && value && net2280_fifo_status (_ep) != 0) | 1240 | else if (ep->is_in && value && net2280_fifo_status (_ep) != 0) |
| 1240 | retval = -EAGAIN; | 1241 | retval = -EAGAIN; |
| 1241 | else { | 1242 | else { |
| 1242 | VDEBUG (ep->dev, "%s %s halt\n", _ep->name, | 1243 | VDEBUG (ep->dev, "%s %s %s\n", _ep->name, |
| 1243 | value ? "set" : "clear"); | 1244 | value ? "set" : "clear", |
| 1245 | wedged ? "wedge" : "halt"); | ||
| 1244 | /* set/clear, then synch memory views with the device */ | 1246 | /* set/clear, then synch memory views with the device */ |
| 1245 | if (value) { | 1247 | if (value) { |
| 1246 | if (ep->num == 0) | 1248 | if (ep->num == 0) |
| 1247 | ep->dev->protocol_stall = 1; | 1249 | ep->dev->protocol_stall = 1; |
| 1248 | else | 1250 | else |
| 1249 | set_halt (ep); | 1251 | set_halt (ep); |
| 1250 | } else | 1252 | if (wedged) |
| 1253 | ep->wedged = 1; | ||
| 1254 | } else { | ||
| 1251 | clear_halt (ep); | 1255 | clear_halt (ep); |
| 1256 | ep->wedged = 0; | ||
| 1257 | } | ||
| 1252 | (void) readl (&ep->regs->ep_rsp); | 1258 | (void) readl (&ep->regs->ep_rsp); |
| 1253 | } | 1259 | } |
| 1254 | spin_unlock_irqrestore (&ep->dev->lock, flags); | 1260 | spin_unlock_irqrestore (&ep->dev->lock, flags); |
| @@ -1257,6 +1263,20 @@ net2280_set_halt (struct usb_ep *_ep, int value) | |||
| 1257 | } | 1263 | } |
| 1258 | 1264 | ||
| 1259 | static int | 1265 | static int |
| 1266 | net2280_set_halt(struct usb_ep *_ep, int value) | ||
| 1267 | { | ||
| 1268 | return net2280_set_halt_and_wedge(_ep, value, 0); | ||
| 1269 | } | ||
| 1270 | |||
| 1271 | static int | ||
| 1272 | net2280_set_wedge(struct usb_ep *_ep) | ||
| 1273 | { | ||
| 1274 | if (!_ep || _ep->name == ep0name) | ||
| 1275 | return -EINVAL; | ||
| 1276 | return net2280_set_halt_and_wedge(_ep, 1, 1); | ||
| 1277 | } | ||
| 1278 | |||
| 1279 | static int | ||
| 1260 | net2280_fifo_status (struct usb_ep *_ep) | 1280 | net2280_fifo_status (struct usb_ep *_ep) |
| 1261 | { | 1281 | { |
| 1262 | struct net2280_ep *ep; | 1282 | struct net2280_ep *ep; |
| @@ -1302,6 +1322,7 @@ static const struct usb_ep_ops net2280_ep_ops = { | |||
| 1302 | .dequeue = net2280_dequeue, | 1322 | .dequeue = net2280_dequeue, |
| 1303 | 1323 | ||
| 1304 | .set_halt = net2280_set_halt, | 1324 | .set_halt = net2280_set_halt, |
| 1325 | .set_wedge = net2280_set_wedge, | ||
| 1305 | .fifo_status = net2280_fifo_status, | 1326 | .fifo_status = net2280_fifo_status, |
| 1306 | .fifo_flush = net2280_fifo_flush, | 1327 | .fifo_flush = net2280_fifo_flush, |
| 1307 | }; | 1328 | }; |
| @@ -2410,9 +2431,14 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat) | |||
| 2410 | goto do_stall; | 2431 | goto do_stall; |
| 2411 | if ((e = get_ep_by_addr (dev, w_index)) == 0) | 2432 | if ((e = get_ep_by_addr (dev, w_index)) == 0) |
| 2412 | goto do_stall; | 2433 | goto do_stall; |
| 2413 | clear_halt (e); | 2434 | if (e->wedged) { |
| 2435 | VDEBUG(dev, "%s wedged, halt not cleared\n", | ||
| 2436 | ep->ep.name); | ||
| 2437 | } else { | ||
| 2438 | VDEBUG(dev, "%s clear halt\n", ep->ep.name); | ||
| 2439 | clear_halt(e); | ||
| 2440 | } | ||
| 2414 | allow_status (ep); | 2441 | allow_status (ep); |
| 2415 | VDEBUG (dev, "%s clear halt\n", ep->ep.name); | ||
| 2416 | goto next_endpoints; | 2442 | goto next_endpoints; |
| 2417 | } | 2443 | } |
| 2418 | break; | 2444 | break; |
| @@ -2427,6 +2453,8 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat) | |||
| 2427 | goto do_stall; | 2453 | goto do_stall; |
| 2428 | if ((e = get_ep_by_addr (dev, w_index)) == 0) | 2454 | if ((e = get_ep_by_addr (dev, w_index)) == 0) |
| 2429 | goto do_stall; | 2455 | goto do_stall; |
| 2456 | if (e->ep.name == ep0name) | ||
| 2457 | goto do_stall; | ||
| 2430 | set_halt (e); | 2458 | set_halt (e); |
| 2431 | allow_status (ep); | 2459 | allow_status (ep); |
| 2432 | VDEBUG (dev, "%s set halt\n", ep->ep.name); | 2460 | VDEBUG (dev, "%s set halt\n", ep->ep.name); |
diff --git a/drivers/usb/gadget/net2280.h b/drivers/usb/gadget/net2280.h index 81a71dbdc2c6..c36852263d93 100644 --- a/drivers/usb/gadget/net2280.h +++ b/drivers/usb/gadget/net2280.h | |||
| @@ -109,6 +109,7 @@ struct net2280_ep { | |||
| 109 | in_fifo_validate : 1, | 109 | in_fifo_validate : 1, |
| 110 | out_overflow : 1, | 110 | out_overflow : 1, |
| 111 | stopped : 1, | 111 | stopped : 1, |
| 112 | wedged : 1, | ||
| 112 | is_in : 1, | 113 | is_in : 1, |
| 113 | is_iso : 1, | 114 | is_iso : 1, |
| 114 | responded : 1; | 115 | responded : 1; |
diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c index bb54cca4c543..34e9e393f929 100644 --- a/drivers/usb/gadget/omap_udc.c +++ b/drivers/usb/gadget/omap_udc.c | |||
| @@ -2313,6 +2313,13 @@ static int proc_otg_show(struct seq_file *s) | |||
| 2313 | 2313 | ||
| 2314 | tmp = omap_readl(OTG_REV); | 2314 | tmp = omap_readl(OTG_REV); |
| 2315 | if (cpu_is_omap24xx()) { | 2315 | if (cpu_is_omap24xx()) { |
| 2316 | /* | ||
| 2317 | * REVISIT: Not clear how this works on OMAP2. trans | ||
| 2318 | * is ANDed to produce bits 7 and 8, which might make | ||
| 2319 | * sense for USB_TRANSCEIVER_CTRL on OMAP1, | ||
| 2320 | * but with CONTROL_DEVCONF, these bits have something to | ||
| 2321 | * do with the frame adjustment counter and McBSP2. | ||
| 2322 | */ | ||
| 2316 | ctrl_name = "control_devconf"; | 2323 | ctrl_name = "control_devconf"; |
| 2317 | trans = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0); | 2324 | trans = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0); |
| 2318 | } else { | 2325 | } else { |
diff --git a/drivers/usb/gadget/printer.c b/drivers/usb/gadget/printer.c index 2b3b9e1dd2ee..5a3034fdfe47 100644 --- a/drivers/usb/gadget/printer.c +++ b/drivers/usb/gadget/printer.c | |||
| @@ -252,7 +252,7 @@ static struct usb_config_descriptor config_desc = { | |||
| 252 | .bConfigurationValue = DEV_CONFIG_VALUE, | 252 | .bConfigurationValue = DEV_CONFIG_VALUE, |
| 253 | .iConfiguration = 0, | 253 | .iConfiguration = 0, |
| 254 | .bmAttributes = USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER, | 254 | .bmAttributes = USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER, |
| 255 | .bMaxPower = 1 /* Self-Powered */ | 255 | .bMaxPower = CONFIG_USB_GADGET_VBUS_DRAW / 2, |
| 256 | }; | 256 | }; |
| 257 | 257 | ||
| 258 | static struct usb_interface_descriptor intf_desc = { | 258 | static struct usb_interface_descriptor intf_desc = { |
| @@ -1278,8 +1278,7 @@ unknown: | |||
| 1278 | /* respond with data transfer before status phase? */ | 1278 | /* respond with data transfer before status phase? */ |
| 1279 | if (value >= 0) { | 1279 | if (value >= 0) { |
| 1280 | req->length = value; | 1280 | req->length = value; |
| 1281 | req->zero = value < wLength | 1281 | req->zero = value < wLength; |
| 1282 | && (value % gadget->ep0->maxpacket) == 0; | ||
| 1283 | value = usb_ep_queue(gadget->ep0, req, GFP_ATOMIC); | 1282 | value = usb_ep_queue(gadget->ep0, req, GFP_ATOMIC); |
| 1284 | if (value < 0) { | 1283 | if (value < 0) { |
| 1285 | DBG(dev, "ep_queue --> %d\n", value); | 1284 | DBG(dev, "ep_queue --> %d\n", value); |
| @@ -1477,7 +1476,6 @@ autoconf_fail: | |||
| 1477 | if (gadget->is_otg) { | 1476 | if (gadget->is_otg) { |
| 1478 | otg_desc.bmAttributes |= USB_OTG_HNP, | 1477 | otg_desc.bmAttributes |= USB_OTG_HNP, |
| 1479 | config_desc.bmAttributes |= USB_CONFIG_ATT_WAKEUP; | 1478 | config_desc.bmAttributes |= USB_CONFIG_ATT_WAKEUP; |
| 1480 | config_desc.bMaxPower = 4; | ||
| 1481 | } | 1479 | } |
| 1482 | 1480 | ||
| 1483 | spin_lock_init(&dev->lock); | 1481 | spin_lock_init(&dev->lock); |
diff --git a/drivers/usb/gadget/pxa27x_udc.c b/drivers/usb/gadget/pxa27x_udc.c index 7cbc78a6853d..bcf375ca3d72 100644 --- a/drivers/usb/gadget/pxa27x_udc.c +++ b/drivers/usb/gadget/pxa27x_udc.c | |||
| @@ -22,7 +22,6 @@ | |||
| 22 | #include <linux/module.h> | 22 | #include <linux/module.h> |
| 23 | #include <linux/kernel.h> | 23 | #include <linux/kernel.h> |
| 24 | #include <linux/types.h> | 24 | #include <linux/types.h> |
| 25 | #include <linux/version.h> | ||
| 26 | #include <linux/errno.h> | 25 | #include <linux/errno.h> |
| 27 | #include <linux/platform_device.h> | 26 | #include <linux/platform_device.h> |
| 28 | #include <linux/delay.h> | 27 | #include <linux/delay.h> |
diff --git a/drivers/usb/gadget/s3c2410_udc.c b/drivers/usb/gadget/s3c2410_udc.c index 29d13ebe7500..48f51b12d2e2 100644 --- a/drivers/usb/gadget/s3c2410_udc.c +++ b/drivers/usb/gadget/s3c2410_udc.c | |||
| @@ -1651,7 +1651,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver) | |||
| 1651 | return -EBUSY; | 1651 | return -EBUSY; |
| 1652 | 1652 | ||
| 1653 | if (!driver->bind || !driver->setup | 1653 | if (!driver->bind || !driver->setup |
| 1654 | || driver->speed != USB_SPEED_FULL) { | 1654 | || driver->speed < USB_SPEED_FULL) { |
| 1655 | printk(KERN_ERR "Invalid driver: bind %p setup %p speed %d\n", | 1655 | printk(KERN_ERR "Invalid driver: bind %p setup %p speed %d\n", |
| 1656 | driver->bind, driver->setup, driver->speed); | 1656 | driver->bind, driver->setup, driver->speed); |
| 1657 | return -EINVAL; | 1657 | return -EINVAL; |
diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c index 3faa7a7022df..37879af1c433 100644 --- a/drivers/usb/gadget/serial.c +++ b/drivers/usb/gadget/serial.c | |||
| @@ -43,6 +43,7 @@ | |||
| 43 | #include "epautoconf.c" | 43 | #include "epautoconf.c" |
| 44 | 44 | ||
| 45 | #include "f_acm.c" | 45 | #include "f_acm.c" |
| 46 | #include "f_obex.c" | ||
| 46 | #include "f_serial.c" | 47 | #include "f_serial.c" |
| 47 | #include "u_serial.c" | 48 | #include "u_serial.c" |
| 48 | 49 | ||
| @@ -56,6 +57,7 @@ | |||
| 56 | #define GS_VENDOR_ID 0x0525 /* NetChip */ | 57 | #define GS_VENDOR_ID 0x0525 /* NetChip */ |
| 57 | #define GS_PRODUCT_ID 0xa4a6 /* Linux-USB Serial Gadget */ | 58 | #define GS_PRODUCT_ID 0xa4a6 /* Linux-USB Serial Gadget */ |
| 58 | #define GS_CDC_PRODUCT_ID 0xa4a7 /* ... as CDC-ACM */ | 59 | #define GS_CDC_PRODUCT_ID 0xa4a7 /* ... as CDC-ACM */ |
| 60 | #define GS_CDC_OBEX_PRODUCT_ID 0xa4a9 /* ... as CDC-OBEX */ | ||
| 59 | 61 | ||
| 60 | /* string IDs are assigned dynamically */ | 62 | /* string IDs are assigned dynamically */ |
| 61 | 63 | ||
| @@ -125,6 +127,10 @@ static int use_acm = true; | |||
| 125 | module_param(use_acm, bool, 0); | 127 | module_param(use_acm, bool, 0); |
| 126 | MODULE_PARM_DESC(use_acm, "Use CDC ACM, default=yes"); | 128 | MODULE_PARM_DESC(use_acm, "Use CDC ACM, default=yes"); |
| 127 | 129 | ||
| 130 | static int use_obex = false; | ||
| 131 | module_param(use_obex, bool, 0); | ||
| 132 | MODULE_PARM_DESC(use_obex, "Use CDC OBEX, default=no"); | ||
| 133 | |||
| 128 | static unsigned n_ports = 1; | 134 | static unsigned n_ports = 1; |
| 129 | module_param(n_ports, uint, 0); | 135 | module_param(n_ports, uint, 0); |
| 130 | MODULE_PARM_DESC(n_ports, "number of ports to create, default=1"); | 136 | MODULE_PARM_DESC(n_ports, "number of ports to create, default=1"); |
| @@ -139,6 +145,8 @@ static int __init serial_bind_config(struct usb_configuration *c) | |||
| 139 | for (i = 0; i < n_ports && status == 0; i++) { | 145 | for (i = 0; i < n_ports && status == 0; i++) { |
| 140 | if (use_acm) | 146 | if (use_acm) |
| 141 | status = acm_bind_config(c, i); | 147 | status = acm_bind_config(c, i); |
| 148 | else if (use_obex) | ||
| 149 | status = obex_bind_config(c, i); | ||
| 142 | else | 150 | else |
| 143 | status = gser_bind_config(c, i); | 151 | status = gser_bind_config(c, i); |
| 144 | } | 152 | } |
| @@ -151,7 +159,6 @@ static struct usb_configuration serial_config_driver = { | |||
| 151 | /* .bConfigurationValue = f(use_acm) */ | 159 | /* .bConfigurationValue = f(use_acm) */ |
| 152 | /* .iConfiguration = DYNAMIC */ | 160 | /* .iConfiguration = DYNAMIC */ |
| 153 | .bmAttributes = USB_CONFIG_ATT_SELFPOWER, | 161 | .bmAttributes = USB_CONFIG_ATT_SELFPOWER, |
| 154 | .bMaxPower = 1, /* 2 mA, minimal */ | ||
| 155 | }; | 162 | }; |
| 156 | 163 | ||
| 157 | static int __init gs_bind(struct usb_composite_dev *cdev) | 164 | static int __init gs_bind(struct usb_composite_dev *cdev) |
| @@ -249,6 +256,12 @@ static int __init init(void) | |||
| 249 | device_desc.bDeviceClass = USB_CLASS_COMM; | 256 | device_desc.bDeviceClass = USB_CLASS_COMM; |
| 250 | device_desc.idProduct = | 257 | device_desc.idProduct = |
| 251 | __constant_cpu_to_le16(GS_CDC_PRODUCT_ID); | 258 | __constant_cpu_to_le16(GS_CDC_PRODUCT_ID); |
| 259 | } else if (use_obex) { | ||
| 260 | serial_config_driver.label = "CDC OBEX config"; | ||
| 261 | serial_config_driver.bConfigurationValue = 3; | ||
| 262 | device_desc.bDeviceClass = USB_CLASS_COMM; | ||
| 263 | device_desc.idProduct = | ||
| 264 | __constant_cpu_to_le16(GS_CDC_OBEX_PRODUCT_ID); | ||
| 252 | } else { | 265 | } else { |
| 253 | serial_config_driver.label = "Generic Serial config"; | 266 | serial_config_driver.label = "Generic Serial config"; |
| 254 | serial_config_driver.bConfigurationValue = 1; | 267 | serial_config_driver.bConfigurationValue = 1; |
diff --git a/drivers/usb/gadget/u_ether.c b/drivers/usb/gadget/u_ether.c index dbd575a194f3..66948b72bb9b 100644 --- a/drivers/usb/gadget/u_ether.c +++ b/drivers/usb/gadget/u_ether.c | |||
| @@ -873,6 +873,13 @@ struct net_device *gether_connect(struct gether *link) | |||
| 873 | spin_lock(&dev->lock); | 873 | spin_lock(&dev->lock); |
| 874 | dev->port_usb = link; | 874 | dev->port_usb = link; |
| 875 | link->ioport = dev; | 875 | link->ioport = dev; |
| 876 | if (netif_running(dev->net)) { | ||
| 877 | if (link->open) | ||
| 878 | link->open(link); | ||
| 879 | } else { | ||
| 880 | if (link->close) | ||
| 881 | link->close(link); | ||
| 882 | } | ||
| 876 | spin_unlock(&dev->lock); | 883 | spin_unlock(&dev->lock); |
| 877 | 884 | ||
| 878 | netif_carrier_on(dev->net); | 885 | netif_carrier_on(dev->net); |
diff --git a/drivers/usb/gadget/u_serial.h b/drivers/usb/gadget/u_serial.h index af3910d01aea..300f0ed9475d 100644 --- a/drivers/usb/gadget/u_serial.h +++ b/drivers/usb/gadget/u_serial.h | |||
| @@ -62,5 +62,6 @@ void gserial_disconnect(struct gserial *); | |||
| 62 | /* functions are bound to configurations by a config or gadget driver */ | 62 | /* functions are bound to configurations by a config or gadget driver */ |
| 63 | int acm_bind_config(struct usb_configuration *c, u8 port_num); | 63 | int acm_bind_config(struct usb_configuration *c, u8 port_num); |
| 64 | int gser_bind_config(struct usb_configuration *c, u8 port_num); | 64 | int gser_bind_config(struct usb_configuration *c, u8 port_num); |
| 65 | int obex_bind_config(struct usb_configuration *c, u8 port_num); | ||
| 65 | 66 | ||
| 66 | #endif /* __U_SERIAL_H */ | 67 | #endif /* __U_SERIAL_H */ |
diff --git a/drivers/usb/host/ehci-dbg.c b/drivers/usb/host/ehci-dbg.c index b0f8ed5a7fb9..0cb53ca8d343 100644 --- a/drivers/usb/host/ehci-dbg.c +++ b/drivers/usb/host/ehci-dbg.c | |||
| @@ -358,7 +358,8 @@ struct debug_buffer { | |||
| 358 | struct usb_bus *bus; | 358 | struct usb_bus *bus; |
| 359 | struct mutex mutex; /* protect filling of buffer */ | 359 | struct mutex mutex; /* protect filling of buffer */ |
| 360 | size_t count; /* number of characters filled into buffer */ | 360 | size_t count; /* number of characters filled into buffer */ |
| 361 | char *page; | 361 | char *output_buf; |
| 362 | size_t alloc_size; | ||
| 362 | }; | 363 | }; |
| 363 | 364 | ||
| 364 | #define speed_char(info1) ({ char tmp; \ | 365 | #define speed_char(info1) ({ char tmp; \ |
| @@ -488,8 +489,8 @@ static ssize_t fill_async_buffer(struct debug_buffer *buf) | |||
| 488 | 489 | ||
| 489 | hcd = bus_to_hcd(buf->bus); | 490 | hcd = bus_to_hcd(buf->bus); |
| 490 | ehci = hcd_to_ehci (hcd); | 491 | ehci = hcd_to_ehci (hcd); |
| 491 | next = buf->page; | 492 | next = buf->output_buf; |
| 492 | size = PAGE_SIZE; | 493 | size = buf->alloc_size; |
| 493 | 494 | ||
| 494 | *next = 0; | 495 | *next = 0; |
| 495 | 496 | ||
| @@ -510,7 +511,7 @@ static ssize_t fill_async_buffer(struct debug_buffer *buf) | |||
| 510 | } | 511 | } |
| 511 | spin_unlock_irqrestore (&ehci->lock, flags); | 512 | spin_unlock_irqrestore (&ehci->lock, flags); |
| 512 | 513 | ||
| 513 | return strlen(buf->page); | 514 | return strlen(buf->output_buf); |
| 514 | } | 515 | } |
| 515 | 516 | ||
| 516 | #define DBG_SCHED_LIMIT 64 | 517 | #define DBG_SCHED_LIMIT 64 |
| @@ -531,8 +532,8 @@ static ssize_t fill_periodic_buffer(struct debug_buffer *buf) | |||
| 531 | 532 | ||
| 532 | hcd = bus_to_hcd(buf->bus); | 533 | hcd = bus_to_hcd(buf->bus); |
| 533 | ehci = hcd_to_ehci (hcd); | 534 | ehci = hcd_to_ehci (hcd); |
| 534 | next = buf->page; | 535 | next = buf->output_buf; |
| 535 | size = PAGE_SIZE; | 536 | size = buf->alloc_size; |
| 536 | 537 | ||
| 537 | temp = scnprintf (next, size, "size = %d\n", ehci->periodic_size); | 538 | temp = scnprintf (next, size, "size = %d\n", ehci->periodic_size); |
| 538 | size -= temp; | 539 | size -= temp; |
| @@ -568,14 +569,16 @@ static ssize_t fill_periodic_buffer(struct debug_buffer *buf) | |||
| 568 | for (temp = 0; temp < seen_count; temp++) { | 569 | for (temp = 0; temp < seen_count; temp++) { |
| 569 | if (seen [temp].ptr != p.ptr) | 570 | if (seen [temp].ptr != p.ptr) |
| 570 | continue; | 571 | continue; |
| 571 | if (p.qh->qh_next.ptr) | 572 | if (p.qh->qh_next.ptr) { |
| 572 | temp = scnprintf (next, size, | 573 | temp = scnprintf (next, size, |
| 573 | " ..."); | 574 | " ..."); |
| 574 | p.ptr = NULL; | 575 | size -= temp; |
| 576 | next += temp; | ||
| 577 | } | ||
| 575 | break; | 578 | break; |
| 576 | } | 579 | } |
| 577 | /* show more info the first time around */ | 580 | /* show more info the first time around */ |
| 578 | if (temp == seen_count && p.ptr) { | 581 | if (temp == seen_count) { |
| 579 | u32 scratch = hc32_to_cpup(ehci, | 582 | u32 scratch = hc32_to_cpup(ehci, |
| 580 | &p.qh->hw_info1); | 583 | &p.qh->hw_info1); |
| 581 | struct ehci_qtd *qtd; | 584 | struct ehci_qtd *qtd; |
| @@ -649,7 +652,7 @@ static ssize_t fill_periodic_buffer(struct debug_buffer *buf) | |||
| 649 | spin_unlock_irqrestore (&ehci->lock, flags); | 652 | spin_unlock_irqrestore (&ehci->lock, flags); |
| 650 | kfree (seen); | 653 | kfree (seen); |
| 651 | 654 | ||
| 652 | return PAGE_SIZE - size; | 655 | return buf->alloc_size - size; |
| 653 | } | 656 | } |
| 654 | #undef DBG_SCHED_LIMIT | 657 | #undef DBG_SCHED_LIMIT |
| 655 | 658 | ||
| @@ -665,14 +668,14 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf) | |||
| 665 | 668 | ||
| 666 | hcd = bus_to_hcd(buf->bus); | 669 | hcd = bus_to_hcd(buf->bus); |
| 667 | ehci = hcd_to_ehci (hcd); | 670 | ehci = hcd_to_ehci (hcd); |
| 668 | next = buf->page; | 671 | next = buf->output_buf; |
| 669 | size = PAGE_SIZE; | 672 | size = buf->alloc_size; |
| 670 | 673 | ||
| 671 | spin_lock_irqsave (&ehci->lock, flags); | 674 | spin_lock_irqsave (&ehci->lock, flags); |
| 672 | 675 | ||
| 673 | if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) { | 676 | if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) { |
| 674 | size = scnprintf (next, size, | 677 | size = scnprintf (next, size, |
| 675 | "bus %s, device %s (driver " DRIVER_VERSION ")\n" | 678 | "bus %s, device %s\n" |
| 676 | "%s\n" | 679 | "%s\n" |
| 677 | "SUSPENDED (no register access)\n", | 680 | "SUSPENDED (no register access)\n", |
| 678 | hcd->self.controller->bus->name, | 681 | hcd->self.controller->bus->name, |
| @@ -684,7 +687,7 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf) | |||
| 684 | /* Capability Registers */ | 687 | /* Capability Registers */ |
| 685 | i = HC_VERSION(ehci_readl(ehci, &ehci->caps->hc_capbase)); | 688 | i = HC_VERSION(ehci_readl(ehci, &ehci->caps->hc_capbase)); |
| 686 | temp = scnprintf (next, size, | 689 | temp = scnprintf (next, size, |
| 687 | "bus %s, device %s (driver " DRIVER_VERSION ")\n" | 690 | "bus %s, device %s\n" |
| 688 | "%s\n" | 691 | "%s\n" |
| 689 | "EHCI %x.%02x, hcd state %d\n", | 692 | "EHCI %x.%02x, hcd state %d\n", |
| 690 | hcd->self.controller->bus->name, | 693 | hcd->self.controller->bus->name, |
| @@ -808,7 +811,7 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf) | |||
| 808 | done: | 811 | done: |
| 809 | spin_unlock_irqrestore (&ehci->lock, flags); | 812 | spin_unlock_irqrestore (&ehci->lock, flags); |
| 810 | 813 | ||
| 811 | return PAGE_SIZE - size; | 814 | return buf->alloc_size - size; |
| 812 | } | 815 | } |
| 813 | 816 | ||
| 814 | static struct debug_buffer *alloc_buffer(struct usb_bus *bus, | 817 | static struct debug_buffer *alloc_buffer(struct usb_bus *bus, |
| @@ -822,6 +825,7 @@ static struct debug_buffer *alloc_buffer(struct usb_bus *bus, | |||
| 822 | buf->bus = bus; | 825 | buf->bus = bus; |
| 823 | buf->fill_func = fill_func; | 826 | buf->fill_func = fill_func; |
| 824 | mutex_init(&buf->mutex); | 827 | mutex_init(&buf->mutex); |
| 828 | buf->alloc_size = PAGE_SIZE; | ||
| 825 | } | 829 | } |
| 826 | 830 | ||
| 827 | return buf; | 831 | return buf; |
| @@ -831,10 +835,10 @@ static int fill_buffer(struct debug_buffer *buf) | |||
| 831 | { | 835 | { |
| 832 | int ret = 0; | 836 | int ret = 0; |
| 833 | 837 | ||
| 834 | if (!buf->page) | 838 | if (!buf->output_buf) |
| 835 | buf->page = (char *)get_zeroed_page(GFP_KERNEL); | 839 | buf->output_buf = (char *)vmalloc(buf->alloc_size); |
| 836 | 840 | ||
| 837 | if (!buf->page) { | 841 | if (!buf->output_buf) { |
| 838 | ret = -ENOMEM; | 842 | ret = -ENOMEM; |
| 839 | goto out; | 843 | goto out; |
| 840 | } | 844 | } |
| @@ -867,7 +871,7 @@ static ssize_t debug_output(struct file *file, char __user *user_buf, | |||
| 867 | mutex_unlock(&buf->mutex); | 871 | mutex_unlock(&buf->mutex); |
| 868 | 872 | ||
| 869 | ret = simple_read_from_buffer(user_buf, len, offset, | 873 | ret = simple_read_from_buffer(user_buf, len, offset, |
| 870 | buf->page, buf->count); | 874 | buf->output_buf, buf->count); |
| 871 | 875 | ||
| 872 | out: | 876 | out: |
| 873 | return ret; | 877 | return ret; |
| @@ -879,8 +883,8 @@ static int debug_close(struct inode *inode, struct file *file) | |||
| 879 | struct debug_buffer *buf = file->private_data; | 883 | struct debug_buffer *buf = file->private_data; |
| 880 | 884 | ||
| 881 | if (buf) { | 885 | if (buf) { |
| 882 | if (buf->page) | 886 | if (buf->output_buf) |
| 883 | free_page((unsigned long)buf->page); | 887 | vfree(buf->output_buf); |
| 884 | kfree(buf); | 888 | kfree(buf); |
| 885 | } | 889 | } |
| 886 | 890 | ||
| @@ -895,10 +899,14 @@ static int debug_async_open(struct inode *inode, struct file *file) | |||
| 895 | 899 | ||
| 896 | static int debug_periodic_open(struct inode *inode, struct file *file) | 900 | static int debug_periodic_open(struct inode *inode, struct file *file) |
| 897 | { | 901 | { |
| 898 | file->private_data = alloc_buffer(inode->i_private, | 902 | struct debug_buffer *buf; |
| 899 | fill_periodic_buffer); | 903 | buf = alloc_buffer(inode->i_private, fill_periodic_buffer); |
| 904 | if (!buf) | ||
| 905 | return -ENOMEM; | ||
| 900 | 906 | ||
| 901 | return file->private_data ? 0 : -ENOMEM; | 907 | buf->alloc_size = (sizeof(void *) == 4 ? 6 : 8)*PAGE_SIZE; |
| 908 | file->private_data = buf; | ||
| 909 | return 0; | ||
| 902 | } | 910 | } |
| 903 | 911 | ||
| 904 | static int debug_registers_open(struct inode *inode, struct file *file) | 912 | static int debug_registers_open(struct inode *inode, struct file *file) |
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index 8409e0705d63..d343afacb0b0 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c | |||
| @@ -24,6 +24,7 @@ | |||
| 24 | #include <linux/ioport.h> | 24 | #include <linux/ioport.h> |
| 25 | #include <linux/sched.h> | 25 | #include <linux/sched.h> |
| 26 | #include <linux/slab.h> | 26 | #include <linux/slab.h> |
| 27 | #include <linux/vmalloc.h> | ||
| 27 | #include <linux/errno.h> | 28 | #include <linux/errno.h> |
| 28 | #include <linux/init.h> | 29 | #include <linux/init.h> |
| 29 | #include <linux/timer.h> | 30 | #include <linux/timer.h> |
| @@ -59,7 +60,6 @@ | |||
| 59 | * providing early devices for those host controllers to talk to! | 60 | * providing early devices for those host controllers to talk to! |
| 60 | */ | 61 | */ |
| 61 | 62 | ||
| 62 | #define DRIVER_VERSION "10 Dec 2004" | ||
| 63 | #define DRIVER_AUTHOR "David Brownell" | 63 | #define DRIVER_AUTHOR "David Brownell" |
| 64 | #define DRIVER_DESC "USB 2.0 'Enhanced' Host Controller (EHCI) Driver" | 64 | #define DRIVER_DESC "USB 2.0 'Enhanced' Host Controller (EHCI) Driver" |
| 65 | 65 | ||
| @@ -620,9 +620,9 @@ static int ehci_run (struct usb_hcd *hcd) | |||
| 620 | 620 | ||
| 621 | temp = HC_VERSION(ehci_readl(ehci, &ehci->caps->hc_capbase)); | 621 | temp = HC_VERSION(ehci_readl(ehci, &ehci->caps->hc_capbase)); |
| 622 | ehci_info (ehci, | 622 | ehci_info (ehci, |
| 623 | "USB %x.%x started, EHCI %x.%02x, driver %s%s\n", | 623 | "USB %x.%x started, EHCI %x.%02x%s\n", |
| 624 | ((ehci->sbrn & 0xf0)>>4), (ehci->sbrn & 0x0f), | 624 | ((ehci->sbrn & 0xf0)>>4), (ehci->sbrn & 0x0f), |
| 625 | temp >> 8, temp & 0xff, DRIVER_VERSION, | 625 | temp >> 8, temp & 0xff, |
| 626 | ignore_oc ? ", overcurrent ignored" : ""); | 626 | ignore_oc ? ", overcurrent ignored" : ""); |
| 627 | 627 | ||
| 628 | ehci_writel(ehci, INTR_MASK, | 628 | ehci_writel(ehci, INTR_MASK, |
| @@ -706,7 +706,7 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd) | |||
| 706 | pcd_status = status; | 706 | pcd_status = status; |
| 707 | 707 | ||
| 708 | /* resume root hub? */ | 708 | /* resume root hub? */ |
| 709 | if (!(ehci_readl(ehci, &ehci->regs->command) & CMD_RUN)) | 709 | if (!(cmd & CMD_RUN)) |
| 710 | usb_hcd_resume_root_hub(hcd); | 710 | usb_hcd_resume_root_hub(hcd); |
| 711 | 711 | ||
| 712 | while (i--) { | 712 | while (i--) { |
| @@ -715,8 +715,11 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd) | |||
| 715 | 715 | ||
| 716 | if (pstatus & PORT_OWNER) | 716 | if (pstatus & PORT_OWNER) |
| 717 | continue; | 717 | continue; |
| 718 | if (!(pstatus & PORT_RESUME) | 718 | if (!(test_bit(i, &ehci->suspended_ports) && |
| 719 | || ehci->reset_done [i] != 0) | 719 | ((pstatus & PORT_RESUME) || |
| 720 | !(pstatus & PORT_SUSPEND)) && | ||
| 721 | (pstatus & PORT_PE) && | ||
| 722 | ehci->reset_done[i] == 0)) | ||
| 720 | continue; | 723 | continue; |
| 721 | 724 | ||
| 722 | /* start 20 msec resume signaling from this port, | 725 | /* start 20 msec resume signaling from this port, |
| @@ -731,9 +734,8 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd) | |||
| 731 | 734 | ||
| 732 | /* PCI errors [4.15.2.4] */ | 735 | /* PCI errors [4.15.2.4] */ |
| 733 | if (unlikely ((status & STS_FATAL) != 0)) { | 736 | if (unlikely ((status & STS_FATAL) != 0)) { |
| 734 | dbg_cmd (ehci, "fatal", ehci_readl(ehci, | 737 | dbg_cmd(ehci, "fatal", cmd); |
| 735 | &ehci->regs->command)); | 738 | dbg_status(ehci, "fatal", status); |
| 736 | dbg_status (ehci, "fatal", status); | ||
| 737 | if (status & STS_HALT) { | 739 | if (status & STS_HALT) { |
| 738 | ehci_err (ehci, "fatal error\n"); | 740 | ehci_err (ehci, "fatal error\n"); |
| 739 | dead: | 741 | dead: |
| @@ -994,9 +996,7 @@ static int ehci_get_frame (struct usb_hcd *hcd) | |||
| 994 | 996 | ||
| 995 | /*-------------------------------------------------------------------------*/ | 997 | /*-------------------------------------------------------------------------*/ |
| 996 | 998 | ||
| 997 | #define DRIVER_INFO DRIVER_VERSION " " DRIVER_DESC | 999 | MODULE_DESCRIPTION(DRIVER_DESC); |
| 998 | |||
| 999 | MODULE_DESCRIPTION (DRIVER_INFO); | ||
| 1000 | MODULE_AUTHOR (DRIVER_AUTHOR); | 1000 | MODULE_AUTHOR (DRIVER_AUTHOR); |
| 1001 | MODULE_LICENSE ("GPL"); | 1001 | MODULE_LICENSE ("GPL"); |
| 1002 | 1002 | ||
| @@ -1020,11 +1020,6 @@ MODULE_LICENSE ("GPL"); | |||
| 1020 | #define PS3_SYSTEM_BUS_DRIVER ps3_ehci_driver | 1020 | #define PS3_SYSTEM_BUS_DRIVER ps3_ehci_driver |
| 1021 | #endif | 1021 | #endif |
| 1022 | 1022 | ||
| 1023 | #if defined(CONFIG_440EPX) && !defined(CONFIG_PPC_MERGE) | ||
| 1024 | #include "ehci-ppc-soc.c" | ||
| 1025 | #define PLATFORM_DRIVER ehci_ppc_soc_driver | ||
| 1026 | #endif | ||
| 1027 | |||
| 1028 | #ifdef CONFIG_USB_EHCI_HCD_PPC_OF | 1023 | #ifdef CONFIG_USB_EHCI_HCD_PPC_OF |
| 1029 | #include "ehci-ppc-of.c" | 1024 | #include "ehci-ppc-of.c" |
| 1030 | #define OF_PLATFORM_DRIVER ehci_hcd_ppc_of_driver | 1025 | #define OF_PLATFORM_DRIVER ehci_hcd_ppc_of_driver |
| @@ -1049,6 +1044,16 @@ static int __init ehci_hcd_init(void) | |||
| 1049 | { | 1044 | { |
| 1050 | int retval = 0; | 1045 | int retval = 0; |
| 1051 | 1046 | ||
| 1047 | if (usb_disabled()) | ||
| 1048 | return -ENODEV; | ||
| 1049 | |||
| 1050 | printk(KERN_INFO "%s: " DRIVER_DESC "\n", hcd_name); | ||
| 1051 | set_bit(USB_EHCI_LOADED, &usb_hcds_loaded); | ||
| 1052 | if (test_bit(USB_UHCI_LOADED, &usb_hcds_loaded) || | ||
| 1053 | test_bit(USB_OHCI_LOADED, &usb_hcds_loaded)) | ||
| 1054 | printk(KERN_WARNING "Warning! ehci_hcd should always be loaded" | ||
| 1055 | " before uhci_hcd and ohci_hcd, not after\n"); | ||
| 1056 | |||
| 1052 | pr_debug("%s: block sizes: qh %Zd qtd %Zd itd %Zd sitd %Zd\n", | 1057 | pr_debug("%s: block sizes: qh %Zd qtd %Zd itd %Zd sitd %Zd\n", |
| 1053 | hcd_name, | 1058 | hcd_name, |
| 1054 | sizeof(struct ehci_qh), sizeof(struct ehci_qtd), | 1059 | sizeof(struct ehci_qh), sizeof(struct ehci_qtd), |
| @@ -1056,8 +1061,10 @@ static int __init ehci_hcd_init(void) | |||
| 1056 | 1061 | ||
| 1057 | #ifdef DEBUG | 1062 | #ifdef DEBUG |
| 1058 | ehci_debug_root = debugfs_create_dir("ehci", NULL); | 1063 | ehci_debug_root = debugfs_create_dir("ehci", NULL); |
| 1059 | if (!ehci_debug_root) | 1064 | if (!ehci_debug_root) { |
| 1060 | return -ENOENT; | 1065 | retval = -ENOENT; |
| 1066 | goto err_debug; | ||
| 1067 | } | ||
| 1061 | #endif | 1068 | #endif |
| 1062 | 1069 | ||
| 1063 | #ifdef PLATFORM_DRIVER | 1070 | #ifdef PLATFORM_DRIVER |
| @@ -1105,6 +1112,8 @@ clean0: | |||
| 1105 | debugfs_remove(ehci_debug_root); | 1112 | debugfs_remove(ehci_debug_root); |
| 1106 | ehci_debug_root = NULL; | 1113 | ehci_debug_root = NULL; |
| 1107 | #endif | 1114 | #endif |
| 1115 | err_debug: | ||
| 1116 | clear_bit(USB_EHCI_LOADED, &usb_hcds_loaded); | ||
| 1108 | return retval; | 1117 | return retval; |
| 1109 | } | 1118 | } |
| 1110 | module_init(ehci_hcd_init); | 1119 | module_init(ehci_hcd_init); |
| @@ -1126,6 +1135,7 @@ static void __exit ehci_hcd_cleanup(void) | |||
| 1126 | #ifdef DEBUG | 1135 | #ifdef DEBUG |
| 1127 | debugfs_remove(ehci_debug_root); | 1136 | debugfs_remove(ehci_debug_root); |
| 1128 | #endif | 1137 | #endif |
| 1138 | clear_bit(USB_EHCI_LOADED, &usb_hcds_loaded); | ||
| 1129 | } | 1139 | } |
| 1130 | module_exit(ehci_hcd_cleanup); | 1140 | module_exit(ehci_hcd_cleanup); |
| 1131 | 1141 | ||
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c index 740835bb8575..218f9660d7ee 100644 --- a/drivers/usb/host/ehci-hub.c +++ b/drivers/usb/host/ehci-hub.c | |||
| @@ -236,10 +236,8 @@ static int ehci_bus_resume (struct usb_hcd *hcd) | |||
| 236 | temp = ehci_readl(ehci, &ehci->regs->port_status [i]); | 236 | temp = ehci_readl(ehci, &ehci->regs->port_status [i]); |
| 237 | temp &= ~(PORT_RWC_BITS | PORT_WAKE_BITS); | 237 | temp &= ~(PORT_RWC_BITS | PORT_WAKE_BITS); |
| 238 | if (test_bit(i, &ehci->bus_suspended) && | 238 | if (test_bit(i, &ehci->bus_suspended) && |
| 239 | (temp & PORT_SUSPEND)) { | 239 | (temp & PORT_SUSPEND)) |
| 240 | ehci->reset_done [i] = jiffies + msecs_to_jiffies (20); | ||
| 241 | temp |= PORT_RESUME; | 240 | temp |= PORT_RESUME; |
| 242 | } | ||
| 243 | ehci_writel(ehci, temp, &ehci->regs->port_status [i]); | 241 | ehci_writel(ehci, temp, &ehci->regs->port_status [i]); |
| 244 | } | 242 | } |
| 245 | i = HCS_N_PORTS (ehci->hcs_params); | 243 | i = HCS_N_PORTS (ehci->hcs_params); |
| @@ -482,10 +480,9 @@ ehci_hub_status_data (struct usb_hcd *hcd, char *buf) | |||
| 482 | * controller by the user. | 480 | * controller by the user. |
| 483 | */ | 481 | */ |
| 484 | 482 | ||
| 485 | if ((temp & mask) != 0 | 483 | if ((temp & mask) != 0 || test_bit(i, &ehci->port_c_suspend) |
| 486 | || ((temp & PORT_RESUME) != 0 | 484 | || (ehci->reset_done[i] && time_after_eq( |
| 487 | && time_after_eq(jiffies, | 485 | jiffies, ehci->reset_done[i]))) { |
| 488 | ehci->reset_done[i]))) { | ||
| 489 | if (i < 7) | 486 | if (i < 7) |
| 490 | buf [0] |= 1 << (i + 1); | 487 | buf [0] |= 1 << (i + 1); |
| 491 | else | 488 | else |
| @@ -688,6 +685,7 @@ static int ehci_hub_control ( | |||
| 688 | /* resume completed? */ | 685 | /* resume completed? */ |
| 689 | else if (time_after_eq(jiffies, | 686 | else if (time_after_eq(jiffies, |
| 690 | ehci->reset_done[wIndex])) { | 687 | ehci->reset_done[wIndex])) { |
| 688 | clear_bit(wIndex, &ehci->suspended_ports); | ||
| 691 | set_bit(wIndex, &ehci->port_c_suspend); | 689 | set_bit(wIndex, &ehci->port_c_suspend); |
| 692 | ehci->reset_done[wIndex] = 0; | 690 | ehci->reset_done[wIndex] = 0; |
| 693 | 691 | ||
| @@ -734,6 +732,9 @@ static int ehci_hub_control ( | |||
| 734 | ehci_readl(ehci, status_reg)); | 732 | ehci_readl(ehci, status_reg)); |
| 735 | } | 733 | } |
| 736 | 734 | ||
| 735 | if (!(temp & (PORT_RESUME|PORT_RESET))) | ||
| 736 | ehci->reset_done[wIndex] = 0; | ||
| 737 | |||
| 737 | /* transfer dedicated ports to the companion hc */ | 738 | /* transfer dedicated ports to the companion hc */ |
| 738 | if ((temp & PORT_CONNECT) && | 739 | if ((temp & PORT_CONNECT) && |
| 739 | test_bit(wIndex, &ehci->companion_ports)) { | 740 | test_bit(wIndex, &ehci->companion_ports)) { |
| @@ -757,8 +758,17 @@ static int ehci_hub_control ( | |||
| 757 | } | 758 | } |
| 758 | if (temp & PORT_PE) | 759 | if (temp & PORT_PE) |
| 759 | status |= 1 << USB_PORT_FEAT_ENABLE; | 760 | status |= 1 << USB_PORT_FEAT_ENABLE; |
| 760 | if (temp & (PORT_SUSPEND|PORT_RESUME)) | 761 | |
| 762 | /* maybe the port was unsuspended without our knowledge */ | ||
| 763 | if (temp & (PORT_SUSPEND|PORT_RESUME)) { | ||
| 761 | status |= 1 << USB_PORT_FEAT_SUSPEND; | 764 | status |= 1 << USB_PORT_FEAT_SUSPEND; |
| 765 | } else if (test_bit(wIndex, &ehci->suspended_ports)) { | ||
| 766 | clear_bit(wIndex, &ehci->suspended_ports); | ||
| 767 | ehci->reset_done[wIndex] = 0; | ||
| 768 | if (temp & PORT_PE) | ||
| 769 | set_bit(wIndex, &ehci->port_c_suspend); | ||
| 770 | } | ||
| 771 | |||
| 762 | if (temp & PORT_OC) | 772 | if (temp & PORT_OC) |
| 763 | status |= 1 << USB_PORT_FEAT_OVER_CURRENT; | 773 | status |= 1 << USB_PORT_FEAT_OVER_CURRENT; |
| 764 | if (temp & PORT_RESET) | 774 | if (temp & PORT_RESET) |
| @@ -803,6 +813,7 @@ static int ehci_hub_control ( | |||
| 803 | || (temp & PORT_RESET) != 0) | 813 | || (temp & PORT_RESET) != 0) |
| 804 | goto error; | 814 | goto error; |
| 805 | ehci_writel(ehci, temp | PORT_SUSPEND, status_reg); | 815 | ehci_writel(ehci, temp | PORT_SUSPEND, status_reg); |
| 816 | set_bit(wIndex, &ehci->suspended_ports); | ||
| 806 | break; | 817 | break; |
| 807 | case USB_PORT_FEAT_POWER: | 818 | case USB_PORT_FEAT_POWER: |
| 808 | if (HCS_PPC (ehci->hcs_params)) | 819 | if (HCS_PPC (ehci->hcs_params)) |
diff --git a/drivers/usb/host/ehci-ppc-soc.c b/drivers/usb/host/ehci-ppc-soc.c deleted file mode 100644 index 529590eb4037..000000000000 --- a/drivers/usb/host/ehci-ppc-soc.c +++ /dev/null | |||
| @@ -1,201 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * EHCI HCD (Host Controller Driver) for USB. | ||
| 3 | * | ||
| 4 | * (C) Copyright 2006-2007 Stefan Roese <sr@denx.de>, DENX Software Engineering | ||
| 5 | * | ||
| 6 | * Bus Glue for PPC On-Chip EHCI driver | ||
| 7 | * Tested on AMCC 440EPx | ||
| 8 | * | ||
| 9 | * Based on "ehci-au1xxx.c" by K.Boge <karsten.boge@amd.com> | ||
| 10 | * | ||
| 11 | * This file is licenced under the GPL. | ||
| 12 | */ | ||
| 13 | |||
| 14 | #include <linux/platform_device.h> | ||
| 15 | |||
| 16 | extern int usb_disabled(void); | ||
| 17 | |||
| 18 | /* called during probe() after chip reset completes */ | ||
| 19 | static int ehci_ppc_soc_setup(struct usb_hcd *hcd) | ||
| 20 | { | ||
| 21 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | ||
| 22 | int retval; | ||
| 23 | |||
| 24 | retval = ehci_halt(ehci); | ||
| 25 | if (retval) | ||
| 26 | return retval; | ||
| 27 | |||
| 28 | retval = ehci_init(hcd); | ||
| 29 | if (retval) | ||
| 30 | return retval; | ||
| 31 | |||
| 32 | ehci->sbrn = 0x20; | ||
| 33 | return ehci_reset(ehci); | ||
| 34 | } | ||
| 35 | |||
| 36 | /** | ||
| 37 | * usb_ehci_ppc_soc_probe - initialize PPC-SoC-based HCDs | ||
| 38 | * Context: !in_interrupt() | ||
| 39 | * | ||
| 40 | * Allocates basic resources for this USB host controller, and | ||
| 41 | * then invokes the start() method for the HCD associated with it | ||
| 42 | * through the hotplug entry's driver_data. | ||
| 43 | * | ||
| 44 | */ | ||
| 45 | int usb_ehci_ppc_soc_probe(const struct hc_driver *driver, | ||
| 46 | struct usb_hcd **hcd_out, | ||
| 47 | struct platform_device *dev) | ||
| 48 | { | ||
| 49 | int retval; | ||
| 50 | struct usb_hcd *hcd; | ||
| 51 | struct ehci_hcd *ehci; | ||
| 52 | |||
| 53 | if (dev->resource[1].flags != IORESOURCE_IRQ) { | ||
| 54 | pr_debug("resource[1] is not IORESOURCE_IRQ"); | ||
| 55 | retval = -ENOMEM; | ||
| 56 | } | ||
| 57 | hcd = usb_create_hcd(driver, &dev->dev, "PPC-SOC EHCI"); | ||
| 58 | if (!hcd) | ||
| 59 | return -ENOMEM; | ||
| 60 | hcd->rsrc_start = dev->resource[0].start; | ||
| 61 | hcd->rsrc_len = dev->resource[0].end - dev->resource[0].start + 1; | ||
| 62 | |||
| 63 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { | ||
| 64 | pr_debug("request_mem_region failed"); | ||
| 65 | retval = -EBUSY; | ||
| 66 | goto err1; | ||
| 67 | } | ||
| 68 | |||
| 69 | hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); | ||
| 70 | if (!hcd->regs) { | ||
| 71 | pr_debug("ioremap failed"); | ||
| 72 | retval = -ENOMEM; | ||
| 73 | goto err2; | ||
| 74 | } | ||
| 75 | |||
| 76 | ehci = hcd_to_ehci(hcd); | ||
| 77 | ehci->big_endian_mmio = 1; | ||
| 78 | ehci->big_endian_desc = 1; | ||
| 79 | ehci->caps = hcd->regs; | ||
| 80 | ehci->regs = hcd->regs + HC_LENGTH(ehci_readl(ehci, &ehci->caps->hc_capbase)); | ||
| 81 | |||
| 82 | /* cache this readonly data; minimize chip reads */ | ||
| 83 | ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params); | ||
| 84 | |||
| 85 | #if defined(CONFIG_440EPX) | ||
| 86 | /* | ||
| 87 | * 440EPx Errata USBH_3 | ||
| 88 | * Fix: Enable Break Memory Transfer (BMT) in INSNREG3 | ||
| 89 | */ | ||
| 90 | out_be32((void *)((ulong)(&ehci->regs->command) + 0x8c), (1 << 0)); | ||
| 91 | ehci_dbg(ehci, "Break Memory Transfer (BMT) has beed enabled!\n"); | ||
| 92 | #endif | ||
| 93 | |||
| 94 | retval = usb_add_hcd(hcd, dev->resource[1].start, IRQF_DISABLED); | ||
| 95 | if (retval == 0) | ||
| 96 | return retval; | ||
| 97 | |||
| 98 | iounmap(hcd->regs); | ||
| 99 | err2: | ||
| 100 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
| 101 | err1: | ||
| 102 | usb_put_hcd(hcd); | ||
| 103 | return retval; | ||
| 104 | } | ||
| 105 | |||
| 106 | /* may be called without controller electrically present */ | ||
| 107 | /* may be called with controller, bus, and devices active */ | ||
| 108 | |||
| 109 | /** | ||
| 110 | * usb_ehci_hcd_ppc_soc_remove - shutdown processing for PPC-SoC-based HCDs | ||
| 111 | * @dev: USB Host Controller being removed | ||
| 112 | * Context: !in_interrupt() | ||
| 113 | * | ||
| 114 | * Reverses the effect of usb_ehci_hcd_ppc_soc_probe(), first invoking | ||
| 115 | * the HCD's stop() method. It is always called from a thread | ||
| 116 | * context, normally "rmmod", "apmd", or something similar. | ||
| 117 | * | ||
| 118 | */ | ||
| 119 | void usb_ehci_ppc_soc_remove(struct usb_hcd *hcd, struct platform_device *dev) | ||
| 120 | { | ||
| 121 | usb_remove_hcd(hcd); | ||
| 122 | iounmap(hcd->regs); | ||
| 123 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
| 124 | usb_put_hcd(hcd); | ||
| 125 | } | ||
| 126 | |||
| 127 | static const struct hc_driver ehci_ppc_soc_hc_driver = { | ||
| 128 | .description = hcd_name, | ||
| 129 | .product_desc = "PPC-SOC EHCI", | ||
| 130 | .hcd_priv_size = sizeof(struct ehci_hcd), | ||
| 131 | |||
| 132 | /* | ||
| 133 | * generic hardware linkage | ||
| 134 | */ | ||
| 135 | .irq = ehci_irq, | ||
| 136 | .flags = HCD_MEMORY | HCD_USB2, | ||
| 137 | |||
| 138 | /* | ||
| 139 | * basic lifecycle operations | ||
| 140 | */ | ||
| 141 | .reset = ehci_ppc_soc_setup, | ||
| 142 | .start = ehci_run, | ||
| 143 | .stop = ehci_stop, | ||
| 144 | .shutdown = ehci_shutdown, | ||
| 145 | |||
| 146 | /* | ||
| 147 | * managing i/o requests and associated device resources | ||
| 148 | */ | ||
| 149 | .urb_enqueue = ehci_urb_enqueue, | ||
| 150 | .urb_dequeue = ehci_urb_dequeue, | ||
| 151 | .endpoint_disable = ehci_endpoint_disable, | ||
| 152 | |||
| 153 | /* | ||
| 154 | * scheduling support | ||
| 155 | */ | ||
| 156 | .get_frame_number = ehci_get_frame, | ||
| 157 | |||
| 158 | /* | ||
| 159 | * root hub support | ||
| 160 | */ | ||
| 161 | .hub_status_data = ehci_hub_status_data, | ||
| 162 | .hub_control = ehci_hub_control, | ||
| 163 | .bus_suspend = ehci_bus_suspend, | ||
| 164 | .bus_resume = ehci_bus_resume, | ||
| 165 | .relinquish_port = ehci_relinquish_port, | ||
| 166 | .port_handed_over = ehci_port_handed_over, | ||
| 167 | }; | ||
| 168 | |||
| 169 | static int ehci_hcd_ppc_soc_drv_probe(struct platform_device *pdev) | ||
| 170 | { | ||
| 171 | struct usb_hcd *hcd = NULL; | ||
| 172 | int ret; | ||
| 173 | |||
| 174 | pr_debug("In ehci_hcd_ppc_soc_drv_probe\n"); | ||
| 175 | |||
| 176 | if (usb_disabled()) | ||
| 177 | return -ENODEV; | ||
| 178 | |||
| 179 | /* FIXME we only want one one probe() not two */ | ||
| 180 | ret = usb_ehci_ppc_soc_probe(&ehci_ppc_soc_hc_driver, &hcd, pdev); | ||
| 181 | return ret; | ||
| 182 | } | ||
| 183 | |||
| 184 | static int ehci_hcd_ppc_soc_drv_remove(struct platform_device *pdev) | ||
| 185 | { | ||
| 186 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | ||
| 187 | |||
| 188 | /* FIXME we only want one one remove() not two */ | ||
| 189 | usb_ehci_ppc_soc_remove(hcd, pdev); | ||
| 190 | return 0; | ||
| 191 | } | ||
| 192 | |||
| 193 | MODULE_ALIAS("platform:ppc-soc-ehci"); | ||
| 194 | static struct platform_driver ehci_ppc_soc_driver = { | ||
| 195 | .probe = ehci_hcd_ppc_soc_drv_probe, | ||
| 196 | .remove = ehci_hcd_ppc_soc_drv_remove, | ||
| 197 | .shutdown = usb_hcd_platform_shutdown, | ||
| 198 | .driver = { | ||
| 199 | .name = "ppc-soc-ehci", | ||
| 200 | } | ||
| 201 | }; | ||
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h index b697a13364ec..b11798d17ae5 100644 --- a/drivers/usb/host/ehci.h +++ b/drivers/usb/host/ehci.h | |||
| @@ -99,6 +99,8 @@ struct ehci_hcd { /* one per controller */ | |||
| 99 | owned by the companion during a bus suspend */ | 99 | owned by the companion during a bus suspend */ |
| 100 | unsigned long port_c_suspend; /* which ports have | 100 | unsigned long port_c_suspend; /* which ports have |
| 101 | the change-suspend feature turned on */ | 101 | the change-suspend feature turned on */ |
| 102 | unsigned long suspended_ports; /* which ports are | ||
| 103 | suspended */ | ||
| 102 | 104 | ||
| 103 | /* per-HC memory pools (could be per-bus, but ...) */ | 105 | /* per-HC memory pools (could be per-bus, but ...) */ |
| 104 | struct dma_pool *qh_pool; /* qh per active urb */ | 106 | struct dma_pool *qh_pool; /* qh per active urb */ |
| @@ -181,14 +183,16 @@ timer_action (struct ehci_hcd *ehci, enum ehci_timer_action action) | |||
| 181 | * the async ring; just the I/O watchdog. Note that if a | 183 | * the async ring; just the I/O watchdog. Note that if a |
| 182 | * SHRINK were pending, OFF would never be requested. | 184 | * SHRINK were pending, OFF would never be requested. |
| 183 | */ | 185 | */ |
| 184 | if (timer_pending(&ehci->watchdog) | 186 | enum ehci_timer_action oldactions = ehci->actions; |
| 185 | && ((BIT(TIMER_ASYNC_SHRINK) | BIT(TIMER_ASYNC_OFF)) | ||
| 186 | & ehci->actions)) | ||
| 187 | return; | ||
| 188 | 187 | ||
| 189 | if (!test_and_set_bit (action, &ehci->actions)) { | 188 | if (!test_and_set_bit (action, &ehci->actions)) { |
| 190 | unsigned long t; | 189 | unsigned long t; |
| 191 | 190 | ||
| 191 | if (timer_pending(&ehci->watchdog) | ||
| 192 | && ((BIT(TIMER_ASYNC_SHRINK) | BIT(TIMER_ASYNC_OFF)) | ||
| 193 | & oldactions)) | ||
| 194 | return; | ||
| 195 | |||
| 192 | switch (action) { | 196 | switch (action) { |
| 193 | case TIMER_IO_WATCHDOG: | 197 | case TIMER_IO_WATCHDOG: |
| 194 | t = EHCI_IO_JIFFIES; | 198 | t = EHCI_IO_JIFFIES; |
| @@ -204,7 +208,7 @@ timer_action (struct ehci_hcd *ehci, enum ehci_timer_action action) | |||
| 204 | t = DIV_ROUND_UP(EHCI_SHRINK_FRAMES * HZ, 1000) + 1; | 208 | t = DIV_ROUND_UP(EHCI_SHRINK_FRAMES * HZ, 1000) + 1; |
| 205 | break; | 209 | break; |
| 206 | } | 210 | } |
| 207 | mod_timer(&ehci->watchdog, t + jiffies); | 211 | mod_timer(&ehci->watchdog, round_jiffies(t + jiffies)); |
| 208 | } | 212 | } |
| 209 | } | 213 | } |
| 210 | 214 | ||
| @@ -604,16 +608,7 @@ ehci_port_speed(struct ehci_hcd *ehci, unsigned int portsc) | |||
| 604 | /* | 608 | /* |
| 605 | * Big-endian read/write functions are arch-specific. | 609 | * Big-endian read/write functions are arch-specific. |
| 606 | * Other arches can be added if/when they're needed. | 610 | * Other arches can be added if/when they're needed. |
| 607 | * | ||
| 608 | * REVISIT: arch/powerpc now has readl/writel_be, so the | ||
| 609 | * definition below can die once the 4xx support is | ||
| 610 | * finally ported over. | ||
| 611 | */ | 611 | */ |
| 612 | #if defined(CONFIG_PPC) && !defined(CONFIG_PPC_MERGE) | ||
| 613 | #define readl_be(addr) in_be32((__force unsigned *)addr) | ||
| 614 | #define writel_be(val, addr) out_be32((__force unsigned *)addr, val) | ||
| 615 | #endif | ||
| 616 | |||
| 617 | #if defined(CONFIG_ARM) && defined(CONFIG_ARCH_IXP4XX) | 612 | #if defined(CONFIG_ARM) && defined(CONFIG_ARCH_IXP4XX) |
| 618 | #define readl_be(addr) __raw_readl((__force unsigned *)addr) | 613 | #define readl_be(addr) __raw_readl((__force unsigned *)addr) |
| 619 | #define writel_be(val, addr) __raw_writel(val, (__force unsigned *)addr) | 614 | #define writel_be(val, addr) __raw_writel(val, (__force unsigned *)addr) |
diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c index ce1ca0ba0515..4dda31b26892 100644 --- a/drivers/usb/host/isp116x-hcd.c +++ b/drivers/usb/host/isp116x-hcd.c | |||
| @@ -1562,11 +1562,12 @@ static int __devinit isp116x_probe(struct platform_device *pdev) | |||
| 1562 | { | 1562 | { |
| 1563 | struct usb_hcd *hcd; | 1563 | struct usb_hcd *hcd; |
| 1564 | struct isp116x *isp116x; | 1564 | struct isp116x *isp116x; |
| 1565 | struct resource *addr, *data; | 1565 | struct resource *addr, *data, *ires; |
| 1566 | void __iomem *addr_reg; | 1566 | void __iomem *addr_reg; |
| 1567 | void __iomem *data_reg; | 1567 | void __iomem *data_reg; |
| 1568 | int irq; | 1568 | int irq; |
| 1569 | int ret = 0; | 1569 | int ret = 0; |
| 1570 | unsigned long irqflags; | ||
| 1570 | 1571 | ||
| 1571 | if (pdev->num_resources < 3) { | 1572 | if (pdev->num_resources < 3) { |
| 1572 | ret = -ENODEV; | 1573 | ret = -ENODEV; |
| @@ -1575,12 +1576,16 @@ static int __devinit isp116x_probe(struct platform_device *pdev) | |||
| 1575 | 1576 | ||
| 1576 | data = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 1577 | data = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 1577 | addr = platform_get_resource(pdev, IORESOURCE_MEM, 1); | 1578 | addr = platform_get_resource(pdev, IORESOURCE_MEM, 1); |
| 1578 | irq = platform_get_irq(pdev, 0); | 1579 | ires = platform_get_resource(pdev, IORESOURCE_IRQ, 0); |
| 1579 | if (!addr || !data || irq < 0) { | 1580 | |
| 1581 | if (!addr || !data || !ires) { | ||
| 1580 | ret = -ENODEV; | 1582 | ret = -ENODEV; |
| 1581 | goto err1; | 1583 | goto err1; |
| 1582 | } | 1584 | } |
| 1583 | 1585 | ||
| 1586 | irq = ires->start; | ||
| 1587 | irqflags = ires->flags & IRQF_TRIGGER_MASK; | ||
| 1588 | |||
| 1584 | if (pdev->dev.dma_mask) { | 1589 | if (pdev->dev.dma_mask) { |
| 1585 | DBG("DMA not supported\n"); | 1590 | DBG("DMA not supported\n"); |
| 1586 | ret = -EINVAL; | 1591 | ret = -EINVAL; |
| @@ -1634,7 +1639,7 @@ static int __devinit isp116x_probe(struct platform_device *pdev) | |||
| 1634 | goto err6; | 1639 | goto err6; |
| 1635 | } | 1640 | } |
| 1636 | 1641 | ||
| 1637 | ret = usb_add_hcd(hcd, irq, IRQF_DISABLED); | 1642 | ret = usb_add_hcd(hcd, irq, irqflags | IRQF_DISABLED); |
| 1638 | if (ret) | 1643 | if (ret) |
| 1639 | goto err6; | 1644 | goto err6; |
| 1640 | 1645 | ||
diff --git a/drivers/usb/host/isp1760-if.c b/drivers/usb/host/isp1760-if.c index 051ef7b6bdc6..af849f596135 100644 --- a/drivers/usb/host/isp1760-if.c +++ b/drivers/usb/host/isp1760-if.c | |||
| @@ -218,7 +218,7 @@ static int __devinit isp1761_pci_probe(struct pci_dev *dev, | |||
| 218 | * and reading back and checking the contents are same or not | 218 | * and reading back and checking the contents are same or not |
| 219 | */ | 219 | */ |
| 220 | if (reg_data != 0xFACE) { | 220 | if (reg_data != 0xFACE) { |
| 221 | err("scratch register mismatch %x", reg_data); | 221 | dev_err(&dev->dev, "scratch register mismatch %x\n", reg_data); |
| 222 | goto clean; | 222 | goto clean; |
| 223 | } | 223 | } |
| 224 | 224 | ||
| @@ -232,9 +232,10 @@ static int __devinit isp1761_pci_probe(struct pci_dev *dev, | |||
| 232 | hcd = isp1760_register(pci_mem_phy0, length, dev->irq, | 232 | hcd = isp1760_register(pci_mem_phy0, length, dev->irq, |
| 233 | IRQF_SHARED | IRQF_DISABLED, &dev->dev, dev_name(&dev->dev), | 233 | IRQF_SHARED | IRQF_DISABLED, &dev->dev, dev_name(&dev->dev), |
| 234 | devflags); | 234 | devflags); |
| 235 | pci_set_drvdata(dev, hcd); | 235 | if (!IS_ERR(hcd)) { |
| 236 | if (!hcd) | 236 | pci_set_drvdata(dev, hcd); |
| 237 | return 0; | 237 | return 0; |
| 238 | } | ||
| 238 | clean: | 239 | clean: |
| 239 | status = -ENODEV; | 240 | status = -ENODEV; |
| 240 | iounmap(iobase); | 241 | iounmap(iobase); |
diff --git a/drivers/usb/host/ohci-dbg.c b/drivers/usb/host/ohci-dbg.c index 7cef1d2f7ccc..d3269656aa4d 100644 --- a/drivers/usb/host/ohci-dbg.c +++ b/drivers/usb/host/ohci-dbg.c | |||
| @@ -649,7 +649,7 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf) | |||
| 649 | ohci_dbg_sw (ohci, &next, &size, | 649 | ohci_dbg_sw (ohci, &next, &size, |
| 650 | "bus %s, device %s\n" | 650 | "bus %s, device %s\n" |
| 651 | "%s\n" | 651 | "%s\n" |
| 652 | "%s version " DRIVER_VERSION "\n", | 652 | "%s\n", |
| 653 | hcd->self.controller->bus->name, | 653 | hcd->self.controller->bus->name, |
| 654 | dev_name(hcd->self.controller), | 654 | dev_name(hcd->self.controller), |
| 655 | hcd->product_desc, | 655 | hcd->product_desc, |
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index 89901962cbfd..8647dab0d7f9 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c | |||
| @@ -46,7 +46,6 @@ | |||
| 46 | 46 | ||
| 47 | #include "../core/hcd.h" | 47 | #include "../core/hcd.h" |
| 48 | 48 | ||
| 49 | #define DRIVER_VERSION "2006 August 04" | ||
| 50 | #define DRIVER_AUTHOR "Roman Weissgaerber, David Brownell" | 49 | #define DRIVER_AUTHOR "Roman Weissgaerber, David Brownell" |
| 51 | #define DRIVER_DESC "USB 1.1 'Open' Host Controller (OHCI) Driver" | 50 | #define DRIVER_DESC "USB 1.1 'Open' Host Controller (OHCI) Driver" |
| 52 | 51 | ||
| @@ -984,10 +983,8 @@ static int ohci_restart (struct ohci_hcd *ohci) | |||
| 984 | 983 | ||
| 985 | /*-------------------------------------------------------------------------*/ | 984 | /*-------------------------------------------------------------------------*/ |
| 986 | 985 | ||
| 987 | #define DRIVER_INFO DRIVER_VERSION " " DRIVER_DESC | ||
| 988 | |||
| 989 | MODULE_AUTHOR (DRIVER_AUTHOR); | 986 | MODULE_AUTHOR (DRIVER_AUTHOR); |
| 990 | MODULE_DESCRIPTION (DRIVER_INFO); | 987 | MODULE_DESCRIPTION(DRIVER_DESC); |
| 991 | MODULE_LICENSE ("GPL"); | 988 | MODULE_LICENSE ("GPL"); |
| 992 | 989 | ||
| 993 | #ifdef CONFIG_PCI | 990 | #ifdef CONFIG_PCI |
| @@ -1095,9 +1092,10 @@ static int __init ohci_hcd_mod_init(void) | |||
| 1095 | if (usb_disabled()) | 1092 | if (usb_disabled()) |
| 1096 | return -ENODEV; | 1093 | return -ENODEV; |
| 1097 | 1094 | ||
| 1098 | printk (KERN_DEBUG "%s: " DRIVER_INFO "\n", hcd_name); | 1095 | printk(KERN_INFO "%s: " DRIVER_DESC "\n", hcd_name); |
| 1099 | pr_debug ("%s: block sizes: ed %Zd td %Zd\n", hcd_name, | 1096 | pr_debug ("%s: block sizes: ed %Zd td %Zd\n", hcd_name, |
| 1100 | sizeof (struct ed), sizeof (struct td)); | 1097 | sizeof (struct ed), sizeof (struct td)); |
| 1098 | set_bit(USB_OHCI_LOADED, &usb_hcds_loaded); | ||
| 1101 | 1099 | ||
| 1102 | #ifdef DEBUG | 1100 | #ifdef DEBUG |
| 1103 | ohci_debug_root = debugfs_create_dir("ohci", NULL); | 1101 | ohci_debug_root = debugfs_create_dir("ohci", NULL); |
| @@ -1184,6 +1182,7 @@ static int __init ohci_hcd_mod_init(void) | |||
| 1184 | error_debug: | 1182 | error_debug: |
| 1185 | #endif | 1183 | #endif |
| 1186 | 1184 | ||
| 1185 | clear_bit(USB_OHCI_LOADED, &usb_hcds_loaded); | ||
| 1187 | return retval; | 1186 | return retval; |
| 1188 | } | 1187 | } |
| 1189 | module_init(ohci_hcd_mod_init); | 1188 | module_init(ohci_hcd_mod_init); |
| @@ -1214,6 +1213,7 @@ static void __exit ohci_hcd_mod_exit(void) | |||
| 1214 | #ifdef DEBUG | 1213 | #ifdef DEBUG |
| 1215 | debugfs_remove(ohci_debug_root); | 1214 | debugfs_remove(ohci_debug_root); |
| 1216 | #endif | 1215 | #endif |
| 1216 | clear_bit(USB_OHCI_LOADED, &usb_hcds_loaded); | ||
| 1217 | } | 1217 | } |
| 1218 | module_exit(ohci_hcd_mod_exit); | 1218 | module_exit(ohci_hcd_mod_exit); |
| 1219 | 1219 | ||
diff --git a/drivers/usb/host/ohci-hub.c b/drivers/usb/host/ohci-hub.c index 7ea9a7b31155..32bbce9718f0 100644 --- a/drivers/usb/host/ohci-hub.c +++ b/drivers/usb/host/ohci-hub.c | |||
| @@ -359,21 +359,24 @@ static void ohci_finish_controller_resume(struct usb_hcd *hcd) | |||
| 359 | 359 | ||
| 360 | /* Carry out polling-, autostop-, and autoresume-related state changes */ | 360 | /* Carry out polling-, autostop-, and autoresume-related state changes */ |
| 361 | static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed, | 361 | static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed, |
| 362 | int any_connected) | 362 | int any_connected, int rhsc_status) |
| 363 | { | 363 | { |
| 364 | int poll_rh = 1; | 364 | int poll_rh = 1; |
| 365 | int rhsc; | 365 | int rhsc_enable; |
| 366 | 366 | ||
| 367 | rhsc = ohci_readl(ohci, &ohci->regs->intrenable) & OHCI_INTR_RHSC; | 367 | /* Some broken controllers never turn off RHCS in the interrupt |
| 368 | switch (ohci->hc_control & OHCI_CTRL_HCFS) { | 368 | * status register. For their sake we won't re-enable RHSC |
| 369 | * interrupts if the interrupt bit is already active. | ||
| 370 | */ | ||
| 371 | rhsc_enable = ohci_readl(ohci, &ohci->regs->intrenable) & | ||
| 372 | OHCI_INTR_RHSC; | ||
| 369 | 373 | ||
| 374 | switch (ohci->hc_control & OHCI_CTRL_HCFS) { | ||
| 370 | case OHCI_USB_OPER: | 375 | case OHCI_USB_OPER: |
| 371 | /* If no status changes are pending, enable status-change | 376 | /* If no status changes are pending, enable RHSC interrupts. */ |
| 372 | * interrupts. | 377 | if (!rhsc_enable && !rhsc_status && !changed) { |
| 373 | */ | 378 | rhsc_enable = OHCI_INTR_RHSC; |
| 374 | if (!rhsc && !changed) { | 379 | ohci_writel(ohci, rhsc_enable, &ohci->regs->intrenable); |
| 375 | rhsc = OHCI_INTR_RHSC; | ||
| 376 | ohci_writel(ohci, rhsc, &ohci->regs->intrenable); | ||
| 377 | } | 380 | } |
| 378 | 381 | ||
| 379 | /* Keep on polling until we know a device is connected | 382 | /* Keep on polling until we know a device is connected |
| @@ -383,7 +386,7 @@ static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed, | |||
| 383 | if (any_connected || | 386 | if (any_connected || |
| 384 | !device_may_wakeup(&ohci_to_hcd(ohci) | 387 | !device_may_wakeup(&ohci_to_hcd(ohci) |
| 385 | ->self.root_hub->dev)) { | 388 | ->self.root_hub->dev)) { |
| 386 | if (rhsc) | 389 | if (rhsc_enable) |
| 387 | poll_rh = 0; | 390 | poll_rh = 0; |
| 388 | } else { | 391 | } else { |
| 389 | ohci->autostop = 1; | 392 | ohci->autostop = 1; |
| @@ -396,34 +399,45 @@ static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed, | |||
| 396 | ohci->autostop = 0; | 399 | ohci->autostop = 0; |
| 397 | ohci->next_statechange = jiffies + | 400 | ohci->next_statechange = jiffies + |
| 398 | STATECHANGE_DELAY; | 401 | STATECHANGE_DELAY; |
| 399 | } else if (rhsc && time_after_eq(jiffies, | 402 | } else if (time_after_eq(jiffies, |
| 400 | ohci->next_statechange) | 403 | ohci->next_statechange) |
| 401 | && !ohci->ed_rm_list | 404 | && !ohci->ed_rm_list |
| 402 | && !(ohci->hc_control & | 405 | && !(ohci->hc_control & |
| 403 | OHCI_SCHED_ENABLES)) { | 406 | OHCI_SCHED_ENABLES)) { |
| 404 | ohci_rh_suspend(ohci, 1); | 407 | ohci_rh_suspend(ohci, 1); |
| 405 | poll_rh = 0; | 408 | if (rhsc_enable) |
| 409 | poll_rh = 0; | ||
| 406 | } | 410 | } |
| 407 | } | 411 | } |
| 408 | break; | 412 | break; |
| 409 | 413 | ||
| 410 | /* if there is a port change, autostart or ask to be resumed */ | ||
| 411 | case OHCI_USB_SUSPEND: | 414 | case OHCI_USB_SUSPEND: |
| 412 | case OHCI_USB_RESUME: | 415 | case OHCI_USB_RESUME: |
| 416 | /* if there is a port change, autostart or ask to be resumed */ | ||
| 413 | if (changed) { | 417 | if (changed) { |
| 414 | if (ohci->autostop) | 418 | if (ohci->autostop) |
| 415 | ohci_rh_resume(ohci); | 419 | ohci_rh_resume(ohci); |
| 416 | else | 420 | else |
| 417 | usb_hcd_resume_root_hub(ohci_to_hcd(ohci)); | 421 | usb_hcd_resume_root_hub(ohci_to_hcd(ohci)); |
| 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 | 422 | ||
| 425 | /* everything is idle, no need for polling */ | 423 | /* If remote wakeup is disabled, stop polling */ |
| 424 | } else if (!ohci->autostop && | ||
| 425 | !ohci_to_hcd(ohci)->self.root_hub-> | ||
| 426 | do_remote_wakeup) { | ||
| 426 | poll_rh = 0; | 427 | poll_rh = 0; |
| 428 | |||
| 429 | } else { | ||
| 430 | /* If no status changes are pending, | ||
| 431 | * enable RHSC interrupts | ||
| 432 | */ | ||
| 433 | if (!rhsc_enable && !rhsc_status) { | ||
| 434 | rhsc_enable = OHCI_INTR_RHSC; | ||
| 435 | ohci_writel(ohci, rhsc_enable, | ||
| 436 | &ohci->regs->intrenable); | ||
| 437 | } | ||
| 438 | /* Keep polling until RHSC is enabled */ | ||
| 439 | if (rhsc_enable) | ||
| 440 | poll_rh = 0; | ||
| 427 | } | 441 | } |
| 428 | break; | 442 | break; |
| 429 | } | 443 | } |
| @@ -441,18 +455,22 @@ static inline int ohci_rh_resume(struct ohci_hcd *ohci) | |||
| 441 | * autostop isn't used when CONFIG_PM is turned off. | 455 | * autostop isn't used when CONFIG_PM is turned off. |
| 442 | */ | 456 | */ |
| 443 | static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed, | 457 | static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed, |
| 444 | int any_connected) | 458 | int any_connected, int rhsc_status) |
| 445 | { | 459 | { |
| 446 | /* If RHSC is enabled, don't poll */ | 460 | /* If RHSC is enabled, don't poll */ |
| 447 | if (ohci_readl(ohci, &ohci->regs->intrenable) & OHCI_INTR_RHSC) | 461 | if (ohci_readl(ohci, &ohci->regs->intrenable) & OHCI_INTR_RHSC) |
| 448 | return 0; | 462 | return 0; |
| 449 | 463 | ||
| 450 | /* If no status changes are pending, enable status-change interrupts */ | 464 | /* If status changes are pending, continue polling. |
| 451 | if (!changed) { | 465 | * Conversely, if no status changes are pending but the RHSC |
| 452 | ohci_writel(ohci, OHCI_INTR_RHSC, &ohci->regs->intrenable); | 466 | * status bit was set, then RHSC may be broken so continue polling. |
| 453 | return 0; | 467 | */ |
| 454 | } | 468 | if (changed || rhsc_status) |
| 455 | return 1; | 469 | return 1; |
| 470 | |||
| 471 | /* It's safe to re-enable RHSC interrupts */ | ||
| 472 | ohci_writel(ohci, OHCI_INTR_RHSC, &ohci->regs->intrenable); | ||
| 473 | return 0; | ||
| 456 | } | 474 | } |
| 457 | 475 | ||
| 458 | #endif /* CONFIG_PM */ | 476 | #endif /* CONFIG_PM */ |
| @@ -467,6 +485,7 @@ ohci_hub_status_data (struct usb_hcd *hcd, char *buf) | |||
| 467 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); | 485 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); |
| 468 | int i, changed = 0, length = 1; | 486 | int i, changed = 0, length = 1; |
| 469 | int any_connected = 0; | 487 | int any_connected = 0; |
| 488 | int rhsc_status; | ||
| 470 | unsigned long flags; | 489 | unsigned long flags; |
| 471 | 490 | ||
| 472 | spin_lock_irqsave (&ohci->lock, flags); | 491 | spin_lock_irqsave (&ohci->lock, flags); |
| @@ -492,12 +511,10 @@ ohci_hub_status_data (struct usb_hcd *hcd, char *buf) | |||
| 492 | length++; | 511 | length++; |
| 493 | } | 512 | } |
| 494 | 513 | ||
| 495 | /* Some broken controllers never turn off RHCS in the interrupt | 514 | /* Clear the RHSC status flag before reading the port statuses */ |
| 496 | * status register. For their sake we won't re-enable RHSC | 515 | ohci_writel(ohci, OHCI_INTR_RHSC, &ohci->regs->intrstatus); |
| 497 | * interrupts if the flag is already set. | 516 | rhsc_status = ohci_readl(ohci, &ohci->regs->intrstatus) & |
| 498 | */ | 517 | OHCI_INTR_RHSC; |
| 499 | if (ohci_readl(ohci, &ohci->regs->intrstatus) & OHCI_INTR_RHSC) | ||
| 500 | changed = 1; | ||
| 501 | 518 | ||
| 502 | /* look at each port */ | 519 | /* look at each port */ |
| 503 | for (i = 0; i < ohci->num_ports; i++) { | 520 | for (i = 0; i < ohci->num_ports; i++) { |
| @@ -517,7 +534,7 @@ ohci_hub_status_data (struct usb_hcd *hcd, char *buf) | |||
| 517 | } | 534 | } |
| 518 | 535 | ||
| 519 | hcd->poll_rh = ohci_root_hub_state_changes(ohci, changed, | 536 | hcd->poll_rh = ohci_root_hub_state_changes(ohci, changed, |
| 520 | any_connected); | 537 | any_connected, rhsc_status); |
| 521 | 538 | ||
| 522 | done: | 539 | done: |
| 523 | spin_unlock_irqrestore (&ohci->lock, flags); | 540 | spin_unlock_irqrestore (&ohci->lock, flags); |
diff --git a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c index 522185629624..91697bdb399f 100644 --- a/drivers/usb/host/ohci-omap.c +++ b/drivers/usb/host/ohci-omap.c | |||
| @@ -231,7 +231,7 @@ static int ohci_omap_init(struct usb_hcd *hcd) | |||
| 231 | 231 | ||
| 232 | omap_ohci_clock_power(1); | 232 | omap_ohci_clock_power(1); |
| 233 | 233 | ||
| 234 | if (cpu_is_omap1510()) { | 234 | if (cpu_is_omap15xx()) { |
| 235 | omap_1510_local_bus_power(1); | 235 | omap_1510_local_bus_power(1); |
| 236 | omap_1510_local_bus_init(); | 236 | omap_1510_local_bus_init(); |
| 237 | } | 237 | } |
| @@ -319,7 +319,7 @@ static int usb_hcd_omap_probe (const struct hc_driver *driver, | |||
| 319 | if (IS_ERR(usb_host_ck)) | 319 | if (IS_ERR(usb_host_ck)) |
| 320 | return PTR_ERR(usb_host_ck); | 320 | return PTR_ERR(usb_host_ck); |
| 321 | 321 | ||
| 322 | if (!cpu_is_omap1510()) | 322 | if (!cpu_is_omap15xx()) |
| 323 | usb_dc_ck = clk_get(0, "usb_dc_ck"); | 323 | usb_dc_ck = clk_get(0, "usb_dc_ck"); |
| 324 | else | 324 | else |
| 325 | usb_dc_ck = clk_get(0, "lb_ck"); | 325 | usb_dc_ck = clk_get(0, "lb_ck"); |
diff --git a/drivers/usb/host/ohci-pnx4008.c b/drivers/usb/host/ohci-pnx4008.c index 658a2a978c32..e306ca6aef3d 100644 --- a/drivers/usb/host/ohci-pnx4008.c +++ b/drivers/usb/host/ohci-pnx4008.c | |||
| @@ -331,7 +331,7 @@ static int __devinit usb_hcd_pnx4008_probe(struct platform_device *pdev) | |||
| 331 | 331 | ||
| 332 | int ret = 0, irq; | 332 | int ret = 0, irq; |
| 333 | 333 | ||
| 334 | dev_dbg(&pdev->dev, "%s: " DRIVER_INFO " (pnx4008)\n", hcd_name); | 334 | dev_dbg(&pdev->dev, "%s: " DRIVER_DESC " (pnx4008)\n", hcd_name); |
| 335 | if (usb_disabled()) { | 335 | if (usb_disabled()) { |
| 336 | err("USB is disabled"); | 336 | err("USB is disabled"); |
| 337 | ret = -ENODEV; | 337 | ret = -ENODEV; |
diff --git a/drivers/usb/host/ohci.h b/drivers/usb/host/ohci.h index faf622eafce7..222011f6172c 100644 --- a/drivers/usb/host/ohci.h +++ b/drivers/usb/host/ohci.h | |||
| @@ -540,15 +540,7 @@ static inline struct usb_hcd *ohci_to_hcd (const struct ohci_hcd *ohci) | |||
| 540 | * Big-endian read/write functions are arch-specific. | 540 | * Big-endian read/write functions are arch-specific. |
| 541 | * Other arches can be added if/when they're needed. | 541 | * Other arches can be added if/when they're needed. |
| 542 | * | 542 | * |
| 543 | * REVISIT: arch/powerpc now has readl/writel_be, so the | ||
| 544 | * definition below can die once the STB04xxx support is | ||
| 545 | * finally ported over. | ||
| 546 | */ | 543 | */ |
| 547 | #if defined(CONFIG_PPC) && !defined(CONFIG_PPC_MERGE) | ||
| 548 | #define readl_be(addr) in_be32((__force unsigned *)addr) | ||
| 549 | #define writel_be(val, addr) out_be32((__force unsigned *)addr, val) | ||
| 550 | #endif | ||
| 551 | |||
| 552 | static inline unsigned int _ohci_readl (const struct ohci_hcd *ohci, | 544 | static inline unsigned int _ohci_readl (const struct ohci_hcd *ohci, |
| 553 | __hc32 __iomem * regs) | 545 | __hc32 __iomem * regs) |
| 554 | { | 546 | { |
diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c index ea7126f99cab..c18d8790c410 100644 --- a/drivers/usb/host/r8a66597-hcd.c +++ b/drivers/usb/host/r8a66597-hcd.c | |||
| @@ -66,7 +66,7 @@ static unsigned short endian; | |||
| 66 | module_param(endian, ushort, 0644); | 66 | module_param(endian, ushort, 0644); |
| 67 | MODULE_PARM_DESC(endian, "data endian: big=256, little=0 (default=0)"); | 67 | MODULE_PARM_DESC(endian, "data endian: big=256, little=0 (default=0)"); |
| 68 | 68 | ||
| 69 | static unsigned short irq_sense = INTL; | 69 | static unsigned short irq_sense = 0xff; |
| 70 | module_param(irq_sense, ushort, 0644); | 70 | module_param(irq_sense, ushort, 0644); |
| 71 | MODULE_PARM_DESC(irq_sense, "IRQ sense: low level=32, falling edge=0 " | 71 | MODULE_PARM_DESC(irq_sense, "IRQ sense: low level=32, falling edge=0 " |
| 72 | "(default=32)"); | 72 | "(default=32)"); |
| @@ -118,7 +118,7 @@ static int r8a66597_clock_enable(struct r8a66597 *r8a66597) | |||
| 118 | r8a66597_write(r8a66597, SCKE, SYSCFG0); | 118 | r8a66597_write(r8a66597, SCKE, SYSCFG0); |
| 119 | tmp = r8a66597_read(r8a66597, SYSCFG0); | 119 | tmp = r8a66597_read(r8a66597, SYSCFG0); |
| 120 | if (i++ > 1000) { | 120 | if (i++ > 1000) { |
| 121 | err("register access fail."); | 121 | printk(KERN_ERR "r8a66597: register access fail.\n"); |
| 122 | return -ENXIO; | 122 | return -ENXIO; |
| 123 | } | 123 | } |
| 124 | } while ((tmp & SCKE) != SCKE); | 124 | } while ((tmp & SCKE) != SCKE); |
| @@ -128,7 +128,7 @@ static int r8a66597_clock_enable(struct r8a66597 *r8a66597) | |||
| 128 | r8a66597_write(r8a66597, USBE, SYSCFG0); | 128 | r8a66597_write(r8a66597, USBE, SYSCFG0); |
| 129 | tmp = r8a66597_read(r8a66597, SYSCFG0); | 129 | tmp = r8a66597_read(r8a66597, SYSCFG0); |
| 130 | if (i++ > 1000) { | 130 | if (i++ > 1000) { |
| 131 | err("register access fail."); | 131 | printk(KERN_ERR "r8a66597: register access fail.\n"); |
| 132 | return -ENXIO; | 132 | return -ENXIO; |
| 133 | } | 133 | } |
| 134 | } while ((tmp & USBE) != USBE); | 134 | } while ((tmp & USBE) != USBE); |
| @@ -141,7 +141,7 @@ static int r8a66597_clock_enable(struct r8a66597 *r8a66597) | |||
| 141 | msleep(1); | 141 | msleep(1); |
| 142 | tmp = r8a66597_read(r8a66597, SYSCFG0); | 142 | tmp = r8a66597_read(r8a66597, SYSCFG0); |
| 143 | if (i++ > 500) { | 143 | if (i++ > 500) { |
| 144 | err("register access fail."); | 144 | printk(KERN_ERR "r8a66597: register access fail.\n"); |
| 145 | return -ENXIO; | 145 | return -ENXIO; |
| 146 | } | 146 | } |
| 147 | } while ((tmp & SCKE) != SCKE); | 147 | } while ((tmp & SCKE) != SCKE); |
| @@ -265,7 +265,7 @@ static void get_port_number(char *devpath, u16 *root_port, u16 *hub_port) | |||
| 265 | if (root_port) { | 265 | if (root_port) { |
| 266 | *root_port = (devpath[0] & 0x0F) - 1; | 266 | *root_port = (devpath[0] & 0x0F) - 1; |
| 267 | if (*root_port >= R8A66597_MAX_ROOT_HUB) | 267 | if (*root_port >= R8A66597_MAX_ROOT_HUB) |
| 268 | err("illegal root port number"); | 268 | printk(KERN_ERR "r8a66597: Illegal root port number.\n"); |
| 269 | } | 269 | } |
| 270 | if (hub_port) | 270 | if (hub_port) |
| 271 | *hub_port = devpath[2] & 0x0F; | 271 | *hub_port = devpath[2] & 0x0F; |
| @@ -286,7 +286,7 @@ static u16 get_r8a66597_usb_speed(enum usb_device_speed speed) | |||
| 286 | usbspd = HSMODE; | 286 | usbspd = HSMODE; |
| 287 | break; | 287 | break; |
| 288 | default: | 288 | default: |
| 289 | err("unknown speed"); | 289 | printk(KERN_ERR "r8a66597: unknown speed\n"); |
| 290 | break; | 290 | break; |
| 291 | } | 291 | } |
| 292 | 292 | ||
| @@ -385,7 +385,7 @@ static u8 alloc_usb_address(struct r8a66597 *r8a66597, struct urb *urb) | |||
| 385 | struct r8a66597_device *dev; | 385 | struct r8a66597_device *dev; |
| 386 | 386 | ||
| 387 | if (is_hub_limit(urb->dev->devpath)) { | 387 | if (is_hub_limit(urb->dev->devpath)) { |
| 388 | err("Externel hub limit reached."); | 388 | dev_err(&urb->dev->dev, "External hub limit reached.\n"); |
| 389 | return 0; | 389 | return 0; |
| 390 | } | 390 | } |
| 391 | 391 | ||
| @@ -406,8 +406,9 @@ static u8 alloc_usb_address(struct r8a66597 *r8a66597, struct urb *urb) | |||
| 406 | return addr; | 406 | return addr; |
| 407 | } | 407 | } |
| 408 | 408 | ||
| 409 | err("cannot communicate with a USB device more than 10.(%x)", | 409 | dev_err(&urb->dev->dev, |
| 410 | r8a66597->address_map); | 410 | "cannot communicate with a USB device more than 10.(%x)\n", |
| 411 | r8a66597->address_map); | ||
| 411 | 412 | ||
| 412 | return 0; | 413 | return 0; |
| 413 | } | 414 | } |
| @@ -447,7 +448,8 @@ static void r8a66597_reg_wait(struct r8a66597 *r8a66597, unsigned long reg, | |||
| 447 | do { | 448 | do { |
| 448 | tmp = r8a66597_read(r8a66597, reg); | 449 | tmp = r8a66597_read(r8a66597, reg); |
| 449 | if (i++ > 1000000) { | 450 | if (i++ > 1000000) { |
| 450 | err("register%lx, loop %x is timeout", reg, loop); | 451 | printk(KERN_ERR "r8a66597: register%lx, loop %x " |
| 452 | "is timeout\n", reg, loop); | ||
| 451 | break; | 453 | break; |
| 452 | } | 454 | } |
| 453 | ndelay(1); | 455 | ndelay(1); |
| @@ -675,7 +677,7 @@ static u16 get_empty_pipenum(struct r8a66597 *r8a66597, | |||
| 675 | array[i++] = 1; | 677 | array[i++] = 1; |
| 676 | break; | 678 | break; |
| 677 | default: | 679 | default: |
| 678 | err("Illegal type"); | 680 | printk(KERN_ERR "r8a66597: Illegal type\n"); |
| 679 | return 0; | 681 | return 0; |
| 680 | } | 682 | } |
| 681 | 683 | ||
| @@ -705,7 +707,7 @@ static u16 get_r8a66597_type(__u8 type) | |||
| 705 | r8a66597_type = R8A66597_ISO; | 707 | r8a66597_type = R8A66597_ISO; |
| 706 | break; | 708 | break; |
| 707 | default: | 709 | default: |
| 708 | err("Illegal type"); | 710 | printk(KERN_ERR "r8a66597: Illegal type\n"); |
| 709 | r8a66597_type = 0x0000; | 711 | r8a66597_type = 0x0000; |
| 710 | break; | 712 | break; |
| 711 | } | 713 | } |
| @@ -724,7 +726,7 @@ static u16 get_bufnum(u16 pipenum) | |||
| 724 | else if (check_interrupt(pipenum)) | 726 | else if (check_interrupt(pipenum)) |
| 725 | bufnum = 4 + (pipenum - 6); | 727 | bufnum = 4 + (pipenum - 6); |
| 726 | else | 728 | else |
| 727 | err("Illegal pipenum (%d)", pipenum); | 729 | printk(KERN_ERR "r8a66597: Illegal pipenum (%d)\n", pipenum); |
| 728 | 730 | ||
| 729 | return bufnum; | 731 | return bufnum; |
| 730 | } | 732 | } |
| @@ -740,7 +742,7 @@ static u16 get_buf_bsize(u16 pipenum) | |||
| 740 | else if (check_interrupt(pipenum)) | 742 | else if (check_interrupt(pipenum)) |
| 741 | buf_bsize = 0; | 743 | buf_bsize = 0; |
| 742 | else | 744 | else |
| 743 | err("Illegal pipenum (%d)", pipenum); | 745 | printk(KERN_ERR "r8a66597: Illegal pipenum (%d)\n", pipenum); |
| 744 | 746 | ||
| 745 | return buf_bsize; | 747 | return buf_bsize; |
| 746 | } | 748 | } |
| @@ -760,10 +762,12 @@ static void enable_r8a66597_pipe_dma(struct r8a66597 *r8a66597, | |||
| 760 | if ((r8a66597->dma_map & (1 << i)) != 0) | 762 | if ((r8a66597->dma_map & (1 << i)) != 0) |
| 761 | continue; | 763 | continue; |
| 762 | 764 | ||
| 763 | info("address %d, EndpointAddress 0x%02x use DMA FIFO", | 765 | dev_info(&dev->udev->dev, |
| 764 | usb_pipedevice(urb->pipe), | 766 | "address %d, EndpointAddress 0x%02x use " |
| 765 | info->dir_in ? USB_ENDPOINT_DIR_MASK + info->epnum | 767 | "DMA FIFO\n", usb_pipedevice(urb->pipe), |
| 766 | : info->epnum); | 768 | info->dir_in ? |
| 769 | USB_ENDPOINT_DIR_MASK + info->epnum | ||
| 770 | : info->epnum); | ||
| 767 | 771 | ||
| 768 | r8a66597->dma_map |= 1 << i; | 772 | r8a66597->dma_map |= 1 << i; |
| 769 | dev->dma_map |= 1 << i; | 773 | dev->dma_map |= 1 << i; |
| @@ -1187,7 +1191,7 @@ static int start_transfer(struct r8a66597 *r8a66597, struct r8a66597_td *td) | |||
| 1187 | prepare_status_packet(r8a66597, td); | 1191 | prepare_status_packet(r8a66597, td); |
| 1188 | break; | 1192 | break; |
| 1189 | default: | 1193 | default: |
| 1190 | err("invalid type."); | 1194 | printk(KERN_ERR "r8a66597: invalid type.\n"); |
| 1191 | break; | 1195 | break; |
| 1192 | } | 1196 | } |
| 1193 | 1197 | ||
| @@ -1295,7 +1299,7 @@ static void packet_read(struct r8a66597 *r8a66597, u16 pipenum) | |||
| 1295 | if (unlikely((tmp & FRDY) == 0)) { | 1299 | if (unlikely((tmp & FRDY) == 0)) { |
| 1296 | pipe_stop(r8a66597, td->pipe); | 1300 | pipe_stop(r8a66597, td->pipe); |
| 1297 | pipe_irq_disable(r8a66597, pipenum); | 1301 | pipe_irq_disable(r8a66597, pipenum); |
| 1298 | err("in fifo not ready (%d)", pipenum); | 1302 | printk(KERN_ERR "r8a66597: in fifo not ready (%d)\n", pipenum); |
| 1299 | finish_request(r8a66597, td, pipenum, td->urb, -EPIPE); | 1303 | finish_request(r8a66597, td, pipenum, td->urb, -EPIPE); |
| 1300 | return; | 1304 | return; |
| 1301 | } | 1305 | } |
| @@ -1370,7 +1374,7 @@ static void packet_write(struct r8a66597 *r8a66597, u16 pipenum) | |||
| 1370 | if (unlikely((tmp & FRDY) == 0)) { | 1374 | if (unlikely((tmp & FRDY) == 0)) { |
| 1371 | pipe_stop(r8a66597, td->pipe); | 1375 | pipe_stop(r8a66597, td->pipe); |
| 1372 | pipe_irq_disable(r8a66597, pipenum); | 1376 | pipe_irq_disable(r8a66597, pipenum); |
| 1373 | err("out write fifo not ready. (%d)", pipenum); | 1377 | printk(KERN_ERR "r8a66597: out fifo not ready (%d)\n", pipenum); |
| 1374 | finish_request(r8a66597, td, pipenum, urb, -EPIPE); | 1378 | finish_request(r8a66597, td, pipenum, urb, -EPIPE); |
| 1375 | return; | 1379 | return; |
| 1376 | } | 1380 | } |
| @@ -2005,7 +2009,7 @@ static struct r8a66597_device *get_r8a66597_device(struct r8a66597 *r8a66597, | |||
| 2005 | return dev; | 2009 | return dev; |
| 2006 | } | 2010 | } |
| 2007 | 2011 | ||
| 2008 | err("get_r8a66597_device fail.(%d)\n", addr); | 2012 | printk(KERN_ERR "r8a66597: get_r8a66597_device fail.(%d)\n", addr); |
| 2009 | return NULL; | 2013 | return NULL; |
| 2010 | } | 2014 | } |
| 2011 | 2015 | ||
| @@ -2263,7 +2267,7 @@ static int __init_or_module r8a66597_remove(struct platform_device *pdev) | |||
| 2263 | #define resource_len(r) (((r)->end - (r)->start) + 1) | 2267 | #define resource_len(r) (((r)->end - (r)->start) + 1) |
| 2264 | static int __init r8a66597_probe(struct platform_device *pdev) | 2268 | static int __init r8a66597_probe(struct platform_device *pdev) |
| 2265 | { | 2269 | { |
| 2266 | struct resource *res = NULL; | 2270 | struct resource *res = NULL, *ires; |
| 2267 | int irq = -1; | 2271 | int irq = -1; |
| 2268 | void __iomem *reg = NULL; | 2272 | void __iomem *reg = NULL; |
| 2269 | struct usb_hcd *hcd = NULL; | 2273 | struct usb_hcd *hcd = NULL; |
| @@ -2274,7 +2278,7 @@ static int __init r8a66597_probe(struct platform_device *pdev) | |||
| 2274 | 2278 | ||
| 2275 | if (pdev->dev.dma_mask) { | 2279 | if (pdev->dev.dma_mask) { |
| 2276 | ret = -EINVAL; | 2280 | ret = -EINVAL; |
| 2277 | err("dma not support"); | 2281 | dev_err(&pdev->dev, "dma not supported\n"); |
| 2278 | goto clean_up; | 2282 | goto clean_up; |
| 2279 | } | 2283 | } |
| 2280 | 2284 | ||
| @@ -2282,21 +2286,25 @@ static int __init r8a66597_probe(struct platform_device *pdev) | |||
| 2282 | (char *)hcd_name); | 2286 | (char *)hcd_name); |
| 2283 | if (!res) { | 2287 | if (!res) { |
| 2284 | ret = -ENODEV; | 2288 | ret = -ENODEV; |
| 2285 | err("platform_get_resource_byname error."); | 2289 | dev_err(&pdev->dev, "platform_get_resource_byname error.\n"); |
| 2286 | goto clean_up; | 2290 | goto clean_up; |
| 2287 | } | 2291 | } |
| 2288 | 2292 | ||
| 2289 | irq = platform_get_irq(pdev, 0); | 2293 | ires = platform_get_resource(pdev, IORESOURCE_IRQ, 0); |
| 2290 | if (irq < 0) { | 2294 | if (!ires) { |
| 2291 | ret = -ENODEV; | 2295 | ret = -ENODEV; |
| 2292 | err("platform_get_irq error."); | 2296 | dev_err(&pdev->dev, |
| 2297 | "platform_get_resource IORESOURCE_IRQ error.\n"); | ||
| 2293 | goto clean_up; | 2298 | goto clean_up; |
| 2294 | } | 2299 | } |
| 2295 | 2300 | ||
| 2301 | irq = ires->start; | ||
| 2302 | irq_trigger = ires->flags & IRQF_TRIGGER_MASK; | ||
| 2303 | |||
| 2296 | reg = ioremap(res->start, resource_len(res)); | 2304 | reg = ioremap(res->start, resource_len(res)); |
| 2297 | if (reg == NULL) { | 2305 | if (reg == NULL) { |
| 2298 | ret = -ENOMEM; | 2306 | ret = -ENOMEM; |
| 2299 | err("ioremap error."); | 2307 | dev_err(&pdev->dev, "ioremap error.\n"); |
| 2300 | goto clean_up; | 2308 | goto clean_up; |
| 2301 | } | 2309 | } |
| 2302 | 2310 | ||
| @@ -2304,7 +2312,7 @@ static int __init r8a66597_probe(struct platform_device *pdev) | |||
| 2304 | hcd = usb_create_hcd(&r8a66597_hc_driver, &pdev->dev, (char *)hcd_name); | 2312 | hcd = usb_create_hcd(&r8a66597_hc_driver, &pdev->dev, (char *)hcd_name); |
| 2305 | if (!hcd) { | 2313 | if (!hcd) { |
| 2306 | ret = -ENOMEM; | 2314 | ret = -ENOMEM; |
| 2307 | err("Failed to create hcd"); | 2315 | dev_err(&pdev->dev, "Failed to create hcd\n"); |
| 2308 | goto clean_up; | 2316 | goto clean_up; |
| 2309 | } | 2317 | } |
| 2310 | r8a66597 = hcd_to_r8a66597(hcd); | 2318 | r8a66597 = hcd_to_r8a66597(hcd); |
| @@ -2329,13 +2337,33 @@ static int __init r8a66597_probe(struct platform_device *pdev) | |||
| 2329 | INIT_LIST_HEAD(&r8a66597->child_device); | 2337 | INIT_LIST_HEAD(&r8a66597->child_device); |
| 2330 | 2338 | ||
| 2331 | hcd->rsrc_start = res->start; | 2339 | hcd->rsrc_start = res->start; |
| 2332 | if (irq_sense == INTL) | 2340 | |
| 2333 | irq_trigger = IRQF_TRIGGER_LOW; | 2341 | /* irq_sense setting on cmdline takes precedence over resource |
| 2334 | else | 2342 | * settings, so the introduction of irqflags in IRQ resourse |
| 2335 | irq_trigger = IRQF_TRIGGER_FALLING; | 2343 | * won't disturb existing setups */ |
| 2344 | switch (irq_sense) { | ||
| 2345 | case INTL: | ||
| 2346 | irq_trigger = IRQF_TRIGGER_LOW; | ||
| 2347 | break; | ||
| 2348 | case 0: | ||
| 2349 | irq_trigger = IRQF_TRIGGER_FALLING; | ||
| 2350 | break; | ||
| 2351 | case 0xff: | ||
| 2352 | if (irq_trigger) | ||
| 2353 | irq_sense = (irq_trigger & IRQF_TRIGGER_LOW) ? | ||
| 2354 | INTL : 0; | ||
| 2355 | else { | ||
| 2356 | irq_sense = INTL; | ||
| 2357 | irq_trigger = IRQF_TRIGGER_LOW; | ||
| 2358 | } | ||
| 2359 | break; | ||
| 2360 | default: | ||
| 2361 | dev_err(&pdev->dev, "Unknown irq_sense value.\n"); | ||
| 2362 | } | ||
| 2363 | |||
| 2336 | ret = usb_add_hcd(hcd, irq, IRQF_DISABLED | irq_trigger); | 2364 | ret = usb_add_hcd(hcd, irq, IRQF_DISABLED | irq_trigger); |
| 2337 | if (ret != 0) { | 2365 | if (ret != 0) { |
| 2338 | err("Failed to add hcd"); | 2366 | dev_err(&pdev->dev, "Failed to add hcd\n"); |
| 2339 | goto clean_up; | 2367 | goto clean_up; |
| 2340 | } | 2368 | } |
| 2341 | 2369 | ||
| @@ -2364,7 +2392,8 @@ static int __init r8a66597_init(void) | |||
| 2364 | if (usb_disabled()) | 2392 | if (usb_disabled()) |
| 2365 | return -ENODEV; | 2393 | return -ENODEV; |
| 2366 | 2394 | ||
| 2367 | info("driver %s, %s", hcd_name, DRIVER_VERSION); | 2395 | printk(KERN_INFO KBUILD_MODNAME ": driver %s, %s\n", hcd_name, |
| 2396 | DRIVER_VERSION); | ||
| 2368 | return platform_driver_register(&r8a66597_driver); | 2397 | return platform_driver_register(&r8a66597_driver); |
| 2369 | } | 2398 | } |
| 2370 | module_init(r8a66597_init); | 2399 | module_init(r8a66597_init); |
diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c index 8a74bbb57d08..e106e9d48d4a 100644 --- a/drivers/usb/host/sl811-hcd.c +++ b/drivers/usb/host/sl811-hcd.c | |||
| @@ -1620,22 +1620,26 @@ sl811h_probe(struct platform_device *dev) | |||
| 1620 | { | 1620 | { |
| 1621 | struct usb_hcd *hcd; | 1621 | struct usb_hcd *hcd; |
| 1622 | struct sl811 *sl811; | 1622 | struct sl811 *sl811; |
| 1623 | struct resource *addr, *data; | 1623 | struct resource *addr, *data, *ires; |
| 1624 | int irq; | 1624 | int irq; |
| 1625 | void __iomem *addr_reg; | 1625 | void __iomem *addr_reg; |
| 1626 | void __iomem *data_reg; | 1626 | void __iomem *data_reg; |
| 1627 | int retval; | 1627 | int retval; |
| 1628 | u8 tmp, ioaddr = 0; | 1628 | u8 tmp, ioaddr = 0; |
| 1629 | unsigned long irqflags; | ||
| 1629 | 1630 | ||
| 1630 | /* basic sanity checks first. board-specific init logic should | 1631 | /* basic sanity checks first. board-specific init logic should |
| 1631 | * have initialized these three resources and probably board | 1632 | * have initialized these three resources and probably board |
| 1632 | * specific platform_data. we don't probe for IRQs, and do only | 1633 | * specific platform_data. we don't probe for IRQs, and do only |
| 1633 | * minimal sanity checking. | 1634 | * minimal sanity checking. |
| 1634 | */ | 1635 | */ |
| 1635 | irq = platform_get_irq(dev, 0); | 1636 | ires = platform_get_resource(dev, IORESOURCE_IRQ, 0); |
| 1636 | if (dev->num_resources < 3 || irq < 0) | 1637 | if (dev->num_resources < 3 || !ires) |
| 1637 | return -ENODEV; | 1638 | return -ENODEV; |
| 1638 | 1639 | ||
| 1640 | irq = ires->start; | ||
| 1641 | irqflags = ires->flags & IRQF_TRIGGER_MASK; | ||
| 1642 | |||
| 1639 | /* refuse to confuse usbcore */ | 1643 | /* refuse to confuse usbcore */ |
| 1640 | if (dev->dev.dma_mask) { | 1644 | if (dev->dev.dma_mask) { |
| 1641 | DBG("no we won't dma\n"); | 1645 | DBG("no we won't dma\n"); |
| @@ -1717,8 +1721,11 @@ sl811h_probe(struct platform_device *dev) | |||
| 1717 | * triggers (e.g. most ARM CPUs). Initial driver stress testing | 1721 | * triggers (e.g. most ARM CPUs). Initial driver stress testing |
| 1718 | * was on a system with single edge triggering, so most sorts of | 1722 | * was on a system with single edge triggering, so most sorts of |
| 1719 | * triggering arrangement should work. | 1723 | * triggering arrangement should work. |
| 1724 | * | ||
| 1725 | * Use resource IRQ flags if set by platform device setup. | ||
| 1720 | */ | 1726 | */ |
| 1721 | retval = usb_add_hcd(hcd, irq, IRQF_DISABLED | IRQF_SHARED); | 1727 | irqflags |= IRQF_SHARED; |
| 1728 | retval = usb_add_hcd(hcd, irq, IRQF_DISABLED | irqflags); | ||
| 1722 | if (retval != 0) | 1729 | if (retval != 0) |
| 1723 | goto err6; | 1730 | goto err6; |
| 1724 | 1731 | ||
diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c index 3a7bfe7a8874..cf5e4cf7ea42 100644 --- a/drivers/usb/host/uhci-hcd.c +++ b/drivers/usb/host/uhci-hcd.c | |||
| @@ -53,7 +53,6 @@ | |||
| 53 | /* | 53 | /* |
| 54 | * Version Information | 54 | * Version Information |
| 55 | */ | 55 | */ |
| 56 | #define DRIVER_VERSION "v3.0" | ||
| 57 | #define DRIVER_AUTHOR "Linus 'Frodo Rabbit' Torvalds, Johannes Erdfelt, \ | 56 | #define DRIVER_AUTHOR "Linus 'Frodo Rabbit' Torvalds, Johannes Erdfelt, \ |
| 58 | Randy Dunlap, Georg Acher, Deti Fliegl, Thomas Sailer, Roman Weissgaerber, \ | 57 | Randy Dunlap, Georg Acher, Deti Fliegl, Thomas Sailer, Roman Weissgaerber, \ |
| 59 | Alan Stern" | 58 | Alan Stern" |
| @@ -951,12 +950,13 @@ static int __init uhci_hcd_init(void) | |||
| 951 | { | 950 | { |
| 952 | int retval = -ENOMEM; | 951 | int retval = -ENOMEM; |
| 953 | 952 | ||
| 954 | printk(KERN_INFO DRIVER_DESC " " DRIVER_VERSION "%s\n", | ||
| 955 | ignore_oc ? ", overcurrent ignored" : ""); | ||
| 956 | |||
| 957 | if (usb_disabled()) | 953 | if (usb_disabled()) |
| 958 | return -ENODEV; | 954 | return -ENODEV; |
| 959 | 955 | ||
| 956 | printk(KERN_INFO "uhci_hcd: " DRIVER_DESC "%s\n", | ||
| 957 | ignore_oc ? ", overcurrent ignored" : ""); | ||
| 958 | set_bit(USB_UHCI_LOADED, &usb_hcds_loaded); | ||
| 959 | |||
| 960 | if (DEBUG_CONFIGURED) { | 960 | if (DEBUG_CONFIGURED) { |
| 961 | errbuf = kmalloc(ERRBUF_LEN, GFP_KERNEL); | 961 | errbuf = kmalloc(ERRBUF_LEN, GFP_KERNEL); |
| 962 | if (!errbuf) | 962 | if (!errbuf) |
| @@ -988,6 +988,7 @@ debug_failed: | |||
| 988 | 988 | ||
| 989 | errbuf_failed: | 989 | errbuf_failed: |
| 990 | 990 | ||
| 991 | clear_bit(USB_UHCI_LOADED, &usb_hcds_loaded); | ||
| 991 | return retval; | 992 | return retval; |
| 992 | } | 993 | } |
| 993 | 994 | ||
| @@ -997,6 +998,7 @@ static void __exit uhci_hcd_cleanup(void) | |||
| 997 | kmem_cache_destroy(uhci_up_cachep); | 998 | kmem_cache_destroy(uhci_up_cachep); |
| 998 | debugfs_remove(uhci_debugfs_root); | 999 | debugfs_remove(uhci_debugfs_root); |
| 999 | kfree(errbuf); | 1000 | kfree(errbuf); |
| 1001 | clear_bit(USB_UHCI_LOADED, &usb_hcds_loaded); | ||
| 1000 | } | 1002 | } |
| 1001 | 1003 | ||
| 1002 | module_init(uhci_hcd_init); | 1004 | module_init(uhci_hcd_init); |
diff --git a/drivers/usb/host/uhci-q.c b/drivers/usb/host/uhci-q.c index 1f0c2cf26e5d..5631d89c8730 100644 --- a/drivers/usb/host/uhci-q.c +++ b/drivers/usb/host/uhci-q.c | |||
| @@ -1065,13 +1065,18 @@ static int uhci_submit_interrupt(struct uhci_hcd *uhci, struct urb *urb, | |||
| 1065 | } | 1065 | } |
| 1066 | if (exponent < 0) | 1066 | if (exponent < 0) |
| 1067 | return -EINVAL; | 1067 | return -EINVAL; |
| 1068 | qh->period = 1 << exponent; | ||
| 1069 | qh->skel = SKEL_INDEX(exponent); | ||
| 1070 | 1068 | ||
| 1071 | /* For now, interrupt phase is fixed by the layout | 1069 | /* If the slot is full, try a lower period */ |
| 1072 | * of the QH lists. */ | 1070 | do { |
| 1073 | qh->phase = (qh->period / 2) & (MAX_PHASE - 1); | 1071 | qh->period = 1 << exponent; |
| 1074 | ret = uhci_check_bandwidth(uhci, qh); | 1072 | qh->skel = SKEL_INDEX(exponent); |
| 1073 | |||
| 1074 | /* For now, interrupt phase is fixed by the layout | ||
| 1075 | * of the QH lists. | ||
| 1076 | */ | ||
| 1077 | qh->phase = (qh->period / 2) & (MAX_PHASE - 1); | ||
| 1078 | ret = uhci_check_bandwidth(uhci, qh); | ||
| 1079 | } while (ret != 0 && --exponent >= 0); | ||
| 1075 | if (ret) | 1080 | if (ret) |
| 1076 | return ret; | 1081 | return ret; |
| 1077 | } else if (qh->period > urb->interval) | 1082 | } else if (qh->period > urb->interval) |
diff --git a/drivers/usb/image/mdc800.c b/drivers/usb/image/mdc800.c index 0fb114ca1eba..878c77ca086e 100644 --- a/drivers/usb/image/mdc800.c +++ b/drivers/usb/image/mdc800.c | |||
| @@ -355,13 +355,14 @@ static int mdc800_usb_waitForIRQ (int mode, int msec) | |||
| 355 | if (mdc800->camera_request_ready>0) | 355 | if (mdc800->camera_request_ready>0) |
| 356 | { | 356 | { |
| 357 | mdc800->camera_request_ready=0; | 357 | mdc800->camera_request_ready=0; |
| 358 | err ("timeout waiting for camera."); | 358 | dev_err(&mdc800->dev->dev, "timeout waiting for camera.\n"); |
| 359 | return -1; | 359 | return -1; |
| 360 | } | 360 | } |
| 361 | 361 | ||
| 362 | if (mdc800->state == NOT_CONNECTED) | 362 | if (mdc800->state == NOT_CONNECTED) |
| 363 | { | 363 | { |
| 364 | warn ("Camera gets disconnected during waiting for irq."); | 364 | printk(KERN_WARNING "mdc800: Camera gets disconnected " |
| 365 | "during waiting for irq.\n"); | ||
| 365 | mdc800->camera_request_ready=0; | 366 | mdc800->camera_request_ready=0; |
| 366 | return -2; | 367 | return -2; |
| 367 | } | 368 | } |
| @@ -379,7 +380,8 @@ static void mdc800_usb_write_notify (struct urb *urb) | |||
| 379 | int status = urb->status; | 380 | int status = urb->status; |
| 380 | 381 | ||
| 381 | if (status != 0) | 382 | if (status != 0) |
| 382 | err ("writing command fails (status=%i)", status); | 383 | dev_err(&mdc800->dev->dev, |
| 384 | "writing command fails (status=%i)\n", status); | ||
| 383 | else | 385 | else |
| 384 | mdc800->state=READY; | 386 | mdc800->state=READY; |
| 385 | mdc800->written = 1; | 387 | mdc800->written = 1; |
| @@ -406,7 +408,8 @@ static void mdc800_usb_download_notify (struct urb *urb) | |||
| 406 | mdc800->state=READY; | 408 | mdc800->state=READY; |
| 407 | } | 409 | } |
| 408 | } else { | 410 | } else { |
| 409 | err ("request bytes fails (status:%i)", status); | 411 | dev_err(&mdc800->dev->dev, |
| 412 | "request bytes fails (status:%i)\n", status); | ||
| 410 | } | 413 | } |
| 411 | mdc800->downloaded = 1; | 414 | mdc800->downloaded = 1; |
| 412 | wake_up (&mdc800->download_wait); | 415 | wake_up (&mdc800->download_wait); |
| @@ -443,13 +446,14 @@ static int mdc800_usb_probe (struct usb_interface *intf, | |||
| 443 | 446 | ||
| 444 | if (mdc800->dev != NULL) | 447 | if (mdc800->dev != NULL) |
| 445 | { | 448 | { |
| 446 | warn ("only one Mustek MDC800 is supported."); | 449 | dev_warn(&intf->dev, "only one Mustek MDC800 is supported.\n"); |
| 447 | return -ENODEV; | 450 | return -ENODEV; |
| 448 | } | 451 | } |
| 449 | 452 | ||
| 450 | if (dev->descriptor.bNumConfigurations != 1) | 453 | if (dev->descriptor.bNumConfigurations != 1) |
| 451 | { | 454 | { |
| 452 | err ("probe fails -> wrong Number of Configuration"); | 455 | dev_err(&intf->dev, |
| 456 | "probe fails -> wrong Number of Configuration\n"); | ||
| 453 | return -ENODEV; | 457 | return -ENODEV; |
| 454 | } | 458 | } |
| 455 | intf_desc = intf->cur_altsetting; | 459 | intf_desc = intf->cur_altsetting; |
| @@ -461,7 +465,7 @@ static int mdc800_usb_probe (struct usb_interface *intf, | |||
| 461 | || ( intf_desc->desc.bNumEndpoints != 4) | 465 | || ( intf_desc->desc.bNumEndpoints != 4) |
| 462 | ) | 466 | ) |
| 463 | { | 467 | { |
| 464 | err ("probe fails -> wrong Interface"); | 468 | dev_err(&intf->dev, "probe fails -> wrong Interface\n"); |
| 465 | return -ENODEV; | 469 | return -ENODEV; |
| 466 | } | 470 | } |
| 467 | 471 | ||
| @@ -482,19 +486,19 @@ static int mdc800_usb_probe (struct usb_interface *intf, | |||
| 482 | } | 486 | } |
| 483 | if (mdc800->endpoint[i] == -1) | 487 | if (mdc800->endpoint[i] == -1) |
| 484 | { | 488 | { |
| 485 | err ("probe fails -> Wrong Endpoints."); | 489 | dev_err(&intf->dev, "probe fails -> Wrong Endpoints.\n"); |
| 486 | return -ENODEV; | 490 | return -ENODEV; |
| 487 | } | 491 | } |
| 488 | } | 492 | } |
| 489 | 493 | ||
| 490 | 494 | ||
| 491 | info ("Found Mustek MDC800 on USB."); | 495 | dev_info(&intf->dev, "Found Mustek MDC800 on USB.\n"); |
| 492 | 496 | ||
| 493 | mutex_lock(&mdc800->io_lock); | 497 | mutex_lock(&mdc800->io_lock); |
| 494 | 498 | ||
| 495 | retval = usb_register_dev(intf, &mdc800_class); | 499 | retval = usb_register_dev(intf, &mdc800_class); |
| 496 | if (retval) { | 500 | if (retval) { |
| 497 | err ("Not able to get a minor for this device."); | 501 | dev_err(&intf->dev, "Not able to get a minor for this device.\n"); |
| 498 | return -ENODEV; | 502 | return -ENODEV; |
| 499 | } | 503 | } |
| 500 | 504 | ||
| @@ -570,7 +574,7 @@ static void mdc800_usb_disconnect (struct usb_interface *intf) | |||
| 570 | mdc800->dev = NULL; | 574 | mdc800->dev = NULL; |
| 571 | usb_set_intfdata(intf, NULL); | 575 | usb_set_intfdata(intf, NULL); |
| 572 | } | 576 | } |
| 573 | info ("Mustek MDC800 disconnected from USB."); | 577 | dev_info(&intf->dev, "Mustek MDC800 disconnected from USB.\n"); |
| 574 | } | 578 | } |
| 575 | 579 | ||
| 576 | 580 | ||
| @@ -644,7 +648,8 @@ static int mdc800_device_open (struct inode* inode, struct file *file) | |||
| 644 | mdc800->irq_urb->dev = mdc800->dev; | 648 | mdc800->irq_urb->dev = mdc800->dev; |
| 645 | retval = usb_submit_urb (mdc800->irq_urb, GFP_KERNEL); | 649 | retval = usb_submit_urb (mdc800->irq_urb, GFP_KERNEL); |
| 646 | if (retval) { | 650 | if (retval) { |
| 647 | err ("request USB irq fails (submit_retval=%i).", retval); | 651 | dev_err(&mdc800->dev->dev, |
| 652 | "request USB irq fails (submit_retval=%i).\n", retval); | ||
| 648 | errn = -EIO; | 653 | errn = -EIO; |
| 649 | goto error_out; | 654 | goto error_out; |
| 650 | } | 655 | } |
| @@ -701,7 +706,8 @@ static ssize_t mdc800_device_read (struct file *file, char __user *buf, size_t l | |||
| 701 | } | 706 | } |
| 702 | if (mdc800->state == WORKING) | 707 | if (mdc800->state == WORKING) |
| 703 | { | 708 | { |
| 704 | warn ("Illegal State \"working\" reached during read ?!"); | 709 | printk(KERN_WARNING "mdc800: Illegal State \"working\"" |
| 710 | "reached during read ?!\n"); | ||
| 705 | mutex_unlock(&mdc800->io_lock); | 711 | mutex_unlock(&mdc800->io_lock); |
| 706 | return -EBUSY; | 712 | return -EBUSY; |
| 707 | } | 713 | } |
| @@ -733,7 +739,9 @@ static ssize_t mdc800_device_read (struct file *file, char __user *buf, size_t l | |||
| 733 | mdc800->download_urb->dev = mdc800->dev; | 739 | mdc800->download_urb->dev = mdc800->dev; |
| 734 | retval = usb_submit_urb (mdc800->download_urb, GFP_KERNEL); | 740 | retval = usb_submit_urb (mdc800->download_urb, GFP_KERNEL); |
| 735 | if (retval) { | 741 | if (retval) { |
| 736 | err ("Can't submit download urb (retval=%i)",retval); | 742 | dev_err(&mdc800->dev->dev, |
| 743 | "Can't submit download urb " | ||
| 744 | "(retval=%i)\n", retval); | ||
| 737 | mutex_unlock(&mdc800->io_lock); | 745 | mutex_unlock(&mdc800->io_lock); |
| 738 | return len-left; | 746 | return len-left; |
| 739 | } | 747 | } |
| @@ -742,7 +750,10 @@ static ssize_t mdc800_device_read (struct file *file, char __user *buf, size_t l | |||
| 742 | mdc800->downloaded = 0; | 750 | mdc800->downloaded = 0; |
| 743 | if (mdc800->download_urb->status != 0) | 751 | if (mdc800->download_urb->status != 0) |
| 744 | { | 752 | { |
| 745 | err ("request download-bytes fails (status=%i)",mdc800->download_urb->status); | 753 | dev_err(&mdc800->dev->dev, |
| 754 | "request download-bytes fails " | ||
| 755 | "(status=%i)\n", | ||
| 756 | mdc800->download_urb->status); | ||
| 746 | mutex_unlock(&mdc800->io_lock); | 757 | mutex_unlock(&mdc800->io_lock); |
| 747 | return len-left; | 758 | return len-left; |
| 748 | } | 759 | } |
| @@ -839,7 +850,8 @@ static ssize_t mdc800_device_write (struct file *file, const char __user *buf, s | |||
| 839 | 850 | ||
| 840 | if (mdc800_usb_waitForIRQ (0,TO_GET_READY)) | 851 | if (mdc800_usb_waitForIRQ (0,TO_GET_READY)) |
| 841 | { | 852 | { |
| 842 | err ("Camera didn't get ready.\n"); | 853 | dev_err(&mdc800->dev->dev, |
| 854 | "Camera didn't get ready.\n"); | ||
| 843 | mutex_unlock(&mdc800->io_lock); | 855 | mutex_unlock(&mdc800->io_lock); |
| 844 | return -EIO; | 856 | return -EIO; |
| 845 | } | 857 | } |
| @@ -851,7 +863,9 @@ static ssize_t mdc800_device_write (struct file *file, const char __user *buf, s | |||
| 851 | mdc800->write_urb->dev = mdc800->dev; | 863 | mdc800->write_urb->dev = mdc800->dev; |
| 852 | retval = usb_submit_urb (mdc800->write_urb, GFP_KERNEL); | 864 | retval = usb_submit_urb (mdc800->write_urb, GFP_KERNEL); |
| 853 | if (retval) { | 865 | if (retval) { |
| 854 | err ("submitting write urb fails (retval=%i)", retval); | 866 | dev_err(&mdc800->dev->dev, |
| 867 | "submitting write urb fails " | ||
| 868 | "(retval=%i)\n", retval); | ||
| 855 | mutex_unlock(&mdc800->io_lock); | 869 | mutex_unlock(&mdc800->io_lock); |
| 856 | return -EIO; | 870 | return -EIO; |
| 857 | } | 871 | } |
| @@ -870,7 +884,9 @@ static ssize_t mdc800_device_write (struct file *file, const char __user *buf, s | |||
| 870 | case 0x3e: /* Take shot in Fine Mode (WCam Mode) */ | 884 | case 0x3e: /* Take shot in Fine Mode (WCam Mode) */ |
| 871 | if (mdc800->pic_len < 0) | 885 | if (mdc800->pic_len < 0) |
| 872 | { | 886 | { |
| 873 | err ("call 0x07 before 0x05,0x3e"); | 887 | dev_err(&mdc800->dev->dev, |
| 888 | "call 0x07 before " | ||
| 889 | "0x05,0x3e\n"); | ||
| 874 | mdc800->state=READY; | 890 | mdc800->state=READY; |
| 875 | mutex_unlock(&mdc800->io_lock); | 891 | mutex_unlock(&mdc800->io_lock); |
| 876 | return -EIO; | 892 | return -EIO; |
| @@ -890,7 +906,7 @@ static ssize_t mdc800_device_write (struct file *file, const char __user *buf, s | |||
| 890 | 906 | ||
| 891 | if (mdc800_usb_waitForIRQ (1,TO_READ_FROM_IRQ)) | 907 | if (mdc800_usb_waitForIRQ (1,TO_READ_FROM_IRQ)) |
| 892 | { | 908 | { |
| 893 | err ("requesting answer from irq fails"); | 909 | dev_err(&mdc800->dev->dev, "requesting answer from irq fails\n"); |
| 894 | mutex_unlock(&mdc800->io_lock); | 910 | mutex_unlock(&mdc800->io_lock); |
| 895 | return -EIO; | 911 | return -EIO; |
| 896 | } | 912 | } |
| @@ -918,7 +934,7 @@ static ssize_t mdc800_device_write (struct file *file, const char __user *buf, s | |||
| 918 | { | 934 | { |
| 919 | if (mdc800_usb_waitForIRQ (0,TO_DEFAULT_COMMAND)) | 935 | if (mdc800_usb_waitForIRQ (0,TO_DEFAULT_COMMAND)) |
| 920 | { | 936 | { |
| 921 | err ("Command Timeout."); | 937 | dev_err(&mdc800->dev->dev, "Command Timeout.\n"); |
| 922 | mutex_unlock(&mdc800->io_lock); | 938 | mutex_unlock(&mdc800->io_lock); |
| 923 | return -EIO; | 939 | return -EIO; |
| 924 | } | 940 | } |
| @@ -1018,7 +1034,8 @@ static int __init usb_mdc800_init (void) | |||
| 1018 | if (retval) | 1034 | if (retval) |
| 1019 | goto cleanup_on_fail; | 1035 | goto cleanup_on_fail; |
| 1020 | 1036 | ||
| 1021 | info (DRIVER_VERSION ":" DRIVER_DESC); | 1037 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
| 1038 | DRIVER_DESC "\n"); | ||
| 1022 | 1039 | ||
| 1023 | return 0; | 1040 | return 0; |
| 1024 | 1041 | ||
| @@ -1028,7 +1045,7 @@ cleanup_on_fail: | |||
| 1028 | 1045 | ||
| 1029 | if (mdc800 != NULL) | 1046 | if (mdc800 != NULL) |
| 1030 | { | 1047 | { |
| 1031 | err ("can't alloc memory!"); | 1048 | printk(KERN_ERR "mdc800: can't alloc memory!\n"); |
| 1032 | 1049 | ||
| 1033 | kfree(mdc800->download_urb_buffer); | 1050 | kfree(mdc800->download_urb_buffer); |
| 1034 | kfree(mdc800->write_urb_buffer); | 1051 | kfree(mdc800->write_urb_buffer); |
diff --git a/drivers/usb/misc/Kconfig b/drivers/usb/misc/Kconfig index 4ea50e0abcbb..e463db5d8188 100644 --- a/drivers/usb/misc/Kconfig +++ b/drivers/usb/misc/Kconfig | |||
| @@ -42,6 +42,15 @@ config USB_ADUTUX | |||
| 42 | To compile this driver as a module, choose M here. The module | 42 | To compile this driver as a module, choose M here. The module |
| 43 | will be called adutux. | 43 | will be called adutux. |
| 44 | 44 | ||
| 45 | config USB_SEVSEG | ||
| 46 | tristate "USB 7-Segment LED Display" | ||
| 47 | depends on USB | ||
| 48 | help | ||
| 49 | Say Y here if you have a USB 7-Segment Display by Delcom | ||
| 50 | |||
| 51 | To compile this driver as a module, choose M here: the | ||
| 52 | module will be called usbsevseg. | ||
| 53 | |||
| 45 | config USB_RIO500 | 54 | config USB_RIO500 |
| 46 | tristate "USB Diamond Rio500 support" | 55 | tristate "USB Diamond Rio500 support" |
| 47 | depends on USB | 56 | depends on USB |
| @@ -271,3 +280,18 @@ config USB_ISIGHTFW | |||
| 271 | The firmware for this driver must be extracted from the MacOS | 280 | The firmware for this driver must be extracted from the MacOS |
| 272 | driver beforehand. Tools for doing so are available at | 281 | driver beforehand. Tools for doing so are available at |
| 273 | http://bersace03.free.fr | 282 | http://bersace03.free.fr |
| 283 | |||
| 284 | config USB_VST | ||
| 285 | tristate "USB VST driver" | ||
| 286 | depends on USB | ||
| 287 | help | ||
| 288 | This driver is intended for Vernier Software Technologies | ||
| 289 | bulk usb devices such as their Ocean-Optics spectrometers or | ||
| 290 | Labquest. | ||
| 291 | It is a bulk channel driver with configurable read and write | ||
| 292 | timeouts. | ||
| 293 | |||
| 294 | To compile this driver as a module, choose M here: the | ||
| 295 | module will be called vstusb. | ||
| 296 | |||
| 297 | |||
diff --git a/drivers/usb/misc/Makefile b/drivers/usb/misc/Makefile index 45b4e12afb08..1334f7bdd7be 100644 --- a/drivers/usb/misc/Makefile +++ b/drivers/usb/misc/Makefile | |||
| @@ -26,6 +26,8 @@ obj-$(CONFIG_USB_RIO500) += rio500.o | |||
| 26 | obj-$(CONFIG_USB_TEST) += usbtest.o | 26 | obj-$(CONFIG_USB_TEST) += usbtest.o |
| 27 | obj-$(CONFIG_USB_TRANCEVIBRATOR) += trancevibrator.o | 27 | obj-$(CONFIG_USB_TRANCEVIBRATOR) += trancevibrator.o |
| 28 | obj-$(CONFIG_USB_USS720) += uss720.o | 28 | obj-$(CONFIG_USB_USS720) += uss720.o |
| 29 | obj-$(CONFIG_USB_SEVSEG) += usbsevseg.o | ||
| 30 | obj-$(CONFIG_USB_VST) += vstusb.o | ||
| 29 | 31 | ||
| 30 | obj-$(CONFIG_USB_SISUSBVGA) += sisusbvga/ | 32 | obj-$(CONFIG_USB_SISUSBVGA) += sisusbvga/ |
| 31 | 33 | ||
diff --git a/drivers/usb/misc/adutux.c b/drivers/usb/misc/adutux.c index 965f6eaea6a0..7b6922e08ed1 100644 --- a/drivers/usb/misc/adutux.c +++ b/drivers/usb/misc/adutux.c | |||
| @@ -283,8 +283,8 @@ static int adu_open(struct inode *inode, struct file *file) | |||
| 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 | printk(KERN_ERR "adutux: %s - error, can't find device for " |
| 287 | __func__, subminor); | 287 | "minor %d\n", __func__, subminor); |
| 288 | retval = -ENODEV; | 288 | retval = -ENODEV; |
| 289 | goto exit_no_device; | 289 | goto exit_no_device; |
| 290 | } | 290 | } |
| @@ -416,7 +416,8 @@ static ssize_t adu_read(struct file *file, __user char *buffer, size_t count, | |||
| 416 | /* verify that the device wasn't unplugged */ | 416 | /* verify that the device wasn't unplugged */ |
| 417 | if (dev->udev == NULL) { | 417 | if (dev->udev == NULL) { |
| 418 | retval = -ENODEV; | 418 | retval = -ENODEV; |
| 419 | err("No device or device unplugged %d", retval); | 419 | printk(KERN_ERR "adutux: No device or device unplugged %d\n", |
| 420 | retval); | ||
| 420 | goto exit; | 421 | goto exit; |
| 421 | } | 422 | } |
| 422 | 423 | ||
| @@ -576,7 +577,8 @@ static ssize_t adu_write(struct file *file, const __user char *buffer, | |||
| 576 | /* verify that the device wasn't unplugged */ | 577 | /* verify that the device wasn't unplugged */ |
| 577 | if (dev->udev == NULL) { | 578 | if (dev->udev == NULL) { |
| 578 | retval = -ENODEV; | 579 | retval = -ENODEV; |
| 579 | err("No device or device unplugged %d", retval); | 580 | printk(KERN_ERR "adutux: No device or device unplugged %d\n", |
| 581 | retval); | ||
| 580 | goto exit; | 582 | goto exit; |
| 581 | } | 583 | } |
| 582 | 584 | ||
| @@ -645,7 +647,8 @@ static ssize_t adu_write(struct file *file, const __user char *buffer, | |||
| 645 | retval = usb_submit_urb(dev->interrupt_out_urb, GFP_KERNEL); | 647 | retval = usb_submit_urb(dev->interrupt_out_urb, GFP_KERNEL); |
| 646 | if (retval < 0) { | 648 | if (retval < 0) { |
| 647 | dev->out_urb_finished = 1; | 649 | dev->out_urb_finished = 1; |
| 648 | err("Couldn't submit interrupt_out_urb %d", retval); | 650 | dev_err(&dev->udev->dev, "Couldn't submit " |
| 651 | "interrupt_out_urb %d\n", retval); | ||
| 649 | goto exit; | 652 | goto exit; |
| 650 | } | 653 | } |
| 651 | 654 | ||
| @@ -890,13 +893,14 @@ static int __init adu_init(void) | |||
| 890 | /* register this driver with the USB subsystem */ | 893 | /* register this driver with the USB subsystem */ |
| 891 | result = usb_register(&adu_driver); | 894 | result = usb_register(&adu_driver); |
| 892 | if (result < 0) { | 895 | if (result < 0) { |
| 893 | err("usb_register failed for the "__FILE__" driver. " | 896 | printk(KERN_ERR "usb_register failed for the "__FILE__ |
| 894 | "Error number %d", result); | 897 | " driver. Error number %d\n", result); |
| 895 | goto exit; | 898 | goto exit; |
| 896 | } | 899 | } |
| 897 | 900 | ||
| 898 | info("adutux " DRIVER_DESC " " DRIVER_VERSION); | 901 | printk(KERN_INFO "adutux " DRIVER_DESC " " DRIVER_VERSION "\n"); |
| 899 | info("adutux is an experimental driver. Use at your own risk"); | 902 | printk(KERN_INFO "adutux is an experimental driver. " |
| 903 | "Use at your own risk\n"); | ||
| 900 | 904 | ||
| 901 | exit: | 905 | exit: |
| 902 | dbg(2," %s : leave, return value %d", __func__, result); | 906 | dbg(2," %s : leave, return value %d", __func__, result); |
diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c index a076c24a312a..1d8e39a557d9 100644 --- a/drivers/usb/misc/appledisplay.c +++ b/drivers/usb/misc/appledisplay.c | |||
| @@ -130,7 +130,8 @@ static void appledisplay_complete(struct urb *urb) | |||
| 130 | exit: | 130 | 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 | dev_err(&pdata->udev->dev, |
| 134 | "%s - usb_submit_urb failed with result %d\n", | ||
| 134 | __func__, retval); | 135 | __func__, retval); |
| 135 | } | 136 | } |
| 136 | } | 137 | } |
| @@ -220,7 +221,7 @@ static int appledisplay_probe(struct usb_interface *iface, | |||
| 220 | } | 221 | } |
| 221 | } | 222 | } |
| 222 | if (!int_in_endpointAddr) { | 223 | if (!int_in_endpointAddr) { |
| 223 | err("Could not find int-in endpoint"); | 224 | dev_err(&iface->dev, "Could not find int-in endpoint\n"); |
| 224 | return -EIO; | 225 | return -EIO; |
| 225 | } | 226 | } |
| 226 | 227 | ||
| @@ -228,7 +229,7 @@ static int appledisplay_probe(struct usb_interface *iface, | |||
| 228 | pdata = kzalloc(sizeof(struct appledisplay), GFP_KERNEL); | 229 | pdata = kzalloc(sizeof(struct appledisplay), GFP_KERNEL); |
| 229 | if (!pdata) { | 230 | if (!pdata) { |
| 230 | retval = -ENOMEM; | 231 | retval = -ENOMEM; |
| 231 | err("Out of memory"); | 232 | dev_err(&iface->dev, "Out of memory\n"); |
| 232 | goto error; | 233 | goto error; |
| 233 | } | 234 | } |
| 234 | 235 | ||
| @@ -241,8 +242,8 @@ static int appledisplay_probe(struct usb_interface *iface, | |||
| 241 | pdata->msgdata = kmalloc(ACD_MSG_BUFFER_LEN, GFP_KERNEL); | 242 | pdata->msgdata = kmalloc(ACD_MSG_BUFFER_LEN, GFP_KERNEL); |
| 242 | if (!pdata->msgdata) { | 243 | if (!pdata->msgdata) { |
| 243 | retval = -ENOMEM; | 244 | retval = -ENOMEM; |
| 244 | err("appledisplay: Allocating buffer for control messages " | 245 | dev_err(&iface->dev, |
| 245 | "failed"); | 246 | "Allocating buffer for control messages failed\n"); |
| 246 | goto error; | 247 | goto error; |
| 247 | } | 248 | } |
| 248 | 249 | ||
| @@ -250,7 +251,7 @@ static int appledisplay_probe(struct usb_interface *iface, | |||
| 250 | pdata->urb = usb_alloc_urb(0, GFP_KERNEL); | 251 | pdata->urb = usb_alloc_urb(0, GFP_KERNEL); |
| 251 | if (!pdata->urb) { | 252 | if (!pdata->urb) { |
| 252 | retval = -ENOMEM; | 253 | retval = -ENOMEM; |
| 253 | err("appledisplay: Allocating URB failed"); | 254 | dev_err(&iface->dev, "Allocating URB failed\n"); |
| 254 | goto error; | 255 | goto error; |
| 255 | } | 256 | } |
| 256 | 257 | ||
| @@ -259,7 +260,7 @@ static int appledisplay_probe(struct usb_interface *iface, | |||
| 259 | GFP_KERNEL, &pdata->urb->transfer_dma); | 260 | GFP_KERNEL, &pdata->urb->transfer_dma); |
| 260 | if (!pdata->urbdata) { | 261 | if (!pdata->urbdata) { |
| 261 | retval = -ENOMEM; | 262 | retval = -ENOMEM; |
| 262 | err("appledisplay: Allocating URB buffer failed"); | 263 | dev_err(&iface->dev, "Allocating URB buffer failed\n"); |
| 263 | goto error; | 264 | goto error; |
| 264 | } | 265 | } |
| 265 | 266 | ||
| @@ -270,7 +271,7 @@ static int appledisplay_probe(struct usb_interface *iface, | |||
| 270 | pdata, 1); | 271 | pdata, 1); |
| 271 | if (usb_submit_urb(pdata->urb, GFP_KERNEL)) { | 272 | if (usb_submit_urb(pdata->urb, GFP_KERNEL)) { |
| 272 | retval = -EIO; | 273 | retval = -EIO; |
| 273 | err("appledisplay: Submitting URB failed"); | 274 | dev_err(&iface->dev, "Submitting URB failed\n"); |
| 274 | goto error; | 275 | goto error; |
| 275 | } | 276 | } |
| 276 | 277 | ||
| @@ -280,7 +281,7 @@ static int appledisplay_probe(struct usb_interface *iface, | |||
| 280 | pdata->bd = backlight_device_register(bl_name, NULL, pdata, | 281 | pdata->bd = backlight_device_register(bl_name, NULL, pdata, |
| 281 | &appledisplay_bl_data); | 282 | &appledisplay_bl_data); |
| 282 | if (IS_ERR(pdata->bd)) { | 283 | if (IS_ERR(pdata->bd)) { |
| 283 | err("appledisplay: Backlight registration failed"); | 284 | dev_err(&iface->dev, "Backlight registration failed\n"); |
| 284 | goto error; | 285 | goto error; |
| 285 | } | 286 | } |
| 286 | 287 | ||
| @@ -291,7 +292,8 @@ static int appledisplay_probe(struct usb_interface *iface, | |||
| 291 | 292 | ||
| 292 | if (brightness < 0) { | 293 | if (brightness < 0) { |
| 293 | retval = brightness; | 294 | retval = brightness; |
| 294 | err("appledisplay: Error while getting initial brightness: %d", retval); | 295 | dev_err(&iface->dev, |
| 296 | "Error while getting initial brightness: %d\n", retval); | ||
| 295 | goto error; | 297 | goto error; |
| 296 | } | 298 | } |
| 297 | 299 | ||
| @@ -314,7 +316,7 @@ error: | |||
| 314 | pdata->urbdata, pdata->urb->transfer_dma); | 316 | pdata->urbdata, pdata->urb->transfer_dma); |
| 315 | usb_free_urb(pdata->urb); | 317 | usb_free_urb(pdata->urb); |
| 316 | } | 318 | } |
| 317 | if (pdata->bd) | 319 | if (pdata->bd && !IS_ERR(pdata->bd)) |
| 318 | backlight_device_unregister(pdata->bd); | 320 | backlight_device_unregister(pdata->bd); |
| 319 | kfree(pdata->msgdata); | 321 | kfree(pdata->msgdata); |
| 320 | } | 322 | } |
| @@ -352,7 +354,7 @@ static int __init appledisplay_init(void) | |||
| 352 | { | 354 | { |
| 353 | wq = create_singlethread_workqueue("appledisplay"); | 355 | wq = create_singlethread_workqueue("appledisplay"); |
| 354 | if (!wq) { | 356 | if (!wq) { |
| 355 | err("Could not create work queue\n"); | 357 | printk(KERN_ERR "appledisplay: Could not create work queue\n"); |
| 356 | return -ENOMEM; | 358 | return -ENOMEM; |
| 357 | } | 359 | } |
| 358 | 360 | ||
diff --git a/drivers/usb/misc/cypress_cy7c63.c b/drivers/usb/misc/cypress_cy7c63.c index 937940404b7a..5720bfef6a38 100644 --- a/drivers/usb/misc/cypress_cy7c63.c +++ b/drivers/usb/misc/cypress_cy7c63.c | |||
| @@ -278,9 +278,9 @@ static int __init cypress_init(void) | |||
| 278 | 278 | ||
| 279 | /* register this driver with the USB subsystem */ | 279 | /* register this driver with the USB subsystem */ |
| 280 | result = usb_register(&cypress_driver); | 280 | result = usb_register(&cypress_driver); |
| 281 | if (result) { | 281 | if (result) |
| 282 | err("Function usb_register failed! Error number: %d\n", result); | 282 | printk(KERN_ERR KBUILD_MODNAME ": usb_register failed! " |
| 283 | } | 283 | "Error number: %d\n", result); |
| 284 | 284 | ||
| 285 | return result; | 285 | return result; |
| 286 | } | 286 | } |
diff --git a/drivers/usb/misc/cytherm.c b/drivers/usb/misc/cytherm.c index 1cd9e7eba93b..4fb3c38b924b 100644 --- a/drivers/usb/misc/cytherm.c +++ b/drivers/usb/misc/cytherm.c | |||
| @@ -422,13 +422,14 @@ static int __init usb_cytherm_init(void) | |||
| 422 | int result; | 422 | int result; |
| 423 | 423 | ||
| 424 | result = usb_register(&cytherm_driver); | 424 | result = usb_register(&cytherm_driver); |
| 425 | if (result) | 425 | if (result) { |
| 426 | { | 426 | printk(KERN_ERR KBUILD_MODNAME ": usb_register failed! " |
| 427 | err("usb_register failed. Error number %d", result); | 427 | "Error number: %d\n", result); |
| 428 | return result; | 428 | return result; |
| 429 | } | 429 | } |
| 430 | 430 | ||
| 431 | info(DRIVER_VERSION ":" DRIVER_DESC); | 431 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
| 432 | DRIVER_DESC "\n"); | ||
| 432 | return 0; | 433 | return 0; |
| 433 | } | 434 | } |
| 434 | 435 | ||
diff --git a/drivers/usb/misc/emi26.c b/drivers/usb/misc/emi26.c index 4b994a0cd272..e762beb5f3c6 100644 --- a/drivers/usb/misc/emi26.c +++ b/drivers/usb/misc/emi26.c | |||
| @@ -50,7 +50,7 @@ static int emi26_writememory (struct usb_device *dev, int address, | |||
| 50 | unsigned char *buffer = kmemdup(data, length, GFP_KERNEL); | 50 | unsigned char *buffer = kmemdup(data, length, GFP_KERNEL); |
| 51 | 51 | ||
| 52 | if (!buffer) { | 52 | if (!buffer) { |
| 53 | err("emi26: kmalloc(%d) failed.", length); | 53 | dev_err(&dev->dev, "kmalloc(%d) failed.\n", length); |
| 54 | return -ENOMEM; | 54 | return -ENOMEM; |
| 55 | } | 55 | } |
| 56 | /* Note: usb_control_msg returns negative value on error or length of the | 56 | /* Note: usb_control_msg returns negative value on error or length of the |
| @@ -64,11 +64,11 @@ static int emi26_writememory (struct usb_device *dev, int address, | |||
| 64 | static int emi26_set_reset (struct usb_device *dev, unsigned char reset_bit) | 64 | static int emi26_set_reset (struct usb_device *dev, unsigned char reset_bit) |
| 65 | { | 65 | { |
| 66 | int response; | 66 | int response; |
| 67 | info("%s - %d", __func__, reset_bit); | 67 | dev_info(&dev->dev, "%s - %d\n", __func__, reset_bit); |
| 68 | /* printk(KERN_DEBUG "%s - %d", __func__, reset_bit); */ | 68 | /* printk(KERN_DEBUG "%s - %d", __func__, reset_bit); */ |
| 69 | response = emi26_writememory (dev, CPUCS_REG, &reset_bit, 1, 0xa0); | 69 | response = emi26_writememory (dev, CPUCS_REG, &reset_bit, 1, 0xa0); |
| 70 | if (response < 0) { | 70 | if (response < 0) { |
| 71 | err("emi26: set_reset (%d) failed", reset_bit); | 71 | dev_err(&dev->dev, "set_reset (%d) failed\n", reset_bit); |
| 72 | } | 72 | } |
| 73 | return response; | 73 | return response; |
| 74 | } | 74 | } |
| @@ -88,7 +88,8 @@ static int emi26_load_firmware (struct usb_device *dev) | |||
| 88 | 88 | ||
| 89 | buf = kmalloc(FW_LOAD_SIZE, GFP_KERNEL); | 89 | buf = kmalloc(FW_LOAD_SIZE, GFP_KERNEL); |
| 90 | if (!buf) { | 90 | if (!buf) { |
| 91 | err( "%s - error loading firmware: error = %d", __func__, -ENOMEM); | 91 | dev_err(&dev->dev, "%s - error loading firmware: error = %d\n", |
| 92 | __func__, -ENOMEM); | ||
| 92 | err = -ENOMEM; | 93 | err = -ENOMEM; |
| 93 | goto wraperr; | 94 | goto wraperr; |
| 94 | } | 95 | } |
| @@ -106,14 +107,16 @@ static int emi26_load_firmware (struct usb_device *dev) | |||
| 106 | &dev->dev); | 107 | &dev->dev); |
| 107 | if (err) { | 108 | if (err) { |
| 108 | nofw: | 109 | nofw: |
| 109 | err( "%s - request_firmware() failed", __func__); | 110 | dev_err(&dev->dev, "%s - request_firmware() failed\n", |
| 111 | __func__); | ||
| 110 | goto wraperr; | 112 | goto wraperr; |
| 111 | } | 113 | } |
| 112 | 114 | ||
| 113 | /* Assert reset (stop the CPU in the EMI) */ | 115 | /* Assert reset (stop the CPU in the EMI) */ |
| 114 | err = emi26_set_reset(dev,1); | 116 | err = emi26_set_reset(dev,1); |
| 115 | if (err < 0) { | 117 | if (err < 0) { |
| 116 | err( "%s - error loading firmware: error = %d", __func__, err); | 118 | dev_err(&dev->dev,"%s - error loading firmware: error = %d\n", |
| 119 | __func__, err); | ||
| 117 | goto wraperr; | 120 | goto wraperr; |
| 118 | } | 121 | } |
| 119 | 122 | ||
| @@ -254,7 +257,7 @@ static int emi26_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
| 254 | { | 257 | { |
| 255 | struct usb_device *dev = interface_to_usbdev(intf); | 258 | struct usb_device *dev = interface_to_usbdev(intf); |
| 256 | 259 | ||
| 257 | info("%s start", __func__); | 260 | dev_info(&intf->dev, "%s start\n", __func__); |
| 258 | 261 | ||
| 259 | emi26_load_firmware(dev); | 262 | emi26_load_firmware(dev); |
| 260 | 263 | ||
diff --git a/drivers/usb/misc/emi62.c b/drivers/usb/misc/emi62.c index 5d859ded5bbf..602ee05ba9ff 100644 --- a/drivers/usb/misc/emi62.c +++ b/drivers/usb/misc/emi62.c | |||
| @@ -73,7 +73,7 @@ static int emi62_writememory(struct usb_device *dev, int address, | |||
| 73 | static int emi62_set_reset (struct usb_device *dev, unsigned char reset_bit) | 73 | static int emi62_set_reset (struct usb_device *dev, unsigned char reset_bit) |
| 74 | { | 74 | { |
| 75 | int response; | 75 | int response; |
| 76 | info("%s - %d", __func__, reset_bit); | 76 | dev_info(&dev->dev, "%s - %d\n", __func__, reset_bit); |
| 77 | 77 | ||
| 78 | response = emi62_writememory (dev, CPUCS_REG, &reset_bit, 1, 0xa0); | 78 | response = emi62_writememory (dev, CPUCS_REG, &reset_bit, 1, 0xa0); |
| 79 | if (response < 0) { | 79 | if (response < 0) { |
| @@ -271,7 +271,7 @@ static int emi62_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
| 271 | struct usb_device *dev = interface_to_usbdev(intf); | 271 | struct usb_device *dev = interface_to_usbdev(intf); |
| 272 | dev_dbg(&intf->dev, "emi62_probe\n"); | 272 | dev_dbg(&intf->dev, "emi62_probe\n"); |
| 273 | 273 | ||
| 274 | info("%s start", __func__); | 274 | dev_info(&intf->dev, "%s start\n", __func__); |
| 275 | 275 | ||
| 276 | emi62_load_firmware(dev); | 276 | emi62_load_firmware(dev); |
| 277 | 277 | ||
diff --git a/drivers/usb/misc/ftdi-elan.c b/drivers/usb/misc/ftdi-elan.c index 97c280971532..79a7668ef264 100644 --- a/drivers/usb/misc/ftdi-elan.c +++ b/drivers/usb/misc/ftdi-elan.c | |||
| @@ -698,7 +698,7 @@ static ssize_t ftdi_elan_read(struct file *file, char __user *buffer, | |||
| 698 | int retval = usb_bulk_msg(ftdi->udev, | 698 | int retval = usb_bulk_msg(ftdi->udev, |
| 699 | usb_rcvbulkpipe(ftdi->udev, ftdi->bulk_in_endpointAddr), | 699 | usb_rcvbulkpipe(ftdi->udev, ftdi->bulk_in_endpointAddr), |
| 700 | ftdi->bulk_in_buffer, ftdi->bulk_in_size, | 700 | ftdi->bulk_in_buffer, ftdi->bulk_in_size, |
| 701 | &packet_bytes, msecs_to_jiffies(50)); | 701 | &packet_bytes, 50); |
| 702 | if (packet_bytes > 2) { | 702 | if (packet_bytes > 2) { |
| 703 | ftdi->bulk_in_left = packet_bytes - 2; | 703 | ftdi->bulk_in_left = packet_bytes - 2; |
| 704 | ftdi->bulk_in_last = 1; | 704 | ftdi->bulk_in_last = 1; |
| @@ -960,7 +960,7 @@ static int ftdi_elan_respond_engine(struct usb_ftdi *ftdi) | |||
| 960 | int retval = usb_bulk_msg(ftdi->udev, | 960 | int retval = usb_bulk_msg(ftdi->udev, |
| 961 | usb_rcvbulkpipe(ftdi->udev, ftdi->bulk_in_endpointAddr), | 961 | usb_rcvbulkpipe(ftdi->udev, ftdi->bulk_in_endpointAddr), |
| 962 | ftdi->bulk_in_buffer, ftdi->bulk_in_size, | 962 | ftdi->bulk_in_buffer, ftdi->bulk_in_size, |
| 963 | &packet_bytes, msecs_to_jiffies(500)); | 963 | &packet_bytes, 500); |
| 964 | char diag[30 *3 + 4]; | 964 | char diag[30 *3 + 4]; |
| 965 | char *d = diag; | 965 | char *d = diag; |
| 966 | int m = packet_bytes; | 966 | int m = packet_bytes; |
| @@ -1880,7 +1880,7 @@ static int ftdi_elan_flush_input_fifo(struct usb_ftdi *ftdi) | |||
| 1880 | int retval = usb_bulk_msg(ftdi->udev, | 1880 | int retval = usb_bulk_msg(ftdi->udev, |
| 1881 | usb_rcvbulkpipe(ftdi->udev, ftdi->bulk_in_endpointAddr), | 1881 | usb_rcvbulkpipe(ftdi->udev, ftdi->bulk_in_endpointAddr), |
| 1882 | ftdi->bulk_in_buffer, ftdi->bulk_in_size, | 1882 | ftdi->bulk_in_buffer, ftdi->bulk_in_size, |
| 1883 | &packet_bytes, msecs_to_jiffies(100)); | 1883 | &packet_bytes, 100); |
| 1884 | if (packet_bytes > 2) { | 1884 | if (packet_bytes > 2) { |
| 1885 | char diag[30 *3 + 4]; | 1885 | char diag[30 *3 + 4]; |
| 1886 | char *d = diag; | 1886 | char *d = diag; |
| @@ -2067,7 +2067,7 @@ static int ftdi_elan_synchronize(struct usb_ftdi *ftdi) | |||
| 2067 | usb_rcvbulkpipe(ftdi->udev, | 2067 | usb_rcvbulkpipe(ftdi->udev, |
| 2068 | ftdi->bulk_in_endpointAddr), | 2068 | ftdi->bulk_in_endpointAddr), |
| 2069 | ftdi->bulk_in_buffer, ftdi->bulk_in_size, | 2069 | ftdi->bulk_in_buffer, ftdi->bulk_in_size, |
| 2070 | &packet_bytes, msecs_to_jiffies(500)); | 2070 | &packet_bytes, 500); |
| 2071 | if (packet_bytes > 2) { | 2071 | if (packet_bytes > 2) { |
| 2072 | char diag[30 *3 + 4]; | 2072 | char diag[30 *3 + 4]; |
| 2073 | char *d = diag; | 2073 | char *d = diag; |
| @@ -2176,7 +2176,7 @@ static int ftdi_elan_stuck_waiting(struct usb_ftdi *ftdi) | |||
| 2176 | int retval = usb_bulk_msg(ftdi->udev, | 2176 | int retval = usb_bulk_msg(ftdi->udev, |
| 2177 | usb_rcvbulkpipe(ftdi->udev, ftdi->bulk_in_endpointAddr), | 2177 | usb_rcvbulkpipe(ftdi->udev, ftdi->bulk_in_endpointAddr), |
| 2178 | ftdi->bulk_in_buffer, ftdi->bulk_in_size, | 2178 | ftdi->bulk_in_buffer, ftdi->bulk_in_size, |
| 2179 | &packet_bytes, msecs_to_jiffies(1000)); | 2179 | &packet_bytes, 1000); |
| 2180 | if (packet_bytes > 2) { | 2180 | if (packet_bytes > 2) { |
| 2181 | char diag[30 *3 + 4]; | 2181 | char diag[30 *3 + 4]; |
| 2182 | char *d = diag; | 2182 | char *d = diag; |
diff --git a/drivers/usb/misc/idmouse.c b/drivers/usb/misc/idmouse.c index 4bcf7fb4e5da..6da8887538c7 100644 --- a/drivers/usb/misc/idmouse.c +++ b/drivers/usb/misc/idmouse.c | |||
| @@ -403,14 +403,15 @@ static void idmouse_disconnect(struct usb_interface *interface) | |||
| 403 | mutex_unlock(&dev->lock); | 403 | mutex_unlock(&dev->lock); |
| 404 | } | 404 | } |
| 405 | 405 | ||
| 406 | info("%s disconnected", DRIVER_DESC); | 406 | dev_info(&interface->dev, "disconnected\n"); |
| 407 | } | 407 | } |
| 408 | 408 | ||
| 409 | static int __init usb_idmouse_init(void) | 409 | static int __init usb_idmouse_init(void) |
| 410 | { | 410 | { |
| 411 | int result; | 411 | int result; |
| 412 | 412 | ||
| 413 | info(DRIVER_DESC " " DRIVER_VERSION); | 413 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
| 414 | DRIVER_DESC "\n"); | ||
| 414 | 415 | ||
| 415 | /* register this driver with the USB subsystem */ | 416 | /* register this driver with the USB subsystem */ |
| 416 | result = usb_register(&idmouse_driver); | 417 | result = usb_register(&idmouse_driver); |
diff --git a/drivers/usb/misc/legousbtower.c b/drivers/usb/misc/legousbtower.c index 9370326a5940..ab0f3226158b 100644 --- a/drivers/usb/misc/legousbtower.c +++ b/drivers/usb/misc/legousbtower.c | |||
| @@ -851,9 +851,8 @@ static int tower_probe (struct usb_interface *interface, const struct usb_device | |||
| 851 | 851 | ||
| 852 | dbg(2, "%s: enter", __func__); | 852 | dbg(2, "%s: enter", __func__); |
| 853 | 853 | ||
| 854 | if (udev == NULL) { | 854 | if (udev == NULL) |
| 855 | info ("udev is NULL."); | 855 | dev_info(&interface->dev, "udev is NULL.\n"); |
| 856 | } | ||
| 857 | 856 | ||
| 858 | /* allocate memory for our device state and initialize it */ | 857 | /* allocate memory for our device state and initialize it */ |
| 859 | 858 | ||
| @@ -954,7 +953,9 @@ static int tower_probe (struct usb_interface *interface, const struct usb_device | |||
| 954 | dev->minor = interface->minor; | 953 | dev->minor = interface->minor; |
| 955 | 954 | ||
| 956 | /* let the user know what node this device is now attached to */ | 955 | /* let the user know what node this device is now attached to */ |
| 957 | info ("LEGO USB Tower #%d now attached to major %d minor %d", (dev->minor - LEGO_USB_TOWER_MINOR_BASE), USB_MAJOR, dev->minor); | 956 | dev_info(&interface->dev, "LEGO USB Tower #%d now attached to major " |
| 957 | "%d minor %d\n", (dev->minor - LEGO_USB_TOWER_MINOR_BASE), | ||
| 958 | USB_MAJOR, dev->minor); | ||
| 958 | 959 | ||
| 959 | /* get the firmware version and log it */ | 960 | /* get the firmware version and log it */ |
| 960 | result = usb_control_msg (udev, | 961 | result = usb_control_msg (udev, |
| @@ -971,10 +972,10 @@ static int tower_probe (struct usb_interface *interface, const struct usb_device | |||
| 971 | retval = result; | 972 | retval = result; |
| 972 | goto error; | 973 | goto error; |
| 973 | } | 974 | } |
| 974 | info("LEGO USB Tower firmware version is %d.%d build %d", | 975 | dev_info(&interface->dev, "LEGO USB Tower firmware version is %d.%d " |
| 975 | get_version_reply.major, | 976 | "build %d\n", get_version_reply.major, |
| 976 | get_version_reply.minor, | 977 | get_version_reply.minor, |
| 977 | le16_to_cpu(get_version_reply.build_no)); | 978 | le16_to_cpu(get_version_reply.build_no)); |
| 978 | 979 | ||
| 979 | 980 | ||
| 980 | exit: | 981 | exit: |
| @@ -1021,7 +1022,8 @@ static void tower_disconnect (struct usb_interface *interface) | |||
| 1021 | mutex_unlock(&dev->lock); | 1022 | mutex_unlock(&dev->lock); |
| 1022 | } | 1023 | } |
| 1023 | 1024 | ||
| 1024 | info("LEGO USB Tower #%d now disconnected", (minor - LEGO_USB_TOWER_MINOR_BASE)); | 1025 | dev_info(&interface->dev, "LEGO USB Tower #%d now disconnected\n", |
| 1026 | (minor - LEGO_USB_TOWER_MINOR_BASE)); | ||
| 1025 | 1027 | ||
| 1026 | dbg(2, "%s: leave", __func__); | 1028 | dbg(2, "%s: leave", __func__); |
| 1027 | } | 1029 | } |
| @@ -1046,7 +1048,8 @@ static int __init lego_usb_tower_init(void) | |||
| 1046 | goto exit; | 1048 | goto exit; |
| 1047 | } | 1049 | } |
| 1048 | 1050 | ||
| 1049 | info(DRIVER_DESC " " DRIVER_VERSION); | 1051 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
| 1052 | DRIVER_DESC "\n"); | ||
| 1050 | 1053 | ||
| 1051 | exit: | 1054 | exit: |
| 1052 | dbg(2, "%s: leave, return value %d", __func__, retval); | 1055 | dbg(2, "%s: leave, return value %d", __func__, retval); |
diff --git a/drivers/usb/misc/rio500.c b/drivers/usb/misc/rio500.c index 248a12aacef6..deb95bb49fd1 100644 --- a/drivers/usb/misc/rio500.c +++ b/drivers/usb/misc/rio500.c | |||
| @@ -89,7 +89,7 @@ static int open_rio(struct inode *inode, struct file *file) | |||
| 89 | 89 | ||
| 90 | mutex_unlock(&(rio->lock)); | 90 | mutex_unlock(&(rio->lock)); |
| 91 | 91 | ||
| 92 | info("Rio opened."); | 92 | dev_info(&rio->rio_dev->dev, "Rio opened.\n"); |
| 93 | 93 | ||
| 94 | return 0; | 94 | return 0; |
| 95 | } | 95 | } |
| @@ -100,7 +100,7 @@ static int close_rio(struct inode *inode, struct file *file) | |||
| 100 | 100 | ||
| 101 | rio->isopen = 0; | 101 | rio->isopen = 0; |
| 102 | 102 | ||
| 103 | info("Rio closed."); | 103 | dev_info(&rio->rio_dev->dev, "Rio closed.\n"); |
| 104 | return 0; | 104 | return 0; |
| 105 | } | 105 | } |
| 106 | 106 | ||
| @@ -451,7 +451,7 @@ static int probe_rio(struct usb_interface *intf, | |||
| 451 | struct rio_usb_data *rio = &rio_instance; | 451 | struct rio_usb_data *rio = &rio_instance; |
| 452 | int retval; | 452 | int retval; |
| 453 | 453 | ||
| 454 | info("USB Rio found at address %d", dev->devnum); | 454 | dev_info(&intf->dev, "USB Rio found at address %d\n", dev->devnum); |
| 455 | 455 | ||
| 456 | retval = usb_register_dev(intf, &usb_rio_class); | 456 | retval = usb_register_dev(intf, &usb_rio_class); |
| 457 | if (retval) { | 457 | if (retval) { |
| @@ -503,7 +503,7 @@ static void disconnect_rio(struct usb_interface *intf) | |||
| 503 | kfree(rio->ibuf); | 503 | kfree(rio->ibuf); |
| 504 | kfree(rio->obuf); | 504 | kfree(rio->obuf); |
| 505 | 505 | ||
| 506 | info("USB Rio disconnected."); | 506 | dev_info(&intf->dev, "USB Rio disconnected.\n"); |
| 507 | 507 | ||
| 508 | rio->present = 0; | 508 | rio->present = 0; |
| 509 | mutex_unlock(&(rio->lock)); | 509 | mutex_unlock(&(rio->lock)); |
| @@ -531,7 +531,8 @@ static int __init usb_rio_init(void) | |||
| 531 | if (retval) | 531 | if (retval) |
| 532 | goto out; | 532 | goto out; |
| 533 | 533 | ||
| 534 | info(DRIVER_VERSION ":" DRIVER_DESC); | 534 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
| 535 | DRIVER_DESC "\n"); | ||
| 535 | 536 | ||
| 536 | out: | 537 | out: |
| 537 | return retval; | 538 | return retval; |
diff --git a/drivers/usb/misc/trancevibrator.c b/drivers/usb/misc/trancevibrator.c index 03368edf3f22..2e14102955c5 100644 --- a/drivers/usb/misc/trancevibrator.c +++ b/drivers/usb/misc/trancevibrator.c | |||
| @@ -144,7 +144,8 @@ static int __init tv_init(void) | |||
| 144 | return retval; | 144 | return retval; |
| 145 | } | 145 | } |
| 146 | 146 | ||
| 147 | info(DRIVER_VERSION ":" DRIVER_DESC); | 147 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
| 148 | DRIVER_DESC "\n"); | ||
| 148 | return 0; | 149 | return 0; |
| 149 | } | 150 | } |
| 150 | 151 | ||
diff --git a/drivers/usb/misc/usblcd.c b/drivers/usb/misc/usblcd.c index 2db4228fbb01..e0ff9ccd866b 100644 --- a/drivers/usb/misc/usblcd.c +++ b/drivers/usb/misc/usblcd.c | |||
| @@ -311,7 +311,7 @@ static int lcd_probe(struct usb_interface *interface, const struct usb_device_id | |||
| 311 | dev->interface = interface; | 311 | dev->interface = interface; |
| 312 | 312 | ||
| 313 | if (le16_to_cpu(dev->udev->descriptor.idProduct) != 0x0001) { | 313 | if (le16_to_cpu(dev->udev->descriptor.idProduct) != 0x0001) { |
| 314 | warn(KERN_INFO "USBLCD model not supported."); | 314 | dev_warn(&interface->dev, "USBLCD model not supported.\n"); |
| 315 | return -ENODEV; | 315 | return -ENODEV; |
| 316 | } | 316 | } |
| 317 | 317 | ||
| @@ -359,12 +359,13 @@ static int lcd_probe(struct usb_interface *interface, const struct usb_device_id | |||
| 359 | 359 | ||
| 360 | i = le16_to_cpu(dev->udev->descriptor.bcdDevice); | 360 | i = le16_to_cpu(dev->udev->descriptor.bcdDevice); |
| 361 | 361 | ||
| 362 | info("USBLCD Version %1d%1d.%1d%1d found at address %d", | 362 | dev_info(&interface->dev, "USBLCD Version %1d%1d.%1d%1d found " |
| 363 | (i & 0xF000)>>12,(i & 0xF00)>>8,(i & 0xF0)>>4,(i & 0xF), | 363 | "at address %d\n", (i & 0xF000)>>12, (i & 0xF00)>>8, |
| 364 | dev->udev->devnum); | 364 | (i & 0xF0)>>4,(i & 0xF), dev->udev->devnum); |
| 365 | 365 | ||
| 366 | /* let the user know what node this device is now attached to */ | 366 | /* let the user know what node this device is now attached to */ |
| 367 | info("USB LCD device now attached to USBLCD-%d", interface->minor); | 367 | dev_info(&interface->dev, "USB LCD device now attached to USBLCD-%d\n", |
| 368 | interface->minor); | ||
| 368 | return 0; | 369 | return 0; |
| 369 | 370 | ||
| 370 | error: | 371 | error: |
| @@ -413,7 +414,7 @@ static void lcd_disconnect(struct usb_interface *interface) | |||
| 413 | /* decrement our usage count */ | 414 | /* decrement our usage count */ |
| 414 | kref_put(&dev->kref, lcd_delete); | 415 | kref_put(&dev->kref, lcd_delete); |
| 415 | 416 | ||
| 416 | info("USB LCD #%d now disconnected", minor); | 417 | dev_info(&interface->dev, "USB LCD #%d now disconnected\n", minor); |
| 417 | } | 418 | } |
| 418 | 419 | ||
| 419 | static struct usb_driver lcd_driver = { | 420 | static struct usb_driver lcd_driver = { |
diff --git a/drivers/usb/misc/usbsevseg.c b/drivers/usb/misc/usbsevseg.c new file mode 100644 index 000000000000..28a6a3a09538 --- /dev/null +++ b/drivers/usb/misc/usbsevseg.c | |||
| @@ -0,0 +1,394 @@ | |||
| 1 | /* | ||
| 2 | * USB 7 Segment Driver | ||
| 3 | * | ||
| 4 | * Copyright (C) 2008 Harrison Metzger <harrisonmetz@gmail.com> | ||
| 5 | * Based on usbled.c by Greg Kroah-Hartman (greg@kroah.com) | ||
| 6 | * | ||
| 7 | * This program is free software; you can redistribute it and/or | ||
| 8 | * modify it under the terms of the GNU General Public License as | ||
| 9 | * published by the Free Software Foundation, version 2. | ||
| 10 | * | ||
| 11 | */ | ||
| 12 | |||
| 13 | #include <linux/kernel.h> | ||
| 14 | #include <linux/errno.h> | ||
| 15 | #include <linux/init.h> | ||
| 16 | #include <linux/slab.h> | ||
| 17 | #include <linux/module.h> | ||
| 18 | #include <linux/string.h> | ||
| 19 | #include <linux/usb.h> | ||
| 20 | |||
| 21 | |||
| 22 | #define DRIVER_AUTHOR "Harrison Metzger <harrisonmetz@gmail.com>" | ||
| 23 | #define DRIVER_DESC "USB 7 Segment Driver" | ||
| 24 | |||
| 25 | #define VENDOR_ID 0x0fc5 | ||
| 26 | #define PRODUCT_ID 0x1227 | ||
| 27 | #define MAXLEN 6 | ||
| 28 | |||
| 29 | /* table of devices that work with this driver */ | ||
| 30 | static struct usb_device_id id_table[] = { | ||
| 31 | { USB_DEVICE(VENDOR_ID, PRODUCT_ID) }, | ||
| 32 | { }, | ||
| 33 | }; | ||
| 34 | MODULE_DEVICE_TABLE(usb, id_table); | ||
| 35 | |||
| 36 | /* the different text display modes the device is capable of */ | ||
| 37 | static char *display_textmodes[] = {"raw", "hex", "ascii", NULL}; | ||
| 38 | |||
| 39 | struct usb_sevsegdev { | ||
| 40 | struct usb_device *udev; | ||
| 41 | |||
| 42 | u8 powered; | ||
| 43 | u8 mode_msb; | ||
| 44 | u8 mode_lsb; | ||
| 45 | u8 decimals[MAXLEN]; | ||
| 46 | u8 textmode; | ||
| 47 | u8 text[MAXLEN]; | ||
| 48 | u16 textlength; | ||
| 49 | }; | ||
| 50 | |||
| 51 | /* sysfs_streq can't replace this completely | ||
| 52 | * If the device was in hex mode, and the user wanted a 0, | ||
| 53 | * if str commands are used, we would assume the end of string | ||
| 54 | * so mem commands are used. | ||
| 55 | */ | ||
| 56 | inline size_t my_memlen(const char *buf, size_t count) | ||
| 57 | { | ||
| 58 | if (count > 0 && buf[count-1] == '\n') | ||
| 59 | return count - 1; | ||
| 60 | else | ||
| 61 | return count; | ||
| 62 | } | ||
| 63 | |||
| 64 | static void update_display_powered(struct usb_sevsegdev *mydev) | ||
| 65 | { | ||
| 66 | int rc; | ||
| 67 | |||
| 68 | rc = usb_control_msg(mydev->udev, | ||
| 69 | usb_sndctrlpipe(mydev->udev, 0), | ||
| 70 | 0x12, | ||
| 71 | 0x48, | ||
| 72 | (80 * 0x100) + 10, /* (power mode) */ | ||
| 73 | (0x00 * 0x100) + (mydev->powered ? 1 : 0), | ||
| 74 | NULL, | ||
| 75 | 0, | ||
| 76 | 2000); | ||
| 77 | if (rc < 0) | ||
| 78 | dev_dbg(&mydev->udev->dev, "power retval = %d\n", rc); | ||
| 79 | } | ||
| 80 | |||
| 81 | static void update_display_mode(struct usb_sevsegdev *mydev) | ||
| 82 | { | ||
| 83 | int rc; | ||
| 84 | |||
| 85 | rc = usb_control_msg(mydev->udev, | ||
| 86 | usb_sndctrlpipe(mydev->udev, 0), | ||
| 87 | 0x12, | ||
| 88 | 0x48, | ||
| 89 | (82 * 0x100) + 10, /* (set mode) */ | ||
| 90 | (mydev->mode_msb * 0x100) + mydev->mode_lsb, | ||
| 91 | NULL, | ||
| 92 | 0, | ||
| 93 | 2000); | ||
| 94 | |||
| 95 | if (rc < 0) | ||
| 96 | dev_dbg(&mydev->udev->dev, "mode retval = %d\n", rc); | ||
| 97 | } | ||
| 98 | |||
| 99 | static void update_display_visual(struct usb_sevsegdev *mydev) | ||
| 100 | { | ||
| 101 | int rc; | ||
| 102 | int i; | ||
| 103 | unsigned char *buffer; | ||
| 104 | u8 decimals = 0; | ||
| 105 | |||
| 106 | buffer = kzalloc(MAXLEN, GFP_KERNEL); | ||
| 107 | if (!buffer) { | ||
| 108 | dev_err(&mydev->udev->dev, "out of memory\n"); | ||
| 109 | return; | ||
| 110 | } | ||
| 111 | |||
| 112 | /* The device is right to left, where as you write left to right */ | ||
| 113 | for (i = 0; i < mydev->textlength; i++) | ||
| 114 | buffer[i] = mydev->text[mydev->textlength-1-i]; | ||
| 115 | |||
| 116 | rc = usb_control_msg(mydev->udev, | ||
| 117 | usb_sndctrlpipe(mydev->udev, 0), | ||
| 118 | 0x12, | ||
| 119 | 0x48, | ||
| 120 | (85 * 0x100) + 10, /* (write text) */ | ||
| 121 | (0 * 0x100) + mydev->textmode, /* mode */ | ||
| 122 | buffer, | ||
| 123 | mydev->textlength, | ||
| 124 | 2000); | ||
| 125 | |||
| 126 | if (rc < 0) | ||
| 127 | dev_dbg(&mydev->udev->dev, "write retval = %d\n", rc); | ||
| 128 | |||
| 129 | kfree(buffer); | ||
| 130 | |||
| 131 | /* The device is right to left, where as you write left to right */ | ||
| 132 | for (i = 0; i < sizeof(mydev->decimals); i++) | ||
| 133 | decimals |= mydev->decimals[i] << i; | ||
| 134 | |||
| 135 | rc = usb_control_msg(mydev->udev, | ||
| 136 | usb_sndctrlpipe(mydev->udev, 0), | ||
| 137 | 0x12, | ||
| 138 | 0x48, | ||
| 139 | (86 * 0x100) + 10, /* (set decimal) */ | ||
| 140 | (0 * 0x100) + decimals, /* decimals */ | ||
| 141 | NULL, | ||
| 142 | 0, | ||
| 143 | 2000); | ||
| 144 | |||
| 145 | if (rc < 0) | ||
| 146 | dev_dbg(&mydev->udev->dev, "decimal retval = %d\n", rc); | ||
| 147 | } | ||
| 148 | |||
| 149 | #define MYDEV_ATTR_SIMPLE_UNSIGNED(name, update_fcn) \ | ||
| 150 | static ssize_t show_attr_##name(struct device *dev, \ | ||
| 151 | struct device_attribute *attr, char *buf) \ | ||
| 152 | { \ | ||
| 153 | struct usb_interface *intf = to_usb_interface(dev); \ | ||
| 154 | struct usb_sevsegdev *mydev = usb_get_intfdata(intf); \ | ||
| 155 | \ | ||
| 156 | return sprintf(buf, "%u\n", mydev->name); \ | ||
| 157 | } \ | ||
| 158 | \ | ||
| 159 | static ssize_t set_attr_##name(struct device *dev, \ | ||
| 160 | struct device_attribute *attr, const char *buf, size_t count) \ | ||
| 161 | { \ | ||
| 162 | struct usb_interface *intf = to_usb_interface(dev); \ | ||
| 163 | struct usb_sevsegdev *mydev = usb_get_intfdata(intf); \ | ||
| 164 | \ | ||
| 165 | mydev->name = simple_strtoul(buf, NULL, 10); \ | ||
| 166 | update_fcn(mydev); \ | ||
| 167 | \ | ||
| 168 | return count; \ | ||
| 169 | } \ | ||
| 170 | static DEVICE_ATTR(name, S_IWUGO | S_IRUGO, show_attr_##name, set_attr_##name); | ||
| 171 | |||
| 172 | static ssize_t show_attr_text(struct device *dev, | ||
| 173 | struct device_attribute *attr, char *buf) | ||
| 174 | { | ||
| 175 | struct usb_interface *intf = to_usb_interface(dev); | ||
| 176 | struct usb_sevsegdev *mydev = usb_get_intfdata(intf); | ||
| 177 | |||
| 178 | return snprintf(buf, mydev->textlength, "%s\n", mydev->text); | ||
| 179 | } | ||
| 180 | |||
| 181 | static ssize_t set_attr_text(struct device *dev, | ||
| 182 | struct device_attribute *attr, const char *buf, size_t count) | ||
| 183 | { | ||
| 184 | struct usb_interface *intf = to_usb_interface(dev); | ||
| 185 | struct usb_sevsegdev *mydev = usb_get_intfdata(intf); | ||
| 186 | size_t end = my_memlen(buf, count); | ||
| 187 | |||
| 188 | if (end > sizeof(mydev->text)) | ||
| 189 | return -EINVAL; | ||
| 190 | |||
| 191 | memset(mydev->text, 0, sizeof(mydev->text)); | ||
| 192 | mydev->textlength = end; | ||
| 193 | |||
| 194 | if (end > 0) | ||
| 195 | memcpy(mydev->text, buf, end); | ||
| 196 | |||
| 197 | update_display_visual(mydev); | ||
| 198 | return count; | ||
| 199 | } | ||
| 200 | |||
| 201 | static DEVICE_ATTR(text, S_IWUGO | S_IRUGO, show_attr_text, set_attr_text); | ||
| 202 | |||
| 203 | static ssize_t show_attr_decimals(struct device *dev, | ||
| 204 | struct device_attribute *attr, char *buf) | ||
| 205 | { | ||
| 206 | struct usb_interface *intf = to_usb_interface(dev); | ||
| 207 | struct usb_sevsegdev *mydev = usb_get_intfdata(intf); | ||
| 208 | int i; | ||
| 209 | int pos; | ||
| 210 | |||
| 211 | for (i = 0; i < sizeof(mydev->decimals); i++) { | ||
| 212 | pos = sizeof(mydev->decimals) - 1 - i; | ||
| 213 | if (mydev->decimals[i] == 0) | ||
| 214 | buf[pos] = '0'; | ||
| 215 | else if (mydev->decimals[i] == 1) | ||
| 216 | buf[pos] = '1'; | ||
| 217 | else | ||
| 218 | buf[pos] = 'x'; | ||
| 219 | } | ||
| 220 | |||
| 221 | buf[sizeof(mydev->decimals)] = '\n'; | ||
| 222 | return sizeof(mydev->decimals) + 1; | ||
| 223 | } | ||
| 224 | |||
| 225 | static ssize_t set_attr_decimals(struct device *dev, | ||
| 226 | struct device_attribute *attr, const char *buf, size_t count) | ||
| 227 | { | ||
| 228 | struct usb_interface *intf = to_usb_interface(dev); | ||
| 229 | struct usb_sevsegdev *mydev = usb_get_intfdata(intf); | ||
| 230 | size_t end = my_memlen(buf, count); | ||
| 231 | int i; | ||
| 232 | |||
| 233 | if (end > sizeof(mydev->decimals)) | ||
| 234 | return -EINVAL; | ||
| 235 | |||
| 236 | for (i = 0; i < end; i++) | ||
| 237 | if (buf[i] != '0' && buf[i] != '1') | ||
| 238 | return -EINVAL; | ||
| 239 | |||
| 240 | memset(mydev->decimals, 0, sizeof(mydev->decimals)); | ||
| 241 | for (i = 0; i < end; i++) | ||
| 242 | if (buf[i] == '1') | ||
| 243 | mydev->decimals[end-1-i] = 1; | ||
| 244 | |||
| 245 | update_display_visual(mydev); | ||
| 246 | |||
| 247 | return count; | ||
| 248 | } | ||
| 249 | |||
| 250 | static DEVICE_ATTR(decimals, S_IWUGO | S_IRUGO, | ||
| 251 | show_attr_decimals, set_attr_decimals); | ||
| 252 | |||
| 253 | static ssize_t show_attr_textmode(struct device *dev, | ||
| 254 | struct device_attribute *attr, char *buf) | ||
| 255 | { | ||
| 256 | struct usb_interface *intf = to_usb_interface(dev); | ||
| 257 | struct usb_sevsegdev *mydev = usb_get_intfdata(intf); | ||
| 258 | int i; | ||
| 259 | |||
| 260 | buf[0] = 0; | ||
| 261 | |||
| 262 | for (i = 0; display_textmodes[i]; i++) { | ||
| 263 | if (mydev->textmode == i) { | ||
| 264 | strcat(buf, " ["); | ||
| 265 | strcat(buf, display_textmodes[i]); | ||
| 266 | strcat(buf, "] "); | ||
| 267 | } else { | ||
| 268 | strcat(buf, " "); | ||
| 269 | strcat(buf, display_textmodes[i]); | ||
| 270 | strcat(buf, " "); | ||
| 271 | } | ||
| 272 | } | ||
| 273 | strcat(buf, "\n"); | ||
| 274 | |||
| 275 | |||
| 276 | return strlen(buf); | ||
| 277 | } | ||
| 278 | |||
| 279 | static ssize_t set_attr_textmode(struct device *dev, | ||
| 280 | struct device_attribute *attr, const char *buf, size_t count) | ||
| 281 | { | ||
| 282 | struct usb_interface *intf = to_usb_interface(dev); | ||
| 283 | struct usb_sevsegdev *mydev = usb_get_intfdata(intf); | ||
| 284 | int i; | ||
| 285 | |||
| 286 | for (i = 0; display_textmodes[i]; i++) { | ||
| 287 | if (sysfs_streq(display_textmodes[i], buf)) { | ||
| 288 | mydev->textmode = i; | ||
| 289 | update_display_visual(mydev); | ||
| 290 | return count; | ||
| 291 | } | ||
| 292 | } | ||
| 293 | |||
| 294 | return -EINVAL; | ||
| 295 | } | ||
| 296 | |||
| 297 | static DEVICE_ATTR(textmode, S_IWUGO | S_IRUGO, | ||
| 298 | show_attr_textmode, set_attr_textmode); | ||
| 299 | |||
| 300 | |||
| 301 | MYDEV_ATTR_SIMPLE_UNSIGNED(powered, update_display_powered); | ||
| 302 | MYDEV_ATTR_SIMPLE_UNSIGNED(mode_msb, update_display_mode); | ||
| 303 | MYDEV_ATTR_SIMPLE_UNSIGNED(mode_lsb, update_display_mode); | ||
| 304 | |||
| 305 | static struct attribute *dev_attrs[] = { | ||
| 306 | &dev_attr_powered.attr, | ||
| 307 | &dev_attr_text.attr, | ||
| 308 | &dev_attr_textmode.attr, | ||
| 309 | &dev_attr_decimals.attr, | ||
| 310 | &dev_attr_mode_msb.attr, | ||
| 311 | &dev_attr_mode_lsb.attr, | ||
| 312 | NULL | ||
| 313 | }; | ||
| 314 | |||
| 315 | static struct attribute_group dev_attr_grp = { | ||
| 316 | .attrs = dev_attrs, | ||
| 317 | }; | ||
| 318 | |||
| 319 | static int sevseg_probe(struct usb_interface *interface, | ||
| 320 | const struct usb_device_id *id) | ||
| 321 | { | ||
| 322 | struct usb_device *udev = interface_to_usbdev(interface); | ||
| 323 | struct usb_sevsegdev *mydev = NULL; | ||
| 324 | int rc = -ENOMEM; | ||
| 325 | |||
| 326 | mydev = kzalloc(sizeof(struct usb_sevsegdev), GFP_KERNEL); | ||
| 327 | if (mydev == NULL) { | ||
| 328 | dev_err(&interface->dev, "Out of memory\n"); | ||
| 329 | goto error_mem; | ||
| 330 | } | ||
| 331 | |||
| 332 | mydev->udev = usb_get_dev(udev); | ||
| 333 | usb_set_intfdata(interface, mydev); | ||
| 334 | |||
| 335 | /*set defaults */ | ||
| 336 | mydev->textmode = 0x02; /* ascii mode */ | ||
| 337 | mydev->mode_msb = 0x06; /* 6 characters */ | ||
| 338 | mydev->mode_lsb = 0x3f; /* scanmode for 6 chars */ | ||
| 339 | |||
| 340 | rc = sysfs_create_group(&interface->dev.kobj, &dev_attr_grp); | ||
| 341 | if (rc) | ||
| 342 | goto error; | ||
| 343 | |||
| 344 | dev_info(&interface->dev, "USB 7 Segment device now attached\n"); | ||
| 345 | return 0; | ||
| 346 | |||
| 347 | error: | ||
| 348 | usb_set_intfdata(interface, NULL); | ||
| 349 | usb_put_dev(mydev->udev); | ||
| 350 | kfree(mydev); | ||
| 351 | error_mem: | ||
| 352 | return rc; | ||
| 353 | } | ||
| 354 | |||
| 355 | static void sevseg_disconnect(struct usb_interface *interface) | ||
| 356 | { | ||
| 357 | struct usb_sevsegdev *mydev; | ||
| 358 | |||
| 359 | mydev = usb_get_intfdata(interface); | ||
| 360 | sysfs_remove_group(&interface->dev.kobj, &dev_attr_grp); | ||
| 361 | usb_set_intfdata(interface, NULL); | ||
| 362 | usb_put_dev(mydev->udev); | ||
| 363 | kfree(mydev); | ||
| 364 | dev_info(&interface->dev, "USB 7 Segment now disconnected\n"); | ||
| 365 | } | ||
| 366 | |||
| 367 | static struct usb_driver sevseg_driver = { | ||
| 368 | .name = "usbsevseg", | ||
| 369 | .probe = sevseg_probe, | ||
| 370 | .disconnect = sevseg_disconnect, | ||
| 371 | .id_table = id_table, | ||
| 372 | }; | ||
| 373 | |||
| 374 | static int __init usb_sevseg_init(void) | ||
| 375 | { | ||
| 376 | int rc = 0; | ||
| 377 | |||
| 378 | rc = usb_register(&sevseg_driver); | ||
| 379 | if (rc) | ||
| 380 | err("usb_register failed. Error number %d", rc); | ||
| 381 | return rc; | ||
| 382 | } | ||
| 383 | |||
| 384 | static void __exit usb_sevseg_exit(void) | ||
| 385 | { | ||
| 386 | usb_deregister(&sevseg_driver); | ||
| 387 | } | ||
| 388 | |||
| 389 | module_init(usb_sevseg_init); | ||
| 390 | module_exit(usb_sevseg_exit); | ||
| 391 | |||
| 392 | MODULE_AUTHOR(DRIVER_AUTHOR); | ||
| 393 | MODULE_DESCRIPTION(DRIVER_DESC); | ||
| 394 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/usb/misc/uss720.c b/drivers/usb/misc/uss720.c index f1255b0a182d..9a6c27a01793 100644 --- a/drivers/usb/misc/uss720.c +++ b/drivers/usb/misc/uss720.c | |||
| @@ -228,11 +228,12 @@ static int get_1284_register(struct parport *pp, unsigned char reg, unsigned cha | |||
| 228 | ret = rq->urb->status; | 228 | ret = rq->urb->status; |
| 229 | *val = priv->reg[(reg >= 9) ? 0 : regindex[reg]]; | 229 | *val = priv->reg[(reg >= 9) ? 0 : regindex[reg]]; |
| 230 | if (ret) | 230 | if (ret) |
| 231 | warn("get_1284_register: usb error %d", ret); | 231 | printk(KERN_WARNING "get_1284_register: " |
| 232 | "usb error %d\n", ret); | ||
| 232 | kref_put(&rq->ref_count, destroy_async); | 233 | kref_put(&rq->ref_count, destroy_async); |
| 233 | return ret; | 234 | return ret; |
| 234 | } | 235 | } |
| 235 | warn("get_1284_register timeout"); | 236 | printk(KERN_WARNING "get_1284_register timeout\n"); |
| 236 | kill_all_async_requests_priv(priv); | 237 | kill_all_async_requests_priv(priv); |
| 237 | return -EIO; | 238 | return -EIO; |
| 238 | } | 239 | } |
| @@ -716,7 +717,7 @@ static int uss720_probe(struct usb_interface *intf, | |||
| 716 | spin_lock_init(&priv->asynclock); | 717 | spin_lock_init(&priv->asynclock); |
| 717 | INIT_LIST_HEAD(&priv->asynclist); | 718 | INIT_LIST_HEAD(&priv->asynclist); |
| 718 | if (!(pp = parport_register_port(0, PARPORT_IRQ_NONE, PARPORT_DMA_NONE, &parport_uss720_ops))) { | 719 | if (!(pp = parport_register_port(0, PARPORT_IRQ_NONE, PARPORT_DMA_NONE, &parport_uss720_ops))) { |
| 719 | warn("could not register parport"); | 720 | printk(KERN_WARNING "uss720: could not register parport\n"); |
| 720 | goto probe_abort; | 721 | goto probe_abort; |
| 721 | } | 722 | } |
| 722 | 723 | ||
| @@ -800,10 +801,14 @@ static int __init uss720_init(void) | |||
| 800 | if (retval) | 801 | if (retval) |
| 801 | goto out; | 802 | goto out; |
| 802 | 803 | ||
| 803 | info(DRIVER_VERSION ":" DRIVER_DESC); | 804 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
| 804 | info("NOTE: this is a special purpose driver to allow nonstandard"); | 805 | DRIVER_DESC "\n"); |
| 805 | info("protocols (eg. bitbang) over USS720 usb to parallel cables"); | 806 | printk(KERN_INFO KBUILD_MODNAME ": NOTE: this is a special purpose " |
| 806 | info("If you just want to connect to a printer, use usblp instead"); | 807 | "driver to allow nonstandard\n"); |
| 808 | printk(KERN_INFO KBUILD_MODNAME ": protocols (eg. bitbang) over " | ||
| 809 | "USS720 usb to parallel cables\n"); | ||
| 810 | printk(KERN_INFO KBUILD_MODNAME ": If you just want to connect to a " | ||
| 811 | "printer, use usblp instead\n"); | ||
| 807 | out: | 812 | out: |
| 808 | return retval; | 813 | return retval; |
| 809 | } | 814 | } |
diff --git a/drivers/usb/misc/vstusb.c b/drivers/usb/misc/vstusb.c new file mode 100644 index 000000000000..8648470c81ca --- /dev/null +++ b/drivers/usb/misc/vstusb.c | |||
| @@ -0,0 +1,782 @@ | |||
| 1 | /***************************************************************************** | ||
| 2 | * File: drivers/usb/misc/vstusb.c | ||
| 3 | * | ||
| 4 | * Purpose: Support for the bulk USB Vernier Spectrophotometers | ||
| 5 | * | ||
| 6 | * Author: Johnnie Peters | ||
| 7 | * Axian Consulting | ||
| 8 | * Beaverton, OR, USA 97005 | ||
| 9 | * | ||
| 10 | * Modified by: EQware Engineering, Inc. | ||
| 11 | * Oregon City, OR, USA 97045 | ||
| 12 | * | ||
| 13 | * Copyright: 2007, 2008 | ||
| 14 | * Vernier Software & Technology | ||
| 15 | * Beaverton, OR, USA 97005 | ||
| 16 | * | ||
| 17 | * Web: www.vernier.com | ||
| 18 | * | ||
| 19 | * This program is free software; you can redistribute it and/or modify | ||
| 20 | * it under the terms of the GNU General Public License version 2 as | ||
| 21 | * published by the Free Software Foundation. | ||
| 22 | * | ||
| 23 | *****************************************************************************/ | ||
| 24 | #include <linux/kernel.h> | ||
| 25 | #include <linux/errno.h> | ||
| 26 | #include <linux/init.h> | ||
| 27 | #include <linux/slab.h> | ||
| 28 | #include <linux/module.h> | ||
| 29 | #include <linux/mutex.h> | ||
| 30 | #include <linux/uaccess.h> | ||
| 31 | #include <linux/usb.h> | ||
| 32 | |||
| 33 | #include <linux/usb/vstusb.h> | ||
| 34 | |||
| 35 | #define DRIVER_VERSION "VST USB Driver Version 1.5" | ||
| 36 | #define DRIVER_DESC "Vernier Software Technology Bulk USB Driver" | ||
| 37 | |||
| 38 | #ifdef CONFIG_USB_DYNAMIC_MINORS | ||
| 39 | #define VSTUSB_MINOR_BASE 0 | ||
| 40 | #else | ||
| 41 | #define VSTUSB_MINOR_BASE 199 | ||
| 42 | #endif | ||
| 43 | |||
| 44 | #define USB_VENDOR_OCEANOPTICS 0x2457 | ||
| 45 | #define USB_VENDOR_VERNIER 0x08F7 /* Vernier Software & Technology */ | ||
| 46 | |||
| 47 | #define USB_PRODUCT_USB2000 0x1002 | ||
| 48 | #define USB_PRODUCT_ADC1000_FW 0x1003 /* firmware download (renumerates) */ | ||
| 49 | #define USB_PRODUCT_ADC1000 0x1004 | ||
| 50 | #define USB_PRODUCT_HR2000_FW 0x1009 /* firmware download (renumerates) */ | ||
| 51 | #define USB_PRODUCT_HR2000 0x100A | ||
| 52 | #define USB_PRODUCT_HR4000_FW 0x1011 /* firmware download (renumerates) */ | ||
| 53 | #define USB_PRODUCT_HR4000 0x1012 | ||
| 54 | #define USB_PRODUCT_USB650 0x1014 /* "Red Tide" */ | ||
| 55 | #define USB_PRODUCT_QE65000 0x1018 | ||
| 56 | #define USB_PRODUCT_USB4000 0x1022 | ||
| 57 | #define USB_PRODUCT_USB325 0x1024 /* "Vernier Spectrometer" */ | ||
| 58 | |||
| 59 | #define USB_PRODUCT_LABPRO 0x0001 | ||
| 60 | #define USB_PRODUCT_LABQUEST 0x0005 | ||
| 61 | |||
| 62 | #define VST_MAXBUFFER (64*1024) | ||
| 63 | |||
| 64 | static struct usb_device_id id_table[] = { | ||
| 65 | { USB_DEVICE(USB_VENDOR_OCEANOPTICS, USB_PRODUCT_USB2000)}, | ||
| 66 | { USB_DEVICE(USB_VENDOR_OCEANOPTICS, USB_PRODUCT_HR4000)}, | ||
| 67 | { USB_DEVICE(USB_VENDOR_OCEANOPTICS, USB_PRODUCT_USB650)}, | ||
| 68 | { USB_DEVICE(USB_VENDOR_OCEANOPTICS, USB_PRODUCT_USB4000)}, | ||
| 69 | { USB_DEVICE(USB_VENDOR_OCEANOPTICS, USB_PRODUCT_USB325)}, | ||
| 70 | { USB_DEVICE(USB_VENDOR_VERNIER, USB_PRODUCT_LABQUEST)}, | ||
| 71 | { USB_DEVICE(USB_VENDOR_VERNIER, USB_PRODUCT_LABPRO)}, | ||
| 72 | {}, | ||
| 73 | }; | ||
| 74 | |||
| 75 | MODULE_DEVICE_TABLE(usb, id_table); | ||
| 76 | |||
| 77 | struct vstusb_device { | ||
| 78 | struct kref kref; | ||
| 79 | struct mutex lock; | ||
| 80 | struct usb_device *usb_dev; | ||
| 81 | char present; | ||
| 82 | char isopen; | ||
| 83 | struct usb_anchor submitted; | ||
| 84 | int rd_pipe; | ||
| 85 | int rd_timeout_ms; | ||
| 86 | int wr_pipe; | ||
| 87 | int wr_timeout_ms; | ||
| 88 | }; | ||
| 89 | #define to_vst_dev(d) container_of(d, struct vstusb_device, kref) | ||
| 90 | |||
| 91 | static struct usb_driver vstusb_driver; | ||
| 92 | |||
| 93 | static void vstusb_delete(struct kref *kref) | ||
| 94 | { | ||
| 95 | struct vstusb_device *vstdev = to_vst_dev(kref); | ||
| 96 | |||
| 97 | usb_put_dev(vstdev->usb_dev); | ||
| 98 | kfree(vstdev); | ||
| 99 | } | ||
| 100 | |||
| 101 | static int vstusb_open(struct inode *inode, struct file *file) | ||
| 102 | { | ||
| 103 | struct vstusb_device *vstdev; | ||
| 104 | struct usb_interface *interface; | ||
| 105 | |||
| 106 | interface = usb_find_interface(&vstusb_driver, iminor(inode)); | ||
| 107 | |||
| 108 | if (!interface) { | ||
| 109 | printk(KERN_ERR KBUILD_MODNAME | ||
| 110 | ": %s - error, can't find device for minor %d\n", | ||
| 111 | __func__, iminor(inode)); | ||
| 112 | return -ENODEV; | ||
| 113 | } | ||
| 114 | |||
| 115 | vstdev = usb_get_intfdata(interface); | ||
| 116 | |||
| 117 | if (!vstdev) | ||
| 118 | return -ENODEV; | ||
| 119 | |||
| 120 | /* lock this device */ | ||
| 121 | mutex_lock(&vstdev->lock); | ||
| 122 | |||
| 123 | /* can only open one time */ | ||
| 124 | if ((!vstdev->present) || (vstdev->isopen)) { | ||
| 125 | mutex_unlock(&vstdev->lock); | ||
| 126 | return -EBUSY; | ||
| 127 | } | ||
| 128 | |||
| 129 | /* increment our usage count */ | ||
| 130 | kref_get(&vstdev->kref); | ||
| 131 | |||
| 132 | vstdev->isopen = 1; | ||
| 133 | |||
| 134 | /* save device in the file's private structure */ | ||
| 135 | file->private_data = vstdev; | ||
| 136 | |||
| 137 | dev_dbg(&vstdev->usb_dev->dev, "%s: opened\n", __func__); | ||
| 138 | |||
| 139 | mutex_unlock(&vstdev->lock); | ||
| 140 | |||
| 141 | return 0; | ||
| 142 | } | ||
| 143 | |||
| 144 | static int vstusb_release(struct inode *inode, struct file *file) | ||
| 145 | { | ||
| 146 | struct vstusb_device *vstdev; | ||
| 147 | |||
| 148 | vstdev = file->private_data; | ||
| 149 | |||
| 150 | if (vstdev == NULL) | ||
| 151 | return -ENODEV; | ||
| 152 | |||
| 153 | mutex_lock(&vstdev->lock); | ||
| 154 | |||
| 155 | vstdev->isopen = 0; | ||
| 156 | |||
| 157 | dev_dbg(&vstdev->usb_dev->dev, "%s: released\n", __func__); | ||
| 158 | |||
| 159 | mutex_unlock(&vstdev->lock); | ||
| 160 | |||
| 161 | kref_put(&vstdev->kref, vstusb_delete); | ||
| 162 | |||
| 163 | return 0; | ||
| 164 | } | ||
| 165 | |||
| 166 | static void usb_api_blocking_completion(struct urb *urb) | ||
| 167 | { | ||
| 168 | struct completion *completeit = urb->context; | ||
| 169 | |||
| 170 | complete(completeit); | ||
| 171 | } | ||
| 172 | |||
| 173 | static int vstusb_fill_and_send_urb(struct urb *urb, | ||
| 174 | struct usb_device *usb_dev, | ||
| 175 | unsigned int pipe, void *data, | ||
| 176 | unsigned int len, struct completion *done) | ||
| 177 | { | ||
| 178 | struct usb_host_endpoint *ep; | ||
| 179 | struct usb_host_endpoint **hostep; | ||
| 180 | unsigned int pipend; | ||
| 181 | |||
| 182 | int status; | ||
| 183 | |||
| 184 | hostep = usb_pipein(pipe) ? usb_dev->ep_in : usb_dev->ep_out; | ||
| 185 | pipend = usb_pipeendpoint(pipe); | ||
| 186 | ep = hostep[pipend]; | ||
| 187 | |||
| 188 | if (!ep || (len == 0)) | ||
| 189 | return -EINVAL; | ||
| 190 | |||
| 191 | if ((ep->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) | ||
| 192 | == USB_ENDPOINT_XFER_INT) { | ||
| 193 | pipe = (pipe & ~(3 << 30)) | (PIPE_INTERRUPT << 30); | ||
| 194 | usb_fill_int_urb(urb, usb_dev, pipe, data, len, | ||
| 195 | (usb_complete_t)usb_api_blocking_completion, | ||
| 196 | NULL, ep->desc.bInterval); | ||
| 197 | } else | ||
| 198 | usb_fill_bulk_urb(urb, usb_dev, pipe, data, len, | ||
| 199 | (usb_complete_t)usb_api_blocking_completion, | ||
| 200 | NULL); | ||
| 201 | |||
| 202 | init_completion(done); | ||
| 203 | urb->context = done; | ||
| 204 | urb->actual_length = 0; | ||
| 205 | status = usb_submit_urb(urb, GFP_KERNEL); | ||
| 206 | |||
| 207 | return status; | ||
| 208 | } | ||
| 209 | |||
| 210 | static int vstusb_complete_urb(struct urb *urb, struct completion *done, | ||
| 211 | int timeout, int *actual_length) | ||
| 212 | { | ||
| 213 | unsigned long expire; | ||
| 214 | int status; | ||
| 215 | |||
| 216 | expire = timeout ? msecs_to_jiffies(timeout) : MAX_SCHEDULE_TIMEOUT; | ||
| 217 | if (!wait_for_completion_interruptible_timeout(done, expire)) { | ||
| 218 | usb_kill_urb(urb); | ||
| 219 | status = urb->status == -ENOENT ? -ETIMEDOUT : urb->status; | ||
| 220 | |||
| 221 | dev_dbg(&urb->dev->dev, | ||
| 222 | "%s timed out on ep%d%s len=%d/%d, urb status = %d\n", | ||
| 223 | current->comm, | ||
| 224 | usb_pipeendpoint(urb->pipe), | ||
| 225 | usb_pipein(urb->pipe) ? "in" : "out", | ||
| 226 | urb->actual_length, | ||
| 227 | urb->transfer_buffer_length, | ||
| 228 | urb->status); | ||
| 229 | |||
| 230 | } else { | ||
| 231 | if (signal_pending(current)) { | ||
| 232 | /* if really an error */ | ||
| 233 | if (urb->status && !((urb->status == -ENOENT) || | ||
| 234 | (urb->status == -ECONNRESET) || | ||
| 235 | (urb->status == -ESHUTDOWN))) { | ||
| 236 | status = -EINTR; | ||
| 237 | usb_kill_urb(urb); | ||
| 238 | } else { | ||
| 239 | status = 0; | ||
| 240 | } | ||
| 241 | |||
| 242 | dev_dbg(&urb->dev->dev, | ||
| 243 | "%s: signal pending on ep%d%s len=%d/%d," | ||
| 244 | "urb status = %d\n", | ||
| 245 | current->comm, | ||
| 246 | usb_pipeendpoint(urb->pipe), | ||
| 247 | usb_pipein(urb->pipe) ? "in" : "out", | ||
| 248 | urb->actual_length, | ||
| 249 | urb->transfer_buffer_length, | ||
| 250 | urb->status); | ||
| 251 | |||
| 252 | } else { | ||
| 253 | status = urb->status; | ||
| 254 | } | ||
| 255 | } | ||
| 256 | |||
| 257 | if (actual_length) | ||
| 258 | *actual_length = urb->actual_length; | ||
| 259 | |||
| 260 | return status; | ||
| 261 | } | ||
| 262 | |||
| 263 | static ssize_t vstusb_read(struct file *file, char __user *buffer, | ||
| 264 | size_t count, loff_t *ppos) | ||
| 265 | { | ||
| 266 | struct vstusb_device *vstdev; | ||
| 267 | int cnt = -1; | ||
| 268 | void *buf; | ||
| 269 | int retval = 0; | ||
| 270 | |||
| 271 | struct urb *urb; | ||
| 272 | struct usb_device *dev; | ||
| 273 | unsigned int pipe; | ||
| 274 | int timeout; | ||
| 275 | |||
| 276 | DECLARE_COMPLETION_ONSTACK(done); | ||
| 277 | |||
| 278 | vstdev = file->private_data; | ||
| 279 | |||
| 280 | if (vstdev == NULL) | ||
| 281 | return -ENODEV; | ||
| 282 | |||
| 283 | /* verify that we actually want to read some data */ | ||
| 284 | if ((count == 0) || (count > VST_MAXBUFFER)) | ||
| 285 | return -EINVAL; | ||
| 286 | |||
| 287 | /* lock this object */ | ||
| 288 | if (mutex_lock_interruptible(&vstdev->lock)) | ||
| 289 | return -ERESTARTSYS; | ||
| 290 | |||
| 291 | /* anyone home */ | ||
| 292 | if (!vstdev->present) { | ||
| 293 | mutex_unlock(&vstdev->lock); | ||
| 294 | printk(KERN_ERR KBUILD_MODNAME | ||
| 295 | ": %s: device not present\n", __func__); | ||
| 296 | return -ENODEV; | ||
| 297 | } | ||
| 298 | |||
| 299 | /* pull out the necessary data */ | ||
| 300 | dev = vstdev->usb_dev; | ||
| 301 | pipe = usb_rcvbulkpipe(dev, vstdev->rd_pipe); | ||
| 302 | timeout = vstdev->rd_timeout_ms; | ||
| 303 | |||
| 304 | buf = kmalloc(count, GFP_KERNEL); | ||
| 305 | if (buf == NULL) { | ||
| 306 | mutex_unlock(&vstdev->lock); | ||
| 307 | return -ENOMEM; | ||
| 308 | } | ||
| 309 | |||
| 310 | urb = usb_alloc_urb(0, GFP_KERNEL); | ||
| 311 | if (!urb) { | ||
| 312 | kfree(buf); | ||
| 313 | mutex_unlock(&vstdev->lock); | ||
| 314 | return -ENOMEM; | ||
| 315 | } | ||
| 316 | |||
| 317 | usb_anchor_urb(urb, &vstdev->submitted); | ||
| 318 | retval = vstusb_fill_and_send_urb(urb, dev, pipe, buf, count, &done); | ||
| 319 | mutex_unlock(&vstdev->lock); | ||
| 320 | if (retval) { | ||
| 321 | usb_unanchor_urb(urb); | ||
| 322 | dev_err(&dev->dev, "%s: error %d filling and sending urb %d\n", | ||
| 323 | __func__, retval, pipe); | ||
| 324 | goto exit; | ||
| 325 | } | ||
| 326 | |||
| 327 | retval = vstusb_complete_urb(urb, &done, timeout, &cnt); | ||
| 328 | if (retval) { | ||
| 329 | dev_err(&dev->dev, "%s: error %d completing urb %d\n", | ||
| 330 | __func__, retval, pipe); | ||
| 331 | goto exit; | ||
| 332 | } | ||
| 333 | |||
| 334 | if (copy_to_user(buffer, buf, cnt)) { | ||
| 335 | dev_err(&dev->dev, "%s: can't copy_to_user\n", __func__); | ||
| 336 | retval = -EFAULT; | ||
| 337 | } else { | ||
| 338 | retval = cnt; | ||
| 339 | dev_dbg(&dev->dev, "%s: read %d bytes from pipe %d\n", | ||
| 340 | __func__, cnt, pipe); | ||
| 341 | } | ||
| 342 | |||
| 343 | exit: | ||
| 344 | usb_free_urb(urb); | ||
| 345 | kfree(buf); | ||
| 346 | return retval; | ||
| 347 | } | ||
| 348 | |||
| 349 | static ssize_t vstusb_write(struct file *file, const char __user *buffer, | ||
| 350 | size_t count, loff_t *ppos) | ||
| 351 | { | ||
| 352 | struct vstusb_device *vstdev; | ||
| 353 | int cnt = -1; | ||
| 354 | void *buf; | ||
| 355 | int retval = 0; | ||
| 356 | |||
| 357 | struct urb *urb; | ||
| 358 | struct usb_device *dev; | ||
| 359 | unsigned int pipe; | ||
| 360 | int timeout; | ||
| 361 | |||
| 362 | DECLARE_COMPLETION_ONSTACK(done); | ||
| 363 | |||
| 364 | vstdev = file->private_data; | ||
| 365 | |||
| 366 | if (vstdev == NULL) | ||
| 367 | return -ENODEV; | ||
| 368 | |||
| 369 | /* verify that we actually have some data to write */ | ||
| 370 | if ((count == 0) || (count > VST_MAXBUFFER)) | ||
| 371 | return retval; | ||
| 372 | |||
| 373 | /* lock this object */ | ||
| 374 | if (mutex_lock_interruptible(&vstdev->lock)) | ||
| 375 | return -ERESTARTSYS; | ||
| 376 | |||
| 377 | /* anyone home */ | ||
| 378 | if (!vstdev->present) { | ||
| 379 | mutex_unlock(&vstdev->lock); | ||
| 380 | printk(KERN_ERR KBUILD_MODNAME | ||
| 381 | ": %s: device not present\n", __func__); | ||
| 382 | return -ENODEV; | ||
| 383 | } | ||
| 384 | |||
| 385 | /* pull out the necessary data */ | ||
| 386 | dev = vstdev->usb_dev; | ||
| 387 | pipe = usb_sndbulkpipe(dev, vstdev->wr_pipe); | ||
| 388 | timeout = vstdev->wr_timeout_ms; | ||
| 389 | |||
| 390 | buf = kmalloc(count, GFP_KERNEL); | ||
| 391 | if (buf == NULL) { | ||
| 392 | mutex_unlock(&vstdev->lock); | ||
| 393 | return -ENOMEM; | ||
| 394 | } | ||
| 395 | |||
| 396 | urb = usb_alloc_urb(0, GFP_KERNEL); | ||
| 397 | if (!urb) { | ||
| 398 | kfree(buf); | ||
| 399 | mutex_unlock(&vstdev->lock); | ||
| 400 | return -ENOMEM; | ||
| 401 | } | ||
| 402 | |||
| 403 | if (copy_from_user(buf, buffer, count)) { | ||
| 404 | dev_err(&dev->dev, "%s: can't copy_from_user\n", __func__); | ||
| 405 | retval = -EFAULT; | ||
| 406 | goto exit; | ||
| 407 | } | ||
| 408 | |||
| 409 | usb_anchor_urb(urb, &vstdev->submitted); | ||
| 410 | retval = vstusb_fill_and_send_urb(urb, dev, pipe, buf, count, &done); | ||
| 411 | mutex_unlock(&vstdev->lock); | ||
| 412 | if (retval) { | ||
| 413 | usb_unanchor_urb(urb); | ||
| 414 | dev_err(&dev->dev, "%s: error %d filling and sending urb %d\n", | ||
| 415 | __func__, retval, pipe); | ||
| 416 | goto exit; | ||
| 417 | } | ||
| 418 | |||
| 419 | retval = vstusb_complete_urb(urb, &done, timeout, &cnt); | ||
| 420 | if (retval) { | ||
| 421 | dev_err(&dev->dev, "%s: error %d completing urb %d\n", | ||
| 422 | __func__, retval, pipe); | ||
| 423 | goto exit; | ||
| 424 | } else { | ||
| 425 | retval = cnt; | ||
| 426 | dev_dbg(&dev->dev, "%s: sent %d bytes to pipe %d\n", | ||
| 427 | __func__, cnt, pipe); | ||
| 428 | } | ||
| 429 | |||
| 430 | exit: | ||
| 431 | usb_free_urb(urb); | ||
| 432 | kfree(buf); | ||
| 433 | return retval; | ||
| 434 | } | ||
| 435 | |||
| 436 | static long vstusb_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | ||
| 437 | { | ||
| 438 | int retval = 0; | ||
| 439 | int cnt = -1; | ||
| 440 | void __user *data = (void __user *)arg; | ||
| 441 | struct vstusb_args usb_data; | ||
| 442 | |||
| 443 | struct vstusb_device *vstdev; | ||
| 444 | void *buffer = NULL; /* must be initialized. buffer is | ||
| 445 | * referenced on exit but not all | ||
| 446 | * ioctls allocate it */ | ||
| 447 | |||
| 448 | struct urb *urb = NULL; /* must be initialized. urb is | ||
| 449 | * referenced on exit but not all | ||
| 450 | * ioctls allocate it */ | ||
| 451 | struct usb_device *dev; | ||
| 452 | unsigned int pipe; | ||
| 453 | int timeout; | ||
| 454 | |||
| 455 | DECLARE_COMPLETION_ONSTACK(done); | ||
| 456 | |||
| 457 | vstdev = file->private_data; | ||
| 458 | |||
| 459 | if (_IOC_TYPE(cmd) != VST_IOC_MAGIC) { | ||
| 460 | dev_warn(&vstdev->usb_dev->dev, | ||
| 461 | "%s: ioctl command %x, bad ioctl magic %x, " | ||
| 462 | "expected %x\n", __func__, cmd, | ||
| 463 | _IOC_TYPE(cmd), VST_IOC_MAGIC); | ||
| 464 | return -EINVAL; | ||
| 465 | } | ||
| 466 | |||
| 467 | if (vstdev == NULL) | ||
| 468 | return -ENODEV; | ||
| 469 | |||
| 470 | if (copy_from_user(&usb_data, data, sizeof(struct vstusb_args))) { | ||
| 471 | dev_err(&vstdev->usb_dev->dev, "%s: can't copy_from_user\n", | ||
| 472 | __func__); | ||
| 473 | return -EFAULT; | ||
| 474 | } | ||
| 475 | |||
| 476 | /* lock this object */ | ||
| 477 | if (mutex_lock_interruptible(&vstdev->lock)) { | ||
| 478 | retval = -ERESTARTSYS; | ||
| 479 | goto exit; | ||
| 480 | } | ||
| 481 | |||
| 482 | /* anyone home */ | ||
| 483 | if (!vstdev->present) { | ||
| 484 | mutex_unlock(&vstdev->lock); | ||
| 485 | dev_err(&vstdev->usb_dev->dev, "%s: device not present\n", | ||
| 486 | __func__); | ||
| 487 | retval = -ENODEV; | ||
| 488 | goto exit; | ||
| 489 | } | ||
| 490 | |||
| 491 | /* pull out the necessary data */ | ||
| 492 | dev = vstdev->usb_dev; | ||
| 493 | |||
| 494 | switch (cmd) { | ||
| 495 | |||
| 496 | case IOCTL_VSTUSB_CONFIG_RW: | ||
| 497 | |||
| 498 | vstdev->rd_pipe = usb_data.rd_pipe; | ||
| 499 | vstdev->rd_timeout_ms = usb_data.rd_timeout_ms; | ||
| 500 | vstdev->wr_pipe = usb_data.wr_pipe; | ||
| 501 | vstdev->wr_timeout_ms = usb_data.wr_timeout_ms; | ||
| 502 | |||
| 503 | mutex_unlock(&vstdev->lock); | ||
| 504 | |||
| 505 | dev_dbg(&dev->dev, "%s: setting pipes/timeouts, " | ||
| 506 | "rdpipe = %d, rdtimeout = %d, " | ||
| 507 | "wrpipe = %d, wrtimeout = %d\n", __func__, | ||
| 508 | vstdev->rd_pipe, vstdev->rd_timeout_ms, | ||
| 509 | vstdev->wr_pipe, vstdev->wr_timeout_ms); | ||
| 510 | break; | ||
| 511 | |||
| 512 | case IOCTL_VSTUSB_SEND_PIPE: | ||
| 513 | |||
| 514 | if ((usb_data.count == 0) || (usb_data.count > VST_MAXBUFFER)) { | ||
| 515 | mutex_unlock(&vstdev->lock); | ||
| 516 | retval = -EINVAL; | ||
| 517 | goto exit; | ||
| 518 | } | ||
| 519 | |||
| 520 | buffer = kmalloc(usb_data.count, GFP_KERNEL); | ||
| 521 | if (buffer == NULL) { | ||
| 522 | mutex_unlock(&vstdev->lock); | ||
| 523 | retval = -ENOMEM; | ||
| 524 | goto exit; | ||
| 525 | } | ||
| 526 | |||
| 527 | urb = usb_alloc_urb(0, GFP_KERNEL); | ||
| 528 | if (!urb) { | ||
| 529 | mutex_unlock(&vstdev->lock); | ||
| 530 | retval = -ENOMEM; | ||
| 531 | goto exit; | ||
| 532 | } | ||
| 533 | |||
| 534 | timeout = usb_data.timeout_ms; | ||
| 535 | |||
| 536 | pipe = usb_sndbulkpipe(dev, usb_data.pipe); | ||
| 537 | |||
| 538 | if (copy_from_user(buffer, usb_data.buffer, usb_data.count)) { | ||
| 539 | dev_err(&dev->dev, "%s: can't copy_from_user\n", | ||
| 540 | __func__); | ||
| 541 | mutex_unlock(&vstdev->lock); | ||
| 542 | retval = -EFAULT; | ||
| 543 | goto exit; | ||
| 544 | } | ||
| 545 | |||
| 546 | usb_anchor_urb(urb, &vstdev->submitted); | ||
| 547 | retval = vstusb_fill_and_send_urb(urb, dev, pipe, buffer, | ||
| 548 | usb_data.count, &done); | ||
| 549 | mutex_unlock(&vstdev->lock); | ||
| 550 | if (retval) { | ||
| 551 | usb_unanchor_urb(urb); | ||
| 552 | dev_err(&dev->dev, | ||
| 553 | "%s: error %d filling and sending urb %d\n", | ||
| 554 | __func__, retval, pipe); | ||
| 555 | goto exit; | ||
| 556 | } | ||
| 557 | |||
| 558 | retval = vstusb_complete_urb(urb, &done, timeout, &cnt); | ||
| 559 | if (retval) { | ||
| 560 | dev_err(&dev->dev, "%s: error %d completing urb %d\n", | ||
| 561 | __func__, retval, pipe); | ||
| 562 | } | ||
| 563 | |||
| 564 | break; | ||
| 565 | case IOCTL_VSTUSB_RECV_PIPE: | ||
| 566 | |||
| 567 | if ((usb_data.count == 0) || (usb_data.count > VST_MAXBUFFER)) { | ||
| 568 | mutex_unlock(&vstdev->lock); | ||
| 569 | retval = -EINVAL; | ||
| 570 | goto exit; | ||
| 571 | } | ||
| 572 | |||
| 573 | buffer = kmalloc(usb_data.count, GFP_KERNEL); | ||
| 574 | if (buffer == NULL) { | ||
| 575 | mutex_unlock(&vstdev->lock); | ||
| 576 | retval = -ENOMEM; | ||
| 577 | goto exit; | ||
| 578 | } | ||
| 579 | |||
| 580 | urb = usb_alloc_urb(0, GFP_KERNEL); | ||
| 581 | if (!urb) { | ||
| 582 | mutex_unlock(&vstdev->lock); | ||
| 583 | retval = -ENOMEM; | ||
| 584 | goto exit; | ||
| 585 | } | ||
| 586 | |||
| 587 | timeout = usb_data.timeout_ms; | ||
| 588 | |||
| 589 | pipe = usb_rcvbulkpipe(dev, usb_data.pipe); | ||
| 590 | |||
| 591 | usb_anchor_urb(urb, &vstdev->submitted); | ||
| 592 | retval = vstusb_fill_and_send_urb(urb, dev, pipe, buffer, | ||
| 593 | usb_data.count, &done); | ||
| 594 | mutex_unlock(&vstdev->lock); | ||
| 595 | if (retval) { | ||
| 596 | usb_unanchor_urb(urb); | ||
| 597 | dev_err(&dev->dev, | ||
| 598 | "%s: error %d filling and sending urb %d\n", | ||
| 599 | __func__, retval, pipe); | ||
| 600 | goto exit; | ||
| 601 | } | ||
| 602 | |||
| 603 | retval = vstusb_complete_urb(urb, &done, timeout, &cnt); | ||
| 604 | if (retval) { | ||
| 605 | dev_err(&dev->dev, "%s: error %d completing urb %d\n", | ||
| 606 | __func__, retval, pipe); | ||
| 607 | goto exit; | ||
| 608 | } | ||
| 609 | |||
| 610 | if (copy_to_user(usb_data.buffer, buffer, cnt)) { | ||
| 611 | dev_err(&dev->dev, "%s: can't copy_to_user\n", | ||
| 612 | __func__); | ||
| 613 | retval = -EFAULT; | ||
| 614 | goto exit; | ||
| 615 | } | ||
| 616 | |||
| 617 | usb_data.count = cnt; | ||
| 618 | if (copy_to_user(data, &usb_data, sizeof(struct vstusb_args))) { | ||
| 619 | dev_err(&dev->dev, "%s: can't copy_to_user\n", | ||
| 620 | __func__); | ||
| 621 | retval = -EFAULT; | ||
| 622 | } else { | ||
| 623 | dev_dbg(&dev->dev, "%s: recv %d bytes from pipe %d\n", | ||
| 624 | __func__, usb_data.count, usb_data.pipe); | ||
| 625 | } | ||
| 626 | |||
| 627 | break; | ||
| 628 | |||
| 629 | default: | ||
| 630 | mutex_unlock(&vstdev->lock); | ||
| 631 | dev_warn(&dev->dev, "ioctl_vstusb: invalid ioctl cmd %x\n", | ||
| 632 | cmd); | ||
| 633 | return -EINVAL; | ||
| 634 | break; | ||
| 635 | } | ||
| 636 | exit: | ||
| 637 | usb_free_urb(urb); | ||
| 638 | kfree(buffer); | ||
| 639 | return retval; | ||
| 640 | } | ||
| 641 | |||
| 642 | static const struct file_operations vstusb_fops = { | ||
| 643 | .owner = THIS_MODULE, | ||
| 644 | .read = vstusb_read, | ||
| 645 | .write = vstusb_write, | ||
| 646 | .unlocked_ioctl = vstusb_ioctl, | ||
| 647 | .compat_ioctl = vstusb_ioctl, | ||
| 648 | .open = vstusb_open, | ||
| 649 | .release = vstusb_release, | ||
| 650 | }; | ||
| 651 | |||
| 652 | static struct usb_class_driver usb_vstusb_class = { | ||
| 653 | .name = "usb/vstusb%d", | ||
| 654 | .fops = &vstusb_fops, | ||
| 655 | .minor_base = VSTUSB_MINOR_BASE, | ||
| 656 | }; | ||
| 657 | |||
| 658 | static int vstusb_probe(struct usb_interface *intf, | ||
| 659 | const struct usb_device_id *id) | ||
| 660 | { | ||
| 661 | struct usb_device *dev = interface_to_usbdev(intf); | ||
| 662 | struct vstusb_device *vstdev; | ||
| 663 | int i; | ||
| 664 | int retval = 0; | ||
| 665 | |||
| 666 | /* allocate memory for our device state and intialize it */ | ||
| 667 | |||
| 668 | vstdev = kzalloc(sizeof(*vstdev), GFP_KERNEL); | ||
| 669 | if (vstdev == NULL) | ||
| 670 | return -ENOMEM; | ||
| 671 | |||
| 672 | /* must do usb_get_dev() prior to kref_init() since the kref_put() | ||
| 673 | * release function will do a usb_put_dev() */ | ||
| 674 | usb_get_dev(dev); | ||
| 675 | kref_init(&vstdev->kref); | ||
| 676 | mutex_init(&vstdev->lock); | ||
| 677 | |||
| 678 | i = dev->descriptor.bcdDevice; | ||
| 679 | |||
| 680 | dev_dbg(&intf->dev, "Version %1d%1d.%1d%1d found at address %d\n", | ||
| 681 | (i & 0xF000) >> 12, (i & 0xF00) >> 8, | ||
| 682 | (i & 0xF0) >> 4, (i & 0xF), dev->devnum); | ||
| 683 | |||
| 684 | vstdev->present = 1; | ||
| 685 | vstdev->isopen = 0; | ||
| 686 | vstdev->usb_dev = dev; | ||
| 687 | init_usb_anchor(&vstdev->submitted); | ||
| 688 | |||
| 689 | usb_set_intfdata(intf, vstdev); | ||
| 690 | retval = usb_register_dev(intf, &usb_vstusb_class); | ||
| 691 | if (retval) { | ||
| 692 | dev_err(&intf->dev, | ||
| 693 | "%s: Not able to get a minor for this device.\n", | ||
| 694 | __func__); | ||
| 695 | usb_set_intfdata(intf, NULL); | ||
| 696 | kref_put(&vstdev->kref, vstusb_delete); | ||
| 697 | return retval; | ||
| 698 | } | ||
| 699 | |||
| 700 | /* let the user know what node this device is now attached to */ | ||
| 701 | dev_info(&intf->dev, | ||
| 702 | "VST USB Device #%d now attached to major %d minor %d\n", | ||
| 703 | (intf->minor - VSTUSB_MINOR_BASE), USB_MAJOR, intf->minor); | ||
| 704 | |||
| 705 | dev_info(&intf->dev, "%s, %s\n", DRIVER_DESC, DRIVER_VERSION); | ||
| 706 | |||
| 707 | return retval; | ||
| 708 | } | ||
| 709 | |||
| 710 | static void vstusb_disconnect(struct usb_interface *intf) | ||
| 711 | { | ||
| 712 | struct vstusb_device *vstdev = usb_get_intfdata(intf); | ||
| 713 | |||
| 714 | usb_deregister_dev(intf, &usb_vstusb_class); | ||
| 715 | usb_set_intfdata(intf, NULL); | ||
| 716 | |||
| 717 | if (vstdev) { | ||
| 718 | |||
| 719 | mutex_lock(&vstdev->lock); | ||
| 720 | vstdev->present = 0; | ||
| 721 | |||
| 722 | usb_kill_anchored_urbs(&vstdev->submitted); | ||
| 723 | |||
| 724 | mutex_unlock(&vstdev->lock); | ||
| 725 | |||
| 726 | kref_put(&vstdev->kref, vstusb_delete); | ||
| 727 | } | ||
| 728 | |||
| 729 | } | ||
| 730 | |||
| 731 | static int vstusb_suspend(struct usb_interface *intf, pm_message_t message) | ||
| 732 | { | ||
| 733 | struct vstusb_device *vstdev = usb_get_intfdata(intf); | ||
| 734 | int time; | ||
| 735 | if (!vstdev) | ||
| 736 | return 0; | ||
| 737 | |||
| 738 | mutex_lock(&vstdev->lock); | ||
| 739 | time = usb_wait_anchor_empty_timeout(&vstdev->submitted, 1000); | ||
| 740 | if (!time) | ||
| 741 | usb_kill_anchored_urbs(&vstdev->submitted); | ||
| 742 | mutex_unlock(&vstdev->lock); | ||
| 743 | |||
| 744 | return 0; | ||
| 745 | } | ||
| 746 | |||
| 747 | static int vstusb_resume(struct usb_interface *intf) | ||
| 748 | { | ||
| 749 | return 0; | ||
| 750 | } | ||
| 751 | |||
| 752 | static struct usb_driver vstusb_driver = { | ||
| 753 | .name = "vstusb", | ||
| 754 | .probe = vstusb_probe, | ||
| 755 | .disconnect = vstusb_disconnect, | ||
| 756 | .suspend = vstusb_suspend, | ||
| 757 | .resume = vstusb_resume, | ||
| 758 | .id_table = id_table, | ||
| 759 | }; | ||
| 760 | |||
| 761 | static int __init vstusb_init(void) | ||
| 762 | { | ||
| 763 | int rc; | ||
| 764 | |||
| 765 | rc = usb_register(&vstusb_driver); | ||
| 766 | if (rc) | ||
| 767 | printk(KERN_ERR "%s: failed to register (%d)", __func__, rc); | ||
| 768 | |||
| 769 | return rc; | ||
| 770 | } | ||
| 771 | |||
| 772 | static void __exit vstusb_exit(void) | ||
| 773 | { | ||
| 774 | usb_deregister(&vstusb_driver); | ||
| 775 | } | ||
| 776 | |||
| 777 | module_init(vstusb_init); | ||
| 778 | module_exit(vstusb_exit); | ||
| 779 | |||
| 780 | MODULE_AUTHOR("Dennis O'Brien/Stephen Ware"); | ||
| 781 | MODULE_DESCRIPTION(DRIVER_VERSION); | ||
| 782 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/usb/mon/mon_main.c b/drivers/usb/mon/mon_main.c index 442d8076b201..5e0ab4201c00 100644 --- a/drivers/usb/mon/mon_main.c +++ b/drivers/usb/mon/mon_main.c | |||
| @@ -361,12 +361,12 @@ static int __init mon_init(void) | |||
| 361 | } | 361 | } |
| 362 | // MOD_INC_USE_COUNT(which_module?); | 362 | // MOD_INC_USE_COUNT(which_module?); |
| 363 | 363 | ||
| 364 | usb_register_notify(&mon_nb); | ||
| 365 | 364 | ||
| 366 | mutex_lock(&usb_bus_list_lock); | 365 | mutex_lock(&usb_bus_list_lock); |
| 367 | list_for_each_entry (ubus, &usb_bus_list, bus_list) { | 366 | list_for_each_entry (ubus, &usb_bus_list, bus_list) { |
| 368 | mon_bus_init(ubus); | 367 | mon_bus_init(ubus); |
| 369 | } | 368 | } |
| 369 | usb_register_notify(&mon_nb); | ||
| 370 | mutex_unlock(&usb_bus_list_lock); | 370 | mutex_unlock(&usb_bus_list_lock); |
| 371 | return 0; | 371 | return 0; |
| 372 | 372 | ||
diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig index 58b2b8fc9439..4b9542bbb35c 100644 --- a/drivers/usb/musb/Kconfig +++ b/drivers/usb/musb/Kconfig | |||
| @@ -33,10 +33,6 @@ config USB_MUSB_SOC | |||
| 33 | default y if ARCH_DAVINCI | 33 | default y if ARCH_DAVINCI |
| 34 | default y if ARCH_OMAP2430 | 34 | default y if ARCH_OMAP2430 |
| 35 | default y if ARCH_OMAP34XX | 35 | default y if ARCH_OMAP34XX |
| 36 | help | ||
| 37 | Use a static <asm/arch/hdrc_cnf.h> file to describe how the | ||
| 38 | controller is configured (endpoints, mechanisms, etc) on the | ||
| 39 | current iteration of a given system-on-chip. | ||
| 40 | 36 | ||
| 41 | comment "DaVinci 644x USB support" | 37 | comment "DaVinci 644x USB support" |
| 42 | depends on USB_MUSB_HDRC && ARCH_DAVINCI | 38 | depends on USB_MUSB_HDRC && ARCH_DAVINCI |
diff --git a/drivers/usb/musb/cppi_dma.h b/drivers/usb/musb/cppi_dma.h index fc5216b5d2c5..729b4071787b 100644 --- a/drivers/usb/musb/cppi_dma.h +++ b/drivers/usb/musb/cppi_dma.h | |||
| @@ -119,8 +119,8 @@ struct cppi { | |||
| 119 | void __iomem *mregs; /* Mentor regs */ | 119 | void __iomem *mregs; /* Mentor regs */ |
| 120 | void __iomem *tibase; /* TI/CPPI regs */ | 120 | void __iomem *tibase; /* TI/CPPI regs */ |
| 121 | 121 | ||
| 122 | struct cppi_channel tx[MUSB_C_NUM_EPT - 1]; | 122 | struct cppi_channel tx[4]; |
| 123 | struct cppi_channel rx[MUSB_C_NUM_EPR - 1]; | 123 | struct cppi_channel rx[4]; |
| 124 | 124 | ||
| 125 | struct dma_pool *pool; | 125 | struct dma_pool *pool; |
| 126 | 126 | ||
diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c index 75baf181a8cd..dfb3bcbe00fc 100644 --- a/drivers/usb/musb/davinci.c +++ b/drivers/usb/musb/davinci.c | |||
| @@ -30,6 +30,7 @@ | |||
| 30 | #include <linux/delay.h> | 30 | #include <linux/delay.h> |
| 31 | #include <linux/clk.h> | 31 | #include <linux/clk.h> |
| 32 | #include <linux/io.h> | 32 | #include <linux/io.h> |
| 33 | #include <linux/gpio.h> | ||
| 33 | 34 | ||
| 34 | #include <asm/arch/hardware.h> | 35 | #include <asm/arch/hardware.h> |
| 35 | #include <asm/arch/memory.h> | 36 | #include <asm/arch/memory.h> |
| @@ -39,7 +40,7 @@ | |||
| 39 | #include "musb_core.h" | 40 | #include "musb_core.h" |
| 40 | 41 | ||
| 41 | #ifdef CONFIG_MACH_DAVINCI_EVM | 42 | #ifdef CONFIG_MACH_DAVINCI_EVM |
| 42 | #include <asm/arch/i2c-client.h> | 43 | #define GPIO_nVBUS_DRV 87 |
| 43 | #endif | 44 | #endif |
| 44 | 45 | ||
| 45 | #include "davinci.h" | 46 | #include "davinci.h" |
| @@ -138,7 +139,6 @@ static int vbus_state = -1; | |||
| 138 | /* VBUS SWITCHING IS BOARD-SPECIFIC */ | 139 | /* VBUS SWITCHING IS BOARD-SPECIFIC */ |
| 139 | 140 | ||
| 140 | #ifdef CONFIG_MACH_DAVINCI_EVM | 141 | #ifdef CONFIG_MACH_DAVINCI_EVM |
| 141 | #ifndef CONFIG_MACH_DAVINCI_EVM_OTG | ||
| 142 | 142 | ||
| 143 | /* I2C operations are always synchronous, and require a task context. | 143 | /* I2C operations are always synchronous, and require a task context. |
| 144 | * With unloaded systems, using the shared workqueue seems to suffice | 144 | * With unloaded systems, using the shared workqueue seems to suffice |
| @@ -146,12 +146,11 @@ static int vbus_state = -1; | |||
| 146 | */ | 146 | */ |
| 147 | static void evm_deferred_drvvbus(struct work_struct *ignored) | 147 | static void evm_deferred_drvvbus(struct work_struct *ignored) |
| 148 | { | 148 | { |
| 149 | davinci_i2c_expander_op(0x3a, USB_DRVVBUS, vbus_state); | 149 | gpio_set_value_cansleep(GPIO_nVBUS_DRV, vbus_state); |
| 150 | vbus_state = !vbus_state; | 150 | vbus_state = !vbus_state; |
| 151 | } | 151 | } |
| 152 | static DECLARE_WORK(evm_vbus_work, evm_deferred_drvvbus); | 152 | static DECLARE_WORK(evm_vbus_work, evm_deferred_drvvbus); |
| 153 | 153 | ||
| 154 | #endif /* modified board */ | ||
| 155 | #endif /* EVM */ | 154 | #endif /* EVM */ |
| 156 | 155 | ||
| 157 | static void davinci_source_power(struct musb *musb, int is_on, int immediate) | 156 | static void davinci_source_power(struct musb *musb, int is_on, int immediate) |
| @@ -165,21 +164,10 @@ static void davinci_source_power(struct musb *musb, int is_on, int immediate) | |||
| 165 | 164 | ||
| 166 | #ifdef CONFIG_MACH_DAVINCI_EVM | 165 | #ifdef CONFIG_MACH_DAVINCI_EVM |
| 167 | if (machine_is_davinci_evm()) { | 166 | if (machine_is_davinci_evm()) { |
| 168 | #ifdef CONFIG_MACH_DAVINCI_EVM_OTG | ||
| 169 | /* modified EVM board switching VBUS with GPIO(6) not I2C | ||
| 170 | * NOTE: PINMUX0.RGB888 (bit23) must be clear | ||
| 171 | */ | ||
| 172 | if (is_on) | ||
| 173 | gpio_set(GPIO(6)); | ||
| 174 | else | ||
| 175 | gpio_clear(GPIO(6)); | ||
| 176 | immediate = 1; | ||
| 177 | #else | ||
| 178 | if (immediate) | 167 | if (immediate) |
| 179 | davinci_i2c_expander_op(0x3a, USB_DRVVBUS, !is_on); | 168 | gpio_set_value_cansleep(GPIO_nVBUS_DRV, vbus_state); |
| 180 | else | 169 | else |
| 181 | schedule_work(&evm_vbus_work); | 170 | schedule_work(&evm_vbus_work); |
| 182 | #endif | ||
| 183 | } | 171 | } |
| 184 | #endif | 172 | #endif |
| 185 | if (immediate) | 173 | if (immediate) |
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index 128e949db47c..4a35745b30be 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c | |||
| @@ -82,9 +82,9 @@ | |||
| 82 | /* | 82 | /* |
| 83 | * This gets many kinds of configuration information: | 83 | * This gets many kinds of configuration information: |
| 84 | * - Kconfig for everything user-configurable | 84 | * - Kconfig for everything user-configurable |
| 85 | * - <asm/arch/hdrc_cnf.h> for SOC or family details | ||
| 86 | * - platform_device for addressing, irq, and platform_data | 85 | * - platform_device for addressing, irq, and platform_data |
| 87 | * - platform_data is mostly for board-specific informarion | 86 | * - platform_data is mostly for board-specific informarion |
| 87 | * (plus recentrly, SOC or family details) | ||
| 88 | * | 88 | * |
| 89 | * Most of the conditional compilation will (someday) vanish. | 89 | * Most of the conditional compilation will (someday) vanish. |
| 90 | */ | 90 | */ |
| @@ -974,9 +974,9 @@ static void musb_shutdown(struct platform_device *pdev) | |||
| 974 | /* | 974 | /* |
| 975 | * The silicon either has hard-wired endpoint configurations, or else | 975 | * The silicon either has hard-wired endpoint configurations, or else |
| 976 | * "dynamic fifo" sizing. The driver has support for both, though at this | 976 | * "dynamic fifo" sizing. The driver has support for both, though at this |
| 977 | * writing only the dynamic sizing is very well tested. We use normal | 977 | * writing only the dynamic sizing is very well tested. Since we switched |
| 978 | * idioms to so both modes are compile-tested, but dead code elimination | 978 | * away from compile-time hardware parameters, we can no longer rely on |
| 979 | * leaves only the relevant one in the object file. | 979 | * dead code elimination to leave only the relevant one in the object file. |
| 980 | * | 980 | * |
| 981 | * We don't currently use dynamic fifo setup capability to do anything | 981 | * We don't currently use dynamic fifo setup capability to do anything |
| 982 | * more than selecting one of a bunch of predefined configurations. | 982 | * more than selecting one of a bunch of predefined configurations. |
| @@ -1806,6 +1806,7 @@ allocate_instance(struct device *dev, | |||
| 1806 | musb->ctrl_base = mbase; | 1806 | musb->ctrl_base = mbase; |
| 1807 | musb->nIrq = -ENODEV; | 1807 | musb->nIrq = -ENODEV; |
| 1808 | musb->config = config; | 1808 | musb->config = config; |
| 1809 | BUG_ON(musb->config->num_eps > MUSB_C_NUM_EPS); | ||
| 1809 | for (epnum = 0, ep = musb->endpoints; | 1810 | for (epnum = 0, ep = musb->endpoints; |
| 1810 | epnum < musb->config->num_eps; | 1811 | epnum < musb->config->num_eps; |
| 1811 | epnum++, ep++) { | 1812 | epnum++, ep++) { |
| @@ -2054,15 +2055,6 @@ bad_config: | |||
| 2054 | 2055 | ||
| 2055 | } | 2056 | } |
| 2056 | 2057 | ||
| 2057 | return 0; | ||
| 2058 | |||
| 2059 | fail: | ||
| 2060 | if (musb->clock) | ||
| 2061 | clk_put(musb->clock); | ||
| 2062 | device_init_wakeup(dev, 0); | ||
| 2063 | musb_free(musb); | ||
| 2064 | return status; | ||
| 2065 | |||
| 2066 | #ifdef CONFIG_SYSFS | 2058 | #ifdef CONFIG_SYSFS |
| 2067 | status = device_create_file(dev, &dev_attr_mode); | 2059 | status = device_create_file(dev, &dev_attr_mode); |
| 2068 | status = device_create_file(dev, &dev_attr_vbus); | 2060 | status = device_create_file(dev, &dev_attr_vbus); |
| @@ -2071,12 +2063,31 @@ fail: | |||
| 2071 | #endif /* CONFIG_USB_GADGET_MUSB_HDRC */ | 2063 | #endif /* CONFIG_USB_GADGET_MUSB_HDRC */ |
| 2072 | status = 0; | 2064 | status = 0; |
| 2073 | #endif | 2065 | #endif |
| 2066 | if (status) | ||
| 2067 | goto fail2; | ||
| 2074 | 2068 | ||
| 2075 | return status; | 2069 | return 0; |
| 2076 | 2070 | ||
| 2077 | fail2: | 2071 | fail2: |
| 2072 | #ifdef CONFIG_SYSFS | ||
| 2073 | device_remove_file(musb->controller, &dev_attr_mode); | ||
| 2074 | device_remove_file(musb->controller, &dev_attr_vbus); | ||
| 2075 | #ifdef CONFIG_USB_MUSB_OTG | ||
| 2076 | device_remove_file(musb->controller, &dev_attr_srp); | ||
| 2077 | #endif | ||
| 2078 | #endif | ||
| 2078 | musb_platform_exit(musb); | 2079 | musb_platform_exit(musb); |
| 2079 | goto fail; | 2080 | fail: |
| 2081 | dev_err(musb->controller, | ||
| 2082 | "musb_init_controller failed with status %d\n", status); | ||
| 2083 | |||
| 2084 | if (musb->clock) | ||
| 2085 | clk_put(musb->clock); | ||
| 2086 | device_init_wakeup(dev, 0); | ||
| 2087 | musb_free(musb); | ||
| 2088 | |||
| 2089 | return status; | ||
| 2090 | |||
| 2080 | } | 2091 | } |
| 2081 | 2092 | ||
| 2082 | /*-------------------------------------------------------------------------*/ | 2093 | /*-------------------------------------------------------------------------*/ |
diff --git a/drivers/usb/musb/musb_gadget_ep0.c b/drivers/usb/musb/musb_gadget_ep0.c index a57652fff39c..3f5e30ddfa27 100644 --- a/drivers/usb/musb/musb_gadget_ep0.c +++ b/drivers/usb/musb/musb_gadget_ep0.c | |||
| @@ -437,7 +437,7 @@ static void ep0_rxstate(struct musb *musb) | |||
| 437 | { | 437 | { |
| 438 | void __iomem *regs = musb->control_ep->regs; | 438 | void __iomem *regs = musb->control_ep->regs; |
| 439 | struct usb_request *req; | 439 | struct usb_request *req; |
| 440 | u16 tmp; | 440 | u16 count, csr; |
| 441 | 441 | ||
| 442 | req = next_ep0_request(musb); | 442 | req = next_ep0_request(musb); |
| 443 | 443 | ||
| @@ -449,35 +449,35 @@ static void ep0_rxstate(struct musb *musb) | |||
| 449 | unsigned len = req->length - req->actual; | 449 | unsigned len = req->length - req->actual; |
| 450 | 450 | ||
| 451 | /* read the buffer */ | 451 | /* read the buffer */ |
| 452 | tmp = musb_readb(regs, MUSB_COUNT0); | 452 | count = musb_readb(regs, MUSB_COUNT0); |
| 453 | if (tmp > len) { | 453 | if (count > len) { |
| 454 | req->status = -EOVERFLOW; | 454 | req->status = -EOVERFLOW; |
| 455 | tmp = len; | 455 | count = len; |
| 456 | } | 456 | } |
| 457 | musb_read_fifo(&musb->endpoints[0], tmp, buf); | 457 | musb_read_fifo(&musb->endpoints[0], count, buf); |
| 458 | req->actual += tmp; | 458 | req->actual += count; |
| 459 | tmp = MUSB_CSR0_P_SVDRXPKTRDY; | 459 | csr = MUSB_CSR0_P_SVDRXPKTRDY; |
| 460 | if (tmp < 64 || req->actual == req->length) { | 460 | if (count < 64 || req->actual == req->length) { |
| 461 | musb->ep0_state = MUSB_EP0_STAGE_STATUSIN; | 461 | musb->ep0_state = MUSB_EP0_STAGE_STATUSIN; |
| 462 | tmp |= MUSB_CSR0_P_DATAEND; | 462 | csr |= MUSB_CSR0_P_DATAEND; |
| 463 | } else | 463 | } else |
| 464 | req = NULL; | 464 | req = NULL; |
| 465 | } else | 465 | } else |
| 466 | tmp = MUSB_CSR0_P_SVDRXPKTRDY | MUSB_CSR0_P_SENDSTALL; | 466 | csr = MUSB_CSR0_P_SVDRXPKTRDY | MUSB_CSR0_P_SENDSTALL; |
| 467 | 467 | ||
| 468 | 468 | ||
| 469 | /* Completion handler may choose to stall, e.g. because the | 469 | /* Completion handler may choose to stall, e.g. because the |
| 470 | * message just received holds invalid data. | 470 | * message just received holds invalid data. |
| 471 | */ | 471 | */ |
| 472 | if (req) { | 472 | if (req) { |
| 473 | musb->ackpend = tmp; | 473 | musb->ackpend = csr; |
| 474 | musb_g_ep0_giveback(musb, req); | 474 | musb_g_ep0_giveback(musb, req); |
| 475 | if (!musb->ackpend) | 475 | if (!musb->ackpend) |
| 476 | return; | 476 | return; |
| 477 | musb->ackpend = 0; | 477 | musb->ackpend = 0; |
| 478 | } | 478 | } |
| 479 | musb_ep_select(musb->mregs, 0); | 479 | musb_ep_select(musb->mregs, 0); |
| 480 | musb_writew(regs, MUSB_CSR0, tmp); | 480 | musb_writew(regs, MUSB_CSR0, csr); |
| 481 | } | 481 | } |
| 482 | 482 | ||
| 483 | /* | 483 | /* |
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c index 8b4be012669a..3133990f04ec 100644 --- a/drivers/usb/musb/musb_host.c +++ b/drivers/usb/musb/musb_host.c | |||
| @@ -108,7 +108,7 @@ static void musb_ep_program(struct musb *musb, u8 epnum, | |||
| 108 | /* | 108 | /* |
| 109 | * Clear TX fifo. Needed to avoid BABBLE errors. | 109 | * Clear TX fifo. Needed to avoid BABBLE errors. |
| 110 | */ | 110 | */ |
| 111 | static inline void musb_h_tx_flush_fifo(struct musb_hw_ep *ep) | 111 | static void musb_h_tx_flush_fifo(struct musb_hw_ep *ep) |
| 112 | { | 112 | { |
| 113 | void __iomem *epio = ep->regs; | 113 | void __iomem *epio = ep->regs; |
| 114 | u16 csr; | 114 | u16 csr; |
| @@ -291,6 +291,7 @@ __acquires(musb->lock) | |||
| 291 | urb->actual_length, urb->transfer_buffer_length | 291 | urb->actual_length, urb->transfer_buffer_length |
| 292 | ); | 292 | ); |
| 293 | 293 | ||
| 294 | usb_hcd_unlink_urb_from_ep(musb_to_hcd(musb), urb); | ||
| 294 | spin_unlock(&musb->lock); | 295 | spin_unlock(&musb->lock); |
| 295 | usb_hcd_giveback_urb(musb_to_hcd(musb), urb, status); | 296 | usb_hcd_giveback_urb(musb_to_hcd(musb), urb, status); |
| 296 | spin_lock(&musb->lock); | 297 | spin_lock(&musb->lock); |
| @@ -353,8 +354,6 @@ musb_giveback(struct musb_qh *qh, struct urb *urb, int status) | |||
| 353 | break; | 354 | break; |
| 354 | } | 355 | } |
| 355 | 356 | ||
| 356 | usb_hcd_unlink_urb_from_ep(musb_to_hcd(musb), urb); | ||
| 357 | |||
| 358 | qh->is_ready = 0; | 357 | qh->is_ready = 0; |
| 359 | __musb_giveback(musb, urb, status); | 358 | __musb_giveback(musb, urb, status); |
| 360 | qh->is_ready = ready; | 359 | qh->is_ready = ready; |
| @@ -436,7 +435,7 @@ musb_advance_schedule(struct musb *musb, struct urb *urb, | |||
| 436 | } | 435 | } |
| 437 | } | 436 | } |
| 438 | 437 | ||
| 439 | static inline u16 musb_h_flush_rxfifo(struct musb_hw_ep *hw_ep, u16 csr) | 438 | static u16 musb_h_flush_rxfifo(struct musb_hw_ep *hw_ep, u16 csr) |
| 440 | { | 439 | { |
| 441 | /* we don't want fifo to fill itself again; | 440 | /* we don't want fifo to fill itself again; |
| 442 | * ignore dma (various models), | 441 | * ignore dma (various models), |
| @@ -1005,7 +1004,7 @@ static bool musb_h_ep0_continue(struct musb *musb, u16 len, struct urb *urb) | |||
| 1005 | 1004 | ||
| 1006 | /* | 1005 | /* |
| 1007 | * Handle default endpoint interrupt as host. Only called in IRQ time | 1006 | * Handle default endpoint interrupt as host. Only called in IRQ time |
| 1008 | * from the LinuxIsr() interrupt service routine. | 1007 | * from musb_interrupt(). |
| 1009 | * | 1008 | * |
| 1010 | * called with controller irqlocked | 1009 | * called with controller irqlocked |
| 1011 | */ | 1010 | */ |
| @@ -1791,7 +1790,9 @@ static int musb_urb_enqueue( | |||
| 1791 | */ | 1790 | */ |
| 1792 | qh = kzalloc(sizeof *qh, mem_flags); | 1791 | qh = kzalloc(sizeof *qh, mem_flags); |
| 1793 | if (!qh) { | 1792 | if (!qh) { |
| 1793 | spin_lock_irqsave(&musb->lock, flags); | ||
| 1794 | usb_hcd_unlink_urb_from_ep(hcd, urb); | 1794 | usb_hcd_unlink_urb_from_ep(hcd, urb); |
| 1795 | spin_unlock_irqrestore(&musb->lock, flags); | ||
| 1795 | return -ENOMEM; | 1796 | return -ENOMEM; |
| 1796 | } | 1797 | } |
| 1797 | 1798 | ||
| @@ -1873,7 +1874,11 @@ static int musb_urb_enqueue( | |||
| 1873 | /* set up tt info if needed */ | 1874 | /* set up tt info if needed */ |
| 1874 | if (urb->dev->tt) { | 1875 | if (urb->dev->tt) { |
| 1875 | qh->h_port_reg = (u8) urb->dev->ttport; | 1876 | qh->h_port_reg = (u8) urb->dev->ttport; |
| 1876 | qh->h_addr_reg |= 0x80; | 1877 | if (urb->dev->tt->hub) |
| 1878 | qh->h_addr_reg = | ||
| 1879 | (u8) urb->dev->tt->hub->devnum; | ||
| 1880 | if (urb->dev->tt->multi) | ||
| 1881 | qh->h_addr_reg |= 0x80; | ||
| 1877 | } | 1882 | } |
| 1878 | } | 1883 | } |
| 1879 | } | 1884 | } |
| @@ -1903,7 +1908,9 @@ static int musb_urb_enqueue( | |||
| 1903 | 1908 | ||
| 1904 | done: | 1909 | done: |
| 1905 | if (ret != 0) { | 1910 | if (ret != 0) { |
| 1911 | spin_lock_irqsave(&musb->lock, flags); | ||
| 1906 | usb_hcd_unlink_urb_from_ep(hcd, urb); | 1912 | usb_hcd_unlink_urb_from_ep(hcd, urb); |
| 1913 | spin_unlock_irqrestore(&musb->lock, flags); | ||
| 1907 | kfree(qh); | 1914 | kfree(qh); |
| 1908 | } | 1915 | } |
| 1909 | return ret; | 1916 | return ret; |
diff --git a/drivers/usb/musb/musb_io.h b/drivers/usb/musb/musb_io.h index 6bbedae83af8..223f0a514094 100644 --- a/drivers/usb/musb/musb_io.h +++ b/drivers/usb/musb/musb_io.h | |||
| @@ -37,7 +37,9 @@ | |||
| 37 | 37 | ||
| 38 | #include <linux/io.h> | 38 | #include <linux/io.h> |
| 39 | 39 | ||
| 40 | #ifndef CONFIG_ARM | 40 | #if !defined(CONFIG_ARM) && !defined(CONFIG_SUPERH) \ |
| 41 | && !defined(CONFIG_AVR32) && !defined(CONFIG_PPC32) \ | ||
| 42 | && !defined(CONFIG_PPC64) | ||
| 41 | static inline void readsl(const void __iomem *addr, void *buf, int len) | 43 | static inline void readsl(const void __iomem *addr, void *buf, int len) |
| 42 | { insl((unsigned long)addr, buf, len); } | 44 | { insl((unsigned long)addr, buf, len); } |
| 43 | static inline void readsw(const void __iomem *addr, void *buf, int len) | 45 | static inline void readsw(const void __iomem *addr, void *buf, int len) |
diff --git a/drivers/usb/musb/musbhsdma.c b/drivers/usb/musb/musbhsdma.c index 9ba8fb7fcd24..8c734ef2c1ed 100644 --- a/drivers/usb/musb/musbhsdma.c +++ b/drivers/usb/musb/musbhsdma.c | |||
| @@ -45,8 +45,8 @@ | |||
| 45 | #define MUSB_HSDMA_ADDRESS 0x8 | 45 | #define MUSB_HSDMA_ADDRESS 0x8 |
| 46 | #define MUSB_HSDMA_COUNT 0xc | 46 | #define MUSB_HSDMA_COUNT 0xc |
| 47 | 47 | ||
| 48 | #define MUSB_HSDMA_CHANNEL_OFFSET(_bChannel, _offset) \ | 48 | #define MUSB_HSDMA_CHANNEL_OFFSET(_bchannel, _offset) \ |
| 49 | (MUSB_HSDMA_BASE + (_bChannel << 4) + _offset) | 49 | (MUSB_HSDMA_BASE + (_bchannel << 4) + _offset) |
| 50 | 50 | ||
| 51 | /* control register (16-bit): */ | 51 | /* control register (16-bit): */ |
| 52 | #define MUSB_HSDMA_ENABLE_SHIFT 0 | 52 | #define MUSB_HSDMA_ENABLE_SHIFT 0 |
| @@ -67,23 +67,23 @@ | |||
| 67 | struct musb_dma_controller; | 67 | struct musb_dma_controller; |
| 68 | 68 | ||
| 69 | struct musb_dma_channel { | 69 | struct musb_dma_channel { |
| 70 | struct dma_channel Channel; | 70 | struct dma_channel channel; |
| 71 | struct musb_dma_controller *controller; | 71 | struct musb_dma_controller *controller; |
| 72 | u32 dwStartAddress; | 72 | u32 start_addr; |
| 73 | u32 len; | 73 | u32 len; |
| 74 | u16 wMaxPacketSize; | 74 | u16 max_packet_sz; |
| 75 | u8 bIndex; | 75 | u8 idx; |
| 76 | u8 epnum; | 76 | u8 epnum; |
| 77 | u8 transmit; | 77 | u8 transmit; |
| 78 | }; | 78 | }; |
| 79 | 79 | ||
| 80 | struct musb_dma_controller { | 80 | struct musb_dma_controller { |
| 81 | struct dma_controller Controller; | 81 | struct dma_controller controller; |
| 82 | struct musb_dma_channel aChannel[MUSB_HSDMA_CHANNELS]; | 82 | struct musb_dma_channel channel[MUSB_HSDMA_CHANNELS]; |
| 83 | void *pDmaPrivate; | 83 | void *private_data; |
| 84 | void __iomem *pCoreBase; | 84 | void __iomem *base; |
| 85 | u8 bChannelCount; | 85 | u8 channel_count; |
| 86 | u8 bmUsedChannels; | 86 | u8 used_channels; |
| 87 | u8 irq; | 87 | u8 irq; |
| 88 | }; | 88 | }; |
| 89 | 89 | ||
| @@ -93,91 +93,91 @@ static int dma_controller_start(struct dma_controller *c) | |||
| 93 | return 0; | 93 | return 0; |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | static void dma_channel_release(struct dma_channel *pChannel); | 96 | static void dma_channel_release(struct dma_channel *channel); |
| 97 | 97 | ||
| 98 | static int dma_controller_stop(struct dma_controller *c) | 98 | static int dma_controller_stop(struct dma_controller *c) |
| 99 | { | 99 | { |
| 100 | struct musb_dma_controller *controller = | 100 | struct musb_dma_controller *controller = container_of(c, |
| 101 | container_of(c, struct musb_dma_controller, Controller); | 101 | struct musb_dma_controller, controller); |
| 102 | struct musb *musb = (struct musb *) controller->pDmaPrivate; | 102 | struct musb *musb = controller->private_data; |
| 103 | struct dma_channel *pChannel; | 103 | struct dma_channel *channel; |
| 104 | u8 bBit; | 104 | u8 bit; |
| 105 | 105 | ||
| 106 | if (controller->bmUsedChannels != 0) { | 106 | if (controller->used_channels != 0) { |
| 107 | dev_err(musb->controller, | 107 | dev_err(musb->controller, |
| 108 | "Stopping DMA controller while channel active\n"); | 108 | "Stopping DMA controller while channel active\n"); |
| 109 | 109 | ||
| 110 | for (bBit = 0; bBit < MUSB_HSDMA_CHANNELS; bBit++) { | 110 | for (bit = 0; bit < MUSB_HSDMA_CHANNELS; bit++) { |
| 111 | if (controller->bmUsedChannels & (1 << bBit)) { | 111 | if (controller->used_channels & (1 << bit)) { |
| 112 | pChannel = &controller->aChannel[bBit].Channel; | 112 | channel = &controller->channel[bit].channel; |
| 113 | dma_channel_release(pChannel); | 113 | dma_channel_release(channel); |
| 114 | 114 | ||
| 115 | if (!controller->bmUsedChannels) | 115 | if (!controller->used_channels) |
| 116 | break; | 116 | break; |
| 117 | } | 117 | } |
| 118 | } | 118 | } |
| 119 | } | 119 | } |
| 120 | |||
| 120 | return 0; | 121 | return 0; |
| 121 | } | 122 | } |
| 122 | 123 | ||
| 123 | static struct dma_channel *dma_channel_allocate(struct dma_controller *c, | 124 | static struct dma_channel *dma_channel_allocate(struct dma_controller *c, |
| 124 | struct musb_hw_ep *hw_ep, u8 transmit) | 125 | struct musb_hw_ep *hw_ep, u8 transmit) |
| 125 | { | 126 | { |
| 126 | u8 bBit; | 127 | struct musb_dma_controller *controller = container_of(c, |
| 127 | struct dma_channel *pChannel = NULL; | 128 | struct musb_dma_controller, controller); |
| 128 | struct musb_dma_channel *pImplChannel = NULL; | 129 | struct musb_dma_channel *musb_channel = NULL; |
| 129 | struct musb_dma_controller *controller = | 130 | struct dma_channel *channel = NULL; |
| 130 | container_of(c, struct musb_dma_controller, Controller); | 131 | u8 bit; |
| 131 | 132 | ||
| 132 | for (bBit = 0; bBit < MUSB_HSDMA_CHANNELS; bBit++) { | 133 | for (bit = 0; bit < MUSB_HSDMA_CHANNELS; bit++) { |
| 133 | if (!(controller->bmUsedChannels & (1 << bBit))) { | 134 | if (!(controller->used_channels & (1 << bit))) { |
| 134 | controller->bmUsedChannels |= (1 << bBit); | 135 | controller->used_channels |= (1 << bit); |
| 135 | pImplChannel = &(controller->aChannel[bBit]); | 136 | musb_channel = &(controller->channel[bit]); |
| 136 | pImplChannel->controller = controller; | 137 | musb_channel->controller = controller; |
| 137 | pImplChannel->bIndex = bBit; | 138 | musb_channel->idx = bit; |
| 138 | pImplChannel->epnum = hw_ep->epnum; | 139 | musb_channel->epnum = hw_ep->epnum; |
| 139 | pImplChannel->transmit = transmit; | 140 | musb_channel->transmit = transmit; |
| 140 | pChannel = &(pImplChannel->Channel); | 141 | channel = &(musb_channel->channel); |
| 141 | pChannel->private_data = pImplChannel; | 142 | channel->private_data = musb_channel; |
| 142 | pChannel->status = MUSB_DMA_STATUS_FREE; | 143 | channel->status = MUSB_DMA_STATUS_FREE; |
| 143 | pChannel->max_len = 0x10000; | 144 | channel->max_len = 0x10000; |
| 144 | /* Tx => mode 1; Rx => mode 0 */ | 145 | /* Tx => mode 1; Rx => mode 0 */ |
| 145 | pChannel->desired_mode = transmit; | 146 | channel->desired_mode = transmit; |
| 146 | pChannel->actual_len = 0; | 147 | channel->actual_len = 0; |
| 147 | break; | 148 | break; |
| 148 | } | 149 | } |
| 149 | } | 150 | } |
| 150 | return pChannel; | 151 | |
| 152 | return channel; | ||
| 151 | } | 153 | } |
| 152 | 154 | ||
| 153 | static void dma_channel_release(struct dma_channel *pChannel) | 155 | static void dma_channel_release(struct dma_channel *channel) |
| 154 | { | 156 | { |
| 155 | struct musb_dma_channel *pImplChannel = | 157 | struct musb_dma_channel *musb_channel = channel->private_data; |
| 156 | (struct musb_dma_channel *) pChannel->private_data; | ||
| 157 | 158 | ||
| 158 | pChannel->actual_len = 0; | 159 | channel->actual_len = 0; |
| 159 | pImplChannel->dwStartAddress = 0; | 160 | musb_channel->start_addr = 0; |
| 160 | pImplChannel->len = 0; | 161 | musb_channel->len = 0; |
| 161 | 162 | ||
| 162 | pImplChannel->controller->bmUsedChannels &= | 163 | musb_channel->controller->used_channels &= |
| 163 | ~(1 << pImplChannel->bIndex); | 164 | ~(1 << musb_channel->idx); |
| 164 | 165 | ||
| 165 | pChannel->status = MUSB_DMA_STATUS_UNKNOWN; | 166 | channel->status = MUSB_DMA_STATUS_UNKNOWN; |
| 166 | } | 167 | } |
| 167 | 168 | ||
| 168 | static void configure_channel(struct dma_channel *pChannel, | 169 | static void configure_channel(struct dma_channel *channel, |
| 169 | u16 packet_sz, u8 mode, | 170 | u16 packet_sz, u8 mode, |
| 170 | dma_addr_t dma_addr, u32 len) | 171 | dma_addr_t dma_addr, u32 len) |
| 171 | { | 172 | { |
| 172 | struct musb_dma_channel *pImplChannel = | 173 | struct musb_dma_channel *musb_channel = channel->private_data; |
| 173 | (struct musb_dma_channel *) pChannel->private_data; | 174 | struct musb_dma_controller *controller = musb_channel->controller; |
| 174 | struct musb_dma_controller *controller = pImplChannel->controller; | 175 | void __iomem *mbase = controller->base; |
| 175 | void __iomem *mbase = controller->pCoreBase; | 176 | u8 bchannel = musb_channel->idx; |
| 176 | u8 bChannel = pImplChannel->bIndex; | ||
| 177 | u16 csr = 0; | 177 | u16 csr = 0; |
| 178 | 178 | ||
| 179 | DBG(4, "%p, pkt_sz %d, addr 0x%x, len %d, mode %d\n", | 179 | DBG(4, "%p, pkt_sz %d, addr 0x%x, len %d, mode %d\n", |
| 180 | pChannel, packet_sz, dma_addr, len, mode); | 180 | channel, packet_sz, dma_addr, len, mode); |
| 181 | 181 | ||
| 182 | if (mode) { | 182 | if (mode) { |
| 183 | csr |= 1 << MUSB_HSDMA_MODE1_SHIFT; | 183 | csr |= 1 << MUSB_HSDMA_MODE1_SHIFT; |
| @@ -195,180 +195,183 @@ static void configure_channel(struct dma_channel *pChannel, | |||
| 195 | } | 195 | } |
| 196 | } | 196 | } |
| 197 | 197 | ||
| 198 | csr |= (pImplChannel->epnum << MUSB_HSDMA_ENDPOINT_SHIFT) | 198 | csr |= (musb_channel->epnum << MUSB_HSDMA_ENDPOINT_SHIFT) |
| 199 | | (1 << MUSB_HSDMA_ENABLE_SHIFT) | 199 | | (1 << MUSB_HSDMA_ENABLE_SHIFT) |
| 200 | | (1 << MUSB_HSDMA_IRQENABLE_SHIFT) | 200 | | (1 << MUSB_HSDMA_IRQENABLE_SHIFT) |
| 201 | | (pImplChannel->transmit | 201 | | (musb_channel->transmit |
| 202 | ? (1 << MUSB_HSDMA_TRANSMIT_SHIFT) | 202 | ? (1 << MUSB_HSDMA_TRANSMIT_SHIFT) |
| 203 | : 0); | 203 | : 0); |
| 204 | 204 | ||
| 205 | /* address/count */ | 205 | /* address/count */ |
| 206 | musb_writel(mbase, | 206 | musb_writel(mbase, |
| 207 | MUSB_HSDMA_CHANNEL_OFFSET(bChannel, MUSB_HSDMA_ADDRESS), | 207 | MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_ADDRESS), |
| 208 | dma_addr); | 208 | dma_addr); |
| 209 | musb_writel(mbase, | 209 | musb_writel(mbase, |
| 210 | MUSB_HSDMA_CHANNEL_OFFSET(bChannel, MUSB_HSDMA_COUNT), | 210 | MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_COUNT), |
| 211 | len); | 211 | len); |
| 212 | 212 | ||
| 213 | /* control (this should start things) */ | 213 | /* control (this should start things) */ |
| 214 | musb_writew(mbase, | 214 | musb_writew(mbase, |
| 215 | MUSB_HSDMA_CHANNEL_OFFSET(bChannel, MUSB_HSDMA_CONTROL), | 215 | MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_CONTROL), |
| 216 | csr); | 216 | csr); |
| 217 | } | 217 | } |
| 218 | 218 | ||
| 219 | static int dma_channel_program(struct dma_channel *pChannel, | 219 | static int dma_channel_program(struct dma_channel *channel, |
| 220 | u16 packet_sz, u8 mode, | 220 | u16 packet_sz, u8 mode, |
| 221 | dma_addr_t dma_addr, u32 len) | 221 | dma_addr_t dma_addr, u32 len) |
| 222 | { | 222 | { |
| 223 | struct musb_dma_channel *pImplChannel = | 223 | struct musb_dma_channel *musb_channel = channel->private_data; |
| 224 | (struct musb_dma_channel *) pChannel->private_data; | ||
| 225 | 224 | ||
| 226 | DBG(2, "ep%d-%s pkt_sz %d, dma_addr 0x%x length %d, mode %d\n", | 225 | DBG(2, "ep%d-%s pkt_sz %d, dma_addr 0x%x length %d, mode %d\n", |
| 227 | pImplChannel->epnum, | 226 | musb_channel->epnum, |
| 228 | pImplChannel->transmit ? "Tx" : "Rx", | 227 | musb_channel->transmit ? "Tx" : "Rx", |
| 229 | packet_sz, dma_addr, len, mode); | 228 | packet_sz, dma_addr, len, mode); |
| 230 | 229 | ||
| 231 | BUG_ON(pChannel->status == MUSB_DMA_STATUS_UNKNOWN || | 230 | BUG_ON(channel->status == MUSB_DMA_STATUS_UNKNOWN || |
| 232 | pChannel->status == MUSB_DMA_STATUS_BUSY); | 231 | channel->status == MUSB_DMA_STATUS_BUSY); |
| 233 | 232 | ||
| 234 | pChannel->actual_len = 0; | 233 | channel->actual_len = 0; |
| 235 | pImplChannel->dwStartAddress = dma_addr; | 234 | musb_channel->start_addr = dma_addr; |
| 236 | pImplChannel->len = len; | 235 | musb_channel->len = len; |
| 237 | pImplChannel->wMaxPacketSize = packet_sz; | 236 | musb_channel->max_packet_sz = packet_sz; |
| 238 | pChannel->status = MUSB_DMA_STATUS_BUSY; | 237 | channel->status = MUSB_DMA_STATUS_BUSY; |
| 239 | 238 | ||
| 240 | if ((mode == 1) && (len >= packet_sz)) | 239 | if ((mode == 1) && (len >= packet_sz)) |
| 241 | configure_channel(pChannel, packet_sz, 1, dma_addr, len); | 240 | configure_channel(channel, packet_sz, 1, dma_addr, len); |
| 242 | else | 241 | else |
| 243 | configure_channel(pChannel, packet_sz, 0, dma_addr, len); | 242 | configure_channel(channel, packet_sz, 0, dma_addr, len); |
| 244 | 243 | ||
| 245 | return true; | 244 | return true; |
| 246 | } | 245 | } |
| 247 | 246 | ||
| 248 | static int dma_channel_abort(struct dma_channel *pChannel) | 247 | static int dma_channel_abort(struct dma_channel *channel) |
| 249 | { | 248 | { |
| 250 | struct musb_dma_channel *pImplChannel = | 249 | struct musb_dma_channel *musb_channel = channel->private_data; |
| 251 | (struct musb_dma_channel *) pChannel->private_data; | 250 | void __iomem *mbase = musb_channel->controller->base; |
| 252 | u8 bChannel = pImplChannel->bIndex; | 251 | |
| 253 | void __iomem *mbase = pImplChannel->controller->pCoreBase; | 252 | u8 bchannel = musb_channel->idx; |
| 254 | u16 csr; | 253 | u16 csr; |
| 255 | 254 | ||
| 256 | if (pChannel->status == MUSB_DMA_STATUS_BUSY) { | 255 | if (channel->status == MUSB_DMA_STATUS_BUSY) { |
| 257 | if (pImplChannel->transmit) { | 256 | if (musb_channel->transmit) { |
| 258 | 257 | ||
| 259 | csr = musb_readw(mbase, | 258 | csr = musb_readw(mbase, |
| 260 | MUSB_EP_OFFSET(pImplChannel->epnum, | 259 | MUSB_EP_OFFSET(musb_channel->epnum, |
| 261 | MUSB_TXCSR)); | 260 | MUSB_TXCSR)); |
| 262 | csr &= ~(MUSB_TXCSR_AUTOSET | | 261 | csr &= ~(MUSB_TXCSR_AUTOSET | |
| 263 | MUSB_TXCSR_DMAENAB | | 262 | MUSB_TXCSR_DMAENAB | |
| 264 | MUSB_TXCSR_DMAMODE); | 263 | MUSB_TXCSR_DMAMODE); |
| 265 | musb_writew(mbase, | 264 | musb_writew(mbase, |
| 266 | MUSB_EP_OFFSET(pImplChannel->epnum, | 265 | MUSB_EP_OFFSET(musb_channel->epnum, MUSB_TXCSR), |
| 267 | MUSB_TXCSR), | ||
| 268 | csr); | 266 | csr); |
| 269 | } else { | 267 | } else { |
| 270 | csr = musb_readw(mbase, | 268 | csr = musb_readw(mbase, |
| 271 | MUSB_EP_OFFSET(pImplChannel->epnum, | 269 | MUSB_EP_OFFSET(musb_channel->epnum, |
| 272 | MUSB_RXCSR)); | 270 | MUSB_RXCSR)); |
| 273 | csr &= ~(MUSB_RXCSR_AUTOCLEAR | | 271 | csr &= ~(MUSB_RXCSR_AUTOCLEAR | |
| 274 | MUSB_RXCSR_DMAENAB | | 272 | MUSB_RXCSR_DMAENAB | |
| 275 | MUSB_RXCSR_DMAMODE); | 273 | MUSB_RXCSR_DMAMODE); |
| 276 | musb_writew(mbase, | 274 | musb_writew(mbase, |
| 277 | MUSB_EP_OFFSET(pImplChannel->epnum, | 275 | MUSB_EP_OFFSET(musb_channel->epnum, MUSB_RXCSR), |
| 278 | MUSB_RXCSR), | ||
| 279 | csr); | 276 | csr); |
| 280 | } | 277 | } |
| 281 | 278 | ||
| 282 | musb_writew(mbase, | 279 | musb_writew(mbase, |
| 283 | MUSB_HSDMA_CHANNEL_OFFSET(bChannel, MUSB_HSDMA_CONTROL), | 280 | MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_CONTROL), |
| 284 | 0); | 281 | 0); |
| 285 | musb_writel(mbase, | 282 | musb_writel(mbase, |
| 286 | MUSB_HSDMA_CHANNEL_OFFSET(bChannel, MUSB_HSDMA_ADDRESS), | 283 | MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_ADDRESS), |
| 287 | 0); | 284 | 0); |
| 288 | musb_writel(mbase, | 285 | musb_writel(mbase, |
| 289 | MUSB_HSDMA_CHANNEL_OFFSET(bChannel, MUSB_HSDMA_COUNT), | 286 | MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_COUNT), |
| 290 | 0); | 287 | 0); |
| 291 | 288 | ||
| 292 | pChannel->status = MUSB_DMA_STATUS_FREE; | 289 | channel->status = MUSB_DMA_STATUS_FREE; |
| 293 | } | 290 | } |
| 291 | |||
| 294 | return 0; | 292 | return 0; |
| 295 | } | 293 | } |
| 296 | 294 | ||
| 297 | static irqreturn_t dma_controller_irq(int irq, void *private_data) | 295 | static irqreturn_t dma_controller_irq(int irq, void *private_data) |
| 298 | { | 296 | { |
| 299 | struct musb_dma_controller *controller = | 297 | struct musb_dma_controller *controller = private_data; |
| 300 | (struct musb_dma_controller *)private_data; | 298 | struct musb *musb = controller->private_data; |
| 301 | struct musb_dma_channel *pImplChannel; | 299 | struct musb_dma_channel *musb_channel; |
| 302 | struct musb *musb = controller->pDmaPrivate; | 300 | struct dma_channel *channel; |
| 303 | void __iomem *mbase = controller->pCoreBase; | 301 | |
| 304 | struct dma_channel *pChannel; | 302 | void __iomem *mbase = controller->base; |
| 305 | u8 bChannel; | 303 | |
| 306 | u16 csr; | ||
| 307 | u32 dwAddress; | ||
| 308 | u8 int_hsdma; | ||
| 309 | irqreturn_t retval = IRQ_NONE; | 304 | irqreturn_t retval = IRQ_NONE; |
| 305 | |||
| 310 | unsigned long flags; | 306 | unsigned long flags; |
| 311 | 307 | ||
| 308 | u8 bchannel; | ||
| 309 | u8 int_hsdma; | ||
| 310 | |||
| 311 | u32 addr; | ||
| 312 | u16 csr; | ||
| 313 | |||
| 312 | spin_lock_irqsave(&musb->lock, flags); | 314 | spin_lock_irqsave(&musb->lock, flags); |
| 313 | 315 | ||
| 314 | int_hsdma = musb_readb(mbase, MUSB_HSDMA_INTR); | 316 | int_hsdma = musb_readb(mbase, MUSB_HSDMA_INTR); |
| 315 | if (!int_hsdma) | 317 | if (!int_hsdma) |
| 316 | goto done; | 318 | goto done; |
| 317 | 319 | ||
| 318 | for (bChannel = 0; bChannel < MUSB_HSDMA_CHANNELS; bChannel++) { | 320 | for (bchannel = 0; bchannel < MUSB_HSDMA_CHANNELS; bchannel++) { |
| 319 | if (int_hsdma & (1 << bChannel)) { | 321 | if (int_hsdma & (1 << bchannel)) { |
| 320 | pImplChannel = (struct musb_dma_channel *) | 322 | musb_channel = (struct musb_dma_channel *) |
| 321 | &(controller->aChannel[bChannel]); | 323 | &(controller->channel[bchannel]); |
| 322 | pChannel = &pImplChannel->Channel; | 324 | channel = &musb_channel->channel; |
| 323 | 325 | ||
| 324 | csr = musb_readw(mbase, | 326 | csr = musb_readw(mbase, |
| 325 | MUSB_HSDMA_CHANNEL_OFFSET(bChannel, | 327 | MUSB_HSDMA_CHANNEL_OFFSET(bchannel, |
| 326 | MUSB_HSDMA_CONTROL)); | 328 | MUSB_HSDMA_CONTROL)); |
| 327 | 329 | ||
| 328 | if (csr & (1 << MUSB_HSDMA_BUSERROR_SHIFT)) | 330 | if (csr & (1 << MUSB_HSDMA_BUSERROR_SHIFT)) { |
| 329 | pImplChannel->Channel.status = | 331 | musb_channel->channel.status = |
| 330 | MUSB_DMA_STATUS_BUS_ABORT; | 332 | MUSB_DMA_STATUS_BUS_ABORT; |
| 331 | else { | 333 | } else { |
| 332 | u8 devctl; | 334 | u8 devctl; |
| 333 | 335 | ||
| 334 | dwAddress = musb_readl(mbase, | 336 | addr = musb_readl(mbase, |
| 335 | MUSB_HSDMA_CHANNEL_OFFSET( | 337 | MUSB_HSDMA_CHANNEL_OFFSET( |
| 336 | bChannel, | 338 | bchannel, |
| 337 | MUSB_HSDMA_ADDRESS)); | 339 | MUSB_HSDMA_ADDRESS)); |
| 338 | pChannel->actual_len = dwAddress | 340 | channel->actual_len = addr |
| 339 | - pImplChannel->dwStartAddress; | 341 | - musb_channel->start_addr; |
| 340 | 342 | ||
| 341 | DBG(2, "ch %p, 0x%x -> 0x%x (%d / %d) %s\n", | 343 | DBG(2, "ch %p, 0x%x -> 0x%x (%d / %d) %s\n", |
| 342 | pChannel, pImplChannel->dwStartAddress, | 344 | channel, musb_channel->start_addr, |
| 343 | dwAddress, pChannel->actual_len, | 345 | addr, channel->actual_len, |
| 344 | pImplChannel->len, | 346 | musb_channel->len, |
| 345 | (pChannel->actual_len | 347 | (channel->actual_len |
| 346 | < pImplChannel->len) ? | 348 | < musb_channel->len) ? |
| 347 | "=> reconfig 0" : "=> complete"); | 349 | "=> reconfig 0" : "=> complete"); |
| 348 | 350 | ||
| 349 | devctl = musb_readb(mbase, MUSB_DEVCTL); | 351 | devctl = musb_readb(mbase, MUSB_DEVCTL); |
| 350 | 352 | ||
| 351 | pChannel->status = MUSB_DMA_STATUS_FREE; | 353 | channel->status = MUSB_DMA_STATUS_FREE; |
| 352 | 354 | ||
| 353 | /* completed */ | 355 | /* completed */ |
| 354 | if ((devctl & MUSB_DEVCTL_HM) | 356 | if ((devctl & MUSB_DEVCTL_HM) |
| 355 | && (pImplChannel->transmit) | 357 | && (musb_channel->transmit) |
| 356 | && ((pChannel->desired_mode == 0) | 358 | && ((channel->desired_mode == 0) |
| 357 | || (pChannel->actual_len & | 359 | || (channel->actual_len & |
| 358 | (pImplChannel->wMaxPacketSize - 1))) | 360 | (musb_channel->max_packet_sz - 1))) |
| 359 | ) { | 361 | ) { |
| 360 | /* Send out the packet */ | 362 | /* Send out the packet */ |
| 361 | musb_ep_select(mbase, | 363 | musb_ep_select(mbase, |
| 362 | pImplChannel->epnum); | 364 | musb_channel->epnum); |
| 363 | musb_writew(mbase, MUSB_EP_OFFSET( | 365 | musb_writew(mbase, MUSB_EP_OFFSET( |
| 364 | pImplChannel->epnum, | 366 | musb_channel->epnum, |
| 365 | MUSB_TXCSR), | 367 | MUSB_TXCSR), |
| 366 | MUSB_TXCSR_TXPKTRDY); | 368 | MUSB_TXCSR_TXPKTRDY); |
| 367 | } else | 369 | } else { |
| 368 | musb_dma_completion( | 370 | musb_dma_completion( |
| 369 | musb, | 371 | musb, |
| 370 | pImplChannel->epnum, | 372 | musb_channel->epnum, |
| 371 | pImplChannel->transmit); | 373 | musb_channel->transmit); |
| 374 | } | ||
| 372 | } | 375 | } |
| 373 | } | 376 | } |
| 374 | } | 377 | } |
| @@ -380,9 +383,9 @@ done: | |||
| 380 | 383 | ||
| 381 | void dma_controller_destroy(struct dma_controller *c) | 384 | void dma_controller_destroy(struct dma_controller *c) |
| 382 | { | 385 | { |
| 383 | struct musb_dma_controller *controller; | 386 | struct musb_dma_controller *controller = container_of(c, |
| 387 | struct musb_dma_controller, controller); | ||
| 384 | 388 | ||
| 385 | controller = container_of(c, struct musb_dma_controller, Controller); | ||
| 386 | if (!controller) | 389 | if (!controller) |
| 387 | return; | 390 | return; |
| 388 | 391 | ||
| @@ -393,7 +396,7 @@ void dma_controller_destroy(struct dma_controller *c) | |||
| 393 | } | 396 | } |
| 394 | 397 | ||
| 395 | struct dma_controller *__init | 398 | struct dma_controller *__init |
| 396 | dma_controller_create(struct musb *musb, void __iomem *pCoreBase) | 399 | dma_controller_create(struct musb *musb, void __iomem *base) |
| 397 | { | 400 | { |
| 398 | struct musb_dma_controller *controller; | 401 | struct musb_dma_controller *controller; |
| 399 | struct device *dev = musb->controller; | 402 | struct device *dev = musb->controller; |
| @@ -405,29 +408,30 @@ dma_controller_create(struct musb *musb, void __iomem *pCoreBase) | |||
| 405 | return NULL; | 408 | return NULL; |
| 406 | } | 409 | } |
| 407 | 410 | ||
| 408 | controller = kzalloc(sizeof(struct musb_dma_controller), GFP_KERNEL); | 411 | controller = kzalloc(sizeof(*controller), GFP_KERNEL); |
| 409 | if (!controller) | 412 | if (!controller) |
| 410 | return NULL; | 413 | return NULL; |
| 411 | 414 | ||
| 412 | controller->bChannelCount = MUSB_HSDMA_CHANNELS; | 415 | controller->channel_count = MUSB_HSDMA_CHANNELS; |
| 413 | controller->pDmaPrivate = musb; | 416 | controller->private_data = musb; |
| 414 | controller->pCoreBase = pCoreBase; | 417 | controller->base = base; |
| 415 | 418 | ||
| 416 | controller->Controller.start = dma_controller_start; | 419 | controller->controller.start = dma_controller_start; |
| 417 | controller->Controller.stop = dma_controller_stop; | 420 | controller->controller.stop = dma_controller_stop; |
| 418 | controller->Controller.channel_alloc = dma_channel_allocate; | 421 | controller->controller.channel_alloc = dma_channel_allocate; |
| 419 | controller->Controller.channel_release = dma_channel_release; | 422 | controller->controller.channel_release = dma_channel_release; |
| 420 | controller->Controller.channel_program = dma_channel_program; | 423 | controller->controller.channel_program = dma_channel_program; |
| 421 | controller->Controller.channel_abort = dma_channel_abort; | 424 | controller->controller.channel_abort = dma_channel_abort; |
| 422 | 425 | ||
| 423 | if (request_irq(irq, dma_controller_irq, IRQF_DISABLED, | 426 | if (request_irq(irq, dma_controller_irq, IRQF_DISABLED, |
| 424 | musb->controller->bus_id, &controller->Controller)) { | 427 | musb->controller->bus_id, &controller->controller)) { |
| 425 | dev_err(dev, "request_irq %d failed!\n", irq); | 428 | dev_err(dev, "request_irq %d failed!\n", irq); |
| 426 | dma_controller_destroy(&controller->Controller); | 429 | dma_controller_destroy(&controller->controller); |
| 430 | |||
| 427 | return NULL; | 431 | return NULL; |
| 428 | } | 432 | } |
| 429 | 433 | ||
| 430 | controller->irq = irq; | 434 | controller->irq = irq; |
| 431 | 435 | ||
| 432 | return &controller->Controller; | 436 | return &controller->controller; |
| 433 | } | 437 | } |
diff --git a/drivers/usb/serial/aircable.c b/drivers/usb/serial/aircable.c index 99fb7dc59c45..537f953bd7f8 100644 --- a/drivers/usb/serial/aircable.c +++ b/drivers/usb/serial/aircable.c | |||
| @@ -220,8 +220,8 @@ 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.", __func__, | 223 | dev_err(&port->dev, "%s- kzalloc(%d) failed.\n", |
| 224 | count + HCI_HEADER_LENGTH); | 224 | __func__, count + HCI_HEADER_LENGTH); |
| 225 | return; | 225 | return; |
| 226 | } | 226 | } |
| 227 | 227 | ||
| @@ -276,7 +276,7 @@ static void aircable_read(struct work_struct *work) | |||
| 276 | 276 | ||
| 277 | if (!tty) { | 277 | if (!tty) { |
| 278 | schedule_work(&priv->rx_work); | 278 | schedule_work(&priv->rx_work); |
| 279 | err("%s - No tty available", __func__); | 279 | dev_err(&port->dev, "%s - No tty available\n", __func__); |
| 280 | return ; | 280 | return ; |
| 281 | } | 281 | } |
| 282 | 282 | ||
| @@ -336,7 +336,7 @@ static int aircable_attach(struct usb_serial *serial) | |||
| 336 | 336 | ||
| 337 | priv = kzalloc(sizeof(struct aircable_private), GFP_KERNEL); | 337 | priv = kzalloc(sizeof(struct aircable_private), GFP_KERNEL); |
| 338 | if (!priv) { | 338 | if (!priv) { |
| 339 | err("%s- kmalloc(%Zd) failed.", __func__, | 339 | dev_err(&port->dev, "%s- kmalloc(%Zd) failed.\n", __func__, |
| 340 | sizeof(struct aircable_private)); | 340 | sizeof(struct aircable_private)); |
| 341 | return -ENOMEM; | 341 | return -ENOMEM; |
| 342 | } | 342 | } |
diff --git a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c index 1913bc7c5f0b..b7eacad4d48c 100644 --- a/drivers/usb/serial/belkin_sa.c +++ b/drivers/usb/serial/belkin_sa.c | |||
| @@ -187,7 +187,7 @@ static int belkin_sa_startup(struct usb_serial *serial) | |||
| 187 | /* see comments at top of file */ | 187 | /* see comments at top of file */ |
| 188 | priv->bad_flow_control = | 188 | priv->bad_flow_control = |
| 189 | (le16_to_cpu(dev->descriptor.bcdDevice) <= 0x0206) ? 1 : 0; | 189 | (le16_to_cpu(dev->descriptor.bcdDevice) <= 0x0206) ? 1 : 0; |
| 190 | info("bcdDevice: %04x, bfc: %d", | 190 | dev_info(&dev->dev, "bcdDevice: %04x, bfc: %d\n", |
| 191 | le16_to_cpu(dev->descriptor.bcdDevice), | 191 | le16_to_cpu(dev->descriptor.bcdDevice), |
| 192 | priv->bad_flow_control); | 192 | priv->bad_flow_control); |
| 193 | 193 | ||
| @@ -228,7 +228,7 @@ static int belkin_sa_open(struct tty_struct *tty, | |||
| 228 | port->read_urb->dev = port->serial->dev; | 228 | port->read_urb->dev = port->serial->dev; |
| 229 | retval = usb_submit_urb(port->read_urb, GFP_KERNEL); | 229 | retval = usb_submit_urb(port->read_urb, GFP_KERNEL); |
| 230 | if (retval) { | 230 | if (retval) { |
| 231 | err("usb_submit_urb(read bulk) failed"); | 231 | dev_err(&port->dev, "usb_submit_urb(read bulk) failed\n"); |
| 232 | goto exit; | 232 | goto exit; |
| 233 | } | 233 | } |
| 234 | 234 | ||
| @@ -236,7 +236,7 @@ static int belkin_sa_open(struct tty_struct *tty, | |||
| 236 | retval = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); | 236 | retval = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); |
| 237 | if (retval) { | 237 | if (retval) { |
| 238 | usb_kill_urb(port->read_urb); | 238 | usb_kill_urb(port->read_urb); |
| 239 | err(" usb_submit_urb(read int) failed"); | 239 | dev_err(&port->dev, "usb_submit_urb(read int) failed\n"); |
| 240 | } | 240 | } |
| 241 | 241 | ||
| 242 | exit: | 242 | exit: |
| @@ -342,8 +342,8 @@ static void belkin_sa_read_int_callback(struct urb *urb) | |||
| 342 | exit: | 342 | exit: |
| 343 | retval = usb_submit_urb(urb, GFP_ATOMIC); | 343 | retval = usb_submit_urb(urb, GFP_ATOMIC); |
| 344 | if (retval) | 344 | if (retval) |
| 345 | err("%s - usb_submit_urb failed with result %d", | 345 | dev_err(&port->dev, "%s - usb_submit_urb failed with " |
| 346 | __func__, retval); | 346 | "result %d\n", __func__, retval); |
| 347 | } | 347 | } |
| 348 | 348 | ||
| 349 | static void belkin_sa_set_termios(struct tty_struct *tty, | 349 | static void belkin_sa_set_termios(struct tty_struct *tty, |
| @@ -382,12 +382,12 @@ static void belkin_sa_set_termios(struct tty_struct *tty, | |||
| 382 | if ((old_cflag & CBAUD) == B0) { | 382 | if ((old_cflag & CBAUD) == B0) { |
| 383 | control_state |= (TIOCM_DTR|TIOCM_RTS); | 383 | control_state |= (TIOCM_DTR|TIOCM_RTS); |
| 384 | if (BSA_USB_CMD(BELKIN_SA_SET_DTR_REQUEST, 1) < 0) | 384 | if (BSA_USB_CMD(BELKIN_SA_SET_DTR_REQUEST, 1) < 0) |
| 385 | err("Set DTR error"); | 385 | dev_err(&port->dev, "Set DTR error\n"); |
| 386 | /* don't set RTS if using hardware flow control */ | 386 | /* don't set RTS if using hardware flow control */ |
| 387 | if (!(old_cflag & CRTSCTS)) | 387 | if (!(old_cflag & CRTSCTS)) |
| 388 | if (BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST | 388 | if (BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST |
| 389 | , 1) < 0) | 389 | , 1) < 0) |
| 390 | err("Set RTS error"); | 390 | dev_err(&port->dev, "Set RTS error\n"); |
| 391 | } | 391 | } |
| 392 | } | 392 | } |
| 393 | 393 | ||
| @@ -403,18 +403,18 @@ static void belkin_sa_set_termios(struct tty_struct *tty, | |||
| 403 | /* Report the actual baud rate back to the caller */ | 403 | /* Report the actual baud rate back to the caller */ |
| 404 | tty_encode_baud_rate(tty, baud, baud); | 404 | tty_encode_baud_rate(tty, baud, baud); |
| 405 | if (BSA_USB_CMD(BELKIN_SA_SET_BAUDRATE_REQUEST, urb_value) < 0) | 405 | if (BSA_USB_CMD(BELKIN_SA_SET_BAUDRATE_REQUEST, urb_value) < 0) |
| 406 | err("Set baudrate error"); | 406 | dev_err(&port->dev, "Set baudrate error\n"); |
| 407 | } else { | 407 | } else { |
| 408 | /* Disable flow control */ | 408 | /* Disable flow control */ |
| 409 | if (BSA_USB_CMD(BELKIN_SA_SET_FLOW_CTRL_REQUEST, | 409 | if (BSA_USB_CMD(BELKIN_SA_SET_FLOW_CTRL_REQUEST, |
| 410 | BELKIN_SA_FLOW_NONE) < 0) | 410 | BELKIN_SA_FLOW_NONE) < 0) |
| 411 | err("Disable flowcontrol error"); | 411 | dev_err(&port->dev, "Disable flowcontrol error\n"); |
| 412 | /* Drop RTS and DTR */ | 412 | /* Drop RTS and DTR */ |
| 413 | control_state &= ~(TIOCM_DTR | TIOCM_RTS); | 413 | control_state &= ~(TIOCM_DTR | TIOCM_RTS); |
| 414 | if (BSA_USB_CMD(BELKIN_SA_SET_DTR_REQUEST, 0) < 0) | 414 | if (BSA_USB_CMD(BELKIN_SA_SET_DTR_REQUEST, 0) < 0) |
| 415 | err("DTR LOW error"); | 415 | dev_err(&port->dev, "DTR LOW error\n"); |
| 416 | if (BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST, 0) < 0) | 416 | if (BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST, 0) < 0) |
| 417 | err("RTS LOW error"); | 417 | dev_err(&port->dev, "RTS LOW error\n"); |
| 418 | } | 418 | } |
| 419 | 419 | ||
| 420 | /* set the parity */ | 420 | /* set the parity */ |
| @@ -425,7 +425,7 @@ static void belkin_sa_set_termios(struct tty_struct *tty, | |||
| 425 | else | 425 | else |
| 426 | urb_value = BELKIN_SA_PARITY_NONE; | 426 | urb_value = BELKIN_SA_PARITY_NONE; |
| 427 | if (BSA_USB_CMD(BELKIN_SA_SET_PARITY_REQUEST, urb_value) < 0) | 427 | if (BSA_USB_CMD(BELKIN_SA_SET_PARITY_REQUEST, urb_value) < 0) |
| 428 | err("Set parity error"); | 428 | dev_err(&port->dev, "Set parity error\n"); |
| 429 | } | 429 | } |
| 430 | 430 | ||
| 431 | /* set the number of data bits */ | 431 | /* set the number of data bits */ |
| @@ -448,7 +448,7 @@ static void belkin_sa_set_termios(struct tty_struct *tty, | |||
| 448 | break; | 448 | break; |
| 449 | } | 449 | } |
| 450 | if (BSA_USB_CMD(BELKIN_SA_SET_DATA_BITS_REQUEST, urb_value) < 0) | 450 | if (BSA_USB_CMD(BELKIN_SA_SET_DATA_BITS_REQUEST, urb_value) < 0) |
| 451 | err("Set data bits error"); | 451 | dev_err(&port->dev, "Set data bits error\n"); |
| 452 | } | 452 | } |
| 453 | 453 | ||
| 454 | /* set the number of stop bits */ | 454 | /* set the number of stop bits */ |
| @@ -457,7 +457,7 @@ static void belkin_sa_set_termios(struct tty_struct *tty, | |||
| 457 | : BELKIN_SA_STOP_BITS(1); | 457 | : BELKIN_SA_STOP_BITS(1); |
| 458 | if (BSA_USB_CMD(BELKIN_SA_SET_STOP_BITS_REQUEST, | 458 | if (BSA_USB_CMD(BELKIN_SA_SET_STOP_BITS_REQUEST, |
| 459 | urb_value) < 0) | 459 | urb_value) < 0) |
| 460 | err("Set stop bits error"); | 460 | dev_err(&port->dev, "Set stop bits error\n"); |
| 461 | } | 461 | } |
| 462 | 462 | ||
| 463 | /* Set flow control */ | 463 | /* Set flow control */ |
| @@ -478,7 +478,7 @@ static void belkin_sa_set_termios(struct tty_struct *tty, | |||
| 478 | urb_value &= ~(BELKIN_SA_FLOW_IRTS); | 478 | urb_value &= ~(BELKIN_SA_FLOW_IRTS); |
| 479 | 479 | ||
| 480 | if (BSA_USB_CMD(BELKIN_SA_SET_FLOW_CTRL_REQUEST, urb_value) < 0) | 480 | if (BSA_USB_CMD(BELKIN_SA_SET_FLOW_CTRL_REQUEST, urb_value) < 0) |
| 481 | err("Set flow control error"); | 481 | dev_err(&port->dev, "Set flow control error\n"); |
| 482 | } | 482 | } |
| 483 | 483 | ||
| 484 | /* save off the modified port settings */ | 484 | /* save off the modified port settings */ |
| @@ -494,7 +494,7 @@ static void belkin_sa_break_ctl(struct tty_struct *tty, int break_state) | |||
| 494 | struct usb_serial *serial = port->serial; | 494 | struct usb_serial *serial = port->serial; |
| 495 | 495 | ||
| 496 | if (BSA_USB_CMD(BELKIN_SA_SET_BREAK_REQUEST, break_state ? 1 : 0) < 0) | 496 | if (BSA_USB_CMD(BELKIN_SA_SET_BREAK_REQUEST, break_state ? 1 : 0) < 0) |
| 497 | err("Set break_ctl %d", break_state); | 497 | dev_err(&port->dev, "Set break_ctl %d\n", break_state); |
| 498 | } | 498 | } |
| 499 | 499 | ||
| 500 | 500 | ||
| @@ -554,13 +554,13 @@ static int belkin_sa_tiocmset(struct tty_struct *tty, struct file *file, | |||
| 554 | 554 | ||
| 555 | retval = BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST, rts); | 555 | retval = BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST, rts); |
| 556 | if (retval < 0) { | 556 | if (retval < 0) { |
| 557 | err("Set RTS error %d", retval); | 557 | dev_err(&port->dev, "Set RTS error %d\n", retval); |
| 558 | goto exit; | 558 | goto exit; |
| 559 | } | 559 | } |
| 560 | 560 | ||
| 561 | retval = BSA_USB_CMD(BELKIN_SA_SET_DTR_REQUEST, dtr); | 561 | retval = BSA_USB_CMD(BELKIN_SA_SET_DTR_REQUEST, dtr); |
| 562 | if (retval < 0) { | 562 | if (retval < 0) { |
| 563 | err("Set DTR error %d", retval); | 563 | dev_err(&port->dev, "Set DTR error %d\n", retval); |
| 564 | goto exit; | 564 | goto exit; |
| 565 | } | 565 | } |
| 566 | exit: | 566 | exit: |
| @@ -577,7 +577,8 @@ static int __init belkin_sa_init(void) | |||
| 577 | retval = usb_register(&belkin_driver); | 577 | retval = usb_register(&belkin_driver); |
| 578 | if (retval) | 578 | if (retval) |
| 579 | goto failed_usb_register; | 579 | goto failed_usb_register; |
| 580 | info(DRIVER_DESC " " DRIVER_VERSION); | 580 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
| 581 | DRIVER_DESC "\n"); | ||
| 581 | return 0; | 582 | return 0; |
| 582 | failed_usb_register: | 583 | failed_usb_register: |
| 583 | usb_serial_deregister(&belkin_device); | 584 | usb_serial_deregister(&belkin_device); |
diff --git a/drivers/usb/serial/cp2101.c b/drivers/usb/serial/cp2101.c index 1279553381e3..8008d0bc80ad 100644 --- a/drivers/usb/serial/cp2101.c +++ b/drivers/usb/serial/cp2101.c | |||
| @@ -753,7 +753,8 @@ static int __init cp2101_init(void) | |||
| 753 | } | 753 | } |
| 754 | 754 | ||
| 755 | /* Success */ | 755 | /* Success */ |
| 756 | info(DRIVER_DESC " " DRIVER_VERSION); | 756 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
| 757 | DRIVER_DESC "\n"); | ||
| 757 | return 0; | 758 | return 0; |
| 758 | } | 759 | } |
| 759 | 760 | ||
diff --git a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c index 94ef36c4764b..858bdd038fbc 100644 --- a/drivers/usb/serial/cyberjack.c +++ b/drivers/usb/serial/cyberjack.c | |||
| @@ -141,7 +141,8 @@ static int cyberjack_startup(struct usb_serial *serial) | |||
| 141 | result = usb_submit_urb(serial->port[i]->interrupt_in_urb, | 141 | result = usb_submit_urb(serial->port[i]->interrupt_in_urb, |
| 142 | GFP_KERNEL); | 142 | GFP_KERNEL); |
| 143 | if (result) | 143 | if (result) |
| 144 | err(" usb_submit_urb(read int) failed"); | 144 | dev_err(&serial->dev->dev, |
| 145 | "usb_submit_urb(read int) failed\n"); | ||
| 145 | dbg("%s - usb_submit_urb(int urb)", __func__); | 146 | dbg("%s - usb_submit_urb(int urb)", __func__); |
| 146 | } | 147 | } |
| 147 | 148 | ||
| @@ -274,8 +275,9 @@ static int cyberjack_write(struct tty_struct *tty, | |||
| 274 | /* send the data out the bulk port */ | 275 | /* send the data out the bulk port */ |
| 275 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); | 276 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); |
| 276 | if (result) { | 277 | if (result) { |
| 277 | err("%s - failed submitting write urb, error %d", | 278 | dev_err(&port->dev, |
| 278 | __func__, result); | 279 | "%s - failed submitting write urb, error %d", |
| 280 | __func__, result); | ||
| 279 | /* Throw away data. No better idea what to do with it. */ | 281 | /* Throw away data. No better idea what to do with it. */ |
| 280 | priv->wrfilled = 0; | 282 | priv->wrfilled = 0; |
| 281 | priv->wrsent = 0; | 283 | priv->wrsent = 0; |
| @@ -351,7 +353,9 @@ static void cyberjack_read_int_callback(struct urb *urb) | |||
| 351 | port->read_urb->dev = port->serial->dev; | 353 | port->read_urb->dev = port->serial->dev; |
| 352 | result = usb_submit_urb(port->read_urb, GFP_ATOMIC); | 354 | result = usb_submit_urb(port->read_urb, GFP_ATOMIC); |
| 353 | if (result) | 355 | if (result) |
| 354 | err("%s - failed resubmitting read urb, error %d", __func__, result); | 356 | dev_err(&port->dev, "%s - failed resubmitting " |
| 357 | "read urb, error %d\n", | ||
| 358 | __func__, result); | ||
| 355 | dbg("%s - usb_submit_urb(read urb)", __func__); | 359 | dbg("%s - usb_submit_urb(read urb)", __func__); |
| 356 | } | 360 | } |
| 357 | } | 361 | } |
| @@ -360,7 +364,7 @@ resubmit: | |||
| 360 | port->interrupt_in_urb->dev = port->serial->dev; | 364 | port->interrupt_in_urb->dev = port->serial->dev; |
| 361 | result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); | 365 | result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); |
| 362 | if (result) | 366 | if (result) |
| 363 | err(" usb_submit_urb(read int) failed"); | 367 | dev_err(&port->dev, "usb_submit_urb(read int) failed\n"); |
| 364 | dbg("%s - usb_submit_urb(int urb)", __func__); | 368 | dbg("%s - usb_submit_urb(int urb)", __func__); |
| 365 | } | 369 | } |
| 366 | 370 | ||
| @@ -414,8 +418,8 @@ static void cyberjack_read_bulk_callback(struct urb *urb) | |||
| 414 | port->read_urb->dev = port->serial->dev; | 418 | port->read_urb->dev = port->serial->dev; |
| 415 | result = usb_submit_urb(port->read_urb, GFP_ATOMIC); | 419 | result = usb_submit_urb(port->read_urb, GFP_ATOMIC); |
| 416 | if (result) | 420 | if (result) |
| 417 | err("%s - failed resubmitting read urb, error %d", | 421 | dev_err(&port->dev, "%s - failed resubmitting read " |
| 418 | __func__, result); | 422 | "urb, error %d\n", __func__, result); |
| 419 | dbg("%s - usb_submit_urb(read urb)", __func__); | 423 | dbg("%s - usb_submit_urb(read urb)", __func__); |
| 420 | } | 424 | } |
| 421 | } | 425 | } |
| @@ -462,8 +466,9 @@ static void cyberjack_write_bulk_callback(struct urb *urb) | |||
| 462 | /* send the data out the bulk port */ | 466 | /* send the data out the bulk port */ |
| 463 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); | 467 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); |
| 464 | if (result) { | 468 | if (result) { |
| 465 | err("%s - failed submitting write urb, error %d", | 469 | dev_err(&port->dev, |
| 466 | __func__, result); | 470 | "%s - failed submitting write urb, error %d\n", |
| 471 | __func__, result); | ||
| 467 | /* Throw away data. No better idea what to do with it. */ | 472 | /* Throw away data. No better idea what to do with it. */ |
| 468 | priv->wrfilled = 0; | 473 | priv->wrfilled = 0; |
| 469 | priv->wrsent = 0; | 474 | priv->wrsent = 0; |
| @@ -499,8 +504,9 @@ static int __init cyberjack_init(void) | |||
| 499 | if (retval) | 504 | if (retval) |
| 500 | goto failed_usb_register; | 505 | goto failed_usb_register; |
| 501 | 506 | ||
| 502 | info(DRIVER_VERSION " " DRIVER_AUTHOR); | 507 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION " " |
| 503 | info(DRIVER_DESC); | 508 | DRIVER_AUTHOR "\n"); |
| 509 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_DESC "\n"); | ||
| 504 | 510 | ||
| 505 | return 0; | 511 | return 0; |
| 506 | failed_usb_register: | 512 | failed_usb_register: |
diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c index f3514a91f915..eae4740d448c 100644 --- a/drivers/usb/serial/cypress_m8.c +++ b/drivers/usb/serial/cypress_m8.c | |||
| @@ -404,8 +404,8 @@ static int cypress_serial_control(struct tty_struct *tty, | |||
| 404 | retval != -ENODEV); | 404 | retval != -ENODEV); |
| 405 | 405 | ||
| 406 | if (retval != sizeof(feature_buffer)) { | 406 | if (retval != sizeof(feature_buffer)) { |
| 407 | err("%s - failed sending serial line settings - %d", | 407 | dev_err(&port->dev, "%s - failed sending serial " |
| 408 | __func__, retval); | 408 | "line settings - %d\n", __func__, retval); |
| 409 | cypress_set_dead(port); | 409 | cypress_set_dead(port); |
| 410 | } else { | 410 | } else { |
| 411 | spin_lock_irqsave(&priv->lock, flags); | 411 | spin_lock_irqsave(&priv->lock, flags); |
| @@ -443,7 +443,8 @@ static int cypress_serial_control(struct tty_struct *tty, | |||
| 443 | && retval != -ENODEV); | 443 | && retval != -ENODEV); |
| 444 | 444 | ||
| 445 | if (retval != sizeof(feature_buffer)) { | 445 | if (retval != sizeof(feature_buffer)) { |
| 446 | err("%s - failed to retrieve serial line settings - %d", __func__, retval); | 446 | dev_err(&port->dev, "%s - failed to retrieve serial " |
| 447 | "line settings - %d\n", __func__, retval); | ||
| 447 | cypress_set_dead(port); | 448 | cypress_set_dead(port); |
| 448 | return retval; | 449 | return retval; |
| 449 | } else { | 450 | } else { |
| @@ -476,8 +477,8 @@ static void cypress_set_dead(struct usb_serial_port *port) | |||
| 476 | priv->comm_is_ok = 0; | 477 | priv->comm_is_ok = 0; |
| 477 | spin_unlock_irqrestore(&priv->lock, flags); | 478 | spin_unlock_irqrestore(&priv->lock, flags); |
| 478 | 479 | ||
| 479 | err("cypress_m8 suspending failing port %d - interval might be too short", | 480 | dev_err(&port->dev, "cypress_m8 suspending failing port %d - " |
| 480 | port->number); | 481 | "interval might be too short\n", port->number); |
| 481 | } | 482 | } |
| 482 | 483 | ||
| 483 | 484 | ||
| @@ -679,7 +680,8 @@ static int cypress_open(struct tty_struct *tty, | |||
| 679 | 680 | ||
| 680 | /* setup the port and start reading from the device */ | 681 | /* setup the port and start reading from the device */ |
| 681 | if (!port->interrupt_in_urb) { | 682 | if (!port->interrupt_in_urb) { |
| 682 | err("%s - interrupt_in_urb is empty!", __func__); | 683 | dev_err(&port->dev, "%s - interrupt_in_urb is empty!\n", |
| 684 | __func__); | ||
| 683 | return -1; | 685 | return -1; |
| 684 | } | 686 | } |
| 685 | 687 | ||
| @@ -1107,8 +1109,8 @@ static void cypress_set_termios(struct tty_struct *tty, | |||
| 1107 | data_bits = 3; | 1109 | data_bits = 3; |
| 1108 | break; | 1110 | break; |
| 1109 | default: | 1111 | default: |
| 1110 | err("%s - CSIZE was set, but not CS5-CS8", | 1112 | dev_err(&port->dev, "%s - CSIZE was set, but not CS5-CS8\n", |
| 1111 | __func__); | 1113 | __func__); |
| 1112 | data_bits = 3; | 1114 | data_bits = 3; |
| 1113 | } | 1115 | } |
| 1114 | spin_lock_irqsave(&priv->lock, flags); | 1116 | spin_lock_irqsave(&priv->lock, flags); |
| @@ -1658,7 +1660,8 @@ static int __init cypress_init(void) | |||
| 1658 | if (retval) | 1660 | if (retval) |
| 1659 | goto failed_usb_register; | 1661 | goto failed_usb_register; |
| 1660 | 1662 | ||
| 1661 | info(DRIVER_DESC " " DRIVER_VERSION); | 1663 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
| 1664 | DRIVER_DESC "\n"); | ||
| 1662 | return 0; | 1665 | return 0; |
| 1663 | 1666 | ||
| 1664 | failed_usb_register: | 1667 | failed_usb_register: |
diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c index 5756ac6d6c92..69f84f0ea6fe 100644 --- a/drivers/usb/serial/digi_acceleport.c +++ b/drivers/usb/serial/digi_acceleport.c | |||
| @@ -661,7 +661,8 @@ static int digi_write_oob_command(struct usb_serial_port *port, | |||
| 661 | } | 661 | } |
| 662 | spin_unlock_irqrestore(&oob_priv->dp_port_lock, flags); | 662 | spin_unlock_irqrestore(&oob_priv->dp_port_lock, flags); |
| 663 | if (ret) | 663 | if (ret) |
| 664 | err("%s: usb_submit_urb failed, ret=%d", __func__, ret); | 664 | dev_err(&port->dev, "%s: usb_submit_urb failed, ret=%d\n", |
| 665 | __func__, ret); | ||
| 665 | return ret; | 666 | return ret; |
| 666 | 667 | ||
| 667 | } | 668 | } |
| @@ -743,7 +744,8 @@ static int digi_write_inb_command(struct usb_serial_port *port, | |||
| 743 | spin_unlock_irqrestore(&priv->dp_port_lock, flags); | 744 | spin_unlock_irqrestore(&priv->dp_port_lock, flags); |
| 744 | 745 | ||
| 745 | if (ret) | 746 | if (ret) |
| 746 | err("%s: usb_submit_urb failed, ret=%d, port=%d", | 747 | dev_err(&port->dev, |
| 748 | "%s: usb_submit_urb failed, ret=%d, port=%d\n", | ||
| 747 | __func__, ret, priv->dp_port_num); | 749 | __func__, ret, priv->dp_port_num); |
| 748 | return ret; | 750 | return ret; |
| 749 | } | 751 | } |
| @@ -812,7 +814,8 @@ static int digi_set_modem_signals(struct usb_serial_port *port, | |||
| 812 | spin_unlock(&port_priv->dp_port_lock); | 814 | spin_unlock(&port_priv->dp_port_lock); |
| 813 | spin_unlock_irqrestore(&oob_priv->dp_port_lock, flags); | 815 | spin_unlock_irqrestore(&oob_priv->dp_port_lock, flags); |
| 814 | if (ret) | 816 | if (ret) |
| 815 | err("%s: usb_submit_urb failed, ret=%d", __func__, ret); | 817 | dev_err(&port->dev, "%s: usb_submit_urb failed, ret=%d\n", |
| 818 | __func__, ret); | ||
| 816 | return ret; | 819 | return ret; |
| 817 | } | 820 | } |
| 818 | 821 | ||
| @@ -907,7 +910,8 @@ static void digi_rx_unthrottle(struct tty_struct *tty) | |||
| 907 | spin_unlock_irqrestore(&priv->dp_port_lock, flags); | 910 | spin_unlock_irqrestore(&priv->dp_port_lock, flags); |
| 908 | 911 | ||
| 909 | if (ret) | 912 | if (ret) |
| 910 | err("%s: usb_submit_urb failed, ret=%d, port=%d", | 913 | dev_err(&port->dev, |
| 914 | "%s: usb_submit_urb failed, ret=%d, port=%d\n", | ||
| 911 | __func__, ret, priv->dp_port_num); | 915 | __func__, ret, priv->dp_port_num); |
| 912 | } | 916 | } |
| 913 | 917 | ||
| @@ -1214,7 +1218,8 @@ static int digi_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
| 1214 | /* return length of new data written, or error */ | 1218 | /* return length of new data written, or error */ |
| 1215 | spin_unlock_irqrestore(&priv->dp_port_lock, flags); | 1219 | spin_unlock_irqrestore(&priv->dp_port_lock, flags); |
| 1216 | if (ret < 0) | 1220 | if (ret < 0) |
| 1217 | err("%s: usb_submit_urb failed, ret=%d, port=%d", | 1221 | dev_err(&port->dev, |
| 1222 | "%s: usb_submit_urb failed, ret=%d, port=%d\n", | ||
| 1218 | __func__, ret, priv->dp_port_num); | 1223 | __func__, ret, priv->dp_port_num); |
| 1219 | dbg("digi_write: returning %d", ret); | 1224 | dbg("digi_write: returning %d", ret); |
| 1220 | return ret; | 1225 | return ret; |
| @@ -1235,14 +1240,16 @@ static void digi_write_bulk_callback(struct urb *urb) | |||
| 1235 | 1240 | ||
| 1236 | /* port and serial sanity check */ | 1241 | /* port and serial sanity check */ |
| 1237 | if (port == NULL || (priv = usb_get_serial_port_data(port)) == NULL) { | 1242 | if (port == NULL || (priv = usb_get_serial_port_data(port)) == NULL) { |
| 1238 | err("%s: port or port->private is NULL, status=%d", | 1243 | dev_err(&port->dev, |
| 1239 | __func__, status); | 1244 | "%s: port or port->private is NULL, status=%d\n", |
| 1245 | __func__, status); | ||
| 1240 | return; | 1246 | return; |
| 1241 | } | 1247 | } |
| 1242 | serial = port->serial; | 1248 | serial = port->serial; |
| 1243 | if (serial == NULL || (serial_priv = usb_get_serial_data(serial)) == NULL) { | 1249 | if (serial == NULL || (serial_priv = usb_get_serial_data(serial)) == NULL) { |
| 1244 | err("%s: serial or serial->private is NULL, status=%d", | 1250 | dev_err(&port->dev, |
| 1245 | __func__, status); | 1251 | "%s: serial or serial->private is NULL, status=%d\n", |
| 1252 | __func__, status); | ||
| 1246 | return; | 1253 | return; |
| 1247 | } | 1254 | } |
| 1248 | 1255 | ||
| @@ -1284,7 +1291,8 @@ static void digi_write_bulk_callback(struct urb *urb) | |||
| 1284 | 1291 | ||
| 1285 | spin_unlock(&priv->dp_port_lock); | 1292 | spin_unlock(&priv->dp_port_lock); |
| 1286 | if (ret) | 1293 | if (ret) |
| 1287 | err("%s: usb_submit_urb failed, ret=%d, port=%d", | 1294 | dev_err(&port->dev, |
| 1295 | "%s: usb_submit_urb failed, ret=%d, port=%d\n", | ||
| 1288 | __func__, ret, priv->dp_port_num); | 1296 | __func__, ret, priv->dp_port_num); |
| 1289 | } | 1297 | } |
| 1290 | 1298 | ||
| @@ -1518,8 +1526,9 @@ static int digi_startup_device(struct usb_serial *serial) | |||
| 1518 | port->write_urb->dev = port->serial->dev; | 1526 | port->write_urb->dev = port->serial->dev; |
| 1519 | ret = usb_submit_urb(port->read_urb, GFP_KERNEL); | 1527 | ret = usb_submit_urb(port->read_urb, GFP_KERNEL); |
| 1520 | if (ret != 0) { | 1528 | if (ret != 0) { |
| 1521 | err("%s: usb_submit_urb failed, ret=%d, port=%d", | 1529 | dev_err(&port->dev, |
| 1522 | __func__, ret, i); | 1530 | "%s: usb_submit_urb failed, ret=%d, port=%d\n", |
| 1531 | __func__, ret, i); | ||
| 1523 | break; | 1532 | break; |
| 1524 | } | 1533 | } |
| 1525 | } | 1534 | } |
| @@ -1618,22 +1627,26 @@ static void digi_read_bulk_callback(struct urb *urb) | |||
| 1618 | dbg("digi_read_bulk_callback: TOP"); | 1627 | dbg("digi_read_bulk_callback: TOP"); |
| 1619 | 1628 | ||
| 1620 | /* port sanity check, do not resubmit if port is not valid */ | 1629 | /* port sanity check, do not resubmit if port is not valid */ |
| 1621 | if (port == NULL || (priv = usb_get_serial_port_data(port)) == NULL) { | 1630 | if (port == NULL) |
| 1622 | err("%s: port or port->private is NULL, status=%d", | 1631 | return; |
| 1623 | __func__, status); | 1632 | priv = usb_get_serial_port_data(port); |
| 1633 | if (priv == NULL) { | ||
| 1634 | dev_err(&port->dev, "%s: port->private is NULL, status=%d\n", | ||
| 1635 | __func__, status); | ||
| 1624 | return; | 1636 | return; |
| 1625 | } | 1637 | } |
| 1626 | if (port->serial == NULL || | 1638 | if (port->serial == NULL || |
| 1627 | (serial_priv = usb_get_serial_data(port->serial)) == NULL) { | 1639 | (serial_priv = usb_get_serial_data(port->serial)) == NULL) { |
| 1628 | err("%s: serial is bad or serial->private is NULL, status=%d", | 1640 | dev_err(&port->dev, "%s: serial is bad or serial->private " |
| 1629 | __func__, status); | 1641 | "is NULL, status=%d\n", __func__, status); |
| 1630 | return; | 1642 | return; |
| 1631 | } | 1643 | } |
| 1632 | 1644 | ||
| 1633 | /* do not resubmit urb if it has any status error */ | 1645 | /* do not resubmit urb if it has any status error */ |
| 1634 | if (status) { | 1646 | if (status) { |
| 1635 | err("%s: nonzero read bulk status: status=%d, port=%d", | 1647 | dev_err(&port->dev, |
| 1636 | __func__, status, priv->dp_port_num); | 1648 | "%s: nonzero read bulk status: status=%d, port=%d\n", |
| 1649 | __func__, status, priv->dp_port_num); | ||
| 1637 | return; | 1650 | return; |
| 1638 | } | 1651 | } |
| 1639 | 1652 | ||
| @@ -1650,8 +1663,9 @@ static void digi_read_bulk_callback(struct urb *urb) | |||
| 1650 | urb->dev = port->serial->dev; | 1663 | urb->dev = port->serial->dev; |
| 1651 | ret = usb_submit_urb(urb, GFP_ATOMIC); | 1664 | ret = usb_submit_urb(urb, GFP_ATOMIC); |
| 1652 | if (ret != 0) { | 1665 | if (ret != 0) { |
| 1653 | err("%s: failed resubmitting urb, ret=%d, port=%d", | 1666 | dev_err(&port->dev, |
| 1654 | __func__, ret, priv->dp_port_num); | 1667 | "%s: failed resubmitting urb, ret=%d, port=%d\n", |
| 1668 | __func__, ret, priv->dp_port_num); | ||
| 1655 | } | 1669 | } |
| 1656 | 1670 | ||
| 1657 | } | 1671 | } |
| @@ -1687,10 +1701,11 @@ static int digi_read_inb_callback(struct urb *urb) | |||
| 1687 | 1701 | ||
| 1688 | /* short/multiple packet check */ | 1702 | /* short/multiple packet check */ |
| 1689 | if (urb->actual_length != len + 2) { | 1703 | if (urb->actual_length != len + 2) { |
| 1690 | err("%s: INCOMPLETE OR MULTIPLE PACKET, urb->status=%d, " | 1704 | dev_err(&port->dev, "%s: INCOMPLETE OR MULTIPLE PACKET, " |
| 1691 | "port=%d, opcode=%d, len=%d, actual_length=%d, " | 1705 | "urb->status=%d, port=%d, opcode=%d, len=%d, " |
| 1692 | "status=%d", __func__, status, priv->dp_port_num, | 1706 | "actual_length=%d, status=%d\n", __func__, status, |
| 1693 | opcode, len, urb->actual_length, port_status); | 1707 | priv->dp_port_num, opcode, len, urb->actual_length, |
| 1708 | port_status); | ||
| 1694 | return -1; | 1709 | return -1; |
| 1695 | } | 1710 | } |
| 1696 | 1711 | ||
| @@ -1854,7 +1869,8 @@ static int __init digi_init(void) | |||
| 1854 | retval = usb_register(&digi_driver); | 1869 | retval = usb_register(&digi_driver); |
| 1855 | if (retval) | 1870 | if (retval) |
| 1856 | goto failed_usb_register; | 1871 | goto failed_usb_register; |
| 1857 | info(DRIVER_VERSION ":" DRIVER_DESC); | 1872 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
| 1873 | DRIVER_DESC "\n"); | ||
| 1858 | return 0; | 1874 | return 0; |
| 1859 | failed_usb_register: | 1875 | failed_usb_register: |
| 1860 | usb_serial_deregister(&digi_acceleport_4_device); | 1876 | usb_serial_deregister(&digi_acceleport_4_device); |
diff --git a/drivers/usb/serial/empeg.c b/drivers/usb/serial/empeg.c index 1072e847280f..8a69cce40b6d 100644 --- a/drivers/usb/serial/empeg.c +++ b/drivers/usb/serial/empeg.c | |||
| @@ -416,7 +416,7 @@ static int empeg_startup(struct usb_serial *serial) | |||
| 416 | dbg("%s", __func__); | 416 | dbg("%s", __func__); |
| 417 | 417 | ||
| 418 | if (serial->dev->actconfig->desc.bConfigurationValue != 1) { | 418 | if (serial->dev->actconfig->desc.bConfigurationValue != 1) { |
| 419 | err("active config #%d != 1 ??", | 419 | dev_err(&serial->dev->dev, "active config #%d != 1 ??\n", |
| 420 | serial->dev->actconfig->desc.bConfigurationValue); | 420 | serial->dev->actconfig->desc.bConfigurationValue); |
| 421 | return -ENODEV; | 421 | return -ENODEV; |
| 422 | } | 422 | } |
| @@ -499,15 +499,15 @@ static int __init empeg_init(void) | |||
| 499 | urb = usb_alloc_urb(0, GFP_KERNEL); | 499 | urb = usb_alloc_urb(0, GFP_KERNEL); |
| 500 | write_urb_pool[i] = urb; | 500 | write_urb_pool[i] = urb; |
| 501 | if (urb == NULL) { | 501 | if (urb == NULL) { |
| 502 | err("No more urbs???"); | 502 | printk(KERN_ERR "empeg: No more urbs???\n"); |
| 503 | continue; | 503 | continue; |
| 504 | } | 504 | } |
| 505 | 505 | ||
| 506 | urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE, | 506 | urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE, |
| 507 | GFP_KERNEL); | 507 | GFP_KERNEL); |
| 508 | if (!urb->transfer_buffer) { | 508 | if (!urb->transfer_buffer) { |
| 509 | err("%s - out of memory for urb buffers.", | 509 | printk(KERN_ERR "empeg: %s - out of memory for urb " |
| 510 | __func__); | 510 | "buffers.", __func__); |
| 511 | continue; | 511 | continue; |
| 512 | } | 512 | } |
| 513 | } | 513 | } |
| @@ -519,7 +519,8 @@ static int __init empeg_init(void) | |||
| 519 | if (retval) | 519 | if (retval) |
| 520 | goto failed_usb_register; | 520 | goto failed_usb_register; |
| 521 | 521 | ||
| 522 | info(DRIVER_VERSION ":" DRIVER_DESC); | 522 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
| 523 | DRIVER_DESC "\n"); | ||
| 523 | 524 | ||
| 524 | return 0; | 525 | return 0; |
| 525 | failed_usb_register: | 526 | failed_usb_register: |
diff --git a/drivers/usb/serial/ezusb.c b/drivers/usb/serial/ezusb.c index 711e84f6ed82..3cfc762f5056 100644 --- a/drivers/usb/serial/ezusb.c +++ b/drivers/usb/serial/ezusb.c | |||
| @@ -28,7 +28,8 @@ int ezusb_writememory(struct usb_serial *serial, int address, | |||
| 28 | 28 | ||
| 29 | /* dbg("ezusb_writememory %x, %d", address, length); */ | 29 | /* dbg("ezusb_writememory %x, %d", address, length); */ |
| 30 | if (!serial->dev) { | 30 | if (!serial->dev) { |
| 31 | err("%s - no physical device present, failing.", __func__); | 31 | printk(KERN_ERR "ezusb: %s - no physical device present, " |
| 32 | "failing.\n", __func__); | ||
| 32 | return -ENODEV; | 33 | return -ENODEV; |
| 33 | } | 34 | } |
| 34 | 35 | ||
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index c2ac129557aa..51d7bdea2869 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c | |||
| @@ -578,6 +578,7 @@ static struct usb_device_id id_table_combined [] = { | |||
| 578 | { USB_DEVICE(FALCOM_VID, FALCOM_TWIST_PID) }, | 578 | { USB_DEVICE(FALCOM_VID, FALCOM_TWIST_PID) }, |
| 579 | { USB_DEVICE(FALCOM_VID, FALCOM_SAMBA_PID) }, | 579 | { USB_DEVICE(FALCOM_VID, FALCOM_SAMBA_PID) }, |
| 580 | { USB_DEVICE(FTDI_VID, FTDI_SUUNTO_SPORTS_PID) }, | 580 | { USB_DEVICE(FTDI_VID, FTDI_SUUNTO_SPORTS_PID) }, |
| 581 | { USB_DEVICE(FTDI_VID, FTDI_OCEANIC_PID) }, | ||
| 581 | { USB_DEVICE(TTI_VID, TTI_QL355P_PID) }, | 582 | { USB_DEVICE(TTI_VID, TTI_QL355P_PID) }, |
| 582 | { USB_DEVICE(FTDI_VID, FTDI_RM_CANVIEW_PID) }, | 583 | { USB_DEVICE(FTDI_VID, FTDI_RM_CANVIEW_PID) }, |
| 583 | { USB_DEVICE(BANDB_VID, BANDB_USOTL4_PID) }, | 584 | { USB_DEVICE(BANDB_VID, BANDB_USOTL4_PID) }, |
| @@ -1153,7 +1154,7 @@ static void ftdi_determine_type(struct usb_serial_port *port) | |||
| 1153 | /* Assume its an FT232R */ | 1154 | /* Assume its an FT232R */ |
| 1154 | priv->chip_type = FT232RL; | 1155 | priv->chip_type = FT232RL; |
| 1155 | } | 1156 | } |
| 1156 | info("Detected %s", ftdi_chip_name[priv->chip_type]); | 1157 | dev_info(&udev->dev, "Detected %s\n", ftdi_chip_name[priv->chip_type]); |
| 1157 | } | 1158 | } |
| 1158 | 1159 | ||
| 1159 | 1160 | ||
| @@ -1326,7 +1327,7 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port) | |||
| 1326 | 1327 | ||
| 1327 | priv = kzalloc(sizeof(struct ftdi_private), GFP_KERNEL); | 1328 | priv = kzalloc(sizeof(struct ftdi_private), GFP_KERNEL); |
| 1328 | if (!priv) { | 1329 | if (!priv) { |
| 1329 | err("%s- kmalloc(%Zd) failed.", __func__, | 1330 | dev_err(&port->dev, "%s- kmalloc(%Zd) failed.\n", __func__, |
| 1330 | sizeof(struct ftdi_private)); | 1331 | sizeof(struct ftdi_private)); |
| 1331 | return -ENOMEM; | 1332 | return -ENOMEM; |
| 1332 | } | 1333 | } |
| @@ -1409,7 +1410,8 @@ static int ftdi_jtag_probe(struct usb_serial *serial) | |||
| 1409 | dbg("%s", __func__); | 1410 | dbg("%s", __func__); |
| 1410 | 1411 | ||
| 1411 | if (interface == udev->actconfig->interface[0]) { | 1412 | if (interface == udev->actconfig->interface[0]) { |
| 1412 | info("Ignoring serial port reserved for JTAG"); | 1413 | dev_info(&udev->dev, |
| 1414 | "Ignoring serial port reserved for JTAG\n"); | ||
| 1413 | return -ENODEV; | 1415 | return -ENODEV; |
| 1414 | } | 1416 | } |
| 1415 | 1417 | ||
| @@ -1427,7 +1429,8 @@ static int ftdi_mtxorb_hack_setup(struct usb_serial *serial) | |||
| 1427 | 1429 | ||
| 1428 | if (ep->enabled && ep_desc->wMaxPacketSize == 0) { | 1430 | if (ep->enabled && ep_desc->wMaxPacketSize == 0) { |
| 1429 | ep_desc->wMaxPacketSize = cpu_to_le16(0x40); | 1431 | ep_desc->wMaxPacketSize = cpu_to_le16(0x40); |
| 1430 | info("Fixing invalid wMaxPacketSize on read pipe"); | 1432 | dev_info(&serial->dev->dev, |
| 1433 | "Fixing invalid wMaxPacketSize on read pipe\n"); | ||
| 1431 | } | 1434 | } |
| 1432 | 1435 | ||
| 1433 | return 0; | 1436 | return 0; |
| @@ -1521,8 +1524,9 @@ static int ftdi_open(struct tty_struct *tty, | |||
| 1521 | ftdi_read_bulk_callback, port); | 1524 | ftdi_read_bulk_callback, port); |
| 1522 | result = usb_submit_urb(port->read_urb, GFP_KERNEL); | 1525 | result = usb_submit_urb(port->read_urb, GFP_KERNEL); |
| 1523 | if (result) | 1526 | if (result) |
| 1524 | err("%s - failed submitting read urb, error %d", | 1527 | dev_err(&port->dev, |
| 1525 | __func__, result); | 1528 | "%s - failed submitting read urb, error %d\n", |
| 1529 | __func__, result); | ||
| 1526 | 1530 | ||
| 1527 | 1531 | ||
| 1528 | return result; | 1532 | return result; |
| @@ -1556,7 +1560,7 @@ static void ftdi_close(struct tty_struct *tty, | |||
| 1556 | FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, | 1560 | FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, |
| 1557 | 0, priv->interface, buf, 0, | 1561 | 0, priv->interface, buf, 0, |
| 1558 | WDR_TIMEOUT) < 0) { | 1562 | WDR_TIMEOUT) < 0) { |
| 1559 | err("error from flowcontrol urb"); | 1563 | dev_err(&port->dev, "error from flowcontrol urb\n"); |
| 1560 | } | 1564 | } |
| 1561 | 1565 | ||
| 1562 | /* drop RTS and DTR */ | 1566 | /* drop RTS and DTR */ |
| @@ -1621,14 +1625,15 @@ static int ftdi_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
| 1621 | 1625 | ||
| 1622 | buffer = kmalloc(transfer_size, GFP_ATOMIC); | 1626 | buffer = kmalloc(transfer_size, GFP_ATOMIC); |
| 1623 | if (!buffer) { | 1627 | if (!buffer) { |
| 1624 | err("%s ran out of kernel memory for urb ...", __func__); | 1628 | dev_err(&port->dev, |
| 1629 | "%s ran out of kernel memory for urb ...\n", __func__); | ||
| 1625 | count = -ENOMEM; | 1630 | count = -ENOMEM; |
| 1626 | goto error_no_buffer; | 1631 | goto error_no_buffer; |
| 1627 | } | 1632 | } |
| 1628 | 1633 | ||
| 1629 | urb = usb_alloc_urb(0, GFP_ATOMIC); | 1634 | urb = usb_alloc_urb(0, GFP_ATOMIC); |
| 1630 | if (!urb) { | 1635 | if (!urb) { |
| 1631 | err("%s - no more free urbs", __func__); | 1636 | dev_err(&port->dev, "%s - no more free urbs\n", __func__); |
| 1632 | count = -ENOMEM; | 1637 | count = -ENOMEM; |
| 1633 | goto error_no_urb; | 1638 | goto error_no_urb; |
| 1634 | } | 1639 | } |
| @@ -1672,8 +1677,9 @@ static int ftdi_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
| 1672 | 1677 | ||
| 1673 | status = usb_submit_urb(urb, GFP_ATOMIC); | 1678 | status = usb_submit_urb(urb, GFP_ATOMIC); |
| 1674 | if (status) { | 1679 | if (status) { |
| 1675 | err("%s - failed submitting write urb, error %d", | 1680 | dev_err(&port->dev, |
| 1676 | __func__, status); | 1681 | "%s - failed submitting write urb, error %d\n", |
| 1682 | __func__, status); | ||
| 1677 | count = status; | 1683 | count = status; |
| 1678 | goto error; | 1684 | goto error; |
| 1679 | } else { | 1685 | } else { |
| @@ -1780,7 +1786,8 @@ static int ftdi_chars_in_buffer(struct tty_struct *tty) | |||
| 1780 | buffered = (int)priv->tx_outstanding_bytes; | 1786 | buffered = (int)priv->tx_outstanding_bytes; |
| 1781 | spin_unlock_irqrestore(&priv->tx_lock, flags); | 1787 | spin_unlock_irqrestore(&priv->tx_lock, flags); |
| 1782 | if (buffered < 0) { | 1788 | if (buffered < 0) { |
| 1783 | err("%s outstanding tx bytes is negative!", __func__); | 1789 | dev_err(&port->dev, "%s outstanding tx bytes is negative!\n", |
| 1790 | __func__); | ||
| 1784 | buffered = 0; | 1791 | buffered = 0; |
| 1785 | } | 1792 | } |
| 1786 | return buffered; | 1793 | return buffered; |
| @@ -1796,11 +1803,12 @@ static void ftdi_read_bulk_callback(struct urb *urb) | |||
| 1796 | int status = urb->status; | 1803 | int status = urb->status; |
| 1797 | 1804 | ||
| 1798 | if (urb->number_of_packets > 0) { | 1805 | if (urb->number_of_packets > 0) { |
| 1799 | err("%s transfer_buffer_length %d actual_length %d number of packets %d", | 1806 | dev_err(&port->dev, "%s transfer_buffer_length %d " |
| 1800 | __func__, | 1807 | "actual_length %d number of packets %d\n", __func__, |
| 1801 | urb->transfer_buffer_length, | 1808 | urb->transfer_buffer_length, |
| 1802 | urb->actual_length, urb->number_of_packets); | 1809 | urb->actual_length, urb->number_of_packets); |
| 1803 | err("%s transfer_flags %x ", __func__, urb->transfer_flags); | 1810 | dev_err(&port->dev, "%s transfer_flags %x\n", __func__, |
| 1811 | urb->transfer_flags); | ||
| 1804 | } | 1812 | } |
| 1805 | 1813 | ||
| 1806 | dbg("%s - port %d", __func__, port->number); | 1814 | dbg("%s - port %d", __func__, port->number); |
| @@ -1821,7 +1829,7 @@ static void ftdi_read_bulk_callback(struct urb *urb) | |||
| 1821 | } | 1829 | } |
| 1822 | 1830 | ||
| 1823 | if (urb != port->read_urb) | 1831 | if (urb != port->read_urb) |
| 1824 | err("%s - Not my urb!", __func__); | 1832 | dev_err(&port->dev, "%s - Not my urb!\n", __func__); |
| 1825 | 1833 | ||
| 1826 | if (status) { | 1834 | if (status) { |
| 1827 | /* This will happen at close every time so it is a dbg not an | 1835 | /* This will happen at close every time so it is a dbg not an |
| @@ -1924,7 +1932,8 @@ static void ftdi_process_read(struct work_struct *work) | |||
| 1924 | 1932 | ||
| 1925 | length = min(PKTSZ, urb->actual_length-packet_offset)-2; | 1933 | length = min(PKTSZ, urb->actual_length-packet_offset)-2; |
| 1926 | if (length < 0) { | 1934 | if (length < 0) { |
| 1927 | err("%s - bad packet length: %d", __func__, length+2); | 1935 | dev_err(&port->dev, "%s - bad packet length: %d\n", |
| 1936 | __func__, length+2); | ||
| 1928 | length = 0; | 1937 | length = 0; |
| 1929 | } | 1938 | } |
| 1930 | 1939 | ||
| @@ -2039,8 +2048,9 @@ static void ftdi_process_read(struct work_struct *work) | |||
| 2039 | 2048 | ||
| 2040 | result = usb_submit_urb(port->read_urb, GFP_ATOMIC); | 2049 | result = usb_submit_urb(port->read_urb, GFP_ATOMIC); |
| 2041 | if (result) | 2050 | if (result) |
| 2042 | err("%s - failed resubmitting read urb, error %d", | 2051 | dev_err(&port->dev, |
| 2043 | __func__, result); | 2052 | "%s - failed resubmitting read urb, error %d\n", |
| 2053 | __func__, result); | ||
| 2044 | } | 2054 | } |
| 2045 | out: | 2055 | out: |
| 2046 | tty_kref_put(tty); | 2056 | tty_kref_put(tty); |
| @@ -2069,8 +2079,8 @@ static void ftdi_break_ctl(struct tty_struct *tty, int break_state) | |||
| 2069 | FTDI_SIO_SET_DATA_REQUEST_TYPE, | 2079 | FTDI_SIO_SET_DATA_REQUEST_TYPE, |
| 2070 | urb_value , priv->interface, | 2080 | urb_value , priv->interface, |
| 2071 | buf, 0, WDR_TIMEOUT) < 0) { | 2081 | buf, 0, WDR_TIMEOUT) < 0) { |
| 2072 | err("%s FAILED to enable/disable break state (state was %d)", | 2082 | dev_err(&port->dev, "%s FAILED to enable/disable break state " |
| 2073 | __func__, break_state); | 2083 | "(state was %d)\n", __func__, break_state); |
| 2074 | } | 2084 | } |
| 2075 | 2085 | ||
| 2076 | dbg("%s break state is %d - urb is %d", __func__, | 2086 | dbg("%s break state is %d - urb is %d", __func__, |
| @@ -2142,7 +2152,7 @@ static void ftdi_set_termios(struct tty_struct *tty, | |||
| 2142 | case CS7: urb_value |= 7; dbg("Setting CS7"); break; | 2152 | case CS7: urb_value |= 7; dbg("Setting CS7"); break; |
| 2143 | case CS8: urb_value |= 8; dbg("Setting CS8"); break; | 2153 | case CS8: urb_value |= 8; dbg("Setting CS8"); break; |
| 2144 | default: | 2154 | default: |
| 2145 | err("CSIZE was set but not CS5-CS8"); | 2155 | dev_err(&port->dev, "CSIZE was set but not CS5-CS8\n"); |
| 2146 | } | 2156 | } |
| 2147 | } | 2157 | } |
| 2148 | 2158 | ||
| @@ -2155,7 +2165,8 @@ static void ftdi_set_termios(struct tty_struct *tty, | |||
| 2155 | FTDI_SIO_SET_DATA_REQUEST_TYPE, | 2165 | FTDI_SIO_SET_DATA_REQUEST_TYPE, |
| 2156 | urb_value , priv->interface, | 2166 | urb_value , priv->interface, |
| 2157 | buf, 0, WDR_SHORT_TIMEOUT) < 0) { | 2167 | buf, 0, WDR_SHORT_TIMEOUT) < 0) { |
| 2158 | err("%s FAILED to set databits/stopbits/parity", __func__); | 2168 | dev_err(&port->dev, "%s FAILED to set " |
| 2169 | "databits/stopbits/parity\n", __func__); | ||
| 2159 | } | 2170 | } |
| 2160 | 2171 | ||
| 2161 | /* Now do the baudrate */ | 2172 | /* Now do the baudrate */ |
| @@ -2166,14 +2177,17 @@ static void ftdi_set_termios(struct tty_struct *tty, | |||
| 2166 | FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, | 2177 | FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, |
| 2167 | 0, priv->interface, | 2178 | 0, priv->interface, |
| 2168 | buf, 0, WDR_TIMEOUT) < 0) { | 2179 | buf, 0, WDR_TIMEOUT) < 0) { |
| 2169 | err("%s error from disable flowcontrol urb", __func__); | 2180 | dev_err(&port->dev, |
| 2181 | "%s error from disable flowcontrol urb\n", | ||
| 2182 | __func__); | ||
| 2170 | } | 2183 | } |
| 2171 | /* Drop RTS and DTR */ | 2184 | /* Drop RTS and DTR */ |
| 2172 | clear_mctrl(port, TIOCM_DTR | TIOCM_RTS); | 2185 | clear_mctrl(port, TIOCM_DTR | TIOCM_RTS); |
| 2173 | } else { | 2186 | } else { |
| 2174 | /* set the baudrate determined before */ | 2187 | /* set the baudrate determined before */ |
| 2175 | if (change_speed(tty, port)) | 2188 | if (change_speed(tty, port)) |
| 2176 | err("%s urb failed to set baudrate", __func__); | 2189 | dev_err(&port->dev, "%s urb failed to set baudrate\n", |
| 2190 | __func__); | ||
| 2177 | /* Ensure RTS and DTR are raised when baudrate changed from 0 */ | 2191 | /* Ensure RTS and DTR are raised when baudrate changed from 0 */ |
| 2178 | if (!old_termios || (old_termios->c_cflag & CBAUD) == B0) | 2192 | if (!old_termios || (old_termios->c_cflag & CBAUD) == B0) |
| 2179 | set_mctrl(port, TIOCM_DTR | TIOCM_RTS); | 2193 | set_mctrl(port, TIOCM_DTR | TIOCM_RTS); |
| @@ -2189,7 +2203,8 @@ static void ftdi_set_termios(struct tty_struct *tty, | |||
| 2189 | FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, | 2203 | FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, |
| 2190 | 0 , (FTDI_SIO_RTS_CTS_HS | priv->interface), | 2204 | 0 , (FTDI_SIO_RTS_CTS_HS | priv->interface), |
| 2191 | buf, 0, WDR_TIMEOUT) < 0) { | 2205 | buf, 0, WDR_TIMEOUT) < 0) { |
| 2192 | err("urb failed to set to rts/cts flow control"); | 2206 | dev_err(&port->dev, |
| 2207 | "urb failed to set to rts/cts flow control\n"); | ||
| 2193 | } | 2208 | } |
| 2194 | 2209 | ||
| 2195 | } else { | 2210 | } else { |
| @@ -2220,7 +2235,8 @@ static void ftdi_set_termios(struct tty_struct *tty, | |||
| 2220 | urb_value , (FTDI_SIO_XON_XOFF_HS | 2235 | urb_value , (FTDI_SIO_XON_XOFF_HS |
| 2221 | | priv->interface), | 2236 | | priv->interface), |
| 2222 | buf, 0, WDR_TIMEOUT) < 0) { | 2237 | buf, 0, WDR_TIMEOUT) < 0) { |
| 2223 | err("urb failed to set to xon/xoff flow control"); | 2238 | dev_err(&port->dev, "urb failed to set to " |
| 2239 | "xon/xoff flow control\n"); | ||
| 2224 | } | 2240 | } |
| 2225 | } else { | 2241 | } else { |
| 2226 | /* else clause to only run if cflag ! CRTSCTS and iflag | 2242 | /* else clause to only run if cflag ! CRTSCTS and iflag |
| @@ -2233,7 +2249,8 @@ static void ftdi_set_termios(struct tty_struct *tty, | |||
| 2233 | FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, | 2249 | FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, |
| 2234 | 0, priv->interface, | 2250 | 0, priv->interface, |
| 2235 | buf, 0, WDR_TIMEOUT) < 0) { | 2251 | buf, 0, WDR_TIMEOUT) < 0) { |
| 2236 | err("urb failed to clear flow control"); | 2252 | dev_err(&port->dev, |
| 2253 | "urb failed to clear flow control\n"); | ||
| 2237 | } | 2254 | } |
| 2238 | } | 2255 | } |
| 2239 | 2256 | ||
| @@ -2425,7 +2442,8 @@ static int __init ftdi_init(void) | |||
| 2425 | if (retval) | 2442 | if (retval) |
| 2426 | goto failed_usb_register; | 2443 | goto failed_usb_register; |
| 2427 | 2444 | ||
| 2428 | info(DRIVER_VERSION ":" DRIVER_DESC); | 2445 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
| 2446 | DRIVER_DESC "\n"); | ||
| 2429 | return 0; | 2447 | return 0; |
| 2430 | failed_usb_register: | 2448 | failed_usb_register: |
| 2431 | usb_serial_deregister(&ftdi_sio_device); | 2449 | usb_serial_deregister(&ftdi_sio_device); |
| @@ -2458,5 +2476,5 @@ module_param(vendor, ushort, 0); | |||
| 2458 | MODULE_PARM_DESC(vendor, "User specified vendor ID (default=" | 2476 | MODULE_PARM_DESC(vendor, "User specified vendor ID (default=" |
| 2459 | __MODULE_STRING(FTDI_VID)")"); | 2477 | __MODULE_STRING(FTDI_VID)")"); |
| 2460 | module_param(product, ushort, 0); | 2478 | module_param(product, ushort, 0); |
| 2461 | MODULE_PARM_DESC(vendor, "User specified product ID"); | 2479 | MODULE_PARM_DESC(product, "User specified product ID"); |
| 2462 | 2480 | ||
diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h index 8a5b6df3a976..07a3992abad2 100644 --- a/drivers/usb/serial/ftdi_sio.h +++ b/drivers/usb/serial/ftdi_sio.h | |||
| @@ -628,6 +628,11 @@ | |||
| 628 | #define FTDI_SUUNTO_SPORTS_PID 0xF680 /* Suunto Sports instrument */ | 628 | #define FTDI_SUUNTO_SPORTS_PID 0xF680 /* Suunto Sports instrument */ |
| 629 | 629 | ||
| 630 | /* | 630 | /* |
| 631 | * Oceanic product ids | ||
| 632 | */ | ||
| 633 | #define FTDI_OCEANIC_PID 0xF460 /* Oceanic dive instrument */ | ||
| 634 | |||
| 635 | /* | ||
| 631 | * TTi (Thurlby Thandar Instruments) | 636 | * TTi (Thurlby Thandar Instruments) |
| 632 | */ | 637 | */ |
| 633 | #define TTI_VID 0x103E /* Vendor Id */ | 638 | #define TTI_VID 0x103E /* Vendor Id */ |
diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c index 2ad0569bcf19..8e6a66e38db2 100644 --- a/drivers/usb/serial/garmin_gps.c +++ b/drivers/usb/serial/garmin_gps.c | |||
| @@ -1585,7 +1585,8 @@ static int __init garmin_init(void) | |||
| 1585 | retval = usb_register(&garmin_driver); | 1585 | retval = usb_register(&garmin_driver); |
| 1586 | if (retval) | 1586 | if (retval) |
| 1587 | goto failed_usb_register; | 1587 | goto failed_usb_register; |
| 1588 | info(DRIVER_DESC " " DRIVER_VERSION); | 1588 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
| 1589 | DRIVER_DESC "\n"); | ||
| 1589 | 1590 | ||
| 1590 | return 0; | 1591 | return 0; |
| 1591 | failed_usb_register: | 1592 | failed_usb_register: |
diff --git a/drivers/usb/serial/hp4x.c b/drivers/usb/serial/hp4x.c index ab905869e959..431329275133 100644 --- a/drivers/usb/serial/hp4x.c +++ b/drivers/usb/serial/hp4x.c | |||
| @@ -63,7 +63,8 @@ static int __init hp49gp_init(void) | |||
| 63 | retval = usb_register(&hp49gp_driver); | 63 | retval = usb_register(&hp49gp_driver); |
| 64 | if (retval) | 64 | if (retval) |
| 65 | goto failed_usb_register; | 65 | goto failed_usb_register; |
| 66 | info(DRIVER_DESC " " DRIVER_VERSION); | 66 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
| 67 | DRIVER_DESC "\n"); | ||
| 67 | return 0; | 68 | return 0; |
| 68 | failed_usb_register: | 69 | failed_usb_register: |
| 69 | usb_serial_deregister(&hp49gp_device); | 70 | usb_serial_deregister(&hp49gp_device); |
diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c index 611f97fd62f1..e85c8c0d1ad9 100644 --- a/drivers/usb/serial/io_edgeport.c +++ b/drivers/usb/serial/io_edgeport.c | |||
| @@ -3109,13 +3109,13 @@ static int edge_startup(struct usb_serial *serial) | |||
| 3109 | edge_serial->interrupt_read_urb = | 3109 | edge_serial->interrupt_read_urb = |
| 3110 | usb_alloc_urb(0, GFP_KERNEL); | 3110 | usb_alloc_urb(0, GFP_KERNEL); |
| 3111 | if (!edge_serial->interrupt_read_urb) { | 3111 | if (!edge_serial->interrupt_read_urb) { |
| 3112 | err("out of memory"); | 3112 | dev_err(&dev->dev, "out of memory\n"); |
| 3113 | return -ENOMEM; | 3113 | return -ENOMEM; |
| 3114 | } | 3114 | } |
| 3115 | edge_serial->interrupt_in_buffer = | 3115 | edge_serial->interrupt_in_buffer = |
| 3116 | kmalloc(buffer_size, GFP_KERNEL); | 3116 | kmalloc(buffer_size, GFP_KERNEL); |
| 3117 | if (!edge_serial->interrupt_in_buffer) { | 3117 | if (!edge_serial->interrupt_in_buffer) { |
| 3118 | err("out of memory"); | 3118 | dev_err(&dev->dev, "out of memory\n"); |
| 3119 | usb_free_urb(edge_serial->interrupt_read_urb); | 3119 | usb_free_urb(edge_serial->interrupt_read_urb); |
| 3120 | return -ENOMEM; | 3120 | return -ENOMEM; |
| 3121 | } | 3121 | } |
| @@ -3146,13 +3146,13 @@ static int edge_startup(struct usb_serial *serial) | |||
| 3146 | edge_serial->read_urb = | 3146 | edge_serial->read_urb = |
| 3147 | usb_alloc_urb(0, GFP_KERNEL); | 3147 | usb_alloc_urb(0, GFP_KERNEL); |
| 3148 | if (!edge_serial->read_urb) { | 3148 | if (!edge_serial->read_urb) { |
| 3149 | err("out of memory"); | 3149 | dev_err(&dev->dev, "out of memory\n"); |
| 3150 | return -ENOMEM; | 3150 | return -ENOMEM; |
| 3151 | } | 3151 | } |
| 3152 | edge_serial->bulk_in_buffer = | 3152 | edge_serial->bulk_in_buffer = |
| 3153 | kmalloc(buffer_size, GFP_KERNEL); | 3153 | kmalloc(buffer_size, GFP_KERNEL); |
| 3154 | if (!edge_serial->bulk_in_buffer) { | 3154 | if (!edge_serial->bulk_in_buffer) { |
| 3155 | err("out of memory"); | 3155 | dev_err(&dev->dev, "out of memory\n"); |
| 3156 | usb_free_urb(edge_serial->read_urb); | 3156 | usb_free_urb(edge_serial->read_urb); |
| 3157 | return -ENOMEM; | 3157 | return -ENOMEM; |
| 3158 | } | 3158 | } |
| @@ -3181,7 +3181,8 @@ static int edge_startup(struct usb_serial *serial) | |||
| 3181 | } | 3181 | } |
| 3182 | 3182 | ||
| 3183 | if (!interrupt_in_found || !bulk_in_found || !bulk_out_found) { | 3183 | if (!interrupt_in_found || !bulk_in_found || !bulk_out_found) { |
| 3184 | err("Error - the proper endpoints were not found!"); | 3184 | dev_err(&dev->dev, "Error - the proper endpoints " |
| 3185 | "were not found!\n"); | ||
| 3185 | return -ENODEV; | 3186 | return -ENODEV; |
| 3186 | } | 3187 | } |
| 3187 | 3188 | ||
| @@ -3190,8 +3191,9 @@ static int edge_startup(struct usb_serial *serial) | |||
| 3190 | response = usb_submit_urb(edge_serial->interrupt_read_urb, | 3191 | response = usb_submit_urb(edge_serial->interrupt_read_urb, |
| 3191 | GFP_KERNEL); | 3192 | GFP_KERNEL); |
| 3192 | if (response) | 3193 | if (response) |
| 3193 | err("%s - Error %d submitting control urb", | 3194 | dev_err(&dev->dev, |
| 3194 | __func__, response); | 3195 | "%s - Error %d submitting control urb\n", |
| 3196 | __func__, response); | ||
| 3195 | } | 3197 | } |
| 3196 | return response; | 3198 | return response; |
| 3197 | } | 3199 | } |
| @@ -3253,7 +3255,8 @@ static int __init edgeport_init(void) | |||
| 3253 | if (retval) | 3255 | if (retval) |
| 3254 | goto failed_usb_register; | 3256 | goto failed_usb_register; |
| 3255 | atomic_set(&CmdUrbs, 0); | 3257 | atomic_set(&CmdUrbs, 0); |
| 3256 | info(DRIVER_DESC " " DRIVER_VERSION); | 3258 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
| 3259 | DRIVER_DESC "\n"); | ||
| 3257 | return 0; | 3260 | return 0; |
| 3258 | 3261 | ||
| 3259 | failed_usb_register: | 3262 | failed_usb_register: |
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c index 541dd8e6e7a2..c3cdd00ddc41 100644 --- a/drivers/usb/serial/io_ti.c +++ b/drivers/usb/serial/io_ti.c | |||
| @@ -2978,7 +2978,8 @@ static int __init edgeport_init(void) | |||
| 2978 | retval = usb_register(&io_driver); | 2978 | retval = usb_register(&io_driver); |
| 2979 | if (retval) | 2979 | if (retval) |
| 2980 | goto failed_usb_register; | 2980 | goto failed_usb_register; |
| 2981 | info(DRIVER_DESC " " DRIVER_VERSION); | 2981 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
| 2982 | DRIVER_DESC "\n"); | ||
| 2982 | return 0; | 2983 | return 0; |
| 2983 | failed_usb_register: | 2984 | failed_usb_register: |
| 2984 | usb_serial_deregister(&edgeport_2port_device); | 2985 | usb_serial_deregister(&edgeport_2port_device); |
diff --git a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c index 2affa9c118b2..132be74d2b89 100644 --- a/drivers/usb/serial/ipaq.c +++ b/drivers/usb/serial/ipaq.c | |||
| @@ -608,7 +608,7 @@ static int ipaq_open(struct tty_struct *tty, | |||
| 608 | bytes_out = 0; | 608 | bytes_out = 0; |
| 609 | priv = kmalloc(sizeof(struct ipaq_private), GFP_KERNEL); | 609 | priv = kmalloc(sizeof(struct ipaq_private), GFP_KERNEL); |
| 610 | if (priv == NULL) { | 610 | if (priv == NULL) { |
| 611 | err("%s - Out of memory", __func__); | 611 | dev_err(&port->dev, "%s - Out of memory\n", __func__); |
| 612 | return -ENOMEM; | 612 | return -ENOMEM; |
| 613 | } | 613 | } |
| 614 | usb_set_serial_port_data(port, priv); | 614 | usb_set_serial_port_data(port, priv); |
| @@ -693,8 +693,7 @@ static int ipaq_open(struct tty_struct *tty, | |||
| 693 | } | 693 | } |
| 694 | 694 | ||
| 695 | if (!retries && result) { | 695 | if (!retries && result) { |
| 696 | err("%s - failed doing control urb, error %d", __func__, | 696 | dev_err(&port->dev, "%s - failed doing control urb, error %d\n", __func__, result); |
| 697 | result); | ||
| 698 | goto error; | 697 | goto error; |
| 699 | } | 698 | } |
| 700 | 699 | ||
| @@ -707,8 +706,9 @@ static int ipaq_open(struct tty_struct *tty, | |||
| 707 | 706 | ||
| 708 | result = usb_submit_urb(port->read_urb, GFP_KERNEL); | 707 | result = usb_submit_urb(port->read_urb, GFP_KERNEL); |
| 709 | if (result) { | 708 | if (result) { |
| 710 | err("%s - failed submitting read urb, error %d", | 709 | dev_err(&port->dev, |
| 711 | __func__, result); | 710 | "%s - failed submitting read urb, error %d\n", |
| 711 | __func__, result); | ||
| 712 | goto error; | 712 | goto error; |
| 713 | } | 713 | } |
| 714 | 714 | ||
| @@ -716,7 +716,7 @@ static int ipaq_open(struct tty_struct *tty, | |||
| 716 | 716 | ||
| 717 | enomem: | 717 | enomem: |
| 718 | result = -ENOMEM; | 718 | result = -ENOMEM; |
| 719 | err("%s - Out of memory", __func__); | 719 | dev_err(&port->dev, "%s - Out of memory\n", __func__); |
| 720 | error: | 720 | error: |
| 721 | ipaq_destroy_lists(port); | 721 | ipaq_destroy_lists(port); |
| 722 | kfree(priv); | 722 | kfree(priv); |
| @@ -781,8 +781,9 @@ static void ipaq_read_bulk_callback(struct urb *urb) | |||
| 781 | ipaq_read_bulk_callback, port); | 781 | ipaq_read_bulk_callback, port); |
| 782 | result = usb_submit_urb(port->read_urb, GFP_ATOMIC); | 782 | result = usb_submit_urb(port->read_urb, GFP_ATOMIC); |
| 783 | if (result) | 783 | if (result) |
| 784 | err("%s - failed resubmitting read urb, error %d", | 784 | dev_err(&port->dev, |
| 785 | __func__, result); | 785 | "%s - failed resubmitting read urb, error %d\n", |
| 786 | __func__, result); | ||
| 786 | return; | 787 | return; |
| 787 | } | 788 | } |
| 788 | 789 | ||
| @@ -847,7 +848,8 @@ static int ipaq_write_bulk(struct usb_serial_port *port, | |||
| 847 | spin_unlock_irqrestore(&write_list_lock, flags); | 848 | spin_unlock_irqrestore(&write_list_lock, flags); |
| 848 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); | 849 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); |
| 849 | if (result) | 850 | if (result) |
| 850 | err("%s - failed submitting write urb, error %d", | 851 | dev_err(&port->dev, |
| 852 | "%s - failed submitting write urb, error %d\n", | ||
| 851 | __func__, result); | 853 | __func__, result); |
| 852 | } else { | 854 | } else { |
| 853 | spin_unlock_irqrestore(&write_list_lock, flags); | 855 | spin_unlock_irqrestore(&write_list_lock, flags); |
| @@ -909,8 +911,9 @@ static void ipaq_write_bulk_callback(struct urb *urb) | |||
| 909 | spin_unlock_irqrestore(&write_list_lock, flags); | 911 | spin_unlock_irqrestore(&write_list_lock, flags); |
| 910 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); | 912 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); |
| 911 | if (result) | 913 | if (result) |
| 912 | err("%s - failed submitting write urb, error %d", | 914 | dev_err(&port->dev, |
| 913 | __func__, result); | 915 | "%s - failed submitting write urb, error %d\n", |
| 916 | __func__, result); | ||
| 914 | } else { | 917 | } else { |
| 915 | priv->active = 0; | 918 | priv->active = 0; |
| 916 | spin_unlock_irqrestore(&write_list_lock, flags); | 919 | spin_unlock_irqrestore(&write_list_lock, flags); |
| @@ -957,7 +960,7 @@ static int ipaq_startup(struct usb_serial *serial) | |||
| 957 | { | 960 | { |
| 958 | dbg("%s", __func__); | 961 | dbg("%s", __func__); |
| 959 | if (serial->dev->actconfig->desc.bConfigurationValue != 1) { | 962 | if (serial->dev->actconfig->desc.bConfigurationValue != 1) { |
| 960 | err("active config #%d != 1 ??", | 963 | dev_err(&serial->dev->dev, "active config #%d != 1 ??\n", |
| 961 | serial->dev->actconfig->desc.bConfigurationValue); | 964 | serial->dev->actconfig->desc.bConfigurationValue); |
| 962 | return -ENODEV; | 965 | return -ENODEV; |
| 963 | } | 966 | } |
| @@ -976,7 +979,6 @@ static int __init ipaq_init(void) | |||
| 976 | retval = usb_serial_register(&ipaq_device); | 979 | retval = usb_serial_register(&ipaq_device); |
| 977 | if (retval) | 980 | if (retval) |
| 978 | goto failed_usb_serial_register; | 981 | goto failed_usb_serial_register; |
| 979 | info(DRIVER_DESC " " DRIVER_VERSION); | ||
| 980 | if (vendor) { | 982 | if (vendor) { |
| 981 | ipaq_id_table[0].idVendor = vendor; | 983 | ipaq_id_table[0].idVendor = vendor; |
| 982 | ipaq_id_table[0].idProduct = product; | 984 | ipaq_id_table[0].idProduct = product; |
| @@ -985,6 +987,8 @@ static int __init ipaq_init(void) | |||
| 985 | if (retval) | 987 | if (retval) |
| 986 | goto failed_usb_register; | 988 | goto failed_usb_register; |
| 987 | 989 | ||
| 990 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" | ||
| 991 | DRIVER_DESC "\n"); | ||
| 988 | return 0; | 992 | return 0; |
| 989 | failed_usb_register: | 993 | failed_usb_register: |
| 990 | usb_serial_deregister(&ipaq_device); | 994 | usb_serial_deregister(&ipaq_device); |
diff --git a/drivers/usb/serial/ipw.c b/drivers/usb/serial/ipw.c index 480cac27d646..3ac59a8a980f 100644 --- a/drivers/usb/serial/ipw.c +++ b/drivers/usb/serial/ipw.c | |||
| @@ -485,7 +485,8 @@ static int usb_ipw_init(void) | |||
| 485 | usb_serial_deregister(&ipw_device); | 485 | usb_serial_deregister(&ipw_device); |
| 486 | return retval; | 486 | return retval; |
| 487 | } | 487 | } |
| 488 | info(DRIVER_DESC " " DRIVER_VERSION); | 488 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
| 489 | DRIVER_DESC "\n"); | ||
| 489 | return 0; | 490 | return 0; |
| 490 | } | 491 | } |
| 491 | 492 | ||
diff --git a/drivers/usb/serial/ir-usb.c b/drivers/usb/serial/ir-usb.c index 45d4043e04ab..b679a556b98d 100644 --- a/drivers/usb/serial/ir-usb.c +++ b/drivers/usb/serial/ir-usb.c | |||
| @@ -602,7 +602,8 @@ static int __init ir_init(void) | |||
| 602 | if (retval) | 602 | if (retval) |
| 603 | goto failed_usb_register; | 603 | goto failed_usb_register; |
| 604 | 604 | ||
| 605 | info(DRIVER_DESC " " DRIVER_VERSION); | 605 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
| 606 | DRIVER_DESC "\n"); | ||
| 606 | 607 | ||
| 607 | return 0; | 608 | return 0; |
| 608 | 609 | ||
diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c index 53710aa7eadd..e320972cb227 100644 --- a/drivers/usb/serial/iuu_phoenix.c +++ b/drivers/usb/serial/iuu_phoenix.c | |||
| @@ -1185,7 +1185,8 @@ static int __init iuu_init(void) | |||
| 1185 | retval = usb_register(&iuu_driver); | 1185 | retval = usb_register(&iuu_driver); |
| 1186 | if (retval) | 1186 | if (retval) |
| 1187 | goto failed_usb_register; | 1187 | goto failed_usb_register; |
| 1188 | info(DRIVER_DESC " " DRIVER_VERSION); | 1188 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
| 1189 | DRIVER_DESC "\n"); | ||
| 1189 | return 0; | 1190 | return 0; |
| 1190 | failed_usb_register: | 1191 | failed_usb_register: |
| 1191 | usb_serial_deregister(&iuu_device); | 1192 | usb_serial_deregister(&iuu_device); |
diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c index 15447af48691..9878c0fb3859 100644 --- a/drivers/usb/serial/keyspan.c +++ b/drivers/usb/serial/keyspan.c | |||
| @@ -217,7 +217,8 @@ static int __init keyspan_init(void) | |||
| 217 | if (retval) | 217 | if (retval) |
| 218 | goto failed_usb_register; | 218 | goto failed_usb_register; |
| 219 | 219 | ||
| 220 | info(DRIVER_VERSION ":" DRIVER_DESC); | 220 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
| 221 | DRIVER_DESC "\n"); | ||
| 221 | 222 | ||
| 222 | return 0; | 223 | return 0; |
| 223 | failed_usb_register: | 224 | failed_usb_register: |
diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c index 99e9a14c5bf6..bf1ae247da66 100644 --- a/drivers/usb/serial/keyspan_pda.c +++ b/drivers/usb/serial/keyspan_pda.c | |||
| @@ -742,11 +742,13 @@ static int keyspan_pda_fake_startup(struct usb_serial *serial) | |||
| 742 | fw_name = "keyspan_pda/xircom_pgs.fw"; | 742 | fw_name = "keyspan_pda/xircom_pgs.fw"; |
| 743 | #endif | 743 | #endif |
| 744 | else { | 744 | else { |
| 745 | err("%s: unknown vendor, aborting.", __func__); | 745 | dev_err(&serial->dev->dev, "%s: unknown vendor, aborting.\n", |
| 746 | __func__); | ||
| 746 | return -ENODEV; | 747 | return -ENODEV; |
| 747 | } | 748 | } |
| 748 | if (request_ihex_firmware(&fw, fw_name, &serial->dev->dev)) { | 749 | if (request_ihex_firmware(&fw, fw_name, &serial->dev->dev)) { |
| 749 | err("failed to load firmware \"%s\"\n", fw_name); | 750 | dev_err(&serial->dev->dev, "failed to load firmware \"%s\"\n", |
| 751 | fw_name); | ||
| 750 | return -ENOENT; | 752 | return -ENOENT; |
| 751 | } | 753 | } |
| 752 | record = (const struct ihex_binrec *)fw->data; | 754 | record = (const struct ihex_binrec *)fw->data; |
| @@ -756,10 +758,10 @@ static int keyspan_pda_fake_startup(struct usb_serial *serial) | |||
| 756 | (unsigned char *)record->data, | 758 | (unsigned char *)record->data, |
| 757 | be16_to_cpu(record->len), 0xa0); | 759 | be16_to_cpu(record->len), 0xa0); |
| 758 | if (response < 0) { | 760 | if (response < 0) { |
| 759 | err("ezusb_writememory failed for Keyspan PDA " | 761 | dev_err(&serial->dev->dev, "ezusb_writememory failed " |
| 760 | "firmware (%d %04X %p %d)", | 762 | "for Keyspan PDA firmware (%d %04X %p %d)\n", |
| 761 | response, be32_to_cpu(record->addr), | 763 | response, be32_to_cpu(record->addr), |
| 762 | record->data, be16_to_cpu(record->len)); | 764 | record->data, be16_to_cpu(record->len)); |
| 763 | break; | 765 | break; |
| 764 | } | 766 | } |
| 765 | record = ihex_next_binrec(record); | 767 | record = ihex_next_binrec(record); |
| @@ -874,7 +876,8 @@ static int __init keyspan_pda_init(void) | |||
| 874 | retval = usb_register(&keyspan_pda_driver); | 876 | retval = usb_register(&keyspan_pda_driver); |
| 875 | if (retval) | 877 | if (retval) |
| 876 | goto failed_usb_register; | 878 | goto failed_usb_register; |
| 877 | info(DRIVER_DESC " " DRIVER_VERSION); | 879 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
| 880 | DRIVER_DESC "\n"); | ||
| 878 | return 0; | 881 | return 0; |
| 879 | failed_usb_register: | 882 | failed_usb_register: |
| 880 | #ifdef XIRCOM | 883 | #ifdef XIRCOM |
diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c index ff3a07f5102f..dc36a052766f 100644 --- a/drivers/usb/serial/kl5kusb105.c +++ b/drivers/usb/serial/kl5kusb105.c | |||
| @@ -182,12 +182,12 @@ static int klsi_105_chg_port_settings(struct usb_serial_port *port, | |||
| 182 | sizeof(struct klsi_105_port_settings), | 182 | sizeof(struct klsi_105_port_settings), |
| 183 | KLSI_TIMEOUT); | 183 | KLSI_TIMEOUT); |
| 184 | if (rc < 0) | 184 | if (rc < 0) |
| 185 | err("Change port settings failed (error = %d)", rc); | 185 | dev_err(&port->dev, |
| 186 | info("%s - %d byte block, baudrate %x, databits %d, u1 %d, u2 %d", | 186 | "Change port settings failed (error = %d)\n", rc); |
| 187 | __func__, | 187 | dev_info(&port->serial->dev->dev, |
| 188 | settings->pktlen, | 188 | "%d byte block, baudrate %x, databits %d, u1 %d, u2 %d\n", |
| 189 | settings->baudrate, settings->databits, | 189 | settings->pktlen, settings->baudrate, settings->databits, |
| 190 | settings->unknown1, settings->unknown2); | 190 | settings->unknown1, settings->unknown2); |
| 191 | return rc; | 191 | return rc; |
| 192 | } /* klsi_105_chg_port_settings */ | 192 | } /* klsi_105_chg_port_settings */ |
| 193 | 193 | ||
| @@ -215,7 +215,7 @@ static int klsi_105_get_line_state(struct usb_serial_port *port, | |||
| 215 | __u8 status_buf[KLSI_STATUSBUF_LEN] = { -1, -1}; | 215 | __u8 status_buf[KLSI_STATUSBUF_LEN] = { -1, -1}; |
| 216 | __u16 status; | 216 | __u16 status; |
| 217 | 217 | ||
| 218 | info("%s - sending SIO Poll request", __func__); | 218 | dev_info(&port->serial->dev->dev, "sending SIO Poll request\n"); |
| 219 | rc = usb_control_msg(port->serial->dev, | 219 | rc = usb_control_msg(port->serial->dev, |
| 220 | usb_rcvctrlpipe(port->serial->dev, 0), | 220 | usb_rcvctrlpipe(port->serial->dev, 0), |
| 221 | KL5KUSB105A_SIO_POLL, | 221 | KL5KUSB105A_SIO_POLL, |
| @@ -226,12 +226,13 @@ static int klsi_105_get_line_state(struct usb_serial_port *port, | |||
| 226 | 10000 | 226 | 10000 |
| 227 | ); | 227 | ); |
| 228 | if (rc < 0) | 228 | if (rc < 0) |
| 229 | err("Reading line status failed (error = %d)", rc); | 229 | dev_err(&port->dev, "Reading line status failed (error = %d)\n", |
| 230 | rc); | ||
| 230 | else { | 231 | else { |
| 231 | status = get_unaligned_le16(status_buf); | 232 | status = get_unaligned_le16(status_buf); |
| 232 | 233 | ||
| 233 | info("%s - read status %x %x", __func__, | 234 | dev_info(&port->serial->dev->dev, "read status %x %x", |
| 234 | status_buf[0], status_buf[1]); | 235 | status_buf[0], status_buf[1]); |
| 235 | 236 | ||
| 236 | *line_state_p = klsi_105_status2linestate(status); | 237 | *line_state_p = klsi_105_status2linestate(status); |
| 237 | } | 238 | } |
| @@ -280,15 +281,16 @@ static int klsi_105_startup(struct usb_serial *serial) | |||
| 280 | 281 | ||
| 281 | priv->write_urb_pool[j] = urb; | 282 | priv->write_urb_pool[j] = urb; |
| 282 | if (urb == NULL) { | 283 | if (urb == NULL) { |
| 283 | err("No more urbs???"); | 284 | dev_err(&serial->dev->dev, "No more urbs???\n"); |
| 284 | goto err_cleanup; | 285 | goto err_cleanup; |
| 285 | } | 286 | } |
| 286 | 287 | ||
| 287 | urb->transfer_buffer = | 288 | urb->transfer_buffer = |
| 288 | kmalloc(URB_TRANSFER_BUFFER_SIZE, GFP_KERNEL); | 289 | kmalloc(URB_TRANSFER_BUFFER_SIZE, GFP_KERNEL); |
| 289 | if (!urb->transfer_buffer) { | 290 | if (!urb->transfer_buffer) { |
| 290 | err("%s - out of memory for urb buffers.", | 291 | dev_err(&serial->dev->dev, |
| 291 | __func__); | 292 | "%s - out of memory for urb buffers.\n", |
| 293 | __func__); | ||
| 292 | goto err_cleanup; | 294 | goto err_cleanup; |
| 293 | } | 295 | } |
| 294 | } | 296 | } |
| @@ -409,7 +411,8 @@ static int klsi_105_open(struct tty_struct *tty, | |||
| 409 | 411 | ||
| 410 | rc = usb_submit_urb(port->read_urb, GFP_KERNEL); | 412 | rc = usb_submit_urb(port->read_urb, GFP_KERNEL); |
| 411 | if (rc) { | 413 | if (rc) { |
| 412 | err("%s - failed submitting read urb, error %d", __func__, rc); | 414 | dev_err(&port->dev, "%s - failed submitting read urb, " |
| 415 | "error %d\n", __func__, rc); | ||
| 413 | retval = rc; | 416 | retval = rc; |
| 414 | goto exit; | 417 | goto exit; |
| 415 | } | 418 | } |
| @@ -424,7 +427,7 @@ static int klsi_105_open(struct tty_struct *tty, | |||
| 424 | 0, | 427 | 0, |
| 425 | KLSI_TIMEOUT); | 428 | KLSI_TIMEOUT); |
| 426 | if (rc < 0) { | 429 | if (rc < 0) { |
| 427 | err("Enabling read failed (error = %d)", rc); | 430 | dev_err(&port->dev, "Enabling read failed (error = %d)\n", rc); |
| 428 | retval = rc; | 431 | retval = rc; |
| 429 | } else | 432 | } else |
| 430 | dbg("%s - enabled reading", __func__); | 433 | dbg("%s - enabled reading", __func__); |
| @@ -464,7 +467,8 @@ static void klsi_105_close(struct tty_struct *tty, | |||
| 464 | NULL, 0, | 467 | NULL, 0, |
| 465 | KLSI_TIMEOUT); | 468 | KLSI_TIMEOUT); |
| 466 | if (rc < 0) | 469 | if (rc < 0) |
| 467 | err("Disabling read failed (error = %d)", rc); | 470 | dev_err(&port->dev, |
| 471 | "Disabling read failed (error = %d)\n", rc); | ||
| 468 | } | 472 | } |
| 469 | mutex_unlock(&port->serial->disc_mutex); | 473 | mutex_unlock(&port->serial->disc_mutex); |
| 470 | 474 | ||
| @@ -475,8 +479,9 @@ static void klsi_105_close(struct tty_struct *tty, | |||
| 475 | /* FIXME */ | 479 | /* FIXME */ |
| 476 | /* wgg - do I need this? I think so. */ | 480 | /* wgg - do I need this? I think so. */ |
| 477 | usb_kill_urb(port->interrupt_in_urb); | 481 | usb_kill_urb(port->interrupt_in_urb); |
| 478 | info("kl5kusb105 port stats: %ld bytes in, %ld bytes out", | 482 | dev_info(&port->serial->dev->dev, |
| 479 | priv->bytes_in, priv->bytes_out); | 483 | "port stats: %ld bytes in, %ld bytes out\n", |
| 484 | priv->bytes_in, priv->bytes_out); | ||
| 480 | } /* klsi_105_close */ | 485 | } /* klsi_105_close */ |
| 481 | 486 | ||
| 482 | 487 | ||
| @@ -522,7 +527,9 @@ static int klsi_105_write(struct tty_struct *tty, | |||
| 522 | urb->transfer_buffer = | 527 | urb->transfer_buffer = |
| 523 | kmalloc(URB_TRANSFER_BUFFER_SIZE, GFP_ATOMIC); | 528 | kmalloc(URB_TRANSFER_BUFFER_SIZE, GFP_ATOMIC); |
| 524 | if (urb->transfer_buffer == NULL) { | 529 | if (urb->transfer_buffer == NULL) { |
| 525 | err("%s - no more kernel memory...", __func__); | 530 | dev_err(&port->dev, |
| 531 | "%s - no more kernel memory...\n", | ||
| 532 | __func__); | ||
| 526 | goto exit; | 533 | goto exit; |
| 527 | } | 534 | } |
| 528 | } | 535 | } |
| @@ -549,8 +556,9 @@ static int klsi_105_write(struct tty_struct *tty, | |||
| 549 | /* send the data out the bulk port */ | 556 | /* send the data out the bulk port */ |
| 550 | result = usb_submit_urb(urb, GFP_ATOMIC); | 557 | result = usb_submit_urb(urb, GFP_ATOMIC); |
| 551 | if (result) { | 558 | if (result) { |
| 552 | err("%s - failed submitting write urb, error %d", | 559 | dev_err(&port->dev, |
| 553 | __func__, result); | 560 | "%s - failed submitting write urb, error %d\n", |
| 561 | __func__, result); | ||
| 554 | goto exit; | 562 | goto exit; |
| 555 | } | 563 | } |
| 556 | buf += size; | 564 | buf += size; |
| @@ -694,8 +702,9 @@ static void klsi_105_read_bulk_callback(struct urb *urb) | |||
| 694 | port); | 702 | port); |
| 695 | rc = usb_submit_urb(port->read_urb, GFP_ATOMIC); | 703 | rc = usb_submit_urb(port->read_urb, GFP_ATOMIC); |
| 696 | if (rc) | 704 | if (rc) |
| 697 | err("%s - failed resubmitting read urb, error %d", | 705 | dev_err(&port->dev, |
| 698 | __func__, rc); | 706 | "%s - failed resubmitting read urb, error %d\n", |
| 707 | __func__, rc); | ||
| 699 | } /* klsi_105_read_bulk_callback */ | 708 | } /* klsi_105_read_bulk_callback */ |
| 700 | 709 | ||
| 701 | 710 | ||
| @@ -799,7 +808,8 @@ static void klsi_105_set_termios(struct tty_struct *tty, | |||
| 799 | priv->cfg.databits = kl5kusb105a_dtb_8; | 808 | priv->cfg.databits = kl5kusb105a_dtb_8; |
| 800 | break; | 809 | break; |
| 801 | default: | 810 | default: |
| 802 | err("CSIZE was not CS5-CS8, using default of 8"); | 811 | dev_err(&port->dev, |
| 812 | "CSIZE was not CS5-CS8, using default of 8\n"); | ||
| 803 | priv->cfg.databits = kl5kusb105a_dtb_8; | 813 | priv->cfg.databits = kl5kusb105a_dtb_8; |
| 804 | break; | 814 | break; |
| 805 | } | 815 | } |
| @@ -886,7 +896,8 @@ static int klsi_105_tiocmget(struct tty_struct *tty, struct file *file) | |||
| 886 | 896 | ||
| 887 | rc = klsi_105_get_line_state(port, &line_state); | 897 | rc = klsi_105_get_line_state(port, &line_state); |
| 888 | if (rc < 0) { | 898 | if (rc < 0) { |
| 889 | err("Reading line control failed (error = %d)", rc); | 899 | dev_err(&port->dev, |
| 900 | "Reading line control failed (error = %d)\n", rc); | ||
| 890 | /* better return value? EAGAIN? */ | 901 | /* better return value? EAGAIN? */ |
| 891 | return rc; | 902 | return rc; |
| 892 | } | 903 | } |
| @@ -944,8 +955,9 @@ static void klsi_105_unthrottle(struct tty_struct *tty) | |||
| 944 | port->read_urb->dev = port->serial->dev; | 955 | port->read_urb->dev = port->serial->dev; |
| 945 | result = usb_submit_urb(port->read_urb, GFP_ATOMIC); | 956 | result = usb_submit_urb(port->read_urb, GFP_ATOMIC); |
| 946 | if (result) | 957 | if (result) |
| 947 | err("%s - failed submitting read urb, error %d", __func__, | 958 | dev_err(&port->dev, |
| 948 | result); | 959 | "%s - failed submitting read urb, error %d\n", |
| 960 | __func__, result); | ||
| 949 | } | 961 | } |
| 950 | 962 | ||
| 951 | 963 | ||
| @@ -960,7 +972,8 @@ static int __init klsi_105_init(void) | |||
| 960 | if (retval) | 972 | if (retval) |
| 961 | goto failed_usb_register; | 973 | goto failed_usb_register; |
| 962 | 974 | ||
| 963 | info(DRIVER_DESC " " DRIVER_VERSION); | 975 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
| 976 | DRIVER_DESC "\n"); | ||
| 964 | return 0; | 977 | return 0; |
| 965 | failed_usb_register: | 978 | failed_usb_register: |
| 966 | usb_serial_deregister(&kl5kusb105d_device); | 979 | usb_serial_deregister(&kl5kusb105d_device); |
diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c index cfcf37c2b957..6286baad9392 100644 --- a/drivers/usb/serial/kobil_sct.c +++ b/drivers/usb/serial/kobil_sct.c | |||
| @@ -744,8 +744,8 @@ static int __init kobil_init(void) | |||
| 744 | if (retval) | 744 | if (retval) |
| 745 | goto failed_usb_register; | 745 | goto failed_usb_register; |
| 746 | 746 | ||
| 747 | info(DRIVER_VERSION " " DRIVER_AUTHOR); | 747 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
| 748 | info(DRIVER_DESC); | 748 | DRIVER_DESC "\n"); |
| 749 | 749 | ||
| 750 | return 0; | 750 | return 0; |
| 751 | failed_usb_register: | 751 | failed_usb_register: |
diff --git a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c index 9b2cef81cde0..07710cf31d0d 100644 --- a/drivers/usb/serial/mct_u232.c +++ b/drivers/usb/serial/mct_u232.c | |||
| @@ -246,7 +246,8 @@ static int mct_u232_set_baud_rate(struct tty_struct *tty, | |||
| 246 | 0, 0, &divisor, MCT_U232_SET_BAUD_RATE_SIZE, | 246 | 0, 0, &divisor, MCT_U232_SET_BAUD_RATE_SIZE, |
| 247 | WDR_TIMEOUT); | 247 | WDR_TIMEOUT); |
| 248 | if (rc < 0) /*FIXME: What value speed results */ | 248 | if (rc < 0) /*FIXME: What value speed results */ |
| 249 | err("Set BAUD RATE %d failed (error = %d)", value, rc); | 249 | dev_err(&port->dev, "Set BAUD RATE %d failed (error = %d)\n", |
| 250 | value, rc); | ||
| 250 | else | 251 | else |
| 251 | tty_encode_baud_rate(tty, speed, speed); | 252 | tty_encode_baud_rate(tty, speed, speed); |
| 252 | dbg("set_baud_rate: value: 0x%x, divisor: 0x%x", value, divisor); | 253 | dbg("set_baud_rate: value: 0x%x, divisor: 0x%x", value, divisor); |
| @@ -274,8 +275,9 @@ static int mct_u232_set_baud_rate(struct tty_struct *tty, | |||
| 274 | 0, 0, &zero_byte, MCT_U232_SET_UNKNOWN1_SIZE, | 275 | 0, 0, &zero_byte, MCT_U232_SET_UNKNOWN1_SIZE, |
| 275 | WDR_TIMEOUT); | 276 | WDR_TIMEOUT); |
| 276 | if (rc < 0) | 277 | if (rc < 0) |
| 277 | err("Sending USB device request code %d failed (error = %d)", | 278 | dev_err(&port->dev, "Sending USB device request code %d " |
| 278 | MCT_U232_SET_UNKNOWN1_REQUEST, rc); | 279 | "failed (error = %d)\n", MCT_U232_SET_UNKNOWN1_REQUEST, |
| 280 | rc); | ||
| 279 | 281 | ||
| 280 | if (port && C_CRTSCTS(tty)) | 282 | if (port && C_CRTSCTS(tty)) |
| 281 | cts_enable_byte = 1; | 283 | cts_enable_byte = 1; |
| @@ -288,8 +290,8 @@ static int mct_u232_set_baud_rate(struct tty_struct *tty, | |||
| 288 | 0, 0, &cts_enable_byte, MCT_U232_SET_CTS_SIZE, | 290 | 0, 0, &cts_enable_byte, MCT_U232_SET_CTS_SIZE, |
| 289 | WDR_TIMEOUT); | 291 | WDR_TIMEOUT); |
| 290 | if (rc < 0) | 292 | if (rc < 0) |
| 291 | err("Sending USB device request code %d failed (error = %d)", | 293 | dev_err(&port->dev, "Sending USB device request code %d " |
| 292 | MCT_U232_SET_CTS_REQUEST, rc); | 294 | "failed (error = %d)\n", MCT_U232_SET_CTS_REQUEST, rc); |
| 293 | 295 | ||
| 294 | return rc; | 296 | return rc; |
| 295 | } /* mct_u232_set_baud_rate */ | 297 | } /* mct_u232_set_baud_rate */ |
| @@ -303,7 +305,8 @@ static int mct_u232_set_line_ctrl(struct usb_serial *serial, unsigned char lcr) | |||
| 303 | 0, 0, &lcr, MCT_U232_SET_LINE_CTRL_SIZE, | 305 | 0, 0, &lcr, MCT_U232_SET_LINE_CTRL_SIZE, |
| 304 | WDR_TIMEOUT); | 306 | WDR_TIMEOUT); |
| 305 | if (rc < 0) | 307 | if (rc < 0) |
| 306 | err("Set LINE CTRL 0x%x failed (error = %d)", lcr, rc); | 308 | dev_err(&serial->dev->dev, |
| 309 | "Set LINE CTRL 0x%x failed (error = %d)\n", lcr, rc); | ||
| 307 | dbg("set_line_ctrl: 0x%x", lcr); | 310 | dbg("set_line_ctrl: 0x%x", lcr); |
| 308 | return rc; | 311 | return rc; |
| 309 | } /* mct_u232_set_line_ctrl */ | 312 | } /* mct_u232_set_line_ctrl */ |
| @@ -325,7 +328,8 @@ static int mct_u232_set_modem_ctrl(struct usb_serial *serial, | |||
| 325 | 0, 0, &mcr, MCT_U232_SET_MODEM_CTRL_SIZE, | 328 | 0, 0, &mcr, MCT_U232_SET_MODEM_CTRL_SIZE, |
| 326 | WDR_TIMEOUT); | 329 | WDR_TIMEOUT); |
| 327 | if (rc < 0) | 330 | if (rc < 0) |
| 328 | err("Set MODEM CTRL 0x%x failed (error = %d)", mcr, rc); | 331 | dev_err(&serial->dev->dev, |
| 332 | "Set MODEM CTRL 0x%x failed (error = %d)\n", mcr, rc); | ||
| 329 | dbg("set_modem_ctrl: state=0x%x ==> mcr=0x%x", control_state, mcr); | 333 | dbg("set_modem_ctrl: state=0x%x ==> mcr=0x%x", control_state, mcr); |
| 330 | 334 | ||
| 331 | return rc; | 335 | return rc; |
| @@ -341,7 +345,8 @@ static int mct_u232_get_modem_stat(struct usb_serial *serial, | |||
| 341 | 0, 0, msr, MCT_U232_GET_MODEM_STAT_SIZE, | 345 | 0, 0, msr, MCT_U232_GET_MODEM_STAT_SIZE, |
| 342 | WDR_TIMEOUT); | 346 | WDR_TIMEOUT); |
| 343 | if (rc < 0) { | 347 | if (rc < 0) { |
| 344 | err("Get MODEM STATus failed (error = %d)", rc); | 348 | dev_err(&serial->dev->dev, |
| 349 | "Get MODEM STATus failed (error = %d)\n", rc); | ||
| 345 | *msr = 0; | 350 | *msr = 0; |
| 346 | } | 351 | } |
| 347 | dbg("get_modem_stat: 0x%x", *msr); | 352 | dbg("get_modem_stat: 0x%x", *msr); |
| @@ -470,8 +475,9 @@ static int mct_u232_open(struct tty_struct *tty, | |||
| 470 | port->read_urb->dev = port->serial->dev; | 475 | port->read_urb->dev = port->serial->dev; |
| 471 | retval = usb_submit_urb(port->read_urb, GFP_KERNEL); | 476 | retval = usb_submit_urb(port->read_urb, GFP_KERNEL); |
| 472 | if (retval) { | 477 | if (retval) { |
| 473 | err("usb_submit_urb(read bulk) failed pipe 0x%x err %d", | 478 | dev_err(&port->dev, |
| 474 | port->read_urb->pipe, retval); | 479 | "usb_submit_urb(read bulk) failed pipe 0x%x err %d\n", |
| 480 | port->read_urb->pipe, retval); | ||
| 475 | goto error; | 481 | goto error; |
| 476 | } | 482 | } |
| 477 | 483 | ||
| @@ -479,8 +485,9 @@ static int mct_u232_open(struct tty_struct *tty, | |||
| 479 | retval = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); | 485 | retval = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); |
| 480 | if (retval) { | 486 | if (retval) { |
| 481 | usb_kill_urb(port->read_urb); | 487 | usb_kill_urb(port->read_urb); |
| 482 | err(" usb_submit_urb(read int) failed pipe 0x%x err %d", | 488 | dev_err(&port->dev, |
| 483 | port->interrupt_in_urb->pipe, retval); | 489 | "usb_submit_urb(read int) failed pipe 0x%x err %d", |
| 490 | port->interrupt_in_urb->pipe, retval); | ||
| 484 | goto error; | 491 | goto error; |
| 485 | } | 492 | } |
| 486 | return 0; | 493 | return 0; |
| @@ -612,8 +619,9 @@ static void mct_u232_read_int_callback(struct urb *urb) | |||
| 612 | exit: | 619 | exit: |
| 613 | retval = usb_submit_urb(urb, GFP_ATOMIC); | 620 | retval = usb_submit_urb(urb, GFP_ATOMIC); |
| 614 | if (retval) | 621 | if (retval) |
| 615 | err("%s - usb_submit_urb failed with result %d", | 622 | dev_err(&port->dev, |
| 616 | __func__, retval); | 623 | "%s - usb_submit_urb failed with result %d\n", |
| 624 | __func__, retval); | ||
| 617 | } /* mct_u232_read_int_callback */ | 625 | } /* mct_u232_read_int_callback */ |
| 618 | 626 | ||
| 619 | static void mct_u232_set_termios(struct tty_struct *tty, | 627 | static void mct_u232_set_termios(struct tty_struct *tty, |
| @@ -680,7 +688,8 @@ static void mct_u232_set_termios(struct tty_struct *tty, | |||
| 680 | case CS8: | 688 | case CS8: |
| 681 | last_lcr |= MCT_U232_DATA_BITS_8; break; | 689 | last_lcr |= MCT_U232_DATA_BITS_8; break; |
| 682 | default: | 690 | default: |
| 683 | err("CSIZE was not CS5-CS8, using default of 8"); | 691 | dev_err(&port->dev, |
| 692 | "CSIZE was not CS5-CS8, using default of 8\n"); | ||
| 684 | last_lcr |= MCT_U232_DATA_BITS_8; | 693 | last_lcr |= MCT_U232_DATA_BITS_8; |
| 685 | break; | 694 | break; |
| 686 | } | 695 | } |
| @@ -817,7 +826,8 @@ static int __init mct_u232_init(void) | |||
| 817 | retval = usb_register(&mct_u232_driver); | 826 | retval = usb_register(&mct_u232_driver); |
| 818 | if (retval) | 827 | if (retval) |
| 819 | goto failed_usb_register; | 828 | goto failed_usb_register; |
| 820 | info(DRIVER_DESC " " DRIVER_VERSION); | 829 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
| 830 | DRIVER_DESC "\n"); | ||
| 821 | return 0; | 831 | return 0; |
| 822 | failed_usb_register: | 832 | failed_usb_register: |
| 823 | usb_serial_deregister(&mct_u232_device); | 833 | usb_serial_deregister(&mct_u232_device); |
diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c index 7b538caec37f..e772cc0a97fd 100644 --- a/drivers/usb/serial/mos7720.c +++ b/drivers/usb/serial/mos7720.c | |||
| @@ -355,14 +355,16 @@ static int mos7720_open(struct tty_struct *tty, | |||
| 355 | mos7720_port->write_urb_pool[j] = urb; | 355 | mos7720_port->write_urb_pool[j] = urb; |
| 356 | 356 | ||
| 357 | if (urb == NULL) { | 357 | if (urb == NULL) { |
| 358 | err("No more urbs???"); | 358 | dev_err(&port->dev, "No more urbs???\n"); |
| 359 | continue; | 359 | continue; |
| 360 | } | 360 | } |
| 361 | 361 | ||
| 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.", __func__); | 365 | dev_err(&port->dev, |
| 366 | "%s-out of memory for urb buffers.\n", | ||
| 367 | __func__); | ||
| 366 | usb_free_urb(mos7720_port->write_urb_pool[j]); | 368 | usb_free_urb(mos7720_port->write_urb_pool[j]); |
| 367 | mos7720_port->write_urb_pool[j] = NULL; | 369 | mos7720_port->write_urb_pool[j] = NULL; |
| 368 | continue; | 370 | continue; |
| @@ -694,7 +696,8 @@ static int mos7720_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
| 694 | urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE, | 696 | urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE, |
| 695 | GFP_KERNEL); | 697 | GFP_KERNEL); |
| 696 | if (urb->transfer_buffer == NULL) { | 698 | if (urb->transfer_buffer == NULL) { |
| 697 | err("%s no more kernel memory...", __func__); | 699 | dev_err(&port->dev, "%s no more kernel memory...\n", |
| 700 | __func__); | ||
| 698 | goto exit; | 701 | goto exit; |
| 699 | } | 702 | } |
| 700 | } | 703 | } |
| @@ -714,8 +717,8 @@ static int mos7720_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
| 714 | /* send it down the pipe */ | 717 | /* send it down the pipe */ |
| 715 | status = usb_submit_urb(urb, GFP_ATOMIC); | 718 | status = usb_submit_urb(urb, GFP_ATOMIC); |
| 716 | if (status) { | 719 | if (status) { |
| 717 | err("%s - usb_submit_urb(write bulk) failed with status = %d", | 720 | dev_err(&port->dev, "%s - usb_submit_urb(write bulk) failed " |
| 718 | __func__, status); | 721 | "with status = %d\n", __func__, status); |
| 719 | bytes_sent = status; | 722 | bytes_sent = status; |
| 720 | goto exit; | 723 | goto exit; |
| 721 | } | 724 | } |
| @@ -975,7 +978,7 @@ static int send_cmd_write_baud_rate(struct moschip_port *mos7720_port, | |||
| 975 | /* Calculate the Divisor */ | 978 | /* Calculate the Divisor */ |
| 976 | status = calc_baud_rate_divisor(baudrate, &divisor); | 979 | status = calc_baud_rate_divisor(baudrate, &divisor); |
| 977 | if (status) { | 980 | if (status) { |
| 978 | err("%s - bad baud rate", __func__); | 981 | dev_err(&port->dev, "%s - bad baud rate\n", __func__); |
| 979 | return status; | 982 | return status; |
| 980 | } | 983 | } |
| 981 | 984 | ||
| @@ -1478,7 +1481,7 @@ static int mos7720_startup(struct usb_serial *serial) | |||
| 1478 | /* create our private serial structure */ | 1481 | /* create our private serial structure */ |
| 1479 | mos7720_serial = kzalloc(sizeof(struct moschip_serial), GFP_KERNEL); | 1482 | mos7720_serial = kzalloc(sizeof(struct moschip_serial), GFP_KERNEL); |
| 1480 | if (mos7720_serial == NULL) { | 1483 | if (mos7720_serial == NULL) { |
| 1481 | err("%s - Out of memory", __func__); | 1484 | dev_err(&dev->dev, "%s - Out of memory\n", __func__); |
| 1482 | return -ENOMEM; | 1485 | return -ENOMEM; |
| 1483 | } | 1486 | } |
| 1484 | 1487 | ||
| @@ -1491,7 +1494,7 @@ static int mos7720_startup(struct usb_serial *serial) | |||
| 1491 | for (i = 0; i < serial->num_ports; ++i) { | 1494 | for (i = 0; i < serial->num_ports; ++i) { |
| 1492 | mos7720_port = kzalloc(sizeof(struct moschip_port), GFP_KERNEL); | 1495 | mos7720_port = kzalloc(sizeof(struct moschip_port), GFP_KERNEL); |
| 1493 | if (mos7720_port == NULL) { | 1496 | if (mos7720_port == NULL) { |
| 1494 | err("%s - Out of memory", __func__); | 1497 | dev_err(&dev->dev, "%s - Out of memory\n", __func__); |
| 1495 | usb_set_serial_data(serial, NULL); | 1498 | usb_set_serial_data(serial, NULL); |
| 1496 | kfree(mos7720_serial); | 1499 | kfree(mos7720_serial); |
| 1497 | return -ENOMEM; | 1500 | return -ENOMEM; |
| @@ -1585,7 +1588,8 @@ static int __init moschip7720_init(void) | |||
| 1585 | if (retval) | 1588 | if (retval) |
| 1586 | goto failed_port_device_register; | 1589 | goto failed_port_device_register; |
| 1587 | 1590 | ||
| 1588 | info(DRIVER_DESC " " DRIVER_VERSION); | 1591 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
| 1592 | DRIVER_DESC "\n"); | ||
| 1589 | 1593 | ||
| 1590 | /* Register with the usb */ | 1594 | /* Register with the usb */ |
| 1591 | retval = usb_register(&usb_driver); | 1595 | retval = usb_register(&usb_driver); |
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c index 60543d79ef56..fda4a6421c44 100644 --- a/drivers/usb/serial/mos7840.c +++ b/drivers/usb/serial/mos7840.c | |||
| @@ -844,7 +844,7 @@ static int mos7840_open(struct tty_struct *tty, | |||
| 844 | mos7840_port->write_urb_pool[j] = urb; | 844 | mos7840_port->write_urb_pool[j] = urb; |
| 845 | 845 | ||
| 846 | if (urb == NULL) { | 846 | if (urb == NULL) { |
| 847 | err("No more urbs???"); | 847 | dev_err(&port->dev, "No more urbs???\n"); |
| 848 | continue; | 848 | continue; |
| 849 | } | 849 | } |
| 850 | 850 | ||
| @@ -853,7 +853,9 @@ static int mos7840_open(struct tty_struct *tty, | |||
| 853 | if (!urb->transfer_buffer) { | 853 | if (!urb->transfer_buffer) { |
| 854 | usb_free_urb(urb); | 854 | usb_free_urb(urb); |
| 855 | mos7840_port->write_urb_pool[j] = NULL; | 855 | mos7840_port->write_urb_pool[j] = NULL; |
| 856 | err("%s-out of memory for urb buffers.", __func__); | 856 | dev_err(&port->dev, |
| 857 | "%s-out of memory for urb buffers.\n", | ||
| 858 | __func__); | ||
| 857 | continue; | 859 | continue; |
| 858 | } | 860 | } |
| 859 | } | 861 | } |
| @@ -1021,8 +1023,8 @@ static int mos7840_open(struct tty_struct *tty, | |||
| 1021 | usb_submit_urb(serial->port[0]->interrupt_in_urb, | 1023 | usb_submit_urb(serial->port[0]->interrupt_in_urb, |
| 1022 | GFP_KERNEL); | 1024 | GFP_KERNEL); |
| 1023 | if (response) { | 1025 | if (response) { |
| 1024 | err("%s - Error %d submitting interrupt urb", | 1026 | dev_err(&port->dev, "%s - Error %d submitting " |
| 1025 | __func__, response); | 1027 | "interrupt urb\n", __func__, response); |
| 1026 | } | 1028 | } |
| 1027 | 1029 | ||
| 1028 | } | 1030 | } |
| @@ -1055,8 +1057,8 @@ static int mos7840_open(struct tty_struct *tty, | |||
| 1055 | port->bulk_in_endpointAddress); | 1057 | port->bulk_in_endpointAddress); |
| 1056 | response = usb_submit_urb(mos7840_port->read_urb, GFP_KERNEL); | 1058 | response = usb_submit_urb(mos7840_port->read_urb, GFP_KERNEL); |
| 1057 | if (response) { | 1059 | if (response) { |
| 1058 | err("%s - Error %d submitting control urb", __func__, | 1060 | dev_err(&port->dev, "%s - Error %d submitting control urb\n", |
| 1059 | response); | 1061 | __func__, response); |
| 1060 | } | 1062 | } |
| 1061 | 1063 | ||
| 1062 | /* initialize our wait queues */ | 1064 | /* initialize our wait queues */ |
| @@ -1492,7 +1494,8 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
| 1492 | kmalloc(URB_TRANSFER_BUFFER_SIZE, GFP_KERNEL); | 1494 | kmalloc(URB_TRANSFER_BUFFER_SIZE, GFP_KERNEL); |
| 1493 | 1495 | ||
| 1494 | if (urb->transfer_buffer == NULL) { | 1496 | if (urb->transfer_buffer == NULL) { |
| 1495 | err("%s no more kernel memory...", __func__); | 1497 | dev_err(&port->dev, "%s no more kernel memory...\n", |
| 1498 | __func__); | ||
| 1496 | goto exit; | 1499 | goto exit; |
| 1497 | } | 1500 | } |
| 1498 | } | 1501 | } |
| @@ -1517,8 +1520,8 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
| 1517 | 1520 | ||
| 1518 | if (status) { | 1521 | if (status) { |
| 1519 | mos7840_port->busy[i] = 0; | 1522 | mos7840_port->busy[i] = 0; |
| 1520 | err("%s - usb_submit_urb(write bulk) failed with status = %d", | 1523 | dev_err(&port->dev, "%s - usb_submit_urb(write bulk) failed " |
| 1521 | __func__, status); | 1524 | "with status = %d\n", __func__, status); |
| 1522 | bytes_sent = status; | 1525 | bytes_sent = status; |
| 1523 | goto exit; | 1526 | goto exit; |
| 1524 | } | 1527 | } |
| @@ -1856,8 +1859,7 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port, | |||
| 1856 | /* Calculate the Divisor */ | 1859 | /* Calculate the Divisor */ |
| 1857 | 1860 | ||
| 1858 | if (status) { | 1861 | if (status) { |
| 1859 | err("%s - bad baud rate", __func__); | 1862 | dev_err(&port->dev, "%s - bad baud rate\n", __func__); |
| 1860 | dbg("%s\n", "bad baud rate"); | ||
| 1861 | return status; | 1863 | return status; |
| 1862 | } | 1864 | } |
| 1863 | /* Enable access to divisor latch */ | 1865 | /* Enable access to divisor latch */ |
| @@ -2446,7 +2448,7 @@ static int mos7840_startup(struct usb_serial *serial) | |||
| 2446 | for (i = 0; i < serial->num_ports; ++i) { | 2448 | for (i = 0; i < serial->num_ports; ++i) { |
| 2447 | mos7840_port = kzalloc(sizeof(struct moschip_port), GFP_KERNEL); | 2449 | mos7840_port = kzalloc(sizeof(struct moschip_port), GFP_KERNEL); |
| 2448 | if (mos7840_port == NULL) { | 2450 | if (mos7840_port == NULL) { |
| 2449 | err("%s - Out of memory", __func__); | 2451 | dev_err(&dev->dev, "%s - Out of memory\n", __func__); |
| 2450 | status = -ENOMEM; | 2452 | status = -ENOMEM; |
| 2451 | i--; /* don't follow NULL pointer cleaning up */ | 2453 | i--; /* don't follow NULL pointer cleaning up */ |
| 2452 | goto error; | 2454 | goto error; |
| @@ -2743,7 +2745,8 @@ static int __init moschip7840_init(void) | |||
| 2743 | goto failed_port_device_register; | 2745 | goto failed_port_device_register; |
| 2744 | 2746 | ||
| 2745 | dbg("%s\n", "Entring..."); | 2747 | dbg("%s\n", "Entring..."); |
| 2746 | info(DRIVER_DESC " " DRIVER_VERSION); | 2748 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
| 2749 | DRIVER_DESC "\n"); | ||
| 2747 | 2750 | ||
| 2748 | /* Register with the usb */ | 2751 | /* Register with the usb */ |
| 2749 | retval = usb_register(&io_driver); | 2752 | retval = usb_register(&io_driver); |
diff --git a/drivers/usb/serial/omninet.c b/drivers/usb/serial/omninet.c index c4d70b0f1e48..df6539712726 100644 --- a/drivers/usb/serial/omninet.c +++ b/drivers/usb/serial/omninet.c | |||
| @@ -154,8 +154,8 @@ static int omninet_attach(struct usb_serial *serial) | |||
| 154 | 154 | ||
| 155 | od = kmalloc(sizeof(struct omninet_data), GFP_KERNEL); | 155 | od = kmalloc(sizeof(struct omninet_data), GFP_KERNEL); |
| 156 | if (!od) { | 156 | if (!od) { |
| 157 | err("%s- kmalloc(%Zd) failed.", | 157 | dev_err(&port->dev, "%s- kmalloc(%Zd) failed.\n", |
| 158 | __func__, sizeof(struct omninet_data)); | 158 | __func__, sizeof(struct omninet_data)); |
| 159 | return -ENOMEM; | 159 | return -ENOMEM; |
| 160 | } | 160 | } |
| 161 | usb_set_serial_port_data(port, od); | 161 | usb_set_serial_port_data(port, od); |
| @@ -183,8 +183,9 @@ static int omninet_open(struct tty_struct *tty, | |||
| 183 | omninet_read_bulk_callback, port); | 183 | omninet_read_bulk_callback, port); |
| 184 | result = usb_submit_urb(port->read_urb, GFP_KERNEL); | 184 | result = usb_submit_urb(port->read_urb, GFP_KERNEL); |
| 185 | if (result) | 185 | if (result) |
| 186 | err("%s - failed submitting read urb, error %d", | 186 | dev_err(&port->dev, |
| 187 | __func__, result); | 187 | "%s - failed submitting read urb, error %d\n", |
| 188 | __func__, result); | ||
| 188 | return result; | 189 | return result; |
| 189 | } | 190 | } |
| 190 | 191 | ||
| @@ -244,8 +245,9 @@ static void omninet_read_bulk_callback(struct urb *urb) | |||
| 244 | omninet_read_bulk_callback, port); | 245 | omninet_read_bulk_callback, port); |
| 245 | result = usb_submit_urb(urb, GFP_ATOMIC); | 246 | result = usb_submit_urb(urb, GFP_ATOMIC); |
| 246 | if (result) | 247 | if (result) |
| 247 | err("%s - failed resubmitting read urb, error %d", | 248 | dev_err(&port->dev, |
| 248 | __func__, result); | 249 | "%s - failed resubmitting read urb, error %d\n", |
| 250 | __func__, result); | ||
| 249 | 251 | ||
| 250 | return; | 252 | return; |
| 251 | } | 253 | } |
| @@ -298,8 +300,9 @@ static int omninet_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
| 298 | result = usb_submit_urb(wport->write_urb, GFP_ATOMIC); | 300 | result = usb_submit_urb(wport->write_urb, GFP_ATOMIC); |
| 299 | if (result) { | 301 | if (result) { |
| 300 | wport->write_urb_busy = 0; | 302 | wport->write_urb_busy = 0; |
| 301 | err("%s - failed submitting write urb, error %d", | 303 | dev_err(&port->dev, |
| 302 | __func__, result); | 304 | "%s - failed submitting write urb, error %d\n", |
| 305 | __func__, result); | ||
| 303 | } else | 306 | } else |
| 304 | result = count; | 307 | result = count; |
| 305 | 308 | ||
| @@ -364,7 +367,8 @@ static int __init omninet_init(void) | |||
| 364 | retval = usb_register(&omninet_driver); | 367 | retval = usb_register(&omninet_driver); |
| 365 | if (retval) | 368 | if (retval) |
| 366 | goto failed_usb_register; | 369 | goto failed_usb_register; |
| 367 | info(DRIVER_VERSION ":" DRIVER_DESC); | 370 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
| 371 | DRIVER_DESC "\n"); | ||
| 368 | return 0; | 372 | return 0; |
| 369 | failed_usb_register: | 373 | failed_usb_register: |
| 370 | usb_serial_deregister(&zyxel_omninet_device); | 374 | usb_serial_deregister(&zyxel_omninet_device); |
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index 6b1727e751e3..3d87eabcd922 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c | |||
| @@ -79,27 +79,16 @@ static int option_send_setup(struct tty_struct *tty, struct usb_serial_port *po | |||
| 79 | #define OPTION_PRODUCT_VIPER 0x6600 | 79 | #define OPTION_PRODUCT_VIPER 0x6600 |
| 80 | #define OPTION_PRODUCT_VIPER_BUS 0x6601 | 80 | #define OPTION_PRODUCT_VIPER_BUS 0x6601 |
| 81 | #define OPTION_PRODUCT_GT_MAX_READY 0x6701 | 81 | #define OPTION_PRODUCT_GT_MAX_READY 0x6701 |
| 82 | #define OPTION_PRODUCT_GT_MAX 0x6711 | ||
| 83 | #define OPTION_PRODUCT_FUJI_MODEM_LIGHT 0x6721 | 82 | #define OPTION_PRODUCT_FUJI_MODEM_LIGHT 0x6721 |
| 84 | #define OPTION_PRODUCT_FUJI_MODEM_GT 0x6741 | 83 | #define OPTION_PRODUCT_FUJI_MODEM_GT 0x6741 |
| 85 | #define OPTION_PRODUCT_FUJI_MODEM_EX 0x6761 | 84 | #define OPTION_PRODUCT_FUJI_MODEM_EX 0x6761 |
| 86 | #define OPTION_PRODUCT_FUJI_NETWORK_LIGHT 0x6731 | ||
| 87 | #define OPTION_PRODUCT_FUJI_NETWORK_GT 0x6751 | ||
| 88 | #define OPTION_PRODUCT_FUJI_NETWORK_EX 0x6771 | ||
| 89 | #define OPTION_PRODUCT_KOI_MODEM 0x6800 | 85 | #define OPTION_PRODUCT_KOI_MODEM 0x6800 |
| 90 | #define OPTION_PRODUCT_KOI_NETWORK 0x6811 | ||
| 91 | #define OPTION_PRODUCT_SCORPION_MODEM 0x6901 | 86 | #define OPTION_PRODUCT_SCORPION_MODEM 0x6901 |
| 92 | #define OPTION_PRODUCT_SCORPION_NETWORK 0x6911 | ||
| 93 | #define OPTION_PRODUCT_ETNA_MODEM 0x7001 | 87 | #define OPTION_PRODUCT_ETNA_MODEM 0x7001 |
| 94 | #define OPTION_PRODUCT_ETNA_NETWORK 0x7011 | ||
| 95 | #define OPTION_PRODUCT_ETNA_MODEM_LITE 0x7021 | 88 | #define OPTION_PRODUCT_ETNA_MODEM_LITE 0x7021 |
| 96 | #define OPTION_PRODUCT_ETNA_MODEM_GT 0x7041 | 89 | #define OPTION_PRODUCT_ETNA_MODEM_GT 0x7041 |
| 97 | #define OPTION_PRODUCT_ETNA_MODEM_EX 0x7061 | 90 | #define OPTION_PRODUCT_ETNA_MODEM_EX 0x7061 |
| 98 | #define OPTION_PRODUCT_ETNA_NETWORK_LITE 0x7031 | ||
| 99 | #define OPTION_PRODUCT_ETNA_NETWORK_GT 0x7051 | ||
| 100 | #define OPTION_PRODUCT_ETNA_NETWORK_EX 0x7071 | ||
| 101 | #define OPTION_PRODUCT_ETNA_KOI_MODEM 0x7100 | 91 | #define OPTION_PRODUCT_ETNA_KOI_MODEM 0x7100 |
| 102 | #define OPTION_PRODUCT_ETNA_KOI_NETWORK 0x7111 | ||
| 103 | 92 | ||
| 104 | #define HUAWEI_VENDOR_ID 0x12D1 | 93 | #define HUAWEI_VENDOR_ID 0x12D1 |
| 105 | #define HUAWEI_PRODUCT_E600 0x1001 | 94 | #define HUAWEI_PRODUCT_E600 0x1001 |
| @@ -220,6 +209,16 @@ static int option_send_setup(struct tty_struct *tty, struct usb_serial_port *po | |||
| 220 | #define ZTE_PRODUCT_MF628 0x0015 | 209 | #define ZTE_PRODUCT_MF628 0x0015 |
| 221 | #define ZTE_PRODUCT_CDMA_TECH 0xfffe | 210 | #define ZTE_PRODUCT_CDMA_TECH 0xfffe |
| 222 | 211 | ||
| 212 | /* Ericsson products */ | ||
| 213 | #define ERICSSON_VENDOR_ID 0x0bdb | ||
| 214 | #define ERICSSON_PRODUCT_F3507G 0x1900 | ||
| 215 | |||
| 216 | /* Pantech products */ | ||
| 217 | #define PANTECH_VENDOR_ID 0x106c | ||
| 218 | #define PANTECH_PRODUCT_PC5740 0x3701 | ||
| 219 | #define PANTECH_PRODUCT_PC5750 0x3702 /* PX-500 */ | ||
| 220 | #define PANTECH_PRODUCT_UM150 0x3711 | ||
| 221 | |||
| 223 | static struct usb_device_id option_ids[] = { | 222 | static struct usb_device_id option_ids[] = { |
| 224 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) }, | 223 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) }, |
| 225 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) }, | 224 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) }, |
| @@ -235,27 +234,16 @@ static struct usb_device_id option_ids[] = { | |||
| 235 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_VIPER) }, | 234 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_VIPER) }, |
| 236 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_VIPER_BUS) }, | 235 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_VIPER_BUS) }, |
| 237 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_GT_MAX_READY) }, | 236 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_GT_MAX_READY) }, |
| 238 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_GT_MAX) }, | ||
| 239 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUJI_MODEM_LIGHT) }, | 237 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUJI_MODEM_LIGHT) }, |
| 240 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUJI_MODEM_GT) }, | 238 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUJI_MODEM_GT) }, |
| 241 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUJI_MODEM_EX) }, | 239 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUJI_MODEM_EX) }, |
| 242 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUJI_NETWORK_LIGHT) }, | ||
| 243 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUJI_NETWORK_GT) }, | ||
| 244 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUJI_NETWORK_EX) }, | ||
| 245 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_KOI_MODEM) }, | 240 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_KOI_MODEM) }, |
| 246 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_KOI_NETWORK) }, | ||
| 247 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_SCORPION_MODEM) }, | 241 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_SCORPION_MODEM) }, |
| 248 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_SCORPION_NETWORK) }, | ||
| 249 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_MODEM) }, | 242 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_MODEM) }, |
| 250 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_NETWORK) }, | ||
| 251 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_MODEM_LITE) }, | 243 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_MODEM_LITE) }, |
| 252 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_MODEM_GT) }, | 244 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_MODEM_GT) }, |
| 253 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_MODEM_EX) }, | 245 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_MODEM_EX) }, |
| 254 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_NETWORK_LITE) }, | ||
| 255 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_NETWORK_GT) }, | ||
| 256 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_NETWORK_EX) }, | ||
| 257 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_KOI_MODEM) }, | 246 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_KOI_MODEM) }, |
| 258 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_KOI_NETWORK) }, | ||
| 259 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E600, 0xff, 0xff, 0xff) }, | 247 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E600, 0xff, 0xff, 0xff) }, |
| 260 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E220, 0xff, 0xff, 0xff) }, | 248 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E220, 0xff, 0xff, 0xff) }, |
| 261 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E220BIS, 0xff, 0xff, 0xff) }, | 249 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E220BIS, 0xff, 0xff, 0xff) }, |
| @@ -318,7 +306,8 @@ static struct usb_device_id option_ids[] = { | |||
| 318 | { USB_DEVICE(DELL_VENDOR_ID, 0x8136) }, /* Dell Wireless HSDPA 5520 == Novatel Expedite EU860D */ | 306 | { USB_DEVICE(DELL_VENDOR_ID, 0x8136) }, /* Dell Wireless HSDPA 5520 == Novatel Expedite EU860D */ |
| 319 | { USB_DEVICE(DELL_VENDOR_ID, 0x8137) }, /* Dell Wireless HSDPA 5520 */ | 307 | { USB_DEVICE(DELL_VENDOR_ID, 0x8137) }, /* Dell Wireless HSDPA 5520 */ |
| 320 | { USB_DEVICE(DELL_VENDOR_ID, 0x8138) }, /* Dell Wireless 5520 Voda I Mobile Broadband (3G HSDPA) Minicard */ | 308 | { USB_DEVICE(DELL_VENDOR_ID, 0x8138) }, /* Dell Wireless 5520 Voda I Mobile Broadband (3G HSDPA) Minicard */ |
| 321 | { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_E100A) }, | 309 | { USB_DEVICE(DELL_VENDOR_ID, 0x8147) }, /* Dell Wireless 5530 Mobile Broadband (3G HSPA) Mini-Card */ |
| 310 | { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_E100A) }, /* ADU-E100, ADU-310 */ | ||
| 322 | { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_500A) }, | 311 | { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_500A) }, |
| 323 | { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_620UW) }, | 312 | { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_620UW) }, |
| 324 | { USB_DEVICE(AXESSTEL_VENDOR_ID, AXESSTEL_PRODUCT_MV110H) }, | 313 | { USB_DEVICE(AXESSTEL_VENDOR_ID, AXESSTEL_PRODUCT_MV110H) }, |
| @@ -349,6 +338,10 @@ static struct usb_device_id option_ids[] = { | |||
| 349 | { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UC864E) }, | 338 | { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UC864E) }, |
| 350 | { USB_DEVICE(ZTE_VENDOR_ID, ZTE_PRODUCT_MF628) }, | 339 | { USB_DEVICE(ZTE_VENDOR_ID, ZTE_PRODUCT_MF628) }, |
| 351 | { USB_DEVICE(ZTE_VENDOR_ID, ZTE_PRODUCT_CDMA_TECH) }, | 340 | { USB_DEVICE(ZTE_VENDOR_ID, ZTE_PRODUCT_CDMA_TECH) }, |
| 341 | { USB_DEVICE(ERICSSON_VENDOR_ID, ERICSSON_PRODUCT_F3507G) }, | ||
| 342 | { USB_DEVICE(PANTECH_VENDOR_ID, PANTECH_PRODUCT_PC5740) }, | ||
| 343 | { USB_DEVICE(PANTECH_VENDOR_ID, PANTECH_PRODUCT_PC5750) }, | ||
| 344 | { USB_DEVICE(PANTECH_VENDOR_ID, PANTECH_PRODUCT_UM150) }, | ||
| 352 | { } /* Terminating entry */ | 345 | { } /* Terminating entry */ |
| 353 | }; | 346 | }; |
| 354 | MODULE_DEVICE_TABLE(usb, option_ids); | 347 | MODULE_DEVICE_TABLE(usb, option_ids); |
| @@ -427,7 +420,8 @@ static int __init option_init(void) | |||
| 427 | if (retval) | 420 | if (retval) |
| 428 | goto failed_driver_register; | 421 | goto failed_driver_register; |
| 429 | 422 | ||
| 430 | info(DRIVER_DESC ": " DRIVER_VERSION); | 423 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
| 424 | DRIVER_DESC "\n"); | ||
| 431 | 425 | ||
| 432 | return 0; | 426 | return 0; |
| 433 | 427 | ||
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index 908437847165..491c8857b644 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c | |||
| @@ -1147,7 +1147,7 @@ static int __init pl2303_init(void) | |||
| 1147 | retval = usb_register(&pl2303_driver); | 1147 | retval = usb_register(&pl2303_driver); |
| 1148 | if (retval) | 1148 | if (retval) |
| 1149 | goto failed_usb_register; | 1149 | goto failed_usb_register; |
| 1150 | info(DRIVER_DESC); | 1150 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_DESC "\n"); |
| 1151 | return 0; | 1151 | return 0; |
| 1152 | failed_usb_register: | 1152 | failed_usb_register: |
| 1153 | usb_serial_deregister(&pl2303_device); | 1153 | usb_serial_deregister(&pl2303_device); |
diff --git a/drivers/usb/serial/safe_serial.c b/drivers/usb/serial/safe_serial.c index 72903ac9f5c0..4b463cd140ef 100644 --- a/drivers/usb/serial/safe_serial.c +++ b/drivers/usb/serial/safe_serial.c | |||
| @@ -250,17 +250,18 @@ static void safe_read_bulk_callback(struct urb *urb) | |||
| 250 | if (!fcs) { | 250 | if (!fcs) { |
| 251 | int actual_length = data[length - 2] >> 2; | 251 | int actual_length = data[length - 2] >> 2; |
| 252 | if (actual_length <= (length - 2)) { | 252 | if (actual_length <= (length - 2)) { |
| 253 | info("%s - actual: %d", __func__, | 253 | dev_info(&urb->dev->dev, "%s - actual: %d\n", |
| 254 | actual_length); | 254 | __func__, actual_length); |
| 255 | tty_insert_flip_string(tty, | 255 | tty_insert_flip_string(tty, |
| 256 | data, actual_length); | 256 | data, actual_length); |
| 257 | tty_flip_buffer_push(tty); | 257 | tty_flip_buffer_push(tty); |
| 258 | } else { | 258 | } else { |
| 259 | err("%s - inconsistent lengths %d:%d", | 259 | dev_err(&port->dev, |
| 260 | "%s - inconsistent lengths %d:%d\n", | ||
| 260 | __func__, actual_length, length); | 261 | __func__, actual_length, length); |
| 261 | } | 262 | } |
| 262 | } else { | 263 | } else { |
| 263 | err("%s - bad CRC %x", __func__, fcs); | 264 | dev_err(&port->dev, "%s - bad CRC %x\n", __func__, fcs); |
| 264 | } | 265 | } |
| 265 | } else { | 266 | } else { |
| 266 | tty_insert_flip_string(tty, data, length); | 267 | tty_insert_flip_string(tty, data, length); |
| @@ -277,8 +278,9 @@ static void safe_read_bulk_callback(struct urb *urb) | |||
| 277 | 278 | ||
| 278 | result = usb_submit_urb(urb, GFP_ATOMIC); | 279 | result = usb_submit_urb(urb, GFP_ATOMIC); |
| 279 | if (result) | 280 | if (result) |
| 280 | err("%s - failed resubmitting read urb, error %d", | 281 | dev_err(&port->dev, |
| 281 | __func__, result); | 282 | "%s - failed resubmitting read urb, error %d\n", |
| 283 | __func__, result); | ||
| 282 | /* FIXME: Need a mechanism to retry later if this happens */ | 284 | /* FIXME: Need a mechanism to retry later if this happens */ |
| 283 | } | 285 | } |
| 284 | 286 | ||
| @@ -369,8 +371,9 @@ static int safe_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
| 369 | result = usb_submit_urb(port->write_urb, GFP_KERNEL); | 371 | result = usb_submit_urb(port->write_urb, GFP_KERNEL); |
| 370 | if (result) { | 372 | if (result) { |
| 371 | port->write_urb_busy = 0; | 373 | port->write_urb_busy = 0; |
| 372 | err("%s - failed submitting write urb, error %d", | 374 | dev_err(&port->dev, |
| 373 | __func__, result); | 375 | "%s - failed submitting write urb, error %d\n", |
| 376 | __func__, result); | ||
| 374 | return 0; | 377 | return 0; |
| 375 | } | 378 | } |
| 376 | dbg("%s urb: %p submitted", __func__, port->write_urb); | 379 | dbg("%s urb: %p submitted", __func__, port->write_urb); |
| @@ -428,14 +431,13 @@ static int __init safe_init(void) | |||
| 428 | { | 431 | { |
| 429 | int i, retval; | 432 | int i, retval; |
| 430 | 433 | ||
| 431 | info(DRIVER_VERSION " " DRIVER_AUTHOR); | 434 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
| 432 | info(DRIVER_DESC); | 435 | DRIVER_DESC "\n"); |
| 433 | info("vendor: %x product: %x safe: %d padded: %d\n", | ||
| 434 | vendor, product, safe, padded); | ||
| 435 | 436 | ||
| 436 | /* if we have vendor / product parameters patch them into id list */ | 437 | /* if we have vendor / product parameters patch them into id list */ |
| 437 | if (vendor || product) { | 438 | if (vendor || product) { |
| 438 | info("vendor: %x product: %x\n", vendor, product); | 439 | printk(KERN_INFO KBUILD_MODNAME ": vendor: %x product: %x\n", |
| 440 | vendor, product); | ||
| 439 | 441 | ||
| 440 | for (i = 0; i < ARRAY_SIZE(id_table); i++) { | 442 | for (i = 0; i < ARRAY_SIZE(id_table); i++) { |
| 441 | if (!id_table[i].idVendor && !id_table[i].idProduct) { | 443 | if (!id_table[i].idVendor && !id_table[i].idProduct) { |
diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c index 8b9eaf383679..0f2b67244af6 100644 --- a/drivers/usb/serial/sierra.c +++ b/drivers/usb/serial/sierra.c | |||
| @@ -247,7 +247,7 @@ static int sierra_send_setup(struct tty_struct *tty, | |||
| 247 | struct sierra_port_private *portdata; | 247 | struct sierra_port_private *portdata; |
| 248 | __u16 interface = 0; | 248 | __u16 interface = 0; |
| 249 | 249 | ||
| 250 | dbg("%s", __func__); | 250 | dev_dbg(&port->dev, "%s", __func__); |
| 251 | 251 | ||
| 252 | portdata = usb_get_serial_port_data(port); | 252 | portdata = usb_get_serial_port_data(port); |
| 253 | 253 | ||
| @@ -284,7 +284,7 @@ static int sierra_send_setup(struct tty_struct *tty, | |||
| 284 | static void sierra_set_termios(struct tty_struct *tty, | 284 | static void sierra_set_termios(struct tty_struct *tty, |
| 285 | struct usb_serial_port *port, struct ktermios *old_termios) | 285 | struct usb_serial_port *port, struct ktermios *old_termios) |
| 286 | { | 286 | { |
| 287 | dbg("%s", __func__); | 287 | dev_dbg(&port->dev, "%s", __func__); |
| 288 | tty_termios_copy_hw(tty->termios, old_termios); | 288 | tty_termios_copy_hw(tty->termios, old_termios); |
| 289 | sierra_send_setup(tty, port); | 289 | sierra_send_setup(tty, port); |
| 290 | } | 290 | } |
| @@ -295,6 +295,7 @@ static int sierra_tiocmget(struct tty_struct *tty, struct file *file) | |||
| 295 | unsigned int value; | 295 | unsigned int value; |
| 296 | struct sierra_port_private *portdata; | 296 | struct sierra_port_private *portdata; |
| 297 | 297 | ||
| 298 | dev_dbg(&port->dev, "%s", __func__); | ||
| 298 | portdata = usb_get_serial_port_data(port); | 299 | portdata = usb_get_serial_port_data(port); |
| 299 | 300 | ||
| 300 | value = ((portdata->rts_state) ? TIOCM_RTS : 0) | | 301 | value = ((portdata->rts_state) ? TIOCM_RTS : 0) | |
| @@ -334,14 +335,14 @@ static void sierra_outdat_callback(struct urb *urb) | |||
| 334 | int status = urb->status; | 335 | int status = urb->status; |
| 335 | unsigned long flags; | 336 | unsigned long flags; |
| 336 | 337 | ||
| 337 | dbg("%s - port %d", __func__, port->number); | 338 | dev_dbg(&port->dev, "%s - port %d", __func__, port->number); |
| 338 | 339 | ||
| 339 | /* free up the transfer buffer, as usb_free_urb() does not do this */ | 340 | /* free up the transfer buffer, as usb_free_urb() does not do this */ |
| 340 | kfree(urb->transfer_buffer); | 341 | kfree(urb->transfer_buffer); |
| 341 | 342 | ||
| 342 | if (status) | 343 | if (status) |
| 343 | dbg("%s - nonzero write bulk status received: %d", | 344 | dev_dbg(&port->dev, "%s - nonzero write bulk status " |
| 344 | __func__, status); | 345 | "received: %d", __func__, status); |
| 345 | 346 | ||
| 346 | spin_lock_irqsave(&portdata->lock, flags); | 347 | spin_lock_irqsave(&portdata->lock, flags); |
| 347 | --portdata->outstanding_urbs; | 348 | --portdata->outstanding_urbs; |
| @@ -363,12 +364,12 @@ static int sierra_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
| 363 | 364 | ||
| 364 | portdata = usb_get_serial_port_data(port); | 365 | portdata = usb_get_serial_port_data(port); |
| 365 | 366 | ||
| 366 | dbg("%s: write (%d chars)", __func__, count); | 367 | dev_dbg(&port->dev, "%s: write (%d chars)", __func__, count); |
| 367 | 368 | ||
| 368 | spin_lock_irqsave(&portdata->lock, flags); | 369 | spin_lock_irqsave(&portdata->lock, flags); |
| 369 | if (portdata->outstanding_urbs > N_OUT_URB) { | 370 | if (portdata->outstanding_urbs > N_OUT_URB) { |
| 370 | spin_unlock_irqrestore(&portdata->lock, flags); | 371 | spin_unlock_irqrestore(&portdata->lock, flags); |
| 371 | dbg("%s - write limit hit\n", __func__); | 372 | dev_dbg(&port->dev, "%s - write limit hit\n", __func__); |
| 372 | return 0; | 373 | return 0; |
| 373 | } | 374 | } |
| 374 | portdata->outstanding_urbs++; | 375 | portdata->outstanding_urbs++; |
| @@ -437,8 +438,8 @@ static void sierra_indat_callback(struct urb *urb) | |||
| 437 | port = urb->context; | 438 | port = urb->context; |
| 438 | 439 | ||
| 439 | if (status) { | 440 | if (status) { |
| 440 | dbg("%s: nonzero status: %d on endpoint %02x.", | 441 | dev_dbg(&port->dev, "%s: nonzero status: %d on" |
| 441 | __func__, status, endpoint); | 442 | " endpoint %02x.", __func__, status, endpoint); |
| 442 | } else { | 443 | } else { |
| 443 | if (urb->actual_length) { | 444 | if (urb->actual_length) { |
| 444 | tty = tty_port_tty_get(&port->port); | 445 | tty = tty_port_tty_get(&port->port); |
| @@ -447,7 +448,8 @@ static void sierra_indat_callback(struct urb *urb) | |||
| 447 | tty_flip_buffer_push(tty); | 448 | tty_flip_buffer_push(tty); |
| 448 | tty_kref_put(tty); | 449 | tty_kref_put(tty); |
| 449 | } else | 450 | } else |
| 450 | dbg("%s: empty read urb received", __func__); | 451 | dev_dbg(&port->dev, "%s: empty read urb" |
| 452 | " received", __func__); | ||
| 451 | 453 | ||
| 452 | /* Resubmit urb so we continue receiving */ | 454 | /* Resubmit urb so we continue receiving */ |
| 453 | if (port->port.count && status != -ESHUTDOWN) { | 455 | if (port->port.count && status != -ESHUTDOWN) { |
| @@ -468,15 +470,17 @@ static void sierra_instat_callback(struct urb *urb) | |||
| 468 | struct sierra_port_private *portdata = usb_get_serial_port_data(port); | 470 | struct sierra_port_private *portdata = usb_get_serial_port_data(port); |
| 469 | struct usb_serial *serial = port->serial; | 471 | struct usb_serial *serial = port->serial; |
| 470 | 472 | ||
| 471 | dbg("%s", __func__); | 473 | dev_dbg(&port->dev, "%s", __func__); |
| 472 | dbg("%s: urb %p port %p has data %p", __func__, urb, port, portdata); | 474 | dev_dbg(&port->dev, "%s: urb %p port %p has data %p", __func__, |
| 475 | urb, port, portdata); | ||
| 473 | 476 | ||
| 474 | if (status == 0) { | 477 | if (status == 0) { |
| 475 | struct usb_ctrlrequest *req_pkt = | 478 | struct usb_ctrlrequest *req_pkt = |
| 476 | (struct usb_ctrlrequest *)urb->transfer_buffer; | 479 | (struct usb_ctrlrequest *)urb->transfer_buffer; |
| 477 | 480 | ||
| 478 | if (!req_pkt) { | 481 | if (!req_pkt) { |
| 479 | dbg("%s: NULL req_pkt\n", __func__); | 482 | dev_dbg(&port->dev, "%s: NULL req_pkt\n", |
| 483 | __func__); | ||
| 480 | return; | 484 | return; |
| 481 | } | 485 | } |
| 482 | if ((req_pkt->bRequestType == 0xA1) && | 486 | if ((req_pkt->bRequestType == 0xA1) && |
| @@ -487,7 +491,8 @@ static void sierra_instat_callback(struct urb *urb) | |||
| 487 | sizeof(struct usb_ctrlrequest)); | 491 | sizeof(struct usb_ctrlrequest)); |
| 488 | struct tty_struct *tty; | 492 | struct tty_struct *tty; |
| 489 | 493 | ||
| 490 | dbg("%s: signal x%x", __func__, signals); | 494 | dev_dbg(&port->dev, "%s: signal x%x", __func__, |
| 495 | signals); | ||
| 491 | 496 | ||
| 492 | old_dcd_state = portdata->dcd_state; | 497 | old_dcd_state = portdata->dcd_state; |
| 493 | portdata->cts_state = 1; | 498 | portdata->cts_state = 1; |
| @@ -501,19 +506,20 @@ static void sierra_instat_callback(struct urb *urb) | |||
| 501 | tty_hangup(tty); | 506 | tty_hangup(tty); |
| 502 | tty_kref_put(tty); | 507 | tty_kref_put(tty); |
| 503 | } else { | 508 | } else { |
| 504 | dbg("%s: type %x req %x", __func__, | 509 | dev_dbg(&port->dev, "%s: type %x req %x", |
| 505 | req_pkt->bRequestType, req_pkt->bRequest); | 510 | __func__, req_pkt->bRequestType, |
| 511 | req_pkt->bRequest); | ||
| 506 | } | 512 | } |
| 507 | } else | 513 | } else |
| 508 | dbg("%s: error %d", __func__, status); | 514 | dev_dbg(&port->dev, "%s: error %d", __func__, status); |
| 509 | 515 | ||
| 510 | /* Resubmit urb so we continue receiving IRQ data */ | 516 | /* Resubmit urb so we continue receiving IRQ data */ |
| 511 | if (status != -ESHUTDOWN) { | 517 | if (status != -ESHUTDOWN) { |
| 512 | urb->dev = serial->dev; | 518 | urb->dev = serial->dev; |
| 513 | err = usb_submit_urb(urb, GFP_ATOMIC); | 519 | err = usb_submit_urb(urb, GFP_ATOMIC); |
| 514 | if (err) | 520 | if (err) |
| 515 | dbg("%s: resubmit intr urb failed. (%d)", | 521 | dev_dbg(&port->dev, "%s: resubmit intr urb " |
| 516 | __func__, err); | 522 | "failed. (%d)", __func__, err); |
| 517 | } | 523 | } |
| 518 | } | 524 | } |
| 519 | 525 | ||
| @@ -523,14 +529,14 @@ static int sierra_write_room(struct tty_struct *tty) | |||
| 523 | struct sierra_port_private *portdata = usb_get_serial_port_data(port); | 529 | struct sierra_port_private *portdata = usb_get_serial_port_data(port); |
| 524 | unsigned long flags; | 530 | unsigned long flags; |
| 525 | 531 | ||
| 526 | dbg("%s - port %d", __func__, port->number); | 532 | dev_dbg(&port->dev, "%s - port %d", __func__, port->number); |
| 527 | 533 | ||
| 528 | /* try to give a good number back based on if we have any free urbs at | 534 | /* try to give a good number back based on if we have any free urbs at |
| 529 | * this point in time */ | 535 | * this point in time */ |
| 530 | spin_lock_irqsave(&portdata->lock, flags); | 536 | spin_lock_irqsave(&portdata->lock, flags); |
| 531 | if (portdata->outstanding_urbs > N_OUT_URB * 2 / 3) { | 537 | if (portdata->outstanding_urbs > N_OUT_URB * 2 / 3) { |
| 532 | spin_unlock_irqrestore(&portdata->lock, flags); | 538 | spin_unlock_irqrestore(&portdata->lock, flags); |
| 533 | dbg("%s - write limit hit\n", __func__); | 539 | dev_dbg(&port->dev, "%s - write limit hit\n", __func__); |
| 534 | return 0; | 540 | return 0; |
| 535 | } | 541 | } |
| 536 | spin_unlock_irqrestore(&portdata->lock, flags); | 542 | spin_unlock_irqrestore(&portdata->lock, flags); |
| @@ -549,7 +555,7 @@ static int sierra_open(struct tty_struct *tty, | |||
| 549 | 555 | ||
| 550 | portdata = usb_get_serial_port_data(port); | 556 | portdata = usb_get_serial_port_data(port); |
| 551 | 557 | ||
| 552 | dbg("%s", __func__); | 558 | dev_dbg(&port->dev, "%s", __func__); |
| 553 | 559 | ||
| 554 | /* Set some sane defaults */ | 560 | /* Set some sane defaults */ |
| 555 | portdata->rts_state = 1; | 561 | portdata->rts_state = 1; |
| @@ -561,8 +567,8 @@ static int sierra_open(struct tty_struct *tty, | |||
| 561 | if (!urb) | 567 | if (!urb) |
| 562 | continue; | 568 | continue; |
| 563 | if (urb->dev != serial->dev) { | 569 | if (urb->dev != serial->dev) { |
| 564 | dbg("%s: dev %p != %p", __func__, | 570 | dev_dbg(&port->dev, "%s: dev %p != %p", |
| 565 | urb->dev, serial->dev); | 571 | __func__, urb->dev, serial->dev); |
| 566 | continue; | 572 | continue; |
| 567 | } | 573 | } |
| 568 | 574 | ||
| @@ -601,7 +607,7 @@ static void sierra_close(struct tty_struct *tty, | |||
| 601 | struct usb_serial *serial = port->serial; | 607 | struct usb_serial *serial = port->serial; |
| 602 | struct sierra_port_private *portdata; | 608 | struct sierra_port_private *portdata; |
| 603 | 609 | ||
| 604 | dbg("%s", __func__); | 610 | dev_dbg(&port->dev, "%s", __func__); |
| 605 | portdata = usb_get_serial_port_data(port); | 611 | portdata = usb_get_serial_port_data(port); |
| 606 | 612 | ||
| 607 | portdata->rts_state = 0; | 613 | portdata->rts_state = 0; |
| @@ -630,7 +636,7 @@ static int sierra_startup(struct usb_serial *serial) | |||
| 630 | int i; | 636 | int i; |
| 631 | int j; | 637 | int j; |
| 632 | 638 | ||
| 633 | dbg("%s", __func__); | 639 | dev_dbg(&serial->dev->dev, "%s", __func__); |
| 634 | 640 | ||
| 635 | /* Set Device mode to D0 */ | 641 | /* Set Device mode to D0 */ |
| 636 | sierra_set_power_state(serial->dev, 0x0000); | 642 | sierra_set_power_state(serial->dev, 0x0000); |
| @@ -644,8 +650,9 @@ static int sierra_startup(struct usb_serial *serial) | |||
| 644 | port = serial->port[i]; | 650 | port = serial->port[i]; |
| 645 | portdata = kzalloc(sizeof(*portdata), GFP_KERNEL); | 651 | portdata = kzalloc(sizeof(*portdata), GFP_KERNEL); |
| 646 | if (!portdata) { | 652 | if (!portdata) { |
| 647 | dbg("%s: kmalloc for sierra_port_private (%d) failed!.", | 653 | dev_dbg(&port->dev, "%s: kmalloc for " |
| 648 | __func__, i); | 654 | "sierra_port_private (%d) failed!.", |
| 655 | __func__, i); | ||
| 649 | return -ENOMEM; | 656 | return -ENOMEM; |
| 650 | } | 657 | } |
| 651 | spin_lock_init(&portdata->lock); | 658 | spin_lock_init(&portdata->lock); |
| @@ -665,8 +672,8 @@ static int sierra_startup(struct usb_serial *serial) | |||
| 665 | for (j = 0; j < N_IN_URB; ++j) { | 672 | for (j = 0; j < N_IN_URB; ++j) { |
| 666 | urb = usb_alloc_urb(0, GFP_KERNEL); | 673 | urb = usb_alloc_urb(0, GFP_KERNEL); |
| 667 | if (urb == NULL) { | 674 | if (urb == NULL) { |
| 668 | dbg("%s: alloc for in port failed.", | 675 | dev_dbg(&port->dev, "%s: alloc for in " |
| 669 | __func__); | 676 | "port failed.", __func__); |
| 670 | continue; | 677 | continue; |
| 671 | } | 678 | } |
| 672 | /* Fill URB using supplied data. */ | 679 | /* Fill URB using supplied data. */ |
| @@ -688,7 +695,7 @@ static void sierra_shutdown(struct usb_serial *serial) | |||
| 688 | struct usb_serial_port *port; | 695 | struct usb_serial_port *port; |
| 689 | struct sierra_port_private *portdata; | 696 | struct sierra_port_private *portdata; |
| 690 | 697 | ||
| 691 | dbg("%s", __func__); | 698 | dev_dbg(&serial->dev->dev, "%s", __func__); |
| 692 | 699 | ||
| 693 | for (i = 0; i < serial->num_ports; ++i) { | 700 | for (i = 0; i < serial->num_ports; ++i) { |
| 694 | port = serial->port[i]; | 701 | port = serial->port[i]; |
| @@ -743,7 +750,8 @@ static int __init sierra_init(void) | |||
| 743 | if (retval) | 750 | if (retval) |
| 744 | goto failed_driver_register; | 751 | goto failed_driver_register; |
| 745 | 752 | ||
| 746 | info(DRIVER_DESC ": " DRIVER_VERSION); | 753 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
| 754 | DRIVER_DESC "\n"); | ||
| 747 | 755 | ||
| 748 | return 0; | 756 | return 0; |
| 749 | 757 | ||
diff --git a/drivers/usb/serial/spcp8x5.c b/drivers/usb/serial/spcp8x5.c index 1533d6e12238..a65bc2bd8e71 100644 --- a/drivers/usb/serial/spcp8x5.c +++ b/drivers/usb/serial/spcp8x5.c | |||
| @@ -589,8 +589,8 @@ static void spcp8x5_set_termios(struct tty_struct *tty, | |||
| 589 | case 1000000: | 589 | case 1000000: |
| 590 | buf[0] = 0x0b; break; | 590 | buf[0] = 0x0b; break; |
| 591 | default: | 591 | default: |
| 592 | err("spcp825 driver does not support the baudrate " | 592 | dev_err(&port->dev, "spcp825 driver does not support the " |
| 593 | "requested, using default of 9600."); | 593 | "baudrate requested, using default of 9600.\n"); |
| 594 | } | 594 | } |
| 595 | 595 | ||
| 596 | /* Set Data Length : 00:5bit, 01:6bit, 10:7bit, 11:8bit */ | 596 | /* Set Data Length : 00:5bit, 01:6bit, 10:7bit, 11:8bit */ |
| @@ -629,7 +629,8 @@ static void spcp8x5_set_termios(struct tty_struct *tty, | |||
| 629 | SET_UART_FORMAT_TYPE, SET_UART_FORMAT, | 629 | SET_UART_FORMAT_TYPE, SET_UART_FORMAT, |
| 630 | uartdata, 0, NULL, 0, 100); | 630 | uartdata, 0, NULL, 0, 100); |
| 631 | if (i < 0) | 631 | if (i < 0) |
| 632 | err("Set UART format %#x failed (error = %d)", uartdata, i); | 632 | dev_err(&port->dev, "Set UART format %#x failed (error = %d)\n", |
| 633 | uartdata, i); | ||
| 633 | dbg("0x21:0x40:0:0 %d\n", i); | 634 | dbg("0x21:0x40:0:0 %d\n", i); |
| 634 | 635 | ||
| 635 | if (cflag & CRTSCTS) { | 636 | if (cflag & CRTSCTS) { |
| @@ -1054,7 +1055,8 @@ static int __init spcp8x5_init(void) | |||
| 1054 | retval = usb_register(&spcp8x5_driver); | 1055 | retval = usb_register(&spcp8x5_driver); |
| 1055 | if (retval) | 1056 | if (retval) |
| 1056 | goto failed_usb_register; | 1057 | goto failed_usb_register; |
| 1057 | info(DRIVER_DESC " " DRIVER_VERSION); | 1058 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
| 1059 | DRIVER_DESC "\n"); | ||
| 1058 | return 0; | 1060 | return 0; |
| 1059 | failed_usb_register: | 1061 | failed_usb_register: |
| 1060 | usb_serial_deregister(&spcp8x5_device); | 1062 | usb_serial_deregister(&spcp8x5_device); |
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c index c90237d48b0e..31c42d1cae13 100644 --- a/drivers/usb/serial/ti_usb_3410_5052.c +++ b/drivers/usb/serial/ti_usb_3410_5052.c | |||
| @@ -85,7 +85,6 @@ | |||
| 85 | #include <linux/uaccess.h> | 85 | #include <linux/uaccess.h> |
| 86 | #include <linux/usb.h> | 86 | #include <linux/usb.h> |
| 87 | #include <linux/usb/serial.h> | 87 | #include <linux/usb/serial.h> |
| 88 | #include <linux/firmware.h> | ||
| 89 | 88 | ||
| 90 | #include "ti_usb_3410_5052.h" | 89 | #include "ti_usb_3410_5052.h" |
| 91 | 90 | ||
| @@ -383,7 +382,8 @@ static int __init ti_init(void) | |||
| 383 | if (ret) | 382 | if (ret) |
| 384 | goto failed_usb; | 383 | goto failed_usb; |
| 385 | 384 | ||
| 386 | info(TI_DRIVER_DESC " " TI_DRIVER_VERSION); | 385 | printk(KERN_INFO KBUILD_MODNAME ": " TI_DRIVER_VERSION ":" |
| 386 | TI_DRIVER_DESC "\n"); | ||
| 387 | 387 | ||
| 388 | return 0; | 388 | return 0; |
| 389 | 389 | ||
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index e7d4246027b2..8be3f39891c7 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c | |||
| @@ -1121,7 +1121,8 @@ static int __init usb_serial_init(void) | |||
| 1121 | 1121 | ||
| 1122 | result = bus_register(&usb_serial_bus_type); | 1122 | result = bus_register(&usb_serial_bus_type); |
| 1123 | if (result) { | 1123 | if (result) { |
| 1124 | err("%s - registering bus driver failed", __func__); | 1124 | printk(KERN_ERR "usb-serial: %s - registering bus driver " |
| 1125 | "failed\n", __func__); | ||
| 1125 | goto exit_bus; | 1126 | goto exit_bus; |
| 1126 | } | 1127 | } |
| 1127 | 1128 | ||
| @@ -1142,25 +1143,28 @@ static int __init usb_serial_init(void) | |||
| 1142 | tty_set_operations(usb_serial_tty_driver, &serial_ops); | 1143 | tty_set_operations(usb_serial_tty_driver, &serial_ops); |
| 1143 | result = tty_register_driver(usb_serial_tty_driver); | 1144 | result = tty_register_driver(usb_serial_tty_driver); |
| 1144 | if (result) { | 1145 | if (result) { |
| 1145 | err("%s - tty_register_driver failed", __func__); | 1146 | printk(KERN_ERR "usb-serial: %s - tty_register_driver failed\n", |
| 1147 | __func__); | ||
| 1146 | goto exit_reg_driver; | 1148 | goto exit_reg_driver; |
| 1147 | } | 1149 | } |
| 1148 | 1150 | ||
| 1149 | /* register the USB driver */ | 1151 | /* register the USB driver */ |
| 1150 | result = usb_register(&usb_serial_driver); | 1152 | result = usb_register(&usb_serial_driver); |
| 1151 | if (result < 0) { | 1153 | if (result < 0) { |
| 1152 | err("%s - usb_register failed", __func__); | 1154 | printk(KERN_ERR "usb-serial: %s - usb_register failed\n", |
| 1155 | __func__); | ||
| 1153 | goto exit_tty; | 1156 | goto exit_tty; |
| 1154 | } | 1157 | } |
| 1155 | 1158 | ||
| 1156 | /* register the generic driver, if we should */ | 1159 | /* register the generic driver, if we should */ |
| 1157 | result = usb_serial_generic_register(debug); | 1160 | result = usb_serial_generic_register(debug); |
| 1158 | if (result < 0) { | 1161 | if (result < 0) { |
| 1159 | err("%s - registering generic driver failed", __func__); | 1162 | printk(KERN_ERR "usb-serial: %s - registering generic " |
| 1163 | "driver failed\n", __func__); | ||
| 1160 | goto exit_generic; | 1164 | goto exit_generic; |
| 1161 | } | 1165 | } |
| 1162 | 1166 | ||
| 1163 | info(DRIVER_DESC); | 1167 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_DESC "\n"); |
| 1164 | 1168 | ||
| 1165 | return result; | 1169 | return result; |
| 1166 | 1170 | ||
| @@ -1174,7 +1178,8 @@ exit_reg_driver: | |||
| 1174 | bus_unregister(&usb_serial_bus_type); | 1178 | bus_unregister(&usb_serial_bus_type); |
| 1175 | 1179 | ||
| 1176 | exit_bus: | 1180 | exit_bus: |
| 1177 | err("%s - returning with error %d", __func__, result); | 1181 | printk(KERN_ERR "usb-serial: %s - returning with error %d\n", |
| 1182 | __func__, result); | ||
| 1178 | put_tty_driver(usb_serial_tty_driver); | 1183 | put_tty_driver(usb_serial_tty_driver); |
| 1179 | return result; | 1184 | return result; |
| 1180 | } | 1185 | } |
| @@ -1233,11 +1238,11 @@ int usb_serial_register(struct usb_serial_driver *driver) | |||
| 1233 | 1238 | ||
| 1234 | retval = usb_serial_bus_register(driver); | 1239 | retval = usb_serial_bus_register(driver); |
| 1235 | if (retval) { | 1240 | if (retval) { |
| 1236 | err("problem %d when registering driver %s", | 1241 | printk(KERN_ERR "usb-serial: problem %d when registering " |
| 1237 | retval, driver->description); | 1242 | "driver %s\n", retval, driver->description); |
| 1238 | list_del(&driver->driver_list); | 1243 | list_del(&driver->driver_list); |
| 1239 | } else | 1244 | } else |
| 1240 | info("USB Serial support registered for %s", | 1245 | printk(KERN_INFO "USB Serial support registered for %s\n", |
| 1241 | driver->description); | 1246 | driver->description); |
| 1242 | 1247 | ||
| 1243 | return retval; | 1248 | return retval; |
| @@ -1248,7 +1253,8 @@ EXPORT_SYMBOL_GPL(usb_serial_register); | |||
| 1248 | void usb_serial_deregister(struct usb_serial_driver *device) | 1253 | void usb_serial_deregister(struct usb_serial_driver *device) |
| 1249 | { | 1254 | { |
| 1250 | /* must be called with BKL held */ | 1255 | /* must be called with BKL held */ |
| 1251 | info("USB Serial deregistering driver %s", device->description); | 1256 | printk(KERN_INFO "USB Serial deregistering driver %s\n", |
| 1257 | device->description); | ||
| 1252 | list_del(&device->driver_list); | 1258 | list_del(&device->driver_list); |
| 1253 | usb_serial_bus_deregister(device); | 1259 | usb_serial_bus_deregister(device); |
| 1254 | } | 1260 | } |
diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c index a6d1c75a1c89..4facce3d9364 100644 --- a/drivers/usb/serial/visor.c +++ b/drivers/usb/serial/visor.c | |||
| @@ -768,7 +768,7 @@ static int visor_probe(struct usb_serial *serial, | |||
| 768 | dbg("%s", __func__); | 768 | dbg("%s", __func__); |
| 769 | 769 | ||
| 770 | if (serial->dev->actconfig->desc.bConfigurationValue != 1) { | 770 | if (serial->dev->actconfig->desc.bConfigurationValue != 1) { |
| 771 | err("active config #%d != 1 ??", | 771 | dev_err(&serial->dev->dev, "active config #%d != 1 ??\n", |
| 772 | serial->dev->actconfig->desc.bConfigurationValue); | 772 | serial->dev->actconfig->desc.bConfigurationValue); |
| 773 | return -ENODEV; | 773 | return -ENODEV; |
| 774 | } | 774 | } |
| @@ -971,11 +971,14 @@ static int __init visor_init(void) | |||
| 971 | break; | 971 | break; |
| 972 | } | 972 | } |
| 973 | } | 973 | } |
| 974 | info( | 974 | printk(KERN_INFO KBUILD_MODNAME |
| 975 | "Untested USB device specified at time of module insertion"); | 975 | ": Untested USB device specified at time of module insertion\n"); |
| 976 | info("Warning: This is not guaranteed to work"); | 976 | printk(KERN_INFO KBUILD_MODNAME |
| 977 | info("Using a newer kernel is preferred to this method"); | 977 | ": Warning: This is not guaranteed to work\n"); |
| 978 | info("Adding Palm OS protocol 4.x support for unknown device: 0x%x/0x%x", | 978 | printk(KERN_INFO KBUILD_MODNAME |
| 979 | ": Using a newer kernel is preferred to this method\n"); | ||
| 980 | printk(KERN_INFO KBUILD_MODNAME | ||
| 981 | ": Adding Palm OS protocol 4.x support for unknown device: 0x%x/0x%x\n", | ||
| 979 | vendor, product); | 982 | vendor, product); |
| 980 | } | 983 | } |
| 981 | retval = usb_serial_register(&handspring_device); | 984 | retval = usb_serial_register(&handspring_device); |
| @@ -990,7 +993,7 @@ static int __init visor_init(void) | |||
| 990 | retval = usb_register(&visor_driver); | 993 | retval = usb_register(&visor_driver); |
| 991 | if (retval) | 994 | if (retval) |
| 992 | goto failed_usb_register; | 995 | goto failed_usb_register; |
| 993 | info(DRIVER_DESC); | 996 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_DESC "\n"); |
| 994 | 997 | ||
| 995 | return 0; | 998 | return 0; |
| 996 | failed_usb_register: | 999 | failed_usb_register: |
diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c index 11c8b97a5177..5335d3211c07 100644 --- a/drivers/usb/serial/whiteheat.c +++ b/drivers/usb/serial/whiteheat.c | |||
| @@ -303,12 +303,15 @@ static int whiteheat_firmware_download(struct usb_serial *serial, | |||
| 303 | 303 | ||
| 304 | if (request_ihex_firmware(&firmware_fw, "whiteheat.fw", | 304 | if (request_ihex_firmware(&firmware_fw, "whiteheat.fw", |
| 305 | &serial->dev->dev)) { | 305 | &serial->dev->dev)) { |
| 306 | err("%s - request \"whiteheat.fw\" failed", __func__); | 306 | dev_err(&serial->dev->dev, |
| 307 | "%s - request \"whiteheat.fw\" failed\n", __func__); | ||
| 307 | goto out; | 308 | goto out; |
| 308 | } | 309 | } |
| 309 | if (request_ihex_firmware(&loader_fw, "whiteheat_loader.fw", | 310 | if (request_ihex_firmware(&loader_fw, "whiteheat_loader.fw", |
| 310 | &serial->dev->dev)) { | 311 | &serial->dev->dev)) { |
| 311 | err("%s - request \"whiteheat_loader.fw\" failed", __func__); | 312 | dev_err(&serial->dev->dev, |
| 313 | "%s - request \"whiteheat_loader.fw\" failed\n", | ||
| 314 | __func__); | ||
| 312 | goto out; | 315 | goto out; |
| 313 | } | 316 | } |
| 314 | ret = 0; | 317 | ret = 0; |
| @@ -320,9 +323,10 @@ static int whiteheat_firmware_download(struct usb_serial *serial, | |||
| 320 | (unsigned char *)record->data, | 323 | (unsigned char *)record->data, |
| 321 | be16_to_cpu(record->len), 0xa0); | 324 | be16_to_cpu(record->len), 0xa0); |
| 322 | if (response < 0) { | 325 | if (response < 0) { |
| 323 | err("%s - ezusb_writememory failed for loader (%d %04X %p %d)", | 326 | dev_err(&serial->dev->dev, "%s - ezusb_writememory " |
| 324 | __func__, response, be32_to_cpu(record->addr), | 327 | "failed for loader (%d %04X %p %d)\n", |
| 325 | record->data, be16_to_cpu(record->len)); | 328 | __func__, response, be32_to_cpu(record->addr), |
| 329 | record->data, be16_to_cpu(record->len)); | ||
| 326 | break; | 330 | break; |
| 327 | } | 331 | } |
| 328 | record = ihex_next_binrec(record); | 332 | record = ihex_next_binrec(record); |
| @@ -338,9 +342,11 @@ static int whiteheat_firmware_download(struct usb_serial *serial, | |||
| 338 | (unsigned char *)record->data, | 342 | (unsigned char *)record->data, |
| 339 | be16_to_cpu(record->len), 0xa3); | 343 | be16_to_cpu(record->len), 0xa3); |
| 340 | if (response < 0) { | 344 | if (response < 0) { |
| 341 | err("%s - ezusb_writememory failed for first firmware step (%d %04X %p %d)", | 345 | dev_err(&serial->dev->dev, "%s - ezusb_writememory " |
| 342 | __func__, response, be32_to_cpu(record->addr), | 346 | "failed for first firmware step " |
| 343 | record->data, be16_to_cpu(record->len)); | 347 | "(%d %04X %p %d)\n", __func__, response, |
| 348 | be32_to_cpu(record->addr), record->data, | ||
| 349 | be16_to_cpu(record->len)); | ||
| 344 | break; | 350 | break; |
| 345 | } | 351 | } |
| 346 | ++record; | 352 | ++record; |
| @@ -354,9 +360,11 @@ static int whiteheat_firmware_download(struct usb_serial *serial, | |||
| 354 | (unsigned char *)record->data, | 360 | (unsigned char *)record->data, |
| 355 | be16_to_cpu(record->len), 0xa0); | 361 | be16_to_cpu(record->len), 0xa0); |
| 356 | if (response < 0) { | 362 | if (response < 0) { |
| 357 | err("%s - ezusb_writememory failed for second firmware step (%d %04X %p %d)", | 363 | dev_err(&serial->dev->dev, "%s - ezusb_writememory " |
| 358 | __func__, response, be32_to_cpu(record->addr), | 364 | "failed for second firmware step " |
| 359 | record->data, be16_to_cpu(record->len)); | 365 | "(%d %04X %p %d)\n", __func__, response, |
| 366 | be32_to_cpu(record->addr), record->data, | ||
| 367 | be16_to_cpu(record->len)); | ||
| 360 | break; | 368 | break; |
| 361 | } | 369 | } |
| 362 | ++record; | 370 | ++record; |
| @@ -421,12 +429,12 @@ static int whiteheat_attach(struct usb_serial *serial) | |||
| 421 | ret = usb_bulk_msg(serial->dev, pipe, command, 2, | 429 | ret = usb_bulk_msg(serial->dev, pipe, command, 2, |
| 422 | &alen, COMMAND_TIMEOUT_MS); | 430 | &alen, COMMAND_TIMEOUT_MS); |
| 423 | if (ret) { | 431 | if (ret) { |
| 424 | err("%s: Couldn't send command [%d]", | 432 | dev_err(&serial->dev->dev, "%s: Couldn't send command [%d]\n", |
| 425 | serial->type->description, ret); | 433 | serial->type->description, ret); |
| 426 | goto no_firmware; | 434 | goto no_firmware; |
| 427 | } else if (alen != 2) { | 435 | } else if (alen != 2) { |
| 428 | err("%s: Send command incomplete [%d]", | 436 | dev_err(&serial->dev->dev, "%s: Send command incomplete [%d]\n", |
| 429 | serial->type->description, alen); | 437 | serial->type->description, alen); |
| 430 | goto no_firmware; | 438 | goto no_firmware; |
| 431 | } | 439 | } |
| 432 | 440 | ||
| @@ -437,31 +445,33 @@ static int whiteheat_attach(struct usb_serial *serial) | |||
| 437 | ret = usb_bulk_msg(serial->dev, pipe, result, | 445 | ret = usb_bulk_msg(serial->dev, pipe, result, |
| 438 | sizeof(*hw_info) + 1, &alen, COMMAND_TIMEOUT_MS); | 446 | sizeof(*hw_info) + 1, &alen, COMMAND_TIMEOUT_MS); |
| 439 | if (ret) { | 447 | if (ret) { |
| 440 | err("%s: Couldn't get results [%d]", | 448 | dev_err(&serial->dev->dev, "%s: Couldn't get results [%d]\n", |
| 441 | serial->type->description, ret); | 449 | serial->type->description, ret); |
| 442 | goto no_firmware; | 450 | goto no_firmware; |
| 443 | } else if (alen != sizeof(*hw_info) + 1) { | 451 | } else if (alen != sizeof(*hw_info) + 1) { |
| 444 | err("%s: Get results incomplete [%d]", | 452 | dev_err(&serial->dev->dev, "%s: Get results incomplete [%d]\n", |
| 445 | serial->type->description, alen); | 453 | serial->type->description, alen); |
| 446 | goto no_firmware; | 454 | goto no_firmware; |
| 447 | } else if (result[0] != command[0]) { | 455 | } else if (result[0] != command[0]) { |
| 448 | err("%s: Command failed [%d]", | 456 | dev_err(&serial->dev->dev, "%s: Command failed [%d]\n", |
| 449 | serial->type->description, result[0]); | 457 | serial->type->description, result[0]); |
| 450 | goto no_firmware; | 458 | goto no_firmware; |
| 451 | } | 459 | } |
| 452 | 460 | ||
| 453 | hw_info = (struct whiteheat_hw_info *)&result[1]; | 461 | hw_info = (struct whiteheat_hw_info *)&result[1]; |
| 454 | 462 | ||
| 455 | info("%s: Driver %s: Firmware v%d.%02d", serial->type->description, | 463 | dev_info(&serial->dev->dev, "%s: Driver %s: Firmware v%d.%02d\n", |
| 456 | DRIVER_VERSION, hw_info->sw_major_rev, hw_info->sw_minor_rev); | 464 | serial->type->description, DRIVER_VERSION, |
| 465 | hw_info->sw_major_rev, hw_info->sw_minor_rev); | ||
| 457 | 466 | ||
| 458 | for (i = 0; i < serial->num_ports; i++) { | 467 | for (i = 0; i < serial->num_ports; i++) { |
| 459 | port = serial->port[i]; | 468 | port = serial->port[i]; |
| 460 | 469 | ||
| 461 | info = kmalloc(sizeof(struct whiteheat_private), GFP_KERNEL); | 470 | info = kmalloc(sizeof(struct whiteheat_private), GFP_KERNEL); |
| 462 | if (info == NULL) { | 471 | if (info == NULL) { |
| 463 | err("%s: Out of memory for port structures\n", | 472 | dev_err(&port->dev, |
| 464 | serial->type->description); | 473 | "%s: Out of memory for port structures\n", |
| 474 | serial->type->description); | ||
| 465 | goto no_private; | 475 | goto no_private; |
| 466 | } | 476 | } |
| 467 | 477 | ||
| @@ -481,18 +491,20 @@ static int whiteheat_attach(struct usb_serial *serial) | |||
| 481 | for (j = 0; j < urb_pool_size; j++) { | 491 | for (j = 0; j < urb_pool_size; j++) { |
| 482 | urb = usb_alloc_urb(0, GFP_KERNEL); | 492 | urb = usb_alloc_urb(0, GFP_KERNEL); |
| 483 | if (!urb) { | 493 | if (!urb) { |
| 484 | err("No free urbs available"); | 494 | dev_err(&port->dev, "No free urbs available\n"); |
| 485 | goto no_rx_urb; | 495 | goto no_rx_urb; |
| 486 | } | 496 | } |
| 487 | buf_size = port->read_urb->transfer_buffer_length; | 497 | buf_size = port->read_urb->transfer_buffer_length; |
| 488 | urb->transfer_buffer = kmalloc(buf_size, GFP_KERNEL); | 498 | urb->transfer_buffer = kmalloc(buf_size, GFP_KERNEL); |
| 489 | if (!urb->transfer_buffer) { | 499 | if (!urb->transfer_buffer) { |
| 490 | err("Couldn't allocate urb buffer"); | 500 | dev_err(&port->dev, |
| 501 | "Couldn't allocate urb buffer\n"); | ||
| 491 | goto no_rx_buf; | 502 | goto no_rx_buf; |
| 492 | } | 503 | } |
| 493 | wrap = kmalloc(sizeof(*wrap), GFP_KERNEL); | 504 | wrap = kmalloc(sizeof(*wrap), GFP_KERNEL); |
| 494 | if (!wrap) { | 505 | if (!wrap) { |
| 495 | err("Couldn't allocate urb wrapper"); | 506 | dev_err(&port->dev, |
| 507 | "Couldn't allocate urb wrapper\n"); | ||
| 496 | goto no_rx_wrap; | 508 | goto no_rx_wrap; |
| 497 | } | 509 | } |
| 498 | usb_fill_bulk_urb(urb, serial->dev, | 510 | usb_fill_bulk_urb(urb, serial->dev, |
| @@ -505,18 +517,20 @@ static int whiteheat_attach(struct usb_serial *serial) | |||
| 505 | 517 | ||
| 506 | urb = usb_alloc_urb(0, GFP_KERNEL); | 518 | urb = usb_alloc_urb(0, GFP_KERNEL); |
| 507 | if (!urb) { | 519 | if (!urb) { |
| 508 | err("No free urbs available"); | 520 | dev_err(&port->dev, "No free urbs available\n"); |
| 509 | goto no_tx_urb; | 521 | goto no_tx_urb; |
| 510 | } | 522 | } |
| 511 | buf_size = port->write_urb->transfer_buffer_length; | 523 | buf_size = port->write_urb->transfer_buffer_length; |
| 512 | urb->transfer_buffer = kmalloc(buf_size, GFP_KERNEL); | 524 | urb->transfer_buffer = kmalloc(buf_size, GFP_KERNEL); |
| 513 | if (!urb->transfer_buffer) { | 525 | if (!urb->transfer_buffer) { |
| 514 | err("Couldn't allocate urb buffer"); | 526 | dev_err(&port->dev, |
| 527 | "Couldn't allocate urb buffer\n"); | ||
| 515 | goto no_tx_buf; | 528 | goto no_tx_buf; |
| 516 | } | 529 | } |
| 517 | wrap = kmalloc(sizeof(*wrap), GFP_KERNEL); | 530 | wrap = kmalloc(sizeof(*wrap), GFP_KERNEL); |
| 518 | if (!wrap) { | 531 | if (!wrap) { |
| 519 | err("Couldn't allocate urb wrapper"); | 532 | dev_err(&port->dev, |
| 533 | "Couldn't allocate urb wrapper\n"); | ||
| 520 | goto no_tx_wrap; | 534 | goto no_tx_wrap; |
| 521 | } | 535 | } |
| 522 | usb_fill_bulk_urb(urb, serial->dev, | 536 | usb_fill_bulk_urb(urb, serial->dev, |
| @@ -534,8 +548,9 @@ static int whiteheat_attach(struct usb_serial *serial) | |||
| 534 | command_info = kmalloc(sizeof(struct whiteheat_command_private), | 548 | command_info = kmalloc(sizeof(struct whiteheat_command_private), |
| 535 | GFP_KERNEL); | 549 | GFP_KERNEL); |
| 536 | if (command_info == NULL) { | 550 | if (command_info == NULL) { |
| 537 | err("%s: Out of memory for port structures\n", | 551 | dev_err(&serial->dev->dev, |
| 538 | serial->type->description); | 552 | "%s: Out of memory for port structures\n", |
| 553 | serial->type->description); | ||
| 539 | goto no_command_private; | 554 | goto no_command_private; |
| 540 | } | 555 | } |
| 541 | 556 | ||
| @@ -552,12 +567,15 @@ static int whiteheat_attach(struct usb_serial *serial) | |||
| 552 | 567 | ||
| 553 | no_firmware: | 568 | no_firmware: |
| 554 | /* Firmware likely not running */ | 569 | /* Firmware likely not running */ |
| 555 | err("%s: Unable to retrieve firmware version, try replugging\n", | 570 | dev_err(&serial->dev->dev, |
| 556 | serial->type->description); | 571 | "%s: Unable to retrieve firmware version, try replugging\n", |
| 557 | err("%s: If the firmware is not running (status led not blinking)\n", | 572 | serial->type->description); |
| 558 | serial->type->description); | 573 | dev_err(&serial->dev->dev, |
| 559 | err("%s: please contact support@connecttech.com\n", | 574 | "%s: If the firmware is not running (status led not blinking)\n", |
| 560 | serial->type->description); | 575 | serial->type->description); |
| 576 | dev_err(&serial->dev->dev, | ||
| 577 | "%s: please contact support@connecttech.com\n", | ||
| 578 | serial->type->description); | ||
| 561 | kfree(result); | 579 | kfree(result); |
| 562 | return -ENODEV; | 580 | return -ENODEV; |
| 563 | 581 | ||
| @@ -680,8 +698,9 @@ static int whiteheat_open(struct tty_struct *tty, | |||
| 680 | /* Start reading from the device */ | 698 | /* Start reading from the device */ |
| 681 | retval = start_port_read(port); | 699 | retval = start_port_read(port); |
| 682 | if (retval) { | 700 | if (retval) { |
| 683 | err("%s - failed submitting read urb, error %d", | 701 | dev_err(&port->dev, |
| 684 | __func__, retval); | 702 | "%s - failed submitting read urb, error %d\n", |
| 703 | __func__, retval); | ||
| 685 | firm_close(port); | 704 | firm_close(port); |
| 686 | stop_command_port(port->serial); | 705 | stop_command_port(port->serial); |
| 687 | goto exit; | 706 | goto exit; |
| @@ -806,8 +825,9 @@ static int whiteheat_write(struct tty_struct *tty, | |||
| 806 | urb->transfer_buffer_length = bytes; | 825 | urb->transfer_buffer_length = bytes; |
| 807 | result = usb_submit_urb(urb, GFP_ATOMIC); | 826 | result = usb_submit_urb(urb, GFP_ATOMIC); |
| 808 | if (result) { | 827 | if (result) { |
| 809 | err("%s - failed submitting write urb, error %d", | 828 | dev_err(&port->dev, |
| 810 | __func__, result); | 829 | "%s - failed submitting write urb, error %d\n", |
| 830 | __func__, result); | ||
| 811 | sent = result; | 831 | sent = result; |
| 812 | spin_lock_irqsave(&info->lock, flags); | 832 | spin_lock_irqsave(&info->lock, flags); |
| 813 | list_add(tmp, &info->tx_urbs_free); | 833 | list_add(tmp, &info->tx_urbs_free); |
| @@ -1075,7 +1095,7 @@ static void whiteheat_read_callback(struct urb *urb) | |||
| 1075 | wrap = urb_to_wrap(urb, &info->rx_urbs_submitted); | 1095 | wrap = urb_to_wrap(urb, &info->rx_urbs_submitted); |
| 1076 | if (!wrap) { | 1096 | if (!wrap) { |
| 1077 | spin_unlock(&info->lock); | 1097 | spin_unlock(&info->lock); |
| 1078 | err("%s - Not my urb!", __func__); | 1098 | dev_err(&port->dev, "%s - Not my urb!\n", __func__); |
| 1079 | return; | 1099 | return; |
| 1080 | } | 1100 | } |
| 1081 | list_del(&wrap->list); | 1101 | list_del(&wrap->list); |
| @@ -1119,7 +1139,7 @@ static void whiteheat_write_callback(struct urb *urb) | |||
| 1119 | wrap = urb_to_wrap(urb, &info->tx_urbs_submitted); | 1139 | wrap = urb_to_wrap(urb, &info->tx_urbs_submitted); |
| 1120 | if (!wrap) { | 1140 | if (!wrap) { |
| 1121 | spin_unlock(&info->lock); | 1141 | spin_unlock(&info->lock); |
| 1122 | err("%s - Not my urb!", __func__); | 1142 | dev_err(&port->dev, "%s - Not my urb!\n", __func__); |
| 1123 | return; | 1143 | return; |
| 1124 | } | 1144 | } |
| 1125 | list_move(&wrap->list, &info->tx_urbs_free); | 1145 | list_move(&wrap->list, &info->tx_urbs_free); |
| @@ -1383,8 +1403,9 @@ static int start_command_port(struct usb_serial *serial) | |||
| 1383 | command_port->read_urb->dev = serial->dev; | 1403 | command_port->read_urb->dev = serial->dev; |
| 1384 | retval = usb_submit_urb(command_port->read_urb, GFP_KERNEL); | 1404 | retval = usb_submit_urb(command_port->read_urb, GFP_KERNEL); |
| 1385 | if (retval) { | 1405 | if (retval) { |
| 1386 | err("%s - failed submitting read urb, error %d", | 1406 | dev_err(&serial->dev->dev, |
| 1387 | __func__, retval); | 1407 | "%s - failed submitting read urb, error %d\n", |
| 1408 | __func__, retval); | ||
| 1388 | goto exit; | 1409 | goto exit; |
| 1389 | } | 1410 | } |
| 1390 | } | 1411 | } |
| @@ -1522,7 +1543,8 @@ static void rx_data_softint(struct work_struct *work) | |||
| 1522 | urb->dev = port->serial->dev; | 1543 | urb->dev = port->serial->dev; |
| 1523 | result = usb_submit_urb(urb, GFP_ATOMIC); | 1544 | result = usb_submit_urb(urb, GFP_ATOMIC); |
| 1524 | if (result) { | 1545 | if (result) { |
| 1525 | err("%s - failed resubmitting read urb, error %d", | 1546 | dev_err(&port->dev, |
| 1547 | "%s - failed resubmitting read urb, error %d\n", | ||
| 1526 | __func__, result); | 1548 | __func__, result); |
| 1527 | spin_lock_irqsave(&info->lock, flags); | 1549 | spin_lock_irqsave(&info->lock, flags); |
| 1528 | list_add(tmp, &info->rx_urbs_free); | 1550 | list_add(tmp, &info->rx_urbs_free); |
| @@ -1556,7 +1578,8 @@ static int __init whiteheat_init(void) | |||
| 1556 | retval = usb_register(&whiteheat_driver); | 1578 | retval = usb_register(&whiteheat_driver); |
| 1557 | if (retval) | 1579 | if (retval) |
| 1558 | goto failed_usb_register; | 1580 | goto failed_usb_register; |
| 1559 | info(DRIVER_DESC " " DRIVER_VERSION); | 1581 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
| 1582 | DRIVER_DESC "\n"); | ||
| 1560 | return 0; | 1583 | return 0; |
| 1561 | failed_usb_register: | 1584 | failed_usb_register: |
| 1562 | usb_serial_deregister(&whiteheat_device); | 1585 | usb_serial_deregister(&whiteheat_device); |
diff --git a/drivers/usb/storage/onetouch.c b/drivers/usb/storage/onetouch.c index 98b89ea9e312..c7bf8954b4e4 100644 --- a/drivers/usb/storage/onetouch.c +++ b/drivers/usb/storage/onetouch.c | |||
| @@ -78,8 +78,8 @@ static void usb_onetouch_irq(struct urb *urb) | |||
| 78 | resubmit: | 78 | resubmit: |
| 79 | retval = usb_submit_urb (urb, GFP_ATOMIC); | 79 | retval = usb_submit_urb (urb, GFP_ATOMIC); |
| 80 | if (retval) | 80 | if (retval) |
| 81 | err ("can't resubmit intr, %s-%s/input0, retval %d", | 81 | dev_err(&dev->dev, "can't resubmit intr, %s-%s/input0, " |
| 82 | onetouch->udev->bus->bus_name, | 82 | "retval %d\n", onetouch->udev->bus->bus_name, |
| 83 | onetouch->udev->devpath, retval); | 83 | onetouch->udev->devpath, retval); |
| 84 | } | 84 | } |
| 85 | 85 | ||
| @@ -90,7 +90,7 @@ static int usb_onetouch_open(struct input_dev *dev) | |||
| 90 | onetouch->is_open = 1; | 90 | onetouch->is_open = 1; |
| 91 | onetouch->irq->dev = onetouch->udev; | 91 | onetouch->irq->dev = onetouch->udev; |
| 92 | if (usb_submit_urb(onetouch->irq, GFP_KERNEL)) { | 92 | if (usb_submit_urb(onetouch->irq, GFP_KERNEL)) { |
| 93 | err("usb_submit_urb failed"); | 93 | dev_err(&dev->dev, "usb_submit_urb failed\n"); |
| 94 | return -EIO; | 94 | return -EIO; |
| 95 | } | 95 | } |
| 96 | 96 | ||
| @@ -117,7 +117,8 @@ static void usb_onetouch_pm_hook(struct us_data *us, int action) | |||
| 117 | break; | 117 | break; |
| 118 | case US_RESUME: | 118 | case US_RESUME: |
| 119 | if (usb_submit_urb(onetouch->irq, GFP_KERNEL) != 0) | 119 | if (usb_submit_urb(onetouch->irq, GFP_KERNEL) != 0) |
| 120 | err("usb_submit_urb failed"); | 120 | dev_err(&onetouch->irq->dev->dev, |
| 121 | "usb_submit_urb failed\n"); | ||
| 121 | break; | 122 | break; |
| 122 | default: | 123 | default: |
| 123 | break; | 124 | break; |
diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c index 3523a0bfa0ff..79108d5d3171 100644 --- a/drivers/usb/storage/transport.c +++ b/drivers/usb/storage/transport.c | |||
| @@ -663,7 +663,7 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us) | |||
| 663 | } | 663 | } |
| 664 | 664 | ||
| 665 | /* Did we transfer less than the minimum amount required? */ | 665 | /* Did we transfer less than the minimum amount required? */ |
| 666 | if (srb->result == SAM_STAT_GOOD && | 666 | if ((srb->result == SAM_STAT_GOOD || srb->sense_buffer[2] == 0) && |
| 667 | scsi_bufflen(srb) - scsi_get_resid(srb) < srb->underflow) | 667 | scsi_bufflen(srb) - scsi_get_resid(srb) < srb->underflow) |
| 668 | srb->result = (DID_ERROR << 16) | (SUGGEST_RETRY << 24); | 668 | srb->result = (DID_ERROR << 16) | (SUGGEST_RETRY << 24); |
| 669 | 669 | ||
diff --git a/include/linux/usb.h b/include/linux/usb.h index 94ac74aba6b6..8fa973bede5e 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h | |||
| @@ -1135,6 +1135,7 @@ struct usb_anchor { | |||
| 1135 | struct list_head urb_list; | 1135 | struct list_head urb_list; |
| 1136 | wait_queue_head_t wait; | 1136 | wait_queue_head_t wait; |
| 1137 | spinlock_t lock; | 1137 | spinlock_t lock; |
| 1138 | unsigned int poisoned:1; | ||
| 1138 | }; | 1139 | }; |
| 1139 | 1140 | ||
| 1140 | static inline void init_usb_anchor(struct usb_anchor *anchor) | 1141 | static inline void init_usb_anchor(struct usb_anchor *anchor) |
| @@ -1459,12 +1460,18 @@ extern struct urb *usb_get_urb(struct urb *urb); | |||
| 1459 | extern int usb_submit_urb(struct urb *urb, gfp_t mem_flags); | 1460 | extern int usb_submit_urb(struct urb *urb, gfp_t mem_flags); |
| 1460 | extern int usb_unlink_urb(struct urb *urb); | 1461 | extern int usb_unlink_urb(struct urb *urb); |
| 1461 | extern void usb_kill_urb(struct urb *urb); | 1462 | extern void usb_kill_urb(struct urb *urb); |
| 1463 | extern void usb_poison_urb(struct urb *urb); | ||
| 1464 | extern void usb_unpoison_urb(struct urb *urb); | ||
| 1462 | extern void usb_kill_anchored_urbs(struct usb_anchor *anchor); | 1465 | extern void usb_kill_anchored_urbs(struct usb_anchor *anchor); |
| 1466 | extern void usb_poison_anchored_urbs(struct usb_anchor *anchor); | ||
| 1463 | extern void usb_unlink_anchored_urbs(struct usb_anchor *anchor); | 1467 | extern void usb_unlink_anchored_urbs(struct usb_anchor *anchor); |
| 1464 | extern void usb_anchor_urb(struct urb *urb, struct usb_anchor *anchor); | 1468 | extern void usb_anchor_urb(struct urb *urb, struct usb_anchor *anchor); |
| 1465 | extern void usb_unanchor_urb(struct urb *urb); | 1469 | extern void usb_unanchor_urb(struct urb *urb); |
| 1466 | extern int usb_wait_anchor_empty_timeout(struct usb_anchor *anchor, | 1470 | extern int usb_wait_anchor_empty_timeout(struct usb_anchor *anchor, |
| 1467 | unsigned int timeout); | 1471 | unsigned int timeout); |
| 1472 | extern struct urb *usb_get_from_anchor(struct usb_anchor *anchor); | ||
| 1473 | extern void usb_scuttle_anchored_urbs(struct usb_anchor *anchor); | ||
| 1474 | extern int usb_anchor_empty(struct usb_anchor *anchor); | ||
| 1468 | 1475 | ||
| 1469 | /** | 1476 | /** |
| 1470 | * usb_urb_dir_in - check if an URB describes an IN transfer | 1477 | * usb_urb_dir_in - check if an URB describes an IN transfer |
diff --git a/include/linux/usb/Kbuild b/include/linux/usb/Kbuild index 42e84fc315e3..54c446309a2a 100644 --- a/include/linux/usb/Kbuild +++ b/include/linux/usb/Kbuild | |||
| @@ -4,4 +4,5 @@ header-y += ch9.h | |||
| 4 | header-y += gadgetfs.h | 4 | header-y += gadgetfs.h |
| 5 | header-y += midi.h | 5 | header-y += midi.h |
| 6 | header-y += g_printer.h | 6 | header-y += g_printer.h |
| 7 | 7 | header-y += tmc.h | |
| 8 | header-y += vstusb.h | ||
diff --git a/include/linux/usb/cdc.h b/include/linux/usb/cdc.h index ca228bb94218..18a729343ffa 100644 --- a/include/linux/usb/cdc.h +++ b/include/linux/usb/cdc.h | |||
| @@ -160,6 +160,15 @@ struct usb_cdc_mdlm_detail_desc { | |||
| 160 | __u8 bDetailData[0]; | 160 | __u8 bDetailData[0]; |
| 161 | } __attribute__ ((packed)); | 161 | } __attribute__ ((packed)); |
| 162 | 162 | ||
| 163 | /* "OBEX Control Model Functional Descriptor" */ | ||
| 164 | struct usb_cdc_obex_desc { | ||
| 165 | __u8 bLength; | ||
| 166 | __u8 bDescriptorType; | ||
| 167 | __u8 bDescriptorSubType; | ||
| 168 | |||
| 169 | __le16 bcdVersion; | ||
| 170 | } __attribute__ ((packed)); | ||
| 171 | |||
| 163 | /*-------------------------------------------------------------------------*/ | 172 | /*-------------------------------------------------------------------------*/ |
| 164 | 173 | ||
| 165 | /* | 174 | /* |
diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h index c932390c6da0..935c380ffe47 100644 --- a/include/linux/usb/composite.h +++ b/include/linux/usb/composite.h | |||
| @@ -130,6 +130,9 @@ struct usb_function { | |||
| 130 | 130 | ||
| 131 | int usb_add_function(struct usb_configuration *, struct usb_function *); | 131 | int usb_add_function(struct usb_configuration *, struct usb_function *); |
| 132 | 132 | ||
| 133 | int usb_function_deactivate(struct usb_function *); | ||
| 134 | int usb_function_activate(struct usb_function *); | ||
| 135 | |||
| 133 | int usb_interface_id(struct usb_configuration *, struct usb_function *); | 136 | int usb_interface_id(struct usb_configuration *, struct usb_function *); |
| 134 | 137 | ||
| 135 | /** | 138 | /** |
| @@ -316,9 +319,13 @@ struct usb_composite_dev { | |||
| 316 | struct usb_composite_driver *driver; | 319 | struct usb_composite_driver *driver; |
| 317 | u8 next_string_id; | 320 | u8 next_string_id; |
| 318 | 321 | ||
| 319 | spinlock_t lock; | 322 | /* the gadget driver won't enable the data pullup |
| 323 | * while the deactivation count is nonzero. | ||
| 324 | */ | ||
| 325 | unsigned deactivations; | ||
| 320 | 326 | ||
| 321 | /* REVISIT use and existence of lock ... */ | 327 | /* protects at least deactivation count */ |
| 328 | spinlock_t lock; | ||
| 322 | }; | 329 | }; |
| 323 | 330 | ||
| 324 | extern int usb_string_id(struct usb_composite_dev *c); | 331 | extern int usb_string_id(struct usb_composite_dev *c); |
diff --git a/include/linux/usb/serial.h b/include/linux/usb/serial.h index 655341d0f534..0b8617a9176d 100644 --- a/include/linux/usb/serial.h +++ b/include/linux/usb/serial.h | |||
| @@ -192,7 +192,7 @@ static inline void usb_set_serial_data(struct usb_serial *serial, void *data) | |||
| 192 | * The driver.owner field should be set to the module owner of this driver. | 192 | * The driver.owner field should be set to the module owner of this driver. |
| 193 | * The driver.name field should be set to the name of this driver (remember | 193 | * The driver.name field should be set to the name of this driver (remember |
| 194 | * it will show up in sysfs, so it needs to be short and to the point. | 194 | * it will show up in sysfs, so it needs to be short and to the point. |
| 195 | * Useing the module name is a good idea.) | 195 | * Using the module name is a good idea.) |
| 196 | */ | 196 | */ |
| 197 | struct usb_serial_driver { | 197 | struct usb_serial_driver { |
| 198 | const char *description; | 198 | const char *description; |
diff --git a/include/linux/usb/tmc.h b/include/linux/usb/tmc.h new file mode 100644 index 000000000000..c045ae12556c --- /dev/null +++ b/include/linux/usb/tmc.h | |||
| @@ -0,0 +1,43 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2007 Stefan Kopp, Gechingen, Germany | ||
| 3 | * Copyright (C) 2008 Novell, Inc. | ||
| 4 | * Copyright (C) 2008 Greg Kroah-Hartman <gregkh@suse.de> | ||
| 5 | * | ||
| 6 | * This file holds USB constants defined by the USB Device Class | ||
| 7 | * Definition for Test and Measurement devices published by the USB-IF. | ||
| 8 | * | ||
| 9 | * It also has the ioctl definitions for the usbtmc kernel driver that | ||
| 10 | * userspace needs to know about. | ||
| 11 | */ | ||
| 12 | |||
| 13 | #ifndef __LINUX_USB_TMC_H | ||
| 14 | #define __LINUX_USB_TMC_H | ||
| 15 | |||
| 16 | /* USB TMC status values */ | ||
| 17 | #define USBTMC_STATUS_SUCCESS 0x01 | ||
| 18 | #define USBTMC_STATUS_PENDING 0x02 | ||
| 19 | #define USBTMC_STATUS_FAILED 0x80 | ||
| 20 | #define USBTMC_STATUS_TRANSFER_NOT_IN_PROGRESS 0x81 | ||
| 21 | #define USBTMC_STATUS_SPLIT_NOT_IN_PROGRESS 0x82 | ||
| 22 | #define USBTMC_STATUS_SPLIT_IN_PROGRESS 0x83 | ||
| 23 | |||
| 24 | /* USB TMC requests values */ | ||
| 25 | #define USBTMC_REQUEST_INITIATE_ABORT_BULK_OUT 1 | ||
| 26 | #define USBTMC_REQUEST_CHECK_ABORT_BULK_OUT_STATUS 2 | ||
| 27 | #define USBTMC_REQUEST_INITIATE_ABORT_BULK_IN 3 | ||
| 28 | #define USBTMC_REQUEST_CHECK_ABORT_BULK_IN_STATUS 4 | ||
| 29 | #define USBTMC_REQUEST_INITIATE_CLEAR 5 | ||
| 30 | #define USBTMC_REQUEST_CHECK_CLEAR_STATUS 6 | ||
| 31 | #define USBTMC_REQUEST_GET_CAPABILITIES 7 | ||
| 32 | #define USBTMC_REQUEST_INDICATOR_PULSE 64 | ||
| 33 | |||
| 34 | /* Request values for USBTMC driver's ioctl entry point */ | ||
| 35 | #define USBTMC_IOC_NR 91 | ||
| 36 | #define USBTMC_IOCTL_INDICATOR_PULSE _IO(USBTMC_IOC_NR, 1) | ||
| 37 | #define USBTMC_IOCTL_CLEAR _IO(USBTMC_IOC_NR, 2) | ||
| 38 | #define USBTMC_IOCTL_ABORT_BULK_OUT _IO(USBTMC_IOC_NR, 3) | ||
| 39 | #define USBTMC_IOCTL_ABORT_BULK_IN _IO(USBTMC_IOC_NR, 4) | ||
| 40 | #define USBTMC_IOCTL_CLEAR_OUT_HALT _IO(USBTMC_IOC_NR, 6) | ||
| 41 | #define USBTMC_IOCTL_CLEAR_IN_HALT _IO(USBTMC_IOC_NR, 7) | ||
| 42 | |||
| 43 | #endif | ||
diff --git a/include/linux/usb/vstusb.h b/include/linux/usb/vstusb.h new file mode 100644 index 000000000000..1cfac67191ff --- /dev/null +++ b/include/linux/usb/vstusb.h | |||
| @@ -0,0 +1,71 @@ | |||
| 1 | /***************************************************************************** | ||
| 2 | * File: drivers/usb/misc/vstusb.h | ||
| 3 | * | ||
| 4 | * Purpose: Support for the bulk USB Vernier Spectrophotometers | ||
| 5 | * | ||
| 6 | * Author: EQware Engineering, Inc. | ||
| 7 | * Oregon City, OR, USA 97045 | ||
| 8 | * | ||
| 9 | * Copyright: 2007, 2008 | ||
| 10 | * Vernier Software & Technology | ||
| 11 | * Beaverton, OR, USA 97005 | ||
| 12 | * | ||
| 13 | * Web: www.vernier.com | ||
| 14 | * | ||
| 15 | * This program is free software; you can redistribute it and/or modify | ||
| 16 | * it under the terms of the GNU General Public License version 2 as | ||
| 17 | * published by the Free Software Foundation. | ||
| 18 | * | ||
| 19 | *****************************************************************************/ | ||
| 20 | /***************************************************************************** | ||
| 21 | * | ||
| 22 | * The vstusb module is a standard usb 'client' driver running on top of the | ||
| 23 | * standard usb host controller stack. | ||
| 24 | * | ||
| 25 | * In general, vstusb supports standard bulk usb pipes. It supports multiple | ||
| 26 | * devices and multiple pipes per device. | ||
| 27 | * | ||
| 28 | * The vstusb driver supports two interfaces: | ||
| 29 | * 1 - ioctl SEND_PIPE/RECV_PIPE - a general bulk write/read msg | ||
| 30 | * interface to any pipe with timeout support; | ||
| 31 | * 2 - standard read/write with ioctl config - offers standard read/write | ||
| 32 | * interface with ioctl configured pipes and timeouts. | ||
| 33 | * | ||
| 34 | * Both interfaces can be signal from other process and will abort its i/o | ||
| 35 | * operation. | ||
| 36 | * | ||
| 37 | * A timeout of 0 means NO timeout. The user can still terminate the read via | ||
| 38 | * signal. | ||
| 39 | * | ||
| 40 | * If using multiple threads with this driver, the user should ensure that | ||
| 41 | * any reads, writes, or ioctls are complete before closing the device. | ||
| 42 | * Changing read/write timeouts or pipes takes effect on next read/write. | ||
| 43 | * | ||
| 44 | *****************************************************************************/ | ||
| 45 | |||
| 46 | struct vstusb_args { | ||
| 47 | union { | ||
| 48 | /* this struct is used for IOCTL_VSTUSB_SEND_PIPE, * | ||
| 49 | * IOCTL_VSTUSB_RECV_PIPE, and read()/write() fops */ | ||
| 50 | struct { | ||
| 51 | void __user *buffer; | ||
| 52 | size_t count; | ||
| 53 | unsigned int timeout_ms; | ||
| 54 | int pipe; | ||
| 55 | }; | ||
| 56 | |||
| 57 | /* this one is used for IOCTL_VSTUSB_CONFIG_RW */ | ||
| 58 | struct { | ||
| 59 | int rd_pipe; | ||
| 60 | int rd_timeout_ms; | ||
| 61 | int wr_pipe; | ||
| 62 | int wr_timeout_ms; | ||
| 63 | }; | ||
| 64 | }; | ||
| 65 | }; | ||
| 66 | |||
| 67 | #define VST_IOC_MAGIC 'L' | ||
| 68 | #define VST_IOC_FIRST 0x20 | ||
| 69 | #define IOCTL_VSTUSB_SEND_PIPE _IO(VST_IOC_MAGIC, VST_IOC_FIRST) | ||
| 70 | #define IOCTL_VSTUSB_RECV_PIPE _IO(VST_IOC_MAGIC, VST_IOC_FIRST + 1) | ||
| 71 | #define IOCTL_VSTUSB_CONFIG_RW _IO(VST_IOC_MAGIC, VST_IOC_FIRST + 2) | ||
