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.
...

+8485 -1544
+62
Documentation/ABI/stable/sysfs-driver-usb-usbtmc
··· 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.
+16
Documentation/ABI/testing/sysfs-bus-usb
··· 85 85 Users: 86 86 PowerTOP <power@bughost.org> 87 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/
+43
Documentation/ABI/testing/sysfs-bus-usb-devices-usbsevseg
··· 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.
+3
Documentation/DocBook/gadget.tmpl
··· 557 557 </para> 558 558 559 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 563 !Edrivers/usb/gadget/f_serial.c 561 564 562 565 </sect1>
+3
Documentation/devices.txt
··· 2571 2571 160 = /dev/usb/legousbtower0 1st USB Legotower device 2572 2572 ... 2573 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 2577 240 = /dev/usb/dabusb0 First daubusb device 2575 2578 ... 2576 2579 243 = /dev/usb/dabusb3 Fourth dabusb device
+3
Documentation/ioctl-number.txt
··· 92 92 'J' 00-1F drivers/scsi/gdth_ioctl.h 93 93 'K' all linux/kd.h 94 94 'L' 00-1F linux/loop.h 95 + 'L' 20-2F driver/usb/misc/vstusb.h 95 96 'L' E0-FF linux/ppdd.h encrypted disk device driver 96 97 <http://linux01.gwdg.de/~alatham/ppdd.html> 97 98 'M' all linux/soundcard.h ··· 111 110 'W' 00-1F linux/wanrouter.h conflict! 112 111 'X' all linux/xfs_fs.h 113 112 'Y' all linux/cyclades.h 113 + '[' 00-07 linux/usb/usbtmc.h USB Test and Measurement Devices 114 + <mailto:gregkh@suse.de> 114 115 'a' all ATM on linux 115 116 <http://lrcwww.epfl.ch/linux-atm/magic.html> 116 117 'b' 00-FF bit3 vme host bridge
+19
Documentation/kernel-parameters.txt
··· 2253 2253 autosuspended. Devices for which the delay is set 2254 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 2275 usbhid.mousepoll= 2257 2276 [USBHID] The interval which mice are to be polled at. 2258 2277
+17
Documentation/usb/anchors.txt
··· 52 52 the call returns. They may be unlinked later but will be unlinked in 53 53 finite time. 54 54 55 + usb_scuttle_anchored_urbs() 56 + --------------------------- 57 + 58 + All URBs of an anchor are unanchored en masse. 59 + 55 60 usb_wait_anchor_empty_timeout() 56 61 ------------------------------- 57 62 ··· 64 59 or a timeout, whichever comes first. Its return value will tell you 65 60 whether the timeout was reached. 66 61 62 + usb_anchor_empty() 63 + ------------------ 67 64 65 + Returns true if no URBs are associated with an anchor. Locking 66 + is the caller's responsibility. 67 + 68 + usb_get_from_anchor() 69 + --------------------- 70 + 71 + Returns the oldest anchored URB of an anchor. The URB is unanchored 72 + and returned with a reference. As you may mix URBs to several 73 + destinations in one anchor you have no guarantee the chronologically 74 + first submitted URB is returned.
+46
Documentation/usb/misc_usbsevseg.txt
··· 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 +
+4 -4
Documentation/usb/power-management.txt
··· 350 350 351 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 354 - usb_autopm_set_interface(), which will attempt an autoresume. 355 - 356 - usb_autopm_disable() sets pm_usage_cnt to 0 and then calls 353 + usb_autopm_enable() sets pm_usage_cnt to 0 and then calls 357 354 usb_autopm_set_interface(), which will attempt an autosuspend. 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 358 359 359 The conventional usage pattern is that a driver calls 360 360 usb_autopm_get_interface() in its open routine and
-3
drivers/block/ub.c
··· 349 349 350 350 struct work_struct reset_work; 351 351 wait_queue_head_t reset_wait; 352 - 353 - int sg_stat[6]; 354 352 }; 355 353 356 354 /* ··· 683 685 goto drop; 684 686 } 685 687 urq->nsg = n_elem; 686 - sc->sg_stat[n_elem < 5 ? n_elem : 5]++; 687 688 688 689 if (blk_pc_request(rq)) { 689 690 ub_cmd_build_packet(sc, lun, cmd, urq);
+2 -2
drivers/hid/usbhid/hid-core.c
··· 428 428 usbhid->out[usbhid->outhead].raw_report = kmalloc(len, GFP_ATOMIC); 429 429 if (!usbhid->out[usbhid->outhead].raw_report) { 430 430 spin_unlock_irqrestore(&usbhid->outlock, flags); 431 - warn("output queueing failed"); 431 + dev_warn(&hid->dev, "output queueing failed\n"); 432 432 return; 433 433 } 434 434 hid_output_report(report, usbhid->out[usbhid->outhead].raw_report); ··· 455 455 usbhid->ctrl[usbhid->ctrlhead].raw_report = kmalloc(len, GFP_ATOMIC); 456 456 if (!usbhid->ctrl[usbhid->ctrlhead].raw_report) { 457 457 spin_unlock_irqrestore(&usbhid->ctrllock, flags); 458 - warn("control queueing failed"); 458 + dev_warn(&hid->dev, "control queueing failed\n"); 459 459 return; 460 460 } 461 461 hid_output_report(report, usbhid->ctrl[usbhid->ctrlhead].raw_report);
+23 -13
drivers/input/joystick/iforce/iforce-ff.c
··· 197 197 * Analyse the changes in an effect, and tell if we need to send an condition 198 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 204 int ret = 0; 203 205 int i; 204 206 205 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 210 return 0; 208 211 } 209 212 ··· 225 222 * Analyse the changes in an effect, and tell if we need to send a magnitude 226 223 * parameter packet 227 224 */ 228 - static int need_magnitude_modifier(struct ff_effect *old, struct ff_effect *effect) 225 + static int need_magnitude_modifier(struct iforce *iforce, 226 + struct ff_effect *old, 227 + struct ff_effect *effect) 229 228 { 230 229 if (effect->type != FF_CONSTANT) { 231 - warn("bad effect type in need_envelope_modifier"); 230 + dev_warn(&iforce->dev->dev, "bad effect type in %s\n", 231 + __func__); 232 232 return 0; 233 233 } 234 234 ··· 242 236 * Analyse the changes in an effect, and tell if we need to send an envelope 243 237 * parameter packet 244 238 */ 245 - static int need_envelope_modifier(struct ff_effect *old, struct ff_effect *effect) 239 + static int need_envelope_modifier(struct iforce *iforce, struct ff_effect *old, 240 + struct ff_effect *effect) 246 241 { 247 242 switch (effect->type) { 248 243 case FF_CONSTANT: ··· 263 256 break; 264 257 265 258 default: 266 - warn("bad effect type in need_envelope_modifier"); 259 + dev_warn(&iforce->dev->dev, "bad effect type in %s\n", 260 + __func__); 267 261 } 268 262 269 263 return 0; ··· 274 266 * Analyse the changes in an effect, and tell if we need to send a periodic 275 267 * parameter effect 276 268 */ 277 - static int need_period_modifier(struct ff_effect *old, struct ff_effect *new) 269 + static int need_period_modifier(struct iforce *iforce, struct ff_effect *old, 270 + struct ff_effect *new) 278 271 { 279 272 if (new->type != FF_PERIODIC) { 280 - warn("bad effect type in need_period_modifier"); 273 + dev_warn(&iforce->dev->dev, "bad effect type in %s\n", 274 + __func__); 281 275 return 0; 282 276 } 283 277 return (old->u.periodic.period != new->u.periodic.period ··· 365 355 int param2_err = 1; 366 356 int core_err = 0; 367 357 368 - if (!old || need_period_modifier(old, effect)) { 358 + if (!old || need_period_modifier(iforce, old, effect)) { 369 359 param1_err = make_period_modifier(iforce, mod1_chunk, 370 360 old != NULL, 371 361 effect->u.periodic.magnitude, effect->u.periodic.offset, ··· 375 365 set_bit(FF_MOD1_IS_USED, core_effect->flags); 376 366 } 377 367 378 - if (!old || need_envelope_modifier(old, effect)) { 368 + if (!old || need_envelope_modifier(iforce, old, effect)) { 379 369 param2_err = make_envelope_modifier(iforce, mod2_chunk, 380 370 old !=NULL, 381 371 effect->u.periodic.envelope.attack_length, ··· 435 425 int param2_err = 1; 436 426 int core_err = 0; 437 427 438 - if (!old || need_magnitude_modifier(old, effect)) { 428 + if (!old || need_magnitude_modifier(iforce, old, effect)) { 439 429 param1_err = make_magnitude_modifier(iforce, mod1_chunk, 440 430 old != NULL, 441 431 effect->u.constant.level); ··· 444 434 set_bit(FF_MOD1_IS_USED, core_effect->flags); 445 435 } 446 436 447 - if (!old || need_envelope_modifier(old, effect)) { 437 + if (!old || need_envelope_modifier(iforce, old, effect)) { 448 438 param2_err = make_envelope_modifier(iforce, mod2_chunk, 449 439 old != NULL, 450 440 effect->u.constant.envelope.attack_length, ··· 497 487 default: return -1; 498 488 } 499 489 500 - if (!old || need_condition_modifier(old, effect)) { 490 + if (!old || need_condition_modifier(iforce, old, effect)) { 501 491 param_err = make_condition_modifier(iforce, mod1_chunk, 502 492 old != NULL, 503 493 effect->u.condition[0].right_saturation,
+8 -6
drivers/input/joystick/iforce/iforce-main.c
··· 218 218 /* Check: no effects should be present in memory */ 219 219 for (i = 0; i < dev->ff->max_effects; i++) { 220 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 224 break; 223 225 } 224 226 } ··· 337 335 if (!iforce_get_id_packet(iforce, "M")) 338 336 input_dev->id.vendor = (iforce->edata[2] << 8) | iforce->edata[1]; 339 337 else 340 - warn("Device does not respond to id packet M"); 338 + dev_warn(&iforce->dev->dev, "Device does not respond to id packet M\n"); 341 339 342 340 if (!iforce_get_id_packet(iforce, "P")) 343 341 input_dev->id.product = (iforce->edata[2] << 8) | iforce->edata[1]; 344 342 else 345 - warn("Device does not respond to id packet P"); 343 + dev_warn(&iforce->dev->dev, "Device does not respond to id packet P\n"); 346 344 347 345 if (!iforce_get_id_packet(iforce, "B")) 348 346 iforce->device_memory.end = (iforce->edata[2] << 8) | iforce->edata[1]; 349 347 else 350 - warn("Device does not respond to id packet B"); 348 + dev_warn(&iforce->dev->dev, "Device does not respond to id packet B\n"); 351 349 352 350 if (!iforce_get_id_packet(iforce, "N")) 353 351 ff_effects = iforce->edata[1]; 354 352 else 355 - warn("Device does not respond to id packet N"); 353 + dev_warn(&iforce->dev->dev, "Device does not respond to id packet N\n"); 356 354 357 355 /* Check if the device can store more effects than the driver can really handle */ 358 356 if (ff_effects > IFORCE_EFFECTS_MAX) { 359 - warn("Limiting number of effects to %d (device reports %d)", 357 + dev_warn(&iforce->dev->dev, "Limiting number of effects to %d (device reports %d)\n", 360 358 IFORCE_EFFECTS_MAX, ff_effects); 361 359 ff_effects = IFORCE_EFFECTS_MAX; 362 360 }
+5 -3
drivers/input/joystick/iforce/iforce-packets.c
··· 65 65 66 66 67 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 70 spin_unlock_irqrestore(&iforce->xmit_lock, flags); 70 71 return -1; 71 72 } ··· 149 148 return 0; 150 149 } 151 150 } 152 - warn("unused effect %04x updated !!!", addr); 151 + dev_warn(&iforce->dev->dev, "unused effect %04x updated !!!\n", addr); 153 152 return -1; 154 153 } 155 154 ··· 160 159 static int being_used = 0; 161 160 162 161 if (being_used) 163 - warn("re-entrant call to iforce_process %d", being_used); 162 + dev_warn(&iforce->dev->dev, 163 + "re-entrant call to iforce_process %d\n", being_used); 164 164 being_used++; 165 165 166 166 #ifdef CONFIG_JOYSTICK_IFORCE_232
+1 -1
drivers/input/joystick/iforce/iforce-usb.c
··· 64 64 65 65 if ( (n=usb_submit_urb(iforce->out, GFP_ATOMIC)) ) { 66 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 70 /* The IFORCE_XMIT_RUNNING bit is not cleared here. That's intended.
+1 -1
drivers/input/joystick/xpad.c
··· 911 911 { 912 912 int result = usb_register(&xpad_driver); 913 913 if (result == 0) 914 - info(DRIVER_DESC); 914 + printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_DESC "\n"); 915 915 return result; 916 916 } 917 917
+11 -9
drivers/input/misc/ati_remote.c
··· 285 285 }; 286 286 287 287 /* Local function prototypes */ 288 - static void ati_remote_dump (unsigned char *data, unsigned int actual_length); 289 288 static int ati_remote_open (struct input_dev *inputdev); 290 289 static void ati_remote_close (struct input_dev *inputdev); 291 290 static int ati_remote_sendpacket (struct ati_remote *ati_remote, u16 cmd, unsigned char *data); ··· 306 307 /* 307 308 * ati_remote_dump_input 308 309 */ 309 - static void ati_remote_dump(unsigned char *data, unsigned int len) 310 + static void ati_remote_dump(struct device *dev, unsigned char *data, 311 + unsigned int len) 310 312 { 311 313 if ((len == 1) && (data[0] != (unsigned char)0xff) && (data[0] != 0x00)) 312 - warn("Weird byte 0x%02x", data[0]); 314 + dev_warn(dev, "Weird byte 0x%02x\n", data[0]); 313 315 else if (len == 4) 314 - warn("Weird key %02x %02x %02x %02x", 316 + dev_warn(dev, "Weird key %02x %02x %02x %02x\n", 315 317 data[0], data[1], data[2], data[3]); 316 318 else 317 - warn("Weird data, len=%d %02x %02x %02x %02x %02x %02x ...", 319 + dev_warn(dev, "Weird data, len=%d %02x %02x %02x %02x %02x %02x ...\n", 318 320 len, data[0], data[1], data[2], data[3], data[4], data[5]); 319 321 } 320 322 ··· 470 470 /* Deal with strange looking inputs */ 471 471 if ( (urb->actual_length != 4) || (data[0] != 0x14) || 472 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 474 return; 475 475 } 476 476 ··· 814 814 ati_remote = usb_get_intfdata(interface); 815 815 usb_set_intfdata(interface, NULL); 816 816 if (!ati_remote) { 817 - warn("%s - null device?\n", __func__); 817 + dev_warn(&interface->dev, "%s - null device?\n", __func__); 818 818 return; 819 819 } 820 820 ··· 834 834 835 835 result = usb_register(&ati_remote_driver); 836 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 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 843 return result; 842 844 }
+2 -1
drivers/input/misc/yealink.c
··· 999 999 { 1000 1000 int ret = usb_register(&yealink_driver); 1001 1001 if (ret == 0) 1002 - info(DRIVER_DESC ":" DRIVER_VERSION); 1002 + printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" 1003 + DRIVER_DESC "\n"); 1003 1004 return ret; 1004 1005 } 1005 1006
+2 -1
drivers/input/tablet/acecad.c
··· 280 280 { 281 281 int result = usb_register(&usb_acecad_driver); 282 282 if (result == 0) 283 - info(DRIVER_VERSION ":" DRIVER_DESC); 283 + printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" 284 + DRIVER_DESC "\n"); 284 285 return result; 285 286 } 286 287
+16 -10
drivers/input/tablet/aiptek.c
··· 1706 1706 aiptek = kzalloc(sizeof(struct aiptek), GFP_KERNEL); 1707 1707 inputdev = input_allocate_device(); 1708 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 1711 goto fail1; 1711 1712 } 1712 1713 1713 1714 aiptek->data = usb_buffer_alloc(usbdev, AIPTEK_PACKET_LENGTH, 1714 1715 GFP_ATOMIC, &aiptek->data_dma); 1715 1716 if (!aiptek->data) { 1716 - warn("aiptek: cannot allocate usb buffer"); 1717 + dev_warn(&intf->dev, "cannot allocate usb buffer\n"); 1717 1718 goto fail1; 1718 1719 } 1719 1720 1720 1721 aiptek->urb = usb_alloc_urb(0, GFP_KERNEL); 1721 1722 if (!aiptek->urb) { 1722 - warn("aiptek: cannot allocate urb"); 1723 + dev_warn(&intf->dev, "cannot allocate urb\n"); 1723 1724 goto fail2; 1724 1725 } 1725 1726 ··· 1844 1843 aiptek->curSetting.programmableDelay = speeds[i]; 1845 1844 (void)aiptek_program_tablet(aiptek); 1846 1845 if (aiptek->inputdev->absmax[ABS_X] > 0) { 1847 - info("input: Aiptek using %d ms programming speed\n", 1848 - aiptek->curSetting.programmableDelay); 1846 + dev_info(&intf->dev, 1847 + "Aiptek using %d ms programming speed\n", 1848 + aiptek->curSetting.programmableDelay); 1849 1849 break; 1850 1850 } 1851 1851 } ··· 1854 1852 /* Murphy says that some day someone will have a tablet that fails the 1855 1853 above test. That's you, Frederic Rodrigo */ 1856 1854 if (i == ARRAY_SIZE(speeds)) { 1857 - info("input: Aiptek tried all speeds, no sane response"); 1855 + dev_info(&intf->dev, 1856 + "Aiptek tried all speeds, no sane response\n"); 1858 1857 goto fail2; 1859 1858 } 1860 1859 ··· 1867 1864 */ 1868 1865 err = sysfs_create_group(&intf->dev.kobj, &aiptek_attribute_group); 1869 1866 if (err) { 1870 - warn("aiptek: cannot create sysfs group err: %d", err); 1867 + dev_warn(&intf->dev, "cannot create sysfs group err: %d\n", 1868 + err); 1871 1869 goto fail3; 1872 1870 } 1873 1871 ··· 1876 1872 */ 1877 1873 err = input_register_device(aiptek->inputdev); 1878 1874 if (err) { 1879 - warn("aiptek: input_register_device returned err: %d", err); 1875 + dev_warn(&intf->dev, 1876 + "input_register_device returned err: %d\n", err); 1880 1877 goto fail4; 1881 1878 } 1882 1879 return 0; ··· 1927 1922 { 1928 1923 int result = usb_register(&aiptek_driver); 1929 1924 if (result == 0) { 1930 - info(DRIVER_VERSION ": " DRIVER_AUTHOR); 1931 - info(DRIVER_DESC); 1925 + printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" 1926 + DRIVER_DESC "\n"); 1927 + printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_AUTHOR "\n"); 1932 1928 } 1933 1929 return result; 1934 1930 }
+2 -2
drivers/input/tablet/gtco.c
··· 2 2 3 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 7 TO CHECK: Is pressure done right on report 5? 8 8 ··· 1010 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 1016 /* STANDARD MODULE LOAD ROUTINES */
+2 -1
drivers/input/tablet/kbtab.c
··· 215 215 retval = usb_register(&kbtab_driver); 216 216 if (retval) 217 217 goto out; 218 - info(DRIVER_VERSION ":" DRIVER_DESC); 218 + printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" 219 + DRIVER_DESC "\n"); 219 220 out: 220 221 return retval; 221 222 }
+2 -1
drivers/input/tablet/wacom_sys.c
··· 385 385 wacom_driver.id_table = get_device_table(); 386 386 result = usb_register(&wacom_driver); 387 387 if (result == 0) 388 - info(DRIVER_VERSION ":" DRIVER_DESC); 388 + printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" 389 + DRIVER_DESC "\n"); 389 390 return result; 390 391 } 391 392
+8 -5
drivers/media/radio/dsbr100.c
··· 310 310 311 311 radio->curfreq = f->frequency; 312 312 if (dsbr100_setfreq(radio, radio->curfreq)==-1) 313 - warn("Set frequency failed"); 313 + dev_warn(&radio->usbdev->dev, "Set frequency failed\n"); 314 314 return 0; 315 315 } 316 316 ··· 361 361 case V4L2_CID_AUDIO_MUTE: 362 362 if (ctrl->value) { 363 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 366 return -EBUSY; 366 367 } 367 368 } else { 368 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 372 return -EBUSY; 371 373 } 372 374 } ··· 418 416 radio->muted = 1; 419 417 420 418 if (dsbr100_start(radio)<0) { 421 - warn("Radio did not start up properly"); 419 + dev_warn(&radio->usbdev->dev, 420 + "Radio did not start up properly\n"); 422 421 radio->users = 0; 423 422 unlock_kernel(); 424 423 return -EIO; ··· 504 501 radio->curfreq = FREQ_MIN*FREQ_MUL; 505 502 video_set_drvdata(radio->videodev, radio); 506 503 if (video_register_device(radio->videodev, VFL_TYPE_RADIO, radio_nr) < 0) { 507 - warn("Could not register video device"); 504 + dev_warn(&intf->dev, "Could not register video device\n"); 508 505 video_device_release(radio->videodev); 509 506 kfree(radio->transfer_buffer); 510 507 kfree(radio);
+2 -2
drivers/media/video/dabusb.c
··· 192 192 err("dabusb_iso_complete: invalid len %d", len); 193 193 } 194 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 196 if (dst != purb->actual_length) 197 197 err("dst!=purb->actual_length:%d!=%d", dst, purb->actual_length); 198 198 } ··· 289 289 } 290 290 291 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 293 if(usb_clear_halt(s->usbdev, usb_pipeendpoint(pipe))) 294 294 err("request failed"); 295 295 }
+12 -7
drivers/media/video/ov511.c
··· 1098 1098 reg_w(ov, R51x_SYS_SNAP, 0x02); 1099 1099 reg_w(ov, R51x_SYS_SNAP, 0x00); 1100 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 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 ··· 1116 1115 if (ov->bclass == BCL_OV511) { 1117 1116 ret = reg_r(ov, R51x_SYS_SNAP); 1118 1117 if (ret < 0) { 1119 - err("Error checking snspshot status (%d)", ret); 1118 + dev_err(&ov->dev->dev, 1119 + "Error checking snspshot status (%d)\n", ret); 1120 1120 } else if (ret & 0x08) { 1121 1121 status = 1; 1122 1122 } 1123 1123 } else if (ov->bclass == BCL_OV518) { 1124 - warn("snapshot check not supported yet on OV518(+)"); 1124 + dev_warn(&ov->dev->dev, 1125 + "snapshot check not supported yet on OV518(+)\n"); 1125 1126 } else { 1126 - err("check snap: invalid bridge type"); 1127 + dev_err(&ov->dev->dev, "clear snap: invalid bridge type\n"); 1127 1128 } 1128 1129 1129 1130 return status; ··· 5220 5217 if (ov->bclass == BCL_OV511) 5221 5218 reg_w(ov, 0x11, 0x00); 5222 5219 else 5223 - warn("SAA7111A not yet supported with OV518/OV518+"); 5220 + dev_warn(&ov->dev->dev, 5221 + "SAA7111A not yet supported with OV518/OV518+\n"); 5224 5222 5225 5223 return 0; 5226 5224 } ··· 5460 5456 * required. OV518 has no uncompressed mode, to save RAM. */ 5461 5457 if (!dumppix && !ov->compress) { 5462 5458 ov->compress = 1; 5463 - warn("Compression required with OV518...enabling"); 5459 + dev_warn(&ov->dev->dev, 5460 + "Compression required with OV518...enabling\n"); 5464 5461 } 5465 5462 5466 5463 if (ov->bridge == BRG_OV518) {
+5 -3
drivers/media/video/usbvideo/konicawc.c
··· 229 229 230 230 cam->input = input_dev = input_allocate_device(); 231 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 234 return; 234 235 } 235 236 ··· 244 243 245 244 error = input_register_device(cam->input); 246 245 if (error) { 247 - warn("Failed to register camera's input device, err: %d\n", 248 - error); 246 + dev_warn(&dev->dev, 247 + "Failed to register camera's input device, err: %d\n", 248 + error); 249 249 input_free_device(cam->input); 250 250 cam->input = NULL; 251 251 }
+8 -6
drivers/media/video/usbvideo/quickcam_messenger.c
··· 93 93 94 94 cam->input = input_dev = input_allocate_device(); 95 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 97 return; 98 98 } 99 99 ··· 107 107 108 108 error = input_register_device(cam->input); 109 109 if (error) { 110 - warn("Failed to register camera's input device, err: %d\n", 111 - error); 110 + dev_warn(&dev->dev, 111 + "Failed to register camera's input device, err: %d\n", 112 + error); 112 113 input_free_device(cam->input); 113 114 cam->input = NULL; 114 115 } ··· 588 587 dataurb->iso_frame_desc[i].offset; 589 588 590 589 if (st < 0) { 591 - warn("Data error: packet=%d. len=%d. status=%d.", 592 - i, n, st); 590 + dev_warn(&uvd->dev->dev, 591 + "Data error: packet=%d. len=%d. status=%d.\n", 592 + i, n, st); 593 593 uvd->stats.iso_err_count++; 594 594 continue; 595 595 } ··· 701 699 702 700 ret = qcm_camera_off(uvd); 703 701 if (ret) 704 - warn("couldn't turn the cam off."); 702 + dev_warn(&uvd->dev->dev, "couldn't turn the cam off.\n"); 705 703 706 704 uvd->streaming = 0; 707 705
+2 -2
drivers/mtd/nand/alauda.c
··· 691 691 al[0].port = ALAUDA_PORT_XD; 692 692 al[1].port = ALAUDA_PORT_SM; 693 693 694 - info("alauda probed"); 694 + dev_info(&interface->dev, "alauda probed\n"); 695 695 alauda_check_media(al); 696 696 alauda_check_media(al+1); 697 697 ··· 716 716 if (al) 717 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 722 static struct usb_driver alauda_driver = {
+2 -1
drivers/net/irda/kingsun-sir.c
··· 540 540 if (ret != 0) 541 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 546 usb_set_intfdata(intf, kingsun); 546 547
+2 -1
drivers/net/irda/ks959-sir.c
··· 801 801 if (ret != 0) 802 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 807 usb_set_intfdata(intf, kingsun); 807 808
+2 -1
drivers/net/irda/ksdazzle-sir.c
··· 705 705 if (ret != 0) 706 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 711 usb_set_intfdata(intf, kingsun); 711 712
+10 -8
drivers/net/irda/stir4200.c
··· 506 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 510 return -EINVAL; 511 511 512 512 found: ··· 598 598 err = read_reg(stir, REG_FIFOCTL, stir->fifo_status, 599 599 FIFO_REGS_SIZE); 600 600 if (unlikely(err != FIFO_REGS_SIZE)) { 601 - warn("%s: FIFO register read error: %d", 602 - stir->netdev->name, err); 601 + dev_warn(&stir->netdev->dev, 602 + "FIFO register read error: %d\n", err); 603 603 604 604 return err; 605 605 } ··· 783 783 784 784 if (unlikely(receive_start(stir))) { 785 785 if (net_ratelimit()) 786 - info("%s: receive usb submit failed", 787 - stir->netdev->name); 786 + dev_info(&dev->dev, 787 + "%s: receive usb submit failed\n", 788 + stir->netdev->name); 788 789 stir->receiving = 0; 789 790 msleep(10); 790 791 continue; ··· 837 836 838 837 /* in case of error, the kernel thread will restart us */ 839 838 if (err) { 840 - warn("%s: usb receive submit error: %d", 841 - stir->netdev->name, err); 839 + dev_warn(&stir->netdev->dev, "usb receive submit error: %d\n", 840 + err); 842 841 stir->receiving = 0; 843 842 wake_up_process(stir->thread); 844 843 } ··· 1074 1073 if (ret != 0) 1075 1074 goto err_out2; 1076 1075 1077 - info("IrDA: Registered SigmaTel device %s", net->name); 1076 + dev_info(&intf->dev, "IrDA: Registered SigmaTel device %s\n", 1077 + net->name); 1078 1078 1079 1079 usb_set_intfdata(intf, stir); 1080 1080
+5 -3
drivers/net/usb/catc.c
··· 456 456 { 457 457 struct catc *catc = netdev_priv(netdev); 458 458 459 - warn("Transmit timed out."); 459 + dev_warn(&netdev->dev, "Transmit timed out.\n"); 460 460 usb_unlink_urb(catc->tx_urb); 461 461 } 462 462 ··· 847 847 dbg("64k Memory\n"); 848 848 break; 849 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 852 case 0x87654321: 852 853 catc_set_reg(catc, TxBufCount, 4); 853 854 catc_set_reg(catc, RxBufCount, 16); ··· 954 953 { 955 954 int result = usb_register(&catc_driver); 956 955 if (result == 0) 957 - info(DRIVER_VERSION " " DRIVER_DESC); 956 + printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" 957 + DRIVER_DESC "\n"); 958 958 return result; 959 959 } 960 960
+14 -13
drivers/net/usb/kaweth.c
··· 832 832 833 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 836 skip: 837 837 kaweth->stats.tx_errors++; 838 838 ··· 924 924 { 925 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 928 kaweth->stats.tx_errors++; 929 929 net->trans_start = jiffies; 930 930 ··· 1016 1016 */ 1017 1017 1018 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 1020 } else { 1021 1021 /* Download the firmware */ 1022 - info("Downloading firmware..."); 1022 + dev_info(&intf->dev, "Downloading firmware...\n"); 1023 1023 kaweth->firmware_buf = (__u8 *)__get_free_page(GFP_KERNEL); 1024 1024 if ((result = kaweth_download_firmware(kaweth, 1025 1025 "kaweth/new_code.bin", ··· 1061 1061 } 1062 1062 1063 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 1065 err_fw: 1066 1066 free_page((unsigned long)kaweth->firmware_buf); 1067 1067 free_netdev(netdev); ··· 1075 1075 goto err_free_netdev; 1076 1076 } 1077 1077 1078 - info("Statistics collection: %x", kaweth->configuration.statistics_mask); 1079 - info("Multicast filter limit: %x", kaweth->configuration.max_multicast_filters & ((1 << 15) - 1)); 1080 - info("MTU: %d", le16_to_cpu(kaweth->configuration.segment_size)); 1081 - info("Read MAC address %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x", 1078 + dev_info(&intf->dev, "Statistics collection: %x\n", kaweth->configuration.statistics_mask); 1079 + dev_info(&intf->dev, "Multicast filter limit: %x\n", kaweth->configuration.max_multicast_filters & ((1 << 15) - 1)); 1080 + dev_info(&intf->dev, "MTU: %d\n", le16_to_cpu(kaweth->configuration.segment_size)); 1081 + dev_info(&intf->dev, "Read MAC address %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x\n", 1082 1082 (int)kaweth->configuration.hw_addr[0], 1083 1083 (int)kaweth->configuration.hw_addr[1], 1084 1084 (int)kaweth->configuration.hw_addr[2], ··· 1174 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 1180 dbg("Kaweth probe returning."); 1180 1181 ··· 1206 1205 struct kaweth_device *kaweth = usb_get_intfdata(intf); 1207 1206 struct net_device *netdev; 1208 1207 1209 - info("Unregistering"); 1208 + dev_info(&intf->dev, "Unregistering\n"); 1210 1209 1211 1210 usb_set_intfdata(intf, NULL); 1212 1211 if (!kaweth) { 1213 - warn("unregistering non-existant device"); 1212 + dev_warn(&intf->dev, "unregistering non-existant device\n"); 1214 1213 return; 1215 1214 } 1216 1215 netdev = kaweth->net; ··· 1270 1269 1271 1270 if (!wait_event_timeout(awd.wqh, awd.done, timeout)) { 1272 1271 // timeout 1273 - warn("usb_control/bulk_msg: timeout"); 1272 + dev_warn(&urb->dev->dev, "usb_control/bulk_msg: timeout\n"); 1274 1273 usb_kill_urb(urb); // remove urb safely 1275 1274 status = -ETIMEDOUT; 1276 1275 }
+17 -14
drivers/net/usb/rtl8150.c
··· 221 221 case -ENOENT: 222 222 break; 223 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 226 dev = urb->context; 227 227 clear_bit(RX_REG_SET, &dev->flags); ··· 441 441 case -ENOENT: 442 442 return; /* the urb is in unlink state */ 443 443 case -ETIME: 444 - warn("may be reset is needed?.."); 444 + dev_warn(&urb->dev->dev, "may be reset is needed?..\n"); 445 445 goto goon; 446 446 default: 447 - warn("Rx status %d", urb->status); 447 + dev_warn(&urb->dev->dev, "Rx status %d\n", urb->status); 448 448 goto goon; 449 449 } 450 450 ··· 538 538 if (!netif_device_present(dev->netdev)) 539 539 return; 540 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 543 dev->netdev->trans_start = jiffies; 543 544 netif_wake_queue(dev->netdev); 544 545 } ··· 562 561 return; 563 562 /* -EPIPE: should clear the halt */ 564 563 default: 565 - info("%s: intr status %d", dev->netdev->name, urb->status); 564 + dev_info(&urb->dev->dev, "%s: intr status %d\n", 565 + dev->netdev->name, urb->status); 566 566 goto resubmit; 567 567 } 568 568 ··· 667 665 u8 cr, tcr, rcr, msr; 668 666 669 667 if (!rtl8150_reset(dev)) { 670 - warn("%s - device reset failed", __FUNCTION__); 668 + dev_warn(&dev->udev->dev, "device reset failed\n"); 671 669 } 672 670 /* RCR bit7=1 attach Rx info at the end; =0 HW CRC (which is broken) */ 673 671 rcr = 0x9e; ··· 701 699 static void rtl8150_tx_timeout(struct net_device *netdev) 702 700 { 703 701 rtl8150_t *dev = netdev_priv(netdev); 704 - warn("%s: Tx timeout.", netdev->name); 702 + dev_warn(&netdev->dev, "Tx timeout.\n"); 705 703 usb_unlink_urb(dev->tx_urb); 706 704 dev->stats.tx_errors++; 707 705 } ··· 712 710 netif_stop_queue(netdev); 713 711 if (netdev->flags & IFF_PROMISC) { 714 712 dev->rx_creg |= cpu_to_le16(0x0001); 715 - info("%s: promiscuous mode", netdev->name); 713 + dev_info(&netdev->dev, "%s: promiscuous mode\n", netdev->name); 716 714 } else if (netdev->mc_count || 717 715 (netdev->flags & IFF_ALLMULTI)) { 718 716 dev->rx_creg &= cpu_to_le16(0xfffe); 719 717 dev->rx_creg |= cpu_to_le16(0x0002); 720 - info("%s: allmulti set", netdev->name); 718 + dev_info(&netdev->dev, "%s: allmulti set\n", netdev->name); 721 719 } else { 722 720 /* ~RX_MULTICAST, ~RX_PROMISCUOUS */ 723 721 dev->rx_creg &= cpu_to_le16(0x00fc); ··· 742 740 if (res == -ENODEV) 743 741 netif_device_detach(dev->netdev); 744 742 else { 745 - warn("failed tx_urb %d\n", res); 743 + dev_warn(&netdev->dev, "failed tx_urb %d\n", res); 746 744 dev->stats.tx_errors++; 747 745 netif_start_queue(netdev); 748 746 } ··· 785 783 if ((res = usb_submit_urb(dev->rx_urb, GFP_KERNEL))) { 786 784 if (res == -ENODEV) 787 785 netif_device_detach(dev->netdev); 788 - warn("%s: rx_urb submit failed: %d", __FUNCTION__, res); 786 + dev_warn(&netdev->dev, "rx_urb submit failed: %d\n", res); 789 787 return res; 790 788 } 791 789 usb_fill_int_urb(dev->intr_urb, dev->udev, usb_rcvintpipe(dev->udev, 3), ··· 794 792 if ((res = usb_submit_urb(dev->intr_urb, GFP_KERNEL))) { 795 793 if (res == -ENODEV) 796 794 netif_device_detach(dev->netdev); 797 - warn("%s: intr_urb submit failed: %d", __FUNCTION__, res); 795 + dev_warn(&netdev->dev, "intr_urb submit failed: %d\n", res); 798 796 usb_kill_urb(dev->rx_urb); 799 797 return res; 800 798 } ··· 949 947 goto out2; 950 948 } 951 949 952 - info("%s: rtl8150 is detected", netdev->name); 950 + dev_info(&intf->dev, "%s: rtl8150 is detected\n", netdev->name); 953 951 954 952 return 0; 955 953 ··· 986 984 987 985 static int __init usb_rtl8150_init(void) 988 986 { 989 - info(DRIVER_DESC " " DRIVER_VERSION); 987 + printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" 988 + DRIVER_DESC "\n"); 990 989 return usb_register(&rtl8150_driver); 991 990 } 992 991
+5 -5
drivers/usb/atm/usbatm.c
··· 344 344 __func__, sarb->len, vcc); 345 345 /* discard cells already received */ 346 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 350 memcpy(skb_tail_pointer(sarb), source + ATM_CELL_HEADER, ATM_CELL_PAYLOAD); ··· 432 432 unsigned char *cell_buf = instance->cell_buf; 433 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 437 if (avail_data >= space_left) { 438 438 /* add new data and process cell */ ··· 475 475 unsigned int stride = instance->tx_channel.stride; 476 476 477 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 480 for (bytes_written = 0; bytes_written < avail_space && ctrl->len; 481 481 bytes_written += stride, target += stride) { ··· 547 547 if (!urb->iso_frame_desc[i].status) { 548 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 552 if (!merge_length) 553 553 merge_start = (unsigned char *)urb->transfer_buffer + urb->iso_frame_desc[i].offset; ··· 1188 1188 struct urb *urb; 1189 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 1193 urb = usb_alloc_urb(iso_packets, GFP_KERNEL); 1194 1194 if (!urb) {
+8 -2
drivers/usb/atm/usbatm.h
··· 40 40 */ 41 41 42 42 #ifdef DEBUG 43 - #define UDSL_ASSERT(x) BUG_ON(!(x)) 43 + #define UDSL_ASSERT(instance, x) BUG_ON(!(x)) 44 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 52 #endif 47 53 48 54 #define usb_err(instance, format, arg...) \
+1 -1
drivers/usb/atm/xusbatm.c
··· 193 193 num_vendor != num_product || 194 194 num_vendor != num_rx_endpoint || 195 195 num_vendor != num_tx_endpoint) { 196 - warn("malformed module parameters"); 196 + printk(KERN_WARNING "xusbatm: malformed module parameters\n"); 197 197 return -EINVAL; 198 198 } 199 199
+10
drivers/usb/class/Kconfig
··· 40 40 To compile this driver as a module, choose M here: the 41 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.
+1
drivers/usb/class/Makefile
··· 6 6 obj-$(CONFIG_USB_ACM) += cdc-acm.o 7 7 obj-$(CONFIG_USB_PRINTER) += usblp.o 8 8 obj-$(CONFIG_USB_WDM) += cdc-wdm.o 9 + obj-$(CONFIG_USB_TMC) += usbtmc.o
+16 -10
drivers/usb/class/cdc-acm.c
··· 326 326 usb_mark_last_busy(acm->dev); 327 327 retval = usb_submit_urb (urb, GFP_ATOMIC); 328 328 if (retval) 329 - err ("%s - usb_submit_urb failed with result %d", 330 - __func__, retval); 329 + dev_err(&urb->dev->dev, "%s - usb_submit_urb failed with " 330 + "result %d", __func__, retval); 331 331 } 332 332 333 333 /* data interface returns incoming bytes, or we got unthrottled */ ··· 514 514 515 515 rv = usb_autopm_get_interface(acm->control); 516 516 if (rv < 0) { 517 - err("Autopm failure in %s", __func__); 517 + dev_err(&acm->dev->dev, "Autopm failure in %s\n", __func__); 518 518 return; 519 519 } 520 520 if (acm->delayed_wb) { ··· 924 924 925 925 /* normal probing*/ 926 926 if (!buffer) { 927 - err("Weird descriptor references\n"); 927 + dev_err(&intf->dev, "Weird descriptor references\n"); 928 928 return -EINVAL; 929 929 } 930 930 ··· 934 934 buflen = intf->cur_altsetting->endpoint->extralen; 935 935 buffer = intf->cur_altsetting->endpoint->extra; 936 936 } else { 937 - err("Zero length descriptor references\n"); 937 + dev_err(&intf->dev, 938 + "Zero length descriptor references\n"); 938 939 return -EINVAL; 939 940 } 940 941 } 941 942 942 943 while (buflen > 0) { 943 944 if (buffer [1] != USB_DT_CS_INTERFACE) { 944 - err("skipping garbage\n"); 945 + dev_err(&intf->dev, "skipping garbage\n"); 945 946 goto next_desc; 946 947 } 947 948 948 949 switch (buffer [2]) { 949 950 case USB_CDC_UNION_TYPE: /* we've found it */ 950 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 955 goto next_desc; 953 956 } 954 957 union_header = (struct usb_cdc_union_desc *) ··· 969 966 call_management_function = buffer[3]; 970 967 call_interface_num = buffer[4]; 971 968 if ((call_management_function & 3) != 3) 972 - err("This device cannot do calls on its own. It is no modem."); 969 + dev_err(&intf->dev, "This device " 970 + "cannot do calls on its own. " 971 + "It is no modem.\n"); 973 972 break; 974 973 default: 975 974 /* there are LOTS more CDC descriptors that ··· 1056 1051 for (minor = 0; minor < ACM_TTY_MINORS && acm_table[minor]; minor++); 1057 1052 1058 1053 if (minor == ACM_TTY_MINORS) { 1059 - err("no more free acm devices"); 1054 + dev_err(&intf->dev, "no more free acm devices\n"); 1060 1055 return -ENODEV; 1061 1056 } 1062 1057 ··· 1459 1454 return retval; 1460 1455 } 1461 1456 1462 - info(DRIVER_VERSION ":" DRIVER_DESC); 1457 + printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" 1458 + DRIVER_DESC "\n"); 1463 1459 1464 1460 return 0; 1465 1461 }
+30 -18
drivers/usb/class/cdc-wdm.c
··· 132 132 "nonzero urb status received: -ESHUTDOWN"); 133 133 break; 134 134 case -EPIPE: 135 - err("nonzero urb status received: -EPIPE"); 135 + dev_err(&desc->intf->dev, 136 + "nonzero urb status received: -EPIPE\n"); 136 137 break; 137 138 default: 138 - err("Unexpected error %d", status); 139 + dev_err(&desc->intf->dev, 140 + "Unexpected error %d\n", status); 139 141 break; 140 142 } 141 143 } ··· 172 170 return; /* unplug */ 173 171 case -EPIPE: 174 172 set_bit(WDM_INT_STALL, &desc->flags); 175 - err("Stall on int endpoint"); 173 + dev_err(&desc->intf->dev, "Stall on int endpoint\n"); 176 174 goto sw; /* halt is cleared in work */ 177 175 default: 178 - err("nonzero urb status received: %d", status); 176 + dev_err(&desc->intf->dev, 177 + "nonzero urb status received: %d\n", status); 179 178 break; 180 179 } 181 180 } 182 181 183 182 if (urb->actual_length < sizeof(struct usb_cdc_notification)) { 184 - err("wdm_int_callback - %d bytes", urb->actual_length); 183 + dev_err(&desc->intf->dev, "wdm_int_callback - %d bytes\n", 184 + urb->actual_length); 185 185 goto exit; 186 186 } 187 187 ··· 202 198 goto exit; 203 199 default: 204 200 clear_bit(WDM_POLL_RUNNING, &desc->flags); 205 - err("unknown notification %d received: index %d len %d", 201 + dev_err(&desc->intf->dev, 202 + "unknown notification %d received: index %d len %d\n", 206 203 dr->bNotificationType, dr->wIndex, dr->wLength); 207 204 goto exit; 208 205 } ··· 241 236 sw: 242 237 rv = schedule_work(&desc->rxwork); 243 238 if (rv) 244 - err("Cannot schedule work"); 239 + dev_err(&desc->intf->dev, 240 + "Cannot schedule work\n"); 245 241 } 246 242 } 247 243 exit: 248 244 rv = usb_submit_urb(urb, GFP_ATOMIC); 249 245 if (rv) 250 - err("%s - usb_submit_urb failed with result %d", 251 - __func__, rv); 246 + dev_err(&desc->intf->dev, 247 + "%s - usb_submit_urb failed with result %d\n", 248 + __func__, rv); 252 249 253 250 } 254 251 ··· 360 353 if (rv < 0) { 361 354 kfree(buf); 362 355 clear_bit(WDM_IN_USE, &desc->flags); 363 - err("Tx URB error: %d", rv); 356 + dev_err(&desc->intf->dev, "Tx URB error: %d\n", rv); 364 357 } else { 365 358 dev_dbg(&desc->intf->dev, "Tx URB has been submitted index=%d", 366 359 req->wIndex); ··· 408 401 int t = desc->rerr; 409 402 desc->rerr = 0; 410 403 spin_unlock_irq(&desc->iuspin); 411 - err("reading had resulted in %d", t); 404 + dev_err(&desc->intf->dev, 405 + "reading had resulted in %d\n", t); 412 406 rv = -EIO; 413 407 goto err; 414 408 } ··· 448 440 err: 449 441 mutex_unlock(&desc->rlock); 450 442 if (rv < 0) 451 - err("wdm_read: exit error"); 443 + dev_err(&desc->intf->dev, "wdm_read: exit error\n"); 452 444 return rv; 453 445 } 454 446 ··· 458 450 459 451 wait_event(desc->wait, !test_bit(WDM_IN_USE, &desc->flags)); 460 452 if (desc->werr < 0) 461 - err("Error in flush path: %d", desc->werr); 453 + dev_err(&desc->intf->dev, "Error in flush path: %d\n", 454 + desc->werr); 462 455 463 456 return desc->werr; 464 457 } ··· 511 502 512 503 rv = usb_autopm_get_interface(desc->intf); 513 504 if (rv < 0) { 514 - err("Error autopm - %d", rv); 505 + dev_err(&desc->intf->dev, "Error autopm - %d\n", rv); 515 506 goto out; 516 507 } 517 508 intf->needs_remote_wakeup = 1; ··· 521 512 rv = usb_submit_urb(desc->validity, GFP_KERNEL); 522 513 if (rv < 0) { 523 514 desc->count--; 524 - err("Error submitting int urb - %d", rv); 515 + dev_err(&desc->intf->dev, 516 + "Error submitting int urb - %d\n", rv); 525 517 } 526 518 } else { 527 519 rv = 0; ··· 610 600 611 601 while (buflen > 0) { 612 602 if (buffer [1] != USB_DT_CS_INTERFACE) { 613 - err("skipping garbage"); 603 + dev_err(&intf->dev, "skipping garbage\n"); 614 604 goto next_desc; 615 605 } 616 606 ··· 624 614 "Finding maximum buffer length: %d", maxcom); 625 615 break; 626 616 default: 627 - err("Ignoring extra header, type %d, length %d", 617 + dev_err(&intf->dev, 618 + "Ignoring extra header, type %d, length %d\n", 628 619 buffer[2], buffer[0]); 629 620 break; 630 621 } ··· 783 772 if (desc->count) { 784 773 rv = usb_submit_urb(desc->validity, GFP_NOIO); 785 774 if (rv < 0) 786 - err("Error resume submitting int urb - %d", rv); 775 + dev_err(&desc->intf->dev, 776 + "Error resume submitting int urb - %d\n", rv); 787 777 } 788 778 return rv; 789 779 }
+13 -12
drivers/usb/class/usblp.c
··· 593 593 err = usblp_hp_channel_change_request(usblp, 594 594 arg, &newChannel); 595 595 if (err < 0) { 596 - err("usblp%d: error = %d setting " 597 - "HP channel", 596 + dev_err(&usblp->dev->dev, 597 + "usblp%d: error = %d setting " 598 + "HP channel\n", 598 599 usblp->minor, err); 599 600 retval = -EIO; 600 601 goto done; ··· 1077 1076 const struct usb_device_id *id) 1078 1077 { 1079 1078 struct usb_device *dev = interface_to_usbdev (intf); 1080 - struct usblp *usblp = NULL; 1079 + struct usblp *usblp; 1081 1080 int protocol; 1082 1081 int retval; 1083 1082 1084 1083 /* Malloc and start initializing usblp structure so we can use it 1085 1084 * directly. */ 1086 - if (!(usblp = kzalloc(sizeof(struct usblp), GFP_KERNEL))) { 1085 + usblp = kzalloc(sizeof(struct usblp), GFP_KERNEL); 1086 + if (!usblp) { 1087 1087 retval = -ENOMEM; 1088 - goto abort; 1088 + goto abort_ret; 1089 1089 } 1090 1090 usblp->dev = dev; 1091 1091 mutex_init(&usblp->wmut); ··· 1181 1179 usb_set_intfdata (intf, NULL); 1182 1180 device_remove_file(&intf->dev, &dev_attr_ieee1284_id); 1183 1181 abort: 1184 - if (usblp) { 1185 - kfree(usblp->readbuf); 1186 - kfree(usblp->statusbuf); 1187 - kfree(usblp->device_id_string); 1188 - kfree(usblp); 1189 - } 1182 + kfree(usblp->readbuf); 1183 + kfree(usblp->statusbuf); 1184 + kfree(usblp->device_id_string); 1185 + kfree(usblp); 1186 + abort_ret: 1190 1187 return retval; 1191 1188 } 1192 1189 ··· 1346 1345 usb_deregister_dev(intf, &usblp_class); 1347 1346 1348 1347 if (!usblp || !usblp->dev) { 1349 - err("bogus disconnect"); 1348 + dev_err(&intf->dev, "bogus disconnect\n"); 1350 1349 BUG (); 1351 1350 } 1352 1351
+1087
drivers/usb/class/usbtmc.c
··· 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 = &current_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");
+1 -1
drivers/usb/core/Kconfig
··· 134 134 If you say Y here, then Linux will refuse to enumerate 135 135 external hubs. OTG hosts are allowed to reduce hardware 136 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
+8 -4
drivers/usb/core/devio.c
··· 413 413 if (likely(ifnum < 8*sizeof(ps->ifclaimed))) 414 414 clear_bit(ifnum, &ps->ifclaimed); 415 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 419 usb_set_intfdata(intf, NULL); 419 420 ··· 625 624 smp_wmb(); 626 625 list_add_tail(&ps->list, &dev->filelist); 627 626 file->private_data = ps; 627 + snoop(&dev->dev, "opened by process %d: %s\n", task_pid_nr(current), 628 + current->comm); 628 629 out: 629 630 if (ret) { 630 631 kfree(ps); ··· 1777 1774 retval = register_chrdev_region(USB_DEVICE_DEV, USB_DEVICE_MAX, 1778 1775 "usb_device"); 1779 1776 if (retval) { 1780 - err("unable to register minors for usb_device"); 1777 + printk(KERN_ERR "Unable to register minors for usb_device\n"); 1781 1778 goto out; 1782 1779 } 1783 1780 cdev_init(&usb_device_cdev, &usbdev_file_operations); 1784 1781 retval = cdev_add(&usb_device_cdev, USB_DEVICE_DEV, USB_DEVICE_MAX); 1785 1782 if (retval) { 1786 - err("unable to get usb_device major %d", USB_DEVICE_MAJOR); 1783 + printk(KERN_ERR "Unable to get usb_device major %d\n", 1784 + USB_DEVICE_MAJOR); 1787 1785 goto error_cdev; 1788 1786 } 1789 1787 #ifdef CONFIG_USB_DEVICE_CLASS 1790 1788 usb_classdev_class = class_create(THIS_MODULE, "usb_device"); 1791 1789 if (IS_ERR(usb_classdev_class)) { 1792 - err("unable to register usb_device class"); 1790 + printk(KERN_ERR "Unable to register usb_device class\n"); 1793 1791 retval = PTR_ERR(usb_classdev_class); 1794 1792 cdev_del(&usb_device_cdev); 1795 1793 usb_classdev_class = NULL;
+2 -1
drivers/usb/core/driver.c
··· 1070 1070 struct usb_driver *driver; 1071 1071 1072 1072 driver = to_usb_driver(intf->dev.driver); 1073 - if (!driver->reset_resume) 1073 + if (!driver->reset_resume || 1074 + intf->needs_remote_wakeup) 1074 1075 return -EOPNOTSUPP; 1075 1076 } 1076 1077 }
+2 -1
drivers/usb/core/endpoint.c
··· 169 169 error = alloc_chrdev_region(&dev, 0, MAX_ENDPOINT_MINORS, 170 170 "usb_endpoint"); 171 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 174 return error; 174 175 } 175 176 usb_endpoint_major = MAJOR(dev);
+3 -2
drivers/usb/core/file.c
··· 86 86 usb_class->class = class_create(THIS_MODULE, "usb"); 87 87 if (IS_ERR(usb_class->class)) { 88 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 90 kfree(usb_class); 91 91 usb_class = NULL; 92 92 } ··· 115 115 116 116 error = register_chrdev(USB_MAJOR, "usb", &usb_fops); 117 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 121 return error; 121 122 }
+4
drivers/usb/core/hcd.c
··· 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 88 /* host controllers we manage */ 85 89 LIST_HEAD (usb_bus_list); 86 90 EXPORT_SYMBOL_GPL (usb_bus_list);
+6
drivers/usb/core/hcd.h
··· 482 482 */ 483 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 491 #endif /* __KERNEL__ */
+90 -10
drivers/usb/core/hub.c
··· 77 77 unsigned has_indicators:1; 78 78 u8 indicator[USB_MAXCHILDREN]; 79 79 struct delayed_work leds; 80 + struct delayed_work init_work; 80 81 }; 81 82 82 83 ··· 99 98 static int blinkenlights = 0; 100 99 module_param (blinkenlights, bool, S_IRUGO); 101 100 MODULE_PARM_DESC (blinkenlights, "true to cycle leds on hubs"); 101 + 102 + /* 103 + * Device SATA8000 FW1.0 from DATAST0R Technology Corp requires about 104 + * 10 seconds to send reply for the initial 64-byte descriptor request. 105 + */ 106 + /* define initial 64-byte descriptor request timeout in milliseconds */ 107 + static int initial_descriptor_timeout = USB_CTRL_GET_TIMEOUT; 108 + module_param(initial_descriptor_timeout, int, S_IRUGO|S_IWUSR); 109 + MODULE_PARM_DESC(initial_descriptor_timeout, "initial 64-byte descriptor request timeout in milliseconds (default 5000 - 5.0 seconds)"); 102 110 103 111 /* 104 112 * As of 2.6.10 we introduce a new USB device initialization scheme which ··· 525 515 } 526 516 EXPORT_SYMBOL_GPL(usb_hub_tt_clear_buffer); 527 517 528 - static void hub_power_on(struct usb_hub *hub) 518 + /* If do_delay is false, return the number of milliseconds the caller 519 + * needs to delay. 520 + */ 521 + static unsigned hub_power_on(struct usb_hub *hub, bool do_delay) 529 522 { 530 523 int port1; 531 524 unsigned pgood_delay = hub->descriptor->bPwrOn2PwrGood * 2; 525 + unsigned delay; 532 526 u16 wHubCharacteristics = 533 527 le16_to_cpu(hub->descriptor->wHubCharacteristics); 534 528 ··· 551 537 set_port_feature(hub->hdev, port1, USB_PORT_FEAT_POWER); 552 538 553 539 /* Wait at least 100 msec for power to become stable */ 554 - msleep(max(pgood_delay, (unsigned) 100)); 540 + delay = max(pgood_delay, (unsigned) 100); 541 + if (do_delay) 542 + msleep(delay); 543 + return delay; 555 544 } 556 545 557 546 static int hub_hub_status(struct usb_hub *hub, ··· 616 599 } 617 600 618 601 enum hub_activation_type { 619 - HUB_INIT, HUB_POST_RESET, HUB_RESUME, HUB_RESET_RESUME 602 + HUB_INIT, HUB_INIT2, HUB_INIT3, 603 + HUB_POST_RESET, HUB_RESUME, HUB_RESET_RESUME, 620 604 }; 605 + 606 + static void hub_init_func2(struct work_struct *ws); 607 + static void hub_init_func3(struct work_struct *ws); 621 608 622 609 static void hub_activate(struct usb_hub *hub, enum hub_activation_type type) 623 610 { ··· 629 608 int port1; 630 609 int status; 631 610 bool need_debounce_delay = false; 611 + unsigned delay; 612 + 613 + /* Continue a partial initialization */ 614 + if (type == HUB_INIT2) 615 + goto init2; 616 + if (type == HUB_INIT3) 617 + goto init3; 632 618 633 619 /* After a resume, port power should still be on. 634 620 * For any other type of activation, turn it on. 635 621 */ 636 - if (type != HUB_RESUME) 637 - hub_power_on(hub); 622 + if (type != HUB_RESUME) { 623 + 624 + /* Speed up system boot by using a delayed_work for the 625 + * hub's initial power-up delays. This is pretty awkward 626 + * and the implementation looks like a home-brewed sort of 627 + * setjmp/longjmp, but it saves at least 100 ms for each 628 + * root hub (assuming usbcore is compiled into the kernel 629 + * rather than as a module). It adds up. 630 + * 631 + * This can't be done for HUB_RESUME or HUB_RESET_RESUME 632 + * because for those activation types the ports have to be 633 + * operational when we return. In theory this could be done 634 + * for HUB_POST_RESET, but it's easier not to. 635 + */ 636 + if (type == HUB_INIT) { 637 + delay = hub_power_on(hub, false); 638 + PREPARE_DELAYED_WORK(&hub->init_work, hub_init_func2); 639 + schedule_delayed_work(&hub->init_work, 640 + msecs_to_jiffies(delay)); 641 + return; /* Continues at init2: below */ 642 + } else { 643 + hub_power_on(hub, true); 644 + } 645 + } 646 + init2: 638 647 639 648 /* Check each port and set hub->change_bits to let khubd know 640 649 * which ports need attention. ··· 743 692 * If any port-status changes do occur during this delay, khubd 744 693 * will see them later and handle them normally. 745 694 */ 746 - if (need_debounce_delay) 747 - msleep(HUB_DEBOUNCE_STABLE); 695 + if (need_debounce_delay) { 696 + delay = HUB_DEBOUNCE_STABLE; 748 697 698 + /* Don't do a long sleep inside a workqueue routine */ 699 + if (type == HUB_INIT2) { 700 + PREPARE_DELAYED_WORK(&hub->init_work, hub_init_func3); 701 + schedule_delayed_work(&hub->init_work, 702 + msecs_to_jiffies(delay)); 703 + return; /* Continues at init3: below */ 704 + } else { 705 + msleep(delay); 706 + } 707 + } 708 + init3: 749 709 hub->quiescing = 0; 750 710 751 711 status = usb_submit_urb(hub->urb, GFP_NOIO); ··· 769 707 kick_khubd(hub); 770 708 } 771 709 710 + /* Implement the continuations for the delays above */ 711 + static void hub_init_func2(struct work_struct *ws) 712 + { 713 + struct usb_hub *hub = container_of(ws, struct usb_hub, init_work.work); 714 + 715 + hub_activate(hub, HUB_INIT2); 716 + } 717 + 718 + static void hub_init_func3(struct work_struct *ws) 719 + { 720 + struct usb_hub *hub = container_of(ws, struct usb_hub, init_work.work); 721 + 722 + hub_activate(hub, HUB_INIT3); 723 + } 724 + 772 725 enum hub_quiescing_type { 773 726 HUB_DISCONNECT, HUB_PRE_RESET, HUB_SUSPEND 774 727 }; ··· 792 715 { 793 716 struct usb_device *hdev = hub->hdev; 794 717 int i; 718 + 719 + cancel_delayed_work_sync(&hub->init_work); 795 720 796 721 /* khubd and related activity won't re-trigger */ 797 722 hub->quiescing = 1; ··· 1178 1099 hub->intfdev = &intf->dev; 1179 1100 hub->hdev = hdev; 1180 1101 INIT_DELAYED_WORK(&hub->leds, led_work); 1102 + INIT_DELAYED_WORK(&hub->init_work, NULL); 1181 1103 usb_get_intf(intf); 1182 1104 1183 1105 usb_set_intfdata (intf, hub); ··· 2547 2467 USB_REQ_GET_DESCRIPTOR, USB_DIR_IN, 2548 2468 USB_DT_DEVICE << 8, 0, 2549 2469 buf, GET_DESCRIPTOR_BUFSIZE, 2550 - USB_CTRL_GET_TIMEOUT); 2470 + initial_descriptor_timeout); 2551 2471 switch (buf->bMaxPacketSize0) { 2552 2472 case 8: case 16: case 32: case 64: case 255: 2553 2473 if (buf->bDescriptorType == ··· 3115 3035 i); 3116 3036 clear_port_feature(hdev, i, 3117 3037 USB_PORT_FEAT_C_OVER_CURRENT); 3118 - hub_power_on(hub); 3038 + hub_power_on(hub, true); 3119 3039 } 3120 3040 3121 3041 if (portchange & USB_PORT_STAT_C_RESET) { ··· 3150 3070 dev_dbg (hub_dev, "overcurrent change\n"); 3151 3071 msleep(500); /* Cool down */ 3152 3072 clear_hub_feature(hdev, C_HUB_OVER_CURRENT); 3153 - hub_power_on(hub); 3073 + hub_power_on(hub, true); 3154 3074 } 3155 3075 } 3156 3076
+10 -8
drivers/usb/core/inode.c
··· 180 180 listmode = option & S_IRWXUGO; 181 181 break; 182 182 default: 183 - err("usbfs: unrecognised mount option \"%s\" " 184 - "or missing value\n", p); 183 + printk(KERN_ERR "usbfs: unrecognised mount option " 184 + "\"%s\" or missing value\n", p); 185 185 return -EINVAL; 186 186 } 187 187 } ··· 240 240 update_special(bus); 241 241 break; 242 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 246 break; 245 247 } 246 248 } ··· 261 259 return 0; 262 260 263 261 if (parse_options(sb, data)) { 264 - warn("usbfs: mount parameter error:"); 262 + printk(KERN_WARNING "usbfs: mount parameter error.\n"); 265 263 return -EINVAL; 266 264 } 267 265 ··· 601 599 /* create the devices special file */ 602 600 retval = simple_pin_fs(&usb_fs_type, &usbfs_mount, &usbfs_mount_count); 603 601 if (retval) { 604 - err ("Unable to get usbfs mount"); 602 + printk(KERN_ERR "Unable to get usbfs mount\n"); 605 603 goto exit; 606 604 } 607 605 ··· 613 611 NULL, &usbfs_devices_fops, 614 612 listuid, listgid); 615 613 if (devices_usbfs_dentry == NULL) { 616 - err ("Unable to create devices usbfs file"); 614 + printk(KERN_ERR "Unable to create devices usbfs file\n"); 617 615 retval = -ENODEV; 618 616 goto error_clean_mounts; 619 617 } ··· 665 663 bus->usbfs_dentry = fs_create_file (name, busmode | S_IFDIR, parent, 666 664 bus, NULL, busuid, busgid); 667 665 if (bus->usbfs_dentry == NULL) { 668 - err ("error creating usbfs bus entry"); 666 + printk(KERN_ERR "Error creating usbfs bus entry\n"); 669 667 return; 670 668 } 671 669 } ··· 696 694 &usbdev_file_operations, 697 695 devuid, devgid); 698 696 if (dev->usbfs_dentry == NULL) { 699 - err ("error creating usbfs device entry"); 697 + printk(KERN_ERR "Error creating usbfs device entry\n"); 700 698 return; 701 699 } 702 700
+2 -1
drivers/usb/core/message.c
··· 1204 1204 1205 1205 alt = usb_altnum_to_altsetting(iface, alternate); 1206 1206 if (!alt) { 1207 - warn("selecting invalid altsetting %d", alternate); 1207 + dev_warn(&dev->dev, "selecting invalid altsetting %d", 1208 + alternate); 1208 1209 return -EINVAL; 1209 1210 } 1210 1211
+24
drivers/usb/core/sysfs.c
··· 743 743 } 744 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 769 static struct attribute *intf_attrs[] = { 747 770 &dev_attr_bInterfaceNumber.attr, 748 771 &dev_attr_bAlternateSetting.attr, ··· 774 751 &dev_attr_bInterfaceSubClass.attr, 775 752 &dev_attr_bInterfaceProtocol.attr, 776 753 &dev_attr_modalias.attr, 754 + &dev_attr_supports_autosuspend.attr, 777 755 NULL, 778 756 }; 779 757 static struct attribute_group intf_attr_grp = {
+161 -8
drivers/usb/core/urb.c
··· 10 10 11 11 #define to_urb(d) container_of(d, struct urb, kref) 12 12 13 + static DEFINE_SPINLOCK(usb_reject_lock); 14 + 13 15 static void urb_destroy(struct kref *kref) 14 16 { 15 17 struct urb *urb = to_urb(kref); ··· 70 68 iso_packets * sizeof(struct usb_iso_packet_descriptor), 71 69 mem_flags); 72 70 if (!urb) { 73 - err("alloc_urb: kmalloc failed"); 71 + printk(KERN_ERR "alloc_urb: kmalloc failed\n"); 74 72 return NULL; 75 73 } 76 74 usb_init_urb(urb); ··· 129 127 usb_get_urb(urb); 130 128 list_add_tail(&urb->anchor_list, &anchor->urb_list); 131 129 urb->anchor = anchor; 130 + 131 + if (unlikely(anchor->poisoned)) { 132 + spin_lock(&usb_reject_lock); 133 + urb->reject++; 134 + spin_unlock(&usb_reject_lock); 135 + } 136 + 132 137 spin_unlock_irqrestore(&anchor->lock, flags); 133 138 } 134 139 EXPORT_SYMBOL_GPL(usb_anchor_urb); ··· 407 398 408 399 /* fail if submitter gave bogus flags */ 409 400 if (urb->transfer_flags != orig_flags) { 410 - err("BOGUS urb flags, %x --> %x", 401 + dev_err(&dev->dev, "BOGUS urb flags, %x --> %x\n", 411 402 orig_flags, urb->transfer_flags); 412 403 return -EINVAL; 413 404 } ··· 553 544 */ 554 545 void usb_kill_urb(struct urb *urb) 555 546 { 556 - static DEFINE_MUTEX(reject_mutex); 557 - 558 547 might_sleep(); 559 548 if (!(urb && urb->dev && urb->ep)) 560 549 return; 561 - mutex_lock(&reject_mutex); 550 + spin_lock_irq(&usb_reject_lock); 562 551 ++urb->reject; 563 - mutex_unlock(&reject_mutex); 552 + spin_unlock_irq(&usb_reject_lock); 564 553 565 554 usb_hcd_unlink_urb(urb, -ENOENT); 566 555 wait_event(usb_kill_urb_queue, atomic_read(&urb->use_count) == 0); 567 556 568 - mutex_lock(&reject_mutex); 557 + spin_lock_irq(&usb_reject_lock); 569 558 --urb->reject; 570 - mutex_unlock(&reject_mutex); 559 + spin_unlock_irq(&usb_reject_lock); 571 560 } 572 561 EXPORT_SYMBOL_GPL(usb_kill_urb); 562 + 563 + /** 564 + * usb_poison_urb - reliably kill a transfer and prevent further use of an URB 565 + * @urb: pointer to URB describing a previously submitted request, 566 + * may be NULL 567 + * 568 + * This routine cancels an in-progress request. It is guaranteed that 569 + * upon return all completion handlers will have finished and the URB 570 + * will be totally idle and cannot be reused. These features make 571 + * this an ideal way to stop I/O in a disconnect() callback. 572 + * If the request has not already finished or been unlinked 573 + * the completion handler will see urb->status == -ENOENT. 574 + * 575 + * After and while the routine runs, attempts to resubmit the URB will fail 576 + * with error -EPERM. Thus even if the URB's completion handler always 577 + * tries to resubmit, it will not succeed and the URB will become idle. 578 + * 579 + * This routine may not be used in an interrupt context (such as a bottom 580 + * half or a completion handler), or when holding a spinlock, or in other 581 + * situations where the caller can't schedule(). 582 + */ 583 + void usb_poison_urb(struct urb *urb) 584 + { 585 + might_sleep(); 586 + if (!(urb && urb->dev && urb->ep)) 587 + return; 588 + spin_lock_irq(&usb_reject_lock); 589 + ++urb->reject; 590 + spin_unlock_irq(&usb_reject_lock); 591 + 592 + usb_hcd_unlink_urb(urb, -ENOENT); 593 + wait_event(usb_kill_urb_queue, atomic_read(&urb->use_count) == 0); 594 + } 595 + EXPORT_SYMBOL_GPL(usb_poison_urb); 596 + 597 + void usb_unpoison_urb(struct urb *urb) 598 + { 599 + unsigned long flags; 600 + 601 + if (!urb) 602 + return; 603 + 604 + spin_lock_irqsave(&usb_reject_lock, flags); 605 + --urb->reject; 606 + spin_unlock_irqrestore(&usb_reject_lock, flags); 607 + } 608 + EXPORT_SYMBOL_GPL(usb_unpoison_urb); 573 609 574 610 /** 575 611 * usb_kill_anchored_urbs - cancel transfer requests en masse ··· 643 589 } 644 590 EXPORT_SYMBOL_GPL(usb_kill_anchored_urbs); 645 591 592 + 593 + /** 594 + * usb_poison_anchored_urbs - cease all traffic from an anchor 595 + * @anchor: anchor the requests are bound to 596 + * 597 + * this allows all outstanding URBs to be poisoned starting 598 + * from the back of the queue. Newly added URBs will also be 599 + * poisoned 600 + */ 601 + void usb_poison_anchored_urbs(struct usb_anchor *anchor) 602 + { 603 + struct urb *victim; 604 + 605 + spin_lock_irq(&anchor->lock); 606 + anchor->poisoned = 1; 607 + while (!list_empty(&anchor->urb_list)) { 608 + victim = list_entry(anchor->urb_list.prev, struct urb, 609 + anchor_list); 610 + /* we must make sure the URB isn't freed before we kill it*/ 611 + usb_get_urb(victim); 612 + spin_unlock_irq(&anchor->lock); 613 + /* this will unanchor the URB */ 614 + usb_poison_urb(victim); 615 + usb_put_urb(victim); 616 + spin_lock_irq(&anchor->lock); 617 + } 618 + spin_unlock_irq(&anchor->lock); 619 + } 620 + EXPORT_SYMBOL_GPL(usb_poison_anchored_urbs); 646 621 /** 647 622 * usb_unlink_anchored_urbs - asynchronously cancel transfer requests en masse 648 623 * @anchor: anchor the requests are bound to ··· 716 633 msecs_to_jiffies(timeout)); 717 634 } 718 635 EXPORT_SYMBOL_GPL(usb_wait_anchor_empty_timeout); 636 + 637 + /** 638 + * usb_get_from_anchor - get an anchor's oldest urb 639 + * @anchor: the anchor whose urb you want 640 + * 641 + * this will take the oldest urb from an anchor, 642 + * unanchor and return it 643 + */ 644 + struct urb *usb_get_from_anchor(struct usb_anchor *anchor) 645 + { 646 + struct urb *victim; 647 + unsigned long flags; 648 + 649 + spin_lock_irqsave(&anchor->lock, flags); 650 + if (!list_empty(&anchor->urb_list)) { 651 + victim = list_entry(anchor->urb_list.next, struct urb, 652 + anchor_list); 653 + usb_get_urb(victim); 654 + spin_unlock_irqrestore(&anchor->lock, flags); 655 + usb_unanchor_urb(victim); 656 + } else { 657 + spin_unlock_irqrestore(&anchor->lock, flags); 658 + victim = NULL; 659 + } 660 + 661 + return victim; 662 + } 663 + 664 + EXPORT_SYMBOL_GPL(usb_get_from_anchor); 665 + 666 + /** 667 + * usb_scuttle_anchored_urbs - unanchor all an anchor's urbs 668 + * @anchor: the anchor whose urbs you want to unanchor 669 + * 670 + * use this to get rid of all an anchor's urbs 671 + */ 672 + void usb_scuttle_anchored_urbs(struct usb_anchor *anchor) 673 + { 674 + struct urb *victim; 675 + unsigned long flags; 676 + 677 + spin_lock_irqsave(&anchor->lock, flags); 678 + while (!list_empty(&anchor->urb_list)) { 679 + victim = list_entry(anchor->urb_list.prev, struct urb, 680 + anchor_list); 681 + usb_get_urb(victim); 682 + spin_unlock_irqrestore(&anchor->lock, flags); 683 + /* this may free the URB */ 684 + usb_unanchor_urb(victim); 685 + usb_put_urb(victim); 686 + spin_lock_irqsave(&anchor->lock, flags); 687 + } 688 + spin_unlock_irqrestore(&anchor->lock, flags); 689 + } 690 + 691 + EXPORT_SYMBOL_GPL(usb_scuttle_anchored_urbs); 692 + 693 + /** 694 + * usb_anchor_empty - is an anchor empty 695 + * @anchor: the anchor you want to query 696 + * 697 + * returns 1 if the anchor has no urbs associated with it 698 + */ 699 + int usb_anchor_empty(struct usb_anchor *anchor) 700 + { 701 + return list_empty(&anchor->urb_list); 702 + } 703 + 704 + EXPORT_SYMBOL_GPL(usb_anchor_empty); 705 +
+201 -138
drivers/usb/gadget/Kconfig
··· 45 45 46 46 config USB_GADGET_DEBUG 47 47 boolean "Debugging messages (DEVELOPMENT)" 48 - depends on USB_GADGET && DEBUG_KERNEL 48 + depends on DEBUG_KERNEL 49 49 help 50 50 Many controller and gadget drivers will print some debugging 51 51 messages if you use this option to ask for those messages. ··· 59 59 60 60 config USB_GADGET_DEBUG_FILES 61 61 boolean "Debugging information files (DEVELOPMENT)" 62 - depends on USB_GADGET && PROC_FS 62 + depends on PROC_FS 63 63 help 64 64 Some of the drivers in the "gadget" framework can expose 65 65 debugging information in files such as /proc/driver/udc ··· 70 70 71 71 config USB_GADGET_DEBUG_FS 72 72 boolean "Debugging information files in debugfs (DEVELOPMENT)" 73 - depends on USB_GADGET && DEBUG_FS 73 + depends on DEBUG_FS 74 74 help 75 75 Some of the drivers in the "gadget" framework can expose 76 76 debugging information in files under /sys/kernel/debug/. ··· 79 79 Enable these files by choosing "Y" here. If in doubt, or 80 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 99 config USB_GADGET_SELECTED 83 100 boolean 84 101 85 102 # 86 103 # USB Peripheral Controller Support 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. 87 111 # 88 112 choice 89 113 prompt "USB Peripheral Controller" ··· 118 94 Many controller drivers are platform-specific; these 119 95 often need board-specific hooks. 120 96 121 - config USB_GADGET_AMD5536UDC 122 - boolean "AMD5536 UDC" 123 - depends on PCI 124 - select USB_GADGET_DUALSPEED 97 + # 98 + # Integrated controllers 99 + # 100 + 101 + config USB_GADGET_AT91 102 + boolean "Atmel AT91 USB Device Port" 103 + depends on ARCH_AT91 && !ARCH_AT91SAM9RL && !ARCH_AT91CAP9 104 + select USB_GADGET_SELECTED 125 105 help 126 - The AMD5536 UDC is part of the AMD Geode CS5536, an x86 southbridge. 127 - It is a USB Highspeed DMA capable USB device controller. Beside ep0 128 - it provides 4 IN and 4 OUT endpoints (bulk or interrupt type). 129 - The UDC port supports OTG operation, and may be used as a host port 130 - if it's not being used to implement peripheral or OTG roles. 106 + Many Atmel AT91 processors (such as the AT91RM2000) have a 107 + full speed USB Device Port with support for five configurable 108 + endpoints (plus endpoint zero). 131 109 132 110 Say "y" to link the driver statically, or "m" to build a 133 - dynamically linked module called "amd5536udc" and force all 111 + dynamically linked module called "at91_udc" and force all 134 112 gadget drivers to also be dynamically linked. 135 113 136 - config USB_AMD5536UDC 114 + config USB_AT91 137 115 tristate 138 - depends on USB_GADGET_AMD5536UDC 116 + depends on USB_GADGET_AT91 139 117 default USB_GADGET 140 - select USB_GADGET_SELECTED 141 118 142 119 config USB_GADGET_ATMEL_USBA 143 120 boolean "Atmel USBA" ··· 175 150 default USB_GADGET 176 151 select USB_GADGET_SELECTED 177 152 178 - config USB_GADGET_NET2280 179 - boolean "NetChip 228x" 180 - depends on PCI 181 - select USB_GADGET_DUALSPEED 153 + config USB_GADGET_LH7A40X 154 + boolean "LH7A40X" 155 + depends on ARCH_LH7A40X 182 156 help 183 - NetChip 2280 / 2282 is a PCI based USB peripheral controller which 184 - supports both full and high speed USB 2.0 data transfers. 185 - 186 - It has six configurable endpoints, as well as endpoint zero 187 - (for control transfers) and several endpoints with dedicated 188 - functions. 157 + This driver provides USB Device Controller driver for LH7A40x 189 158 190 - Say "y" to link the driver statically, or "m" to build a 191 - dynamically linked module called "net2280" and force all 192 - gadget drivers to also be dynamically linked. 193 - 194 - config USB_NET2280 159 + config USB_LH7A40X 195 160 tristate 196 - depends on USB_GADGET_NET2280 161 + depends on USB_GADGET_LH7A40X 197 162 default USB_GADGET 198 163 select USB_GADGET_SELECTED 164 + 165 + config USB_GADGET_OMAP 166 + boolean "OMAP USB Device Controller" 167 + depends on ARCH_OMAP 168 + select ISP1301_OMAP if MACH_OMAP_H2 || MACH_OMAP_H3 || MACH_OMAP_H4_OTG 169 + help 170 + Many Texas Instruments OMAP processors have flexible full 171 + speed USB device controllers, with support for up to 30 172 + endpoints (plus endpoint zero). This driver supports the 173 + controller in the OMAP 1611, and should work with controllers 174 + in other OMAP processors too, given minor tweaks. 175 + 176 + Say "y" to link the driver statically, or "m" to build a 177 + dynamically linked module called "omap_udc" and force all 178 + gadget drivers to also be dynamically linked. 179 + 180 + config USB_OMAP 181 + tristate 182 + depends on USB_GADGET_OMAP 183 + default USB_GADGET 184 + select USB_GADGET_SELECTED 185 + 186 + config USB_OTG 187 + boolean "OTG Support" 188 + depends on USB_GADGET_OMAP && ARCH_OMAP_OTG && USB_OHCI_HCD 189 + help 190 + The most notable feature of USB OTG is support for a 191 + "Dual-Role" device, which can act as either a device 192 + or a host. The initial role choice can be changed 193 + later, when two dual-role devices talk to each other. 194 + 195 + Select this only if your OMAP board has a Mini-AB connector. 199 196 200 197 config USB_GADGET_PXA25X 201 198 boolean "PXA 25x or IXP 4xx" ··· 250 203 default y if USB_ETH 251 204 default y if USB_G_SERIAL 252 205 206 + config USB_GADGET_PXA27X 207 + boolean "PXA 27x" 208 + depends on ARCH_PXA && PXA27x 209 + help 210 + Intel's PXA 27x series XScale ARM v5TE processors include 211 + an integrated full speed USB 1.1 device controller. 212 + 213 + It has up to 23 endpoints, as well as endpoint zero (for 214 + control transfers). 215 + 216 + Say "y" to link the driver statically, or "m" to build a 217 + dynamically linked module called "pxa27x_udc" and force all 218 + gadget drivers to also be dynamically linked. 219 + 220 + config USB_PXA27X 221 + tristate 222 + depends on USB_GADGET_PXA27X 223 + default USB_GADGET 224 + select USB_GADGET_SELECTED 225 + 226 + config USB_GADGET_S3C2410 227 + boolean "S3C2410 USB Device Controller" 228 + depends on ARCH_S3C2410 229 + help 230 + Samsung's S3C2410 is an ARM-4 processor with an integrated 231 + full speed USB 1.1 device controller. It has 4 configurable 232 + endpoints, as well as endpoint zero (for control transfers). 233 + 234 + This driver has been tested on the S3C2410, S3C2412, and 235 + S3C2440 processors. 236 + 237 + config USB_S3C2410 238 + tristate 239 + depends on USB_GADGET_S3C2410 240 + default USB_GADGET 241 + select USB_GADGET_SELECTED 242 + 243 + config USB_S3C2410_DEBUG 244 + boolean "S3C2410 udc debug messages" 245 + depends on USB_GADGET_S3C2410 246 + 247 + # 248 + # Controllers available in both integrated and discrete versions 249 + # 250 + 251 + # musb builds in ../musb along with host support 252 + config USB_GADGET_MUSB_HDRC 253 + boolean "Inventra HDRC USB Peripheral (TI, ...)" 254 + depends on USB_MUSB_HDRC && (USB_MUSB_PERIPHERAL || USB_MUSB_OTG) 255 + select USB_GADGET_DUALSPEED 256 + select USB_GADGET_SELECTED 257 + help 258 + This OTG-capable silicon IP is used in dual designs including 259 + the TI DaVinci, OMAP 243x, OMAP 343x, and TUSB 6010. 260 + 253 261 config USB_GADGET_M66592 254 262 boolean "Renesas M66592 USB Peripheral Controller" 255 263 select USB_GADGET_DUALSPEED ··· 333 231 However, this problem is improved if change a value of 334 232 NET_IP_ALIGN to 4. 335 233 336 - config USB_GADGET_PXA27X 337 - boolean "PXA 27x" 338 - depends on ARCH_PXA && PXA27x 339 - help 340 - Intel's PXA 27x series XScale ARM v5TE processors include 341 - an integrated full speed USB 1.1 device controller. 234 + # 235 + # Controllers available only in discrete form (and all PCI controllers) 236 + # 342 237 343 - It has up to 23 endpoints, as well as endpoint zero (for 344 - control transfers). 238 + config USB_GADGET_AMD5536UDC 239 + boolean "AMD5536 UDC" 240 + depends on PCI 241 + select USB_GADGET_DUALSPEED 242 + help 243 + The AMD5536 UDC is part of the AMD Geode CS5536, an x86 southbridge. 244 + It is a USB Highspeed DMA capable USB device controller. Beside ep0 245 + it provides 4 IN and 4 OUT endpoints (bulk or interrupt type). 246 + The UDC port supports OTG operation, and may be used as a host port 247 + if it's not being used to implement peripheral or OTG roles. 345 248 346 249 Say "y" to link the driver statically, or "m" to build a 347 - dynamically linked module called "pxa27x_udc" and force all 250 + dynamically linked module called "amd5536udc" and force all 348 251 gadget drivers to also be dynamically linked. 349 252 350 - config USB_PXA27X 253 + config USB_AMD5536UDC 351 254 tristate 352 - depends on USB_GADGET_PXA27X 255 + depends on USB_GADGET_AMD5536UDC 256 + default USB_GADGET 257 + select USB_GADGET_SELECTED 258 + 259 + config USB_GADGET_FSL_QE 260 + boolean "Freescale QE/CPM USB Device Controller" 261 + depends on FSL_SOC && (QUICC_ENGINE || CPM) 262 + help 263 + Some of Freescale PowerPC processors have a Full Speed 264 + QE/CPM2 USB controller, which support device mode with 4 265 + programmable endpoints. This driver supports the 266 + controller in the MPC8360 and MPC8272, and should work with 267 + controllers having QE or CPM2, given minor tweaks. 268 + 269 + Set CONFIG_USB_GADGET to "m" to build this driver as a 270 + dynmically linked module called "fsl_qe_udc". 271 + 272 + config USB_FSL_QE 273 + tristate 274 + depends on USB_GADGET_FSL_QE 275 + default USB_GADGET 276 + select USB_GADGET_SELECTED 277 + 278 + config USB_GADGET_NET2280 279 + boolean "NetChip 228x" 280 + depends on PCI 281 + select USB_GADGET_DUALSPEED 282 + help 283 + NetChip 2280 / 2282 is a PCI based USB peripheral controller which 284 + supports both full and high speed USB 2.0 data transfers. 285 + 286 + It has six configurable endpoints, as well as endpoint zero 287 + (for control transfers) and several endpoints with dedicated 288 + functions. 289 + 290 + Say "y" to link the driver statically, or "m" to build a 291 + dynamically linked module called "net2280" and force all 292 + gadget drivers to also be dynamically linked. 293 + 294 + config USB_NET2280 295 + tristate 296 + depends on USB_GADGET_NET2280 353 297 default USB_GADGET 354 298 select USB_GADGET_SELECTED 355 299 ··· 405 257 help 406 258 The Toshiba TC86C001 is a PCI device which includes controllers 407 259 for full speed USB devices, IDE, I2C, SIO, plus a USB host (OHCI). 408 - 260 + 409 261 The device controller has three configurable (bulk or interrupt) 410 262 endpoints, plus endpoint zero (for control transfers). 411 263 ··· 420 272 select USB_GADGET_SELECTED 421 273 422 274 423 - config USB_GADGET_LH7A40X 424 - boolean "LH7A40X" 425 - depends on ARCH_LH7A40X 426 - help 427 - This driver provides USB Device Controller driver for LH7A40x 428 - 429 - config USB_LH7A40X 430 - tristate 431 - depends on USB_GADGET_LH7A40X 432 - default USB_GADGET 433 - select USB_GADGET_SELECTED 434 - 435 - # built in ../musb along with host support 436 - config USB_GADGET_MUSB_HDRC 437 - boolean "Inventra HDRC USB Peripheral (TI, ...)" 438 - depends on USB_MUSB_HDRC && (USB_MUSB_PERIPHERAL || USB_MUSB_OTG) 439 - select USB_GADGET_DUALSPEED 440 - select USB_GADGET_SELECTED 441 - help 442 - This OTG-capable silicon IP is used in dual designs including 443 - the TI DaVinci, OMAP 243x, OMAP 343x, and TUSB 6010. 444 - 445 - config USB_GADGET_OMAP 446 - boolean "OMAP USB Device Controller" 447 - depends on ARCH_OMAP 448 - select ISP1301_OMAP if MACH_OMAP_H2 || MACH_OMAP_H3 449 - help 450 - Many Texas Instruments OMAP processors have flexible full 451 - speed USB device controllers, with support for up to 30 452 - endpoints (plus endpoint zero). This driver supports the 453 - controller in the OMAP 1611, and should work with controllers 454 - in other OMAP processors too, given minor tweaks. 455 - 456 - Say "y" to link the driver statically, or "m" to build a 457 - dynamically linked module called "omap_udc" and force all 458 - gadget drivers to also be dynamically linked. 459 - 460 - config USB_OMAP 461 - tristate 462 - depends on USB_GADGET_OMAP 463 - default USB_GADGET 464 - select USB_GADGET_SELECTED 465 - 466 - config USB_OTG 467 - boolean "OTG Support" 468 - depends on USB_GADGET_OMAP && ARCH_OMAP_OTG && USB_OHCI_HCD 469 - help 470 - The most notable feature of USB OTG is support for a 471 - "Dual-Role" device, which can act as either a device 472 - or a host. The initial role choice can be changed 473 - later, when two dual-role devices talk to each other. 474 - 475 - Select this only if your OMAP board has a Mini-AB connector. 476 - 477 - config USB_GADGET_S3C2410 478 - boolean "S3C2410 USB Device Controller" 479 - depends on ARCH_S3C2410 480 - help 481 - Samsung's S3C2410 is an ARM-4 processor with an integrated 482 - full speed USB 1.1 device controller. It has 4 configurable 483 - endpoints, as well as endpoint zero (for control transfers). 484 - 485 - This driver has been tested on the S3C2410, S3C2412, and 486 - S3C2440 processors. 487 - 488 - config USB_S3C2410 489 - tristate 490 - depends on USB_GADGET_S3C2410 491 - default USB_GADGET 492 - select USB_GADGET_SELECTED 493 - 494 - config USB_S3C2410_DEBUG 495 - boolean "S3C2410 udc debug messages" 496 - depends on USB_GADGET_S3C2410 497 - 498 - config USB_GADGET_AT91 499 - boolean "AT91 USB Device Port" 500 - depends on ARCH_AT91 && !ARCH_AT91SAM9RL && !ARCH_AT91CAP9 501 - select USB_GADGET_SELECTED 502 - help 503 - Many Atmel AT91 processors (such as the AT91RM2000) have a 504 - full speed USB Device Port with support for five configurable 505 - endpoints (plus endpoint zero). 506 - 507 - Say "y" to link the driver statically, or "m" to build a 508 - dynamically linked module called "at91_udc" and force all 509 - gadget drivers to also be dynamically linked. 510 - 511 - config USB_AT91 512 - tristate 513 - depends on USB_GADGET_AT91 514 - default USB_GADGET 275 + # 276 + # LAST -- dummy/emulated controller 277 + # 515 278 516 279 config USB_GADGET_DUMMY_HCD 517 280 boolean "Dummy HCD (DEVELOPMENT)" ··· 612 553 normal operation. 613 554 614 555 config USB_G_SERIAL 615 - tristate "Serial Gadget (with CDC ACM support)" 556 + tristate "Serial Gadget (with CDC ACM and CDC OBEX support)" 616 557 help 617 558 The Serial Gadget talks to the Linux-USB generic serial driver. 618 559 This driver supports a CDC-ACM module option, which can be used 619 560 to interoperate with MS-Windows hosts or with the Linux-USB 620 561 "cdc-acm" driver. 621 562 563 + This driver also supports a CDC-OBEX option. You will need a 564 + user space OBEX server talking to /dev/ttyGS*, since the kernel 565 + itself doesn't implement the OBEX protocol. 566 + 622 567 Say "y" to link the driver statically, or "m" to build a 623 568 dynamically linked module called "g_serial". 624 569 625 570 For more information, see Documentation/usb/gadget_serial.txt 626 571 which includes instructions and a "driver info file" needed to 627 - make MS-Windows work with this driver. 572 + make MS-Windows work with CDC ACM. 628 573 629 574 config USB_MIDI_GADGET 630 575 tristate "MIDI Gadget (EXPERIMENTAL)"
+1
drivers/usb/gadget/Makefile
··· 18 18 obj-$(CONFIG_USB_ATMEL_USBA) += atmel_usba_udc.o 19 19 obj-$(CONFIG_USB_FSL_USB2) += fsl_usb2_udc.o 20 20 obj-$(CONFIG_USB_M66592) += m66592-udc.o 21 + obj-$(CONFIG_USB_FSL_QE) += fsl_qe_udc.o 21 22 22 23 # 23 24 # USB gadget drivers
-1
drivers/usb/gadget/cdc2.c
··· 155 155 .bConfigurationValue = 1, 156 156 /* .iConfiguration = DYNAMIC */ 157 157 .bmAttributes = USB_CONFIG_ATT_SELFPOWER, 158 - .bMaxPower = 1, /* 2 mA, minimal */ 159 158 }; 160 159 161 160 /*-------------------------------------------------------------------------*/
+66 -2
drivers/usb/gadget/composite.c
··· 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 195 * usb_interface_id() - allocate an unused interface ID 132 196 * @config: configuration associated with the interface 133 197 * @function: function handling the interface ··· 245 181 c->bConfigurationValue = config->bConfigurationValue; 246 182 c->iConfiguration = config->iConfiguration; 247 183 c->bmAttributes = USB_CONFIG_ATT_ONE | config->bmAttributes; 248 - c->bMaxPower = config->bMaxPower; 184 + c->bMaxPower = config->bMaxPower ? : (CONFIG_USB_GADGET_VBUS_DRAW / 2); 249 185 250 186 /* There may be e.g. OTG descriptors */ 251 187 if (config->descriptors) { ··· 432 368 } 433 369 434 370 /* when we return, be sure our power usage is valid */ 435 - power = 2 * c->bMaxPower; 371 + power = c->bMaxPower ? (2 * c->bMaxPower) : CONFIG_USB_GADGET_VBUS_DRAW; 436 372 done: 437 373 usb_gadget_vbus_draw(gadget, power); 438 374 return result;
+27 -6
drivers/usb/gadget/dummy_hcd.c
··· 82 82 const struct usb_endpoint_descriptor *desc; 83 83 struct usb_ep ep; 84 84 unsigned halted : 1; 85 + unsigned wedged : 1; 85 86 unsigned already_seen : 1; 86 87 unsigned setup_stage : 1; 87 88 }; ··· 437 436 /* at this point real hardware should be NAKing transfers 438 437 * to that endpoint, until a buffer is queued to it. 439 438 */ 439 + ep->halted = ep->wedged = 0; 440 440 retval = 0; 441 441 done: 442 442 return retval; ··· 599 597 } 600 598 601 599 static int 602 - dummy_set_halt (struct usb_ep *_ep, int value) 600 + dummy_set_halt_and_wedge(struct usb_ep *_ep, int value, int wedged) 603 601 { 604 602 struct dummy_ep *ep; 605 603 struct dummy *dum; ··· 611 609 if (!dum->driver) 612 610 return -ESHUTDOWN; 613 611 if (!value) 614 - ep->halted = 0; 612 + ep->halted = ep->wedged = 0; 615 613 else if (ep->desc && (ep->desc->bEndpointAddress & USB_DIR_IN) && 616 614 !list_empty (&ep->queue)) 617 615 return -EAGAIN; 618 - else 616 + else { 619 617 ep->halted = 1; 618 + if (wedged) 619 + ep->wedged = 1; 620 + } 620 621 /* FIXME clear emulated data toggle too */ 621 622 return 0; 623 + } 624 + 625 + static int 626 + dummy_set_halt(struct usb_ep *_ep, int value) 627 + { 628 + return dummy_set_halt_and_wedge(_ep, value, 0); 629 + } 630 + 631 + static int dummy_set_wedge(struct usb_ep *_ep) 632 + { 633 + if (!_ep || _ep->name == ep0name) 634 + return -EINVAL; 635 + return dummy_set_halt_and_wedge(_ep, 1, 1); 622 636 } 623 637 624 638 static const struct usb_ep_ops dummy_ep_ops = { ··· 648 630 .dequeue = dummy_dequeue, 649 631 650 632 .set_halt = dummy_set_halt, 633 + .set_wedge = dummy_set_wedge, 651 634 }; 652 635 653 636 /*-------------------------------------------------------------------------*/ ··· 779 760 ep->ep.name = ep_name [i]; 780 761 ep->ep.ops = &dummy_ep_ops; 781 762 list_add_tail (&ep->ep.ep_list, &dum->gadget.ep_list); 782 - ep->halted = ep->already_seen = ep->setup_stage = 0; 763 + ep->halted = ep->wedged = ep->already_seen = 764 + ep->setup_stage = 0; 783 765 ep->ep.maxpacket = ~0; 784 766 ep->last_io = jiffies; 785 767 ep->gadget = &dum->gadget; ··· 1371 1351 } else if (setup.bRequestType == Ep_Request) { 1372 1352 // endpoint halt 1373 1353 ep2 = find_endpoint (dum, w_index); 1374 - if (!ep2) { 1354 + if (!ep2 || ep2->ep.name == ep0name) { 1375 1355 value = -EOPNOTSUPP; 1376 1356 break; 1377 1357 } ··· 1400 1380 value = -EOPNOTSUPP; 1401 1381 break; 1402 1382 } 1403 - ep2->halted = 0; 1383 + if (!ep2->wedged) 1384 + ep2->halted = 0; 1404 1385 value = 0; 1405 1386 status = 0; 1406 1387 }
-2
drivers/usb/gadget/ether.c
··· 242 242 .bConfigurationValue = 2, 243 243 /* .iConfiguration = DYNAMIC */ 244 244 .bmAttributes = USB_CONFIG_ATT_SELFPOWER, 245 - .bMaxPower = 1, /* 2 mA, minimal */ 246 245 }; 247 246 248 247 /*-------------------------------------------------------------------------*/ ··· 270 271 .bConfigurationValue = 1, 271 272 /* .iConfiguration = DYNAMIC */ 272 273 .bmAttributes = USB_CONFIG_ATT_SELFPOWER, 273 - .bMaxPower = 1, /* 2 mA, minimal */ 274 274 }; 275 275 276 276 /*-------------------------------------------------------------------------*/
-1
drivers/usb/gadget/f_loopback.c
··· 352 352 .bind = loopback_bind_config, 353 353 .bConfigurationValue = 2, 354 354 .bmAttributes = USB_CONFIG_ATT_SELFPOWER, 355 - .bMaxPower = 1, /* 2 mA, minimal */ 356 355 /* .iConfiguration = DYNAMIC */ 357 356 }; 358 357
+493
drivers/usb/gadget/f_obex.c
··· 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");
-1
drivers/usb/gadget/f_sourcesink.c
··· 552 552 .setup = sourcesink_setup, 553 553 .bConfigurationValue = 3, 554 554 .bmAttributes = USB_CONFIG_ATT_SELFPOWER, 555 - .bMaxPower = 1, /* 2 mA, minimal */ 556 555 /* .iConfiguration = DYNAMIC */ 557 556 }; 558 557
+18 -5
drivers/usb/gadget/file_storage.c
··· 851 851 .bConfigurationValue = CONFIG_VALUE, 852 852 .iConfiguration = STRING_CONFIG, 853 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 857 static struct usb_otg_descriptor ··· 2676 2676 /* Verify the length of the command itself */ 2677 2677 if (cmnd_size != fsg->cmnd_size) { 2678 2678 2679 - /* Special case workaround: MS-Windows issues REQUEST SENSE 2680 - * with cbw->Length == 12 (it should be 6). */ 2681 - if (fsg->cmnd[0] == SC_REQUEST_SENSE && fsg->cmnd_size == 12) 2679 + /* Special case workaround: There are plenty of buggy SCSI 2680 + * implementations. Many have issues with cbw->Length 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 2695 cmnd_size = fsg->cmnd_size; 2683 - else { 2696 + } else { 2684 2697 fsg->phase_error = 1; 2685 2698 return -EINVAL; 2686 2699 }
+2760
drivers/usb/gadget/fsl_qe_udc.c
··· 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 +
+437
drivers/usb/gadget/fsl_qe_udc.h
··· 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 */
+78 -98
drivers/usb/gadget/fsl_usb2_udc.c
··· 23 23 #include <linux/ioport.h> 24 24 #include <linux/types.h> 25 25 #include <linux/errno.h> 26 - #include <linux/delay.h> 27 - #include <linux/sched.h> 28 26 #include <linux/slab.h> 29 27 #include <linux/init.h> 30 - #include <linux/timer.h> 31 28 #include <linux/list.h> 32 29 #include <linux/interrupt.h> 33 30 #include <linux/proc_fs.h> ··· 41 44 42 45 #include <asm/byteorder.h> 43 46 #include <asm/io.h> 44 - #include <asm/irq.h> 45 47 #include <asm/system.h> 46 48 #include <asm/unaligned.h> 47 49 #include <asm/dma.h> 48 - #include <asm/cacheflush.h> 49 50 50 51 #include "fsl_usb2_udc.h" 51 52 ··· 56 61 static const char driver_name[] = "fsl-usb2-udc"; 57 62 static const char driver_desc[] = DRIVER_DESC; 58 63 59 - volatile static struct usb_dr_device *dr_regs = NULL; 60 - volatile static struct usb_sys_interface *usb_sys_regs = NULL; 64 + static struct usb_dr_device *dr_regs; 65 + static struct usb_sys_interface *usb_sys_regs; 61 66 62 67 /* it is initialized in probe() */ 63 68 static struct fsl_udc *udc_controller = NULL; ··· 71 76 .wMaxPacketSize = USB_MAX_CTRL_PAYLOAD, 72 77 }; 73 78 74 - static int fsl_udc_suspend(struct platform_device *pdev, pm_message_t state); 75 - static int fsl_udc_resume(struct platform_device *pdev); 76 79 static void fsl_ep_fifo_flush(struct usb_ep *_ep); 77 80 78 81 #ifdef CONFIG_PPC32 79 82 #define fsl_readl(addr) in_le32(addr) 80 - #define fsl_writel(addr, val32) out_le32(val32, addr) 83 + #define fsl_writel(val32, addr) out_le32(addr, val32) 81 84 #else 82 85 #define fsl_readl(addr) readl(addr) 83 - #define fsl_writel(addr, val32) writel(addr, val32) 86 + #define fsl_writel(val32, addr) writel(val32, addr) 84 87 #endif 85 88 86 89 /******************************************************************** ··· 178 185 unsigned long timeout; 179 186 #define FSL_UDC_RESET_TIMEOUT 1000 180 187 181 - /* before here, make sure dr_regs has been initialized */ 182 - if (!udc) 183 - return -EINVAL; 184 - 185 188 /* Stop and reset the usb controller */ 186 189 tmp = fsl_readl(&dr_regs->usbcmd); 187 190 tmp &= ~USB_CMD_RUN_STOP; ··· 191 202 timeout = jiffies + FSL_UDC_RESET_TIMEOUT; 192 203 while (fsl_readl(&dr_regs->usbcmd) & USB_CMD_CTRL_RESET) { 193 204 if (time_after(jiffies, timeout)) { 194 - ERR("udc reset timeout! \n"); 205 + ERR("udc reset timeout!\n"); 195 206 return -ETIMEDOUT; 196 207 } 197 208 cpu_relax(); ··· 304 315 return; 305 316 } 306 317 307 - void dr_ep_setup(unsigned char ep_num, unsigned char dir, unsigned char ep_type) 318 + static void dr_ep_setup(unsigned char ep_num, unsigned char dir, 319 + unsigned char ep_type) 308 320 { 309 321 unsigned int tmp_epctrl = 0; 310 322 ··· 553 563 /* nuke all pending requests (does flush) */ 554 564 nuke(ep, -ESHUTDOWN); 555 565 556 - ep->desc = 0; 566 + ep->desc = NULL; 557 567 ep->stopped = 1; 558 568 spin_unlock_irqrestore(&udc->lock, flags); 559 569 ··· 592 602 } 593 603 594 604 /*-------------------------------------------------------------------------*/ 595 - static int fsl_queue_td(struct fsl_ep *ep, struct fsl_req *req) 605 + static void fsl_queue_td(struct fsl_ep *ep, struct fsl_req *req) 596 606 { 597 607 int i = ep_index(ep) * 2 + ep_is_in(ep); 598 608 u32 temp, bitmask, tmp_stat; ··· 643 653 | EP_QUEUE_HEAD_STATUS_HALT)); 644 654 dQH->size_ioc_int_sts &= temp; 645 655 656 + /* Ensure that updates to the QH will occure before priming. */ 657 + wmb(); 658 + 646 659 /* Prime endpoint by writing 1 to ENDPTPRIME */ 647 660 temp = ep_is_in(ep) 648 661 ? (1 << (ep_index(ep) + 16)) 649 662 : (1 << (ep_index(ep))); 650 663 fsl_writel(temp, &dr_regs->endpointprime); 651 664 out: 652 - return 0; 665 + return; 653 666 } 654 667 655 668 /* Fill in the dTD structure ··· 703 710 *is_last = 0; 704 711 705 712 if ((*is_last) == 0) 706 - VDBG("multi-dtd request!\n"); 713 + VDBG("multi-dtd request!"); 707 714 /* Fill in the transfer size; set active bit */ 708 715 swap_temp = ((*length << DTD_LENGTH_BIT_POS) | DTD_STATUS_ACTIVE); 709 716 ··· 766 773 /* catch various bogus parameters */ 767 774 if (!_req || !req->req.complete || !req->req.buf 768 775 || !list_empty(&req->queue)) { 769 - VDBG("%s, bad params\n", __func__); 776 + VDBG("%s, bad params", __func__); 770 777 return -EINVAL; 771 778 } 772 779 if (unlikely(!_ep || !ep->desc)) { 773 - VDBG("%s, bad ep\n", __func__); 780 + VDBG("%s, bad ep", __func__); 774 781 return -EINVAL; 775 782 } 776 783 if (ep->desc->bmAttributes == USB_ENDPOINT_XFER_ISOC) { ··· 1062 1069 1063 1070 udc = container_of(gadget, struct fsl_udc, gadget); 1064 1071 spin_lock_irqsave(&udc->lock, flags); 1065 - VDBG("VBUS %s\n", is_active ? "on" : "off"); 1072 + VDBG("VBUS %s", is_active ? "on" : "off"); 1066 1073 udc->vbus_active = (is_active != 0); 1067 1074 if (can_pullup(udc)) 1068 1075 fsl_writel((fsl_readl(&dr_regs->usbcmd) | USB_CMD_RUN_STOP), ··· 1139 1146 { 1140 1147 struct fsl_req *req = udc->status_req; 1141 1148 struct fsl_ep *ep; 1142 - int status = 0; 1143 1149 1144 1150 if (direction == EP_DIR_IN) 1145 1151 udc->ep0_dir = USB_DIR_IN; ··· 1156 1164 req->dtd_count = 0; 1157 1165 1158 1166 if (fsl_req_to_dtd(req) == 0) 1159 - status = fsl_queue_td(ep, req); 1167 + fsl_queue_td(ep, req); 1160 1168 else 1161 1169 return -ENOMEM; 1162 1170 1163 - if (status) 1164 - ERR("Can't queue ep0 status request \n"); 1165 1171 list_add_tail(&req->queue, &ep->queue); 1166 1172 1167 - return status; 1173 + return 0; 1168 1174 } 1169 1175 1170 - static inline int udc_reset_ep_queue(struct fsl_udc *udc, u8 pipe) 1176 + static void udc_reset_ep_queue(struct fsl_udc *udc, u8 pipe) 1171 1177 { 1172 1178 struct fsl_ep *ep = get_ep_by_pipe(udc, pipe); 1173 1179 1174 - if (!ep->name) 1175 - return 0; 1176 - 1177 - nuke(ep, -ESHUTDOWN); 1178 - 1179 - return 0; 1180 + if (ep->name) 1181 + nuke(ep, -ESHUTDOWN); 1180 1182 } 1181 1183 1182 1184 /* ··· 1194 1208 u16 index, u16 length) 1195 1209 { 1196 1210 u16 tmp = 0; /* Status, cpu endian */ 1197 - 1198 1211 struct fsl_req *req; 1199 1212 struct fsl_ep *ep; 1200 - int status = 0; 1201 1213 1202 1214 ep = &udc->eps[0]; 1203 1215 ··· 1234 1250 1235 1251 /* prime the data phase */ 1236 1252 if ((fsl_req_to_dtd(req) == 0)) 1237 - status = fsl_queue_td(ep, req); 1253 + fsl_queue_td(ep, req); 1238 1254 else /* no mem */ 1239 1255 goto stall; 1240 1256 1241 - if (status) { 1242 - ERR("Can't respond to getstatus request \n"); 1243 - goto stall; 1244 - } 1245 1257 list_add_tail(&req->queue, &ep->queue); 1246 1258 udc->ep0_state = DATA_STATE_XMIT; 1247 1259 return; ··· 1377 1397 udc->ep0_state = WAIT_FOR_SETUP; 1378 1398 break; 1379 1399 case WAIT_FOR_SETUP: 1380 - ERR("Unexpect ep0 packets \n"); 1400 + ERR("Unexpect ep0 packets\n"); 1381 1401 break; 1382 1402 default: 1383 1403 ep0stall(udc); ··· 1456 1476 status = -EILSEQ; 1457 1477 break; 1458 1478 } else 1459 - ERR("Unknown error has occured (0x%x)!\r\n", 1479 + ERR("Unknown error has occured (0x%x)!\n", 1460 1480 errors); 1461 1481 1462 1482 } else if (le32_to_cpu(curr_td->size_ioc_sts) ··· 1475 1495 } 1476 1496 } else { 1477 1497 td_complete++; 1478 - VDBG("dTD transmitted successful "); 1498 + VDBG("dTD transmitted successful"); 1479 1499 } 1480 1500 1481 1501 if (j != curr_req->dtd_count - 1) ··· 1547 1567 static void port_change_irq(struct fsl_udc *udc) 1548 1568 { 1549 1569 u32 speed; 1550 - 1551 - if (udc->bus_reset) 1552 - udc->bus_reset = 0; 1553 1570 1554 1571 /* Bus resetting is finished */ 1555 1572 if (!(fsl_readl(&dr_regs->portsc1) & PORTSCX_PORT_RESET)) { ··· 1655 1678 1656 1679 if (fsl_readl(&dr_regs->portsc1) & PORTSCX_PORT_RESET) { 1657 1680 VDBG("Bus reset"); 1658 - /* Bus is reseting */ 1659 - udc->bus_reset = 1; 1660 1681 /* Reset all the queues, include XD, dTD, EP queue 1661 1682 * head and TR Queue */ 1662 1683 reset_queues(udc); ··· 1743 1768 } 1744 1769 1745 1770 if (irq_src & (USB_STS_ERR | USB_STS_SYS_ERR)) { 1746 - VDBG("Error IRQ %x ", irq_src); 1771 + VDBG("Error IRQ %x", irq_src); 1747 1772 } 1748 1773 1749 1774 spin_unlock_irqrestore(&udc->lock, flags); ··· 1774 1799 /* lock is needed but whether should use this lock or another */ 1775 1800 spin_lock_irqsave(&udc_controller->lock, flags); 1776 1801 1777 - driver->driver.bus = 0; 1802 + driver->driver.bus = NULL; 1778 1803 /* hook up the driver */ 1779 1804 udc_controller->driver = driver; 1780 1805 udc_controller->gadget.dev.driver = &driver->driver; ··· 1784 1809 retval = driver->bind(&udc_controller->gadget); 1785 1810 if (retval) { 1786 1811 VDBG("bind to %s --> %d", driver->driver.name, retval); 1787 - udc_controller->gadget.dev.driver = 0; 1788 - udc_controller->driver = 0; 1812 + udc_controller->gadget.dev.driver = NULL; 1813 + udc_controller->driver = NULL; 1789 1814 goto out; 1790 1815 } 1791 1816 ··· 1794 1819 udc_controller->usb_state = USB_STATE_ATTACHED; 1795 1820 udc_controller->ep0_state = WAIT_FOR_SETUP; 1796 1821 udc_controller->ep0_dir = 0; 1797 - printk(KERN_INFO "%s: bind to driver %s \n", 1822 + printk(KERN_INFO "%s: bind to driver %s\n", 1798 1823 udc_controller->gadget.name, driver->driver.name); 1799 1824 1800 1825 out: 1801 1826 if (retval) 1802 - printk("retval %d \n", retval); 1827 + printk("gadget driver register failed %d\n", retval); 1803 1828 return retval; 1804 1829 } 1805 1830 EXPORT_SYMBOL(usb_gadget_register_driver); ··· 1817 1842 return -EINVAL; 1818 1843 1819 1844 if (udc_controller->transceiver) 1820 - (void)otg_set_peripheral(udc_controller->transceiver, 0); 1845 + otg_set_peripheral(udc_controller->transceiver, NULL); 1821 1846 1822 1847 /* stop DR, disable intr */ 1823 1848 dr_controller_stop(udc_controller); ··· 1838 1863 1839 1864 /* unbind gadget and unhook driver. */ 1840 1865 driver->unbind(&udc_controller->gadget); 1841 - udc_controller->gadget.dev.driver = 0; 1842 - udc_controller->driver = 0; 1866 + udc_controller->gadget.dev.driver = NULL; 1867 + udc_controller->driver = NULL; 1843 1868 1844 - printk("unregistered gadget driver '%s'\r\n", driver->driver.name); 1869 + printk("unregistered gadget driver '%s'\n", driver->driver.name); 1845 1870 return 0; 1846 1871 } 1847 1872 EXPORT_SYMBOL(usb_gadget_unregister_driver); ··· 1897 1922 tmp_reg = fsl_readl(&dr_regs->usbsts); 1898 1923 t = scnprintf(next, size, 1899 1924 "USB Status Reg:\n" 1900 - "Dr Suspend: %d" "Reset Received: %d" "System Error: %s" 1925 + "Dr Suspend: %d Reset Received: %d System Error: %s " 1901 1926 "USB Error Interrupt: %s\n\n", 1902 1927 (tmp_reg & USB_STS_SUSPEND) ? 1 : 0, 1903 1928 (tmp_reg & USB_STS_RESET) ? 1 : 0, ··· 1909 1934 tmp_reg = fsl_readl(&dr_regs->usbintr); 1910 1935 t = scnprintf(next, size, 1911 1936 "USB Intrrupt Enable Reg:\n" 1912 - "Sleep Enable: %d" "SOF Received Enable: %d" 1937 + "Sleep Enable: %d SOF Received Enable: %d " 1913 1938 "Reset Enable: %d\n" 1914 - "System Error Enable: %d" 1939 + "System Error Enable: %d " 1915 1940 "Port Change Dectected Enable: %d\n" 1916 - "USB Error Intr Enable: %d" "USB Intr Enable: %d\n\n", 1941 + "USB Error Intr Enable: %d USB Intr Enable: %d\n\n", 1917 1942 (tmp_reg & USB_INTR_DEVICE_SUSPEND) ? 1 : 0, 1918 1943 (tmp_reg & USB_INTR_SOF_EN) ? 1 : 0, 1919 1944 (tmp_reg & USB_INTR_RESET_EN) ? 1 : 0, ··· 1926 1951 1927 1952 tmp_reg = fsl_readl(&dr_regs->frindex); 1928 1953 t = scnprintf(next, size, 1929 - "USB Frame Index Reg:" "Frame Number is 0x%x\n\n", 1954 + "USB Frame Index Reg: Frame Number is 0x%x\n\n", 1930 1955 (tmp_reg & USB_FRINDEX_MASKS)); 1931 1956 size -= t; 1932 1957 next += t; 1933 1958 1934 1959 tmp_reg = fsl_readl(&dr_regs->deviceaddr); 1935 1960 t = scnprintf(next, size, 1936 - "USB Device Address Reg:" "Device Addr is 0x%x\n\n", 1961 + "USB Device Address Reg: Device Addr is 0x%x\n\n", 1937 1962 (tmp_reg & USB_DEVICE_ADDRESS_MASK)); 1938 1963 size -= t; 1939 1964 next += t; 1940 1965 1941 1966 tmp_reg = fsl_readl(&dr_regs->endpointlistaddr); 1942 1967 t = scnprintf(next, size, 1943 - "USB Endpoint List Address Reg:" 1968 + "USB Endpoint List Address Reg: " 1944 1969 "Device Addr is 0x%x\n\n", 1945 1970 (tmp_reg & USB_EP_LIST_ADDRESS_MASK)); 1946 1971 size -= t; ··· 1949 1974 tmp_reg = fsl_readl(&dr_regs->portsc1); 1950 1975 t = scnprintf(next, size, 1951 1976 "USB Port Status&Control Reg:\n" 1952 - "Port Transceiver Type : %s" "Port Speed: %s \n" 1953 - "PHY Low Power Suspend: %s" "Port Reset: %s" 1954 - "Port Suspend Mode: %s \n" "Over-current Change: %s" 1977 + "Port Transceiver Type : %s Port Speed: %s\n" 1978 + "PHY Low Power Suspend: %s Port Reset: %s " 1979 + "Port Suspend Mode: %s\n" 1980 + "Over-current Change: %s " 1955 1981 "Port Enable/Disable Change: %s\n" 1956 - "Port Enabled/Disabled: %s" 1982 + "Port Enabled/Disabled: %s " 1957 1983 "Current Connect Status: %s\n\n", ( { 1958 1984 char *s; 1959 1985 switch (tmp_reg & PORTSCX_PTS_FSLS) { ··· 1999 2023 2000 2024 tmp_reg = fsl_readl(&dr_regs->usbmode); 2001 2025 t = scnprintf(next, size, 2002 - "USB Mode Reg:" "Controller Mode is : %s\n\n", ( { 2026 + "USB Mode Reg: Controller Mode is: %s\n\n", ( { 2003 2027 char *s; 2004 2028 switch (tmp_reg & USB_MODE_CTRL_MODE_HOST) { 2005 2029 case USB_MODE_CTRL_MODE_IDLE: ··· 2018 2042 2019 2043 tmp_reg = fsl_readl(&dr_regs->endptsetupstat); 2020 2044 t = scnprintf(next, size, 2021 - "Endpoint Setup Status Reg:" "SETUP on ep 0x%x\n\n", 2045 + "Endpoint Setup Status Reg: SETUP on ep 0x%x\n\n", 2022 2046 (tmp_reg & EP_SETUP_STATUS_MASK)); 2023 2047 size -= t; 2024 2048 next += t; ··· 2031 2055 next += t; 2032 2056 } 2033 2057 tmp_reg = fsl_readl(&dr_regs->endpointprime); 2034 - t = scnprintf(next, size, "EP Prime Reg = [0x%x]\n", tmp_reg); 2058 + t = scnprintf(next, size, "EP Prime Reg = [0x%x]\n\n", tmp_reg); 2035 2059 size -= t; 2036 2060 next += t; 2037 2061 2038 2062 tmp_reg = usb_sys_regs->snoop1; 2039 - t = scnprintf(next, size, "\nSnoop1 Reg : = [0x%x]\n\n", tmp_reg); 2063 + t = scnprintf(next, size, "Snoop1 Reg : = [0x%x]\n\n", tmp_reg); 2040 2064 size -= t; 2041 2065 next += t; 2042 2066 ··· 2060 2084 } else { 2061 2085 list_for_each_entry(req, &ep->queue, queue) { 2062 2086 t = scnprintf(next, size, 2063 - "req %p actual 0x%x length 0x%x buf %p\n", 2087 + "req %p actual 0x%x length 0x%x buf %p\n", 2064 2088 &req->req, req->req.actual, 2065 2089 req->req.length, req->req.buf); 2066 2090 size -= t; ··· 2086 2110 } else { 2087 2111 list_for_each_entry(req, &ep->queue, queue) { 2088 2112 t = scnprintf(next, size, 2089 - "req %p actual 0x%x length" 2113 + "req %p actual 0x%x length " 2090 2114 "0x%x buf %p\n", 2091 2115 &req->req, req->req.actual, 2092 2116 req->req.length, req->req.buf); ··· 2178 2202 udc->usb_state = USB_STATE_POWERED; 2179 2203 udc->ep0_dir = 0; 2180 2204 udc->remote_wakeup = 0; /* default to 0 on reset */ 2181 - spin_lock_init(&udc->lock); 2182 2205 2183 2206 return 0; 2184 2207 } ··· 2229 2254 u32 dccparams; 2230 2255 2231 2256 if (strcmp(pdev->name, driver_name)) { 2232 - VDBG("Wrong device\n"); 2257 + VDBG("Wrong device"); 2233 2258 return -ENODEV; 2234 2259 } 2235 2260 ··· 2239 2264 return -ENOMEM; 2240 2265 } 2241 2266 2267 + spin_lock_init(&udc_controller->lock); 2268 + udc_controller->stopped = 1; 2269 + 2242 2270 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 2243 2271 if (!res) { 2244 - kfree(udc_controller); 2245 - return -ENXIO; 2272 + ret = -ENXIO; 2273 + goto err_kfree; 2246 2274 } 2247 2275 2248 2276 if (!request_mem_region(res->start, res->end - res->start + 1, 2249 2277 driver_name)) { 2250 - ERR("request mem region for %s failed \n", pdev->name); 2251 - kfree(udc_controller); 2252 - return -EBUSY; 2278 + ERR("request mem region for %s failed\n", pdev->name); 2279 + ret = -EBUSY; 2280 + goto err_kfree; 2253 2281 } 2254 2282 2255 2283 dr_regs = ioremap(res->start, res->end - res->start + 1); 2256 2284 if (!dr_regs) { 2257 2285 ret = -ENOMEM; 2258 - goto err1; 2286 + goto err_release_mem_region; 2259 2287 } 2260 2288 2261 2289 usb_sys_regs = (struct usb_sys_interface *) ··· 2269 2291 if (!(dccparams & DCCPARAMS_DC)) { 2270 2292 ERR("This SOC doesn't support device role\n"); 2271 2293 ret = -ENODEV; 2272 - goto err2; 2294 + goto err_iounmap; 2273 2295 } 2274 2296 /* Get max device endpoints */ 2275 2297 /* DEN is bidirectional ep number, max_ep doubles the number */ ··· 2278 2300 udc_controller->irq = platform_get_irq(pdev, 0); 2279 2301 if (!udc_controller->irq) { 2280 2302 ret = -ENODEV; 2281 - goto err2; 2303 + goto err_iounmap; 2282 2304 } 2283 2305 2284 2306 ret = request_irq(udc_controller->irq, fsl_udc_irq, IRQF_SHARED, 2285 2307 driver_name, udc_controller); 2286 2308 if (ret != 0) { 2287 - ERR("cannot request irq %d err %d \n", 2309 + ERR("cannot request irq %d err %d\n", 2288 2310 udc_controller->irq, ret); 2289 - goto err2; 2311 + goto err_iounmap; 2290 2312 } 2291 2313 2292 2314 /* Initialize the udc structure including QH member and other member */ 2293 2315 if (struct_udc_setup(udc_controller, pdev)) { 2294 2316 ERR("Can't initialize udc data structure\n"); 2295 2317 ret = -ENOMEM; 2296 - goto err3; 2318 + goto err_free_irq; 2297 2319 } 2298 2320 2299 2321 /* initialize usb hw reg except for regs for EP, ··· 2314 2336 udc_controller->gadget.dev.parent = &pdev->dev; 2315 2337 ret = device_register(&udc_controller->gadget.dev); 2316 2338 if (ret < 0) 2317 - goto err3; 2339 + goto err_free_irq; 2318 2340 2319 2341 /* setup QH and epctrl for ep0 */ 2320 2342 ep0_setup(udc_controller); ··· 2344 2366 DTD_ALIGNMENT, UDC_DMA_BOUNDARY); 2345 2367 if (udc_controller->td_pool == NULL) { 2346 2368 ret = -ENOMEM; 2347 - goto err4; 2369 + goto err_unregister; 2348 2370 } 2349 2371 create_proc_file(); 2350 2372 return 0; 2351 2373 2352 - err4: 2374 + err_unregister: 2353 2375 device_unregister(&udc_controller->gadget.dev); 2354 - err3: 2376 + err_free_irq: 2355 2377 free_irq(udc_controller->irq, udc_controller); 2356 - err2: 2378 + err_iounmap: 2357 2379 iounmap(dr_regs); 2358 - err1: 2380 + err_release_mem_region: 2359 2381 release_mem_region(res->start, res->end - res->start + 1); 2382 + err_kfree: 2360 2383 kfree(udc_controller); 2384 + udc_controller = NULL; 2361 2385 return ret; 2362 2386 } 2363 2387 ··· 2449 2469 static void __exit udc_exit(void) 2450 2470 { 2451 2471 platform_driver_unregister(&udc_driver); 2452 - printk("%s unregistered \n", driver_desc); 2472 + printk("%s unregistered\n", driver_desc); 2453 2473 } 2454 2474 2455 2475 module_exit(udc_exit);
+2 -19
drivers/usb/gadget/fsl_usb2_udc.h
··· 424 424 /* Controller dma boundary */ 425 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 429 /* ### driver private data ··· 459 469 #define EP_DIR_OUT 0 460 470 461 471 struct fsl_udc { 462 - 463 472 struct usb_gadget gadget; 464 473 struct usb_gadget_driver *driver; 474 + struct completion *done; /* to make sure release() is done */ 465 475 struct fsl_ep *eps; 466 476 unsigned int max_ep; 467 477 unsigned int irq; ··· 482 492 size_t ep_qh_size; /* size after alignment adjustment*/ 483 493 dma_addr_t ep_qh_dma; /* dma address of QH */ 484 494 485 - u32 max_pipes; /* Device max pipes */ 486 - u32 max_use_endpts; /* Max endpointes to be used */ 487 - u32 bus_reset; /* Device is bus reseting */ 495 + u32 max_pipes; /* Device max pipes */ 488 496 u32 resume_state; /* USB state to resume */ 489 497 u32 usb_state; /* USB current state */ 490 - u32 usb_next_state; /* USB next state */ 491 498 u32 ep0_state; /* Endpoint zero state */ 492 499 u32 ep0_dir; /* Endpoint zero direction: can be 493 500 USB_DIR_IN or USB_DIR_OUT */ 494 - u32 usb_sof_count; /* SOF count */ 495 - u32 errors; /* USB ERRORs count */ 496 501 u8 device_address; /* Device USB address */ 497 - 498 - struct completion *done; /* to make sure release() is done */ 499 502 }; 500 503 501 504 /*-------------------------------------------------------------------------*/
+9
drivers/usb/gadget/gadget_chips.h
··· 151 151 #define gadget_is_m66592(g) 0 152 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 162 // CONFIG_USB_GADGET_SX2 156 163 // CONFIG_USB_GADGET_AU1X00 ··· 223 216 return 0x20; 224 217 else if (gadget_is_m66592(gadget)) 225 218 return 0x21; 219 + else if (gadget_is_fsl_qe(gadget)) 220 + return 0x22; 226 221 return -ENOENT; 227 222 } 228 223
+1 -1
drivers/usb/gadget/gmidi.c
··· 222 222 * power properties of the device. Is it selfpowered? 223 223 */ 224 224 .bmAttributes = USB_CONFIG_ATT_ONE, 225 - .bMaxPower = 1, 225 + .bMaxPower = CONFIG_USB_GADGET_VBUS_DRAW / 2, 226 226 }; 227 227 228 228 /* B.3.1 Standard AC Interface Descriptor */
+34 -6
drivers/usb/gadget/net2280.c
··· 178 178 179 179 /* ep_reset() has already been called */ 180 180 ep->stopped = 0; 181 + ep->wedged = 0; 181 182 ep->out_overflow = 0; 182 183 183 184 /* set speed-dependent max packet; may kick in high bandwidth */ ··· 1219 1218 static int net2280_fifo_status (struct usb_ep *_ep); 1220 1219 1221 1220 static int 1222 - net2280_set_halt (struct usb_ep *_ep, int value) 1221 + net2280_set_halt_and_wedge(struct usb_ep *_ep, int value, int wedged) 1223 1222 { 1224 1223 struct net2280_ep *ep; 1225 1224 unsigned long flags; ··· 1240 1239 else if (ep->is_in && value && net2280_fifo_status (_ep) != 0) 1241 1240 retval = -EAGAIN; 1242 1241 else { 1243 - VDEBUG (ep->dev, "%s %s halt\n", _ep->name, 1244 - value ? "set" : "clear"); 1242 + VDEBUG (ep->dev, "%s %s %s\n", _ep->name, 1243 + value ? "set" : "clear", 1244 + wedged ? "wedge" : "halt"); 1245 1245 /* set/clear, then synch memory views with the device */ 1246 1246 if (value) { 1247 1247 if (ep->num == 0) 1248 1248 ep->dev->protocol_stall = 1; 1249 1249 else 1250 1250 set_halt (ep); 1251 - } else 1251 + if (wedged) 1252 + ep->wedged = 1; 1253 + } else { 1252 1254 clear_halt (ep); 1255 + ep->wedged = 0; 1256 + } 1253 1257 (void) readl (&ep->regs->ep_rsp); 1254 1258 } 1255 1259 spin_unlock_irqrestore (&ep->dev->lock, flags); 1256 1260 1257 1261 return retval; 1262 + } 1263 + 1264 + static int 1265 + net2280_set_halt(struct usb_ep *_ep, int value) 1266 + { 1267 + return net2280_set_halt_and_wedge(_ep, value, 0); 1268 + } 1269 + 1270 + static int 1271 + net2280_set_wedge(struct usb_ep *_ep) 1272 + { 1273 + if (!_ep || _ep->name == ep0name) 1274 + return -EINVAL; 1275 + return net2280_set_halt_and_wedge(_ep, 1, 1); 1258 1276 } 1259 1277 1260 1278 static int ··· 1322 1302 .dequeue = net2280_dequeue, 1323 1303 1324 1304 .set_halt = net2280_set_halt, 1305 + .set_wedge = net2280_set_wedge, 1325 1306 .fifo_status = net2280_fifo_status, 1326 1307 .fifo_flush = net2280_fifo_flush, 1327 1308 }; ··· 2431 2410 goto do_stall; 2432 2411 if ((e = get_ep_by_addr (dev, w_index)) == 0) 2433 2412 goto do_stall; 2434 - clear_halt (e); 2413 + if (e->wedged) { 2414 + VDEBUG(dev, "%s wedged, halt not cleared\n", 2415 + ep->ep.name); 2416 + } else { 2417 + VDEBUG(dev, "%s clear halt\n", ep->ep.name); 2418 + clear_halt(e); 2419 + } 2435 2420 allow_status (ep); 2436 - VDEBUG (dev, "%s clear halt\n", ep->ep.name); 2437 2421 goto next_endpoints; 2438 2422 } 2439 2423 break; ··· 2452 2426 || w_length != 0) 2453 2427 goto do_stall; 2454 2428 if ((e = get_ep_by_addr (dev, w_index)) == 0) 2429 + goto do_stall; 2430 + if (e->ep.name == ep0name) 2455 2431 goto do_stall; 2456 2432 set_halt (e); 2457 2433 allow_status (ep);
+1
drivers/usb/gadget/net2280.h
··· 109 109 in_fifo_validate : 1, 110 110 out_overflow : 1, 111 111 stopped : 1, 112 + wedged : 1, 112 113 is_in : 1, 113 114 is_iso : 1, 114 115 responded : 1;
+7
drivers/usb/gadget/omap_udc.c
··· 2313 2313 2314 2314 tmp = omap_readl(OTG_REV); 2315 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 2323 ctrl_name = "control_devconf"; 2317 2324 trans = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0); 2318 2325 } else {
+2 -4
drivers/usb/gadget/printer.c
··· 252 252 .bConfigurationValue = DEV_CONFIG_VALUE, 253 253 .iConfiguration = 0, 254 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 258 static struct usb_interface_descriptor intf_desc = { ··· 1278 1278 /* respond with data transfer before status phase? */ 1279 1279 if (value >= 0) { 1280 1280 req->length = value; 1281 - req->zero = value < wLength 1282 - && (value % gadget->ep0->maxpacket) == 0; 1281 + req->zero = value < wLength; 1283 1282 value = usb_ep_queue(gadget->ep0, req, GFP_ATOMIC); 1284 1283 if (value < 0) { 1285 1284 DBG(dev, "ep_queue --> %d\n", value); ··· 1476 1477 if (gadget->is_otg) { 1477 1478 otg_desc.bmAttributes |= USB_OTG_HNP, 1478 1479 config_desc.bmAttributes |= USB_CONFIG_ATT_WAKEUP; 1479 - config_desc.bMaxPower = 4; 1480 1480 } 1481 1481 1482 1482 spin_lock_init(&dev->lock);
-1
drivers/usb/gadget/pxa27x_udc.c
··· 22 22 #include <linux/module.h> 23 23 #include <linux/kernel.h> 24 24 #include <linux/types.h> 25 - #include <linux/version.h> 26 25 #include <linux/errno.h> 27 26 #include <linux/platform_device.h> 28 27 #include <linux/delay.h>
+1 -1
drivers/usb/gadget/s3c2410_udc.c
··· 1651 1651 return -EBUSY; 1652 1652 1653 1653 if (!driver->bind || !driver->setup 1654 - || driver->speed != USB_SPEED_FULL) { 1654 + || driver->speed < USB_SPEED_FULL) { 1655 1655 printk(KERN_ERR "Invalid driver: bind %p setup %p speed %d\n", 1656 1656 driver->bind, driver->setup, driver->speed); 1657 1657 return -EINVAL;
+14 -1
drivers/usb/gadget/serial.c
··· 43 43 #include "epautoconf.c" 44 44 45 45 #include "f_acm.c" 46 + #include "f_obex.c" 46 47 #include "f_serial.c" 47 48 #include "u_serial.c" 48 49 ··· 57 56 #define GS_VENDOR_ID 0x0525 /* NetChip */ 58 57 #define GS_PRODUCT_ID 0xa4a6 /* Linux-USB Serial Gadget */ 59 58 #define GS_CDC_PRODUCT_ID 0xa4a7 /* ... as CDC-ACM */ 59 + #define GS_CDC_OBEX_PRODUCT_ID 0xa4a9 /* ... as CDC-OBEX */ 60 60 61 61 /* string IDs are assigned dynamically */ 62 62 ··· 127 125 module_param(use_acm, bool, 0); 128 126 MODULE_PARM_DESC(use_acm, "Use CDC ACM, default=yes"); 129 127 128 + static int use_obex = false; 129 + module_param(use_obex, bool, 0); 130 + MODULE_PARM_DESC(use_obex, "Use CDC OBEX, default=no"); 131 + 130 132 static unsigned n_ports = 1; 131 133 module_param(n_ports, uint, 0); 132 134 MODULE_PARM_DESC(n_ports, "number of ports to create, default=1"); ··· 145 139 for (i = 0; i < n_ports && status == 0; i++) { 146 140 if (use_acm) 147 141 status = acm_bind_config(c, i); 142 + else if (use_obex) 143 + status = obex_bind_config(c, i); 148 144 else 149 145 status = gser_bind_config(c, i); 150 146 } ··· 159 151 /* .bConfigurationValue = f(use_acm) */ 160 152 /* .iConfiguration = DYNAMIC */ 161 153 .bmAttributes = USB_CONFIG_ATT_SELFPOWER, 162 - .bMaxPower = 1, /* 2 mA, minimal */ 163 154 }; 164 155 165 156 static int __init gs_bind(struct usb_composite_dev *cdev) ··· 256 249 device_desc.bDeviceClass = USB_CLASS_COMM; 257 250 device_desc.idProduct = 258 251 __constant_cpu_to_le16(GS_CDC_PRODUCT_ID); 252 + } else if (use_obex) { 253 + serial_config_driver.label = "CDC OBEX config"; 254 + serial_config_driver.bConfigurationValue = 3; 255 + device_desc.bDeviceClass = USB_CLASS_COMM; 256 + device_desc.idProduct = 257 + __constant_cpu_to_le16(GS_CDC_OBEX_PRODUCT_ID); 259 258 } else { 260 259 serial_config_driver.label = "Generic Serial config"; 261 260 serial_config_driver.bConfigurationValue = 1;
+7
drivers/usb/gadget/u_ether.c
··· 873 873 spin_lock(&dev->lock); 874 874 dev->port_usb = link; 875 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 883 spin_unlock(&dev->lock); 877 884 878 885 netif_carrier_on(dev->net);
+1
drivers/usb/gadget/u_serial.h
··· 62 62 /* functions are bound to configurations by a config or gadget driver */ 63 63 int acm_bind_config(struct usb_configuration *c, u8 port_num); 64 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 67 #endif /* __U_SERIAL_H */
+32 -24
drivers/usb/host/ehci-dbg.c
··· 358 358 struct usb_bus *bus; 359 359 struct mutex mutex; /* protect filling of buffer */ 360 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 365 #define speed_char(info1) ({ char tmp; \ ··· 489 488 490 489 hcd = bus_to_hcd(buf->bus); 491 490 ehci = hcd_to_ehci (hcd); 492 - next = buf->page; 493 - size = PAGE_SIZE; 491 + next = buf->output_buf; 492 + size = buf->alloc_size; 494 493 495 494 *next = 0; 496 495 ··· 511 510 } 512 511 spin_unlock_irqrestore (&ehci->lock, flags); 513 512 514 - return strlen(buf->page); 513 + return strlen(buf->output_buf); 515 514 } 516 515 517 516 #define DBG_SCHED_LIMIT 64 ··· 532 531 533 532 hcd = bus_to_hcd(buf->bus); 534 533 ehci = hcd_to_ehci (hcd); 535 - next = buf->page; 536 - size = PAGE_SIZE; 534 + next = buf->output_buf; 535 + size = buf->alloc_size; 537 536 538 537 temp = scnprintf (next, size, "size = %d\n", ehci->periodic_size); 539 538 size -= temp; ··· 569 568 for (temp = 0; temp < seen_count; temp++) { 570 569 if (seen [temp].ptr != p.ptr) 571 570 continue; 572 - if (p.qh->qh_next.ptr) 571 + if (p.qh->qh_next.ptr) { 573 572 temp = scnprintf (next, size, 574 573 " ..."); 575 - p.ptr = NULL; 574 + size -= temp; 575 + next += temp; 576 + } 576 577 break; 577 578 } 578 579 /* show more info the first time around */ 579 - if (temp == seen_count && p.ptr) { 580 + if (temp == seen_count) { 580 581 u32 scratch = hc32_to_cpup(ehci, 581 582 &p.qh->hw_info1); 582 583 struct ehci_qtd *qtd; ··· 652 649 spin_unlock_irqrestore (&ehci->lock, flags); 653 650 kfree (seen); 654 651 655 - return PAGE_SIZE - size; 652 + return buf->alloc_size - size; 656 653 } 657 654 #undef DBG_SCHED_LIMIT 658 655 ··· 668 665 669 666 hcd = bus_to_hcd(buf->bus); 670 667 ehci = hcd_to_ehci (hcd); 671 - next = buf->page; 672 - size = PAGE_SIZE; 668 + next = buf->output_buf; 669 + size = buf->alloc_size; 673 670 674 671 spin_lock_irqsave (&ehci->lock, flags); 675 672 676 673 if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) { 677 674 size = scnprintf (next, size, 678 - "bus %s, device %s (driver " DRIVER_VERSION ")\n" 675 + "bus %s, device %s\n" 679 676 "%s\n" 680 677 "SUSPENDED (no register access)\n", 681 678 hcd->self.controller->bus->name, ··· 687 684 /* Capability Registers */ 688 685 i = HC_VERSION(ehci_readl(ehci, &ehci->caps->hc_capbase)); 689 686 temp = scnprintf (next, size, 690 - "bus %s, device %s (driver " DRIVER_VERSION ")\n" 687 + "bus %s, device %s\n" 691 688 "%s\n" 692 689 "EHCI %x.%02x, hcd state %d\n", 693 690 hcd->self.controller->bus->name, ··· 811 808 done: 812 809 spin_unlock_irqrestore (&ehci->lock, flags); 813 810 814 - return PAGE_SIZE - size; 811 + return buf->alloc_size - size; 815 812 } 816 813 817 814 static struct debug_buffer *alloc_buffer(struct usb_bus *bus, ··· 825 822 buf->bus = bus; 826 823 buf->fill_func = fill_func; 827 824 mutex_init(&buf->mutex); 825 + buf->alloc_size = PAGE_SIZE; 828 826 } 829 827 830 828 return buf; ··· 835 831 { 836 832 int ret = 0; 837 833 838 - if (!buf->page) 839 - buf->page = (char *)get_zeroed_page(GFP_KERNEL); 834 + if (!buf->output_buf) 835 + buf->output_buf = (char *)vmalloc(buf->alloc_size); 840 836 841 - if (!buf->page) { 837 + if (!buf->output_buf) { 842 838 ret = -ENOMEM; 843 839 goto out; 844 840 } ··· 871 867 mutex_unlock(&buf->mutex); 872 868 873 869 ret = simple_read_from_buffer(user_buf, len, offset, 874 - buf->page, buf->count); 870 + buf->output_buf, buf->count); 875 871 876 872 out: 877 873 return ret; ··· 883 879 struct debug_buffer *buf = file->private_data; 884 880 885 881 if (buf) { 886 - if (buf->page) 887 - free_page((unsigned long)buf->page); 882 + if (buf->output_buf) 883 + vfree(buf->output_buf); 888 884 kfree(buf); 889 885 } 890 886 ··· 899 895 900 896 static int debug_periodic_open(struct inode *inode, struct file *file) 901 897 { 902 - file->private_data = alloc_buffer(inode->i_private, 903 - fill_periodic_buffer); 898 + struct debug_buffer *buf; 899 + buf = alloc_buffer(inode->i_private, fill_periodic_buffer); 900 + if (!buf) 901 + return -ENOMEM; 904 902 905 - return file->private_data ? 0 : -ENOMEM; 903 + buf->alloc_size = (sizeof(void *) == 4 ? 6 : 8)*PAGE_SIZE; 904 + file->private_data = buf; 905 + return 0; 906 906 } 907 907 908 908 static int debug_registers_open(struct inode *inode, struct file *file)
+29 -19
drivers/usb/host/ehci-hcd.c
··· 24 24 #include <linux/ioport.h> 25 25 #include <linux/sched.h> 26 26 #include <linux/slab.h> 27 + #include <linux/vmalloc.h> 27 28 #include <linux/errno.h> 28 29 #include <linux/init.h> 29 30 #include <linux/timer.h> ··· 60 59 * providing early devices for those host controllers to talk to! 61 60 */ 62 61 63 - #define DRIVER_VERSION "10 Dec 2004" 64 62 #define DRIVER_AUTHOR "David Brownell" 65 63 #define DRIVER_DESC "USB 2.0 'Enhanced' Host Controller (EHCI) Driver" 66 64 ··· 620 620 621 621 temp = HC_VERSION(ehci_readl(ehci, &ehci->caps->hc_capbase)); 622 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 624 ((ehci->sbrn & 0xf0)>>4), (ehci->sbrn & 0x0f), 625 - temp >> 8, temp & 0xff, DRIVER_VERSION, 625 + temp >> 8, temp & 0xff, 626 626 ignore_oc ? ", overcurrent ignored" : ""); 627 627 628 628 ehci_writel(ehci, INTR_MASK, ··· 706 706 pcd_status = status; 707 707 708 708 /* resume root hub? */ 709 - if (!(ehci_readl(ehci, &ehci->regs->command) & CMD_RUN)) 709 + if (!(cmd & CMD_RUN)) 710 710 usb_hcd_resume_root_hub(hcd); 711 711 712 712 while (i--) { ··· 715 715 716 716 if (pstatus & PORT_OWNER) 717 717 continue; 718 - if (!(pstatus & PORT_RESUME) 719 - || ehci->reset_done [i] != 0) 718 + if (!(test_bit(i, &ehci->suspended_ports) && 719 + ((pstatus & PORT_RESUME) || 720 + !(pstatus & PORT_SUSPEND)) && 721 + (pstatus & PORT_PE) && 722 + ehci->reset_done[i] == 0)) 720 723 continue; 721 724 722 725 /* start 20 msec resume signaling from this port, ··· 734 731 735 732 /* PCI errors [4.15.2.4] */ 736 733 if (unlikely ((status & STS_FATAL) != 0)) { 737 - dbg_cmd (ehci, "fatal", ehci_readl(ehci, 738 - &ehci->regs->command)); 739 - dbg_status (ehci, "fatal", status); 734 + dbg_cmd(ehci, "fatal", cmd); 735 + dbg_status(ehci, "fatal", status); 740 736 if (status & STS_HALT) { 741 737 ehci_err (ehci, "fatal error\n"); 742 738 dead: ··· 996 994 997 995 /*-------------------------------------------------------------------------*/ 998 996 999 - #define DRIVER_INFO DRIVER_VERSION " " DRIVER_DESC 1000 - 1001 - MODULE_DESCRIPTION (DRIVER_INFO); 997 + MODULE_DESCRIPTION(DRIVER_DESC); 1002 998 MODULE_AUTHOR (DRIVER_AUTHOR); 1003 999 MODULE_LICENSE ("GPL"); 1004 1000 ··· 1018 1018 #ifdef CONFIG_PPC_PS3 1019 1019 #include "ehci-ps3.c" 1020 1020 #define PS3_SYSTEM_BUS_DRIVER ps3_ehci_driver 1021 - #endif 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 1021 #endif 1027 1022 1028 1023 #ifdef CONFIG_USB_EHCI_HCD_PPC_OF ··· 1044 1049 { 1045 1050 int retval = 0; 1046 1051 1052 + if (usb_disabled()) 1053 + return -ENODEV; 1054 + 1055 + printk(KERN_INFO "%s: " DRIVER_DESC "\n", hcd_name); 1056 + set_bit(USB_EHCI_LOADED, &usb_hcds_loaded); 1057 + if (test_bit(USB_UHCI_LOADED, &usb_hcds_loaded) || 1058 + test_bit(USB_OHCI_LOADED, &usb_hcds_loaded)) 1059 + printk(KERN_WARNING "Warning! ehci_hcd should always be loaded" 1060 + " before uhci_hcd and ohci_hcd, not after\n"); 1061 + 1047 1062 pr_debug("%s: block sizes: qh %Zd qtd %Zd itd %Zd sitd %Zd\n", 1048 1063 hcd_name, 1049 1064 sizeof(struct ehci_qh), sizeof(struct ehci_qtd), ··· 1061 1056 1062 1057 #ifdef DEBUG 1063 1058 ehci_debug_root = debugfs_create_dir("ehci", NULL); 1064 - if (!ehci_debug_root) 1065 - return -ENOENT; 1059 + if (!ehci_debug_root) { 1060 + retval = -ENOENT; 1061 + goto err_debug; 1062 + } 1066 1063 #endif 1067 1064 1068 1065 #ifdef PLATFORM_DRIVER ··· 1112 1105 debugfs_remove(ehci_debug_root); 1113 1106 ehci_debug_root = NULL; 1114 1107 #endif 1108 + err_debug: 1109 + clear_bit(USB_EHCI_LOADED, &usb_hcds_loaded); 1115 1110 return retval; 1116 1111 } 1117 1112 module_init(ehci_hcd_init); ··· 1135 1126 #ifdef DEBUG 1136 1127 debugfs_remove(ehci_debug_root); 1137 1128 #endif 1129 + clear_bit(USB_EHCI_LOADED, &usb_hcds_loaded); 1138 1130 } 1139 1131 module_exit(ehci_hcd_cleanup); 1140 1132
+19 -8
drivers/usb/host/ehci-hub.c
··· 236 236 temp = ehci_readl(ehci, &ehci->regs->port_status [i]); 237 237 temp &= ~(PORT_RWC_BITS | PORT_WAKE_BITS); 238 238 if (test_bit(i, &ehci->bus_suspended) && 239 - (temp & PORT_SUSPEND)) { 240 - ehci->reset_done [i] = jiffies + msecs_to_jiffies (20); 239 + (temp & PORT_SUSPEND)) 241 240 temp |= PORT_RESUME; 242 - } 243 241 ehci_writel(ehci, temp, &ehci->regs->port_status [i]); 244 242 } 245 243 i = HCS_N_PORTS (ehci->hcs_params); ··· 480 482 * controller by the user. 481 483 */ 482 484 483 - if ((temp & mask) != 0 484 - || ((temp & PORT_RESUME) != 0 485 - && time_after_eq(jiffies, 486 - ehci->reset_done[i]))) { 485 + if ((temp & mask) != 0 || test_bit(i, &ehci->port_c_suspend) 486 + || (ehci->reset_done[i] && time_after_eq( 487 + jiffies, ehci->reset_done[i]))) { 487 488 if (i < 7) 488 489 buf [0] |= 1 << (i + 1); 489 490 else ··· 685 688 /* resume completed? */ 686 689 else if (time_after_eq(jiffies, 687 690 ehci->reset_done[wIndex])) { 691 + clear_bit(wIndex, &ehci->suspended_ports); 688 692 set_bit(wIndex, &ehci->port_c_suspend); 689 693 ehci->reset_done[wIndex] = 0; 690 694 ··· 732 734 ehci_readl(ehci, status_reg)); 733 735 } 734 736 737 + if (!(temp & (PORT_RESUME|PORT_RESET))) 738 + ehci->reset_done[wIndex] = 0; 739 + 735 740 /* transfer dedicated ports to the companion hc */ 736 741 if ((temp & PORT_CONNECT) && 737 742 test_bit(wIndex, &ehci->companion_ports)) { ··· 758 757 } 759 758 if (temp & PORT_PE) 760 759 status |= 1 << USB_PORT_FEAT_ENABLE; 761 - if (temp & (PORT_SUSPEND|PORT_RESUME)) 760 + 761 + /* maybe the port was unsuspended without our knowledge */ 762 + if (temp & (PORT_SUSPEND|PORT_RESUME)) { 762 763 status |= 1 << USB_PORT_FEAT_SUSPEND; 764 + } else if (test_bit(wIndex, &ehci->suspended_ports)) { 765 + clear_bit(wIndex, &ehci->suspended_ports); 766 + ehci->reset_done[wIndex] = 0; 767 + if (temp & PORT_PE) 768 + set_bit(wIndex, &ehci->port_c_suspend); 769 + } 770 + 763 771 if (temp & PORT_OC) 764 772 status |= 1 << USB_PORT_FEAT_OVER_CURRENT; 765 773 if (temp & PORT_RESET) ··· 813 803 || (temp & PORT_RESET) != 0) 814 804 goto error; 815 805 ehci_writel(ehci, temp | PORT_SUSPEND, status_reg); 806 + set_bit(wIndex, &ehci->suspended_ports); 816 807 break; 817 808 case USB_PORT_FEAT_POWER: 818 809 if (HCS_PPC (ehci->hcs_params))
-201
drivers/usb/host/ehci-ppc-soc.c
··· 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 - };
+9 -14
drivers/usb/host/ehci.h
··· 99 99 owned by the companion during a bus suspend */ 100 100 unsigned long port_c_suspend; /* which ports have 101 101 the change-suspend feature turned on */ 102 + unsigned long suspended_ports; /* which ports are 103 + suspended */ 102 104 103 105 /* per-HC memory pools (could be per-bus, but ...) */ 104 106 struct dma_pool *qh_pool; /* qh per active urb */ ··· 183 181 * the async ring; just the I/O watchdog. Note that if a 184 182 * SHRINK were pending, OFF would never be requested. 185 183 */ 186 - if (timer_pending(&ehci->watchdog) 187 - && ((BIT(TIMER_ASYNC_SHRINK) | BIT(TIMER_ASYNC_OFF)) 188 - & ehci->actions)) 189 - return; 184 + enum ehci_timer_action oldactions = ehci->actions; 190 185 191 186 if (!test_and_set_bit (action, &ehci->actions)) { 192 187 unsigned long t; 188 + 189 + if (timer_pending(&ehci->watchdog) 190 + && ((BIT(TIMER_ASYNC_SHRINK) | BIT(TIMER_ASYNC_OFF)) 191 + & oldactions)) 192 + return; 193 193 194 194 switch (action) { 195 195 case TIMER_IO_WATCHDOG: ··· 208 204 t = DIV_ROUND_UP(EHCI_SHRINK_FRAMES * HZ, 1000) + 1; 209 205 break; 210 206 } 211 - mod_timer(&ehci->watchdog, t + jiffies); 207 + mod_timer(&ehci->watchdog, round_jiffies(t + jiffies)); 212 208 } 213 209 } 214 210 ··· 608 604 /* 609 605 * Big-endian read/write functions are arch-specific. 610 606 * Other arches can be added if/when they're needed. 611 - * 612 - * REVISIT: arch/powerpc now has readl/writel_be, so the 613 - * definition below can die once the 4xx support is 614 - * finally ported over. 615 607 */ 616 - #if defined(CONFIG_PPC) && !defined(CONFIG_PPC_MERGE) 617 - #define readl_be(addr) in_be32((__force unsigned *)addr) 618 - #define writel_be(val, addr) out_be32((__force unsigned *)addr, val) 619 - #endif 620 - 621 608 #if defined(CONFIG_ARM) && defined(CONFIG_ARCH_IXP4XX) 622 609 #define readl_be(addr) __raw_readl((__force unsigned *)addr) 623 610 #define writel_be(val, addr) __raw_writel(val, (__force unsigned *)addr)
+9 -4
drivers/usb/host/isp116x-hcd.c
··· 1562 1562 { 1563 1563 struct usb_hcd *hcd; 1564 1564 struct isp116x *isp116x; 1565 - struct resource *addr, *data; 1565 + struct resource *addr, *data, *ires; 1566 1566 void __iomem *addr_reg; 1567 1567 void __iomem *data_reg; 1568 1568 int irq; 1569 1569 int ret = 0; 1570 + unsigned long irqflags; 1570 1571 1571 1572 if (pdev->num_resources < 3) { 1572 1573 ret = -ENODEV; ··· 1576 1575 1577 1576 data = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1578 1577 addr = platform_get_resource(pdev, IORESOURCE_MEM, 1); 1579 - irq = platform_get_irq(pdev, 0); 1580 - if (!addr || !data || irq < 0) { 1578 + ires = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 1579 + 1580 + if (!addr || !data || !ires) { 1581 1581 ret = -ENODEV; 1582 1582 goto err1; 1583 1583 } 1584 + 1585 + irq = ires->start; 1586 + irqflags = ires->flags & IRQF_TRIGGER_MASK; 1584 1587 1585 1588 if (pdev->dev.dma_mask) { 1586 1589 DBG("DMA not supported\n"); ··· 1639 1634 goto err6; 1640 1635 } 1641 1636 1642 - ret = usb_add_hcd(hcd, irq, IRQF_DISABLED); 1637 + ret = usb_add_hcd(hcd, irq, irqflags | IRQF_DISABLED); 1643 1638 if (ret) 1644 1639 goto err6; 1645 1640
+4 -3
drivers/usb/host/isp1760-if.c
··· 218 218 * and reading back and checking the contents are same or not 219 219 */ 220 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 222 goto clean; 223 223 } 224 224 ··· 232 232 hcd = isp1760_register(pci_mem_phy0, length, dev->irq, 233 233 IRQF_SHARED | IRQF_DISABLED, &dev->dev, dev_name(&dev->dev), 234 234 devflags); 235 - pci_set_drvdata(dev, hcd); 236 - if (!hcd) 235 + if (!IS_ERR(hcd)) { 236 + pci_set_drvdata(dev, hcd); 237 237 return 0; 238 + } 238 239 clean: 239 240 status = -ENODEV; 240 241 iounmap(iobase);
+1 -1
drivers/usb/host/ohci-dbg.c
··· 649 649 ohci_dbg_sw (ohci, &next, &size, 650 650 "bus %s, device %s\n" 651 651 "%s\n" 652 - "%s version " DRIVER_VERSION "\n", 652 + "%s\n", 653 653 hcd->self.controller->bus->name, 654 654 dev_name(hcd->self.controller), 655 655 hcd->product_desc,
+5 -5
drivers/usb/host/ohci-hcd.c
··· 46 46 47 47 #include "../core/hcd.h" 48 48 49 - #define DRIVER_VERSION "2006 August 04" 50 49 #define DRIVER_AUTHOR "Roman Weissgaerber, David Brownell" 51 50 #define DRIVER_DESC "USB 1.1 'Open' Host Controller (OHCI) Driver" 52 51 ··· 983 984 984 985 /*-------------------------------------------------------------------------*/ 985 986 986 - #define DRIVER_INFO DRIVER_VERSION " " DRIVER_DESC 987 - 988 987 MODULE_AUTHOR (DRIVER_AUTHOR); 989 - MODULE_DESCRIPTION (DRIVER_INFO); 988 + MODULE_DESCRIPTION(DRIVER_DESC); 990 989 MODULE_LICENSE ("GPL"); 991 990 992 991 #ifdef CONFIG_PCI ··· 1092 1095 if (usb_disabled()) 1093 1096 return -ENODEV; 1094 1097 1095 - printk (KERN_DEBUG "%s: " DRIVER_INFO "\n", hcd_name); 1098 + printk(KERN_INFO "%s: " DRIVER_DESC "\n", hcd_name); 1096 1099 pr_debug ("%s: block sizes: ed %Zd td %Zd\n", hcd_name, 1097 1100 sizeof (struct ed), sizeof (struct td)); 1101 + set_bit(USB_OHCI_LOADED, &usb_hcds_loaded); 1098 1102 1099 1103 #ifdef DEBUG 1100 1104 ohci_debug_root = debugfs_create_dir("ohci", NULL); ··· 1182 1184 error_debug: 1183 1185 #endif 1184 1186 1187 + clear_bit(USB_OHCI_LOADED, &usb_hcds_loaded); 1185 1188 return retval; 1186 1189 } 1187 1190 module_init(ohci_hcd_mod_init); ··· 1213 1214 #ifdef DEBUG 1214 1215 debugfs_remove(ohci_debug_root); 1215 1216 #endif 1217 + clear_bit(USB_OHCI_LOADED, &usb_hcds_loaded); 1216 1218 } 1217 1219 module_exit(ohci_hcd_mod_exit); 1218 1220
+52 -35
drivers/usb/host/ohci-hub.c
··· 359 359 360 360 /* Carry out polling-, autostop-, and autoresume-related state changes */ 361 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 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 + * 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; 373 + 368 374 switch (ohci->hc_control & OHCI_CTRL_HCFS) { 369 - 370 375 case OHCI_USB_OPER: 371 - /* If no status changes are pending, enable status-change 372 - * interrupts. 373 - */ 374 - if (!rhsc && !changed) { 375 - rhsc = OHCI_INTR_RHSC; 376 - ohci_writel(ohci, rhsc, &ohci->regs->intrenable); 376 + /* If no status changes are pending, enable RHSC interrupts. */ 377 + if (!rhsc_enable && !rhsc_status && !changed) { 378 + rhsc_enable = OHCI_INTR_RHSC; 379 + ohci_writel(ohci, rhsc_enable, &ohci->regs->intrenable); 377 380 } 378 381 379 382 /* Keep on polling until we know a device is connected ··· 386 383 if (any_connected || 387 384 !device_may_wakeup(&ohci_to_hcd(ohci) 388 385 ->self.root_hub->dev)) { 389 - if (rhsc) 386 + if (rhsc_enable) 390 387 poll_rh = 0; 391 388 } else { 392 389 ohci->autostop = 1; ··· 399 396 ohci->autostop = 0; 400 397 ohci->next_statechange = jiffies + 401 398 STATECHANGE_DELAY; 402 - } else if (rhsc && time_after_eq(jiffies, 399 + } else if (time_after_eq(jiffies, 403 400 ohci->next_statechange) 404 401 && !ohci->ed_rm_list 405 402 && !(ohci->hc_control & 406 403 OHCI_SCHED_ENABLES)) { 407 404 ohci_rh_suspend(ohci, 1); 408 - poll_rh = 0; 405 + if (rhsc_enable) 406 + poll_rh = 0; 409 407 } 410 408 } 411 409 break; 412 410 413 - /* if there is a port change, autostart or ask to be resumed */ 414 411 case OHCI_USB_SUSPEND: 415 412 case OHCI_USB_RESUME: 413 + /* if there is a port change, autostart or ask to be resumed */ 416 414 if (changed) { 417 415 if (ohci->autostop) 418 416 ohci_rh_resume(ohci); 419 417 else 420 418 usb_hcd_resume_root_hub(ohci_to_hcd(ohci)); 421 - } else { 422 - if (!rhsc && (ohci->autostop || 423 - ohci_to_hcd(ohci)->self.root_hub-> 424 - do_remote_wakeup)) 425 - ohci_writel(ohci, OHCI_INTR_RHSC, 426 - &ohci->regs->intrenable); 427 419 428 - /* everything is idle, no need for polling */ 420 + /* If remote wakeup is disabled, stop polling */ 421 + } else if (!ohci->autostop && 422 + !ohci_to_hcd(ohci)->self.root_hub-> 423 + do_remote_wakeup) { 429 424 poll_rh = 0; 425 + 426 + } else { 427 + /* If no status changes are pending, 428 + * enable RHSC interrupts 429 + */ 430 + if (!rhsc_enable && !rhsc_status) { 431 + rhsc_enable = OHCI_INTR_RHSC; 432 + ohci_writel(ohci, rhsc_enable, 433 + &ohci->regs->intrenable); 434 + } 435 + /* Keep polling until RHSC is enabled */ 436 + if (rhsc_enable) 437 + poll_rh = 0; 430 438 } 431 439 break; 432 440 } ··· 455 441 * autostop isn't used when CONFIG_PM is turned off. 456 442 */ 457 443 static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed, 458 - int any_connected) 444 + int any_connected, int rhsc_status) 459 445 { 460 446 /* If RHSC is enabled, don't poll */ 461 447 if (ohci_readl(ohci, &ohci->regs->intrenable) & OHCI_INTR_RHSC) 462 448 return 0; 463 449 464 - /* If no status changes are pending, enable status-change interrupts */ 465 - if (!changed) { 466 - ohci_writel(ohci, OHCI_INTR_RHSC, &ohci->regs->intrenable); 467 - return 0; 468 - } 469 - return 1; 450 + /* If status changes are pending, continue polling. 451 + * Conversely, if no status changes are pending but the RHSC 452 + * status bit was set, then RHSC may be broken so continue polling. 453 + */ 454 + if (changed || rhsc_status) 455 + return 1; 456 + 457 + /* It's safe to re-enable RHSC interrupts */ 458 + ohci_writel(ohci, OHCI_INTR_RHSC, &ohci->regs->intrenable); 459 + return 0; 470 460 } 471 461 472 462 #endif /* CONFIG_PM */ ··· 485 467 struct ohci_hcd *ohci = hcd_to_ohci (hcd); 486 468 int i, changed = 0, length = 1; 487 469 int any_connected = 0; 470 + int rhsc_status; 488 471 unsigned long flags; 489 472 490 473 spin_lock_irqsave (&ohci->lock, flags); ··· 511 492 length++; 512 493 } 513 494 514 - /* Some broken controllers never turn off RHCS in the interrupt 515 - * status register. For their sake we won't re-enable RHSC 516 - * interrupts if the flag is already set. 517 - */ 518 - if (ohci_readl(ohci, &ohci->regs->intrstatus) & OHCI_INTR_RHSC) 519 - changed = 1; 495 + /* Clear the RHSC status flag before reading the port statuses */ 496 + ohci_writel(ohci, OHCI_INTR_RHSC, &ohci->regs->intrstatus); 497 + rhsc_status = ohci_readl(ohci, &ohci->regs->intrstatus) & 498 + OHCI_INTR_RHSC; 520 499 521 500 /* look at each port */ 522 501 for (i = 0; i < ohci->num_ports; i++) { ··· 534 517 } 535 518 536 519 hcd->poll_rh = ohci_root_hub_state_changes(ohci, changed, 537 - any_connected); 520 + any_connected, rhsc_status); 538 521 539 522 done: 540 523 spin_unlock_irqrestore (&ohci->lock, flags);
+2 -2
drivers/usb/host/ohci-omap.c
··· 231 231 232 232 omap_ohci_clock_power(1); 233 233 234 - if (cpu_is_omap1510()) { 234 + if (cpu_is_omap15xx()) { 235 235 omap_1510_local_bus_power(1); 236 236 omap_1510_local_bus_init(); 237 237 } ··· 319 319 if (IS_ERR(usb_host_ck)) 320 320 return PTR_ERR(usb_host_ck); 321 321 322 - if (!cpu_is_omap1510()) 322 + if (!cpu_is_omap15xx()) 323 323 usb_dc_ck = clk_get(0, "usb_dc_ck"); 324 324 else 325 325 usb_dc_ck = clk_get(0, "lb_ck");
+1 -1
drivers/usb/host/ohci-pnx4008.c
··· 331 331 332 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 335 if (usb_disabled()) { 336 336 err("USB is disabled"); 337 337 ret = -ENODEV;
-8
drivers/usb/host/ohci.h
··· 540 540 * Big-endian read/write functions are arch-specific. 541 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 544 static inline unsigned int _ohci_readl (const struct ohci_hcd *ohci, 553 545 __hc32 __iomem * regs) 554 546 {
+65 -36
drivers/usb/host/r8a66597-hcd.c
··· 66 66 module_param(endian, ushort, 0644); 67 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 70 module_param(irq_sense, ushort, 0644); 71 71 MODULE_PARM_DESC(irq_sense, "IRQ sense: low level=32, falling edge=0 " 72 72 "(default=32)"); ··· 118 118 r8a66597_write(r8a66597, SCKE, SYSCFG0); 119 119 tmp = r8a66597_read(r8a66597, SYSCFG0); 120 120 if (i++ > 1000) { 121 - err("register access fail."); 121 + printk(KERN_ERR "r8a66597: register access fail.\n"); 122 122 return -ENXIO; 123 123 } 124 124 } while ((tmp & SCKE) != SCKE); ··· 128 128 r8a66597_write(r8a66597, USBE, SYSCFG0); 129 129 tmp = r8a66597_read(r8a66597, SYSCFG0); 130 130 if (i++ > 1000) { 131 - err("register access fail."); 131 + printk(KERN_ERR "r8a66597: register access fail.\n"); 132 132 return -ENXIO; 133 133 } 134 134 } while ((tmp & USBE) != USBE); ··· 141 141 msleep(1); 142 142 tmp = r8a66597_read(r8a66597, SYSCFG0); 143 143 if (i++ > 500) { 144 - err("register access fail."); 144 + printk(KERN_ERR "r8a66597: register access fail.\n"); 145 145 return -ENXIO; 146 146 } 147 147 } while ((tmp & SCKE) != SCKE); ··· 265 265 if (root_port) { 266 266 *root_port = (devpath[0] & 0x0F) - 1; 267 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 270 if (hub_port) 271 271 *hub_port = devpath[2] & 0x0F; ··· 286 286 usbspd = HSMODE; 287 287 break; 288 288 default: 289 - err("unknown speed"); 289 + printk(KERN_ERR "r8a66597: unknown speed\n"); 290 290 break; 291 291 } 292 292 ··· 385 385 struct r8a66597_device *dev; 386 386 387 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 389 return 0; 390 390 } 391 391 ··· 406 406 return addr; 407 407 } 408 408 409 - err("cannot communicate with a USB device more than 10.(%x)", 410 - r8a66597->address_map); 409 + dev_err(&urb->dev->dev, 410 + "cannot communicate with a USB device more than 10.(%x)\n", 411 + r8a66597->address_map); 411 412 412 413 return 0; 413 414 } ··· 448 447 do { 449 448 tmp = r8a66597_read(r8a66597, reg); 450 449 if (i++ > 1000000) { 451 - err("register%lx, loop %x is timeout", reg, loop); 450 + printk(KERN_ERR "r8a66597: register%lx, loop %x " 451 + "is timeout\n", reg, loop); 452 452 break; 453 453 } 454 454 ndelay(1); ··· 677 675 array[i++] = 1; 678 676 break; 679 677 default: 680 - err("Illegal type"); 678 + printk(KERN_ERR "r8a66597: Illegal type\n"); 681 679 return 0; 682 680 } 683 681 ··· 707 705 r8a66597_type = R8A66597_ISO; 708 706 break; 709 707 default: 710 - err("Illegal type"); 708 + printk(KERN_ERR "r8a66597: Illegal type\n"); 711 709 r8a66597_type = 0x0000; 712 710 break; 713 711 } ··· 726 724 else if (check_interrupt(pipenum)) 727 725 bufnum = 4 + (pipenum - 6); 728 726 else 729 - err("Illegal pipenum (%d)", pipenum); 727 + printk(KERN_ERR "r8a66597: Illegal pipenum (%d)\n", pipenum); 730 728 731 729 return bufnum; 732 730 } ··· 742 740 else if (check_interrupt(pipenum)) 743 741 buf_bsize = 0; 744 742 else 745 - err("Illegal pipenum (%d)", pipenum); 743 + printk(KERN_ERR "r8a66597: Illegal pipenum (%d)\n", pipenum); 746 744 747 745 return buf_bsize; 748 746 } ··· 762 760 if ((r8a66597->dma_map & (1 << i)) != 0) 763 761 continue; 764 762 765 - info("address %d, EndpointAddress 0x%02x use DMA FIFO", 766 - usb_pipedevice(urb->pipe), 767 - info->dir_in ? USB_ENDPOINT_DIR_MASK + info->epnum 768 - : info->epnum); 763 + dev_info(&dev->udev->dev, 764 + "address %d, EndpointAddress 0x%02x use " 765 + "DMA FIFO\n", usb_pipedevice(urb->pipe), 766 + info->dir_in ? 767 + USB_ENDPOINT_DIR_MASK + info->epnum 768 + : info->epnum); 769 769 770 770 r8a66597->dma_map |= 1 << i; 771 771 dev->dma_map |= 1 << i; ··· 1191 1187 prepare_status_packet(r8a66597, td); 1192 1188 break; 1193 1189 default: 1194 - err("invalid type."); 1190 + printk(KERN_ERR "r8a66597: invalid type.\n"); 1195 1191 break; 1196 1192 } 1197 1193 ··· 1299 1295 if (unlikely((tmp & FRDY) == 0)) { 1300 1296 pipe_stop(r8a66597, td->pipe); 1301 1297 pipe_irq_disable(r8a66597, pipenum); 1302 - err("in fifo not ready (%d)", pipenum); 1298 + printk(KERN_ERR "r8a66597: in fifo not ready (%d)\n", pipenum); 1303 1299 finish_request(r8a66597, td, pipenum, td->urb, -EPIPE); 1304 1300 return; 1305 1301 } ··· 1374 1370 if (unlikely((tmp & FRDY) == 0)) { 1375 1371 pipe_stop(r8a66597, td->pipe); 1376 1372 pipe_irq_disable(r8a66597, pipenum); 1377 - err("out write fifo not ready. (%d)", pipenum); 1373 + printk(KERN_ERR "r8a66597: out fifo not ready (%d)\n", pipenum); 1378 1374 finish_request(r8a66597, td, pipenum, urb, -EPIPE); 1379 1375 return; 1380 1376 } ··· 2009 2005 return dev; 2010 2006 } 2011 2007 2012 - err("get_r8a66597_device fail.(%d)\n", addr); 2008 + printk(KERN_ERR "r8a66597: get_r8a66597_device fail.(%d)\n", addr); 2013 2009 return NULL; 2014 2010 } 2015 2011 ··· 2267 2263 #define resource_len(r) (((r)->end - (r)->start) + 1) 2268 2264 static int __init r8a66597_probe(struct platform_device *pdev) 2269 2265 { 2270 - struct resource *res = NULL; 2266 + struct resource *res = NULL, *ires; 2271 2267 int irq = -1; 2272 2268 void __iomem *reg = NULL; 2273 2269 struct usb_hcd *hcd = NULL; ··· 2278 2274 2279 2275 if (pdev->dev.dma_mask) { 2280 2276 ret = -EINVAL; 2281 - err("dma not support"); 2277 + dev_err(&pdev->dev, "dma not supported\n"); 2282 2278 goto clean_up; 2283 2279 } 2284 2280 ··· 2286 2282 (char *)hcd_name); 2287 2283 if (!res) { 2288 2284 ret = -ENODEV; 2289 - err("platform_get_resource_byname error."); 2285 + dev_err(&pdev->dev, "platform_get_resource_byname error.\n"); 2290 2286 goto clean_up; 2291 2287 } 2292 2288 2293 - irq = platform_get_irq(pdev, 0); 2294 - if (irq < 0) { 2289 + ires = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 2290 + if (!ires) { 2295 2291 ret = -ENODEV; 2296 - err("platform_get_irq error."); 2292 + dev_err(&pdev->dev, 2293 + "platform_get_resource IORESOURCE_IRQ error.\n"); 2297 2294 goto clean_up; 2298 2295 } 2296 + 2297 + irq = ires->start; 2298 + irq_trigger = ires->flags & IRQF_TRIGGER_MASK; 2299 2299 2300 2300 reg = ioremap(res->start, resource_len(res)); 2301 2301 if (reg == NULL) { 2302 2302 ret = -ENOMEM; 2303 - err("ioremap error."); 2303 + dev_err(&pdev->dev, "ioremap error.\n"); 2304 2304 goto clean_up; 2305 2305 } 2306 2306 ··· 2312 2304 hcd = usb_create_hcd(&r8a66597_hc_driver, &pdev->dev, (char *)hcd_name); 2313 2305 if (!hcd) { 2314 2306 ret = -ENOMEM; 2315 - err("Failed to create hcd"); 2307 + dev_err(&pdev->dev, "Failed to create hcd\n"); 2316 2308 goto clean_up; 2317 2309 } 2318 2310 r8a66597 = hcd_to_r8a66597(hcd); ··· 2337 2329 INIT_LIST_HEAD(&r8a66597->child_device); 2338 2330 2339 2331 hcd->rsrc_start = res->start; 2340 - if (irq_sense == INTL) 2341 - irq_trigger = IRQF_TRIGGER_LOW; 2342 - else 2343 - irq_trigger = IRQF_TRIGGER_FALLING; 2332 + 2333 + /* irq_sense setting on cmdline takes precedence over resource 2334 + * settings, so the introduction of irqflags in IRQ resourse 2335 + * won't disturb existing setups */ 2336 + switch (irq_sense) { 2337 + case INTL: 2338 + irq_trigger = IRQF_TRIGGER_LOW; 2339 + break; 2340 + case 0: 2341 + irq_trigger = IRQF_TRIGGER_FALLING; 2342 + break; 2343 + case 0xff: 2344 + if (irq_trigger) 2345 + irq_sense = (irq_trigger & IRQF_TRIGGER_LOW) ? 2346 + INTL : 0; 2347 + else { 2348 + irq_sense = INTL; 2349 + irq_trigger = IRQF_TRIGGER_LOW; 2350 + } 2351 + break; 2352 + default: 2353 + dev_err(&pdev->dev, "Unknown irq_sense value.\n"); 2354 + } 2355 + 2344 2356 ret = usb_add_hcd(hcd, irq, IRQF_DISABLED | irq_trigger); 2345 2357 if (ret != 0) { 2346 - err("Failed to add hcd"); 2358 + dev_err(&pdev->dev, "Failed to add hcd\n"); 2347 2359 goto clean_up; 2348 2360 } 2349 2361 ··· 2392 2364 if (usb_disabled()) 2393 2365 return -ENODEV; 2394 2366 2395 - info("driver %s, %s", hcd_name, DRIVER_VERSION); 2367 + printk(KERN_INFO KBUILD_MODNAME ": driver %s, %s\n", hcd_name, 2368 + DRIVER_VERSION); 2396 2369 return platform_driver_register(&r8a66597_driver); 2397 2370 } 2398 2371 module_init(r8a66597_init);
+11 -4
drivers/usb/host/sl811-hcd.c
··· 1620 1620 { 1621 1621 struct usb_hcd *hcd; 1622 1622 struct sl811 *sl811; 1623 - struct resource *addr, *data; 1623 + struct resource *addr, *data, *ires; 1624 1624 int irq; 1625 1625 void __iomem *addr_reg; 1626 1626 void __iomem *data_reg; 1627 1627 int retval; 1628 1628 u8 tmp, ioaddr = 0; 1629 + unsigned long irqflags; 1629 1630 1630 1631 /* basic sanity checks first. board-specific init logic should 1631 1632 * have initialized these three resources and probably board 1632 1633 * specific platform_data. we don't probe for IRQs, and do only 1633 1634 * minimal sanity checking. 1634 1635 */ 1635 - irq = platform_get_irq(dev, 0); 1636 - if (dev->num_resources < 3 || irq < 0) 1636 + ires = platform_get_resource(dev, IORESOURCE_IRQ, 0); 1637 + if (dev->num_resources < 3 || !ires) 1637 1638 return -ENODEV; 1639 + 1640 + irq = ires->start; 1641 + irqflags = ires->flags & IRQF_TRIGGER_MASK; 1638 1642 1639 1643 /* refuse to confuse usbcore */ 1640 1644 if (dev->dev.dma_mask) { ··· 1721 1717 * triggers (e.g. most ARM CPUs). Initial driver stress testing 1722 1718 * was on a system with single edge triggering, so most sorts of 1723 1719 * triggering arrangement should work. 1720 + * 1721 + * Use resource IRQ flags if set by platform device setup. 1724 1722 */ 1725 - retval = usb_add_hcd(hcd, irq, IRQF_DISABLED | IRQF_SHARED); 1723 + irqflags |= IRQF_SHARED; 1724 + retval = usb_add_hcd(hcd, irq, IRQF_DISABLED | irqflags); 1726 1725 if (retval != 0) 1727 1726 goto err6; 1728 1727
+6 -4
drivers/usb/host/uhci-hcd.c
··· 53 53 /* 54 54 * Version Information 55 55 */ 56 - #define DRIVER_VERSION "v3.0" 57 56 #define DRIVER_AUTHOR "Linus 'Frodo Rabbit' Torvalds, Johannes Erdfelt, \ 58 57 Randy Dunlap, Georg Acher, Deti Fliegl, Thomas Sailer, Roman Weissgaerber, \ 59 58 Alan Stern" ··· 950 951 { 951 952 int retval = -ENOMEM; 952 953 953 - printk(KERN_INFO DRIVER_DESC " " DRIVER_VERSION "%s\n", 954 - ignore_oc ? ", overcurrent ignored" : ""); 955 - 956 954 if (usb_disabled()) 957 955 return -ENODEV; 956 + 957 + printk(KERN_INFO "uhci_hcd: " DRIVER_DESC "%s\n", 958 + ignore_oc ? ", overcurrent ignored" : ""); 959 + set_bit(USB_UHCI_LOADED, &usb_hcds_loaded); 958 960 959 961 if (DEBUG_CONFIGURED) { 960 962 errbuf = kmalloc(ERRBUF_LEN, GFP_KERNEL); ··· 988 988 989 989 errbuf_failed: 990 990 991 + clear_bit(USB_UHCI_LOADED, &usb_hcds_loaded); 991 992 return retval; 992 993 } 993 994 ··· 998 997 kmem_cache_destroy(uhci_up_cachep); 999 998 debugfs_remove(uhci_debugfs_root); 1000 999 kfree(errbuf); 1000 + clear_bit(USB_UHCI_LOADED, &usb_hcds_loaded); 1001 1001 } 1002 1002 1003 1003 module_init(uhci_hcd_init);
+11 -6
drivers/usb/host/uhci-q.c
··· 1065 1065 } 1066 1066 if (exponent < 0) 1067 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 1072 - * of the QH lists. */ 1073 - qh->phase = (qh->period / 2) & (MAX_PHASE - 1); 1074 - ret = uhci_check_bandwidth(uhci, qh); 1069 + /* If the slot is full, try a lower period */ 1070 + do { 1071 + qh->period = 1 << exponent; 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 1080 if (ret) 1076 1081 return ret; 1077 1082 } else if (qh->period > urb->interval)
+39 -22
drivers/usb/image/mdc800.c
··· 355 355 if (mdc800->camera_request_ready>0) 356 356 { 357 357 mdc800->camera_request_ready=0; 358 - err ("timeout waiting for camera."); 358 + dev_err(&mdc800->dev->dev, "timeout waiting for camera.\n"); 359 359 return -1; 360 360 } 361 361 362 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 366 mdc800->camera_request_ready=0; 366 367 return -2; 367 368 } ··· 380 379 int status = urb->status; 381 380 382 381 if (status != 0) 383 - err ("writing command fails (status=%i)", status); 382 + dev_err(&mdc800->dev->dev, 383 + "writing command fails (status=%i)\n", status); 384 384 else 385 385 mdc800->state=READY; 386 386 mdc800->written = 1; ··· 408 406 mdc800->state=READY; 409 407 } 410 408 } else { 411 - err ("request bytes fails (status:%i)", status); 409 + dev_err(&mdc800->dev->dev, 410 + "request bytes fails (status:%i)\n", status); 412 411 } 413 412 mdc800->downloaded = 1; 414 413 wake_up (&mdc800->download_wait); ··· 446 443 447 444 if (mdc800->dev != NULL) 448 445 { 449 - warn ("only one Mustek MDC800 is supported."); 446 + dev_warn(&intf->dev, "only one Mustek MDC800 is supported.\n"); 450 447 return -ENODEV; 451 448 } 452 449 453 450 if (dev->descriptor.bNumConfigurations != 1) 454 451 { 455 - err ("probe fails -> wrong Number of Configuration"); 452 + dev_err(&intf->dev, 453 + "probe fails -> wrong Number of Configuration\n"); 456 454 return -ENODEV; 457 455 } 458 456 intf_desc = intf->cur_altsetting; ··· 465 461 || ( intf_desc->desc.bNumEndpoints != 4) 466 462 ) 467 463 { 468 - err ("probe fails -> wrong Interface"); 464 + dev_err(&intf->dev, "probe fails -> wrong Interface\n"); 469 465 return -ENODEV; 470 466 } 471 467 ··· 486 482 } 487 483 if (mdc800->endpoint[i] == -1) 488 484 { 489 - err ("probe fails -> Wrong Endpoints."); 485 + dev_err(&intf->dev, "probe fails -> Wrong Endpoints.\n"); 490 486 return -ENODEV; 491 487 } 492 488 } 493 489 494 490 495 - info ("Found Mustek MDC800 on USB."); 491 + dev_info(&intf->dev, "Found Mustek MDC800 on USB.\n"); 496 492 497 493 mutex_lock(&mdc800->io_lock); 498 494 499 495 retval = usb_register_dev(intf, &mdc800_class); 500 496 if (retval) { 501 - err ("Not able to get a minor for this device."); 497 + dev_err(&intf->dev, "Not able to get a minor for this device.\n"); 502 498 return -ENODEV; 503 499 } 504 500 ··· 574 570 mdc800->dev = NULL; 575 571 usb_set_intfdata(intf, NULL); 576 572 } 577 - info ("Mustek MDC800 disconnected from USB."); 573 + dev_info(&intf->dev, "Mustek MDC800 disconnected from USB.\n"); 578 574 } 579 575 580 576 ··· 648 644 mdc800->irq_urb->dev = mdc800->dev; 649 645 retval = usb_submit_urb (mdc800->irq_urb, GFP_KERNEL); 650 646 if (retval) { 651 - err ("request USB irq fails (submit_retval=%i).", retval); 647 + dev_err(&mdc800->dev->dev, 648 + "request USB irq fails (submit_retval=%i).\n", retval); 652 649 errn = -EIO; 653 650 goto error_out; 654 651 } ··· 706 701 } 707 702 if (mdc800->state == WORKING) 708 703 { 709 - warn ("Illegal State \"working\" reached during read ?!"); 704 + printk(KERN_WARNING "mdc800: Illegal State \"working\"" 705 + "reached during read ?!\n"); 710 706 mutex_unlock(&mdc800->io_lock); 711 707 return -EBUSY; 712 708 } ··· 739 733 mdc800->download_urb->dev = mdc800->dev; 740 734 retval = usb_submit_urb (mdc800->download_urb, GFP_KERNEL); 741 735 if (retval) { 742 - err ("Can't submit download urb (retval=%i)",retval); 736 + dev_err(&mdc800->dev->dev, 737 + "Can't submit download urb " 738 + "(retval=%i)\n", retval); 743 739 mutex_unlock(&mdc800->io_lock); 744 740 return len-left; 745 741 } ··· 750 742 mdc800->downloaded = 0; 751 743 if (mdc800->download_urb->status != 0) 752 744 { 753 - err ("request download-bytes fails (status=%i)",mdc800->download_urb->status); 745 + dev_err(&mdc800->dev->dev, 746 + "request download-bytes fails " 747 + "(status=%i)\n", 748 + mdc800->download_urb->status); 754 749 mutex_unlock(&mdc800->io_lock); 755 750 return len-left; 756 751 } ··· 850 839 851 840 if (mdc800_usb_waitForIRQ (0,TO_GET_READY)) 852 841 { 853 - err ("Camera didn't get ready.\n"); 842 + dev_err(&mdc800->dev->dev, 843 + "Camera didn't get ready.\n"); 854 844 mutex_unlock(&mdc800->io_lock); 855 845 return -EIO; 856 846 } ··· 863 851 mdc800->write_urb->dev = mdc800->dev; 864 852 retval = usb_submit_urb (mdc800->write_urb, GFP_KERNEL); 865 853 if (retval) { 866 - err ("submitting write urb fails (retval=%i)", retval); 854 + dev_err(&mdc800->dev->dev, 855 + "submitting write urb fails " 856 + "(retval=%i)\n", retval); 867 857 mutex_unlock(&mdc800->io_lock); 868 858 return -EIO; 869 859 } ··· 884 870 case 0x3e: /* Take shot in Fine Mode (WCam Mode) */ 885 871 if (mdc800->pic_len < 0) 886 872 { 887 - err ("call 0x07 before 0x05,0x3e"); 873 + dev_err(&mdc800->dev->dev, 874 + "call 0x07 before " 875 + "0x05,0x3e\n"); 888 876 mdc800->state=READY; 889 877 mutex_unlock(&mdc800->io_lock); 890 878 return -EIO; ··· 906 890 907 891 if (mdc800_usb_waitForIRQ (1,TO_READ_FROM_IRQ)) 908 892 { 909 - err ("requesting answer from irq fails"); 893 + dev_err(&mdc800->dev->dev, "requesting answer from irq fails\n"); 910 894 mutex_unlock(&mdc800->io_lock); 911 895 return -EIO; 912 896 } ··· 934 918 { 935 919 if (mdc800_usb_waitForIRQ (0,TO_DEFAULT_COMMAND)) 936 920 { 937 - err ("Command Timeout."); 921 + dev_err(&mdc800->dev->dev, "Command Timeout.\n"); 938 922 mutex_unlock(&mdc800->io_lock); 939 923 return -EIO; 940 924 } ··· 1034 1018 if (retval) 1035 1019 goto cleanup_on_fail; 1036 1020 1037 - info (DRIVER_VERSION ":" DRIVER_DESC); 1021 + printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" 1022 + DRIVER_DESC "\n"); 1038 1023 1039 1024 return 0; 1040 1025 ··· 1045 1028 1046 1029 if (mdc800 != NULL) 1047 1030 { 1048 - err ("can't alloc memory!"); 1031 + printk(KERN_ERR "mdc800: can't alloc memory!\n"); 1049 1032 1050 1033 kfree(mdc800->download_urb_buffer); 1051 1034 kfree(mdc800->write_urb_buffer);
+24
drivers/usb/misc/Kconfig
··· 42 42 To compile this driver as a module, choose M here. The module 43 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 54 config USB_RIO500 46 55 tristate "USB Diamond Rio500 support" 47 56 depends on USB ··· 280 271 The firmware for this driver must be extracted from the MacOS 281 272 driver beforehand. Tools for doing so are available at 282 273 http://bersace03.free.fr 274 + 275 + config USB_VST 276 + tristate "USB VST driver" 277 + depends on USB 278 + help 279 + This driver is intended for Vernier Software Technologies 280 + bulk usb devices such as their Ocean-Optics spectrometers or 281 + Labquest. 282 + It is a bulk channel driver with configurable read and write 283 + timeouts. 284 + 285 + To compile this driver as a module, choose M here: the 286 + module will be called vstusb. 287 + 288 +
+2
drivers/usb/misc/Makefile
··· 26 26 obj-$(CONFIG_USB_TEST) += usbtest.o 27 27 obj-$(CONFIG_USB_TRANCEVIBRATOR) += trancevibrator.o 28 28 obj-$(CONFIG_USB_USS720) += uss720.o 29 + obj-$(CONFIG_USB_SEVSEG) += usbsevseg.o 30 + obj-$(CONFIG_USB_VST) += vstusb.o 29 31 30 32 obj-$(CONFIG_USB_SISUSBVGA) += sisusbvga/ 31 33
+13 -9
drivers/usb/misc/adutux.c
··· 283 283 284 284 interface = usb_find_interface(&adu_driver, subminor); 285 285 if (!interface) { 286 - err("%s - error, can't find device for minor %d", 287 - __func__, subminor); 286 + printk(KERN_ERR "adutux: %s - error, can't find device for " 287 + "minor %d\n", __func__, subminor); 288 288 retval = -ENODEV; 289 289 goto exit_no_device; 290 290 } ··· 416 416 /* verify that the device wasn't unplugged */ 417 417 if (dev->udev == NULL) { 418 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 421 goto exit; 421 422 } 422 423 ··· 577 576 /* verify that the device wasn't unplugged */ 578 577 if (dev->udev == NULL) { 579 578 retval = -ENODEV; 580 - err("No device or device unplugged %d", retval); 579 + printk(KERN_ERR "adutux: No device or device unplugged %d\n", 580 + retval); 581 581 goto exit; 582 582 } 583 583 ··· 647 645 retval = usb_submit_urb(dev->interrupt_out_urb, GFP_KERNEL); 648 646 if (retval < 0) { 649 647 dev->out_urb_finished = 1; 650 - err("Couldn't submit interrupt_out_urb %d", retval); 648 + dev_err(&dev->udev->dev, "Couldn't submit " 649 + "interrupt_out_urb %d\n", retval); 651 650 goto exit; 652 651 } 653 652 ··· 893 890 /* register this driver with the USB subsystem */ 894 891 result = usb_register(&adu_driver); 895 892 if (result < 0) { 896 - err("usb_register failed for the "__FILE__" driver. " 897 - "Error number %d", result); 893 + printk(KERN_ERR "usb_register failed for the "__FILE__ 894 + " driver. Error number %d\n", result); 898 895 goto exit; 899 896 } 900 897 901 - info("adutux " DRIVER_DESC " " DRIVER_VERSION); 902 - info("adutux is an experimental driver. Use at your own risk"); 898 + printk(KERN_INFO "adutux " DRIVER_DESC " " DRIVER_VERSION "\n"); 899 + printk(KERN_INFO "adutux is an experimental driver. " 900 + "Use at your own risk\n"); 903 901 904 902 exit: 905 903 dbg(2," %s : leave, return value %d", __func__, result);
+14 -12
drivers/usb/misc/appledisplay.c
··· 130 130 exit: 131 131 retval = usb_submit_urb(pdata->urb, GFP_ATOMIC); 132 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 135 __func__, retval); 135 136 } 136 137 } ··· 221 220 } 222 221 } 223 222 if (!int_in_endpointAddr) { 224 - err("Could not find int-in endpoint"); 223 + dev_err(&iface->dev, "Could not find int-in endpoint\n"); 225 224 return -EIO; 226 225 } 227 226 ··· 229 228 pdata = kzalloc(sizeof(struct appledisplay), GFP_KERNEL); 230 229 if (!pdata) { 231 230 retval = -ENOMEM; 232 - err("Out of memory"); 231 + dev_err(&iface->dev, "Out of memory\n"); 233 232 goto error; 234 233 } 235 234 ··· 242 241 pdata->msgdata = kmalloc(ACD_MSG_BUFFER_LEN, GFP_KERNEL); 243 242 if (!pdata->msgdata) { 244 243 retval = -ENOMEM; 245 - err("appledisplay: Allocating buffer for control messages " 246 - "failed"); 244 + dev_err(&iface->dev, 245 + "Allocating buffer for control messages failed\n"); 247 246 goto error; 248 247 } 249 248 ··· 251 250 pdata->urb = usb_alloc_urb(0, GFP_KERNEL); 252 251 if (!pdata->urb) { 253 252 retval = -ENOMEM; 254 - err("appledisplay: Allocating URB failed"); 253 + dev_err(&iface->dev, "Allocating URB failed\n"); 255 254 goto error; 256 255 } 257 256 ··· 260 259 GFP_KERNEL, &pdata->urb->transfer_dma); 261 260 if (!pdata->urbdata) { 262 261 retval = -ENOMEM; 263 - err("appledisplay: Allocating URB buffer failed"); 262 + dev_err(&iface->dev, "Allocating URB buffer failed\n"); 264 263 goto error; 265 264 } 266 265 ··· 271 270 pdata, 1); 272 271 if (usb_submit_urb(pdata->urb, GFP_KERNEL)) { 273 272 retval = -EIO; 274 - err("appledisplay: Submitting URB failed"); 273 + dev_err(&iface->dev, "Submitting URB failed\n"); 275 274 goto error; 276 275 } 277 276 ··· 281 280 pdata->bd = backlight_device_register(bl_name, NULL, pdata, 282 281 &appledisplay_bl_data); 283 282 if (IS_ERR(pdata->bd)) { 284 - err("appledisplay: Backlight registration failed"); 283 + dev_err(&iface->dev, "Backlight registration failed\n"); 285 284 goto error; 286 285 } 287 286 ··· 292 291 293 292 if (brightness < 0) { 294 293 retval = brightness; 295 - err("appledisplay: Error while getting initial brightness: %d", retval); 294 + dev_err(&iface->dev, 295 + "Error while getting initial brightness: %d\n", retval); 296 296 goto error; 297 297 } 298 298 ··· 316 314 pdata->urbdata, pdata->urb->transfer_dma); 317 315 usb_free_urb(pdata->urb); 318 316 } 319 - if (pdata->bd) 317 + if (pdata->bd && !IS_ERR(pdata->bd)) 320 318 backlight_device_unregister(pdata->bd); 321 319 kfree(pdata->msgdata); 322 320 } ··· 354 352 { 355 353 wq = create_singlethread_workqueue("appledisplay"); 356 354 if (!wq) { 357 - err("Could not create work queue\n"); 355 + printk(KERN_ERR "appledisplay: Could not create work queue\n"); 358 356 return -ENOMEM; 359 357 } 360 358
+3 -3
drivers/usb/misc/cypress_cy7c63.c
··· 278 278 279 279 /* register this driver with the USB subsystem */ 280 280 result = usb_register(&cypress_driver); 281 - if (result) { 282 - err("Function usb_register failed! Error number: %d\n", result); 283 - } 281 + if (result) 282 + printk(KERN_ERR KBUILD_MODNAME ": usb_register failed! " 283 + "Error number: %d\n", result); 284 284 285 285 return result; 286 286 }
+5 -4
drivers/usb/misc/cytherm.c
··· 422 422 int result; 423 423 424 424 result = usb_register(&cytherm_driver); 425 - if (result) 426 - { 427 - err("usb_register failed. Error number %d", result); 425 + if (result) { 426 + printk(KERN_ERR KBUILD_MODNAME ": usb_register failed! " 427 + "Error number: %d\n", result); 428 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 433 return 0; 433 434 } 434 435
+10 -7
drivers/usb/misc/emi26.c
··· 50 50 unsigned char *buffer = kmemdup(data, length, GFP_KERNEL); 51 51 52 52 if (!buffer) { 53 - err("emi26: kmalloc(%d) failed.", length); 53 + dev_err(&dev->dev, "kmalloc(%d) failed.\n", length); 54 54 return -ENOMEM; 55 55 } 56 56 /* Note: usb_control_msg returns negative value on error or length of the ··· 64 64 static int emi26_set_reset (struct usb_device *dev, unsigned char reset_bit) 65 65 { 66 66 int response; 67 - info("%s - %d", __func__, reset_bit); 67 + dev_info(&dev->dev, "%s - %d\n", __func__, reset_bit); 68 68 /* printk(KERN_DEBUG "%s - %d", __func__, reset_bit); */ 69 69 response = emi26_writememory (dev, CPUCS_REG, &reset_bit, 1, 0xa0); 70 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 73 return response; 74 74 } ··· 88 88 89 89 buf = kmalloc(FW_LOAD_SIZE, GFP_KERNEL); 90 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 93 err = -ENOMEM; 93 94 goto wraperr; 94 95 } ··· 107 106 &dev->dev); 108 107 if (err) { 109 108 nofw: 110 - err( "%s - request_firmware() failed", __func__); 109 + dev_err(&dev->dev, "%s - request_firmware() failed\n", 110 + __func__); 111 111 goto wraperr; 112 112 } 113 113 114 114 /* Assert reset (stop the CPU in the EMI) */ 115 115 err = emi26_set_reset(dev,1); 116 116 if (err < 0) { 117 - err( "%s - error loading firmware: error = %d", __func__, err); 117 + dev_err(&dev->dev,"%s - error loading firmware: error = %d\n", 118 + __func__, err); 118 119 goto wraperr; 119 120 } 120 121 ··· 257 254 { 258 255 struct usb_device *dev = interface_to_usbdev(intf); 259 256 260 - info("%s start", __func__); 257 + dev_info(&intf->dev, "%s start\n", __func__); 261 258 262 259 emi26_load_firmware(dev); 263 260
+2 -2
drivers/usb/misc/emi62.c
··· 73 73 static int emi62_set_reset (struct usb_device *dev, unsigned char reset_bit) 74 74 { 75 75 int response; 76 - info("%s - %d", __func__, reset_bit); 76 + dev_info(&dev->dev, "%s - %d\n", __func__, reset_bit); 77 77 78 78 response = emi62_writememory (dev, CPUCS_REG, &reset_bit, 1, 0xa0); 79 79 if (response < 0) { ··· 271 271 struct usb_device *dev = interface_to_usbdev(intf); 272 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 276 emi62_load_firmware(dev); 277 277
+5 -5
drivers/usb/misc/ftdi-elan.c
··· 698 698 int retval = usb_bulk_msg(ftdi->udev, 699 699 usb_rcvbulkpipe(ftdi->udev, ftdi->bulk_in_endpointAddr), 700 700 ftdi->bulk_in_buffer, ftdi->bulk_in_size, 701 - &packet_bytes, msecs_to_jiffies(50)); 701 + &packet_bytes, 50); 702 702 if (packet_bytes > 2) { 703 703 ftdi->bulk_in_left = packet_bytes - 2; 704 704 ftdi->bulk_in_last = 1; ··· 960 960 int retval = usb_bulk_msg(ftdi->udev, 961 961 usb_rcvbulkpipe(ftdi->udev, ftdi->bulk_in_endpointAddr), 962 962 ftdi->bulk_in_buffer, ftdi->bulk_in_size, 963 - &packet_bytes, msecs_to_jiffies(500)); 963 + &packet_bytes, 500); 964 964 char diag[30 *3 + 4]; 965 965 char *d = diag; 966 966 int m = packet_bytes; ··· 1880 1880 int retval = usb_bulk_msg(ftdi->udev, 1881 1881 usb_rcvbulkpipe(ftdi->udev, ftdi->bulk_in_endpointAddr), 1882 1882 ftdi->bulk_in_buffer, ftdi->bulk_in_size, 1883 - &packet_bytes, msecs_to_jiffies(100)); 1883 + &packet_bytes, 100); 1884 1884 if (packet_bytes > 2) { 1885 1885 char diag[30 *3 + 4]; 1886 1886 char *d = diag; ··· 2067 2067 usb_rcvbulkpipe(ftdi->udev, 2068 2068 ftdi->bulk_in_endpointAddr), 2069 2069 ftdi->bulk_in_buffer, ftdi->bulk_in_size, 2070 - &packet_bytes, msecs_to_jiffies(500)); 2070 + &packet_bytes, 500); 2071 2071 if (packet_bytes > 2) { 2072 2072 char diag[30 *3 + 4]; 2073 2073 char *d = diag; ··· 2176 2176 int retval = usb_bulk_msg(ftdi->udev, 2177 2177 usb_rcvbulkpipe(ftdi->udev, ftdi->bulk_in_endpointAddr), 2178 2178 ftdi->bulk_in_buffer, ftdi->bulk_in_size, 2179 - &packet_bytes, msecs_to_jiffies(1000)); 2179 + &packet_bytes, 1000); 2180 2180 if (packet_bytes > 2) { 2181 2181 char diag[30 *3 + 4]; 2182 2182 char *d = diag;
+3 -2
drivers/usb/misc/idmouse.c
··· 403 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 409 static int __init usb_idmouse_init(void) 410 410 { 411 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 416 /* register this driver with the USB subsystem */ 416 417 result = usb_register(&idmouse_driver);
+13 -10
drivers/usb/misc/legousbtower.c
··· 851 851 852 852 dbg(2, "%s: enter", __func__); 853 853 854 - if (udev == NULL) { 855 - info ("udev is NULL."); 856 - } 854 + if (udev == NULL) 855 + dev_info(&interface->dev, "udev is NULL.\n"); 857 856 858 857 /* allocate memory for our device state and initialize it */ 859 858 ··· 953 954 dev->minor = interface->minor; 954 955 955 956 /* let the user know what node this device is now attached to */ 956 - info ("LEGO USB Tower #%d now attached to major %d minor %d", (dev->minor - LEGO_USB_TOWER_MINOR_BASE), USB_MAJOR, dev->minor); 957 + dev_info(&interface->dev, "LEGO USB Tower #%d now attached to major " 958 + "%d minor %d\n", (dev->minor - LEGO_USB_TOWER_MINOR_BASE), 959 + USB_MAJOR, dev->minor); 957 960 958 961 /* get the firmware version and log it */ 959 962 result = usb_control_msg (udev, ··· 972 971 retval = result; 973 972 goto error; 974 973 } 975 - info("LEGO USB Tower firmware version is %d.%d build %d", 976 - get_version_reply.major, 977 - get_version_reply.minor, 978 - le16_to_cpu(get_version_reply.build_no)); 974 + dev_info(&interface->dev, "LEGO USB Tower firmware version is %d.%d " 975 + "build %d\n", get_version_reply.major, 976 + get_version_reply.minor, 977 + le16_to_cpu(get_version_reply.build_no)); 979 978 980 979 981 980 exit: ··· 1022 1021 mutex_unlock(&dev->lock); 1023 1022 } 1024 1023 1025 - info("LEGO USB Tower #%d now disconnected", (minor - LEGO_USB_TOWER_MINOR_BASE)); 1024 + dev_info(&interface->dev, "LEGO USB Tower #%d now disconnected\n", 1025 + (minor - LEGO_USB_TOWER_MINOR_BASE)); 1026 1026 1027 1027 dbg(2, "%s: leave", __func__); 1028 1028 } ··· 1048 1046 goto exit; 1049 1047 } 1050 1048 1051 - info(DRIVER_DESC " " DRIVER_VERSION); 1049 + printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" 1050 + DRIVER_DESC "\n"); 1052 1051 1053 1052 exit: 1054 1053 dbg(2, "%s: leave, return value %d", __func__, retval);
+6 -5
drivers/usb/misc/rio500.c
··· 89 89 90 90 mutex_unlock(&(rio->lock)); 91 91 92 - info("Rio opened."); 92 + dev_info(&rio->rio_dev->dev, "Rio opened.\n"); 93 93 94 94 return 0; 95 95 } ··· 100 100 101 101 rio->isopen = 0; 102 102 103 - info("Rio closed."); 103 + dev_info(&rio->rio_dev->dev, "Rio closed.\n"); 104 104 return 0; 105 105 } 106 106 ··· 451 451 struct rio_usb_data *rio = &rio_instance; 452 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 456 retval = usb_register_dev(intf, &usb_rio_class); 457 457 if (retval) { ··· 503 503 kfree(rio->ibuf); 504 504 kfree(rio->obuf); 505 505 506 - info("USB Rio disconnected."); 506 + dev_info(&intf->dev, "USB Rio disconnected.\n"); 507 507 508 508 rio->present = 0; 509 509 mutex_unlock(&(rio->lock)); ··· 531 531 if (retval) 532 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 537 out: 537 538 return retval;
+2 -1
drivers/usb/misc/trancevibrator.c
··· 144 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 149 return 0; 149 150 } 150 151
+7 -6
drivers/usb/misc/usblcd.c
··· 311 311 dev->interface = interface; 312 312 313 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 315 return -ENODEV; 316 316 } 317 317 ··· 359 359 360 360 i = le16_to_cpu(dev->udev->descriptor.bcdDevice); 361 361 362 - info("USBLCD Version %1d%1d.%1d%1d found at address %d", 363 - (i & 0xF000)>>12,(i & 0xF00)>>8,(i & 0xF0)>>4,(i & 0xF), 364 - dev->udev->devnum); 362 + dev_info(&interface->dev, "USBLCD Version %1d%1d.%1d%1d found " 363 + "at address %d\n", (i & 0xF000)>>12, (i & 0xF00)>>8, 364 + (i & 0xF0)>>4,(i & 0xF), dev->udev->devnum); 365 365 366 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 369 return 0; 369 370 370 371 error: ··· 414 413 /* decrement our usage count */ 415 414 kref_put(&dev->kref, lcd_delete); 416 415 417 - info("USB LCD #%d now disconnected", minor); 416 + dev_info(&interface->dev, "USB LCD #%d now disconnected\n", minor); 418 417 } 419 418 420 419 static struct usb_driver lcd_driver = {
+394
drivers/usb/misc/usbsevseg.c
··· 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");
+12 -7
drivers/usb/misc/uss720.c
··· 228 228 ret = rq->urb->status; 229 229 *val = priv->reg[(reg >= 9) ? 0 : regindex[reg]]; 230 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 233 kref_put(&rq->ref_count, destroy_async); 233 234 return ret; 234 235 } 235 - warn("get_1284_register timeout"); 236 + printk(KERN_WARNING "get_1284_register timeout\n"); 236 237 kill_all_async_requests_priv(priv); 237 238 return -EIO; 238 239 } ··· 717 716 spin_lock_init(&priv->asynclock); 718 717 INIT_LIST_HEAD(&priv->asynclist); 719 718 if (!(pp = parport_register_port(0, PARPORT_IRQ_NONE, PARPORT_DMA_NONE, &parport_uss720_ops))) { 720 - warn("could not register parport"); 719 + printk(KERN_WARNING "uss720: could not register parport\n"); 721 720 goto probe_abort; 722 721 } 723 722 ··· 801 800 if (retval) 802 801 goto out; 803 802 804 - info(DRIVER_VERSION ":" DRIVER_DESC); 805 - info("NOTE: this is a special purpose driver to allow nonstandard"); 806 - info("protocols (eg. bitbang) over USS720 usb to parallel cables"); 807 - info("If you just want to connect to a printer, use usblp instead"); 803 + printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" 804 + DRIVER_DESC "\n"); 805 + printk(KERN_INFO KBUILD_MODNAME ": NOTE: this is a special purpose " 806 + "driver to allow nonstandard\n"); 807 + printk(KERN_INFO KBUILD_MODNAME ": protocols (eg. bitbang) over " 808 + "USS720 usb to parallel cables\n"); 809 + printk(KERN_INFO KBUILD_MODNAME ": If you just want to connect to a " 810 + "printer, use usblp instead\n"); 808 811 out: 809 812 return retval; 810 813 }
+782
drivers/usb/misc/vstusb.c
··· 1 + /***************************************************************************** 2 + * File: drivers/usb/misc/vstusb.c 3 + * 4 + * Purpose: Support for the bulk USB Vernier Spectrophotometers 5 + * 6 + * Author: Johnnie Peters 7 + * Axian Consulting 8 + * Beaverton, OR, USA 97005 9 + * 10 + * Modified by: EQware Engineering, Inc. 11 + * Oregon City, OR, USA 97045 12 + * 13 + * Copyright: 2007, 2008 14 + * Vernier Software & Technology 15 + * Beaverton, OR, USA 97005 16 + * 17 + * Web: www.vernier.com 18 + * 19 + * This program is free software; you can redistribute it and/or modify 20 + * it under the terms of the GNU General Public License version 2 as 21 + * published by the Free Software Foundation. 22 + * 23 + *****************************************************************************/ 24 + #include <linux/kernel.h> 25 + #include <linux/errno.h> 26 + #include <linux/init.h> 27 + #include <linux/slab.h> 28 + #include <linux/module.h> 29 + #include <linux/mutex.h> 30 + #include <linux/uaccess.h> 31 + #include <linux/usb.h> 32 + 33 + #include <linux/usb/vstusb.h> 34 + 35 + #define DRIVER_VERSION "VST USB Driver Version 1.5" 36 + #define DRIVER_DESC "Vernier Software Technology Bulk USB Driver" 37 + 38 + #ifdef CONFIG_USB_DYNAMIC_MINORS 39 + #define VSTUSB_MINOR_BASE 0 40 + #else 41 + #define VSTUSB_MINOR_BASE 199 42 + #endif 43 + 44 + #define USB_VENDOR_OCEANOPTICS 0x2457 45 + #define USB_VENDOR_VERNIER 0x08F7 /* Vernier Software & Technology */ 46 + 47 + #define USB_PRODUCT_USB2000 0x1002 48 + #define USB_PRODUCT_ADC1000_FW 0x1003 /* firmware download (renumerates) */ 49 + #define USB_PRODUCT_ADC1000 0x1004 50 + #define USB_PRODUCT_HR2000_FW 0x1009 /* firmware download (renumerates) */ 51 + #define USB_PRODUCT_HR2000 0x100A 52 + #define USB_PRODUCT_HR4000_FW 0x1011 /* firmware download (renumerates) */ 53 + #define USB_PRODUCT_HR4000 0x1012 54 + #define USB_PRODUCT_USB650 0x1014 /* "Red Tide" */ 55 + #define USB_PRODUCT_QE65000 0x1018 56 + #define USB_PRODUCT_USB4000 0x1022 57 + #define USB_PRODUCT_USB325 0x1024 /* "Vernier Spectrometer" */ 58 + 59 + #define USB_PRODUCT_LABPRO 0x0001 60 + #define USB_PRODUCT_LABQUEST 0x0005 61 + 62 + #define VST_MAXBUFFER (64*1024) 63 + 64 + static struct usb_device_id id_table[] = { 65 + { USB_DEVICE(USB_VENDOR_OCEANOPTICS, USB_PRODUCT_USB2000)}, 66 + { USB_DEVICE(USB_VENDOR_OCEANOPTICS, USB_PRODUCT_HR4000)}, 67 + { USB_DEVICE(USB_VENDOR_OCEANOPTICS, USB_PRODUCT_USB650)}, 68 + { USB_DEVICE(USB_VENDOR_OCEANOPTICS, USB_PRODUCT_USB4000)}, 69 + { USB_DEVICE(USB_VENDOR_OCEANOPTICS, USB_PRODUCT_USB325)}, 70 + { USB_DEVICE(USB_VENDOR_VERNIER, USB_PRODUCT_LABQUEST)}, 71 + { USB_DEVICE(USB_VENDOR_VERNIER, USB_PRODUCT_LABPRO)}, 72 + {}, 73 + }; 74 + 75 + MODULE_DEVICE_TABLE(usb, id_table); 76 + 77 + struct vstusb_device { 78 + struct kref kref; 79 + struct mutex lock; 80 + struct usb_device *usb_dev; 81 + char present; 82 + char isopen; 83 + struct usb_anchor submitted; 84 + int rd_pipe; 85 + int rd_timeout_ms; 86 + int wr_pipe; 87 + int wr_timeout_ms; 88 + }; 89 + #define to_vst_dev(d) container_of(d, struct vstusb_device, kref) 90 + 91 + static struct usb_driver vstusb_driver; 92 + 93 + static void vstusb_delete(struct kref *kref) 94 + { 95 + struct vstusb_device *vstdev = to_vst_dev(kref); 96 + 97 + usb_put_dev(vstdev->usb_dev); 98 + kfree(vstdev); 99 + } 100 + 101 + static int vstusb_open(struct inode *inode, struct file *file) 102 + { 103 + struct vstusb_device *vstdev; 104 + struct usb_interface *interface; 105 + 106 + interface = usb_find_interface(&vstusb_driver, iminor(inode)); 107 + 108 + if (!interface) { 109 + printk(KERN_ERR KBUILD_MODNAME 110 + ": %s - error, can't find device for minor %d\n", 111 + __func__, iminor(inode)); 112 + return -ENODEV; 113 + } 114 + 115 + vstdev = usb_get_intfdata(interface); 116 + 117 + if (!vstdev) 118 + return -ENODEV; 119 + 120 + /* lock this device */ 121 + mutex_lock(&vstdev->lock); 122 + 123 + /* can only open one time */ 124 + if ((!vstdev->present) || (vstdev->isopen)) { 125 + mutex_unlock(&vstdev->lock); 126 + return -EBUSY; 127 + } 128 + 129 + /* increment our usage count */ 130 + kref_get(&vstdev->kref); 131 + 132 + vstdev->isopen = 1; 133 + 134 + /* save device in the file's private structure */ 135 + file->private_data = vstdev; 136 + 137 + dev_dbg(&vstdev->usb_dev->dev, "%s: opened\n", __func__); 138 + 139 + mutex_unlock(&vstdev->lock); 140 + 141 + return 0; 142 + } 143 + 144 + static int vstusb_release(struct inode *inode, struct file *file) 145 + { 146 + struct vstusb_device *vstdev; 147 + 148 + vstdev = file->private_data; 149 + 150 + if (vstdev == NULL) 151 + return -ENODEV; 152 + 153 + mutex_lock(&vstdev->lock); 154 + 155 + vstdev->isopen = 0; 156 + 157 + dev_dbg(&vstdev->usb_dev->dev, "%s: released\n", __func__); 158 + 159 + mutex_unlock(&vstdev->lock); 160 + 161 + kref_put(&vstdev->kref, vstusb_delete); 162 + 163 + return 0; 164 + } 165 + 166 + static void usb_api_blocking_completion(struct urb *urb) 167 + { 168 + struct completion *completeit = urb->context; 169 + 170 + complete(completeit); 171 + } 172 + 173 + static int vstusb_fill_and_send_urb(struct urb *urb, 174 + struct usb_device *usb_dev, 175 + unsigned int pipe, void *data, 176 + unsigned int len, struct completion *done) 177 + { 178 + struct usb_host_endpoint *ep; 179 + struct usb_host_endpoint **hostep; 180 + unsigned int pipend; 181 + 182 + int status; 183 + 184 + hostep = usb_pipein(pipe) ? usb_dev->ep_in : usb_dev->ep_out; 185 + pipend = usb_pipeendpoint(pipe); 186 + ep = hostep[pipend]; 187 + 188 + if (!ep || (len == 0)) 189 + return -EINVAL; 190 + 191 + if ((ep->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) 192 + == USB_ENDPOINT_XFER_INT) { 193 + pipe = (pipe & ~(3 << 30)) | (PIPE_INTERRUPT << 30); 194 + usb_fill_int_urb(urb, usb_dev, pipe, data, len, 195 + (usb_complete_t)usb_api_blocking_completion, 196 + NULL, ep->desc.bInterval); 197 + } else 198 + usb_fill_bulk_urb(urb, usb_dev, pipe, data, len, 199 + (usb_complete_t)usb_api_blocking_completion, 200 + NULL); 201 + 202 + init_completion(done); 203 + urb->context = done; 204 + urb->actual_length = 0; 205 + status = usb_submit_urb(urb, GFP_KERNEL); 206 + 207 + return status; 208 + } 209 + 210 + static int vstusb_complete_urb(struct urb *urb, struct completion *done, 211 + int timeout, int *actual_length) 212 + { 213 + unsigned long expire; 214 + int status; 215 + 216 + expire = timeout ? msecs_to_jiffies(timeout) : MAX_SCHEDULE_TIMEOUT; 217 + if (!wait_for_completion_interruptible_timeout(done, expire)) { 218 + usb_kill_urb(urb); 219 + status = urb->status == -ENOENT ? -ETIMEDOUT : urb->status; 220 + 221 + dev_dbg(&urb->dev->dev, 222 + "%s timed out on ep%d%s len=%d/%d, urb status = %d\n", 223 + current->comm, 224 + usb_pipeendpoint(urb->pipe), 225 + usb_pipein(urb->pipe) ? "in" : "out", 226 + urb->actual_length, 227 + urb->transfer_buffer_length, 228 + urb->status); 229 + 230 + } else { 231 + if (signal_pending(current)) { 232 + /* if really an error */ 233 + if (urb->status && !((urb->status == -ENOENT) || 234 + (urb->status == -ECONNRESET) || 235 + (urb->status == -ESHUTDOWN))) { 236 + status = -EINTR; 237 + usb_kill_urb(urb); 238 + } else { 239 + status = 0; 240 + } 241 + 242 + dev_dbg(&urb->dev->dev, 243 + "%s: signal pending on ep%d%s len=%d/%d," 244 + "urb status = %d\n", 245 + current->comm, 246 + usb_pipeendpoint(urb->pipe), 247 + usb_pipein(urb->pipe) ? "in" : "out", 248 + urb->actual_length, 249 + urb->transfer_buffer_length, 250 + urb->status); 251 + 252 + } else { 253 + status = urb->status; 254 + } 255 + } 256 + 257 + if (actual_length) 258 + *actual_length = urb->actual_length; 259 + 260 + return status; 261 + } 262 + 263 + static ssize_t vstusb_read(struct file *file, char __user *buffer, 264 + size_t count, loff_t *ppos) 265 + { 266 + struct vstusb_device *vstdev; 267 + int cnt = -1; 268 + void *buf; 269 + int retval = 0; 270 + 271 + struct urb *urb; 272 + struct usb_device *dev; 273 + unsigned int pipe; 274 + int timeout; 275 + 276 + DECLARE_COMPLETION_ONSTACK(done); 277 + 278 + vstdev = file->private_data; 279 + 280 + if (vstdev == NULL) 281 + return -ENODEV; 282 + 283 + /* verify that we actually want to read some data */ 284 + if ((count == 0) || (count > VST_MAXBUFFER)) 285 + return -EINVAL; 286 + 287 + /* lock this object */ 288 + if (mutex_lock_interruptible(&vstdev->lock)) 289 + return -ERESTARTSYS; 290 + 291 + /* anyone home */ 292 + if (!vstdev->present) { 293 + mutex_unlock(&vstdev->lock); 294 + printk(KERN_ERR KBUILD_MODNAME 295 + ": %s: device not present\n", __func__); 296 + return -ENODEV; 297 + } 298 + 299 + /* pull out the necessary data */ 300 + dev = vstdev->usb_dev; 301 + pipe = usb_rcvbulkpipe(dev, vstdev->rd_pipe); 302 + timeout = vstdev->rd_timeout_ms; 303 + 304 + buf = kmalloc(count, GFP_KERNEL); 305 + if (buf == NULL) { 306 + mutex_unlock(&vstdev->lock); 307 + return -ENOMEM; 308 + } 309 + 310 + urb = usb_alloc_urb(0, GFP_KERNEL); 311 + if (!urb) { 312 + kfree(buf); 313 + mutex_unlock(&vstdev->lock); 314 + return -ENOMEM; 315 + } 316 + 317 + usb_anchor_urb(urb, &vstdev->submitted); 318 + retval = vstusb_fill_and_send_urb(urb, dev, pipe, buf, count, &done); 319 + mutex_unlock(&vstdev->lock); 320 + if (retval) { 321 + usb_unanchor_urb(urb); 322 + dev_err(&dev->dev, "%s: error %d filling and sending urb %d\n", 323 + __func__, retval, pipe); 324 + goto exit; 325 + } 326 + 327 + retval = vstusb_complete_urb(urb, &done, timeout, &cnt); 328 + if (retval) { 329 + dev_err(&dev->dev, "%s: error %d completing urb %d\n", 330 + __func__, retval, pipe); 331 + goto exit; 332 + } 333 + 334 + if (copy_to_user(buffer, buf, cnt)) { 335 + dev_err(&dev->dev, "%s: can't copy_to_user\n", __func__); 336 + retval = -EFAULT; 337 + } else { 338 + retval = cnt; 339 + dev_dbg(&dev->dev, "%s: read %d bytes from pipe %d\n", 340 + __func__, cnt, pipe); 341 + } 342 + 343 + exit: 344 + usb_free_urb(urb); 345 + kfree(buf); 346 + return retval; 347 + } 348 + 349 + static ssize_t vstusb_write(struct file *file, const char __user *buffer, 350 + size_t count, loff_t *ppos) 351 + { 352 + struct vstusb_device *vstdev; 353 + int cnt = -1; 354 + void *buf; 355 + int retval = 0; 356 + 357 + struct urb *urb; 358 + struct usb_device *dev; 359 + unsigned int pipe; 360 + int timeout; 361 + 362 + DECLARE_COMPLETION_ONSTACK(done); 363 + 364 + vstdev = file->private_data; 365 + 366 + if (vstdev == NULL) 367 + return -ENODEV; 368 + 369 + /* verify that we actually have some data to write */ 370 + if ((count == 0) || (count > VST_MAXBUFFER)) 371 + return retval; 372 + 373 + /* lock this object */ 374 + if (mutex_lock_interruptible(&vstdev->lock)) 375 + return -ERESTARTSYS; 376 + 377 + /* anyone home */ 378 + if (!vstdev->present) { 379 + mutex_unlock(&vstdev->lock); 380 + printk(KERN_ERR KBUILD_MODNAME 381 + ": %s: device not present\n", __func__); 382 + return -ENODEV; 383 + } 384 + 385 + /* pull out the necessary data */ 386 + dev = vstdev->usb_dev; 387 + pipe = usb_sndbulkpipe(dev, vstdev->wr_pipe); 388 + timeout = vstdev->wr_timeout_ms; 389 + 390 + buf = kmalloc(count, GFP_KERNEL); 391 + if (buf == NULL) { 392 + mutex_unlock(&vstdev->lock); 393 + return -ENOMEM; 394 + } 395 + 396 + urb = usb_alloc_urb(0, GFP_KERNEL); 397 + if (!urb) { 398 + kfree(buf); 399 + mutex_unlock(&vstdev->lock); 400 + return -ENOMEM; 401 + } 402 + 403 + if (copy_from_user(buf, buffer, count)) { 404 + 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");
+1 -1
drivers/usb/mon/mon_main.c
··· 361 361 } 362 362 // MOD_INC_USE_COUNT(which_module?); 363 363 364 - usb_register_notify(&mon_nb); 365 364 366 365 mutex_lock(&usb_bus_list_lock); 367 366 list_for_each_entry (ubus, &usb_bus_list, bus_list) { 368 367 mon_bus_init(ubus); 369 368 } 369 + usb_register_notify(&mon_nb); 370 370 mutex_unlock(&usb_bus_list_lock); 371 371 return 0; 372 372
-4
drivers/usb/musb/Kconfig
··· 33 33 default y if ARCH_DAVINCI 34 34 default y if ARCH_OMAP2430 35 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 37 comment "DaVinci 644x USB support" 42 38 depends on USB_MUSB_HDRC && ARCH_DAVINCI
+2 -2
drivers/usb/musb/cppi_dma.h
··· 119 119 void __iomem *mregs; /* Mentor regs */ 120 120 void __iomem *tibase; /* TI/CPPI regs */ 121 121 122 - struct cppi_channel tx[MUSB_C_NUM_EPT - 1]; 123 - struct cppi_channel rx[MUSB_C_NUM_EPR - 1]; 122 + struct cppi_channel tx[4]; 123 + struct cppi_channel rx[4]; 124 124 125 125 struct dma_pool *pool; 126 126
+4 -16
drivers/usb/musb/davinci.c
··· 30 30 #include <linux/delay.h> 31 31 #include <linux/clk.h> 32 32 #include <linux/io.h> 33 + #include <linux/gpio.h> 33 34 34 35 #include <asm/arch/hardware.h> 35 36 #include <asm/arch/memory.h> ··· 40 39 #include "musb_core.h" 41 40 42 41 #ifdef CONFIG_MACH_DAVINCI_EVM 43 - #include <asm/arch/i2c-client.h> 42 + #define GPIO_nVBUS_DRV 87 44 43 #endif 45 44 46 45 #include "davinci.h" ··· 139 138 /* VBUS SWITCHING IS BOARD-SPECIFIC */ 140 139 141 140 #ifdef CONFIG_MACH_DAVINCI_EVM 142 - #ifndef CONFIG_MACH_DAVINCI_EVM_OTG 143 141 144 142 /* I2C operations are always synchronous, and require a task context. 145 143 * With unloaded systems, using the shared workqueue seems to suffice ··· 146 146 */ 147 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 150 vbus_state = !vbus_state; 151 151 } 152 152 static DECLARE_WORK(evm_vbus_work, evm_deferred_drvvbus); 153 153 154 - #endif /* modified board */ 155 154 #endif /* EVM */ 156 155 157 156 static void davinci_source_power(struct musb *musb, int is_on, int immediate) ··· 164 165 165 166 #ifdef CONFIG_MACH_DAVINCI_EVM 166 167 if (machine_is_davinci_evm()) { 167 - #ifdef CONFIG_MACH_DAVINCI_EVM_OTG 168 - /* modified EVM board switching VBUS with GPIO(6) not I2C 169 - * NOTE: PINMUX0.RGB888 (bit23) must be clear 170 - */ 171 - if (is_on) 172 - gpio_set(GPIO(6)); 173 - else 174 - gpio_clear(GPIO(6)); 175 - immediate = 1; 176 - #else 177 168 if (immediate) 178 - davinci_i2c_expander_op(0x3a, USB_DRVVBUS, !is_on); 169 + gpio_set_value_cansleep(GPIO_nVBUS_DRV, vbus_state); 179 170 else 180 171 schedule_work(&evm_vbus_work); 181 - #endif 182 172 } 183 173 #endif 184 174 if (immediate)
+27 -16
drivers/usb/musb/musb_core.c
··· 82 82 /* 83 83 * This gets many kinds of configuration information: 84 84 * - Kconfig for everything user-configurable 85 - * - <asm/arch/hdrc_cnf.h> for SOC or family details 86 85 * - platform_device for addressing, irq, and platform_data 87 86 * - platform_data is mostly for board-specific informarion 87 + * (plus recentrly, SOC or family details) 88 88 * 89 89 * Most of the conditional compilation will (someday) vanish. 90 90 */ ··· 974 974 /* 975 975 * The silicon either has hard-wired endpoint configurations, or else 976 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 978 - * idioms to so both modes are compile-tested, but dead code elimination 979 - * leaves only the relevant one in the object file. 977 + * writing only the dynamic sizing is very well tested. Since we switched 978 + * away from compile-time hardware parameters, we can no longer rely on 979 + * dead code elimination to leave only the relevant one in the object file. 980 980 * 981 981 * We don't currently use dynamic fifo setup capability to do anything 982 982 * more than selecting one of a bunch of predefined configurations. ··· 1806 1806 musb->ctrl_base = mbase; 1807 1807 musb->nIrq = -ENODEV; 1808 1808 musb->config = config; 1809 + BUG_ON(musb->config->num_eps > MUSB_C_NUM_EPS); 1809 1810 for (epnum = 0, ep = musb->endpoints; 1810 1811 epnum < musb->config->num_eps; 1811 1812 epnum++, ep++) { ··· 2055 2054 2056 2055 } 2057 2056 2058 - return 0; 2059 - 2060 - fail: 2061 - if (musb->clock) 2062 - clk_put(musb->clock); 2063 - device_init_wakeup(dev, 0); 2064 - musb_free(musb); 2065 - return status; 2066 - 2067 2057 #ifdef CONFIG_SYSFS 2068 2058 status = device_create_file(dev, &dev_attr_mode); 2069 2059 status = device_create_file(dev, &dev_attr_vbus); ··· 2063 2071 #endif /* CONFIG_USB_GADGET_MUSB_HDRC */ 2064 2072 status = 0; 2065 2073 #endif 2074 + if (status) 2075 + goto fail2; 2076 + 2077 + return 0; 2078 + 2079 + fail2: 2080 + #ifdef CONFIG_SYSFS 2081 + device_remove_file(musb->controller, &dev_attr_mode); 2082 + device_remove_file(musb->controller, &dev_attr_vbus); 2083 + #ifdef CONFIG_USB_MUSB_OTG 2084 + device_remove_file(musb->controller, &dev_attr_srp); 2085 + #endif 2086 + #endif 2087 + musb_platform_exit(musb); 2088 + fail: 2089 + dev_err(musb->controller, 2090 + "musb_init_controller failed with status %d\n", status); 2091 + 2092 + if (musb->clock) 2093 + clk_put(musb->clock); 2094 + device_init_wakeup(dev, 0); 2095 + musb_free(musb); 2066 2096 2067 2097 return status; 2068 2098 2069 - fail2: 2070 - musb_platform_exit(musb); 2071 - goto fail; 2072 2099 } 2073 2100 2074 2101 /*-------------------------------------------------------------------------*/
+12 -12
drivers/usb/musb/musb_gadget_ep0.c
··· 437 437 { 438 438 void __iomem *regs = musb->control_ep->regs; 439 439 struct usb_request *req; 440 - u16 tmp; 440 + u16 count, csr; 441 441 442 442 req = next_ep0_request(musb); 443 443 ··· 449 449 unsigned len = req->length - req->actual; 450 450 451 451 /* read the buffer */ 452 - tmp = musb_readb(regs, MUSB_COUNT0); 453 - if (tmp > len) { 452 + count = musb_readb(regs, MUSB_COUNT0); 453 + if (count > len) { 454 454 req->status = -EOVERFLOW; 455 - tmp = len; 455 + count = len; 456 456 } 457 - musb_read_fifo(&musb->endpoints[0], tmp, buf); 458 - req->actual += tmp; 459 - tmp = MUSB_CSR0_P_SVDRXPKTRDY; 460 - if (tmp < 64 || req->actual == req->length) { 457 + musb_read_fifo(&musb->endpoints[0], count, buf); 458 + req->actual += count; 459 + csr = MUSB_CSR0_P_SVDRXPKTRDY; 460 + if (count < 64 || req->actual == req->length) { 461 461 musb->ep0_state = MUSB_EP0_STAGE_STATUSIN; 462 - tmp |= MUSB_CSR0_P_DATAEND; 462 + csr |= MUSB_CSR0_P_DATAEND; 463 463 } else 464 464 req = NULL; 465 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 469 /* Completion handler may choose to stall, e.g. because the 470 470 * message just received holds invalid data. 471 471 */ 472 472 if (req) { 473 - musb->ackpend = tmp; 473 + musb->ackpend = csr; 474 474 musb_g_ep0_giveback(musb, req); 475 475 if (!musb->ackpend) 476 476 return; 477 477 musb->ackpend = 0; 478 478 } 479 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 /*
+13 -6
drivers/usb/musb/musb_host.c
··· 108 108 /* 109 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 113 void __iomem *epio = ep->regs; 114 114 u16 csr; ··· 291 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 295 spin_unlock(&musb->lock); 295 296 usb_hcd_giveback_urb(musb_to_hcd(musb), urb, status); 296 297 spin_lock(&musb->lock); ··· 353 352 status = -EXDEV; 354 353 break; 355 354 } 356 - 357 - usb_hcd_unlink_urb_from_ep(musb_to_hcd(musb), urb); 358 355 359 356 qh->is_ready = 0; 360 357 __musb_giveback(musb, urb, status); ··· 435 436 } 436 437 } 437 438 438 - static inline u16 musb_h_flush_rxfifo(struct musb_hw_ep *hw_ep, u16 csr) 439 + static u16 musb_h_flush_rxfifo(struct musb_hw_ep *hw_ep, u16 csr) 439 440 { 440 441 /* we don't want fifo to fill itself again; 441 442 * ignore dma (various models), ··· 1004 1005 1005 1006 /* 1006 1007 * Handle default endpoint interrupt as host. Only called in IRQ time 1007 - * from the LinuxIsr() interrupt service routine. 1008 + * from musb_interrupt(). 1008 1009 * 1009 1010 * called with controller irqlocked 1010 1011 */ ··· 1790 1791 */ 1791 1792 qh = kzalloc(sizeof *qh, mem_flags); 1792 1793 if (!qh) { 1794 + spin_lock_irqsave(&musb->lock, flags); 1793 1795 usb_hcd_unlink_urb_from_ep(hcd, urb); 1796 + spin_unlock_irqrestore(&musb->lock, flags); 1794 1797 return -ENOMEM; 1795 1798 } 1796 1799 ··· 1874 1873 /* set up tt info if needed */ 1875 1874 if (urb->dev->tt) { 1876 1875 qh->h_port_reg = (u8) urb->dev->ttport; 1877 - qh->h_addr_reg |= 0x80; 1876 + if (urb->dev->tt->hub) 1877 + qh->h_addr_reg = 1878 + (u8) urb->dev->tt->hub->devnum; 1879 + if (urb->dev->tt->multi) 1880 + qh->h_addr_reg |= 0x80; 1878 1881 } 1879 1882 } 1880 1883 } ··· 1908 1903 1909 1904 done: 1910 1905 if (ret != 0) { 1906 + spin_lock_irqsave(&musb->lock, flags); 1911 1907 usb_hcd_unlink_urb_from_ep(hcd, urb); 1908 + spin_unlock_irqrestore(&musb->lock, flags); 1912 1909 kfree(qh); 1913 1910 } 1914 1911 return ret;
+3 -1
drivers/usb/musb/musb_io.h
··· 37 37 38 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 43 static inline void readsl(const void __iomem *addr, void *buf, int len) 42 44 { insl((unsigned long)addr, buf, len); } 43 45 static inline void readsw(const void __iomem *addr, void *buf, int len)
+154 -150
drivers/usb/musb/musbhsdma.c
··· 45 45 #define MUSB_HSDMA_ADDRESS 0x8 46 46 #define MUSB_HSDMA_COUNT 0xc 47 47 48 - #define MUSB_HSDMA_CHANNEL_OFFSET(_bChannel, _offset) \ 49 - (MUSB_HSDMA_BASE + (_bChannel << 4) + _offset) 48 + #define MUSB_HSDMA_CHANNEL_OFFSET(_bchannel, _offset) \ 49 + (MUSB_HSDMA_BASE + (_bchannel << 4) + _offset) 50 50 51 51 /* control register (16-bit): */ 52 52 #define MUSB_HSDMA_ENABLE_SHIFT 0 ··· 67 67 struct musb_dma_controller; 68 68 69 69 struct musb_dma_channel { 70 - struct dma_channel Channel; 70 + struct dma_channel channel; 71 71 struct musb_dma_controller *controller; 72 - u32 dwStartAddress; 72 + u32 start_addr; 73 73 u32 len; 74 - u16 wMaxPacketSize; 75 - u8 bIndex; 74 + u16 max_packet_sz; 75 + u8 idx; 76 76 u8 epnum; 77 77 u8 transmit; 78 78 }; 79 79 80 80 struct musb_dma_controller { 81 - struct dma_controller Controller; 82 - struct musb_dma_channel aChannel[MUSB_HSDMA_CHANNELS]; 83 - void *pDmaPrivate; 84 - void __iomem *pCoreBase; 85 - u8 bChannelCount; 86 - u8 bmUsedChannels; 81 + struct dma_controller controller; 82 + struct musb_dma_channel channel[MUSB_HSDMA_CHANNELS]; 83 + void *private_data; 84 + void __iomem *base; 85 + u8 channel_count; 86 + u8 used_channels; 87 87 u8 irq; 88 88 }; 89 89 ··· 93 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 98 static int dma_controller_stop(struct dma_controller *c) 99 99 { 100 - struct musb_dma_controller *controller = 101 - container_of(c, struct musb_dma_controller, Controller); 102 - struct musb *musb = (struct musb *) controller->pDmaPrivate; 103 - struct dma_channel *pChannel; 104 - u8 bBit; 100 + struct musb_dma_controller *controller = container_of(c, 101 + struct musb_dma_controller, controller); 102 + struct musb *musb = controller->private_data; 103 + struct dma_channel *channel; 104 + u8 bit; 105 105 106 - if (controller->bmUsedChannels != 0) { 106 + if (controller->used_channels != 0) { 107 107 dev_err(musb->controller, 108 108 "Stopping DMA controller while channel active\n"); 109 109 110 - for (bBit = 0; bBit < MUSB_HSDMA_CHANNELS; bBit++) { 111 - if (controller->bmUsedChannels & (1 << bBit)) { 112 - pChannel = &controller->aChannel[bBit].Channel; 113 - dma_channel_release(pChannel); 110 + for (bit = 0; bit < MUSB_HSDMA_CHANNELS; bit++) { 111 + if (controller->used_channels & (1 << bit)) { 112 + channel = &controller->channel[bit].channel; 113 + dma_channel_release(channel); 114 114 115 - if (!controller->bmUsedChannels) 115 + if (!controller->used_channels) 116 116 break; 117 117 } 118 118 } 119 119 } 120 + 120 121 return 0; 121 122 } 122 123 123 124 static struct dma_channel *dma_channel_allocate(struct dma_controller *c, 124 125 struct musb_hw_ep *hw_ep, u8 transmit) 125 126 { 126 - u8 bBit; 127 - struct dma_channel *pChannel = NULL; 128 - struct musb_dma_channel *pImplChannel = NULL; 129 - struct musb_dma_controller *controller = 130 - container_of(c, struct musb_dma_controller, Controller); 127 + struct musb_dma_controller *controller = container_of(c, 128 + struct musb_dma_controller, controller); 129 + struct musb_dma_channel *musb_channel = NULL; 130 + struct dma_channel *channel = NULL; 131 + u8 bit; 131 132 132 - for (bBit = 0; bBit < MUSB_HSDMA_CHANNELS; bBit++) { 133 - if (!(controller->bmUsedChannels & (1 << bBit))) { 134 - controller->bmUsedChannels |= (1 << bBit); 135 - pImplChannel = &(controller->aChannel[bBit]); 136 - pImplChannel->controller = controller; 137 - pImplChannel->bIndex = bBit; 138 - pImplChannel->epnum = hw_ep->epnum; 139 - pImplChannel->transmit = transmit; 140 - pChannel = &(pImplChannel->Channel); 141 - pChannel->private_data = pImplChannel; 142 - pChannel->status = MUSB_DMA_STATUS_FREE; 143 - pChannel->max_len = 0x10000; 133 + for (bit = 0; bit < MUSB_HSDMA_CHANNELS; bit++) { 134 + if (!(controller->used_channels & (1 << bit))) { 135 + controller->used_channels |= (1 << bit); 136 + musb_channel = &(controller->channel[bit]); 137 + musb_channel->controller = controller; 138 + musb_channel->idx = bit; 139 + musb_channel->epnum = hw_ep->epnum; 140 + musb_channel->transmit = transmit; 141 + channel = &(musb_channel->channel); 142 + channel->private_data = musb_channel; 143 + channel->status = MUSB_DMA_STATUS_FREE; 144 + channel->max_len = 0x10000; 144 145 /* Tx => mode 1; Rx => mode 0 */ 145 - pChannel->desired_mode = transmit; 146 - pChannel->actual_len = 0; 146 + channel->desired_mode = transmit; 147 + channel->actual_len = 0; 147 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 = 156 - (struct musb_dma_channel *) pChannel->private_data; 157 + struct musb_dma_channel *musb_channel = channel->private_data; 157 158 158 - pChannel->actual_len = 0; 159 - pImplChannel->dwStartAddress = 0; 160 - pImplChannel->len = 0; 159 + channel->actual_len = 0; 160 + musb_channel->start_addr = 0; 161 + musb_channel->len = 0; 161 162 162 - pImplChannel->controller->bmUsedChannels &= 163 - ~(1 << pImplChannel->bIndex); 163 + musb_channel->controller->used_channels &= 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 170 u16 packet_sz, u8 mode, 170 171 dma_addr_t dma_addr, u32 len) 171 172 { 172 - struct musb_dma_channel *pImplChannel = 173 - (struct musb_dma_channel *) pChannel->private_data; 174 - struct musb_dma_controller *controller = pImplChannel->controller; 175 - void __iomem *mbase = controller->pCoreBase; 176 - u8 bChannel = pImplChannel->bIndex; 173 + struct musb_dma_channel *musb_channel = channel->private_data; 174 + struct musb_dma_controller *controller = musb_channel->controller; 175 + void __iomem *mbase = controller->base; 176 + u8 bchannel = musb_channel->idx; 177 177 u16 csr = 0; 178 178 179 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 182 if (mode) { 183 183 csr |= 1 << MUSB_HSDMA_MODE1_SHIFT; ··· 195 195 } 196 196 } 197 197 198 - csr |= (pImplChannel->epnum << MUSB_HSDMA_ENDPOINT_SHIFT) 198 + csr |= (musb_channel->epnum << MUSB_HSDMA_ENDPOINT_SHIFT) 199 199 | (1 << MUSB_HSDMA_ENABLE_SHIFT) 200 200 | (1 << MUSB_HSDMA_IRQENABLE_SHIFT) 201 - | (pImplChannel->transmit 201 + | (musb_channel->transmit 202 202 ? (1 << MUSB_HSDMA_TRANSMIT_SHIFT) 203 203 : 0); 204 204 205 205 /* address/count */ 206 206 musb_writel(mbase, 207 - MUSB_HSDMA_CHANNEL_OFFSET(bChannel, MUSB_HSDMA_ADDRESS), 207 + MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_ADDRESS), 208 208 dma_addr); 209 209 musb_writel(mbase, 210 - MUSB_HSDMA_CHANNEL_OFFSET(bChannel, MUSB_HSDMA_COUNT), 210 + MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_COUNT), 211 211 len); 212 212 213 213 /* control (this should start things) */ 214 214 musb_writew(mbase, 215 - MUSB_HSDMA_CHANNEL_OFFSET(bChannel, MUSB_HSDMA_CONTROL), 215 + MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_CONTROL), 216 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 220 u16 packet_sz, u8 mode, 221 221 dma_addr_t dma_addr, u32 len) 222 222 { 223 - struct musb_dma_channel *pImplChannel = 224 - (struct musb_dma_channel *) pChannel->private_data; 223 + struct musb_dma_channel *musb_channel = channel->private_data; 225 224 226 225 DBG(2, "ep%d-%s pkt_sz %d, dma_addr 0x%x length %d, mode %d\n", 227 - pImplChannel->epnum, 228 - pImplChannel->transmit ? "Tx" : "Rx", 226 + musb_channel->epnum, 227 + musb_channel->transmit ? "Tx" : "Rx", 229 228 packet_sz, dma_addr, len, mode); 230 229 231 - BUG_ON(pChannel->status == MUSB_DMA_STATUS_UNKNOWN || 232 - pChannel->status == MUSB_DMA_STATUS_BUSY); 230 + BUG_ON(channel->status == MUSB_DMA_STATUS_UNKNOWN || 231 + channel->status == MUSB_DMA_STATUS_BUSY); 233 232 234 - pChannel->actual_len = 0; 235 - pImplChannel->dwStartAddress = dma_addr; 236 - pImplChannel->len = len; 237 - pImplChannel->wMaxPacketSize = packet_sz; 238 - pChannel->status = MUSB_DMA_STATUS_BUSY; 233 + channel->actual_len = 0; 234 + musb_channel->start_addr = dma_addr; 235 + musb_channel->len = len; 236 + musb_channel->max_packet_sz = packet_sz; 237 + channel->status = MUSB_DMA_STATUS_BUSY; 239 238 240 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 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 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 = 251 - (struct musb_dma_channel *) pChannel->private_data; 252 - u8 bChannel = pImplChannel->bIndex; 253 - void __iomem *mbase = pImplChannel->controller->pCoreBase; 249 + struct musb_dma_channel *musb_channel = channel->private_data; 250 + void __iomem *mbase = musb_channel->controller->base; 251 + 252 + u8 bchannel = musb_channel->idx; 254 253 u16 csr; 255 254 256 - if (pChannel->status == MUSB_DMA_STATUS_BUSY) { 257 - if (pImplChannel->transmit) { 255 + if (channel->status == MUSB_DMA_STATUS_BUSY) { 256 + if (musb_channel->transmit) { 258 257 259 258 csr = musb_readw(mbase, 260 - MUSB_EP_OFFSET(pImplChannel->epnum, 259 + MUSB_EP_OFFSET(musb_channel->epnum, 261 260 MUSB_TXCSR)); 262 261 csr &= ~(MUSB_TXCSR_AUTOSET | 263 262 MUSB_TXCSR_DMAENAB | 264 263 MUSB_TXCSR_DMAMODE); 265 264 musb_writew(mbase, 266 - MUSB_EP_OFFSET(pImplChannel->epnum, 267 - MUSB_TXCSR), 265 + MUSB_EP_OFFSET(musb_channel->epnum, MUSB_TXCSR), 268 266 csr); 269 267 } else { 270 268 csr = musb_readw(mbase, 271 - MUSB_EP_OFFSET(pImplChannel->epnum, 269 + MUSB_EP_OFFSET(musb_channel->epnum, 272 270 MUSB_RXCSR)); 273 271 csr &= ~(MUSB_RXCSR_AUTOCLEAR | 274 272 MUSB_RXCSR_DMAENAB | 275 273 MUSB_RXCSR_DMAMODE); 276 274 musb_writew(mbase, 277 - MUSB_EP_OFFSET(pImplChannel->epnum, 278 - MUSB_RXCSR), 275 + MUSB_EP_OFFSET(musb_channel->epnum, MUSB_RXCSR), 279 276 csr); 280 277 } 281 278 282 279 musb_writew(mbase, 283 - MUSB_HSDMA_CHANNEL_OFFSET(bChannel, MUSB_HSDMA_CONTROL), 280 + MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_CONTROL), 284 281 0); 285 282 musb_writel(mbase, 286 - MUSB_HSDMA_CHANNEL_OFFSET(bChannel, MUSB_HSDMA_ADDRESS), 283 + MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_ADDRESS), 287 284 0); 288 285 musb_writel(mbase, 289 - MUSB_HSDMA_CHANNEL_OFFSET(bChannel, MUSB_HSDMA_COUNT), 286 + MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_COUNT), 290 287 0); 291 288 292 - pChannel->status = MUSB_DMA_STATUS_FREE; 289 + channel->status = MUSB_DMA_STATUS_FREE; 293 290 } 291 + 294 292 return 0; 295 293 } 296 294 297 295 static irqreturn_t dma_controller_irq(int irq, void *private_data) 298 296 { 299 - struct musb_dma_controller *controller = 300 - (struct musb_dma_controller *)private_data; 301 - struct musb_dma_channel *pImplChannel; 302 - struct musb *musb = controller->pDmaPrivate; 303 - void __iomem *mbase = controller->pCoreBase; 304 - struct dma_channel *pChannel; 305 - u8 bChannel; 306 - u16 csr; 307 - u32 dwAddress; 308 - u8 int_hsdma; 297 + struct musb_dma_controller *controller = private_data; 298 + struct musb *musb = controller->private_data; 299 + struct musb_dma_channel *musb_channel; 300 + struct dma_channel *channel; 301 + 302 + void __iomem *mbase = controller->base; 303 + 309 304 irqreturn_t retval = IRQ_NONE; 305 + 310 306 unsigned long flags; 307 + 308 + u8 bchannel; 309 + u8 int_hsdma; 310 + 311 + u32 addr; 312 + u16 csr; 311 313 312 314 spin_lock_irqsave(&musb->lock, flags); 313 315 ··· 317 315 if (!int_hsdma) 318 316 goto done; 319 317 320 - for (bChannel = 0; bChannel < MUSB_HSDMA_CHANNELS; bChannel++) { 321 - if (int_hsdma & (1 << bChannel)) { 322 - pImplChannel = (struct musb_dma_channel *) 323 - &(controller->aChannel[bChannel]); 324 - pChannel = &pImplChannel->Channel; 318 + for (bchannel = 0; bchannel < MUSB_HSDMA_CHANNELS; bchannel++) { 319 + if (int_hsdma & (1 << bchannel)) { 320 + musb_channel = (struct musb_dma_channel *) 321 + &(controller->channel[bchannel]); 322 + channel = &musb_channel->channel; 325 323 326 324 csr = musb_readw(mbase, 327 - MUSB_HSDMA_CHANNEL_OFFSET(bChannel, 325 + MUSB_HSDMA_CHANNEL_OFFSET(bchannel, 328 326 MUSB_HSDMA_CONTROL)); 329 327 330 - if (csr & (1 << MUSB_HSDMA_BUSERROR_SHIFT)) 331 - pImplChannel->Channel.status = 328 + if (csr & (1 << MUSB_HSDMA_BUSERROR_SHIFT)) { 329 + musb_channel->channel.status = 332 330 MUSB_DMA_STATUS_BUS_ABORT; 333 - else { 331 + } else { 334 332 u8 devctl; 335 333 336 - dwAddress = musb_readl(mbase, 334 + addr = musb_readl(mbase, 337 335 MUSB_HSDMA_CHANNEL_OFFSET( 338 - bChannel, 336 + bchannel, 339 337 MUSB_HSDMA_ADDRESS)); 340 - pChannel->actual_len = dwAddress 341 - - pImplChannel->dwStartAddress; 338 + channel->actual_len = addr 339 + - musb_channel->start_addr; 342 340 343 341 DBG(2, "ch %p, 0x%x -> 0x%x (%d / %d) %s\n", 344 - pChannel, pImplChannel->dwStartAddress, 345 - dwAddress, pChannel->actual_len, 346 - pImplChannel->len, 347 - (pChannel->actual_len 348 - < pImplChannel->len) ? 342 + channel, musb_channel->start_addr, 343 + addr, channel->actual_len, 344 + musb_channel->len, 345 + (channel->actual_len 346 + < musb_channel->len) ? 349 347 "=> reconfig 0" : "=> complete"); 350 348 351 349 devctl = musb_readb(mbase, MUSB_DEVCTL); 352 350 353 - pChannel->status = MUSB_DMA_STATUS_FREE; 351 + channel->status = MUSB_DMA_STATUS_FREE; 354 352 355 353 /* completed */ 356 354 if ((devctl & MUSB_DEVCTL_HM) 357 - && (pImplChannel->transmit) 358 - && ((pChannel->desired_mode == 0) 359 - || (pChannel->actual_len & 360 - (pImplChannel->wMaxPacketSize - 1))) 355 + && (musb_channel->transmit) 356 + && ((channel->desired_mode == 0) 357 + || (channel->actual_len & 358 + (musb_channel->max_packet_sz - 1))) 361 359 ) { 362 360 /* Send out the packet */ 363 361 musb_ep_select(mbase, 364 - pImplChannel->epnum); 362 + musb_channel->epnum); 365 363 musb_writew(mbase, MUSB_EP_OFFSET( 366 - pImplChannel->epnum, 364 + musb_channel->epnum, 367 365 MUSB_TXCSR), 368 366 MUSB_TXCSR_TXPKTRDY); 369 - } else 367 + } else { 370 368 musb_dma_completion( 371 369 musb, 372 - pImplChannel->epnum, 373 - pImplChannel->transmit); 370 + musb_channel->epnum, 371 + musb_channel->transmit); 372 + } 374 373 } 375 374 } 376 375 } ··· 383 380 384 381 void dma_controller_destroy(struct dma_controller *c) 385 382 { 386 - struct musb_dma_controller *controller; 383 + struct musb_dma_controller *controller = container_of(c, 384 + struct musb_dma_controller, controller); 387 385 388 - controller = container_of(c, struct musb_dma_controller, Controller); 389 386 if (!controller) 390 387 return; 391 388 ··· 396 393 } 397 394 398 395 struct dma_controller *__init 399 - dma_controller_create(struct musb *musb, void __iomem *pCoreBase) 396 + dma_controller_create(struct musb *musb, void __iomem *base) 400 397 { 401 398 struct musb_dma_controller *controller; 402 399 struct device *dev = musb->controller; ··· 408 405 return NULL; 409 406 } 410 407 411 - controller = kzalloc(sizeof(struct musb_dma_controller), GFP_KERNEL); 408 + controller = kzalloc(sizeof(*controller), GFP_KERNEL); 412 409 if (!controller) 413 410 return NULL; 414 411 415 - controller->bChannelCount = MUSB_HSDMA_CHANNELS; 416 - controller->pDmaPrivate = musb; 417 - controller->pCoreBase = pCoreBase; 412 + controller->channel_count = MUSB_HSDMA_CHANNELS; 413 + controller->private_data = musb; 414 + controller->base = base; 418 415 419 - controller->Controller.start = dma_controller_start; 420 - controller->Controller.stop = dma_controller_stop; 421 - controller->Controller.channel_alloc = dma_channel_allocate; 422 - controller->Controller.channel_release = dma_channel_release; 423 - controller->Controller.channel_program = dma_channel_program; 424 - controller->Controller.channel_abort = dma_channel_abort; 416 + controller->controller.start = dma_controller_start; 417 + controller->controller.stop = dma_controller_stop; 418 + controller->controller.channel_alloc = dma_channel_allocate; 419 + controller->controller.channel_release = dma_channel_release; 420 + controller->controller.channel_program = dma_channel_program; 421 + controller->controller.channel_abort = dma_channel_abort; 425 422 426 423 if (request_irq(irq, dma_controller_irq, IRQF_DISABLED, 427 - musb->controller->bus_id, &controller->Controller)) { 424 + musb->controller->bus_id, &controller->controller)) { 428 425 dev_err(dev, "request_irq %d failed!\n", irq); 429 - dma_controller_destroy(&controller->Controller); 426 + dma_controller_destroy(&controller->controller); 427 + 430 428 return NULL; 431 429 } 432 430 433 431 controller->irq = irq; 434 432 435 - return &controller->Controller; 433 + return &controller->controller; 436 434 }
+4 -4
drivers/usb/serial/aircable.c
··· 220 220 221 221 buf = kzalloc(count + HCI_HEADER_LENGTH, GFP_ATOMIC); 222 222 if (!buf) { 223 - err("%s- kzalloc(%d) failed.", __func__, 224 - count + HCI_HEADER_LENGTH); 223 + dev_err(&port->dev, "%s- kzalloc(%d) failed.\n", 224 + __func__, count + HCI_HEADER_LENGTH); 225 225 return; 226 226 } 227 227 ··· 276 276 277 277 if (!tty) { 278 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 280 return ; 281 281 } 282 282 ··· 336 336 337 337 priv = kzalloc(sizeof(struct aircable_private), GFP_KERNEL); 338 338 if (!priv) { 339 - err("%s- kmalloc(%Zd) failed.", __func__, 339 + dev_err(&port->dev, "%s- kmalloc(%Zd) failed.\n", __func__, 340 340 sizeof(struct aircable_private)); 341 341 return -ENOMEM; 342 342 }
+20 -19
drivers/usb/serial/belkin_sa.c
··· 187 187 /* see comments at top of file */ 188 188 priv->bad_flow_control = 189 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 191 le16_to_cpu(dev->descriptor.bcdDevice), 192 192 priv->bad_flow_control); 193 193 ··· 228 228 port->read_urb->dev = port->serial->dev; 229 229 retval = usb_submit_urb(port->read_urb, GFP_KERNEL); 230 230 if (retval) { 231 - err("usb_submit_urb(read bulk) failed"); 231 + dev_err(&port->dev, "usb_submit_urb(read bulk) failed\n"); 232 232 goto exit; 233 233 } 234 234 ··· 236 236 retval = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); 237 237 if (retval) { 238 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 242 exit: ··· 342 342 exit: 343 343 retval = usb_submit_urb(urb, GFP_ATOMIC); 344 344 if (retval) 345 - err("%s - usb_submit_urb failed with result %d", 346 - __func__, retval); 345 + dev_err(&port->dev, "%s - usb_submit_urb failed with " 346 + "result %d\n", __func__, retval); 347 347 } 348 348 349 349 static void belkin_sa_set_termios(struct tty_struct *tty, ··· 382 382 if ((old_cflag & CBAUD) == B0) { 383 383 control_state |= (TIOCM_DTR|TIOCM_RTS); 384 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 386 /* don't set RTS if using hardware flow control */ 387 387 if (!(old_cflag & CRTSCTS)) 388 388 if (BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST 389 389 , 1) < 0) 390 - err("Set RTS error"); 390 + dev_err(&port->dev, "Set RTS error\n"); 391 391 } 392 392 } 393 393 ··· 403 403 /* Report the actual baud rate back to the caller */ 404 404 tty_encode_baud_rate(tty, baud, baud); 405 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 407 } else { 408 408 /* Disable flow control */ 409 409 if (BSA_USB_CMD(BELKIN_SA_SET_FLOW_CTRL_REQUEST, 410 410 BELKIN_SA_FLOW_NONE) < 0) 411 - err("Disable flowcontrol error"); 411 + dev_err(&port->dev, "Disable flowcontrol error\n"); 412 412 /* Drop RTS and DTR */ 413 413 control_state &= ~(TIOCM_DTR | TIOCM_RTS); 414 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 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 420 /* set the parity */ ··· 425 425 else 426 426 urb_value = BELKIN_SA_PARITY_NONE; 427 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 431 /* set the number of data bits */ ··· 448 448 break; 449 449 } 450 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 454 /* set the number of stop bits */ ··· 457 457 : BELKIN_SA_STOP_BITS(1); 458 458 if (BSA_USB_CMD(BELKIN_SA_SET_STOP_BITS_REQUEST, 459 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 463 /* Set flow control */ ··· 478 478 urb_value &= ~(BELKIN_SA_FLOW_IRTS); 479 479 480 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 484 /* save off the modified port settings */ ··· 494 494 struct usb_serial *serial = port->serial; 495 495 496 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 554 555 555 retval = BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST, rts); 556 556 if (retval < 0) { 557 - err("Set RTS error %d", retval); 557 + dev_err(&port->dev, "Set RTS error %d\n", retval); 558 558 goto exit; 559 559 } 560 560 561 561 retval = BSA_USB_CMD(BELKIN_SA_SET_DTR_REQUEST, dtr); 562 562 if (retval < 0) { 563 - err("Set DTR error %d", retval); 563 + dev_err(&port->dev, "Set DTR error %d\n", retval); 564 564 goto exit; 565 565 } 566 566 exit: ··· 577 577 retval = usb_register(&belkin_driver); 578 578 if (retval) 579 579 goto failed_usb_register; 580 - info(DRIVER_DESC " " DRIVER_VERSION); 580 + printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" 581 + DRIVER_DESC "\n"); 581 582 return 0; 582 583 failed_usb_register: 583 584 usb_serial_deregister(&belkin_device);
+2 -1
drivers/usb/serial/cp2101.c
··· 753 753 } 754 754 755 755 /* Success */ 756 - info(DRIVER_DESC " " DRIVER_VERSION); 756 + printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" 757 + DRIVER_DESC "\n"); 757 758 return 0; 758 759 } 759 760
+17 -11
drivers/usb/serial/cyberjack.c
··· 141 141 result = usb_submit_urb(serial->port[i]->interrupt_in_urb, 142 142 GFP_KERNEL); 143 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 146 dbg("%s - usb_submit_urb(int urb)", __func__); 146 147 } 147 148 ··· 275 274 /* send the data out the bulk port */ 276 275 result = usb_submit_urb(port->write_urb, GFP_ATOMIC); 277 276 if (result) { 278 - err("%s - failed submitting write urb, error %d", 279 - __func__, result); 277 + dev_err(&port->dev, 278 + "%s - failed submitting write urb, error %d", 279 + __func__, result); 280 280 /* Throw away data. No better idea what to do with it. */ 281 281 priv->wrfilled = 0; 282 282 priv->wrsent = 0; ··· 353 351 port->read_urb->dev = port->serial->dev; 354 352 result = usb_submit_urb(port->read_urb, GFP_ATOMIC); 355 353 if (result) 356 - err("%s - failed resubmitting read urb, error %d", __func__, result); 354 + dev_err(&port->dev, "%s - failed resubmitting " 355 + "read urb, error %d\n", 356 + __func__, result); 357 357 dbg("%s - usb_submit_urb(read urb)", __func__); 358 358 } 359 359 } ··· 364 360 port->interrupt_in_urb->dev = port->serial->dev; 365 361 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); 366 362 if (result) 367 - err(" usb_submit_urb(read int) failed"); 363 + dev_err(&port->dev, "usb_submit_urb(read int) failed\n"); 368 364 dbg("%s - usb_submit_urb(int urb)", __func__); 369 365 } 370 366 ··· 418 414 port->read_urb->dev = port->serial->dev; 419 415 result = usb_submit_urb(port->read_urb, GFP_ATOMIC); 420 416 if (result) 421 - err("%s - failed resubmitting read urb, error %d", 422 - __func__, result); 417 + dev_err(&port->dev, "%s - failed resubmitting read " 418 + "urb, error %d\n", __func__, result); 423 419 dbg("%s - usb_submit_urb(read urb)", __func__); 424 420 } 425 421 } ··· 466 462 /* send the data out the bulk port */ 467 463 result = usb_submit_urb(port->write_urb, GFP_ATOMIC); 468 464 if (result) { 469 - err("%s - failed submitting write urb, error %d", 470 - __func__, result); 465 + dev_err(&port->dev, 466 + "%s - failed submitting write urb, error %d\n", 467 + __func__, result); 471 468 /* Throw away data. No better idea what to do with it. */ 472 469 priv->wrfilled = 0; 473 470 priv->wrsent = 0; ··· 504 499 if (retval) 505 500 goto failed_usb_register; 506 501 507 - info(DRIVER_VERSION " " DRIVER_AUTHOR); 508 - info(DRIVER_DESC); 502 + printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION " " 503 + DRIVER_AUTHOR "\n"); 504 + printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_DESC "\n"); 509 505 510 506 return 0; 511 507 failed_usb_register:
+12 -9
drivers/usb/serial/cypress_m8.c
··· 404 404 retval != -ENODEV); 405 405 406 406 if (retval != sizeof(feature_buffer)) { 407 - err("%s - failed sending serial line settings - %d", 408 - __func__, retval); 407 + dev_err(&port->dev, "%s - failed sending serial " 408 + "line settings - %d\n", __func__, retval); 409 409 cypress_set_dead(port); 410 410 } else { 411 411 spin_lock_irqsave(&priv->lock, flags); ··· 443 443 && retval != -ENODEV); 444 444 445 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 448 cypress_set_dead(port); 448 449 return retval; 449 450 } else { ··· 477 476 priv->comm_is_ok = 0; 478 477 spin_unlock_irqrestore(&priv->lock, flags); 479 478 480 - err("cypress_m8 suspending failing port %d - interval might be too short", 481 - port->number); 479 + dev_err(&port->dev, "cypress_m8 suspending failing port %d - " 480 + "interval might be too short\n", port->number); 482 481 } 483 482 484 483 ··· 680 679 681 680 /* setup the port and start reading from the device */ 682 681 if (!port->interrupt_in_urb) { 683 - err("%s - interrupt_in_urb is empty!", __func__); 682 + dev_err(&port->dev, "%s - interrupt_in_urb is empty!\n", 683 + __func__); 684 684 return -1; 685 685 } 686 686 ··· 1109 1107 data_bits = 3; 1110 1108 break; 1111 1109 default: 1112 - err("%s - CSIZE was set, but not CS5-CS8", 1113 - __func__); 1110 + dev_err(&port->dev, "%s - CSIZE was set, but not CS5-CS8\n", 1111 + __func__); 1114 1112 data_bits = 3; 1115 1113 } 1116 1114 spin_lock_irqsave(&priv->lock, flags); ··· 1660 1658 if (retval) 1661 1659 goto failed_usb_register; 1662 1660 1663 - info(DRIVER_DESC " " DRIVER_VERSION); 1661 + printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" 1662 + DRIVER_DESC "\n"); 1664 1663 return 0; 1665 1664 1666 1665 failed_usb_register:
+42 -26
drivers/usb/serial/digi_acceleport.c
··· 661 661 } 662 662 spin_unlock_irqrestore(&oob_priv->dp_port_lock, flags); 663 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 666 return ret; 666 667 667 668 } ··· 744 743 spin_unlock_irqrestore(&priv->dp_port_lock, flags); 745 744 746 745 if (ret) 747 - err("%s: usb_submit_urb failed, ret=%d, port=%d", 746 + dev_err(&port->dev, 747 + "%s: usb_submit_urb failed, ret=%d, port=%d\n", 748 748 __func__, ret, priv->dp_port_num); 749 749 return ret; 750 750 } ··· 814 812 spin_unlock(&port_priv->dp_port_lock); 815 813 spin_unlock_irqrestore(&oob_priv->dp_port_lock, flags); 816 814 if (ret) 817 - err("%s: usb_submit_urb failed, ret=%d", __func__, ret); 815 + dev_err(&port->dev, "%s: usb_submit_urb failed, ret=%d\n", 816 + __func__, ret); 818 817 return ret; 819 818 } 820 819 ··· 910 907 spin_unlock_irqrestore(&priv->dp_port_lock, flags); 911 908 912 909 if (ret) 913 - err("%s: usb_submit_urb failed, ret=%d, port=%d", 910 + dev_err(&port->dev, 911 + "%s: usb_submit_urb failed, ret=%d, port=%d\n", 914 912 __func__, ret, priv->dp_port_num); 915 913 } 916 914 ··· 1218 1214 /* return length of new data written, or error */ 1219 1215 spin_unlock_irqrestore(&priv->dp_port_lock, flags); 1220 1216 if (ret < 0) 1221 - err("%s: usb_submit_urb failed, ret=%d, port=%d", 1217 + dev_err(&port->dev, 1218 + "%s: usb_submit_urb failed, ret=%d, port=%d\n", 1222 1219 __func__, ret, priv->dp_port_num); 1223 1220 dbg("digi_write: returning %d", ret); 1224 1221 return ret; ··· 1240 1235 1241 1236 /* port and serial sanity check */ 1242 1237 if (port == NULL || (priv = usb_get_serial_port_data(port)) == NULL) { 1243 - err("%s: port or port->private is NULL, status=%d", 1244 - __func__, status); 1238 + dev_err(&port->dev, 1239 + "%s: port or port->private is NULL, status=%d\n", 1240 + __func__, status); 1245 1241 return; 1246 1242 } 1247 1243 serial = port->serial; 1248 1244 if (serial == NULL || (serial_priv = usb_get_serial_data(serial)) == NULL) { 1249 - err("%s: serial or serial->private is NULL, status=%d", 1250 - __func__, status); 1245 + dev_err(&port->dev, 1246 + "%s: serial or serial->private is NULL, status=%d\n", 1247 + __func__, status); 1251 1248 return; 1252 1249 } 1253 1250 ··· 1291 1284 1292 1285 spin_unlock(&priv->dp_port_lock); 1293 1286 if (ret) 1294 - err("%s: usb_submit_urb failed, ret=%d, port=%d", 1287 + dev_err(&port->dev, 1288 + "%s: usb_submit_urb failed, ret=%d, port=%d\n", 1295 1289 __func__, ret, priv->dp_port_num); 1296 1290 } 1297 1291 ··· 1526 1518 port->write_urb->dev = port->serial->dev; 1527 1519 ret = usb_submit_urb(port->read_urb, GFP_KERNEL); 1528 1520 if (ret != 0) { 1529 - err("%s: usb_submit_urb failed, ret=%d, port=%d", 1530 - __func__, ret, i); 1521 + dev_err(&port->dev, 1522 + "%s: usb_submit_urb failed, ret=%d, port=%d\n", 1523 + __func__, ret, i); 1531 1524 break; 1532 1525 } 1533 1526 } ··· 1627 1618 dbg("digi_read_bulk_callback: TOP"); 1628 1619 1629 1620 /* port sanity check, do not resubmit if port is not valid */ 1630 - if (port == NULL || (priv = usb_get_serial_port_data(port)) == NULL) { 1631 - err("%s: port or port->private is NULL, status=%d", 1632 - __func__, status); 1621 + if (port == NULL) 1622 + return; 1623 + priv = usb_get_serial_port_data(port); 1624 + if (priv == NULL) { 1625 + dev_err(&port->dev, "%s: port->private is NULL, status=%d\n", 1626 + __func__, status); 1633 1627 return; 1634 1628 } 1635 1629 if (port->serial == NULL || 1636 1630 (serial_priv = usb_get_serial_data(port->serial)) == NULL) { 1637 - err("%s: serial is bad or serial->private is NULL, status=%d", 1638 - __func__, status); 1631 + dev_err(&port->dev, "%s: serial is bad or serial->private " 1632 + "is NULL, status=%d\n", __func__, status); 1639 1633 return; 1640 1634 } 1641 1635 1642 1636 /* do not resubmit urb if it has any status error */ 1643 1637 if (status) { 1644 - err("%s: nonzero read bulk status: status=%d, port=%d", 1645 - __func__, status, priv->dp_port_num); 1638 + dev_err(&port->dev, 1639 + "%s: nonzero read bulk status: status=%d, port=%d\n", 1640 + __func__, status, priv->dp_port_num); 1646 1641 return; 1647 1642 } 1648 1643 ··· 1663 1650 urb->dev = port->serial->dev; 1664 1651 ret = usb_submit_urb(urb, GFP_ATOMIC); 1665 1652 if (ret != 0) { 1666 - err("%s: failed resubmitting urb, ret=%d, port=%d", 1667 - __func__, ret, priv->dp_port_num); 1653 + dev_err(&port->dev, 1654 + "%s: failed resubmitting urb, ret=%d, port=%d\n", 1655 + __func__, ret, priv->dp_port_num); 1668 1656 } 1669 1657 1670 1658 } ··· 1701 1687 1702 1688 /* short/multiple packet check */ 1703 1689 if (urb->actual_length != len + 2) { 1704 - err("%s: INCOMPLETE OR MULTIPLE PACKET, urb->status=%d, " 1705 - "port=%d, opcode=%d, len=%d, actual_length=%d, " 1706 - "status=%d", __func__, status, priv->dp_port_num, 1707 - opcode, len, urb->actual_length, port_status); 1690 + dev_err(&port->dev, "%s: INCOMPLETE OR MULTIPLE PACKET, " 1691 + "urb->status=%d, port=%d, opcode=%d, len=%d, " 1692 + "actual_length=%d, status=%d\n", __func__, status, 1693 + priv->dp_port_num, opcode, len, urb->actual_length, 1694 + port_status); 1708 1695 return -1; 1709 1696 } 1710 1697 ··· 1869 1854 retval = usb_register(&digi_driver); 1870 1855 if (retval) 1871 1856 goto failed_usb_register; 1872 - info(DRIVER_VERSION ":" DRIVER_DESC); 1857 + printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" 1858 + DRIVER_DESC "\n"); 1873 1859 return 0; 1874 1860 failed_usb_register: 1875 1861 usb_serial_deregister(&digi_acceleport_4_device);
+6 -5
drivers/usb/serial/empeg.c
··· 416 416 dbg("%s", __func__); 417 417 418 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 420 serial->dev->actconfig->desc.bConfigurationValue); 421 421 return -ENODEV; 422 422 } ··· 499 499 urb = usb_alloc_urb(0, GFP_KERNEL); 500 500 write_urb_pool[i] = urb; 501 501 if (urb == NULL) { 502 - err("No more urbs???"); 502 + printk(KERN_ERR "empeg: No more urbs???\n"); 503 503 continue; 504 504 } 505 505 506 506 urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE, 507 507 GFP_KERNEL); 508 508 if (!urb->transfer_buffer) { 509 - err("%s - out of memory for urb buffers.", 510 - __func__); 509 + printk(KERN_ERR "empeg: %s - out of memory for urb " 510 + "buffers.", __func__); 511 511 continue; 512 512 } 513 513 } ··· 519 519 if (retval) 520 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 525 return 0; 525 526 failed_usb_register:
+2 -1
drivers/usb/serial/ezusb.c
··· 28 28 29 29 /* dbg("ezusb_writememory %x, %d", address, length); */ 30 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 33 return -ENODEV; 33 34 } 34 35
+50 -32
drivers/usb/serial/ftdi_sio.c
··· 578 578 { USB_DEVICE(FALCOM_VID, FALCOM_TWIST_PID) }, 579 579 { USB_DEVICE(FALCOM_VID, FALCOM_SAMBA_PID) }, 580 580 { USB_DEVICE(FTDI_VID, FTDI_SUUNTO_SPORTS_PID) }, 581 + { USB_DEVICE(FTDI_VID, FTDI_OCEANIC_PID) }, 581 582 { USB_DEVICE(TTI_VID, TTI_QL355P_PID) }, 582 583 { USB_DEVICE(FTDI_VID, FTDI_RM_CANVIEW_PID) }, 583 584 { USB_DEVICE(BANDB_VID, BANDB_USOTL4_PID) }, ··· 1154 1153 /* Assume its an FT232R */ 1155 1154 priv->chip_type = FT232RL; 1156 1155 } 1157 - info("Detected %s", ftdi_chip_name[priv->chip_type]); 1156 + dev_info(&udev->dev, "Detected %s\n", ftdi_chip_name[priv->chip_type]); 1158 1157 } 1159 1158 1160 1159 ··· 1327 1326 1328 1327 priv = kzalloc(sizeof(struct ftdi_private), GFP_KERNEL); 1329 1328 if (!priv) { 1330 - err("%s- kmalloc(%Zd) failed.", __func__, 1329 + dev_err(&port->dev, "%s- kmalloc(%Zd) failed.\n", __func__, 1331 1330 sizeof(struct ftdi_private)); 1332 1331 return -ENOMEM; 1333 1332 } ··· 1410 1409 dbg("%s", __func__); 1411 1410 1412 1411 if (interface == udev->actconfig->interface[0]) { 1413 - info("Ignoring serial port reserved for JTAG"); 1412 + dev_info(&udev->dev, 1413 + "Ignoring serial port reserved for JTAG\n"); 1414 1414 return -ENODEV; 1415 1415 } 1416 1416 ··· 1429 1427 1430 1428 if (ep->enabled && ep_desc->wMaxPacketSize == 0) { 1431 1429 ep_desc->wMaxPacketSize = cpu_to_le16(0x40); 1432 - info("Fixing invalid wMaxPacketSize on read pipe"); 1430 + dev_info(&serial->dev->dev, 1431 + "Fixing invalid wMaxPacketSize on read pipe\n"); 1433 1432 } 1434 1433 1435 1434 return 0; ··· 1524 1521 ftdi_read_bulk_callback, port); 1525 1522 result = usb_submit_urb(port->read_urb, GFP_KERNEL); 1526 1523 if (result) 1527 - err("%s - failed submitting read urb, error %d", 1528 - __func__, result); 1524 + dev_err(&port->dev, 1525 + "%s - failed submitting read urb, error %d\n", 1526 + __func__, result); 1529 1527 1530 1528 1531 1529 return result; ··· 1560 1556 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 1561 1557 0, priv->interface, buf, 0, 1562 1558 WDR_TIMEOUT) < 0) { 1563 - err("error from flowcontrol urb"); 1559 + dev_err(&port->dev, "error from flowcontrol urb\n"); 1564 1560 } 1565 1561 1566 1562 /* drop RTS and DTR */ ··· 1625 1621 1626 1622 buffer = kmalloc(transfer_size, GFP_ATOMIC); 1627 1623 if (!buffer) { 1628 - err("%s ran out of kernel memory for urb ...", __func__); 1624 + dev_err(&port->dev, 1625 + "%s ran out of kernel memory for urb ...\n", __func__); 1629 1626 count = -ENOMEM; 1630 1627 goto error_no_buffer; 1631 1628 } 1632 1629 1633 1630 urb = usb_alloc_urb(0, GFP_ATOMIC); 1634 1631 if (!urb) { 1635 - err("%s - no more free urbs", __func__); 1632 + dev_err(&port->dev, "%s - no more free urbs\n", __func__); 1636 1633 count = -ENOMEM; 1637 1634 goto error_no_urb; 1638 1635 } ··· 1677 1672 1678 1673 status = usb_submit_urb(urb, GFP_ATOMIC); 1679 1674 if (status) { 1680 - err("%s - failed submitting write urb, error %d", 1681 - __func__, status); 1675 + dev_err(&port->dev, 1676 + "%s - failed submitting write urb, error %d\n", 1677 + __func__, status); 1682 1678 count = status; 1683 1679 goto error; 1684 1680 } else { ··· 1786 1780 buffered = (int)priv->tx_outstanding_bytes; 1787 1781 spin_unlock_irqrestore(&priv->tx_lock, flags); 1788 1782 if (buffered < 0) { 1789 - err("%s outstanding tx bytes is negative!", __func__); 1783 + dev_err(&port->dev, "%s outstanding tx bytes is negative!\n", 1784 + __func__); 1790 1785 buffered = 0; 1791 1786 } 1792 1787 return buffered; ··· 1803 1796 int status = urb->status; 1804 1797 1805 1798 if (urb->number_of_packets > 0) { 1806 - err("%s transfer_buffer_length %d actual_length %d number of packets %d", 1807 - __func__, 1808 - urb->transfer_buffer_length, 1809 - urb->actual_length, urb->number_of_packets); 1810 - err("%s transfer_flags %x ", __func__, urb->transfer_flags); 1799 + dev_err(&port->dev, "%s transfer_buffer_length %d " 1800 + "actual_length %d number of packets %d\n", __func__, 1801 + urb->transfer_buffer_length, 1802 + urb->actual_length, urb->number_of_packets); 1803 + dev_err(&port->dev, "%s transfer_flags %x\n", __func__, 1804 + urb->transfer_flags); 1811 1805 } 1812 1806 1813 1807 dbg("%s - port %d", __func__, port->number); ··· 1829 1821 } 1830 1822 1831 1823 if (urb != port->read_urb) 1832 - err("%s - Not my urb!", __func__); 1824 + dev_err(&port->dev, "%s - Not my urb!\n", __func__); 1833 1825 1834 1826 if (status) { 1835 1827 /* This will happen at close every time so it is a dbg not an ··· 1932 1924 1933 1925 length = min(PKTSZ, urb->actual_length-packet_offset)-2; 1934 1926 if (length < 0) { 1935 - err("%s - bad packet length: %d", __func__, length+2); 1927 + dev_err(&port->dev, "%s - bad packet length: %d\n", 1928 + __func__, length+2); 1936 1929 length = 0; 1937 1930 } 1938 1931 ··· 2048 2039 2049 2040 result = usb_submit_urb(port->read_urb, GFP_ATOMIC); 2050 2041 if (result) 2051 - err("%s - failed resubmitting read urb, error %d", 2052 - __func__, result); 2042 + dev_err(&port->dev, 2043 + "%s - failed resubmitting read urb, error %d\n", 2044 + __func__, result); 2053 2045 } 2054 2046 out: 2055 2047 tty_kref_put(tty); ··· 2079 2069 FTDI_SIO_SET_DATA_REQUEST_TYPE, 2080 2070 urb_value , priv->interface, 2081 2071 buf, 0, WDR_TIMEOUT) < 0) { 2082 - err("%s FAILED to enable/disable break state (state was %d)", 2083 - __func__, break_state); 2072 + dev_err(&port->dev, "%s FAILED to enable/disable break state " 2073 + "(state was %d)\n", __func__, break_state); 2084 2074 } 2085 2075 2086 2076 dbg("%s break state is %d - urb is %d", __func__, ··· 2152 2142 case CS7: urb_value |= 7; dbg("Setting CS7"); break; 2153 2143 case CS8: urb_value |= 8; dbg("Setting CS8"); break; 2154 2144 default: 2155 - err("CSIZE was set but not CS5-CS8"); 2145 + dev_err(&port->dev, "CSIZE was set but not CS5-CS8\n"); 2156 2146 } 2157 2147 } 2158 2148 ··· 2165 2155 FTDI_SIO_SET_DATA_REQUEST_TYPE, 2166 2156 urb_value , priv->interface, 2167 2157 buf, 0, WDR_SHORT_TIMEOUT) < 0) { 2168 - err("%s FAILED to set databits/stopbits/parity", __func__); 2158 + dev_err(&port->dev, "%s FAILED to set " 2159 + "databits/stopbits/parity\n", __func__); 2169 2160 } 2170 2161 2171 2162 /* Now do the baudrate */ ··· 2177 2166 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 2178 2167 0, priv->interface, 2179 2168 buf, 0, WDR_TIMEOUT) < 0) { 2180 - err("%s error from disable flowcontrol urb", __func__); 2169 + dev_err(&port->dev, 2170 + "%s error from disable flowcontrol urb\n", 2171 + __func__); 2181 2172 } 2182 2173 /* Drop RTS and DTR */ 2183 2174 clear_mctrl(port, TIOCM_DTR | TIOCM_RTS); 2184 2175 } else { 2185 2176 /* set the baudrate determined before */ 2186 2177 if (change_speed(tty, port)) 2187 - err("%s urb failed to set baudrate", __func__); 2178 + dev_err(&port->dev, "%s urb failed to set baudrate\n", 2179 + __func__); 2188 2180 /* Ensure RTS and DTR are raised when baudrate changed from 0 */ 2189 2181 if (!old_termios || (old_termios->c_cflag & CBAUD) == B0) 2190 2182 set_mctrl(port, TIOCM_DTR | TIOCM_RTS); ··· 2203 2189 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 2204 2190 0 , (FTDI_SIO_RTS_CTS_HS | priv->interface), 2205 2191 buf, 0, WDR_TIMEOUT) < 0) { 2206 - err("urb failed to set to rts/cts flow control"); 2192 + dev_err(&port->dev, 2193 + "urb failed to set to rts/cts flow control\n"); 2207 2194 } 2208 2195 2209 2196 } else { ··· 2235 2220 urb_value , (FTDI_SIO_XON_XOFF_HS 2236 2221 | priv->interface), 2237 2222 buf, 0, WDR_TIMEOUT) < 0) { 2238 - err("urb failed to set to xon/xoff flow control"); 2223 + dev_err(&port->dev, "urb failed to set to " 2224 + "xon/xoff flow control\n"); 2239 2225 } 2240 2226 } else { 2241 2227 /* else clause to only run if cflag ! CRTSCTS and iflag ··· 2249 2233 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 2250 2234 0, priv->interface, 2251 2235 buf, 0, WDR_TIMEOUT) < 0) { 2252 - err("urb failed to clear flow control"); 2236 + dev_err(&port->dev, 2237 + "urb failed to clear flow control\n"); 2253 2238 } 2254 2239 } 2255 2240 ··· 2442 2425 if (retval) 2443 2426 goto failed_usb_register; 2444 2427 2445 - info(DRIVER_VERSION ":" DRIVER_DESC); 2428 + printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" 2429 + DRIVER_DESC "\n"); 2446 2430 return 0; 2447 2431 failed_usb_register: 2448 2432 usb_serial_deregister(&ftdi_sio_device); ··· 2476 2458 MODULE_PARM_DESC(vendor, "User specified vendor ID (default=" 2477 2459 __MODULE_STRING(FTDI_VID)")"); 2478 2460 module_param(product, ushort, 0); 2479 - MODULE_PARM_DESC(vendor, "User specified product ID"); 2461 + MODULE_PARM_DESC(product, "User specified product ID"); 2480 2462
+5
drivers/usb/serial/ftdi_sio.h
··· 628 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 636 * TTi (Thurlby Thandar Instruments) 632 637 */ 633 638 #define TTI_VID 0x103E /* Vendor Id */
+2 -1
drivers/usb/serial/garmin_gps.c
··· 1585 1585 retval = usb_register(&garmin_driver); 1586 1586 if (retval) 1587 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 1591 return 0; 1591 1592 failed_usb_register:
+2 -1
drivers/usb/serial/hp4x.c
··· 63 63 retval = usb_register(&hp49gp_driver); 64 64 if (retval) 65 65 goto failed_usb_register; 66 - info(DRIVER_DESC " " DRIVER_VERSION); 66 + printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" 67 + DRIVER_DESC "\n"); 67 68 return 0; 68 69 failed_usb_register: 69 70 usb_serial_deregister(&hp49gp_device);
+11 -8
drivers/usb/serial/io_edgeport.c
··· 3109 3109 edge_serial->interrupt_read_urb = 3110 3110 usb_alloc_urb(0, GFP_KERNEL); 3111 3111 if (!edge_serial->interrupt_read_urb) { 3112 - err("out of memory"); 3112 + dev_err(&dev->dev, "out of memory\n"); 3113 3113 return -ENOMEM; 3114 3114 } 3115 3115 edge_serial->interrupt_in_buffer = 3116 3116 kmalloc(buffer_size, GFP_KERNEL); 3117 3117 if (!edge_serial->interrupt_in_buffer) { 3118 - err("out of memory"); 3118 + dev_err(&dev->dev, "out of memory\n"); 3119 3119 usb_free_urb(edge_serial->interrupt_read_urb); 3120 3120 return -ENOMEM; 3121 3121 } ··· 3146 3146 edge_serial->read_urb = 3147 3147 usb_alloc_urb(0, GFP_KERNEL); 3148 3148 if (!edge_serial->read_urb) { 3149 - err("out of memory"); 3149 + dev_err(&dev->dev, "out of memory\n"); 3150 3150 return -ENOMEM; 3151 3151 } 3152 3152 edge_serial->bulk_in_buffer = 3153 3153 kmalloc(buffer_size, GFP_KERNEL); 3154 3154 if (!edge_serial->bulk_in_buffer) { 3155 - err("out of memory"); 3155 + dev_err(&dev->dev, "out of memory\n"); 3156 3156 usb_free_urb(edge_serial->read_urb); 3157 3157 return -ENOMEM; 3158 3158 } ··· 3181 3181 } 3182 3182 3183 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 3186 return -ENODEV; 3186 3187 } 3187 3188 ··· 3191 3190 response = usb_submit_urb(edge_serial->interrupt_read_urb, 3192 3191 GFP_KERNEL); 3193 3192 if (response) 3194 - err("%s - Error %d submitting control urb", 3195 - __func__, response); 3193 + dev_err(&dev->dev, 3194 + "%s - Error %d submitting control urb\n", 3195 + __func__, response); 3196 3196 } 3197 3197 return response; 3198 3198 } ··· 3255 3253 if (retval) 3256 3254 goto failed_usb_register; 3257 3255 atomic_set(&CmdUrbs, 0); 3258 - info(DRIVER_DESC " " DRIVER_VERSION); 3256 + printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" 3257 + DRIVER_DESC "\n"); 3259 3258 return 0; 3260 3259 3261 3260 failed_usb_register:
+2 -1
drivers/usb/serial/io_ti.c
··· 2978 2978 retval = usb_register(&io_driver); 2979 2979 if (retval) 2980 2980 goto failed_usb_register; 2981 - info(DRIVER_DESC " " DRIVER_VERSION); 2981 + printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" 2982 + DRIVER_DESC "\n"); 2982 2983 return 0; 2983 2984 failed_usb_register: 2984 2985 usb_serial_deregister(&edgeport_2port_device);
+17 -13
drivers/usb/serial/ipaq.c
··· 608 608 bytes_out = 0; 609 609 priv = kmalloc(sizeof(struct ipaq_private), GFP_KERNEL); 610 610 if (priv == NULL) { 611 - err("%s - Out of memory", __func__); 611 + dev_err(&port->dev, "%s - Out of memory\n", __func__); 612 612 return -ENOMEM; 613 613 } 614 614 usb_set_serial_port_data(port, priv); ··· 693 693 } 694 694 695 695 if (!retries && result) { 696 - err("%s - failed doing control urb, error %d", __func__, 697 - result); 696 + dev_err(&port->dev, "%s - failed doing control urb, error %d\n", __func__, result); 698 697 goto error; 699 698 } 700 699 ··· 706 707 707 708 result = usb_submit_urb(port->read_urb, GFP_KERNEL); 708 709 if (result) { 709 - err("%s - failed submitting read urb, error %d", 710 - __func__, result); 710 + dev_err(&port->dev, 711 + "%s - failed submitting read urb, error %d\n", 712 + __func__, result); 711 713 goto error; 712 714 } 713 715 ··· 716 716 717 717 enomem: 718 718 result = -ENOMEM; 719 - err("%s - Out of memory", __func__); 719 + dev_err(&port->dev, "%s - Out of memory\n", __func__); 720 720 error: 721 721 ipaq_destroy_lists(port); 722 722 kfree(priv); ··· 781 781 ipaq_read_bulk_callback, port); 782 782 result = usb_submit_urb(port->read_urb, GFP_ATOMIC); 783 783 if (result) 784 - err("%s - failed resubmitting read urb, error %d", 785 - __func__, result); 784 + dev_err(&port->dev, 785 + "%s - failed resubmitting read urb, error %d\n", 786 + __func__, result); 786 787 return; 787 788 } 788 789 ··· 848 847 spin_unlock_irqrestore(&write_list_lock, flags); 849 848 result = usb_submit_urb(port->write_urb, GFP_ATOMIC); 850 849 if (result) 851 - err("%s - failed submitting write urb, error %d", 850 + dev_err(&port->dev, 851 + "%s - failed submitting write urb, error %d\n", 852 852 __func__, result); 853 853 } else { 854 854 spin_unlock_irqrestore(&write_list_lock, flags); ··· 911 909 spin_unlock_irqrestore(&write_list_lock, flags); 912 910 result = usb_submit_urb(port->write_urb, GFP_ATOMIC); 913 911 if (result) 914 - err("%s - failed submitting write urb, error %d", 915 - __func__, result); 912 + dev_err(&port->dev, 913 + "%s - failed submitting write urb, error %d\n", 914 + __func__, result); 916 915 } else { 917 916 priv->active = 0; 918 917 spin_unlock_irqrestore(&write_list_lock, flags); ··· 960 957 { 961 958 dbg("%s", __func__); 962 959 if (serial->dev->actconfig->desc.bConfigurationValue != 1) { 963 - err("active config #%d != 1 ??", 960 + dev_err(&serial->dev->dev, "active config #%d != 1 ??\n", 964 961 serial->dev->actconfig->desc.bConfigurationValue); 965 962 return -ENODEV; 966 963 } ··· 979 976 retval = usb_serial_register(&ipaq_device); 980 977 if (retval) 981 978 goto failed_usb_serial_register; 982 - info(DRIVER_DESC " " DRIVER_VERSION); 983 979 if (vendor) { 984 980 ipaq_id_table[0].idVendor = vendor; 985 981 ipaq_id_table[0].idProduct = product; ··· 987 985 if (retval) 988 986 goto failed_usb_register; 989 987 988 + printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" 989 + DRIVER_DESC "\n"); 990 990 return 0; 991 991 failed_usb_register: 992 992 usb_serial_deregister(&ipaq_device);
+2 -1
drivers/usb/serial/ipw.c
··· 485 485 usb_serial_deregister(&ipw_device); 486 486 return retval; 487 487 } 488 - info(DRIVER_DESC " " DRIVER_VERSION); 488 + printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" 489 + DRIVER_DESC "\n"); 489 490 return 0; 490 491 } 491 492
+2 -1
drivers/usb/serial/ir-usb.c
··· 602 602 if (retval) 603 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 608 return 0; 608 609
+2 -1
drivers/usb/serial/iuu_phoenix.c
··· 1185 1185 retval = usb_register(&iuu_driver); 1186 1186 if (retval) 1187 1187 goto failed_usb_register; 1188 - info(DRIVER_DESC " " DRIVER_VERSION); 1188 + printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" 1189 + DRIVER_DESC "\n"); 1189 1190 return 0; 1190 1191 failed_usb_register: 1191 1192 usb_serial_deregister(&iuu_device);
+2 -1
drivers/usb/serial/keyspan.c
··· 217 217 if (retval) 218 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 223 return 0; 223 224 failed_usb_register:
+10 -7
drivers/usb/serial/keyspan_pda.c
··· 742 742 fw_name = "keyspan_pda/xircom_pgs.fw"; 743 743 #endif 744 744 else { 745 - err("%s: unknown vendor, aborting.", __func__); 745 + dev_err(&serial->dev->dev, "%s: unknown vendor, aborting.\n", 746 + __func__); 746 747 return -ENODEV; 747 748 } 748 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 752 return -ENOENT; 751 753 } 752 754 record = (const struct ihex_binrec *)fw->data; ··· 758 756 (unsigned char *)record->data, 759 757 be16_to_cpu(record->len), 0xa0); 760 758 if (response < 0) { 761 - err("ezusb_writememory failed for Keyspan PDA " 762 - "firmware (%d %04X %p %d)", 763 - response, be32_to_cpu(record->addr), 764 - record->data, be16_to_cpu(record->len)); 759 + dev_err(&serial->dev->dev, "ezusb_writememory failed " 760 + "for Keyspan PDA firmware (%d %04X %p %d)\n", 761 + response, be32_to_cpu(record->addr), 762 + record->data, be16_to_cpu(record->len)); 765 763 break; 766 764 } 767 765 record = ihex_next_binrec(record); ··· 876 874 retval = usb_register(&keyspan_pda_driver); 877 875 if (retval) 878 876 goto failed_usb_register; 879 - info(DRIVER_DESC " " DRIVER_VERSION); 877 + printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" 878 + DRIVER_DESC "\n"); 880 879 return 0; 881 880 failed_usb_register: 882 881 #ifdef XIRCOM
+41 -28
drivers/usb/serial/kl5kusb105.c
··· 182 182 sizeof(struct klsi_105_port_settings), 183 183 KLSI_TIMEOUT); 184 184 if (rc < 0) 185 - err("Change port settings failed (error = %d)", rc); 186 - info("%s - %d byte block, baudrate %x, databits %d, u1 %d, u2 %d", 187 - __func__, 188 - settings->pktlen, 189 - settings->baudrate, settings->databits, 190 - settings->unknown1, settings->unknown2); 185 + dev_err(&port->dev, 186 + "Change port settings failed (error = %d)\n", rc); 187 + dev_info(&port->serial->dev->dev, 188 + "%d byte block, baudrate %x, databits %d, u1 %d, u2 %d\n", 189 + settings->pktlen, settings->baudrate, settings->databits, 190 + settings->unknown1, settings->unknown2); 191 191 return rc; 192 192 } /* klsi_105_chg_port_settings */ 193 193 ··· 215 215 __u8 status_buf[KLSI_STATUSBUF_LEN] = { -1, -1}; 216 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 219 rc = usb_control_msg(port->serial->dev, 220 220 usb_rcvctrlpipe(port->serial->dev, 0), 221 221 KL5KUSB105A_SIO_POLL, ··· 226 226 10000 227 227 ); 228 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 231 else { 231 232 status = get_unaligned_le16(status_buf); 232 233 233 - info("%s - read status %x %x", __func__, 234 - status_buf[0], status_buf[1]); 234 + dev_info(&port->serial->dev->dev, "read status %x %x", 235 + status_buf[0], status_buf[1]); 235 236 236 237 *line_state_p = klsi_105_status2linestate(status); 237 238 } ··· 281 280 282 281 priv->write_urb_pool[j] = urb; 283 282 if (urb == NULL) { 284 - err("No more urbs???"); 283 + dev_err(&serial->dev->dev, "No more urbs???\n"); 285 284 goto err_cleanup; 286 285 } 287 286 288 287 urb->transfer_buffer = 289 288 kmalloc(URB_TRANSFER_BUFFER_SIZE, GFP_KERNEL); 290 289 if (!urb->transfer_buffer) { 291 - err("%s - out of memory for urb buffers.", 292 - __func__); 290 + dev_err(&serial->dev->dev, 291 + "%s - out of memory for urb buffers.\n", 292 + __func__); 293 293 goto err_cleanup; 294 294 } 295 295 } ··· 411 409 412 410 rc = usb_submit_urb(port->read_urb, GFP_KERNEL); 413 411 if (rc) { 414 - err("%s - failed submitting read urb, error %d", __func__, rc); 412 + dev_err(&port->dev, "%s - failed submitting read urb, " 413 + "error %d\n", __func__, rc); 415 414 retval = rc; 416 415 goto exit; 417 416 } ··· 427 424 0, 428 425 KLSI_TIMEOUT); 429 426 if (rc < 0) { 430 - err("Enabling read failed (error = %d)", rc); 427 + dev_err(&port->dev, "Enabling read failed (error = %d)\n", rc); 431 428 retval = rc; 432 429 } else 433 430 dbg("%s - enabled reading", __func__); ··· 467 464 NULL, 0, 468 465 KLSI_TIMEOUT); 469 466 if (rc < 0) 470 - err("Disabling read failed (error = %d)", rc); 467 + dev_err(&port->dev, 468 + "Disabling read failed (error = %d)\n", rc); 471 469 } 472 470 mutex_unlock(&port->serial->disc_mutex); 473 471 ··· 479 475 /* FIXME */ 480 476 /* wgg - do I need this? I think so. */ 481 477 usb_kill_urb(port->interrupt_in_urb); 482 - info("kl5kusb105 port stats: %ld bytes in, %ld bytes out", 483 - priv->bytes_in, priv->bytes_out); 478 + dev_info(&port->serial->dev->dev, 479 + "port stats: %ld bytes in, %ld bytes out\n", 480 + priv->bytes_in, priv->bytes_out); 484 481 } /* klsi_105_close */ 485 482 486 483 ··· 527 522 urb->transfer_buffer = 528 523 kmalloc(URB_TRANSFER_BUFFER_SIZE, GFP_ATOMIC); 529 524 if (urb->transfer_buffer == NULL) { 530 - err("%s - no more kernel memory...", __func__); 525 + dev_err(&port->dev, 526 + "%s - no more kernel memory...\n", 527 + __func__); 531 528 goto exit; 532 529 } 533 530 } ··· 556 549 /* send the data out the bulk port */ 557 550 result = usb_submit_urb(urb, GFP_ATOMIC); 558 551 if (result) { 559 - err("%s - failed submitting write urb, error %d", 560 - __func__, result); 552 + dev_err(&port->dev, 553 + "%s - failed submitting write urb, error %d\n", 554 + __func__, result); 561 555 goto exit; 562 556 } 563 557 buf += size; ··· 702 694 port); 703 695 rc = usb_submit_urb(port->read_urb, GFP_ATOMIC); 704 696 if (rc) 705 - err("%s - failed resubmitting read urb, error %d", 706 - __func__, rc); 697 + dev_err(&port->dev, 698 + "%s - failed resubmitting read urb, error %d\n", 699 + __func__, rc); 707 700 } /* klsi_105_read_bulk_callback */ 708 701 709 702 ··· 808 799 priv->cfg.databits = kl5kusb105a_dtb_8; 809 800 break; 810 801 default: 811 - err("CSIZE was not CS5-CS8, using default of 8"); 802 + dev_err(&port->dev, 803 + "CSIZE was not CS5-CS8, using default of 8\n"); 812 804 priv->cfg.databits = kl5kusb105a_dtb_8; 813 805 break; 814 806 } ··· 896 886 897 887 rc = klsi_105_get_line_state(port, &line_state); 898 888 if (rc < 0) { 899 - err("Reading line control failed (error = %d)", rc); 889 + dev_err(&port->dev, 890 + "Reading line control failed (error = %d)\n", rc); 900 891 /* better return value? EAGAIN? */ 901 892 return rc; 902 893 } ··· 955 944 port->read_urb->dev = port->serial->dev; 956 945 result = usb_submit_urb(port->read_urb, GFP_ATOMIC); 957 946 if (result) 958 - err("%s - failed submitting read urb, error %d", __func__, 959 - result); 947 + dev_err(&port->dev, 948 + "%s - failed submitting read urb, error %d\n", 949 + __func__, result); 960 950 } 961 951 962 952 ··· 972 960 if (retval) 973 961 goto failed_usb_register; 974 962 975 - info(DRIVER_DESC " " DRIVER_VERSION); 963 + printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" 964 + DRIVER_DESC "\n"); 976 965 return 0; 977 966 failed_usb_register: 978 967 usb_serial_deregister(&kl5kusb105d_device);
+2 -2
drivers/usb/serial/kobil_sct.c
··· 744 744 if (retval) 745 745 goto failed_usb_register; 746 746 747 - info(DRIVER_VERSION " " DRIVER_AUTHOR); 748 - info(DRIVER_DESC); 747 + printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" 748 + DRIVER_DESC "\n"); 749 749 750 750 return 0; 751 751 failed_usb_register:
+26 -16
drivers/usb/serial/mct_u232.c
··· 246 246 0, 0, &divisor, MCT_U232_SET_BAUD_RATE_SIZE, 247 247 WDR_TIMEOUT); 248 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 251 else 251 252 tty_encode_baud_rate(tty, speed, speed); 252 253 dbg("set_baud_rate: value: 0x%x, divisor: 0x%x", value, divisor); ··· 275 274 0, 0, &zero_byte, MCT_U232_SET_UNKNOWN1_SIZE, 276 275 WDR_TIMEOUT); 277 276 if (rc < 0) 278 - err("Sending USB device request code %d failed (error = %d)", 279 - MCT_U232_SET_UNKNOWN1_REQUEST, rc); 277 + dev_err(&port->dev, "Sending USB device request code %d " 278 + "failed (error = %d)\n", MCT_U232_SET_UNKNOWN1_REQUEST, 279 + rc); 280 280 281 281 if (port && C_CRTSCTS(tty)) 282 282 cts_enable_byte = 1; ··· 290 288 0, 0, &cts_enable_byte, MCT_U232_SET_CTS_SIZE, 291 289 WDR_TIMEOUT); 292 290 if (rc < 0) 293 - err("Sending USB device request code %d failed (error = %d)", 294 - MCT_U232_SET_CTS_REQUEST, rc); 291 + dev_err(&port->dev, "Sending USB device request code %d " 292 + "failed (error = %d)\n", MCT_U232_SET_CTS_REQUEST, rc); 295 293 296 294 return rc; 297 295 } /* mct_u232_set_baud_rate */ ··· 305 303 0, 0, &lcr, MCT_U232_SET_LINE_CTRL_SIZE, 306 304 WDR_TIMEOUT); 307 305 if (rc < 0) 308 - err("Set LINE CTRL 0x%x failed (error = %d)", lcr, rc); 306 + dev_err(&serial->dev->dev, 307 + "Set LINE CTRL 0x%x failed (error = %d)\n", lcr, rc); 309 308 dbg("set_line_ctrl: 0x%x", lcr); 310 309 return rc; 311 310 } /* mct_u232_set_line_ctrl */ ··· 328 325 0, 0, &mcr, MCT_U232_SET_MODEM_CTRL_SIZE, 329 326 WDR_TIMEOUT); 330 327 if (rc < 0) 331 - err("Set MODEM CTRL 0x%x failed (error = %d)", mcr, rc); 328 + dev_err(&serial->dev->dev, 329 + "Set MODEM CTRL 0x%x failed (error = %d)\n", mcr, rc); 332 330 dbg("set_modem_ctrl: state=0x%x ==> mcr=0x%x", control_state, mcr); 333 331 334 332 return rc; ··· 345 341 0, 0, msr, MCT_U232_GET_MODEM_STAT_SIZE, 346 342 WDR_TIMEOUT); 347 343 if (rc < 0) { 348 - err("Get MODEM STATus failed (error = %d)", rc); 344 + dev_err(&serial->dev->dev, 345 + "Get MODEM STATus failed (error = %d)\n", rc); 349 346 *msr = 0; 350 347 } 351 348 dbg("get_modem_stat: 0x%x", *msr); ··· 475 470 port->read_urb->dev = port->serial->dev; 476 471 retval = usb_submit_urb(port->read_urb, GFP_KERNEL); 477 472 if (retval) { 478 - err("usb_submit_urb(read bulk) failed pipe 0x%x err %d", 479 - port->read_urb->pipe, retval); 473 + dev_err(&port->dev, 474 + "usb_submit_urb(read bulk) failed pipe 0x%x err %d\n", 475 + port->read_urb->pipe, retval); 480 476 goto error; 481 477 } 482 478 ··· 485 479 retval = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); 486 480 if (retval) { 487 481 usb_kill_urb(port->read_urb); 488 - err(" usb_submit_urb(read int) failed pipe 0x%x err %d", 489 - port->interrupt_in_urb->pipe, retval); 482 + dev_err(&port->dev, 483 + "usb_submit_urb(read int) failed pipe 0x%x err %d", 484 + port->interrupt_in_urb->pipe, retval); 490 485 goto error; 491 486 } 492 487 return 0; ··· 619 612 exit: 620 613 retval = usb_submit_urb(urb, GFP_ATOMIC); 621 614 if (retval) 622 - err("%s - usb_submit_urb failed with result %d", 623 - __func__, retval); 615 + dev_err(&port->dev, 616 + "%s - usb_submit_urb failed with result %d\n", 617 + __func__, retval); 624 618 } /* mct_u232_read_int_callback */ 625 619 626 620 static void mct_u232_set_termios(struct tty_struct *tty, ··· 688 680 case CS8: 689 681 last_lcr |= MCT_U232_DATA_BITS_8; break; 690 682 default: 691 - err("CSIZE was not CS5-CS8, using default of 8"); 683 + dev_err(&port->dev, 684 + "CSIZE was not CS5-CS8, using default of 8\n"); 692 685 last_lcr |= MCT_U232_DATA_BITS_8; 693 686 break; 694 687 } ··· 826 817 retval = usb_register(&mct_u232_driver); 827 818 if (retval) 828 819 goto failed_usb_register; 829 - info(DRIVER_DESC " " DRIVER_VERSION); 820 + printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" 821 + DRIVER_DESC "\n"); 830 822 return 0; 831 823 failed_usb_register: 832 824 usb_serial_deregister(&mct_u232_device);
+13 -9
drivers/usb/serial/mos7720.c
··· 355 355 mos7720_port->write_urb_pool[j] = urb; 356 356 357 357 if (urb == NULL) { 358 - err("No more urbs???"); 358 + dev_err(&port->dev, "No more urbs???\n"); 359 359 continue; 360 360 } 361 361 362 362 urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE, 363 363 GFP_KERNEL); 364 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 368 usb_free_urb(mos7720_port->write_urb_pool[j]); 367 369 mos7720_port->write_urb_pool[j] = NULL; 368 370 continue; ··· 696 694 urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE, 697 695 GFP_KERNEL); 698 696 if (urb->transfer_buffer == NULL) { 699 - err("%s no more kernel memory...", __func__); 697 + dev_err(&port->dev, "%s no more kernel memory...\n", 698 + __func__); 700 699 goto exit; 701 700 } 702 701 } ··· 717 714 /* send it down the pipe */ 718 715 status = usb_submit_urb(urb, GFP_ATOMIC); 719 716 if (status) { 720 - err("%s - usb_submit_urb(write bulk) failed with status = %d", 721 - __func__, status); 717 + dev_err(&port->dev, "%s - usb_submit_urb(write bulk) failed " 718 + "with status = %d\n", __func__, status); 722 719 bytes_sent = status; 723 720 goto exit; 724 721 } ··· 978 975 /* Calculate the Divisor */ 979 976 status = calc_baud_rate_divisor(baudrate, &divisor); 980 977 if (status) { 981 - err("%s - bad baud rate", __func__); 978 + dev_err(&port->dev, "%s - bad baud rate\n", __func__); 982 979 return status; 983 980 } 984 981 ··· 1481 1478 /* create our private serial structure */ 1482 1479 mos7720_serial = kzalloc(sizeof(struct moschip_serial), GFP_KERNEL); 1483 1480 if (mos7720_serial == NULL) { 1484 - err("%s - Out of memory", __func__); 1481 + dev_err(&dev->dev, "%s - Out of memory\n", __func__); 1485 1482 return -ENOMEM; 1486 1483 } 1487 1484 ··· 1494 1491 for (i = 0; i < serial->num_ports; ++i) { 1495 1492 mos7720_port = kzalloc(sizeof(struct moschip_port), GFP_KERNEL); 1496 1493 if (mos7720_port == NULL) { 1497 - err("%s - Out of memory", __func__); 1494 + dev_err(&dev->dev, "%s - Out of memory\n", __func__); 1498 1495 usb_set_serial_data(serial, NULL); 1499 1496 kfree(mos7720_serial); 1500 1497 return -ENOMEM; ··· 1588 1585 if (retval) 1589 1586 goto failed_port_device_register; 1590 1587 1591 - info(DRIVER_DESC " " DRIVER_VERSION); 1588 + printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" 1589 + DRIVER_DESC "\n"); 1592 1590 1593 1591 /* Register with the usb */ 1594 1592 retval = usb_register(&usb_driver);
+16 -13
drivers/usb/serial/mos7840.c
··· 844 844 mos7840_port->write_urb_pool[j] = urb; 845 845 846 846 if (urb == NULL) { 847 - err("No more urbs???"); 847 + dev_err(&port->dev, "No more urbs???\n"); 848 848 continue; 849 849 } 850 850 ··· 853 853 if (!urb->transfer_buffer) { 854 854 usb_free_urb(urb); 855 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 859 continue; 858 860 } 859 861 } ··· 1023 1021 usb_submit_urb(serial->port[0]->interrupt_in_urb, 1024 1022 GFP_KERNEL); 1025 1023 if (response) { 1026 - err("%s - Error %d submitting interrupt urb", 1027 - __func__, response); 1024 + dev_err(&port->dev, "%s - Error %d submitting " 1025 + "interrupt urb\n", __func__, response); 1028 1026 } 1029 1027 1030 1028 } ··· 1057 1055 port->bulk_in_endpointAddress); 1058 1056 response = usb_submit_urb(mos7840_port->read_urb, GFP_KERNEL); 1059 1057 if (response) { 1060 - err("%s - Error %d submitting control urb", __func__, 1061 - response); 1058 + dev_err(&port->dev, "%s - Error %d submitting control urb\n", 1059 + __func__, response); 1062 1060 } 1063 1061 1064 1062 /* initialize our wait queues */ ··· 1494 1492 kmalloc(URB_TRANSFER_BUFFER_SIZE, GFP_KERNEL); 1495 1493 1496 1494 if (urb->transfer_buffer == NULL) { 1497 - err("%s no more kernel memory...", __func__); 1495 + dev_err(&port->dev, "%s no more kernel memory...\n", 1496 + __func__); 1498 1497 goto exit; 1499 1498 } 1500 1499 } ··· 1520 1517 1521 1518 if (status) { 1522 1519 mos7840_port->busy[i] = 0; 1523 - err("%s - usb_submit_urb(write bulk) failed with status = %d", 1524 - __func__, status); 1520 + dev_err(&port->dev, "%s - usb_submit_urb(write bulk) failed " 1521 + "with status = %d\n", __func__, status); 1525 1522 bytes_sent = status; 1526 1523 goto exit; 1527 1524 } ··· 1859 1856 /* Calculate the Divisor */ 1860 1857 1861 1858 if (status) { 1862 - err("%s - bad baud rate", __func__); 1863 - dbg("%s\n", "bad baud rate"); 1859 + dev_err(&port->dev, "%s - bad baud rate\n", __func__); 1864 1860 return status; 1865 1861 } 1866 1862 /* Enable access to divisor latch */ ··· 2448 2446 for (i = 0; i < serial->num_ports; ++i) { 2449 2447 mos7840_port = kzalloc(sizeof(struct moschip_port), GFP_KERNEL); 2450 2448 if (mos7840_port == NULL) { 2451 - err("%s - Out of memory", __func__); 2449 + dev_err(&dev->dev, "%s - Out of memory\n", __func__); 2452 2450 status = -ENOMEM; 2453 2451 i--; /* don't follow NULL pointer cleaning up */ 2454 2452 goto error; ··· 2745 2743 goto failed_port_device_register; 2746 2744 2747 2745 dbg("%s\n", "Entring..."); 2748 - info(DRIVER_DESC " " DRIVER_VERSION); 2746 + printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" 2747 + DRIVER_DESC "\n"); 2749 2748 2750 2749 /* Register with the usb */ 2751 2750 retval = usb_register(&io_driver);
+13 -9
drivers/usb/serial/omninet.c
··· 154 154 155 155 od = kmalloc(sizeof(struct omninet_data), GFP_KERNEL); 156 156 if (!od) { 157 - err("%s- kmalloc(%Zd) failed.", 158 - __func__, sizeof(struct omninet_data)); 157 + dev_err(&port->dev, "%s- kmalloc(%Zd) failed.\n", 158 + __func__, sizeof(struct omninet_data)); 159 159 return -ENOMEM; 160 160 } 161 161 usb_set_serial_port_data(port, od); ··· 183 183 omninet_read_bulk_callback, port); 184 184 result = usb_submit_urb(port->read_urb, GFP_KERNEL); 185 185 if (result) 186 - err("%s - failed submitting read urb, error %d", 187 - __func__, result); 186 + dev_err(&port->dev, 187 + "%s - failed submitting read urb, error %d\n", 188 + __func__, result); 188 189 return result; 189 190 } 190 191 ··· 245 244 omninet_read_bulk_callback, port); 246 245 result = usb_submit_urb(urb, GFP_ATOMIC); 247 246 if (result) 248 - err("%s - failed resubmitting read urb, error %d", 249 - __func__, result); 247 + dev_err(&port->dev, 248 + "%s - failed resubmitting read urb, error %d\n", 249 + __func__, result); 250 250 251 251 return; 252 252 } ··· 300 298 result = usb_submit_urb(wport->write_urb, GFP_ATOMIC); 301 299 if (result) { 302 300 wport->write_urb_busy = 0; 303 - err("%s - failed submitting write urb, error %d", 304 - __func__, result); 301 + dev_err(&port->dev, 302 + "%s - failed submitting write urb, error %d\n", 303 + __func__, result); 305 304 } else 306 305 result = count; 307 306 ··· 367 364 retval = usb_register(&omninet_driver); 368 365 if (retval) 369 366 goto failed_usb_register; 370 - info(DRIVER_VERSION ":" DRIVER_DESC); 367 + printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" 368 + DRIVER_DESC "\n"); 371 369 return 0; 372 370 failed_usb_register: 373 371 usb_serial_deregister(&zyxel_omninet_device);
+18 -24
drivers/usb/serial/option.c
··· 79 79 #define OPTION_PRODUCT_VIPER 0x6600 80 80 #define OPTION_PRODUCT_VIPER_BUS 0x6601 81 81 #define OPTION_PRODUCT_GT_MAX_READY 0x6701 82 - #define OPTION_PRODUCT_GT_MAX 0x6711 83 82 #define OPTION_PRODUCT_FUJI_MODEM_LIGHT 0x6721 84 83 #define OPTION_PRODUCT_FUJI_MODEM_GT 0x6741 85 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 85 #define OPTION_PRODUCT_KOI_MODEM 0x6800 90 - #define OPTION_PRODUCT_KOI_NETWORK 0x6811 91 86 #define OPTION_PRODUCT_SCORPION_MODEM 0x6901 92 - #define OPTION_PRODUCT_SCORPION_NETWORK 0x6911 93 87 #define OPTION_PRODUCT_ETNA_MODEM 0x7001 94 - #define OPTION_PRODUCT_ETNA_NETWORK 0x7011 95 88 #define OPTION_PRODUCT_ETNA_MODEM_LITE 0x7021 96 89 #define OPTION_PRODUCT_ETNA_MODEM_GT 0x7041 97 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 91 #define OPTION_PRODUCT_ETNA_KOI_MODEM 0x7100 102 - #define OPTION_PRODUCT_ETNA_KOI_NETWORK 0x7111 103 92 104 93 #define HUAWEI_VENDOR_ID 0x12D1 105 94 #define HUAWEI_PRODUCT_E600 0x1001 ··· 209 220 #define ZTE_PRODUCT_MF628 0x0015 210 221 #define ZTE_PRODUCT_CDMA_TECH 0xfffe 211 222 223 + /* Ericsson products */ 224 + #define ERICSSON_VENDOR_ID 0x0bdb 225 + #define ERICSSON_PRODUCT_F3507G 0x1900 226 + 227 + /* Pantech products */ 228 + #define PANTECH_VENDOR_ID 0x106c 229 + #define PANTECH_PRODUCT_PC5740 0x3701 230 + #define PANTECH_PRODUCT_PC5750 0x3702 /* PX-500 */ 231 + #define PANTECH_PRODUCT_UM150 0x3711 232 + 212 233 static struct usb_device_id option_ids[] = { 213 234 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) }, 214 235 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) }, ··· 234 235 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_VIPER) }, 235 236 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_VIPER_BUS) }, 236 237 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_GT_MAX_READY) }, 237 - { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_GT_MAX) }, 238 238 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUJI_MODEM_LIGHT) }, 239 239 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUJI_MODEM_GT) }, 240 240 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUJI_MODEM_EX) }, 241 - { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUJI_NETWORK_LIGHT) }, 242 - { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUJI_NETWORK_GT) }, 243 - { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUJI_NETWORK_EX) }, 244 241 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_KOI_MODEM) }, 245 - { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_KOI_NETWORK) }, 246 242 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_SCORPION_MODEM) }, 247 - { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_SCORPION_NETWORK) }, 248 243 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_MODEM) }, 249 - { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_NETWORK) }, 250 244 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_MODEM_LITE) }, 251 245 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_MODEM_GT) }, 252 246 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_MODEM_EX) }, 253 - { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_NETWORK_LITE) }, 254 - { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_NETWORK_GT) }, 255 - { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_NETWORK_EX) }, 256 247 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_KOI_MODEM) }, 257 - { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_KOI_NETWORK) }, 258 248 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E600, 0xff, 0xff, 0xff) }, 259 249 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E220, 0xff, 0xff, 0xff) }, 260 250 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E220BIS, 0xff, 0xff, 0xff) }, ··· 306 318 { USB_DEVICE(DELL_VENDOR_ID, 0x8136) }, /* Dell Wireless HSDPA 5520 == Novatel Expedite EU860D */ 307 319 { USB_DEVICE(DELL_VENDOR_ID, 0x8137) }, /* Dell Wireless HSDPA 5520 */ 308 320 { USB_DEVICE(DELL_VENDOR_ID, 0x8138) }, /* Dell Wireless 5520 Voda I Mobile Broadband (3G HSDPA) Minicard */ 309 - { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_E100A) }, 321 + { USB_DEVICE(DELL_VENDOR_ID, 0x8147) }, /* Dell Wireless 5530 Mobile Broadband (3G HSPA) Mini-Card */ 322 + { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_E100A) }, /* ADU-E100, ADU-310 */ 310 323 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_500A) }, 311 324 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_620UW) }, 312 325 { USB_DEVICE(AXESSTEL_VENDOR_ID, AXESSTEL_PRODUCT_MV110H) }, ··· 338 349 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UC864E) }, 339 350 { USB_DEVICE(ZTE_VENDOR_ID, ZTE_PRODUCT_MF628) }, 340 351 { USB_DEVICE(ZTE_VENDOR_ID, ZTE_PRODUCT_CDMA_TECH) }, 352 + { USB_DEVICE(ERICSSON_VENDOR_ID, ERICSSON_PRODUCT_F3507G) }, 353 + { USB_DEVICE(PANTECH_VENDOR_ID, PANTECH_PRODUCT_PC5740) }, 354 + { USB_DEVICE(PANTECH_VENDOR_ID, PANTECH_PRODUCT_PC5750) }, 355 + { USB_DEVICE(PANTECH_VENDOR_ID, PANTECH_PRODUCT_UM150) }, 341 356 { } /* Terminating entry */ 342 357 }; 343 358 MODULE_DEVICE_TABLE(usb, option_ids); ··· 420 427 if (retval) 421 428 goto failed_driver_register; 422 429 423 - info(DRIVER_DESC ": " DRIVER_VERSION); 430 + printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" 431 + DRIVER_DESC "\n"); 424 432 425 433 return 0; 426 434
+1 -1
drivers/usb/serial/pl2303.c
··· 1147 1147 retval = usb_register(&pl2303_driver); 1148 1148 if (retval) 1149 1149 goto failed_usb_register; 1150 - info(DRIVER_DESC); 1150 + printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_DESC "\n"); 1151 1151 return 0; 1152 1152 failed_usb_register: 1153 1153 usb_serial_deregister(&pl2303_device);
+15 -13
drivers/usb/serial/safe_serial.c
··· 250 250 if (!fcs) { 251 251 int actual_length = data[length - 2] >> 2; 252 252 if (actual_length <= (length - 2)) { 253 - info("%s - actual: %d", __func__, 254 - actual_length); 253 + dev_info(&urb->dev->dev, "%s - actual: %d\n", 254 + __func__, actual_length); 255 255 tty_insert_flip_string(tty, 256 256 data, actual_length); 257 257 tty_flip_buffer_push(tty); 258 258 } else { 259 - err("%s - inconsistent lengths %d:%d", 259 + dev_err(&port->dev, 260 + "%s - inconsistent lengths %d:%d\n", 260 261 __func__, actual_length, length); 261 262 } 262 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 266 } else { 266 267 tty_insert_flip_string(tty, data, length); ··· 278 277 279 278 result = usb_submit_urb(urb, GFP_ATOMIC); 280 279 if (result) 281 - err("%s - failed resubmitting read urb, error %d", 282 - __func__, result); 280 + dev_err(&port->dev, 281 + "%s - failed resubmitting read urb, error %d\n", 282 + __func__, result); 283 283 /* FIXME: Need a mechanism to retry later if this happens */ 284 284 } 285 285 ··· 371 369 result = usb_submit_urb(port->write_urb, GFP_KERNEL); 372 370 if (result) { 373 371 port->write_urb_busy = 0; 374 - err("%s - failed submitting write urb, error %d", 375 - __func__, result); 372 + dev_err(&port->dev, 373 + "%s - failed submitting write urb, error %d\n", 374 + __func__, result); 376 375 return 0; 377 376 } 378 377 dbg("%s urb: %p submitted", __func__, port->write_urb); ··· 431 428 { 432 429 int i, retval; 433 430 434 - info(DRIVER_VERSION " " DRIVER_AUTHOR); 435 - info(DRIVER_DESC); 436 - info("vendor: %x product: %x safe: %d padded: %d\n", 437 - vendor, product, safe, padded); 431 + printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" 432 + DRIVER_DESC "\n"); 438 433 439 434 /* if we have vendor / product parameters patch them into id list */ 440 435 if (vendor || product) { 441 - info("vendor: %x product: %x\n", vendor, product); 436 + printk(KERN_INFO KBUILD_MODNAME ": vendor: %x product: %x\n", 437 + vendor, product); 442 438 443 439 for (i = 0; i < ARRAY_SIZE(id_table); i++) { 444 440 if (!id_table[i].idVendor && !id_table[i].idProduct) {
+40 -32
drivers/usb/serial/sierra.c
··· 247 247 struct sierra_port_private *portdata; 248 248 __u16 interface = 0; 249 249 250 - dbg("%s", __func__); 250 + dev_dbg(&port->dev, "%s", __func__); 251 251 252 252 portdata = usb_get_serial_port_data(port); 253 253 ··· 284 284 static void sierra_set_termios(struct tty_struct *tty, 285 285 struct usb_serial_port *port, struct ktermios *old_termios) 286 286 { 287 - dbg("%s", __func__); 287 + dev_dbg(&port->dev, "%s", __func__); 288 288 tty_termios_copy_hw(tty->termios, old_termios); 289 289 sierra_send_setup(tty, port); 290 290 } ··· 295 295 unsigned int value; 296 296 struct sierra_port_private *portdata; 297 297 298 + dev_dbg(&port->dev, "%s", __func__); 298 299 portdata = usb_get_serial_port_data(port); 299 300 300 301 value = ((portdata->rts_state) ? TIOCM_RTS : 0) | ··· 335 334 int status = urb->status; 336 335 unsigned long flags; 337 336 338 - dbg("%s - port %d", __func__, port->number); 337 + dev_dbg(&port->dev, "%s - port %d", __func__, port->number); 339 338 340 339 /* free up the transfer buffer, as usb_free_urb() does not do this */ 341 340 kfree(urb->transfer_buffer); 342 341 343 342 if (status) 344 - dbg("%s - nonzero write bulk status received: %d", 345 - __func__, status); 343 + dev_dbg(&port->dev, "%s - nonzero write bulk status " 344 + "received: %d", __func__, status); 346 345 347 346 spin_lock_irqsave(&portdata->lock, flags); 348 347 --portdata->outstanding_urbs; ··· 364 363 365 364 portdata = usb_get_serial_port_data(port); 366 365 367 - dbg("%s: write (%d chars)", __func__, count); 366 + dev_dbg(&port->dev, "%s: write (%d chars)", __func__, count); 368 367 369 368 spin_lock_irqsave(&portdata->lock, flags); 370 369 if (portdata->outstanding_urbs > N_OUT_URB) { 371 370 spin_unlock_irqrestore(&portdata->lock, flags); 372 - dbg("%s - write limit hit\n", __func__); 371 + dev_dbg(&port->dev, "%s - write limit hit\n", __func__); 373 372 return 0; 374 373 } 375 374 portdata->outstanding_urbs++; ··· 438 437 port = urb->context; 439 438 440 439 if (status) { 441 - dbg("%s: nonzero status: %d on endpoint %02x.", 442 - __func__, status, endpoint); 440 + dev_dbg(&port->dev, "%s: nonzero status: %d on" 441 + " endpoint %02x.", __func__, status, endpoint); 443 442 } else { 444 443 if (urb->actual_length) { 445 444 tty = tty_port_tty_get(&port->port); ··· 448 447 tty_flip_buffer_push(tty); 449 448 tty_kref_put(tty); 450 449 } else 451 - dbg("%s: empty read urb received", __func__); 450 + dev_dbg(&port->dev, "%s: empty read urb" 451 + " received", __func__); 452 452 453 453 /* Resubmit urb so we continue receiving */ 454 454 if (port->port.count && status != -ESHUTDOWN) { ··· 470 468 struct sierra_port_private *portdata = usb_get_serial_port_data(port); 471 469 struct usb_serial *serial = port->serial; 472 470 473 - dbg("%s", __func__); 474 - dbg("%s: urb %p port %p has data %p", __func__, urb, port, portdata); 471 + dev_dbg(&port->dev, "%s", __func__); 472 + dev_dbg(&port->dev, "%s: urb %p port %p has data %p", __func__, 473 + urb, port, portdata); 475 474 476 475 if (status == 0) { 477 476 struct usb_ctrlrequest *req_pkt = 478 477 (struct usb_ctrlrequest *)urb->transfer_buffer; 479 478 480 479 if (!req_pkt) { 481 - dbg("%s: NULL req_pkt\n", __func__); 480 + dev_dbg(&port->dev, "%s: NULL req_pkt\n", 481 + __func__); 482 482 return; 483 483 } 484 484 if ((req_pkt->bRequestType == 0xA1) && ··· 491 487 sizeof(struct usb_ctrlrequest)); 492 488 struct tty_struct *tty; 493 489 494 - dbg("%s: signal x%x", __func__, signals); 490 + dev_dbg(&port->dev, "%s: signal x%x", __func__, 491 + signals); 495 492 496 493 old_dcd_state = portdata->dcd_state; 497 494 portdata->cts_state = 1; ··· 506 501 tty_hangup(tty); 507 502 tty_kref_put(tty); 508 503 } else { 509 - dbg("%s: type %x req %x", __func__, 510 - req_pkt->bRequestType, req_pkt->bRequest); 504 + dev_dbg(&port->dev, "%s: type %x req %x", 505 + __func__, req_pkt->bRequestType, 506 + req_pkt->bRequest); 511 507 } 512 508 } else 513 - dbg("%s: error %d", __func__, status); 509 + dev_dbg(&port->dev, "%s: error %d", __func__, status); 514 510 515 511 /* Resubmit urb so we continue receiving IRQ data */ 516 512 if (status != -ESHUTDOWN) { 517 513 urb->dev = serial->dev; 518 514 err = usb_submit_urb(urb, GFP_ATOMIC); 519 515 if (err) 520 - dbg("%s: resubmit intr urb failed. (%d)", 521 - __func__, err); 516 + dev_dbg(&port->dev, "%s: resubmit intr urb " 517 + "failed. (%d)", __func__, err); 522 518 } 523 519 } 524 520 ··· 529 523 struct sierra_port_private *portdata = usb_get_serial_port_data(port); 530 524 unsigned long flags; 531 525 532 - dbg("%s - port %d", __func__, port->number); 526 + dev_dbg(&port->dev, "%s - port %d", __func__, port->number); 533 527 534 528 /* try to give a good number back based on if we have any free urbs at 535 529 * this point in time */ 536 530 spin_lock_irqsave(&portdata->lock, flags); 537 531 if (portdata->outstanding_urbs > N_OUT_URB * 2 / 3) { 538 532 spin_unlock_irqrestore(&portdata->lock, flags); 539 - dbg("%s - write limit hit\n", __func__); 533 + dev_dbg(&port->dev, "%s - write limit hit\n", __func__); 540 534 return 0; 541 535 } 542 536 spin_unlock_irqrestore(&portdata->lock, flags); ··· 555 549 556 550 portdata = usb_get_serial_port_data(port); 557 551 558 - dbg("%s", __func__); 552 + dev_dbg(&port->dev, "%s", __func__); 559 553 560 554 /* Set some sane defaults */ 561 555 portdata->rts_state = 1; ··· 567 561 if (!urb) 568 562 continue; 569 563 if (urb->dev != serial->dev) { 570 - dbg("%s: dev %p != %p", __func__, 571 - urb->dev, serial->dev); 564 + dev_dbg(&port->dev, "%s: dev %p != %p", 565 + __func__, urb->dev, serial->dev); 572 566 continue; 573 567 } 574 568 ··· 607 601 struct usb_serial *serial = port->serial; 608 602 struct sierra_port_private *portdata; 609 603 610 - dbg("%s", __func__); 604 + dev_dbg(&port->dev, "%s", __func__); 611 605 portdata = usb_get_serial_port_data(port); 612 606 613 607 portdata->rts_state = 0; ··· 636 630 int i; 637 631 int j; 638 632 639 - dbg("%s", __func__); 633 + dev_dbg(&serial->dev->dev, "%s", __func__); 640 634 641 635 /* Set Device mode to D0 */ 642 636 sierra_set_power_state(serial->dev, 0x0000); ··· 650 644 port = serial->port[i]; 651 645 portdata = kzalloc(sizeof(*portdata), GFP_KERNEL); 652 646 if (!portdata) { 653 - dbg("%s: kmalloc for sierra_port_private (%d) failed!.", 654 - __func__, i); 647 + dev_dbg(&port->dev, "%s: kmalloc for " 648 + "sierra_port_private (%d) failed!.", 649 + __func__, i); 655 650 return -ENOMEM; 656 651 } 657 652 spin_lock_init(&portdata->lock); ··· 672 665 for (j = 0; j < N_IN_URB; ++j) { 673 666 urb = usb_alloc_urb(0, GFP_KERNEL); 674 667 if (urb == NULL) { 675 - dbg("%s: alloc for in port failed.", 676 - __func__); 668 + dev_dbg(&port->dev, "%s: alloc for in " 669 + "port failed.", __func__); 677 670 continue; 678 671 } 679 672 /* Fill URB using supplied data. */ ··· 695 688 struct usb_serial_port *port; 696 689 struct sierra_port_private *portdata; 697 690 698 - dbg("%s", __func__); 691 + dev_dbg(&serial->dev->dev, "%s", __func__); 699 692 700 693 for (i = 0; i < serial->num_ports; ++i) { 701 694 port = serial->port[i]; ··· 750 743 if (retval) 751 744 goto failed_driver_register; 752 745 753 - info(DRIVER_DESC ": " DRIVER_VERSION); 746 + printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" 747 + DRIVER_DESC "\n"); 754 748 755 749 return 0; 756 750
+6 -4
drivers/usb/serial/spcp8x5.c
··· 589 589 case 1000000: 590 590 buf[0] = 0x0b; break; 591 591 default: 592 - err("spcp825 driver does not support the baudrate " 593 - "requested, using default of 9600."); 592 + dev_err(&port->dev, "spcp825 driver does not support the " 593 + "baudrate requested, using default of 9600.\n"); 594 594 } 595 595 596 596 /* Set Data Length : 00:5bit, 01:6bit, 10:7bit, 11:8bit */ ··· 629 629 SET_UART_FORMAT_TYPE, SET_UART_FORMAT, 630 630 uartdata, 0, NULL, 0, 100); 631 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 634 dbg("0x21:0x40:0:0 %d\n", i); 634 635 635 636 if (cflag & CRTSCTS) { ··· 1055 1054 retval = usb_register(&spcp8x5_driver); 1056 1055 if (retval) 1057 1056 goto failed_usb_register; 1058 - info(DRIVER_DESC " " DRIVER_VERSION); 1057 + printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" 1058 + DRIVER_DESC "\n"); 1059 1059 return 0; 1060 1060 failed_usb_register: 1061 1061 usb_serial_deregister(&spcp8x5_device);
+2 -2
drivers/usb/serial/ti_usb_3410_5052.c
··· 85 85 #include <linux/uaccess.h> 86 86 #include <linux/usb.h> 87 87 #include <linux/usb/serial.h> 88 - #include <linux/firmware.h> 89 88 90 89 #include "ti_usb_3410_5052.h" 91 90 ··· 382 383 if (ret) 383 384 goto failed_usb; 384 385 385 - info(TI_DRIVER_DESC " " TI_DRIVER_VERSION); 386 + printk(KERN_INFO KBUILD_MODNAME ": " TI_DRIVER_VERSION ":" 387 + TI_DRIVER_DESC "\n"); 386 388 387 389 return 0; 388 390
+16 -10
drivers/usb/serial/usb-serial.c
··· 1121 1121 1122 1122 result = bus_register(&usb_serial_bus_type); 1123 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 1126 goto exit_bus; 1126 1127 } 1127 1128 ··· 1143 1142 tty_set_operations(usb_serial_tty_driver, &serial_ops); 1144 1143 result = tty_register_driver(usb_serial_tty_driver); 1145 1144 if (result) { 1146 - err("%s - tty_register_driver failed", __func__); 1145 + printk(KERN_ERR "usb-serial: %s - tty_register_driver failed\n", 1146 + __func__); 1147 1147 goto exit_reg_driver; 1148 1148 } 1149 1149 1150 1150 /* register the USB driver */ 1151 1151 result = usb_register(&usb_serial_driver); 1152 1152 if (result < 0) { 1153 - err("%s - usb_register failed", __func__); 1153 + printk(KERN_ERR "usb-serial: %s - usb_register failed\n", 1154 + __func__); 1154 1155 goto exit_tty; 1155 1156 } 1156 1157 1157 1158 /* register the generic driver, if we should */ 1158 1159 result = usb_serial_generic_register(debug); 1159 1160 if (result < 0) { 1160 - err("%s - registering generic driver failed", __func__); 1161 + printk(KERN_ERR "usb-serial: %s - registering generic " 1162 + "driver failed\n", __func__); 1161 1163 goto exit_generic; 1162 1164 } 1163 1165 1164 - info(DRIVER_DESC); 1166 + printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_DESC "\n"); 1165 1167 1166 1168 return result; 1167 1169 ··· 1178 1174 bus_unregister(&usb_serial_bus_type); 1179 1175 1180 1176 exit_bus: 1181 - err("%s - returning with error %d", __func__, result); 1177 + printk(KERN_ERR "usb-serial: %s - returning with error %d\n", 1178 + __func__, result); 1182 1179 put_tty_driver(usb_serial_tty_driver); 1183 1180 return result; 1184 1181 } ··· 1238 1233 1239 1234 retval = usb_serial_bus_register(driver); 1240 1235 if (retval) { 1241 - err("problem %d when registering driver %s", 1242 - retval, driver->description); 1236 + printk(KERN_ERR "usb-serial: problem %d when registering " 1237 + "driver %s\n", retval, driver->description); 1243 1238 list_del(&driver->driver_list); 1244 1239 } else 1245 - info("USB Serial support registered for %s", 1240 + printk(KERN_INFO "USB Serial support registered for %s\n", 1246 1241 driver->description); 1247 1242 1248 1243 return retval; ··· 1253 1248 void usb_serial_deregister(struct usb_serial_driver *device) 1254 1249 { 1255 1250 /* must be called with BKL held */ 1256 - info("USB Serial deregistering driver %s", device->description); 1251 + printk(KERN_INFO "USB Serial deregistering driver %s\n", 1252 + device->description); 1257 1253 list_del(&device->driver_list); 1258 1254 usb_serial_bus_deregister(device); 1259 1255 }
+10 -7
drivers/usb/serial/visor.c
··· 768 768 dbg("%s", __func__); 769 769 770 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 772 serial->dev->actconfig->desc.bConfigurationValue); 773 773 return -ENODEV; 774 774 } ··· 971 971 break; 972 972 } 973 973 } 974 - info( 975 - "Untested USB device specified at time of module insertion"); 976 - info("Warning: This is not guaranteed to work"); 977 - info("Using a newer kernel is preferred to this method"); 978 - info("Adding Palm OS protocol 4.x support for unknown device: 0x%x/0x%x", 974 + printk(KERN_INFO KBUILD_MODNAME 975 + ": Untested USB device specified at time of module insertion\n"); 976 + printk(KERN_INFO KBUILD_MODNAME 977 + ": Warning: This is not guaranteed to work\n"); 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 982 vendor, product); 980 983 } 981 984 retval = usb_serial_register(&handspring_device); ··· 993 990 retval = usb_register(&visor_driver); 994 991 if (retval) 995 992 goto failed_usb_register; 996 - info(DRIVER_DESC); 993 + printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_DESC "\n"); 997 994 998 995 return 0; 999 996 failed_usb_register:
+72 -49
drivers/usb/serial/whiteheat.c
··· 303 303 304 304 if (request_ihex_firmware(&firmware_fw, "whiteheat.fw", 305 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 308 goto out; 308 309 } 309 310 if (request_ihex_firmware(&loader_fw, "whiteheat_loader.fw", 310 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 315 goto out; 313 316 } 314 317 ret = 0; ··· 323 320 (unsigned char *)record->data, 324 321 be16_to_cpu(record->len), 0xa0); 325 322 if (response < 0) { 326 - err("%s - ezusb_writememory failed for loader (%d %04X %p %d)", 327 - __func__, response, be32_to_cpu(record->addr), 328 - record->data, be16_to_cpu(record->len)); 323 + dev_err(&serial->dev->dev, "%s - ezusb_writememory " 324 + "failed for loader (%d %04X %p %d)\n", 325 + __func__, response, be32_to_cpu(record->addr), 326 + record->data, be16_to_cpu(record->len)); 329 327 break; 330 328 } 331 329 record = ihex_next_binrec(record); ··· 342 338 (unsigned char *)record->data, 343 339 be16_to_cpu(record->len), 0xa3); 344 340 if (response < 0) { 345 - err("%s - ezusb_writememory failed for first firmware step (%d %04X %p %d)", 346 - __func__, response, be32_to_cpu(record->addr), 347 - record->data, be16_to_cpu(record->len)); 341 + dev_err(&serial->dev->dev, "%s - ezusb_writememory " 342 + "failed for first firmware step " 343 + "(%d %04X %p %d)\n", __func__, response, 344 + be32_to_cpu(record->addr), record->data, 345 + be16_to_cpu(record->len)); 348 346 break; 349 347 } 350 348 ++record; ··· 360 354 (unsigned char *)record->data, 361 355 be16_to_cpu(record->len), 0xa0); 362 356 if (response < 0) { 363 - err("%s - ezusb_writememory failed for second firmware step (%d %04X %p %d)", 364 - __func__, response, be32_to_cpu(record->addr), 365 - record->data, be16_to_cpu(record->len)); 357 + dev_err(&serial->dev->dev, "%s - ezusb_writememory " 358 + "failed for second firmware step " 359 + "(%d %04X %p %d)\n", __func__, response, 360 + be32_to_cpu(record->addr), record->data, 361 + be16_to_cpu(record->len)); 366 362 break; 367 363 } 368 364 ++record; ··· 429 421 ret = usb_bulk_msg(serial->dev, pipe, command, 2, 430 422 &alen, COMMAND_TIMEOUT_MS); 431 423 if (ret) { 432 - err("%s: Couldn't send command [%d]", 433 - serial->type->description, ret); 424 + dev_err(&serial->dev->dev, "%s: Couldn't send command [%d]\n", 425 + serial->type->description, ret); 434 426 goto no_firmware; 435 427 } else if (alen != 2) { 436 - err("%s: Send command incomplete [%d]", 437 - serial->type->description, alen); 428 + dev_err(&serial->dev->dev, "%s: Send command incomplete [%d]\n", 429 + serial->type->description, alen); 438 430 goto no_firmware; 439 431 } 440 432 ··· 445 437 ret = usb_bulk_msg(serial->dev, pipe, result, 446 438 sizeof(*hw_info) + 1, &alen, COMMAND_TIMEOUT_MS); 447 439 if (ret) { 448 - err("%s: Couldn't get results [%d]", 449 - serial->type->description, ret); 440 + dev_err(&serial->dev->dev, "%s: Couldn't get results [%d]\n", 441 + serial->type->description, ret); 450 442 goto no_firmware; 451 443 } else if (alen != sizeof(*hw_info) + 1) { 452 - err("%s: Get results incomplete [%d]", 453 - serial->type->description, alen); 444 + dev_err(&serial->dev->dev, "%s: Get results incomplete [%d]\n", 445 + serial->type->description, alen); 454 446 goto no_firmware; 455 447 } else if (result[0] != command[0]) { 456 - err("%s: Command failed [%d]", 457 - serial->type->description, result[0]); 448 + dev_err(&serial->dev->dev, "%s: Command failed [%d]\n", 449 + serial->type->description, result[0]); 458 450 goto no_firmware; 459 451 } 460 452 461 453 hw_info = (struct whiteheat_hw_info *)&result[1]; 462 454 463 - info("%s: Driver %s: Firmware v%d.%02d", serial->type->description, 464 - DRIVER_VERSION, hw_info->sw_major_rev, hw_info->sw_minor_rev); 455 + dev_info(&serial->dev->dev, "%s: Driver %s: Firmware v%d.%02d\n", 456 + serial->type->description, DRIVER_VERSION, 457 + hw_info->sw_major_rev, hw_info->sw_minor_rev); 465 458 466 459 for (i = 0; i < serial->num_ports; i++) { 467 460 port = serial->port[i]; 468 461 469 462 info = kmalloc(sizeof(struct whiteheat_private), GFP_KERNEL); 470 463 if (info == NULL) { 471 - err("%s: Out of memory for port structures\n", 472 - serial->type->description); 464 + dev_err(&port->dev, 465 + "%s: Out of memory for port structures\n", 466 + serial->type->description); 473 467 goto no_private; 474 468 } 475 469 ··· 491 481 for (j = 0; j < urb_pool_size; j++) { 492 482 urb = usb_alloc_urb(0, GFP_KERNEL); 493 483 if (!urb) { 494 - err("No free urbs available"); 484 + dev_err(&port->dev, "No free urbs available\n"); 495 485 goto no_rx_urb; 496 486 } 497 487 buf_size = port->read_urb->transfer_buffer_length; 498 488 urb->transfer_buffer = kmalloc(buf_size, GFP_KERNEL); 499 489 if (!urb->transfer_buffer) { 500 - err("Couldn't allocate urb buffer"); 490 + dev_err(&port->dev, 491 + "Couldn't allocate urb buffer\n"); 501 492 goto no_rx_buf; 502 493 } 503 494 wrap = kmalloc(sizeof(*wrap), GFP_KERNEL); 504 495 if (!wrap) { 505 - err("Couldn't allocate urb wrapper"); 496 + dev_err(&port->dev, 497 + "Couldn't allocate urb wrapper\n"); 506 498 goto no_rx_wrap; 507 499 } 508 500 usb_fill_bulk_urb(urb, serial->dev, ··· 517 505 518 506 urb = usb_alloc_urb(0, GFP_KERNEL); 519 507 if (!urb) { 520 - err("No free urbs available"); 508 + dev_err(&port->dev, "No free urbs available\n"); 521 509 goto no_tx_urb; 522 510 } 523 511 buf_size = port->write_urb->transfer_buffer_length; 524 512 urb->transfer_buffer = kmalloc(buf_size, GFP_KERNEL); 525 513 if (!urb->transfer_buffer) { 526 - err("Couldn't allocate urb buffer"); 514 + dev_err(&port->dev, 515 + "Couldn't allocate urb buffer\n"); 527 516 goto no_tx_buf; 528 517 } 529 518 wrap = kmalloc(sizeof(*wrap), GFP_KERNEL); 530 519 if (!wrap) { 531 - err("Couldn't allocate urb wrapper"); 520 + dev_err(&port->dev, 521 + "Couldn't allocate urb wrapper\n"); 532 522 goto no_tx_wrap; 533 523 } 534 524 usb_fill_bulk_urb(urb, serial->dev, ··· 548 534 command_info = kmalloc(sizeof(struct whiteheat_command_private), 549 535 GFP_KERNEL); 550 536 if (command_info == NULL) { 551 - err("%s: Out of memory for port structures\n", 552 - serial->type->description); 537 + dev_err(&serial->dev->dev, 538 + "%s: Out of memory for port structures\n", 539 + serial->type->description); 553 540 goto no_command_private; 554 541 } 555 542 ··· 567 552 568 553 no_firmware: 569 554 /* Firmware likely not running */ 570 - err("%s: Unable to retrieve firmware version, try replugging\n", 571 - serial->type->description); 572 - err("%s: If the firmware is not running (status led not blinking)\n", 573 - serial->type->description); 574 - err("%s: please contact support@connecttech.com\n", 575 - serial->type->description); 555 + dev_err(&serial->dev->dev, 556 + "%s: Unable to retrieve firmware version, try replugging\n", 557 + serial->type->description); 558 + dev_err(&serial->dev->dev, 559 + "%s: If the firmware is not running (status led not blinking)\n", 560 + serial->type->description); 561 + dev_err(&serial->dev->dev, 562 + "%s: please contact support@connecttech.com\n", 563 + serial->type->description); 576 564 kfree(result); 577 565 return -ENODEV; 578 566 ··· 698 680 /* Start reading from the device */ 699 681 retval = start_port_read(port); 700 682 if (retval) { 701 - err("%s - failed submitting read urb, error %d", 702 - __func__, retval); 683 + dev_err(&port->dev, 684 + "%s - failed submitting read urb, error %d\n", 685 + __func__, retval); 703 686 firm_close(port); 704 687 stop_command_port(port->serial); 705 688 goto exit; ··· 825 806 urb->transfer_buffer_length = bytes; 826 807 result = usb_submit_urb(urb, GFP_ATOMIC); 827 808 if (result) { 828 - err("%s - failed submitting write urb, error %d", 829 - __func__, result); 809 + dev_err(&port->dev, 810 + "%s - failed submitting write urb, error %d\n", 811 + __func__, result); 830 812 sent = result; 831 813 spin_lock_irqsave(&info->lock, flags); 832 814 list_add(tmp, &info->tx_urbs_free); ··· 1095 1075 wrap = urb_to_wrap(urb, &info->rx_urbs_submitted); 1096 1076 if (!wrap) { 1097 1077 spin_unlock(&info->lock); 1098 - err("%s - Not my urb!", __func__); 1078 + dev_err(&port->dev, "%s - Not my urb!\n", __func__); 1099 1079 return; 1100 1080 } 1101 1081 list_del(&wrap->list); ··· 1139 1119 wrap = urb_to_wrap(urb, &info->tx_urbs_submitted); 1140 1120 if (!wrap) { 1141 1121 spin_unlock(&info->lock); 1142 - err("%s - Not my urb!", __func__); 1122 + dev_err(&port->dev, "%s - Not my urb!\n", __func__); 1143 1123 return; 1144 1124 } 1145 1125 list_move(&wrap->list, &info->tx_urbs_free); ··· 1403 1383 command_port->read_urb->dev = serial->dev; 1404 1384 retval = usb_submit_urb(command_port->read_urb, GFP_KERNEL); 1405 1385 if (retval) { 1406 - err("%s - failed submitting read urb, error %d", 1407 - __func__, retval); 1386 + dev_err(&serial->dev->dev, 1387 + "%s - failed submitting read urb, error %d\n", 1388 + __func__, retval); 1408 1389 goto exit; 1409 1390 } 1410 1391 } ··· 1543 1522 urb->dev = port->serial->dev; 1544 1523 result = usb_submit_urb(urb, GFP_ATOMIC); 1545 1524 if (result) { 1546 - err("%s - failed resubmitting read urb, error %d", 1525 + dev_err(&port->dev, 1526 + "%s - failed resubmitting read urb, error %d\n", 1547 1527 __func__, result); 1548 1528 spin_lock_irqsave(&info->lock, flags); 1549 1529 list_add(tmp, &info->rx_urbs_free); ··· 1578 1556 retval = usb_register(&whiteheat_driver); 1579 1557 if (retval) 1580 1558 goto failed_usb_register; 1581 - info(DRIVER_DESC " " DRIVER_VERSION); 1559 + printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" 1560 + DRIVER_DESC "\n"); 1582 1561 return 0; 1583 1562 failed_usb_register: 1584 1563 usb_serial_deregister(&whiteheat_device);
+5 -4
drivers/usb/storage/onetouch.c
··· 78 78 resubmit: 79 79 retval = usb_submit_urb (urb, GFP_ATOMIC); 80 80 if (retval) 81 - err ("can't resubmit intr, %s-%s/input0, retval %d", 82 - onetouch->udev->bus->bus_name, 81 + dev_err(&dev->dev, "can't resubmit intr, %s-%s/input0, " 82 + "retval %d\n", onetouch->udev->bus->bus_name, 83 83 onetouch->udev->devpath, retval); 84 84 } 85 85 ··· 90 90 onetouch->is_open = 1; 91 91 onetouch->irq->dev = onetouch->udev; 92 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 94 return -EIO; 95 95 } 96 96 ··· 117 117 break; 118 118 case US_RESUME: 119 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 122 break; 122 123 default: 123 124 break;
+1 -1
drivers/usb/storage/transport.c
··· 663 663 } 664 664 665 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 667 scsi_bufflen(srb) - scsi_get_resid(srb) < srb->underflow) 668 668 srb->result = (DID_ERROR << 16) | (SUGGEST_RETRY << 24); 669 669
+7
include/linux/usb.h
··· 1135 1135 struct list_head urb_list; 1136 1136 wait_queue_head_t wait; 1137 1137 spinlock_t lock; 1138 + unsigned int poisoned:1; 1138 1139 }; 1139 1140 1140 1141 static inline void init_usb_anchor(struct usb_anchor *anchor) ··· 1460 1459 extern int usb_submit_urb(struct urb *urb, gfp_t mem_flags); 1461 1460 extern int usb_unlink_urb(struct urb *urb); 1462 1461 extern void usb_kill_urb(struct urb *urb); 1462 + extern void usb_poison_urb(struct urb *urb); 1463 + extern void usb_unpoison_urb(struct urb *urb); 1463 1464 extern void usb_kill_anchored_urbs(struct usb_anchor *anchor); 1465 + extern void usb_poison_anchored_urbs(struct usb_anchor *anchor); 1464 1466 extern void usb_unlink_anchored_urbs(struct usb_anchor *anchor); 1465 1467 extern void usb_anchor_urb(struct urb *urb, struct usb_anchor *anchor); 1466 1468 extern void usb_unanchor_urb(struct urb *urb); 1467 1469 extern int usb_wait_anchor_empty_timeout(struct usb_anchor *anchor, 1468 1470 unsigned int timeout); 1471 + extern struct urb *usb_get_from_anchor(struct usb_anchor *anchor); 1472 + extern void usb_scuttle_anchored_urbs(struct usb_anchor *anchor); 1473 + extern int usb_anchor_empty(struct usb_anchor *anchor); 1469 1474 1470 1475 /** 1471 1476 * usb_urb_dir_in - check if an URB describes an IN transfer
+2 -1
include/linux/usb/Kbuild
··· 4 4 header-y += gadgetfs.h 5 5 header-y += midi.h 6 6 header-y += g_printer.h 7 - 7 + header-y += tmc.h 8 + header-y += vstusb.h
+9
include/linux/usb/cdc.h
··· 160 160 __u8 bDetailData[0]; 161 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 /*
+9 -2
include/linux/usb/composite.h
··· 130 130 131 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 136 int usb_interface_id(struct usb_configuration *, struct usb_function *); 134 137 135 138 /** ··· 319 316 struct usb_composite_driver *driver; 320 317 u8 next_string_id; 321 318 322 - spinlock_t lock; 319 + /* the gadget driver won't enable the data pullup 320 + * while the deactivation count is nonzero. 321 + */ 322 + unsigned deactivations; 323 323 324 - /* REVISIT use and existence of lock ... */ 324 + /* protects at least deactivation count */ 325 + spinlock_t lock; 325 326 }; 326 327 327 328 extern int usb_string_id(struct usb_composite_dev *c);
+1 -1
include/linux/usb/serial.h
··· 192 192 * The driver.owner field should be set to the module owner of this driver. 193 193 * The driver.name field should be set to the name of this driver (remember 194 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 197 struct usb_serial_driver { 198 198 const char *description;
+43
include/linux/usb/tmc.h
··· 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
+71
include/linux/usb/vstusb.h
··· 1 + /***************************************************************************** 2 + * File: drivers/usb/misc/vstusb.h 3 + * 4 + * Purpose: Support for the bulk USB Vernier Spectrophotometers 5 + * 6 + * Author: EQware Engineering, Inc. 7 + * Oregon City, OR, USA 97045 8 + * 9 + * Copyright: 2007, 2008 10 + * Vernier Software & Technology 11 + * Beaverton, OR, USA 97005 12 + * 13 + * Web: www.vernier.com 14 + * 15 + * This program is free software; you can redistribute it and/or modify 16 + * it under the terms of the GNU General Public License version 2 as 17 + * published by the Free Software Foundation. 18 + * 19 + *****************************************************************************/ 20 + /***************************************************************************** 21 + * 22 + * The vstusb module is a standard usb 'client' driver running on top of the 23 + * standard usb host controller stack. 24 + * 25 + * In general, vstusb supports standard bulk usb pipes. It supports multiple 26 + * devices and multiple pipes per device. 27 + * 28 + * The vstusb driver supports two interfaces: 29 + * 1 - ioctl SEND_PIPE/RECV_PIPE - a general bulk write/read msg 30 + * interface to any pipe with timeout support; 31 + * 2 - standard read/write with ioctl config - offers standard read/write 32 + * interface with ioctl configured pipes and timeouts. 33 + * 34 + * Both interfaces can be signal from other process and will abort its i/o 35 + * operation. 36 + * 37 + * A timeout of 0 means NO timeout. The user can still terminate the read via 38 + * signal. 39 + * 40 + * If using multiple threads with this driver, the user should ensure that 41 + * any reads, writes, or ioctls are complete before closing the device. 42 + * Changing read/write timeouts or pipes takes effect on next read/write. 43 + * 44 + *****************************************************************************/ 45 + 46 + struct vstusb_args { 47 + union { 48 + /* this struct is used for IOCTL_VSTUSB_SEND_PIPE, * 49 + * IOCTL_VSTUSB_RECV_PIPE, and read()/write() fops */ 50 + struct { 51 + void __user *buffer; 52 + size_t count; 53 + unsigned int timeout_ms; 54 + int pipe; 55 + }; 56 + 57 + /* this one is used for IOCTL_VSTUSB_CONFIG_RW */ 58 + struct { 59 + int rd_pipe; 60 + int rd_timeout_ms; 61 + int wr_pipe; 62 + int wr_timeout_ms; 63 + }; 64 + }; 65 + }; 66 + 67 + #define VST_IOC_MAGIC 'L' 68 + #define VST_IOC_FIRST 0x20 69 + #define IOCTL_VSTUSB_SEND_PIPE _IO(VST_IOC_MAGIC, VST_IOC_FIRST) 70 + #define IOCTL_VSTUSB_RECV_PIPE _IO(VST_IOC_MAGIC, VST_IOC_FIRST + 1) 71 + #define IOCTL_VSTUSB_CONFIG_RW _IO(VST_IOC_MAGIC, VST_IOC_FIRST + 2)